Commit 0c790eb8 authored by Jan Möbius's avatar Jan Möbius
Browse files

More functionality for context Menu

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5127 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7b603586
...@@ -51,27 +51,25 @@ ...@@ -51,27 +51,25 @@
void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { void CoreWidget::slotCustomContextMenu( const QPoint& _point ) {
QObject* senderPointer = sender(); // QObject* senderPointer = sender();
unsigned int examinerId = 0;
QPoint popupPosition; QPoint popupPosition;
QPoint scenePos; QPoint scenePos;
if ( senderPointer == 0 ) { // if ( senderPointer == 0 ) {
std::cerr << "Error : slotCustomContextMenu directly called! This should only be called by an examiner" << std::endl; // std::cerr << "Error : slotCustomContextMenu directly called! This should only be called by an examiner" << std::endl;
} else { // } else {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) { // for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == examiner_widgets_[i] ) { // if ( senderPointer == examiner_widgets_[i] ) {
popupPosition = examiner_widgets_[i]->glMapToGlobal(_point); popupPosition = examiner_widgets_[PluginFunctions::activeExaminer()]->glMapToGlobal(_point);
QPointF f = examiner_widgets_[i]->mapToScene(QPointF(_point.x(), _point.y())); QPointF f = examiner_widgets_[PluginFunctions::activeExaminer()]->mapToScene(QPointF(_point.x(), _point.y()));
scenePos = QPoint (f.x(), f.y()); scenePos = QPoint (f.x(), f.y());
examinerId = i; // break;
break; // }
} // }
}
} // }
updatePopupMenu(scenePos,examinerId); updatePopupMenu(scenePos);
// If not initialized, dont show it!! // If not initialized, dont show it!!
if ( !contextMenu_->isEmpty () ) if ( !contextMenu_->isEmpty () )
...@@ -79,13 +77,17 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { ...@@ -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(); contextMenu_->clear();
contextSelectionMenu_->clear(); contextSelectionMenu_->clear();
QIcon icon; QIcon icon;
QAction* typeEntry = new QAction("No type",contextMenu_); QAction* typeEntry = new QAction("Viewer",contextMenu_);
contextMenu_->addAction( typeEntry ); contextMenu_->addAction( typeEntry );
QAction* entrySeparator = contextMenu_->addSeparator( ); QAction* entrySeparator = contextMenu_->addSeparator( );
...@@ -101,7 +103,7 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) ...@@ -101,7 +103,7 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
unsigned int node_idx, target_idx; unsigned int node_idx, target_idx;
ACG::Vec3d hit_point; ACG::Vec3d hit_point;
BaseObjectData* object; 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) ) if ( PluginFunctions::getPickedObject(node_idx, object) )
objectId = object->id(); objectId = object->id();
...@@ -114,6 +116,11 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) ...@@ -114,6 +116,11 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
if ( node == 0 ) if ( node == 0 )
std::cerr << "Node not found" << std::endl; std::cerr << "Node not found" << std::endl;
else { 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 << "Picked Node with name" << node->name() << std::endl;
std::cerr << "Target index was : " << target_idx << std::endl; std::cerr << "Target index was : " << target_idx << std::endl;
} }
...@@ -296,16 +303,16 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) ...@@ -296,16 +303,16 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
contextMenu_->addMenu(functionMenu_ ); 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"); examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu()->setTitle("&DrawModes");
QAction* drawMenuAction = contextMenu_->addMenu(examiner_widgets_[_examinerId]->getDrawMenu() ); QAction* drawMenuAction = contextMenu_->addMenu(examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu() );
QIcon icon; QIcon icon;
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
drawMenuAction->setIcon(icon); drawMenuAction->setIcon(icon);
examiner_widgets_[_examinerId]->getDrawMenu()->setTearOffEnabled(true); examiner_widgets_[PluginFunctions::activeExaminer()]->getDrawMenu()->setTearOffEnabled(true);
} }
} }
......
...@@ -527,9 +527,12 @@ public: ...@@ -527,9 +527,12 @@ public:
/** Update the contextmenu for the given position inside an examiner widget /** Update the contextmenu for the given position inside an examiner widget
* *
* @param _point Picking position in coordinates of the viewer * @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 : private :
/// context Menu for the gl area /// context Menu for the gl area
......
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