|
Computer Assited Medical Intervention Tool Kit
version 5.0
|
|
Go to the documentation of this file.
26 #ifndef CAMITK_COMPONENT_H
27 #define CAMITK_COMPONENT_H
44 #include <CamiTKDisableWarnings>
45 #include <vtkWindowLevelLookupTable.h>
47 #include <vtkAxesActor.h>
48 #include <vtkImageActor.h>
49 #include <CamiTKReEnableWarnings>
51 #include <vtkImageData.h>
52 #include <vtkPointSet.h>
53 #include <vtkSmartPointer.h>
54 #include <vtkAlgorithmOutput.h>
55 #include <vtkActor2D.h>
56 #include <vtkTransform.h>
62 class vtkUnstructuredGridAlgorithm;
63 class vtkDataSetToUnstructuredGridFilter;
64 class vtkWindowLevelLookupTable;
77 #define invoke0(HANDLER,METHOD) \
81 #define invoke1(HANDLER,METHOD,PARAM) \
83 HANDLER->METHOD(PARAM);
85 #define invoke2(HANDLER,METHOD,PARAM1,PARAM2) \
87 HANDLER->METHOD(PARAM1,PARAM2);
89 #define invoke3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
91 HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
93 #define invoke4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
95 HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
101 #define invokeGet0(HANDLER,METHOD) \
103 return HANDLER->METHOD();
105 #define invokeGet1(HANDLER,METHOD,PARAM) \
107 return HANDLER->METHOD(PARAM);
109 #define invokeGet2(HANDLER,METHOD,PARAM1,PARAM2) \
111 return HANDLER->METHOD(PARAM1,PARAM2);
113 #define invokeGet3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
115 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
117 #define invokeGet4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
119 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
124 #define invokeChildren0(METHOD) \
125 foreach (Component *child, childrenComponent) { \
129 #define invokeChildren1(METHOD,PARAM) \
130 foreach (Component *child, childrenComponent) { \
131 child->METHOD(PARAM); \
134 #define invokeChildren2(METHOD,PARAM1,PARAM2) \
135 foreach (Component *child, childrenComponent) { \
136 child->METHOD(PARAM1,PARAM2); \
139 #define invokeChildren3(METHOD,PARAM1,PARAM2,PARAM3) \
140 foreach (Component *child, childrenComponent) { \
141 child->METHOD(PARAM1,PARAM2,PARAM3); \
144 #define invokeChildren4(METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
145 foreach (Component *child, childrenComponent) { \
146 child->METHOD(PARAM1,PARAM2,PARAM3,PARAM4); \
154 #define delegate0(HANDLER,METHOD) \
155 virtual void METHOD() override { \
156 invoke0(HANDLER,METHOD) \
159 #define delegate1(HANDLER,METHOD,PARAM_TYPE) \
160 virtual void METHOD(PARAM_TYPE param) override { \
161 invoke1(HANDLER,METHOD,param) \
164 #define delegate2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
165 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) override { \
166 invoke2(HANDLER,METHOD,param1,param2) \
169 #define delegate3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
170 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) override { \
171 invoke3(HANDLER,METHOD,param1,param2,param3) \
174 #define delegate4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3, PARAM_TYPE4) \
175 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3, PARAM_TYPE4 param4) override { \
176 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
185 #define delegateGet0(HANDLER,METHOD,TYPE) \
186 virtual TYPE METHOD() override { \
187 invokeGet0(HANDLER,METHOD) \
192 #define delegateGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
193 virtual TYPE METHOD(PARAM_TYPE param) override { \
194 invokeGet1(HANDLER,METHOD,param) \
199 #define delegateGet2(HANDLER,METHOD,TYPE,PARAM1_TYPE,PARAM2_TYPE) \
200 virtual TYPE METHOD(PARAM1_TYPE param1, PARAM2_TYPE param2) override { \
201 invokeGet2(HANDLER,METHOD,param1,param2) \
208 #define delegateConstGet0(HANDLER,METHOD,TYPE) \
209 virtual TYPE METHOD() const override { \
210 invokeGet0(HANDLER,METHOD) \
215 #define delegateConstGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
216 virtual TYPE METHOD(PARAM_TYPE param) const override { \
217 invokeGet1(HANDLER,METHOD,param) \
226 #define delegateAndInvokeChildren1(HANDLER,METHOD,PARAM_TYPE) \
227 virtual void METHOD(PARAM_TYPE param) override { \
228 invoke1(HANDLER,METHOD,param) \
229 invokeChildren1(METHOD,param) \
232 #define delegateAndInvokeChildren2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
233 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) override { \
234 invoke2(HANDLER,METHOD,param1,param2) \
235 invokeChildren2(METHOD,param1,param2) \
238 #define delegateAndInvokeChildren1Array(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,DIM) \
239 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2[DIM]) override { \
240 invoke2(HANDLER,METHOD,param1,param2) \
241 invokeChildren2(METHOD,param1,param2) \
244 #define delegateAndInvokeChildren3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
245 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) override { \
246 invoke3(HANDLER,METHOD,param1,param2,param3) \
247 invokeChildren3(METHOD,param1,param2,param3) \
250 #define delegateAndInvokeChildren4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3,PARAM_TYPE4) \
251 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3,PARAM_TYPE4 param4) override { \
252 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
253 invokeChildren4(METHOD,param1,param2,param3,param4) \
328 Component(QString file, QString name, Representation
rep = NO_REPRESENTATION);
353 Representation getRepresentation()
const;
356 bool isTopLevel()
const;
368 virtual void setModified(
bool modified =
true);
371 virtual bool getModified()
const;
389 virtual
void setVisibility(QString,
bool);
392 virtual
bool getVisibility(QString) const;
413 CAMITK_API_DEPRECATED("refreshInterfaceNode() is not required anymore. Everything should now be done transparently (
if it does not work, use setNodeModified(true) to force
a specific
InterfaceNode refresh instead)") virtual
void refreshInterfaceNode();
417 virtual
bool isSelected() const;
423 virtual
void setSelected(const
bool b, const
bool recursive = true);
426 const QString getFileName() const;
429 void setFileName(const QString&);
432 bool event(QEvent* e) override;
435 QMenu* getActionMenu();
442 QStringList getHierarchy() const override;
447 bool isInstanceOf(QString className) const override;
453 unsigned int getNumberOfPropertyWidget()
override {
483 void updateProperty(QString name, QVariant value)
override;
493 indexOfPropertyExplorerTab = index;
504 return indexOfPropertyExplorerTab;
523 bool addProperty(
Property*)
override;
543 bool doubleClicked()
override;
548 void deleteChildren() override final;
549 QString getName() const override;
550 void setName(const QString&) override;
553 QPixmap getIcon() override;
554 void setNodeModified(
bool) override final;
555 bool getNodeModified() const override;
560 bool inItalic() const override;
563 QMenu* getPopupMenu(QWidget* parent =
nullptr)
override {
572 const QString getLabel()
const override;
577 void setLabel(QString newName)
override;
579 delegateGet0(myGeometry, getPointSet, vtkSmartPointer<vtkPointSet>)
581 delegate1(myGeometry, setPointSet, vtkSmartPointer<vtkPointSet>)
583 delegate1(myGeometry, setPointData, vtkSmartPointer<vtkDataArray>)
587 delegate1(myGeometry, setDataConnection, vtkSmartPointer<vtkAlgorithmOutput>)
589 delegateGet1(myGeometry, getActor, vtkSmartPointer<vtkActor>, const RenderingModes)
593 vtkSmartPointer<vtkProp> getProp(const QString& param)
override {
595 return myGeometry->getProp(param);
598 return mySlice->getProp(param);
606 return myGeometry->getNumberOfProp();
609 return mySlice->getNumberOfProp();
615 vtkSmartPointer<vtkProp>
getProp(
unsigned int index)
override {
617 return myGeometry->getProp(index);
620 return mySlice->getProp(index);
626 bool addProp(
const QString& name, vtkSmartPointer<vtkProp> prop)
override {
628 return myGeometry->addProp(name, prop);
631 return mySlice->addProp(name, prop);
640 return myGeometry->removeProp(name);
643 return mySlice->removeProp(name);
662 void getBounds(
double* bounds)
override;
667 double getBoundingRadius()
override;
669 delegate4(myGeometry, setPointPosition,
const unsigned int,
const double,
const double,
const double)
679 virtual const EnhancedModes getEnhancedModes()
const override {
681 return myGeometry->getEnhancedModes();
684 return EnhancedModes();
693 void getActorColor(const RenderingModes,
double [4]) override;
705 delegate2(myGeometry, setMapperScalarRange,
double,
double)
707 delegate1(myGeometry, setTexture, vtkSmartPointer<vtkTexture>)
709 void setGlyphType(const GlyphTypes type, const
double size = 0.0) override;
711 delegate1(myGeometry, setLinesAsTubes,
bool)
713 delegate1(myGeometry, setMeshWorldTransform, vtkSmartPointer<vtkTransform>)
724 delegate1(mySlice, setOriginalVolume, vtkSmartPointer<vtkImageData>)
734 delegate3(mySlice, pixelPicked,
double,
double,
double)
744 delegate3(mySlice, setPixelRealPosition,
double,
double,
double)
746 delegate1(mySlice, setImageWorldTransform, vtkSmartPointer<vtkTransform>)
748 delegate1(mySlice, setArbitraryTransform, vtkSmartPointer<vtkTransform>)
751 int getNumberOfSlices() const override;
754 int getSlice() const override;
762 const QString& getFrameName() const override;
765 delegate1(myFrame, setFrameName, QString)
769 void setParentFrame(
InterfaceFrame* frame,
bool keepTransform = true) override;
771 const QVector<
InterfaceFrame*>& getChildrenFrame() const override;
773 const vtkSmartPointer<vtkTransform> getTransformFromWorld() const override;
775 const vtkSmartPointer<vtkTransform> getTransform() const override;
777 const vtkSmartPointer<vtkTransform> getTransformFromFrame(
InterfaceFrame* frame) const override;
779 delegate1(myFrame, setTransform, vtkSmartPointer<vtkTransform>)
783 delegate3(myFrame, translate,
double,
double,
double)
787 delegate3(myFrame, rotateVTK,
double,
double,
double)
789 delegate3(myFrame, setTransformTranslation,
double,
double,
double)
791 delegate3(myFrame, setTransformTranslationVTK,
double,
double,
double)
793 delegate3(myFrame, setTransformRotation,
double,
double,
double)
795 delegate3(myFrame, setTransformRotationVTK,
double,
double,
double)
797 vtkSmartPointer<vtkAxesActor> getFrameAxisActor() override;
807 virtual
void setFrameVisibility(
Viewer*,
bool) override;
809 virtual
bool getFrameVisibility(
Viewer*) const override;
812 delegate2(myFrame, setFrameVisibility, QString,
bool)
814 bool getFrameVisibility(QString) const override;
848 unsigned int indexOfPropertyExplorerTab;
869 virtual
void initRepresentation() = 0;
872 QMap<QString,
bool> myViewers;
878 QMenu* visibilityMenu;
884 bool interfaceNodeModifiedFlag;
893 return isSelectedFlag;
903 return childrenComponent;
923 return QPixmap(0, 0);
936 myGeometry->setLabel(n);
939 setNodeModified(
true);
944 modifiedFlag = modification;
964 interfaceNodeModifiedFlag = nodeModified;
969 return interfaceNodeModifiedFlag;
bool inItalic() const override
A component name is not displayed in italic by default.
Definition: sdk/libraries/core/component/Component.h:927
#define CAMITK_WARNING(MSG)
Log for warning verbosity (the most common one) Will appear by default.
Definition: Log.h:266
#define delegateGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:192
#define delegate2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:164
bool addProp(const QString &name, vtkSmartPointer< vtkProp > prop) override
insert an additional prop, defining it by its name (default visibility = false)
Definition: sdk/libraries/core/component/Component.h:626
if(${CMAKE_VERSION} VERSION_GREATER "3.3" OR ${CMAKE_VERSION} VERSION_EQUAL "3.3") option(CAMITK_INCLUDE_WHAT_YOU_USE "Enable the header analysis on you code
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:958
#define delegateAndInvokeChildren1Array(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, DIM)
Definition: sdk/libraries/core/component/Component.h:238
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
void setIndexOfPropertyExplorerTab(unsigned int index) override final
Set the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:492
Properties * properties
Definition: modeling/libraries/pml/Component.h:118
#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:261
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:943
void deleteProperties()
delete the "properties" pointer and set it to NULL
Definition: modeling/libraries/pml/Component.cpp:42
const const RenderingModes InterfaceGeometry::RenderingModes getRenderingModes() const override
see Component.cpp
Definition: sdk/libraries/core/component/Component.cpp:622
#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:226
#define delegateAndInvokeChildren2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:232
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:136
#define delegateConstGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:215
bool actionLessThan(const camitk::Action *a1, const camitk::Action *a2)
Definition: Application.cpp:778
unsigned int getIndexOfPropertyExplorerTab() override
Get the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:503
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:303
#define delegateAndInvokeChildren4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:250
bool getNodeModified() const override
Get the current modification flag.
Definition: sdk/libraries/core/component/Component.h:968
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:231
virtual QAction * getQAction(Component *target=nullptr)
Get the corresponding QAction.
Definition: Action.cpp:204
void setParent(InterfaceNode *) override
set the parent Component.
Definition: sdk/libraries/core/component/Component.cpp:587
#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:154
The generic/default application. Once this class is intanciated in the main, everything is setup....
Definition: Application.h:82
const std::string getName() const
get the name of the component
Definition: modeling/libraries/pml/Component.h:147
#define delegateConstGet0(HANDLER, METHOD, TYPE)
delegateConstGet macros: Same as delegateGet but for const METHOD
Definition: sdk/libraries/core/component/Component.h:208
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:185
unsigned int getNumberOfProp() const override
return the number of additional prop
Definition: sdk/libraries/core/component/Component.h:604
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:276
#define delegate1(HANDLER, METHOD, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:159
#define delegateAndInvokeChildren3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:244
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:907
#define invoke1(HANDLER, METHOD, PARAM)
Definition: sdk/libraries/core/component/Component.h:81
bool removeProp(const QString &name) override
remove a given additional prop.
Definition: sdk/libraries/core/component/Component.h:638
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:897
Representation
Definition: sdk/libraries/core/component/Component.h:311
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:127
void setNodeModified(bool) override final
Set up the node modification flag.
Definition: sdk/libraries/core/component/Component.h:963
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:671
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:65
const ComponentList & getChildren() override
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: sdk/libraries/core/component/Component.h:902
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:256
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
QList< Viewer * > ViewerList
A list of Viewer.
Definition: CamiTKAPI.h:139
@ GEOMETRY
this Component can be displayed as a GEOMETRY
Definition: sdk/libraries/core/component/Component.h:312
This class describes what are the methods to implement for a BitMap. An InterfaceBitMap is a kind of ...
Definition: InterfaceBitMap.h:68
#define delegate3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:169
void cellPicked(vtkIdType, bool) override
an inherited class can redefine this method something specific.
Definition: sdk/libraries/core/component/Component.h:659
vtkSmartPointer< vtkProp > getProp(unsigned int index) override
return an additional prop by its index
Definition: sdk/libraries/core/component/Component.h:615
void pointPicked(vtkIdType, bool) override
an inherited class can redefine this method something specific.
Definition: sdk/libraries/core/component/Component.h:654
vtkScalarBarRepresentation * rep
Definition: RendererWidget.cpp:510
@ SLICE
this Component can be displayed as a SLICE
Definition: sdk/libraries/core/component/Component.h:313
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:932
InterfaceNode * getParent() override
get the parent Component
Definition: sdk/libraries/core/component/Component.h:912
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
virtual void setParent(InterfaceNode *)=0
set the parent Component
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: sdk/libraries/core/component/Component.h:922
QWidget * getPropertyWidgetAt(unsigned int) override
Get the ith alternative property widget.
Definition: sdk/libraries/core/component/Component.h:461
This class describe what are the methods to implement for a hierarchical tree node.
Definition: InterfaceNode.h:58
#define CAMITK_API_DEPRECATED(X)
Definition: CamiTKAPI.h:94
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
virtual bool getModified() const
set the modified flag
Definition: sdk/libraries/core/component/Component.h:948
const QString getLabel() const override
Definition: sdk/libraries/core/component/Component.h:953
#define delegate4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:174
#define CAMITK_API
Definition: CamiTKAPI.h:49
Definition: Action.cpp:35
InterfaceFrame * getFrame()
get the associated frame
Definition: sdk/libraries/core/component/Component.h:917
QObject * getPropertyObject() override
Get the property object that could be understood by PropertyEditor.
Definition: sdk/libraries/core/component/Component.h:473