Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
camitk::ComponentPopupMenu Class Reference

#include <ComponentPopupMenu.h>

+ Inheritance diagram for camitk::ComponentPopupMenu:

Public Member Functions

 ComponentPopupMenu (Component *, QWidget *)
 default constructor

Protected Member Functions

QAction * addAction (const QString name, const char *member, bool isCheckable=true)
 Add a new item to the popup menu)
QAction * addSeparator ()
 insert a menu separator and return the corresponding action

Protected Attributes

ComponentmyComponent
 the Component concerned by this popup menu

Detailed Description

Deprecated:
since CamiTK 2.0
Note
this class is deprecated, please use the Action framework.
Generic class for Component popup menu.
To create your own Component popup, create a class that inherits from this one. Your class could have as many
slot that you want. Create popup menu item and connect your slot using the addAction method.

<b>Example:</b>
@code 
// ------------------------— // – ExampleComponentPopup.h // ------------------------— #include <ComponentPopupMenu.h> using namespace camitk;

class ExampleComponentPopup : public ComponentPopupMenu { Q _ OBJECT // note: the spaces around the underscore have to be removed

public: ExampleComponentPopup(Component *, QWidget*);

public slots: void test(); };

// --------------------------— // – ExampleComponentPopup.cpp // --------------------------—

#include "ExampleComponentPopup.h" #include "ExampleComponent.h" #include <QMessageBox>

ExampleComponentPopup::ExampleComponentPopup(Component *comp, QWidget *parent) : ComponentPopupMenu(comp,parent) { addAction("action test", SLOT(test()), true); }

void ExampleComponentPopup::test() { // if you want to do something specific to the ExampleComponent class, then you can // safely use dynamic cast as this: // ExampleComponent comp = dynamic_cast<ExampleComponent>(myComponent); // comp->specificMethodOfExampleComponent(...)

QString testMessage;

// myComponent is known here, so we could ask for its name // getName() is a generic Component method, not specific to ExampleComponent, no need to use dynamic_cast here testMessage = QString("This is a test on \"%1" . isn't it?").arg(QString(myComponent->getName()));

QMessageBox::information( 0, "Test", testMessage);

}

// -------------------— // – ExampleComponent.h // -------------------— ... public: /// Overriden method so that we actually can instanciate a popup menu using ExampleComponentPopup virtual QMenu * getPopupMenu(QWidget* parent); ... private: /// the popup menu QMenu * myPopupMenu; ...

// ---------------------— // – ExampleComponent.cpp // ---------------------— #include "ExampleComponentPopup.h" ... // Do NOT forget to add this line in the constructor myPopupMenu = NULL; ... // Do NOT forget to add these lines in the destructor delete myPopupMenu; myPopupMenu = NULL; ... QMenu * ExampleComponent::getPopupMenu(QWidget* parent) { // lazy instanciation pattern if (!myPopupMenu) { myPopupMenu = new ExampleComponentPopup(this,parent); }

return myPopupMenu; }

...

Constructor & Destructor Documentation

camitk::ComponentPopupMenu::ComponentPopupMenu ( Component comp,
QWidget *  parent 
)

default constructor

References myComponent.

Member Function Documentation

QAction * camitk::ComponentPopupMenu::addAction ( const QString  name,
const char *  member,
bool  isCheckable = true 
)
protected

Add a new item to the popup menu)

Parameters
namestring that will appears as the name of the menu item
memberis the slot to be connected to this action (slot that should be implemented in your subclass)
isCheckableif the item is checkable
Returns
the corresponding action

Referenced by AtomDCPopup::AtomDCPopup(), MMLComponentPopup::MMLComponentPopup(), MultiComponentDCPopup::MultiComponentDCPopup(), PMManagerDCPopup::PMManagerDCPopup(), StructuralComponentDCPopup::StructuralComponentDCPopup(), and VtkMeshComponentPopup::VtkMeshComponentPopup().

QAction * camitk::ComponentPopupMenu::addSeparator ( )
protected

insert a menu separator and return the corresponding action

Referenced by PMManagerDCPopup::PMManagerDCPopup(), and VtkMeshComponentPopup::VtkMeshComponentPopup().

Member Data Documentation

Component* camitk::ComponentPopupMenu::myComponent
protected

The documentation for this class was generated from the following files: