Commit 46462207 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

actionModes/pickModes moved from BaseViewer to CoreWidget

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5381 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 380878ee
...@@ -371,39 +371,28 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction ...@@ -371,39 +371,28 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction
} }
const std::string & pickMode () { const std::string pickMode () {
// No seperate draw modes available all should have the same so take first // No seperate draw modes available all should have the same so take first
return examiner_widgets_[0]->pickMode(); return viewerProperties().pickMode();
} }
void pickMode ( std::string _mode) { void pickMode ( std::string _mode) {
for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i ) viewerProperties().pickMode(_mode);
examiner_widgets_[i]->pickMode(_mode);
} }
void pickMode ( const unsigned int _examiner, std::string _mode) { Viewer::ActionMode actionMode() {
if ( _examiner >= examiner_widgets_.size() ) { return viewerProperties().actionMode();
std::cerr << "Wrong examiner id" << std::endl;
return;
}
examiner_widgets_[_examiner]->pickMode(_mode);
} }
void actionMode ( Viewer::ActionMode _mode) { void actionMode ( Viewer::ActionMode _mode) {
for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i ) viewerProperties().actionMode(_mode);
viewerProperties(i).actionMode(_mode);
} }
void getCurrentViewImage(QImage& _image) { void getCurrentViewImage(QImage& _image) {
examiner_widget_->copyToImage( _image ); examiner_widget_->copyToImage( _image );
} }
Viewer::ActionMode actionMode() {
return viewerProperties(activeExaminer_).actionMode();
}
Viewer::ViewerProperties& viewerProperties(int _id) { Viewer::ViewerProperties& viewerProperties(int _id) {
if ( _id >= (int)viewerProperties_.size() ) { if ( _id >= (int)viewerProperties_.size() ) {
std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl; std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <ACG/Scenegraph/SceneGraph.hh> #include <ACG/Scenegraph/SceneGraph.hh>
#include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh> #include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.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. */
namespace PluginFunctions { namespace PluginFunctions {
...@@ -250,16 +251,12 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction ...@@ -250,16 +251,12 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction
/// 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 for all examiner widgets /// 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 ( const unsigned int _examiner, std::string _mode);
/// Returns a QImage of the current View /// Returns a QImage of the current View
DLLEXPORT DLLEXPORT
void getCurrentViewImage(QImage& _image); void getCurrentViewImage(QImage& _image);
...@@ -309,6 +306,7 @@ QPoint mapToLocal( const QPoint _point ); ...@@ -309,6 +306,7 @@ QPoint mapToLocal( const QPoint _point );
/** @} */ /** @} */
//======================================= //=======================================
// Iterators for object Access // Iterators for object Access
/** @name Iterators /** @name Iterators
......
...@@ -630,8 +630,7 @@ Core::slotWheelEvent( QWheelEvent * _event, const std::string & _mode) ...@@ -630,8 +630,7 @@ 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() )
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) coreWidget_->addPickMode(_mode);
coreWidget_->examiner_widgets_[i]->addPickMode(_mode);
} }
...@@ -641,8 +640,7 @@ void ...@@ -641,8 +640,7 @@ void
Core::slotAddHiddenPickMode( const std::string _mode ) { Core::slotAddHiddenPickMode( const std::string _mode ) {
if ( OpenFlipper::Options::gui() ) if ( OpenFlipper::Options::gui() )
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) coreWidget_->addPickMode(_mode,false,1000,false);
coreWidget_->examiner_widgets_[i]->addPickMode(_mode,false,1000,false);
} }
......
...@@ -727,7 +727,7 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -727,7 +727,7 @@ void Core::loadPlugin(QString filename, bool silent){
supported = supported + "Picking "; supported = supported + "Picking ";
if ( checkSlot( plugin , "slotPickModeChanged(const std::string&)" ) ) if ( checkSlot( plugin , "slotPickModeChanged(const std::string&)" ) )
connect(coreWidget_->examiner_widgets_[0],SIGNAL(signalPickModeChanged (const std::string &)), connect(coreWidget_,SIGNAL(signalPickModeChanged (const std::string &)),
plugin,SLOT(slotPickModeChanged( const std::string &))); plugin,SLOT(slotPickModeChanged( const std::string &)));
if ( checkSignal(plugin,"addPickMode(const std::string)") ) if ( checkSignal(plugin,"addPickMode(const std::string)") )
...@@ -741,13 +741,13 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -741,13 +741,13 @@ void Core::loadPlugin(QString filename, bool silent){
if ( checkSignal(plugin,"setPickModeCursor(const std::string,QCursor)") ) if ( checkSignal(plugin,"setPickModeCursor(const std::string,QCursor)") )
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(plugin,SIGNAL(setPickModeCursor( const std::string ,QCursor)), connect(plugin,SIGNAL(setPickModeCursor( const std::string ,QCursor)),
coreWidget_->examiner_widgets_[i],SLOT(setPickModeCursor( const std::string ,QCursor)),Qt::DirectConnection); coreWidget_,SLOT(setPickModeCursor( const std::string ,QCursor)),Qt::DirectConnection);
if ( checkSignal(plugin,"setPickModeMouseTracking(const std::string,bool)") ) if ( checkSignal(plugin,"setPickModeMouseTracking(const std::string,bool)") )
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(plugin,SIGNAL(setPickModeMouseTracking( const std::string ,bool)), connect(plugin,SIGNAL(setPickModeMouseTracking( const std::string ,bool)),
coreWidget_->examiner_widgets_[i],SLOT(setPickModeMouseTracking( const std::string ,bool)),Qt::DirectConnection); coreWidget_,SLOT(setPickModeMouseTracking( const std::string ,bool)),Qt::DirectConnection);
} }
//Check if the plugin supports INI-Interface //Check if the plugin supports INI-Interface
......
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
namespace Viewer { namespace Viewer {
ViewerProperties::ViewerProperties(): ViewerProperties::ViewerProperties():
actionMode_(Viewer::PickingMode),
lastActionMode_(Viewer::PickingMode),
currentDrawMode_(ACG::SceneGraph::DrawModes::NONE), currentDrawMode_(ACG::SceneGraph::DrawModes::NONE),
snapshotName_("snap.png"), snapshotName_("snap.png"),
snapshotCounter_(0), snapshotCounter_(0),
...@@ -73,19 +71,31 @@ namespace Viewer { ...@@ -73,19 +71,31 @@ namespace Viewer {
} }
void ViewerProperties::actionMode(Viewer::ActionMode _am) {
if (_am != actionMode_) {
lastActionMode_ = actionMode_;
actionMode_ = _am;
emit actionModeChanged(_am);
}
}
void ViewerProperties::snapshotBaseFileName(const QString& _fname) { void ViewerProperties::snapshotBaseFileName(const QString& _fname) {
snapshotName_ = _fname; snapshotName_ = _fname;
snapshotCounter_ = 0; snapshotCounter_ = 0;
} }
std::string ViewerProperties::pickMode(){
std::string mode;
emit getPickMode(mode);
return mode;
}
void ViewerProperties::pickMode(const std::string _name){
emit setPickMode(_name);
}
Viewer::ActionMode ViewerProperties::actionMode(){
Viewer::ActionMode am;
emit getActionMode(am);
return am;
}
void ViewerProperties::actionMode(const Viewer::ActionMode _am){
emit setActionMode(_am);
}
} }
...@@ -78,37 +78,6 @@ namespace Viewer { ...@@ -78,37 +78,6 @@ namespace Viewer {
public: public:
ViewerProperties(); ViewerProperties();
~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 Draw Mode States /** @name Draw Mode States
...@@ -364,8 +333,25 @@ namespace Viewer { ...@@ -364,8 +333,25 @@ namespace Viewer {
*/ */
void updated(); void updated();
void actionModeChanged( Viewer::ActionMode ); void getPickMode(std::string& _mode );
void setPickMode(const std::string _mode );
void getActionMode(Viewer::ActionMode& _am);
void setActionMode(const Viewer::ActionMode _am);
public:
/// get active pick mode
std::string pickMode();
/// set the pickMode
void pickMode(const std::string _name);
/// get the action mode
Viewer::ActionMode actionMode();
/// set active action mode
void actionMode(const Viewer::ActionMode _am);
}; };
......
...@@ -284,16 +284,11 @@ void CoreWidget::updatePopupMenuObject(QMenu* _menu , BaseObjectData* _object ) ...@@ -284,16 +284,11 @@ void CoreWidget::updatePopupMenuObject(QMenu* _menu , BaseObjectData* _object )
_menu->addSeparator(); _menu->addSeparator();
// Add picking Menu // Add picking Menu
if (examiner_widgets_[0]->getPickMenu() != NULL) { if (pickMenu_ != 0 && pickMenu_->actions().size() > 0) {
if ( examiner_widgets_[0]->getPickMenu()->actions().size() > 0 ) { pickMenu_->setTitle("&Picking");
examiner_widgets_[0]->getPickMenu()->setTitle("&Picking"); contextMenu_->addMenu( pickMenu_ );
contextMenu_->addMenu(examiner_widgets_[0]->getPickMenu() ); pickMenu_->setTearOffEnabled(true);
examiner_widgets_[0]->getPickMenu()->setTearOffEnabled(true);
}
} }
} }
bool CoreWidget::addContextMenus( QMenu* _menu , ContextMenuType _type , int _id ) { bool CoreWidget::addContextMenus( QMenu* _menu , ContextMenuType _type , int _id ) {
......
...@@ -102,7 +102,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -102,7 +102,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
aboutWidget_(0), aboutWidget_(0),
optionsWidget_(0), optionsWidget_(0),
plugins_(_plugins), plugins_(_plugins),
stereoActive_(false) stereoActive_(false),
actionMode_(Viewer::PickingMode),
lastActionMode_(Viewer::ExamineMode),
pickMenu_(0),
pick_mode_name_(""),
pick_mode_idx_(-1)
{ {
setupStatusBar(); setupStatusBar();
...@@ -221,6 +226,16 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -221,6 +226,16 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
statusBar_); statusBar_);
examiner_widgets_.push_back(newWidget); examiner_widgets_.push_back(newWidget);
connect (&PluginFunctions::viewerProperties(i), SIGNAL( getPickMode(std::string&) ),
this, SLOT( getPickMode(std::string&) ),Qt::DirectConnection );
connect (&PluginFunctions::viewerProperties(i), SIGNAL( setPickMode(const std::string) ),
this, SLOT( setPickMode(const std::string) ),Qt::DirectConnection );
connect (&PluginFunctions::viewerProperties(i), SIGNAL( getActionMode(Viewer::ActionMode&) ),
this, SLOT( getActionMode(Viewer::ActionMode&) ),Qt::DirectConnection );
connect (&PluginFunctions::viewerProperties(i), SIGNAL( setActionMode(const Viewer::ActionMode) ),
this, SLOT( setActionMode(const Viewer::ActionMode)), Qt::DirectConnection );
} }
// Initialize all examiners // Initialize all examiners
...@@ -285,11 +300,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -285,11 +300,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"<ul><li><b>Rotate</b> using <b>left</b> mouse button.</li>" "<ul><li><b>Rotate</b> using <b>left</b> mouse button.</li>"
"<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 ) {
connect( moveButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setExamineMode() ) ); connect( moveButton_,SIGNAL( clicked() ), this, SLOT( setExamineMode() ) );
connect( &PluginFunctions::viewerProperties(i) , SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
this , SLOT( slotActionModeChanged(Viewer::ActionMode) ) ); connect( this, SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
} this, SLOT( slotActionModeChanged(Viewer::ActionMode) ) );
viewerToolbar_->addWidget( moveButton_ )->setText("Move"); viewerToolbar_->addWidget( moveButton_ )->setText("Move");
moveButton_->setDown(true); moveButton_->setDown(true);
...@@ -303,8 +318,8 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -303,8 +318,8 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
lightButton_->setWhatsThis( lightButton_->setWhatsThis(
"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.");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect( lightButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setLightMode() ) ); connect( lightButton_,SIGNAL( clicked() ), this, SLOT( setLightMode() ) );
viewerToolbar_->addWidget( lightButton_)->setText("Light"); viewerToolbar_->addWidget( lightButton_)->setText("Light");
...@@ -318,8 +333,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -318,8 +333,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"Use picking functions like flipping edges.<br>" "Use picking functions like flipping edges.<br>"
"To change the mode use the right click<br>" "To change the mode use the right click<br>"
"context menu in the viewer."); "context menu in the viewer.");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) connect( pickButton_,SIGNAL( clicked() ), this, SLOT( setPickingMode() ) );
connect( pickButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setPickingMode() ) );
viewerToolbar_->addWidget( pickButton_)->setText("Pick"); viewerToolbar_->addWidget( pickButton_)->setText("Pick");
...@@ -334,8 +348,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -334,8 +348,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"about objects. Click on an object and see " "about objects. Click on an object and see "
"the log output for information about the " "the log output for information about the "
"object."); "object.");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
connect( questionButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setQuestionMode() ) );
viewerToolbar_->addWidget( questionButton_)->setText("Question"); viewerToolbar_->addWidget( questionButton_)->setText("Question");
viewerToolbar_->addSeparator(); viewerToolbar_->addSeparator();
...@@ -420,6 +433,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -420,6 +433,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
registerCoreKeys(); registerCoreKeys();
setExamineMode();
setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() ); setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
#include <ACG/QtWidgets/QtSceneGraphWidget.hh> #include <ACG/QtWidgets/QtSceneGraphWidget.hh>
#include <OpenFlipper/INIFile/INIFile.hh> #include <OpenFlipper/INIFile/INIFile.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
struct ViewMode{ struct ViewMode{
...@@ -783,9 +783,6 @@ public: ...@@ -783,9 +783,6 @@ public:
/// Enable or disable Stereo /// Enable or disable Stereo
void slotToggleStereoMode(); void slotToggleStereoMode();
/// Change Icons if action mode is changed in an examiner
void slotActionModeChanged( Viewer::ActionMode _mode );
/// Set Background Color for all viewers at once. /// Set Background Color for all viewers at once.
void slotSetGlobalBackgroundColor(); void slotSetGlobalBackgroundColor();
...@@ -855,6 +852,153 @@ public: ...@@ -855,6 +852,153 @@ public:
bool stereoActive_; bool stereoActive_;
/** @} */ /** @} */
//===========================================================================
/** @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() { setActionMode(Viewer::ExamineMode ); };
void setPickingMode() { setActionMode(Viewer::PickingMode ); };
void setLightMode() { setActionMode(Viewer::LightMode ); };
void setQuestionMode(){ setActionMode(Viewer::QuestionMode ); };
void setActionMode(const Viewer::ActionMode _am);
void getActionMode(Viewer::ActionMode& _am);
public:
Viewer::ActionMode actionMode() { return actionMode_; };
Viewer::ActionMode lastActionMode() { return lastActionMode_; };
private :
Viewer::ActionMode actionMode_, lastActionMode_;
/** @} */
//===========================================================================
/** @name PickModes
* @{ */
//===========================================================================
public:
/** \brief add pick mode
*
* @param _name Name of the Pick Mode or "Separator" to insert a separator
* @param _mouse_tracking true: every mouse movement will emit mouse events not only when mousebutton is pressed
* @param _pos position to insert the mode in the popup menu.
*/
void addPickMode(const std::string& _name,
bool _mouse_tracking = false,
int _pos = -1,
bool _visible = true,
QCursor _cursor = Qt::ArrowCursor );
/** clear all pick modes
*/
void clearPickModes();
/** return the currently active pick mode
*/
const std::string& pickMode() const;
/** Switch to given picking mode
* @param _id Id of the picking Mode
*/
void pickMode( int _id );
public slots:
/** Switch to given picking mode
* @param _name Name of the picking mode
*/
void setPickMode(const std::string _name);
void getPickMode(std::string& _name);
public slots:
/** \brief set a new cursor for the pick mode
*
* @param _name Name of the Pick Mode
* @param _cursor the new cursor
*/
void setPickModeCursor(const std::string& _name, QCursor _cursor);
/** \brief set mouseTracking for the pick mode
*
* @param _name Name of the Pick Mode
* @param _mouseTracking true: every mouse movement will emit mouse events not only when mousebutton is pressed
*/
void setPickModeMouseTracking(const std::string& _name, bool _mouseTracking);
void actionPickMenu( QAction * _action );
signals:
/** This signal is emitted when the pickMode is changed and contains the new PickMode
*/
void signalPickModeChanged(const std::string&);
private:
QMenu* pickMenu_;
/** Struct containing information about pickModes
*/
struct PickMode
{
/// Constructor