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

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_;
*
* 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!!
*
......@@ -68,8 +73,13 @@ void setDataRoot( BaseObject* _root ) {
objectRoot_ = _root;
}
void set_examiner( ACG::QtWidgets::QtExaminerViewer* _examiner_widget ) {
PluginFunctions::examiner_widget_ = _examiner_widget;
void set_examiner( std::vector< ACG::QtWidgets::QtExaminerViewer* > _examiner_widgets ) {
PluginFunctions::examiner_widgets_ = _examiner_widgets;
PluginFunctions::examiner_widget_ = examiner_widgets_[0];
}
void setActiveExaminer( unsigned int _id ) {
activeExaminer_ = _id;
}
void set_rootNode( SeparatorNode* _root_node ) {
......@@ -348,15 +358,15 @@ bool get_all_object_identifiers( std::vector<int>& _identifiers ) {
}
void setBackColor( OpenMesh::Vec4f _color) {
examiner_widget_->backgroundColor(_color);
examiner_widgets_[activeExaminer_]->backgroundColor(_color);
}
QPoint mapToGlobal(QPoint _point ) {
return examiner_widget_->glMapToGlobal(_point);
return examiner_widgets_[activeExaminer_]->glMapToGlobal(_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
......@@ -365,8 +375,10 @@ QPoint mapToLocal( QPoint _point ) {
* They can be combined.
*/
void setDrawMode( unsigned int _mode ) {
examiner_widget_->drawMode(_mode);
examiner_widget_->updateGL();
for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i ) {
examiner_widgets_[i]->drawMode(_mode);
examiner_widgets_[i]->updateGL();
}
}
/** Get the current draw Mode of the examiner widget.\n
......@@ -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 ) {
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!!
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 () {
return examiner_widget_->pickMode();
}
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) {
......@@ -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
// ===============================================================================
......@@ -771,7 +679,7 @@ PolyMeshObject* polyMeshObject( BaseObjectData* _object ) {
// ===============================================================================
// Get the root of the object structure
// ===============================================================================
BaseObject* objectRoot() {
BaseObject*& objectRoot() {
return (objectRoot_);
}
......
......@@ -286,7 +286,11 @@ bool get_property_handle(MeshT* _mesh , QString _name, OpenMesh::HPropHandleT< p
//=======================================
/// Set the internal examiner pointer ( DO NOT USE!! )
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!! )
DLLEXPORT
......@@ -296,22 +300,36 @@ void set_sceneGraphRootNode( SeparatorNode* _root_node );
DLLEXPORT
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
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
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
DLLEXPORT
const std::string & pickMode ();
/// Set the current Picking mode
/// Set the current Picking mode for all examiner widgets
DLLEXPORT
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
DLLEXPORT
ACG::GLState& glState();
......@@ -659,7 +677,7 @@ BaseObjectData* baseObjectData( BaseObject* _object );
/// Get the root of the object structure
DLLEXPORT
BaseObject* objectRoot();
BaseObject*& objectRoot();
}
......
......@@ -192,12 +192,7 @@ Core::init() {
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_examiner( coreWidget_->examiner_widgets_[0] );
if ( OpenFlipper::Options::multiView() ) {
std::cerr << "Todo : Pluginfunctions set multiple examiners" << std::endl;
}
PluginFunctions::set_examiner( coreWidget_->examiner_widgets_ );
}
......@@ -393,12 +388,14 @@ Core::init() {
else
coreWidget_->setViewMode("All");
connect( coreWidget_->examiner_widget_, SIGNAL(signalMouseEvent(QMouseEvent*)),
this,SLOT(slotMouseEvent(QMouseEvent*)));
connect( coreWidget_->examiner_widget_, SIGNAL(signalMouseEventIdentify(QMouseEvent*)),
this,SLOT(slotMouseEventIdentify(QMouseEvent*)));
connect( coreWidget_->examiner_widget_, SIGNAL(signalWheelEvent(QWheelEvent *, const std::string &)),
this, SLOT(slotWheelEvent(QWheelEvent *, const std::string &)));
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
connect( coreWidget_->examiner_widgets_[i], SIGNAL(signalMouseEvent(QMouseEvent*)),
this , SLOT(slotMouseEvent(QMouseEvent*)));
connect( coreWidget_->examiner_widgets_[i], SIGNAL(signalMouseEventIdentify(QMouseEvent*)),
this , SLOT(slotMouseEventIdentify(QMouseEvent*)));
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 )
// if ( _event->button() == Qt::RightButton )
// 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 );
}
//-----------------------------------------------------------------------------
......@@ -504,6 +520,23 @@ Core::slotMouseEvent( QMouseEvent* _event )
// if ( _event->button() == Qt::RightButton )
// 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 );
}
......@@ -512,6 +545,23 @@ Core::slotMouseEvent( QMouseEvent* _event )
void
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 );
}
......@@ -520,15 +570,20 @@ Core::slotWheelEvent( QWheelEvent * _event, const std::string & _mode)
void
Core::slotAddPickMode( const std::string _mode ) {
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
Core::slotAddHiddenPickMode( const std::string _mode ) {
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() {
/// Synchronise two viewers
bool Core::add_sync_host(const QString& _name)
{
// Todo : Only syncing one Viewer
if ( OpenFlipper::Options::gui() ) {
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)
coreWidget_->examiner_widget_->setSynchronization(true);
coreWidget_->examiner_widgets_[0]->setSynchronization(true);
else
emit log(LOGERR,"Sync failed! ");
return ok;
......@@ -889,14 +945,30 @@ void Core::slotGetDescription(QString _function, QString& _fnDescript
}
}
void Core::snapshotBaseFileName(const QString& _fname){
if ( OpenFlipper::Options::gui() )
coreWidget_->examiner_widget_->snapshotBaseFileName(_fname);
void Core::snapshotBaseFileName(const QString& _fname, unsigned int _viewerId ){
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(){
if ( OpenFlipper::Options::gui() )
coreWidget_->examiner_widget_->snapshot();
void Core::snapshot( unsigned int _viewerId ){
if ( OpenFlipper::Options::gui() ) {
if ( _viewerId >= OpenFlipper::Options::examinerWidgets() ) {
emit log(LOGERR,"Unable to create snapshot for viewer " + QString::number(_viewerId) );
return;
}
coreWidget_->examiner_widgets_[_viewerId]->snapshot();
}
}
......
......@@ -293,13 +293,13 @@ public slots:
/// set the baseFilename for snapshots (a counter is automatically increased when
/// snapshot() is called)
void snapshotBaseFileName(const QString& _fname);
void snapshotBaseFileName(const QString& _fname, unsigned int _viewerId = 0);
/** Trigger a snapshot and increase the snapshot counter.
Save snapshot to file determined by snapshotBaseFileName() and
the current snapshot counter. The \a back buffer will be saved.
*/
void snapshot();
void snapshot(unsigned int _viewerId = 0);
/// resize the examinerViewer
void resizeViewer(int _width, int _height );
......
......@@ -51,8 +51,8 @@ void Core::resetScenegraph() {
coreWidget_->examiner_widgets_[i]->lockUpdate();
coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_);
coreWidget_->examiner_widgets_[i]->viewAll();
coreWidget_->examiner_widgets_[i]->setScenePos( coreWidget_->examiner_widget_->scene_center() ,
coreWidget_->examiner_widget_->scene_radius() /* 10.0*/ );
coreWidget_->examiner_widgets_[i]->setScenePos( coreWidget_->examiner_widgets_[i]->scene_center() ,
coreWidget_->examiner_widgets_[i]->scene_radius() /* 10.0*/ );
coreWidget_->examiner_widgets_[i]->setHome();
coreWidget_->examiner_widgets_[i]->drawMode( OpenFlipper::Options::standardDrawMode() );
......
......@@ -120,17 +120,19 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
if ( !OpenFlipper::Options::multiView() ) {
examiner_widget_ = new ACG::QtWidgets::QtExaminerViewer(stackedWidget_,
"Examiner Widget",
statusBar_ ,
&format);
ACG::QtWidgets::QtExaminerViewer* examinerWidget = new ACG::QtWidgets::QtExaminerViewer(stackedWidget_,
"Examiner Widget",
statusBar_ ,
&format);
examiner_widgets_.push_back(examiner_widget_);
examiner_widgets_.push_back(examinerWidget);
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examinerWidget->enablePopupMenu(false);
examiner_widget_->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widget_->enablePopupMenu(false);
stackedWidget_->addWidget(examinerWidget);
stackedWidget_->addWidget(examiner_widget_);
examiner_widget_ = examinerWidget;
} else {
......@@ -222,7 +224,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
viewerToolbar_->setIconSize(QSize(20,20));
viewerToolbar_->setObjectName("ViewerToolbar");
// Set our own Icons
// Set our own Icons and connect to additional examiner widgets
QList<QAction *> actions = viewerToolbar_->actions();
for ( int i = 0 ; i < actions.size(); ++i ) {
if ( actions[i]->text() == "Move" ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment