 |
Computer Assited Medical Intervention Tool Kit
version 4.1
|
Go to the documentation of this file.
26 #ifndef CAMITK_COMPONENT_H
27 #define CAMITK_COMPONENT_H
43 #include <vtkWindowLevelLookupTable.h>
44 #include <vtkImageData.h>
45 #include <vtkPointSet.h>
46 #include <vtkSmartPointer.h>
47 #include <vtkAlgorithmOutput.h>
49 #include <vtkAxesActor.h>
50 #include <vtkActor2D.h>
51 #include <vtkImageActor.h>
52 #include <vtkTransform.h>
58 class vtkUnstructuredGridAlgorithm;
59 class vtkDataSetToUnstructuredGridFilter;
60 class vtkWindowLevelLookupTable;
73 #define invoke0(HANDLER,METHOD) \
77 #define invoke1(HANDLER,METHOD,PARAM) \
79 HANDLER->METHOD(PARAM);
81 #define invoke2(HANDLER,METHOD,PARAM1,PARAM2) \
83 HANDLER->METHOD(PARAM1,PARAM2);
85 #define invoke3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
87 HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
89 #define invoke4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
91 HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
97 #define invokeGet0(HANDLER,METHOD) \
99 return HANDLER->METHOD();
101 #define invokeGet1(HANDLER,METHOD,PARAM) \
103 return HANDLER->METHOD(PARAM);
105 #define invokeGet2(HANDLER,METHOD,PARAM1,PARAM2) \
107 return HANDLER->METHOD(PARAM1,PARAM2);
109 #define invokeGet3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
111 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
113 #define invokeGet4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
115 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
120 #define invokeChildren0(METHOD) \
121 foreach (Component *child, childrenComponent) { \
125 #define invokeChildren1(METHOD,PARAM) \
126 foreach (Component *child, childrenComponent) { \
127 child->METHOD(PARAM); \
130 #define invokeChildren2(METHOD,PARAM1,PARAM2) \
131 foreach (Component *child, childrenComponent) { \
132 child->METHOD(PARAM1,PARAM2); \
135 #define invokeChildren3(METHOD,PARAM1,PARAM2,PARAM3) \
136 foreach (Component *child, childrenComponent) { \
137 child->METHOD(PARAM1,PARAM2,PARAM3); \
140 #define invokeChildren4(METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
141 foreach (Component *child, childrenComponent) { \
142 child->METHOD(PARAM1,PARAM2,PARAM3,PARAM4); \
150 #define delegate0(HANDLER,METHOD) \
151 virtual void METHOD() { \
152 invoke0(HANDLER,METHOD) \
155 #define delegate1(HANDLER,METHOD,PARAM_TYPE) \
156 virtual void METHOD(PARAM_TYPE param) { \
157 invoke1(HANDLER,METHOD,param) \
160 #define delegate2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
161 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) { \
162 invoke2(HANDLER,METHOD,param1,param2) \
165 #define delegate3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
166 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) { \
167 invoke3(HANDLER,METHOD,param1,param2,param3) \
170 #define delegate4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3, PARAM_TYPE4) \
171 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3, PARAM_TYPE4 param4) { \
172 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
181 #define delegateGet0(HANDLER,METHOD,TYPE) \
182 virtual TYPE METHOD() { \
183 invokeGet0(HANDLER,METHOD) \
188 #define delegateGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
189 virtual TYPE METHOD(PARAM_TYPE param) { \
190 invokeGet1(HANDLER,METHOD,param) \
195 #define delegateGet2(HANDLER,METHOD,TYPE,PARAM1_TYPE,PARAM2_TYPE) \
196 virtual TYPE METHOD(PARAM1_TYPE param1, PARAM2_TYPE param2) { \
197 invokeGet2(HANDLER,METHOD,param1,param2) \
204 #define delegateConstGet0(HANDLER,METHOD,TYPE) \
205 virtual TYPE METHOD() const { \
206 invokeGet0(HANDLER,METHOD) \
211 #define delegateConstGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
212 virtual TYPE METHOD(PARAM_TYPE param) const { \
213 invokeGet1(HANDLER,METHOD,param) \
222 #define delegateAndInvokeChildren1(HANDLER,METHOD,PARAM_TYPE) \
223 virtual void METHOD(PARAM_TYPE param) { \
224 invoke1(HANDLER,METHOD,param) \
225 invokeChildren1(METHOD,param) \
228 #define delegateAndInvokeChildren2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
229 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) { \
230 invoke2(HANDLER,METHOD,param1,param2) \
231 invokeChildren2(METHOD,param1,param2) \
234 #define delegateAndInvokeChildren1Array(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,DIM) \
235 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2[DIM]) { \
236 invoke2(HANDLER,METHOD,param1,param2) \
237 invokeChildren2(METHOD,param1,param2) \
240 #define delegateAndInvokeChildren3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
241 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) { \
242 invoke3(HANDLER,METHOD,param1,param2,param3) \
243 invokeChildren3(METHOD,param1,param2,param3) \
246 #define delegateAndInvokeChildren4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3,PARAM_TYPE4) \
247 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3,PARAM_TYPE4 param4) { \
248 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
249 invokeChildren4(METHOD,param1,param2,param3,param4) \
324 Component(QString file, QString name, Representation
rep = NO_REPRESENTATION);
349 Representation getRepresentation()
const;
352 bool isTopLevel()
const;
358 virtual Component* getTopLevelComponent();
364 virtual void setModified(
bool modified =
true);
367 virtual bool getModified()
const;
370 virtual void setVisibility(
Viewer*,
bool);
373 virtual bool getVisibility(
Viewer*)
const;
384 virtual void refreshInterfaceNode();
387 virtual bool isSelected()
const;
393 virtual void setSelected(
const bool b,
const bool recursive =
true);
396 const QString getFileName()
const;
399 void setFileName(
const QString&);
402 bool event(QEvent* e)
override;
405 QMenu* getActionMenu();
412 QStringList getHierarchy()
const override;
417 bool isInstanceOf(QString className)
const override;
453 void updateProperty(QString name, QVariant value)
override;
463 this->indexOfPropertyExplorerTab = index;
474 return this->indexOfPropertyExplorerTab;
483 Q_INVOKABLE
Property* getProperty(QString name)
override;
493 bool addProperty(
Property*)
override;
513 void deleteChildren()
override;
514 QString getName()
const override;
515 void setName(
const QString&)
override;
517 bool doubleClicked()
override;
519 QPixmap getIcon()
override;
524 bool inItalic()
const override;
536 const QString getLabel()
const override;
541 void setLabel(QString newName)
override;
543 delegateGet0(myGeometry, getPointSet, vtkSmartPointer<vtkPointSet>)
545 delegate1(myGeometry, setPointSet, vtkSmartPointer<vtkPointSet>)
547 delegate1(myGeometry, setPointData, vtkSmartPointer<vtkDataArray>)
551 delegate1(myGeometry, setDataConnection, vtkSmartPointer<vtkAlgorithmOutput>)
553 delegateGet1(myGeometry, getActor, vtkSmartPointer<vtkActor>, const RenderingModes)
557 vtkSmartPointer<vtkProp> getProp(const QString& param) {
559 return myGeometry->getProp(param);
562 return mySlice->getProp(param);
569 return myGeometry->getNumberOfProp();
572 return mySlice->getNumberOfProp();
577 vtkSmartPointer<vtkProp>
getProp(
unsigned int index) {
579 return myGeometry->getProp(index);
582 return mySlice->getProp(index);
587 bool addProp(
const QString& name, vtkSmartPointer<vtkProp> prop) {
589 return myGeometry->addProp(name, prop);
592 return mySlice->addProp(name, prop);
600 return myGeometry->removeProp(name);
603 return mySlice->removeProp(name);
623 void getBounds(
double* bounds)
override;
628 double getBoundingRadius()
override;
630 delegate4(myGeometry, setPointPosition,
const unsigned int,
const double,
const double,
const double)
646 void getActorColor(const RenderingModes,
double [4]) override;
658 delegate2(myGeometry, setMapperScalarRange,
double,
double)
660 delegate1(myGeometry, setTexture, vtkSmartPointer<vtkTexture>)
662 void setGlyphType(const GlyphTypes type, const
double size = 0.0) override;
664 delegate1(myGeometry, setLinesAsTubes,
bool)
666 delegate1(myGeometry, setMeshWorldTransform, vtkSmartPointer<vtkTransform>)
677 delegate1(mySlice, setOriginalVolume, vtkSmartPointer<vtkImageData>)
689 delegate3(mySlice, pixelPicked,
double,
double,
double)
699 delegate3(mySlice, setPixelRealPosition,
double,
double,
double)
701 delegate1(mySlice, setImageWorldTransform, vtkSmartPointer<vtkTransform>)
704 int getNumberOfSlices() const override;
707 int getSlice() const override;
715 const QString& getFrameName() const override;
718 delegate1(myFrame, setFrameName, QString)
722 void setParentFrame(
InterfaceFrame* frame,
bool keepTransform = true) override;
724 const QVector<
InterfaceFrame*>& getChildrenFrame() const override;
726 const vtkSmartPointer<vtkTransform> getTransformFromWorld() const override;
728 const vtkSmartPointer<vtkTransform> getTransform() const override;
730 const vtkSmartPointer<vtkTransform> getTransformFromFrame(
InterfaceFrame* frame) const override;
732 delegate1(myFrame, setTransform, vtkSmartPointer<vtkTransform>)
736 delegate3(myFrame, translate,
double,
double,
double)
740 delegate3(myFrame, rotateVTK,
double,
double,
double)
742 delegate3(myFrame, setTransformTranslation,
double,
double,
double)
744 delegate3(myFrame, setTransformTranslationVTK,
double,
double,
double)
746 delegate3(myFrame, setTransformRotation,
double,
double,
double)
748 delegate3(myFrame, setTransformRotationVTK,
double,
double,
double)
750 vtkSmartPointer<vtkAxesActor> getFrameAxisActor() override;
754 bool getFrameVisibility(
Viewer* viewer) const override;
788 unsigned int indexOfPropertyExplorerTab;
809 virtual
void initRepresentation() = 0;
824 static QSet<
Viewer*> allViewers;
834 return isSelectedFlag;
845 return childrenComponent;
865 return QPixmap(0, 0);
877 myGeometry->setLabel(n);
883 modifiedFlag = modification;
bool inItalic() const override
A component name is not displayed in italic by default.
Definition: sdk/libraries/core/component/Component.h:869
static QSet< Viewer * > allViewers
Definition: sdk/libraries/core/component/Component.h:826
bool removeProp(const QString &name)
remove a given additional prop.
Definition: sdk/libraries/core/component/Component.h:598
#define delegateGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:188
#define delegate2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:160
QObject * getPropertyObject()
Get the property object that could be understood by PropertyEditor.
Definition: sdk/libraries/core/component/Component.h:443
void removeFromParents()
this tell the parent components that this component is removed from memory.
Definition: modeling/libraries/pml/Component.cpp:48
void setLabel(QString newName) override
set the string used to display the label, do the same as setName
Definition: sdk/libraries/core/component/Component.h:896
#define delegateAndInvokeChildren1Array(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, DIM)
Definition: sdk/libraries/core/component/Component.h:234
std::vector< MultiComponent * > parentMultiComponentList
list of Component that are using this component (if another component is using this component,...
Definition: modeling/libraries/pml/Component.h:136
Properties * properties
Definition: modeling/libraries/pml/Component.h:118
QAction * getQAction()
Get the corresponding QAction.
Definition: Action.cpp:183
#define CAMITK_INFO(MSG)
Log for info verbosity (the second most verbose one) The msg will appear only if the user asked for I...
Definition: Log.h:258
virtual bool isInstanceOf(const char *) const =0
pure virtual method, implemented in the child-class
virtual void setModified(bool modified=true)
set the modified flag
Definition: sdk/libraries/core/component/Component.h:882
vtkSmartPointer< vtkProp > getProp(unsigned int index)
return an additional prop by its index
Definition: sdk/libraries/core/component/Component.h:577
void deleteProperties()
delete the "properties" pointer and set it to NULL
Definition: modeling/libraries/pml/Component.cpp:42
void setIndexOfPropertyExplorerTab(unsigned int index)
Set the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:462
#define delegateAndInvokeChildren1(HANDLER, METHOD, PARAM_TYPE)
delegateAndInvokeChildren macros: Same as delegate but also calls METHOD, eventually with PARAM_TYPE,...
Definition: sdk/libraries/core/component/Component.h:222
#define delegateAndInvokeChildren2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:228
virtual Component * getTopLevelComponent()
get the top-level component
Definition: sdk/libraries/core/component/Component.cpp:266
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:95
#define delegateConstGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:211
bool actionLessThan(const camitk::Action *a1, const camitk::Action *a2)
Definition: Application.cpp:747
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:314
#define delegateAndInvokeChildren4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:246
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:86
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:230
void setParent(InterfaceNode *) override
set the parent Component. This method automatically remove this Component from its previous (if alrea...
Definition: sdk/libraries/core/component/Component.cpp:241
QWidget * getPropertyWidgetAt(unsigned int i)
Get the ith alternative property widget.
Definition: sdk/libraries/core/component/Component.h:431
#define delegate0(HANDLER, METHOD)
delegate macros: completely delegates METHOD to HANDLER, eventually using parameters of given PARAM_T...
Definition: sdk/libraries/core/component/Component.h:150
QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:92
bool addProp(const QString &name, vtkSmartPointer< vtkProp > prop)
insert an additional prop, defining it by its name (default visibility = false)
Definition: sdk/libraries/core/component/Component.h:587
#define delegateConstGet0(HANDLER, METHOD, TYPE)
delegateConstGet macros: Same as delegateGet but for const METHOD
Definition: sdk/libraries/core/component/Component.h:204
This class describes what are the methods to implement for a Geometry (rendering parameters,...
Definition: InterfaceGeometry.h:61
#define delegateGet0(HANDLER, METHOD, TYPE)
delegateGet macros: Same as delegate macro but for an accessor non-const METHOD, returns a value of t...
Definition: sdk/libraries/core/component/Component.h:181
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:273
unsigned int getIndexOfPropertyExplorerTab()
Get the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:473
#define delegate1(HANDLER, METHOD, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:155
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:558
#define delegateAndInvokeChildren3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:240
bool exclusive
Definition: modeling/libraries/pml/Component.h:131
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:849
#define invoke1(HANDLER, METHOD, PARAM)
Definition: sdk/libraries/core/component/Component.h:77
This class describes what are the methods to implement in order to manage a Component position in spa...
Definition: InterfaceFrame.h:64
bool doubleClicked() override
this method is called each time the InterfaceNode is double clicked by the user.
Definition: sdk/libraries/core/component/Component.h:838
Representation
Definition: sdk/libraries/core/component/Component.h:307
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:89
void getBounds(double *bounds) override
compute the object's bounding box [xmin,xmax, ymin,ymax, zmin,zmax], see Component....
Definition: sdk/libraries/core/component/Component.cpp:462
void cellPicked(vtkIdType, bool)
an inherited class can redefine this method something specific.
Definition: sdk/libraries/core/component/Component.h:618
Component(QString file, QString name, Representation rep=NO_REPRESENTATION)
Component constructor for top-level component (please use the other constructor for sub-level compone...
Definition: sdk/libraries/core/component/Component.cpp:71
virtual void setGlyphType(const GlyphTypes type, const double size=0.0)=0
Set the glyph type (a glyph is a geometric representation attached to every point in the input datase...
const ComponentList & getChildren() override
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: sdk/libraries/core/component/Component.h:844
QMenu * getPopupMenu(QWidget *parent=nullptr)
get the popup menu to display (always return NULL, overwrite this method if you want to give here you...
Definition: sdk/libraries/core/component/Component.h:527
A component is something that composed something and could also be a part of something.
Definition: modeling/libraries/pml/Component.h:48
#define CAMITK_TRACE(MSG)
Log for trace verbosity (the most verbose one, should be used for bug report) The msg will appear onl...
Definition: Log.h:253
Viewer is an abstract viewer.
Definition: Viewer.h:55
@ GEOMETRY
this Component can be displayed as a GEOMETRY
Definition: sdk/libraries/core/component/Component.h:308
This class describes what are the methods to implement for a BitMap. An InterfaceBitMap is a kind of ...
Definition: InterfaceBitMap.h:63
unsigned int getNumberOfProp() const
return the number of additional prop
Definition: sdk/libraries/core/component/Component.h:567
void pointPicked(vtkIdType, bool)
an inherited class can redefine this method something specific.
Definition: sdk/libraries/core/component/Component.h:613
#define delegate3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:165
unsigned int getNumberOfPropertyWidget()
get the number of alternative property widgets
Definition: sdk/libraries/core/component/Component.h:423
vtkScalarBarRepresentation * rep
Definition: RendererWidget.cpp:719
@ SLICE
this Component can be displayed as a SLICE
Definition: sdk/libraries/core/component/Component.h:309
Describes the properties common to all structures and components.
Definition: Properties.h:59
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:874
InterfaceNode * getParent() override
get the parent Component
Definition: sdk/libraries/core/component/Component.h:854
void refresh()
refresh the display
Component(PhysicalModel *, std::string n="")
Default constructor, a component needs to know the PM it is in.
Definition: modeling/libraries/pml/Component.cpp:30
This class describe what are the methods to implement in order to manage dynamic properties....
Definition: InterfaceProperty.h:66
virtual ~Component()
Virtual destructor needed here as this is an abstract class (pure virtual)
Definition: modeling/libraries/pml/Component.cpp:36
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: sdk/libraries/core/component/Component.h:864
This class describe what are the methods to implement for a hierarchical tree node.
Definition: InterfaceNode.h:58
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:298
virtual bool getModified() const
set the modified flag
Definition: sdk/libraries/core/component/Component.h:887
const QString getLabel() const override
Definition: sdk/libraries/core/component/Component.h:892
#define delegate4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:170
#define CAMITK_API
Definition: CamiTKAPI.h:49
Definition: Action.cpp:36
virtual InterfaceFrame * getFrame()
get the associated frame
Definition: sdk/libraries/core/component/Component.h:859