Hi Nil,
you can extend the context menu from within your plugin. Therefor you have to
use the plugin.xml. You can have a look into the one of the segmentation
plugin. You basically define an extension point and the according data type for
which this entry should appear (=nodeDescriptorName) and the action (class)
that should be executed:
<extension point="org.mitk.gui.qt.datamanager.contextMenuActions">
<contextMenuAction nodeDescriptorName="ImageMask" label="Create polygon
model" icon="" smoothed="false" class="QmitkCreatePolygonModelAction" />
<contextMenuAction nodeDescriptorName="ImageMask" label="Create smoothed
polygon model" icon="" smoothed = "true" class="QmitkCreatePolygonModelAction"
/>
<contextMenuAction nodeDescriptorName="ImageMask" label="Autocrop" icon=""
class="QmitkAutocropAction" />
</extension>
In the DataManagerView these extension point are recognized and added to the
context menu. You simply have to adapt the function:
void QmitkDataManagerView::ContextMenuActionTriggered( bool )
Regarding the action you want to perform if the menu entry is selected: You
will have to create your own mitk::IContextMenuAction like it is done for the
QmitkCreatePolygonModelAction.
Hope this helps!
Best regards
Andreas
From: Nil Goyette [mailto:[email protected]]
Sent: Freitag, 10. Oktober 2014 20:16
To: [email protected]
Subject: [mitk-users] Type-specific DataManager context menu
Hi all,
I've been trying to add an action in the DataManager context menu, but only for
a specific type of object, namely mitk::BoundingObject.
Looking in mitk code, I succeeded in adding the option but I'm stuck. Here's
the code in one of my plugin activator:
QmitkNodeDescriptorManager* manager = QmitkNodeDescriptorManager::GetInstance();
QAction* locateSelectionObject = new QAction(QIcon("..."), "name", this);
QObject::connect(locateSelectionObject, SIGNAL(triggered(bool)), this,
SLOT(test(bool)));
QmitkNodeDescriptor* desc = new QmitkNodeDescriptor("name", "", myPredicate,
manager);
desc->AddAction(locateSelectionObject);
manager->AddDescriptor(desc);
I can see it in the context menu when I click on a mitk::BoundingObject and I
know my test() function is called. The problem is that the only parameter it
has is a bool. I don't even know which node was clicked. The standard context
menu item (inheriting from mitk::IContextMenuAction) receives a List of
selected node, but afaik they always appear in the context menu and this is not
what I want.
I couldn't find any exemple of type-specific action in mitk's code, they are
all hardcoded in QmitkDataManagerView :(
Can someone please tell me what is the right way to do that? Thanks.
--
[cid:[email protected]]<http://imeka.ca/>
Nil Goyette, M.Sc.
www.imeka.ca<http://imeka.ca/>
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users