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)
{
REGISTERapplication 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
--
Logo Imeka <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