From ff84210d478b565ebd45b2950d1081e887b7ed75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 27 Feb 2009 15:02:33 +0000 Subject: [PATCH] More functionality for context Menu git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5127 383ad7c9-94d9-4d36-a494-682f7c89f535 --- widgets/coreWidget/ContextMenu.cc | 51 ++++++++++++++++++------------- widgets/coreWidget/CoreWidget.hh | 7 +++-- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/widgets/coreWidget/ContextMenu.cc b/widgets/coreWidget/ContextMenu.cc index 5c6c7f0d..a709fd66 100644 --- a/widgets/coreWidget/ContextMenu.cc +++ b/widgets/coreWidget/ContextMenu.cc @@ -51,27 +51,25 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { - QObject* senderPointer = sender(); - unsigned int examinerId = 0; +// QObject* senderPointer = sender(); QPoint popupPosition; QPoint scenePos; - if ( senderPointer == 0 ) { - std::cerr << "Error : slotCustomContextMenu 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 == examiner_widgets_[i] ) { - popupPosition = examiner_widgets_[i]->glMapToGlobal(_point); - QPointF f = examiner_widgets_[i]->mapToScene(QPointF(_point.x(), _point.y())); +// if ( senderPointer == 0 ) { +// std::cerr << "Error : slotCustomContextMenu 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 == examiner_widgets_[i] ) { + popupPosition = examiner_widgets_[PluginFunctions::activeExaminer()]->glMapToGlobal(_point); + QPointF f = examiner_widgets_[PluginFunctions::activeExaminer()]->mapToScene(QPointF(_point.x(), _point.y())); scenePos = QPoint (f.x(), f.y()); - examinerId = i; - break; - } - } +// break; +// } +// } - } +// } - updatePopupMenu(scenePos,examinerId); + updatePopupMenu(scenePos); // If not initialized, dont show it!! if ( !contextMenu_->isEmpty () ) @@ -79,13 +77,17 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { } -void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) { +void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const QPoint& _point) { + +} + +void CoreWidget::updatePopupMenu(const QPoint& _point) { contextMenu_->clear(); contextSelectionMenu_->clear(); QIcon icon; - QAction* typeEntry = new QAction("No type",contextMenu_); + QAction* typeEntry = new QAction("Viewer",contextMenu_); contextMenu_->addAction( typeEntry ); QAction* entrySeparator = contextMenu_->addSeparator( ); @@ -101,7 +103,7 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) unsigned int node_idx, target_idx; ACG::Vec3d hit_point; BaseObjectData* object; - if (examiner_widgets_[_examinerId]->pick( ACG::SceneGraph::PICK_ANYTHING,_point,node_idx, target_idx, &hit_point ) ) { + if (examiner_widgets_[PluginFunctions::activeExaminer()]->pick( ACG::SceneGraph::PICK_ANYTHING,_point,node_idx, target_idx, &hit_point ) ) { if ( PluginFunctions::getPickedObject(node_idx, object) ) objectId = object->id(); @@ -114,6 +116,11 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) if ( node == 0 ) std::cerr << "Node not found" << std::endl; else { + if ( node->name() == "Core Coordsys Node") { + std::cerr << "Picked Coordsys Node" << std::endl; + typeEntry->setText( "Viewer Settings" ); + + } std::cerr << "Picked Node with name" << node->name() << std::endl; std::cerr << "Target index was : " << target_idx << std::endl; } @@ -296,16 +303,16 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) contextMenu_->addMenu(functionMenu_ ); - if ( ( examiner_widgets_[_examinerId]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) { + if ( ( examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) { - examiner_widgets_[_examinerId]->getDrawMenu()->setTitle("&DrawModes"); - QAction* drawMenuAction = contextMenu_->addMenu(examiner_widgets_[_examinerId]->getDrawMenu() ); + examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu()->setTitle("&DrawModes"); + QAction* drawMenuAction = contextMenu_->addMenu(examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu() ); QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png"); drawMenuAction->setIcon(icon); - examiner_widgets_[_examinerId]->getDrawMenu()->setTearOffEnabled(true); + examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu()->setTearOffEnabled(true); } } diff --git a/widgets/coreWidget/CoreWidget.hh b/widgets/coreWidget/CoreWidget.hh index e635691b..399e049b 100644 --- a/widgets/coreWidget/CoreWidget.hh +++ b/widgets/coreWidget/CoreWidget.hh @@ -527,9 +527,12 @@ public: /** Update the contextmenu for the given position inside an examiner widget * * @param _point Picking position in coordinates of the viewer - * @param _examinerId Id of the examinerWidget used */ - void updatePopupMenu(const QPoint& _point, unsigned int _examinerId); + void updatePopupMenu(const QPoint& _point); + + /** This function creates the PopupMenu Part when clicking on the Coordsys Node + */ + void updatePopupMenuCoordsysNode(QMenu* _menu , const QPoint& _point); private : /// context Menu for the gl area -- GitLab