Commit f7c37d43 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4511 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bf92191c
...@@ -65,7 +65,7 @@ class GlobalAccessInterface { ...@@ -65,7 +65,7 @@ class GlobalAccessInterface {
* This function is called to set a pointer to the global examiner Widget.\n * This function is called to set a pointer to the global examiner Widget.\n
* @param _examiner_widget Pointer to the Examiner Widget in the Main app * @param _examiner_widget Pointer to the Examiner Widget in the Main app
*/ */
virtual void set_examiner( QtBaseViewer* /*_examiner_widget*/) = 0; virtual void set_examiner( glViewer* /*_examiner_widget*/) = 0;
}; };
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
#include "PluginFunctions.hh" #include "PluginFunctions.hh"
#include "PluginFunctionsCore.hh"
namespace PluginFunctions { namespace PluginFunctions {
...@@ -54,10 +55,10 @@ static BaseObject* objectRoot_; ...@@ -54,10 +55,10 @@ 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 std::vector< QtBaseViewer* > examiner_widgets_; static std::vector< glViewer* > examiner_widgets_;
/// TODO : Remove this variable and implement multiView correctly here /// TODO : Remove this variable and implement multiView correctly here
static QtBaseViewer* examiner_widget_; static glViewer* examiner_widget_;
static unsigned int activeExaminer_ = 0; static unsigned int activeExaminer_ = 0;
...@@ -69,11 +70,13 @@ static SeparatorNode* root_node_; ...@@ -69,11 +70,13 @@ static SeparatorNode* root_node_;
static SeparatorNode* sceneGraph_root_node_; static SeparatorNode* sceneGraph_root_node_;
static Viewer::ViewerProperties dummyProperties;
void setDataRoot( BaseObject* _root ) { void setDataRoot( BaseObject* _root ) {
objectRoot_ = _root; objectRoot_ = _root;
} }
void set_examiner( std::vector< QtBaseViewer* > _examiner_widgets ) { void setViewers( std::vector< glViewer* > _examiner_widgets ) {
PluginFunctions::examiner_widgets_ = _examiner_widgets; PluginFunctions::examiner_widgets_ = _examiner_widgets;
PluginFunctions::examiner_widget_ = examiner_widgets_[0]; PluginFunctions::examiner_widget_ = examiner_widgets_[0];
} }
...@@ -86,11 +89,11 @@ unsigned int activeExaminer( ) { ...@@ -86,11 +89,11 @@ unsigned int activeExaminer( ) {
return activeExaminer_; return activeExaminer_;
} }
void set_rootNode( SeparatorNode* _root_node ) { void setRootNode( SeparatorNode* _root_node ) {
PluginFunctions::root_node_ = _root_node; PluginFunctions::root_node_ = _root_node;
} }
void set_sceneGraphRootNode( SeparatorNode* _root_node ) { void setSceneGraphRootNode( SeparatorNode* _root_node ) {
PluginFunctions::sceneGraph_root_node_ = _root_node; PluginFunctions::sceneGraph_root_node_ = _root_node;
} }
...@@ -334,9 +337,10 @@ void pickMode ( const unsigned int _examiner, std::string _mode) { ...@@ -334,9 +337,10 @@ void pickMode ( const unsigned int _examiner, std::string _mode) {
examiner_widgets_[_examiner]->pickMode(_mode); examiner_widgets_[_examiner]->pickMode(_mode);
} }
void actionMode ( QtBaseViewer::ActionMode _mode) { void actionMode ( Viewer::ActionMode _mode) {
for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i ) for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i )
examiner_widgets_[i]->actionMode(_mode); viewerProperties(i).actionMode(_mode);
} }
ACG::GLState& glState() { ACG::GLState& glState() {
...@@ -347,8 +351,21 @@ void getCurrentViewImage(QImage& _image) { ...@@ -347,8 +351,21 @@ void getCurrentViewImage(QImage& _image) {
examiner_widget_->copyToImage( _image ); examiner_widget_->copyToImage( _image );
} }
QtBaseViewer::ActionMode actionMode() { Viewer::ActionMode actionMode() {
return examiner_widget_->actionMode(); return viewerProperties(activeExaminer_).actionMode();
}
Viewer::ViewerProperties& viewerProperties(int _id) {
if ( _id >= (int)examiner_widgets_.size() ) {
std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
return dummyProperties;
}
if ( _id == -1 )
_id = activeExaminer_;
return (*examiner_widgets_[_id]->properties());
} }
void perspectiveProjection() { void perspectiveProjection() {
......
...@@ -49,9 +49,10 @@ ...@@ -49,9 +49,10 @@
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
// #include <ACG/Math/VectorT.hh> #include <ACG/Scenegraph/SceneGraph.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> // #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <ACG/GL/GLState.hh> #include <ACG/GL/GLState.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
/** The Namespace PluginFunctions contains functions for all plugins. These functions should be used to get the /** The Namespace PluginFunctions contains functions for all plugins. These functions should be used to get the
* objects to work on or to set modes in the examiner widget. */ * objects to work on or to set modes in the examiner widget. */
...@@ -191,9 +192,6 @@ int visible_count(); ...@@ -191,9 +192,6 @@ int visible_count();
/** @name Examiner handling /** @name Examiner handling
* @{ */ * @{ */
//======================================= //=======================================
/// Set the internal examiner pointer ( DO NOT USE!! )
DLLEXPORT
void set_examiner( std::vector< QtBaseViewer* > _examiner_widgets );
/// Set the active id of the examiner which got the last mouse events /// Set the active id of the examiner which got the last mouse events
DLLEXPORT DLLEXPORT
...@@ -203,14 +201,6 @@ void setActiveExaminer( const unsigned int _id ); ...@@ -203,14 +201,6 @@ void setActiveExaminer( const unsigned int _id );
DLLEXPORT DLLEXPORT
unsigned int activeExaminer(); unsigned int activeExaminer();
/// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT
void set_sceneGraphRootNode( SeparatorNode* _root_node );
/// Set the internal data root node pointer ( DO NOT USE!! )
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 * This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core * Set by mouseevents from the core
...@@ -272,11 +262,20 @@ void addGlobalNode(ACG::SceneGraph::BaseNode* _node); ...@@ -272,11 +262,20 @@ void addGlobalNode(ACG::SceneGraph::BaseNode* _node);
/// Set the current Action Mode (PickMode,ExamineMode,...) /// Set the current Action Mode (PickMode,ExamineMode,...)
DLLEXPORT DLLEXPORT
void actionMode ( QtBaseViewer::ActionMode _mode); void actionMode ( Viewer::ActionMode _mode);
/// Get the current Action mode /// Get the current Action mode
DLLEXPORT DLLEXPORT
QtBaseViewer::ActionMode actionMode(); Viewer::ActionMode actionMode();
/** Get the viewer properties
* -1 will get the properties of the active Viewer which is the default
*/
DLLEXPORT
Viewer::ViewerProperties& viewerProperties(int _id = -1);
/** Lock scene rotation via mouse /** Lock scene rotation via mouse
* *
......
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 4482 $
// $Author: moebius $
// $Date: 2009-01-28 11:12:14 +0100 (Mi, 28. Jan 2009) $
//
//=============================================================================
//=============================================================================
//
// Standard Functions
//
//=============================================================================
/**
* \file PluginFunctions.hh
* This file contains functions to setup the internal structures for PluginFunctions.
* Dont Use these Functions in your Plugins!
*/
//
#ifndef PLUGINFUNCTIONSCORE_HH
#define PLUGINFUNCTIONSCORE_HH
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
namespace PluginFunctions {
//=======================================
// Set pointers for global handling in PluginFunctions without exporting them to the Plugins
/** @name Setup Functions
* @{ */
//=======================================
/// Set the internal examiner pointer ( DO NOT USE!! )
DLLEXPORT
void setViewers( std::vector< glViewer* > _examiner_widgets );
/// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT
void setSceneGraphRootNode( SeparatorNode* _root_node );
/// Set the internal data root node pointer ( DO NOT USE!! )
DLLEXPORT
void setRootNode( SeparatorNode* _root_node );
/** @} */
}
#endif //PLUGINFUNCTIONSCORE_HH
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include <ACG/Scenegraph/SeparatorNode.hh> #include <ACG/Scenegraph/SeparatorNode.hh>
#include "OpenFlipper/BasePlugin/PluginFunctions.hh" #include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include "OpenFlipper/BasePlugin/PluginFunctionsCore.hh"
#include <OpenMesh/Core/System/omstream.hh> #include <OpenMesh/Core/System/omstream.hh>
...@@ -141,9 +142,9 @@ void ...@@ -141,9 +142,9 @@ void
Core::init() { Core::init() {
// Make root_node available to the plugins ( defined in PluginFunctions.hh) // Make root_node available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_rootNode( root_node_ ); PluginFunctions::setRootNode( root_node_ );
PluginFunctions::set_sceneGraphRootNode( root_node_scenegraph_ ); PluginFunctions::setSceneGraphRootNode( root_node_scenegraph_ );
// Initialize the first object as the root Object for the object tree // Initialize the first object as the root Object for the object tree
objectRoot_ = dynamic_cast< BaseObject* > ( new GroupObject("ObjectRoot") ); objectRoot_ = dynamic_cast< BaseObject* > ( new GroupObject("ObjectRoot") );
...@@ -200,10 +201,6 @@ Core::init() { ...@@ -200,10 +201,6 @@ Core::init() {
coreWidget_->setWindowTitle( OpenFlipper::Options::windowTitle() ); coreWidget_->setWindowTitle( OpenFlipper::Options::windowTitle() );
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_examiner( coreWidget_->examiner_widgets_ );
} }
// ====================================================================== // ======================================================================
......
This diff is collapsed.
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 4482 $
// $Author: moebius $
// $Date: 2009-01-28 11:12:14 +0100 (Mi, 28. Jan 2009) $
//
//=============================================================================
//=============================================================================
//
// Property storage Class for glWidgets
//
//=============================================================================
#include <OpenFlipper/common/GlobalDefines.hh>
#include "ViewerProperties.hh"
#include <iostream>
namespace Viewer {
ViewerProperties::ViewerProperties():
actionMode_(Viewer::PickingMode),
lastActionMode_(Viewer::PickingMode)
{
}
ViewerProperties::~ViewerProperties() {
}
void ViewerProperties::actionMode(Viewer::ActionMode _am) {
std::cerr << "ActionModeChanged" << std::endl;
if (_am != actionMode_) {
lastActionMode_ = actionMode_;
actionMode_ = _am;
emit actionModeChanged(_am);
}
}
}
\ No newline at end of file
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 4482 $
// $Author: moebius $
// $Date: 2009-01-28 11:12:14 +0100 (Mi, 28. Jan 2009) $
//
//=============================================================================
//=============================================================================
//
// Property storage Class for glWidgets
//
//=============================================================================
/**
* \file ViewerProperties.hh
* This file contains a class for managing all viewer settings
*/
//
#ifndef VIEWERPROPERTIES_HH
#define VIEWERPROPERTIES_HH
#include <QObject>
namespace Viewer {
/// How to react on mouse events?
enum ActionMode {
// examine geometry, get transformations from mouse events
ExamineMode,
/** Picking mode. Actually no pick()ing is performed (!) but events are
forwarded to the application via signalMouseEvent().
*/
PickingMode,
// same as picking, but emit signalMouseEventIdentify()
QuestionMode,
// Ligh rotation mode
LightMode
};
class ViewerProperties : public QObject {
Q_OBJECT
public:
ViewerProperties();
~ViewerProperties();
//===========================================================================
/** @name Action Mode States
* @{ */
//===========================================================================
public slots:
bool examineMode() { return(actionMode_ == Viewer::ExamineMode ); };
bool pickingMode() { return(actionMode_ == Viewer::PickingMode ); };
bool lightMode() { return(actionMode_ == Viewer::LightMode ); };
bool questionMode(){ return(actionMode_ == Viewer::QuestionMode ); };
/** Set action mode.
The ActionMode determines the type of reaction on mouse events.
*/
void setExamineMode() { actionMode(Viewer::ExamineMode ); };
void setPickingMode() { actionMode(Viewer::PickingMode ); };
void setLightMode() { actionMode(Viewer::LightMode ); };
void setQuestionMode(){ actionMode(Viewer::QuestionMode ); };
public:
void actionMode(Viewer::ActionMode _am);
Viewer::ActionMode actionMode() { return actionMode_; };
Viewer::ActionMode lastActionMode() { return lastActionMode_; };
private :
Viewer::ActionMode actionMode_, lastActionMode_;
/** @} */
//===========================================================================
/** @name Action Mode States
* @{ */
//===========================================================================
/** @} */
signals:
/** \brief This signal is emitted when the configuration has been changed
*/
void updated();
void actionModeChanged( Viewer::ActionMode );
};
}
#endif //VIEWERPROPERTIES_HH
\ No newline at end of file
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <OpenFlipper/common/GlobalOptions.hh> #include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/common/RecentFiles.hh> #include <OpenFlipper/common/RecentFiles.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh> #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh> #include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh> #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
...@@ -131,7 +132,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -131,7 +132,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
if ( !OpenFlipper::Options::multiView() ) { if ( !OpenFlipper::Options::multiView() ) {
QtBaseViewer* examinerWidget = new QtBaseViewer(stackedWidget_, glViewer* examinerWidget = new glViewer(stackedWidget_,
"Examiner Widget", "Examiner Widget",
statusBar_ , statusBar_ ,
&format); &format);
...@@ -148,7 +149,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -148,7 +149,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
tmp = new QWidget(stackedWidget_); tmp = new QWidget(stackedWidget_);
// Create master examiner widget // Create master examiner widget
QtBaseViewer* examinerWidget = new QtBaseViewer(tmp, glViewer* examinerWidget = new glViewer(tmp,
"Examiner Widget", "Examiner Widget",
statusBar_ , statusBar_ ,
&format, &format,
...@@ -158,7 +159,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -158,7 +159,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Create all other examiners using the same gl context as the others // Create all other examiners using the same gl context as the others
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
QtBaseViewer* newWidget = new QtBaseViewer(tmp, glViewer* newWidget = new glViewer(tmp,
"Examiner Widget", "Examiner Widget",
statusBar_ , statusBar_ ,
&format, &format,
...@@ -183,6 +184,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -183,6 +184,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
stackedWidget_->addWidget(tmp); stackedWidget_->addWidget(tmp);
} }
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::setViewers( examiner_widgets_ );
...@@ -232,8 +236,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -232,8 +236,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"<li><b>Translate</b> using <b>middle</b> mouse button.</li>" "<li><b>Translate</b> using <b>middle</b> mouse button.</li>"
"<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" ); "<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" );
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
connect( moveButton_,SIGNAL( clicked() ), examiner_widgets_[i], SLOT( examineMode() ) ); connect( moveButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setExamineMode() ) );
connect( examiner_widgets_[i],SIGNAL( actionModeChanged( QtBaseViewer::ActionMode ) ),this , SLOT( slotActionModeChanged(QtBaseViewer::ActionMode) ) ); connect( examiner_widgets_[i] , SIGNAL( signalActionModeChanged( Viewer::ActionMode ) ),
this , SLOT( slotActionModeChanged(Viewer::ActionMode) ) );
} }
viewerToolbar_->addWidget( moveButton_ )->setText("Move"); viewerToolbar_->addWidget( moveButton_ )->setText("Move");
...@@ -249,7 +254,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -249,7 +254,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"Switch to <b>light</b> mode.<br>" "Switch to <b>light</b> mode.<br>"
"Rotate lights using left mouse button."); "Rotate lights using left mouse button."