Commit 3fc30555 authored by Jan Möbius's avatar Jan Möbius
Browse files

Moved pickmode class out of corewidget and introduced getters and setters

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11575 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ff5b7676
...@@ -71,6 +71,56 @@ ...@@ -71,6 +71,56 @@
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
PickMode::PickMode(const std::string& _n, const bool _t, const bool _v, QCursor _c, QToolBar *_tb ) :
name_(_n),
tracking_(_t),
visible_(_v),
cursor_(_c),
toolbar_(_tb)
{
}
void PickMode::visible(const bool _visible) {
visible_ = _visible;
}
bool PickMode::visible() const {
return visible_;
}
std::string PickMode::name() const {
return name_;
}
void PickMode::tracking(bool _tracking) {
tracking_ = _tracking;
}
bool PickMode::tracking() const {
return tracking_;
}
QCursor PickMode::cursor() const{
return cursor_;
}
void PickMode::toolbar(QToolBar* _toolbar) {
toolbar_ = _toolbar;
}
QToolBar * PickMode::toolbar() const {
return toolbar_;
}
/** \brief Constuctor for the Core Widget /** \brief Constuctor for the Core Widget
* *
*/ */
......
...@@ -138,17 +138,69 @@ class StackWidgetInfo { ...@@ -138,17 +138,69 @@ class StackWidgetInfo {
/** Info struct containing information about custom context menus /** Info struct containing information about custom context menus
*/ */
struct MenuInfo { class MenuInfo {
/// The context item public:
QAction* action; MenuInfo():
action(0)
{}
/// The context item
QAction* action;
/// Type of objects for which the context Menu should be visible /// Type of objects for which the context Menu should be visible
DataType contextType; DataType contextType;
/// Type of the context Menu ( Context for what type .. Background,Object,Node) /// Type of the context Menu ( Context for what type .. Background,Object,Node)
ContextMenuType type; ContextMenuType type;
}; };
/** Struct containing information about pickModes
*/
class PickMode
{
public:
/// Constructor
PickMode(const std::string& _n, const bool _t, const bool _v, QCursor _c, QToolBar *_tb = 0 );
~PickMode() {};
void visible(const bool _visible);
bool visible() const;
std::string name() const;
void tracking(const bool _tracking);
bool tracking() const;
QCursor cursor() const;
void toolbar(QToolBar* _toolbar);
QToolBar* toolbar() const;
private:
/// Name of the pickMode
std::string name_;
/** MouseTracking enabled for this mode?
*/
bool tracking_;
/** Defines if the Mode will be visible in the popup Menu
*/
bool visible_;
/** Cursor used in this pickMode
*/
QCursor cursor_;
/** Additional toolbar showed in this pickMode
*/
QToolBar * toolbar_;
};
/** Core Widget of the Application /** Core Widget of the Application
*/ */
class CoreWidget : public QMainWindow class CoreWidget : public QMainWindow
...@@ -1220,41 +1272,6 @@ public: ...@@ -1220,41 +1272,6 @@ public:
QMenu* pickMenu_; QMenu* pickMenu_;
/** Struct containing information about pickModes
*/
class PickMode
{
public:
/// Constructor
PickMode(const std::string& _n, bool _t, bool _v, QCursor _c, QToolBar *_tb = 0 ) :
name(_n),
tracking(_t),
visible(_v),
cursor(_c),
toolbar(_tb) {};
~PickMode() {};
/// Name of the pickMode
std::string name;
/** MouseTracking enabled for this mode?
*/
bool tracking;
/** Defines if the Mode will be visible in the popup Menu
*/
bool visible;
/** Cursor used in this pickMode
*/
QCursor cursor;
/** Additional toolbar showed in this pickMode
*/
QToolBar * toolbar;
};
/** Vector of all Picking modes /** Vector of all Picking modes
*/ */
std::vector<PickMode> pick_modes_; std::vector<PickMode> pick_modes_;
......
...@@ -99,7 +99,7 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){ ...@@ -99,7 +99,7 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
case Viewer::PickingMode: case Viewer::PickingMode:
cursorPainter_->setCursor(QCursor( QPixmap( OpenFlipper::Options::iconDirStr() + QDir::separator() + "cursor_arrow.png" ) ,0,0 )); cursorPainter_->setCursor(QCursor( QPixmap( OpenFlipper::Options::iconDirStr() + QDir::separator() + "cursor_arrow.png" ) ,0,0 ));
if (pick_mode_idx_ != -1) { if (pick_mode_idx_ != -1) {
cursorPainter_->setCursor(pick_modes_[pick_mode_idx_].cursor); cursorPainter_->setCursor(pick_modes_[pick_mode_idx_].cursor() );
} }
break; break;
case Viewer::QuestionMode: case Viewer::QuestionMode:
...@@ -122,11 +122,11 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){ ...@@ -122,11 +122,11 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
break; break;
case Viewer::PickingMode: case Viewer::PickingMode:
if (pick_mode_idx_ != -1) { if (pick_mode_idx_ != -1) {
examiner_widgets_[i]->trackMouse(pick_modes_[pick_mode_idx_].tracking); examiner_widgets_[i]->trackMouse(pick_modes_[pick_mode_idx_].tracking() );
// Show the pickMode Toolbar for this picking mode if it is set // Show the pickMode Toolbar for this picking mode if it is set
if (pick_modes_[pick_mode_idx_].toolbar) if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar); pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else else
pickToolbar_->detachToolbar (); pickToolbar_->detachToolbar ();
} }
...@@ -156,7 +156,7 @@ void CoreWidget::setPickMode(const std::string _mode){ ...@@ -156,7 +156,7 @@ void CoreWidget::setPickMode(const std::string _mode){
for (unsigned int i=0; i<pick_modes_.size(); ++i) for (unsigned int i=0; i<pick_modes_.size(); ++i)
{ {
if (pick_modes_[i].name == _mode) if (pick_modes_[i].name() == _mode)
{ {
pickMode( i ); pickMode( i );
updatePickMenu(); updatePickMenu();
...@@ -187,17 +187,17 @@ void CoreWidget::updatePickMenu() ...@@ -187,17 +187,17 @@ void CoreWidget::updatePickMenu()
ag->setExclusive( true ); ag->setExclusive( true );
for (unsigned int i=0; i<pick_modes_.size(); ++i) { for (unsigned int i=0; i<pick_modes_.size(); ++i) {
if ( !pick_modes_[i].visible ) if ( !pick_modes_[i].visible() )
continue; continue;
if (pick_modes_[i].name == "Separator") if (pick_modes_[i].name() == "Separator")
{ {
if ((i > 0) && (i<pick_modes_.size()-1)) // not first, not last if ((i > 0) && (i<pick_modes_.size()-1)) // not first, not last
pickMenu_->addSeparator(); pickMenu_->addSeparator();
} }
else else
{ {
QAction* ac = new QAction( pick_modes_[i].name.c_str(), ag ); QAction* ac = new QAction( pick_modes_[i].name().c_str(), ag );
ac->setData( QVariant( i ) ); ac->setData( QVariant( i ) );
ac->setCheckable( true ); ac->setCheckable( true );
...@@ -250,21 +250,21 @@ void CoreWidget::pickMode( int _id ) ...@@ -250,21 +250,21 @@ void CoreWidget::pickMode( int _id )
if (_id < (int) pick_modes_.size() ) if (_id < (int) pick_modes_.size() )
{ {
pick_mode_idx_ = _id; pick_mode_idx_ = _id;
pick_mode_name_ = pick_modes_[pick_mode_idx_].name; pick_mode_name_ = pick_modes_[pick_mode_idx_].name();
if (pick_modes_[pick_mode_idx_].toolbar) if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar); pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else else
pickToolbar_->detachToolbar (); pickToolbar_->detachToolbar ();
// adjust mouse tracking // adjust mouse tracking
if ( pickingMode() ) if ( pickingMode() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->trackMouse(pick_modes_[pick_mode_idx_].tracking); examiner_widgets_[i]->trackMouse(pick_modes_[pick_mode_idx_].tracking() );
// adjust Cursor // adjust Cursor
if ( pickingMode() ) if ( pickingMode() )
cursorPainter_->setCursor( pick_modes_[pick_mode_idx_].cursor); cursorPainter_->setCursor( pick_modes_[pick_mode_idx_].cursor() );
// emit signal // emit signal
emit(signalPickModeChanged(pick_mode_name_)); emit(signalPickModeChanged(pick_mode_name_));
...@@ -299,8 +299,8 @@ void CoreWidget::addPickMode(const std::string& _name, ...@@ -299,8 +299,8 @@ void CoreWidget::addPickMode(const std::string& _name,
void CoreWidget::setPickModeCursor(const std::string& _name, QCursor _cursor) void CoreWidget::setPickModeCursor(const std::string& _name, QCursor _cursor)
{ {
for (uint i=0; i < pick_modes_.size(); i++) for (uint i=0; i < pick_modes_.size(); i++)
if ( pick_modes_[i].name == _name ){ if ( pick_modes_[i].name() == _name ){
pick_modes_[i].cursor = _cursor; pick_modes_[i].cursor() = _cursor;
//switch cursor if pickMode is active //switch cursor if pickMode is active
if (pick_mode_name_ == _name && pickingMode() ) if (pick_mode_name_ == _name && pickingMode() )
...@@ -314,8 +314,9 @@ void CoreWidget::setPickModeCursor(const std::string& _name, QCursor _cursor) ...@@ -314,8 +314,9 @@ void CoreWidget::setPickModeCursor(const std::string& _name, QCursor _cursor)
void CoreWidget::setPickModeMouseTracking(const std::string& _name, bool _mouseTracking) void CoreWidget::setPickModeMouseTracking(const std::string& _name, bool _mouseTracking)
{ {
for (uint i=0; i < pick_modes_.size(); i++) for (uint i=0; i < pick_modes_.size(); i++)
if ( pick_modes_[i].name == _name ){ if ( pick_modes_[i].name() == _name ){
pick_modes_[i].tracking = _mouseTracking;
pick_modes_[i].tracking(_mouseTracking );
//switch cursor if pickMode is active //switch cursor if pickMode is active
if (pick_mode_name_ == _name && pickingMode() ) if (pick_mode_name_ == _name && pickingMode() )
...@@ -331,10 +332,10 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb ...@@ -331,10 +332,10 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb
{ {
// Get the pickmode that belongs to the given name // Get the pickmode that belongs to the given name
for (uint i=0; i < pick_modes_.size(); i++) for (uint i=0; i < pick_modes_.size(); i++)
if ( pick_modes_[i].name == _mode ){ if ( pick_modes_[i].name() == _mode ){
// Set the new toolbar for that mode // Set the new toolbar for that mode
pick_modes_[i].toolbar = _toolbar; pick_modes_[i].toolbar( _toolbar );
// Activate the toolbar if this mode is currently active // Activate the toolbar if this mode is currently active
if (pick_mode_name_ == _mode && pickingMode() ) if (pick_mode_name_ == _mode && pickingMode() )
...@@ -349,8 +350,9 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb ...@@ -349,8 +350,9 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb
void CoreWidget::removePickModeToolbar( const std::string _mode ) void CoreWidget::removePickModeToolbar( const std::string _mode )
{ {
for (uint i=0; i < pick_modes_.size(); i++) for (uint i=0; i < pick_modes_.size(); i++)
if ( pick_modes_[i].name == _mode ){ if ( pick_modes_[i].name() == _mode ){
pick_modes_[i].toolbar = NULL;
pick_modes_[i].toolbar(0);
if (pick_mode_name_ == _mode && pickingMode() ) if (pick_mode_name_ == _mode && pickingMode() )
pickToolbar_->detachToolbar (); pickToolbar_->detachToolbar ();
......
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