Hi Nil, thank you for your notes! We will add that to the documentation.
Regarding your follow-up question: Actually as far as I can see, there no standard out of the box way to do that. The QmitkRenderWindow layout is hidden by purpose, so that others can use their custom RenderWindowEditor. This is why you cannot simply access the renderwindos e.g. using the RenderManager. I would recommend that you simply pass the IRenderWindowPart as a parameter to your action. You can do this in the DatamanagerView::ContextMenuActionTriggered function. There some custom parameters for other actions are set as well. Andreas From: Nil Goyette [mailto:[email protected]] Sent: Mittwoch, 22. Oktober 2014 14:47 To: Fetzer, Andreas; [email protected] Subject: Re: [mitk-users] Type-specific DataManager context menu Thank you Andreas! It exactly what I wanted. I would note for the next programmers who want to do that the string in nodeDescriptorName may not be defined. Some are defined in Modules\QtWidgets\QmitkNodeDescriptorManager.cpp: Image, ImageMask, PointSet, Surface and NoneBinaryImage. If you want to add one, you can: 1) Add this to your app activator #include <QmitkNodeDescriptorManager.h> your_activator::start(ctkPluginContext* context) { REGISTER application and perspective auto manager = QmitkNodeDescriptorManager::GetInstance(); auto descriptor = new QmitkNodeDescriptor( tr("BoundingObject"), QString(":/icon"), some_predicate, manager); manager->AddDescriptor(descriptor); } 2) Add this to your plugin activator, in ::start BERRY_REGISTER_EXTENSION_CLASS(TheAction, context) I have a follow-up question. My goal with this new action in the menu was to add a "Locate" action because we often lose our bounding object :) I wanted to simply call GetRenderWindowPart()->SetSelectedPosition(center); but I realize now that I can access that method only in a view. Is there a way to change the crosshair position in a context menu action? I hacked it for now, but I would prefer the clean way :) Le 2014-10-14 12:00, Fetzer, Andreas a écrit : 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 -- [cid:[email protected]]<http://imeka.ca/> Nil Goyette, M.Sc. www.imeka.ca<http://imeka.ca/>
------------------------------------------------------------------------------
_______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users
