Commit 659f3d46 authored by Jan Möbius's avatar Jan Möbius
Browse files

More works towards multiview

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4016 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6313aace
...@@ -54,7 +54,12 @@ static BaseObject* objectRoot_; ...@@ -54,7 +54,12 @@ static BaseObject* objectRoot_;
* *
* This pointer is internally used to acces the examiner widget in the main apllication * This pointer is internally used to acces the examiner widget in the main apllication
*/ */
static ACG::QtWidgets::QtExaminerViewer* examiner_widget_; static std::vector< ACG::QtWidgets::QtExaminerViewer* > examiner_widgets_;
/// TODO : Remove this variable and implement multiView correctly here
static ACG::QtWidgets::QtExaminerViewer* examiner_widget_;
static unsigned int activeExaminer_ = 0;
/** \brief DONT USE DIRECTLY!! /** \brief DONT USE DIRECTLY!!
* *
...@@ -68,8 +73,13 @@ void setDataRoot( BaseObject* _root ) { ...@@ -68,8 +73,13 @@ void setDataRoot( BaseObject* _root ) {
objectRoot_ = _root; objectRoot_ = _root;
} }
void set_examiner( ACG::QtWidgets::QtExaminerViewer* _examiner_widget ) { void set_examiner( std::vector< ACG::QtWidgets::QtExaminerViewer* > _examiner_widgets ) {
PluginFunctions::examiner_widget_ = _examiner_widget; PluginFunctions::examiner_widgets_ = _examiner_widgets;
PluginFunctions::examiner_widget_ = examiner_widgets_[0];
}
void setActiveExaminer( unsigned int _id ) {
activeExaminer_ = _id;
} }
void set_rootNode( SeparatorNode* _root_node ) { void set_rootNode( SeparatorNode* _root_node ) {
...@@ -348,15 +358,15 @@ bool get_all_object_identifiers( std::vector<int>& _identifiers ) { ...@@ -348,15 +358,15 @@ bool get_all_object_identifiers( std::vector<int>& _identifiers ) {
} }
void setBackColor( OpenMesh::Vec4f _color) { void setBackColor( OpenMesh::Vec4f _color) {
examiner_widget_->backgroundColor(_color); examiner_widgets_[activeExaminer_]->backgroundColor(_color);
} }
QPoint mapToGlobal(QPoint _point ) { QPoint mapToGlobal(QPoint _point ) {
return examiner_widget_->glMapToGlobal(_point); return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point);
} }
QPoint mapToLocal( QPoint _point ) { QPoint mapToLocal( QPoint _point ) {
return examiner_widget_->glMapFromGlobal(_point); return examiner_widgets_[activeExaminer_]->glMapFromGlobal(_point);
} }
/** Set the draw Mode of the examiner widget.\n /** Set the draw Mode of the examiner widget.\n
...@@ -365,8 +375,10 @@ QPoint mapToLocal( QPoint _point ) { ...@@ -365,8 +375,10 @@ QPoint mapToLocal( QPoint _point ) {
* They can be combined. * They can be combined.
*/ */
void setDrawMode( unsigned int _mode ) { void setDrawMode( unsigned int _mode ) {
examiner_widget_->drawMode(_mode); for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i ) {
examiner_widget_->updateGL(); examiner_widgets_[i]->drawMode(_mode);
examiner_widgets_[i]->updateGL();
}
} }
/** Get the current draw Mode of the examiner widget.\n /** Get the current draw Mode of the examiner widget.\n
...@@ -379,21 +391,54 @@ unsigned int drawMode( ) { ...@@ -379,21 +391,54 @@ unsigned int drawMode( ) {
} }
bool scenegraph_pick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) { bool scenegraph_pick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
return examiner_widget_->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
return examiner_widgets_[activeExaminer_]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
}
bool scenegraph_pick( unsigned int _examiner, ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
if ( _examiner >= examiner_widgets_.size() ) {
std::cerr << "Wrong examiner id" << std::endl;
return false;
}
return examiner_widgets_[_examiner]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
} }
//Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!! //Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!!
void traverse( ACG::SceneGraph::MouseEventAction &_action ) { void traverse( ACG::SceneGraph::MouseEventAction &_action ) {
ACG::SceneGraph::traverse(PluginFunctions::examiner_widget_->sceneGraph(), _action,PluginFunctions::examiner_widget_->glState() ); ACG::SceneGraph::traverse(PluginFunctions::examiner_widgets_[activeExaminer_]->sceneGraph(),
_action,PluginFunctions::examiner_widgets_[activeExaminer_]->glState() );
} }
//Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!!
void traverse( unsigned int _examiner, ACG::SceneGraph::MouseEventAction &_action ) {
if ( _examiner >= examiner_widgets_.size() ) {
std::cerr << "Wrong examiner id" << std::endl;
return;
}
ACG::SceneGraph::traverse(PluginFunctions::examiner_widgets_[_examiner]->sceneGraph(), _action,PluginFunctions::examiner_widgets_[_examiner]->glState() );
}
const std::string & pickMode () { const std::string & pickMode () {
return examiner_widget_->pickMode(); return examiner_widget_->pickMode();
} }
void pickMode ( std::string _mode) { void pickMode ( std::string _mode) {
examiner_widget_->pickMode(_mode); for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i )
examiner_widgets_[i]->pickMode(_mode);
}
void pickMode ( unsigned int _examiner, std::string _mode) {
if ( _examiner >= examiner_widgets_.size() ) {
std::cerr << "Wrong examiner id" << std::endl;
return;
}
examiner_widgets_[_examiner]->pickMode(_mode);
} }
void actionMode ( ACG::QtWidgets::QtBaseViewer::ActionMode _mode) { void actionMode ( ACG::QtWidgets::QtBaseViewer::ActionMode _mode) {
...@@ -578,143 +623,6 @@ void flyTo (const TriMesh::Point &_position, const TriMesh::Point &_center, do ...@@ -578,143 +623,6 @@ void flyTo (const TriMesh::Point &_position, const TriMesh::Point &_center, do
} }
ObjectIterator::ObjectIterator( IteratorRestriction _restriction , DataType _dataType) {
// Initialize with invalid pos
pos_ = 0;
// Store the restriction for the operator ( Source/Target )
restriction_ = _restriction;
// Store the requested DataType
dataType_ = _dataType;
// Start at the root Node
BaseObject* currentPos = objectRoot_->next();
// Go through the tree and stop at the root node or if we found a baseObjectData Object
while ( (currentPos != objectRoot_) && !dynamic_cast<BaseObjectData* > (currentPos) )
currentPos = currentPos->next();
if (currentPos == objectRoot_)
return;
while ( (currentPos != objectRoot_) ) {
// Return only target objects if requested
if ( (restriction_ == TARGET_OBJECTS) && (! currentPos->target() ) ) {
currentPos = currentPos->next();
continue;
}
// Return only source objects if requested
if ( (restriction_ == SOURCE_OBJECTS) && (! currentPos->source() ) ) {
currentPos = currentPos->next();
continue;
}
// Return only the right dataType
if ( _dataType != DATA_ALL )
if ( ! (currentPos->dataType( dataType_ ) ) ) {
currentPos = currentPos->next();
continue;
}
// found a valid object
pos_ = dynamic_cast<BaseObjectData* > (currentPos);
break;
}
}
ObjectIterator::ObjectIterator(BaseObjectData* pos, IteratorRestriction _restriction , DataType _data)
{
restriction_ = _restriction;
pos_ = pos;
dataType_ = _data;
};
bool ObjectIterator::operator==( const ObjectIterator& _rhs) {
std::cerr << "==" << std::endl;
return ( _rhs.pos_ == pos_ );
}
bool ObjectIterator::operator!=( const ObjectIterator& _rhs) {
return ( _rhs.pos_ != pos_ );
}
ObjectIterator& ObjectIterator::operator=( const ObjectIterator& _rhs) {
pos_ = _rhs.pos_;
return *this;
}
ObjectIterator::pointer ObjectIterator::operator->(){
return pos_;
}
ObjectIterator& ObjectIterator::operator++() {
// Convert our pointer to the basic one
BaseObject* currentPos = dynamic_cast< BaseObject* >(pos_);
// Get the next element in the tree
currentPos = currentPos->next();
while ( (currentPos != objectRoot_) ) {
// Return only target objects if requested
if ( (restriction_ == TARGET_OBJECTS) && (! currentPos->target() ) ) {
currentPos = currentPos->next();
continue;
}
// Return only source objects if requested
if ( (restriction_ == SOURCE_OBJECTS) && (! currentPos->source() ) ) {
currentPos = currentPos->next();
continue;
}
// Return only the right dataType
if ( ! (currentPos->dataType( dataType_ ) ) ) {
currentPos = currentPos->next();
continue;
}
// found a valid object
pos_ = dynamic_cast<BaseObjectData* > (currentPos);
return *this;
}
// No valid object found
pos_ = 0;
return *this;
}
ObjectIterator& ObjectIterator::operator--() {
std::cerr << "TODO :--" << std::endl;
return *this;
}
/** This operator returns a pointer to the current object the iterator
* points to.
*
* @return Pointer to the current ObjectData
*/
BaseObjectData* ObjectIterator::operator*() {
return pos_;
}
/// Return Iterator to Object End
ObjectIterator objects_end() {
return ObjectIterator(0);
};
// =============================================================================== // ===============================================================================
// Getting data from objects and casting between them // Getting data from objects and casting between them
// =============================================================================== // ===============================================================================
...@@ -771,7 +679,7 @@ PolyMeshObject* polyMeshObject( BaseObjectData* _object ) { ...@@ -771,7 +679,7 @@ PolyMeshObject* polyMeshObject( BaseObjectData* _object ) {
// =============================================================================== // ===============================================================================
// Get the root of the object structure // Get the root of the object structure
// =============================================================================== // ===============================================================================
BaseObject* objectRoot() { BaseObject*& objectRoot() {
return (objectRoot_); return (objectRoot_);
} }
......
...@@ -286,7 +286,11 @@ bool get_property_handle(MeshT* _mesh , QString _name, OpenMesh::HPropHandleT< p ...@@ -286,7 +286,11 @@ bool get_property_handle(MeshT* _mesh , QString _name, OpenMesh::HPropHandleT< p
//======================================= //=======================================
/// Set the internal examiner pointer ( DO NOT USE!! ) /// Set the internal examiner pointer ( DO NOT USE!! )
DLLEXPORT DLLEXPORT
void set_examiner( ACG::QtWidgets::QtExaminerViewer* examiner_widget_ ); void set_examiner( std::vector< ACG::QtWidgets::QtExaminerViewer* > _examiner_widgets );
/// Set the active id of the examiner which got the last mouse events
DLLEXPORT
void setActiveExaminer( unsigned int _id );
/// Set the internal scenegraph root node pointer ( DO NOT USE!! ) /// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT DLLEXPORT
...@@ -296,22 +300,36 @@ void set_sceneGraphRootNode( SeparatorNode* _root_node ); ...@@ -296,22 +300,36 @@ void set_sceneGraphRootNode( SeparatorNode* _root_node );
DLLEXPORT DLLEXPORT
void set_rootNode( SeparatorNode* _root_node ); void set_rootNode( SeparatorNode* _root_node );
/// Execute picking operation on scenegraph /** Execute picking operation on scenegraph
* This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core
*/
DLLEXPORT DLLEXPORT
bool scenegraph_pick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr ); bool scenegraph_pick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr );
/// Execute Scenegraph traversal with action DLLEXPORT
bool scenegraph_pick( unsigned int _examiner ,ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr );
/// Execute Scenegraph traversal with action and use the last active examiner
DLLEXPORT DLLEXPORT
void traverse( ACG::SceneGraph::MouseEventAction &_action ); void traverse( ACG::SceneGraph::MouseEventAction &_action );
/// Execute Scenegraph traversal with action and a specified examiner
void traverse( unsigned int _examiner, ACG::SceneGraph::MouseEventAction &_action );
/// Get the current Picking mode /// Get the current Picking mode
DLLEXPORT DLLEXPORT
const std::string & pickMode (); const std::string & pickMode ();
/// Set the current Picking mode /// Set the current Picking mode for all examiner widgets
DLLEXPORT DLLEXPORT
void pickMode ( std::string _mode); void pickMode ( std::string _mode);
/// Set pick mode for a specific examiner
DLLEXPORT
void pickMode ( unsigned int _examiner, std::string _mode);
/// Get the current gl state from examiner /// Get the current gl state from examiner
DLLEXPORT DLLEXPORT
ACG::GLState& glState(); ACG::GLState& glState();
...@@ -659,7 +677,7 @@ BaseObjectData* baseObjectData( BaseObject* _object ); ...@@ -659,7 +677,7 @@ BaseObjectData* baseObjectData( BaseObject* _object );
/// Get the root of the object structure /// Get the root of the object structure
DLLEXPORT DLLEXPORT
BaseObject* objectRoot(); BaseObject*& objectRoot();
} }
......
...@@ -192,12 +192,7 @@ Core::init() { ...@@ -192,12 +192,7 @@ Core::init() {
// Make examiner available to the plugins ( defined in PluginFunctions.hh) // Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_examiner( coreWidget_->examiner_widgets_[0] ); PluginFunctions::set_examiner( coreWidget_->examiner_widgets_ );
if ( OpenFlipper::Options::multiView() ) {
std::cerr << "Todo : Pluginfunctions set multiple examiners" << std::endl;
}
} }
...@@ -393,12 +388,14 @@ Core::init() { ...@@ -393,12 +388,14 @@ Core::init() {
else else
coreWidget_->setViewMode("All"); coreWidget_->setViewMode("All");
connect( coreWidget_->examiner_widget_, SIGNAL(signalMouseEvent(QMouseEvent*)), for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
this,SLOT(slotMouseEvent(QMouseEvent*))); connect( coreWidget_->examiner_widgets_[i], SIGNAL(signalMouseEvent(QMouseEvent*)),
connect( coreWidget_->examiner_widget_, SIGNAL(signalMouseEventIdentify(QMouseEvent*)), this , SLOT(slotMouseEvent(QMouseEvent*)));
this,SLOT(slotMouseEventIdentify(QMouseEvent*))); connect( coreWidget_->examiner_widgets_[i], SIGNAL(signalMouseEventIdentify(QMouseEvent*)),
connect( coreWidget_->examiner_widget_, SIGNAL(signalWheelEvent(QWheelEvent *, const std::string &)), this , SLOT(slotMouseEventIdentify(QMouseEvent*)));
this, SLOT(slotWheelEvent(QWheelEvent *, const std::string &))); connect( coreWidget_->examiner_widgets_[i], SIGNAL(signalWheelEvent(QWheelEvent *, const std::string &)),
this , SLOT(slotWheelEvent(QWheelEvent *, const std::string &)));
}
} }
...@@ -491,7 +488,26 @@ Core::slotMouseEventIdentify( QMouseEvent* _event ) ...@@ -491,7 +488,26 @@ Core::slotMouseEventIdentify( QMouseEvent* _event )
// if ( _event->button() == Qt::RightButton ) // if ( _event->button() == Qt::RightButton )
// return; // return;
const QObject* senderPointer = sender();
unsigned int examinerId = 0;
if ( senderPointer == 0 ) {
std::cerr << "Error : slotMouseEventIdentify directly called! This should only be called by an examiner" << std::endl;
} else {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == coreWidget_->examiner_widgets_[i] ) {
examinerId = i;
break;
}
}
}
PluginFunctions::setActiveExaminer( examinerId );
emit PluginMouseEventIdentify( _event ); emit PluginMouseEventIdentify( _event );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -504,6 +520,23 @@ Core::slotMouseEvent( QMouseEvent* _event ) ...@@ -504,6 +520,23 @@ Core::slotMouseEvent( QMouseEvent* _event )
// if ( _event->button() == Qt::RightButton ) // if ( _event->button() == Qt::RightButton )
// return; // return;
const QObject* senderPointer = sender();
unsigned int examinerId = 0;
if ( senderPointer == 0 ) {
std::cerr << "Error : slotMouseEvent directly called! This should only be called by an examiner" << std::endl;
} else {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == coreWidget_->examiner_widgets_[i] ) {
examinerId = i;
break;
}
}
}
PluginFunctions::setActiveExaminer( examinerId );
emit PluginMouseEvent(_event ); emit PluginMouseEvent(_event );
} }
...@@ -512,6 +545,23 @@ Core::slotMouseEvent( QMouseEvent* _event ) ...@@ -512,6 +545,23 @@ Core::slotMouseEvent( QMouseEvent* _event )
void void
Core::slotWheelEvent( QWheelEvent * _event, const std::string & _mode) Core::slotWheelEvent( QWheelEvent * _event, const std::string & _mode)
{ {
const QObject* senderPointer = sender();
unsigned int examinerId = 0;
if ( senderPointer == 0 ) {
std::cerr << "Error : slotWheelEvent directly called! This should only be called by an examiner" << std::endl;
} else {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == coreWidget_->examiner_widgets_[i] ) {
examinerId = i;
break;
}
}
}
PluginFunctions::setActiveExaminer( examinerId );
emit PluginWheelEvent(_event , _mode ); emit PluginWheelEvent(_event , _mode );
} }
...@@ -520,15 +570,20 @@ Core::slotWheelEvent( QWheelEvent * _event, const std::string & _mode) ...@@ -520,15 +570,20 @@ Core::slotWheelEvent( QWheelEvent * _event, const std::string & _mode)
void void
Core::slotAddPickMode( const std::string _mode ) { Core::slotAddPickMode( const std::string _mode ) {
if ( OpenFlipper::Options::gui() ) if ( OpenFlipper::Options::gui() )
coreWidget_->examiner_widget_->addPickMode(_mode); for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i )
coreWidget_->examiner_widgets_[i]->addPickMode(_mode);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
Core::slotAddHiddenPickMode( const std::string _mode ) { Core::slotAddHiddenPickMode( const std::string _mode ) {
if ( OpenFlipper::Options::gui() ) if ( OpenFlipper::Options::gui() )
coreWidget_->examiner_widget_->addPickMode(_mode,false,1000,false); for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i )
coreWidget_->examiner_widgets_[i]->addPickMode(_mode,false,1000,false);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -750,11 +805,12 @@ void Core::slotExit() { ...@@ -750,11 +805,12 @@ void Core::slotExit() {
/// Synchronise two viewers /// Synchronise two viewers
bool Core::add_sync_host(const QString& _name) bool Core::add_sync_host(const QString& _name)
{ {
// Todo : Only syncing one Viewer
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
emit log(LOGINFO,"Adding SyncHost"); emit log(LOGINFO,"Adding SyncHost");
bool ok = coreWidget_->examiner_widget_->add_sync_host(_name); bool ok = coreWidget_->examiner_widgets_[0]->add_sync_host(_name);
if (ok) if (ok)
coreWidget_->examiner_widget_->setSynchronization(true); coreWidget_->examiner_widgets_[0]->setSynchronization(true);
else else
emit log(LOGERR,"Sync failed! "); emit log(LOGERR,"Sync failed! ");
return ok; return ok;
...@@ -889,14 +945,30 @@ void Core::slotGetDescription(QString _function, QString& _fnDescript ...@@ -889,14 +945,30 @@ void Core::slotGetDescription(QString _function, QString& _fnDescript
} }
} }
void Core::snapshotBaseFileName(const QString& _fname){ void Core::snapshotBaseFileName(const QString& _fname, unsigned int _viewerId ){
if ( OpenFlipper::Options::gui() )
coreWidget_->examiner_widget_->snapshotBaseFileName(_fname); if ( OpenFlipper::Options::gui() ) {
if ( _viewerId >= OpenFlipper::Options::examinerWidgets() ) {
emit log(LOGERR,"Unable to snapshotBaseFileName for viewer " + QString::number(_viewerId) );
return;
}
coreWidget_->examiner_widgets_[_viewerId]->snapshotBaseFileName( _fname );
}
} }
void Core::snapshot(){ void Core::snapshot( unsigned int _viewerId ){
if ( OpenFlipper::Options::gui() )
coreWidget_->examiner_widget_->snapshot();
if ( OpenFlipper::Options::gui() ) {
if ( _viewerId >= OpenFlipper::Options::examinerWidgets() ) {
emit log(LOGERR,"Unable to create snapshot for viewer " + QString::number(_viewerId) );
return;
}