 |
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) \
298 class CAMITK_API Component :
public InterfaceProperty,
public InterfaceNode,
public InterfaceGeometry,
public InterfaceBitMap,
public InterfaceFrame {
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;
423 unsigned int getNumberOfPropertyWidget() {
431 QWidget* getPropertyWidgetAt(
unsigned int i) {
443 QObject* getPropertyObject() {
453 void updateProperty(QString name, QVariant value)
override;
462 inline void setIndexOfPropertyExplorerTab(
unsigned int index) {
463 this->indexOfPropertyExplorerTab = index;
473 inline unsigned int getIndexOfPropertyExplorerTab() {
474 return this->indexOfPropertyExplorerTab;
483 Q_INVOKABLE Property* getProperty(QString name)
override;
493 bool addProperty(Property*)
override;
502 void addChild(InterfaceNode*)
override;
503 void attachChild(InterfaceNode*)
override;
507 void removeChild(InterfaceNode*)
override;
510 void setParent(InterfaceNode*)
override;
513 void deleteChildren()
override;
514 QString getName()
const override;
515 void setName(
const QString&)
override;
517 bool doubleClicked()
override;
518 InterfaceNode* getParent()
override;
519 QPixmap getIcon()
override;
524 bool inItalic()
const override;
527 QMenu* getPopupMenu(QWidget* parent =
nullptr) {
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);
567 unsigned int getNumberOfProp()
const {
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);
613 void pointPicked(vtkIdType,
bool) {}
618 void cellPicked(vtkIdType,
bool) {}
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>)
685 delegateGet0(mySlice, getPixelActor, vtkSmartPointer<vtkActor>)
689 delegate3(mySlice, pixelPicked,
double,
double,
double)
695 delegate3(mySlice, setSlice,
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)
738 delegate3(myFrame, rotate,
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;
812 QMap<
Viewer*,
bool> myViewers;
818 QMap<QString,
Property*> propertyMap;
824 static QSet<
Viewer*> allViewers;
833 inline
bool Component::isSelected()
const {
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:868
static QSet< Viewer * > allViewers
Definition: sdk/libraries/core/component/Component.h:825
#define delegateGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:187
#define delegate2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:159
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:895
#define delegateAndInvokeChildren1Array(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, DIM)
Definition: sdk/libraries/core/component/Component.h:233
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:135
Properties * properties
Definition: modeling/libraries/pml/Component.h:117
QAction * getQAction()
Get the corresponding QAction.
Definition: Action.cpp:182
#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:256
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:881
void deleteProperties()
delete the "properties" pointer and set it to NULL
Definition: modeling/libraries/pml/Component.cpp:42
#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:221
#define delegateAndInvokeChildren2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:227
virtual Component * getTopLevelComponent()
get the top-level component
Definition: sdk/libraries/core/component/Component.cpp:265
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:94
#define delegateConstGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:210
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:312
#define delegateAndInvokeChildren4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:245
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:85
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:228
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:240
#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:149
QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:91
#define delegateConstGet0(HANDLER, METHOD, TYPE)
delegateConstGet macros: Same as delegateGet but for const METHOD
Definition: sdk/libraries/core/component/Component.h:203
This class describes what are the methods to implement for a Geometry (rendering parameters,...
Definition: InterfaceGeometry.h:60
#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:180
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:271
#define delegate1(HANDLER, METHOD, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:154
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:557
#define delegateAndInvokeChildren3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:239
bool exclusive
Definition: modeling/libraries/pml/Component.h:130
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:848
#define invoke1(HANDLER, METHOD, PARAM)
Definition: sdk/libraries/core/component/Component.h:76
This class describes what are the methods to implement in order to manage a Component position in spa...
Definition: InterfaceFrame.h:63
bool doubleClicked() override
this method is called each time the InterfaceNode is double clicked by the user.
Definition: sdk/libraries/core/component/Component.h:837
Representation
Definition: sdk/libraries/core/component/Component.h:306
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:88
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:461
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:70
const ComponentList & getChildren() override
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: sdk/libraries/core/component/Component.h:843
A component is something that composed something and could also be a part of something.
Definition: modeling/libraries/pml/Component.h:47
#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:251
Viewer is an abstract viewer.
Definition: Viewer.h:54
This class describes what are the methods to implement for a BitMap. An InterfaceBitMap is a kind of ...
Definition: InterfaceBitMap.h:62
void removeProp(vtkSmartPointer< vtkProp > p, bool refresh=false)
remove the given vtkProp (e.g.
#define delegate3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:164
vtkScalarBarRepresentation * rep
Definition: RendererWidget.cpp:717
Describes the properties common to all structures and components.
Definition: Properties.h:58
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:873
InterfaceNode * getParent() override
get the parent Component
Definition: sdk/libraries/core/component/Component.h:853
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
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:863
This class describe what are the methods to implement for a hierarchical tree node.
Definition: InterfaceNode.h:57
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:297
virtual bool getModified() const
set the modified flag
Definition: sdk/libraries/core/component/Component.h:886
const QString getLabel() const override
Definition: sdk/libraries/core/component/Component.h:891
#define delegate4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:169
#define CAMITK_API
Definition: CamiTKAPI.h:48
Definition: Action.cpp:36
virtual InterfaceFrame * getFrame()
get the associated frame
Definition: sdk/libraries/core/component/Component.h:858