From 9daa0b9d9add74556731078ee3953cdc2ea3ccd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 27 Jan 2009 18:45:11 +0000 Subject: [PATCH] Removed function Menu from local examiner and move it to corewidget git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4464 383ad7c9-94d9-4d36-a494-682f7c89f535 --- widgets/coreWidget/ContextMenu.cc | 125 +++--- widgets/coreWidget/CoreWidget.cc | 9 +- widgets/coreWidget/CoreWidget.hh | 6 + widgets/coreWidget/viewerControl.cc | 21 + widgets/glWidget/QtBaseViewer.cc | 380 ++---------------- widgets/glWidget/QtBaseViewer.hh | 85 ++-- widgets/glWidget/QtBaseViewerSnapshot.cc | 18 +- .../glWidget/QtBaseViewerSynchronization.cc | 19 +- 8 files changed, 181 insertions(+), 482 deletions(-) diff --git a/widgets/coreWidget/ContextMenu.cc b/widgets/coreWidget/ContextMenu.cc index 2c8f3d86..4b122a11 100644 --- a/widgets/coreWidget/ContextMenu.cc +++ b/widgets/coreWidget/ContextMenu.cc @@ -204,92 +204,95 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) // Add a functions menu QAction* action; - QMenu* functionMenu = new QMenu("&Functions",contextMenu_); + if ( functionMenu_ == 0 ) { + functionMenu_ = new QMenu("&Functions",contextMenu_); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Set Background Color"); - action->setToolTip("Set the background color for the viewer"); - connect(action, SIGNAL(triggered()), this, SLOT(changeBackgroundColor()) ); + action = functionMenu_->addAction("Set Background Color"); + action->setToolTip("Set the background color for the viewer"); + connect(action, SIGNAL(triggered()), this, SLOT(changeBackgroundColor()) ); - //==================================================================================================== + //==================================================================================================== - functionMenu->addSeparator(); + functionMenu_->addSeparator(); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Snapshot"); - action->setToolTip("Make a snapshot"); - connect(action, SIGNAL(triggered()), this, SLOT( slotSnapshot() ) ); + action = functionMenu_->addAction("Snapshot"); + action->setToolTip("Make a snapshot"); + connect(action, SIGNAL(triggered()), this, SLOT( slotSnapshot() ) ); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Set Snapshot Name"); - action->setToolTip("Set a name for snapshots"); - connect(action, SIGNAL(triggered()), this, SLOT(slotSnapshotName()) ); + action = functionMenu_->addAction("Set Snapshot Name"); + action->setToolTip("Set a name for snapshots"); + connect(action, SIGNAL(triggered()), this, SLOT(slotSnapshotName()) ); - //==================================================================================================== + //==================================================================================================== - functionMenu->addSeparator(); + functionMenu_->addSeparator(); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Copy View"); - action->setToolTip("Copy current view to clipboard"); - connect(action, SIGNAL(triggered()), this, SLOT(slotCopyView()) ); + action = functionMenu_->addAction("Copy View"); + action->setToolTip("Copy current view to clipboard"); + connect(action, SIGNAL(triggered()), this, SLOT(slotCopyView()) ); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Paste View"); - action->setToolTip("Paste current view from clipboard"); - connect(action, SIGNAL(triggered()), this , SLOT( slotPasteView( ) ) ); + action = functionMenu_->addAction("Paste View"); + action->setToolTip("Paste current view from clipboard"); + connect(action, SIGNAL(triggered()), this , SLOT( slotPasteView( ) ) ); - //==================================================================================================== + //==================================================================================================== - functionMenu->addSeparator(); + functionMenu_->addSeparator(); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Synchronization"); - action->setToolTip("Synchronize two different viewers"); - action->setCheckable( true ); - action->setChecked( OpenFlipper::Options::synchronization() ); - for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) - connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionSynchronize(bool)) ); - connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); + action = functionMenu_->addAction("Synchronization"); + action->setToolTip("Synchronize two different viewers"); + action->setCheckable( true ); + action->setChecked( OpenFlipper::Options::synchronization() ); + for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) + connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(setSynchronization(bool)) ); + connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Animation"); - action->setToolTip("Animate rotation of objects"); - action->setCheckable( true ); - action->setChecked( OpenFlipper::Options::animation() ); - for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) - connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionAnimation(bool)) ); - connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); + action = functionMenu_->addAction("Animation"); + action->setToolTip("Animate rotation of objects"); + action->setCheckable( true ); + action->setChecked( OpenFlipper::Options::animation() ); + for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) + connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(animation(bool)) ); + connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Backface Culling"); - action->setToolTip("Enable backface culling"); - action->setCheckable( true ); - action->setChecked( OpenFlipper::Options::backfaceCulling() ); - for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) - connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionBackfaceCulling(bool)) ); - connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); + action = functionMenu_->addAction("Backface Culling"); + action->setToolTip("Enable backface culling"); + action->setCheckable( true ); + action->setChecked( OpenFlipper::Options::backfaceCulling() ); + for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) + connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(backFaceCulling(bool)) ); + connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); - //==================================================================================================== + //==================================================================================================== - action = functionMenu->addAction("Two-sided Lighting"); - action->setToolTip("Enable two-sided lighting"); - action->setCheckable( true ); - action->setChecked( OpenFlipper::Options::twoSidedLighting() ); - for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) - connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionTwoSidedLighting(bool)) ); - connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); + action = functionMenu_->addAction("Two-sided Lighting"); + action->setToolTip("Enable two-sided lighting"); + action->setCheckable( true ); + action->setChecked( OpenFlipper::Options::twoSidedLighting() ); + for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) + connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(twoSidedLighting(bool)) ); + connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); - functionMenu->setTearOffEnabled(true); - contextMenu_->addMenu(functionMenu ); + functionMenu_->setTearOffEnabled(true); + } + + contextMenu_->addMenu(functionMenu_ ); if ( ( examiner_widgets_[0]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) { diff --git a/widgets/coreWidget/CoreWidget.cc b/widgets/coreWidget/CoreWidget.cc index 94ddae2a..e2c81812 100644 --- a/widgets/coreWidget/CoreWidget.cc +++ b/widgets/coreWidget/CoreWidget.cc @@ -77,7 +77,14 @@ CoreWidget( QVector& _viewModes, fileMenu_(0), viewMenu_(0), fileMenuEnd_(0), + stereoButton_(0), + projectionButton_(0), + moveButton_(0), + lightButton_(0), + pickButton_(0), + questionButton_(0), contextMenu_(0), + functionMenu_(0), contextSelectionMenu_(0), stackMenu_(0), stackedWidget_(0), @@ -131,7 +138,6 @@ CoreWidget( QVector& _viewModes, examinerWidget->disableKeyHandling(true); examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); - examinerWidget->enablePopupMenu(false); stackedWidget_->addWidget(examinerWidget); @@ -164,7 +170,6 @@ CoreWidget( QVector& _viewModes, // Initialize all examiners for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); - examiner_widgets_[i]->enablePopupMenu(false); examiner_widgets_[i]->disableKeyHandling(true); } diff --git a/widgets/coreWidget/CoreWidget.hh b/widgets/coreWidget/CoreWidget.hh index c399b6cb..5bd4804c 100644 --- a/widgets/coreWidget/CoreWidget.hh +++ b/widgets/coreWidget/CoreWidget.hh @@ -460,6 +460,9 @@ public: /// context Menu for the gl area QMenu* contextMenu_; + /// Function Menu + QMenu* functionMenu_; + /// Context Menu containing all selection elements QMenu* contextSelectionMenu_; @@ -629,6 +632,9 @@ public: /// Change Icons if action mode is changed in an examiner void slotActionModeChanged( QtBaseViewer::ActionMode _mode ); + /// Called when the functionMenu has to be updated + void slotFunctionMenuUpdate(); + private : bool stereoActive_; diff --git a/widgets/coreWidget/viewerControl.cc b/widgets/coreWidget/viewerControl.cc index b7b8dc2e..3db7e722 100644 --- a/widgets/coreWidget/viewerControl.cc +++ b/widgets/coreWidget/viewerControl.cc @@ -113,4 +113,25 @@ void CoreWidget::slotActionModeChanged( QtBaseViewer::ActionMode _mode ) { } } +void CoreWidget::slotFunctionMenuUpdate() { + std::cerr << "DF" < allActions = functionMenu_->actions(); + + for ( int i = 0 ; i < allActions.size(); ++i ) { + if ( allActions[i]->text() == "Synchronization" ) + allActions[i]->setChecked(examiner_widgets_[0]->synchronization()); + else if ( allActions[i]->text() == "Animation" ) + allActions[i]->setChecked(examiner_widgets_[0]->animation()); + else if ( allActions[i]->text() == "Backface Culling" ) + allActions[i]->setChecked(examiner_widgets_[0]->backFaceCulling()); + else if ( allActions[i]->text() == "Two-sided Lighting" ) + allActions[i]->setChecked(examiner_widgets_[0]->twoSidedLighting()); + } + +} + + //============================================================================= diff --git a/widgets/glWidget/QtBaseViewer.cc b/widgets/glWidget/QtBaseViewer.cc index 754ed760..a688bb16 100644 --- a/widgets/glWidget/QtBaseViewer.cc +++ b/widgets/glWidget/QtBaseViewer.cc @@ -180,15 +180,12 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent, snapshot_=new QImage; trackMouse_ = false; - popupEnabled_ = true; - // stereo stereo_ = false; pickMenu_ = 0; - funcMenu_ = 0; drawMenu_ = 0; @@ -218,52 +215,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent, // Note: we start locked (initialization of updateLocked_) // will be unlocked in initializeGL() - - // Actions - - action_.insert( "Background", new QAction( "Background color", this ) ); - action_.insert( "Snapshot", new QAction( "Snapshot", this ) ); - action_.insert( "SnapshotName", new QAction( "Set snapshot name", this ) ); - action_.insert( "SnapshotSavesView", new QAction( "Snapshot saves view", this ) ); - action_.insert( "CopyView", new QAction( "Copy view", this ) ); - action_.insert( "PasteView", new QAction( "Paste view", this ) ); - action_.insert( "PasteDropSize", new QAction( "Paste/Drop effects size", this ) ); - action_.insert( "Synchronize", new QAction( "Synchronize", this ) ); - action_.insert( "Animation", new QAction( "Animation", this ) ); - action_.insert( "BackfaceCulling", new QAction( "Backface culling", this ) ); - action_.insert( "TwoSidedLighting", new QAction( "Two-sided lighting", this ) ); - - connect( action_["Background"], SIGNAL( triggered() ), - this, SLOT( actionBackground() ) ); - connect( action_["Snapshot"], SIGNAL( triggered() ), - this, SLOT( actionSnapshot() ) ); - connect( action_["SnapshotName"], SIGNAL( triggered() ), - this, SLOT( actionSnapshotName() ) ); - connect( action_["SnapshotSavesView"], SIGNAL( triggered() ), - this, SLOT( actionSnapshotSavesView() ) ); - connect( action_["CopyView"], SIGNAL( triggered() ), - this, SLOT( actionCopyView() ) ); - connect( action_["PasteView"], SIGNAL( triggered() ), - this, SLOT( actionPasteView() ) ); - connect( action_["PasteDropSize"], SIGNAL( triggered() ), - this, SLOT( actionPasteDropSize() ) ); - connect( action_["Synchronize"], SIGNAL( triggered() ), - this, SLOT( actionSynchronize() ) ); - connect( action_["Animation"], SIGNAL( triggered() ), - this, SLOT( actionAnimation() ) ); - connect( action_["BackfaceCulling"], SIGNAL( triggered() ), - this, SLOT( actionBackfaceCulling() ) ); - connect( action_["TwoSidedLighting"], SIGNAL( triggered() ), - this, SLOT( actionTwoSidedLighting() ) ); - - action_["SnapshotSavesView"]->setCheckable( true ); - action_["PasteDropSize"]->setCheckable( true ); - action_["Synchronize"]->setCheckable( true ); - action_["Animation"]->setCheckable( true ); - action_["BackfaceCulling"]->setCheckable( true ); - action_["TwoSidedLighting"]->setCheckable( true ); - - QSizePolicy sp = sizePolicy(); sp.setHorizontalPolicy( QSizePolicy::Expanding ); sp.setVerticalPolicy( QSizePolicy::Expanding ); @@ -422,22 +373,6 @@ void QtBaseViewer::trackMouse(bool _track) } -//----------------------------------------------------------------------------- - - -void QtBaseViewer::enablePopupMenu(bool _enable) -{ - popupEnabled_ = _enable; - - if ( popupEnabled_ ) { - glView_->setContextMenuPolicy( Qt::DefaultContextMenu ); - } else { - glView_->setContextMenuPolicy( Qt::CustomContextMenu ); - } - -} - - //----------------------------------------------------------------------------- void QtBaseViewer::perspectiveProjection() @@ -635,34 +570,34 @@ void QtBaseViewer::faceOrientation(FaceOrientation _ori) void QtBaseViewer::backFaceCulling(bool _b) { + emit functionMenuUpdate(); + makeCurrent(); - if (funcMenu_==0) updatePopupMenu(); + if ( (backFaceCulling_ = _b) ) glEnable( GL_CULL_FACE ); else glDisable( GL_CULL_FACE ); - action_["BackfaceCulling"]->setChecked( backFaceCulling_ ); updateGL(); } void QtBaseViewer::twoSidedLighting(bool _b) { + emit functionMenuUpdate(); + makeCurrent(); - if (funcMenu_==0) updatePopupMenu(); glstate_->set_twosided_lighting(twoSidedLighting_=_b); - action_["TwoSidedLighting"]->setChecked(twoSidedLighting_); updateGL(); } void QtBaseViewer::animation(bool _b) { + emit functionMenuUpdate(); makeCurrent(); - if (funcMenu_==0) updatePopupMenu(); animation_ = _b; - action_["Animation"]->setChecked( animation_ ); updateGL(); } @@ -1301,13 +1236,15 @@ bool QtBaseViewer::decodeView(const QString& _view) glstate_->set_modelview(m); - if (w>0 && h>0 && - action_["PasteDropSize"]->isChecked() ) - { - glstate_->set_projection(p); - glView_->setFixedSize(w,h); - updateGeometry(); - } + std::cerr << "Todo : Add Checkbox if size should also be pasted" << std::endl; + +// if (w>0 && h>0 && +// action_["PasteDropSize"]->isChecked() ) +// { +// glstate_->set_projection(p); +// glView_->setFixedSize(w,h); +// updateGeometry(); +// } updateGL(); @@ -1320,6 +1257,26 @@ bool QtBaseViewer::decodeView(const QString& _view) //----------------------------------------------------------------------------- +void QtBaseViewer::actionCopyView() +{ + QString view; encodeView(view); + QApplication::clipboard()->setText(view); +} + + +//----------------------------------------------------------------------------- + + +void QtBaseViewer::actionPasteView() +{ + QString view; view=QApplication::clipboard()->text(); + decodeView(view); +} + + +//----------------------------------------------------------------------------- + + void QtBaseViewer::actionDrawMenu( QAction * _action ) { unsigned int mode( _action->data().toUInt() ); @@ -1358,110 +1315,10 @@ void QtBaseViewer::actionDrawMenu( QAction * _action ) //----------------------------------------------------------------------------- - -void QtBaseViewer::actionBackground() -{ - const ACG::Vec4f bc = glstate_->clear_color() * 255.0; - QColor backCol((int)bc[0], (int)bc[1], (int)bc[2]); - QColor c = QColorDialog::getColor(backCol,this); - if (c != backCol && c.isValid()) - backgroundColor(ACG::Vec4f(((double) c.red()) / 255.0, - ((double) c.green()) / 255.0, - ((double) c.blue()) / 255.0, - 1.0)); - -} - -//----------------------------------------------------------------------------- - - -void QtBaseViewer::actionCopyView() -{ - QString view; encodeView(view); - QApplication::clipboard()->setText(view); -} - - -//----------------------------------------------------------------------------- - - -void QtBaseViewer::actionPasteView() -{ - QString view; view=QApplication::clipboard()->text(); - decodeView(view); -} - - -//----------------------------------------------------------------------------- - - -void QtBaseViewer::actionPasteDropSize() -{ -} - -//----------------------------------------------------------------------------- - - -void QtBaseViewer::actionSynchronize() -{ - setSynchronization( action_["Synchronize"]->isChecked() ); -} - -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionSynchronize(bool _enable) -{ - setSynchronization( _enable ); -} - bool QtBaseViewer::synchronization(){ return synchronized_; } -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionAnimation() -{ - animation(!animation()); -} - -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionAnimation(bool _enable) -{ - animation(_enable); -} - -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionBackfaceCulling() -{ - backFaceCulling(!backFaceCulling()); -} - -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionBackfaceCulling(bool _enable) -{ - backFaceCulling(_enable); -} - -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionTwoSidedLighting() -{ - twoSidedLighting(!twoSidedLighting()); -} - -//----------------------------------------------------------------------------- - -void QtBaseViewer::actionTwoSidedLighting(bool _enable) -{ - twoSidedLighting(_enable); -} - -//----------------------------------------------------------------------------- - void QtBaseViewer::createWidgets(const QGLFormat* _format, QStatusBar* _sb, @@ -1470,7 +1327,6 @@ QtBaseViewer::createWidgets(const QGLFormat* _format, statusbar_=privateStatusBar_=0; setStatusBar(_sb); drawMenu_=0; - funcMenu_=0; pickMenu_=0; @@ -1510,6 +1366,8 @@ QtBaseViewer::createWidgets(const QGLFormat* _format, glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); glView_->setScene(glScene_); + glView_->setContextMenuPolicy( Qt::CustomContextMenu ); + wheelZ_=new ACG::QtWidgets::QtWheel( 0,"wheel-z",ACG::QtWidgets::QtWheel::Vertical); wheelZ_->setMinimumSize(wheelZ_->sizeHint()); wheelZ_->setMaximumSize(wheelZ_->sizeHint()); @@ -1576,7 +1434,6 @@ QtBaseViewer::createWidgets(const QGLFormat* _format, connect ( glScene_, SIGNAL( sceneRectChanged( const QRectF & ) ), this, SLOT( sceneRectChanged( const QRectF & ) ) ); - // If popupEnabled_ this signal will not be emitted! // If popupEnabled_ is set to false the Contextmenu Mode will be set to customContextMenuRequested // and this signal will be emitted on right click connect( glView_ , SIGNAL( customContextMenuRequested( const QPoint& ) ) , @@ -1653,33 +1510,6 @@ void QtBaseViewer::updatePopupMenu() drawMenu_->addActions( drawGroup->actions() ); - // function menu - - if (!funcMenu_) - { - funcMenu_=new QMenu( this ); - - funcMenu_->addAction( action_[ "Background" ] ); - funcMenu_->addSeparator(); - funcMenu_->addAction( action_[ "Snapshot" ] ); - funcMenu_->addAction( action_[ "SnapshotName" ] ); - funcMenu_->addAction( action_[ "SnapshotSavesView" ] ); - funcMenu_->addSeparator(); - funcMenu_->addAction( action_[ "CopyView" ] ); - funcMenu_->addAction( action_[ "PasteView" ] ); - funcMenu_->addAction( action_[ "PasteDropSize" ] ); - funcMenu_->addSeparator(); - funcMenu_->addAction( action_[ "Synchronize" ] ); - funcMenu_->addSeparator(); - funcMenu_->addAction( action_[ "Animation" ] ); - funcMenu_->addAction( action_[ "BackfaceCulling" ] ); - funcMenu_->addAction( action_[ "TwoSidedLighting" ] ); - - connect( funcMenu_, SIGNAL( aboutToHide() ), - this, SLOT( hidePopupMenus() ) ); - } - - } @@ -1695,13 +1525,6 @@ void QtBaseViewer::hidePopupMenus() drawMenu_->blockSignals(false); } - if ( funcMenu_ ) - { - funcMenu_->blockSignals(true); - funcMenu_->hide(); - funcMenu_->blockSignals(false); - } - if ( pickMenu_ ) { pickMenu_->blockSignals(true); @@ -1877,127 +1700,6 @@ void QtBaseViewer::releaseGLArea() void QtBaseViewer::glContextMenuEvent(QContextMenuEvent* _event) { - if (popupEnabled_) - { - QPoint cpos(QCursor::pos()), dpos, fpos, ppos; - int offset = 10, dw, dh, fw, fh, pw, ph; - int minx, maxx, miny, maxy; - int dx(0), dy(0); - - -#ifdef ARCH_DARWIN -# define WIDTH width() -# define HEIGHT height() -#else -# define WIDTH sizeHint().width() -# define HEIGHT sizeHint().height() -#endif - - - - // drawing mode menu - if (drawMenu_)//TODO: && drawMenu_->count()>0) - { - dw = drawMenu_->WIDTH; - dh = drawMenu_->HEIGHT; - dpos = cpos + QPoint(offset, offset); - } - else - { - dpos = cpos; dw=dh=0; - } - - - // function menu - ///@todo: if (funcMenu_ && funcMenu_->count()>0) - if (funcMenu_) - { - fw = funcMenu_->WIDTH; - fh = funcMenu_->HEIGHT; - fpos = cpos + QPoint(offset, -offset-fh); - } - else - { - fpos = cpos; fw=fh=0; - } - - - // pick mode menu - ///@todo: if (pickMenu_ && pickMenu_->count()>0) - if (pickMenu_) - { - pw = pickMenu_->WIDTH; - ph = pickMenu_->HEIGHT; - ppos = cpos + QPoint(-offset-pw, -ph/2); - } - else - { - ppos = cpos; pw=ph=0; - } - - - - // handle screen boundaries - minx = std::min(dpos.x(), std::min(fpos.x(), ppos.x())); - maxx = std::max(dpos.x()+dw, std::max(fpos.x()+fw, ppos.x()+pw)); - miny = std::min(dpos.y(), std::min(fpos.y(), ppos.y())); - maxy = std::max(dpos.y()+dh, std::max(fpos.y()+fh, ppos.y()+ph)); - - - if (minx < 0) - { - dx = -minx; - } - else if (maxx >= qApp->desktop()->width()) - { - dx = qApp->desktop()->width() - maxx; - } - - if (miny < 0) - { - dy = -miny; - } - else if (maxy >= qApp->desktop()->height()) - { - dy = qApp->desktop()->height() - maxy; - } - - - dpos += QPoint(dx, dy); - fpos += QPoint(dx, dy); - ppos += QPoint(dx, dy); - - - - // popping up 3 menus only works w/o Qt menu fade/animate effects - bool animate_menu = qApp->isEffectEnabled(Qt::UI_AnimateMenu); - bool fade_menu = qApp->isEffectEnabled(Qt::UI_FadeMenu); - if (animate_menu) qApp->setEffectEnabled(Qt::UI_AnimateMenu, false); - if (fade_menu) qApp->setEffectEnabled(Qt::UI_FadeMenu, false); - - - // popup the 3 menus - - if (drawMenu_) ///@todo: && drawMenu_->count()>0) - { - // SceneGraph::DrawModes::setQPopupMenuChecked(drawMenu_, curDrawMode_); - drawMenu_->popup(dpos); - } - - if (funcMenu_) ///@todo: && funcMenu_->count()>0) - funcMenu_->popup(fpos); - - if (pickMenu_) ///@todo: && pickMenu_->count()>0) - pickMenu_->popup(ppos); - - - // restore effect state - if (animate_menu) qApp->setEffectEnabled(Qt::UI_AnimateMenu, true); - if (fade_menu) qApp->setEffectEnabled(Qt::UI_FadeMenu, true); - - - _event->accept(); - } } @@ -2007,11 +1709,7 @@ void QtBaseViewer::glContextMenuEvent(QContextMenuEvent* _event) void QtBaseViewer::glMousePressEvent(QMouseEvent* _event) { // right button pressed => popup menu (ignore here) - if (_event->button() == Qt::RightButton && popupEnabled_) - { - return; - } - else + if (_event->button() != Qt::RightButton ) { switch (actionMode_) { @@ -2115,7 +1813,7 @@ void QtBaseViewer::glMouseReleaseEvent(QMouseEvent* _event) // hidePopupMenus(); if (_event->button() != Qt::RightButton || - (actionMode_ == PickingMode && !popupEnabled_) ) + (actionMode_ == PickingMode ) ) { switch ( actionMode_ ) { diff --git a/widgets/glWidget/QtBaseViewer.hh b/widgets/glWidget/QtBaseViewer.hh index c264dd83..c570ef78 100644 --- a/widgets/glWidget/QtBaseViewer.hh +++ b/widgets/glWidget/QtBaseViewer.hh @@ -259,18 +259,18 @@ public: /// Is animation enabled? bool animation() const { return animation_; } - /// Set animation enabled. - void animation(bool _b); - - /// Enable/disable mouse tracking (move events with no button press) - void trackMouse(bool _track); - - /// Enable/disable right button draw mode menu (default: enabled) - void enablePopupMenu(bool _enable); + public slots: + /// Set animation enabled. + void animation(bool _b); + signals : + void functionMenuUpdate(); + public: + /// Enable/disable mouse tracking (move events with no button press) + void trackMouse(bool _track); /// Returns: root node of scene graph @@ -369,13 +369,19 @@ public: /// get face orientation FaceOrientation faceOrientation() const { return faceOrientation_; } - /// set backface culling on/off - void backFaceCulling( bool _b ); + public slots: + /// set backface culling on/off + void backFaceCulling( bool _b ); + + public: /// is backface culling enabled? bool backFaceCulling() const { return backFaceCulling_; } + public slots: /// set 2-sided lighting on/off void twoSidedLighting( bool _b ); + + public: /// is 2-sided lighing enabled? bool twoSidedLighting() const { return twoSidedLighting_; } @@ -470,7 +476,6 @@ public: /// Get the menu pointers (required to add them to the menubar as a temp workaround for a qt 4.3 bug QMenu * getPickMenu() { return pickMenu_; }; - QMenu * getFuncMenu() { return funcMenu_; }; QMenu * getDrawMenu() { return drawMenu_; }; @@ -534,22 +539,14 @@ public slots: virtual void setView( const ACG::GLMatrixd& _modelview, const ACG::GLMatrixd& _inverse_modelview ); - void actionBackground(); - void actionCopyView(); - void actionPasteView(); - void actionPasteDropSize(); - void actionSynchronize(); - void actionAnimation(); - void actionBackfaceCulling(); - void actionTwoSidedLighting(); - void actionSynchronize(bool _enable); - void actionAnimation(bool _enable); - void actionBackfaceCulling(bool _enable); - void actionTwoSidedLighting(bool _enable); - void actionDrawMenu( QAction * _action ); void actionPickMenu( QAction * _action ); + void actionSnapshotName(); + void actionSnapshot(); + void actionPasteView(); + void actionCopyView(); + @@ -682,21 +679,6 @@ private slots: //----------------------------------------------------------- private functions private: - // IDs for \c funcMenu_ - enum FuncMenuID { - M_CopyView=0x100, - M_PasteView, - M_PasteDropSize, - M_Animation, - M_BackfaceCulling, - M_TwoSidedLighting, - M_Background, - M_Snapshot, - M_SnapshotName, - M_SnapshotSavesView, - M_Synchronize - }; - /// Copy constructor. Never used! QtBaseViewer(const QtBaseViewer&); /// Assignment operator. Never used! @@ -772,13 +754,11 @@ private: // helper bool trackMouse_; - bool popupEnabled_; bool glareaGrabbed_; double frame_time_; QMenu * pickMenu_; - QMenu * funcMenu_; QMenu * drawMenu_; // scenegraph stuff @@ -824,9 +804,6 @@ private: // translate along z-axis ACG::QtWidgets::QtWheel* wheelZ_; - // all actions - QMap< QString, QAction * > action_; - // vector of current draw mode actions std::vector< QAction * > drawMenuActions_; @@ -987,8 +964,7 @@ private: /// unsync two sync_connect()ed QtBaseViewer's void sync_disconnect(const QtBaseViewer*); - /// toggle global synchronization - virtual void setSynchronization(bool _b); + /// add host to synchronize with, given by its name bool add_sync_host(const QString& _name); @@ -997,6 +973,11 @@ private: bool synchronization(); + public slots: + + /// toggle global synchronization + virtual void setSynchronization(bool _b); + private slots: void sync_receive(); @@ -1043,18 +1024,6 @@ private: */ virtual void snapshot(); - /** This action triggers a snapshot - */ - void actionSnapshot(); - - /** This action creates a widget for entering the snapshots name. - */ - void actionSnapshotName(); - - /** Doesn't do anything at the moment. Widget shows a checkbox for that. - */ - void actionSnapshotSavesView(); - private: QString snapshotName_; diff --git a/widgets/glWidget/QtBaseViewerSnapshot.cc b/widgets/glWidget/QtBaseViewerSnapshot.cc index 59727396..c12203c3 100644 --- a/widgets/glWidget/QtBaseViewerSnapshot.cc +++ b/widgets/glWidget/QtBaseViewerSnapshot.cc @@ -94,12 +94,12 @@ void QtBaseViewer::snapshot() if (rval) { statusbar_->showMessage(QString("snapshot: ")+fname,5000); - if ( action_["SnapshotSavesView"]->isChecked() ) - { - QString view; encodeView(view); - QFile f(fname+".view"); f.open(QIODevice::WriteOnly|QIODevice::Truncate); - QTextStream sf(&f); sf << view; f.close(); - } +// if ( action_["SnapshotSavesView"]->isChecked() ) +// { +// QString view; encodeView(view); +// QFile f(fname+".view"); f.open(QIODevice::WriteOnly|QIODevice::Truncate); +// QTextStream sf(&f); sf << view; f.close(); +// } } else { @@ -139,12 +139,6 @@ void QtBaseViewer::actionSnapshotName() } -//----------------------------------------------------------------------------- - - -void QtBaseViewer::actionSnapshotSavesView() -{ -} //============================================================================= //============================================================================= diff --git a/widgets/glWidget/QtBaseViewerSynchronization.cc b/widgets/glWidget/QtBaseViewerSynchronization.cc index e9196d12..d0142d00 100644 --- a/widgets/glWidget/QtBaseViewerSynchronization.cc +++ b/widgets/glWidget/QtBaseViewerSynchronization.cc @@ -148,13 +148,15 @@ void QtBaseViewer::sync_receive() glstate_->set_modelview(m); - if (w>0 && h>0 && - action_["PasteDropSize"]->isChecked() ) - { - glstate_->set_projection(p); - glView_->setFixedSize(w,h); - updateGeometry(); - } + std::cerr << "Todo : Checkbox if size should be applied to" << std::endl; + +// if (w>0 && h>0 && +// action_["PasteDropSize"]->isChecked() ) +// { +// glstate_->set_projection(p); +// glView_->setFixedSize(w,h); +// updateGeometry(); +// } blockSignals(false); @@ -167,8 +169,9 @@ void QtBaseViewer::sync_receive() void QtBaseViewer::setSynchronization(bool _b) { + emit functionMenuUpdate(); + synchronized_ = _b; - action_["Synchronize"]->setChecked( synchronized_ ); if (synchronized_) { -- GitLab