26 #ifndef CAMITK_COMPONENT_H
27 #define CAMITK_COMPONENT_H
45 #include <CamiTKDisableWarnings>
46 #include <vtkWindowLevelLookupTable.h>
48 #include <vtkAxesActor.h>
49 #include <vtkImageActor.h>
50 #include <CamiTKReEnableWarnings>
52 #include <vtkImageData.h>
53 #include <vtkPointSet.h>
54 #include <vtkSmartPointer.h>
55 #include <vtkAlgorithmOutput.h>
56 #include <vtkActor2D.h>
57 #include <vtkTransform.h>
63 class vtkUnstructuredGridAlgorithm;
64 class vtkDataSetToUnstructuredGridFilter;
65 class vtkWindowLevelLookupTable;
78 #define invoke0(HANDLER,METHOD) \
82 #define invoke1(HANDLER,METHOD,PARAM) \
84 HANDLER->METHOD(PARAM);
86 #define invoke2(HANDLER,METHOD,PARAM1,PARAM2) \
88 HANDLER->METHOD(PARAM1,PARAM2);
90 #define invoke3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
92 HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
94 #define invoke4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
96 HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
102 #define invokeGet0(HANDLER,METHOD) \
104 return HANDLER->METHOD();
106 #define invokeGet1(HANDLER,METHOD,PARAM) \
108 return HANDLER->METHOD(PARAM);
110 #define invokeGet2(HANDLER,METHOD,PARAM1,PARAM2) \
112 return HANDLER->METHOD(PARAM1,PARAM2);
114 #define invokeGet3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
116 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
118 #define invokeGet4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
120 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
125 #define invokeChildren0(METHOD) \
126 foreach (Component *child, childrenComponent) { \
130 #define invokeChildren1(METHOD,PARAM) \
131 foreach (Component *child, childrenComponent) { \
132 child->METHOD(PARAM); \
135 #define invokeChildren2(METHOD,PARAM1,PARAM2) \
136 foreach (Component *child, childrenComponent) { \
137 child->METHOD(PARAM1,PARAM2); \
140 #define invokeChildren3(METHOD,PARAM1,PARAM2,PARAM3) \
141 foreach (Component *child, childrenComponent) { \
142 child->METHOD(PARAM1,PARAM2,PARAM3); \
145 #define invokeChildren4(METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
146 foreach (Component *child, childrenComponent) { \
147 child->METHOD(PARAM1,PARAM2,PARAM3,PARAM4); \
155 #define delegate0(HANDLER,METHOD) \
156 virtual void METHOD() override { \
157 invoke0(HANDLER,METHOD) \
160 #define delegate1(HANDLER,METHOD,PARAM_TYPE) \
161 virtual void METHOD(PARAM_TYPE param) override { \
162 invoke1(HANDLER,METHOD,param) \
165 #define delegate2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
166 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) override { \
167 invoke2(HANDLER,METHOD,param1,param2) \
170 #define delegate3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
171 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) override { \
172 invoke3(HANDLER,METHOD,param1,param2,param3) \
175 #define delegate4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3, PARAM_TYPE4) \
176 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3, PARAM_TYPE4 param4) override { \
177 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
186 #define delegateGet0(HANDLER,METHOD,TYPE) \
187 virtual TYPE METHOD() override { \
188 invokeGet0(HANDLER,METHOD) \
193 #define delegateGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
194 virtual TYPE METHOD(PARAM_TYPE param) override { \
195 invokeGet1(HANDLER,METHOD,param) \
200 #define delegateGet2(HANDLER,METHOD,TYPE,PARAM1_TYPE,PARAM2_TYPE) \
201 virtual TYPE METHOD(PARAM1_TYPE param1, PARAM2_TYPE param2) override { \
202 invokeGet2(HANDLER,METHOD,param1,param2) \
209 #define delegateConstGet0(HANDLER,METHOD,TYPE) \
210 virtual TYPE METHOD() const override { \
211 invokeGet0(HANDLER,METHOD) \
216 #define delegateConstGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
217 virtual TYPE METHOD(PARAM_TYPE param) const override { \
218 invokeGet1(HANDLER,METHOD,param) \
227 #define delegateAndInvokeChildren1(HANDLER,METHOD,PARAM_TYPE) \
228 virtual void METHOD(PARAM_TYPE param) override { \
229 invoke1(HANDLER,METHOD,param) \
230 invokeChildren1(METHOD,param) \
233 #define delegateAndInvokeChildren2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
234 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) override { \
235 invoke2(HANDLER,METHOD,param1,param2) \
236 invokeChildren2(METHOD,param1,param2) \
239 #define delegateAndInvokeChildren1Array(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,DIM) \
240 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2[DIM]) override { \
241 invoke2(HANDLER,METHOD,param1,param2) \
242 invokeChildren2(METHOD,param1,param2) \
245 #define delegateAndInvokeChildren3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
246 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) override { \
247 invoke3(HANDLER,METHOD,param1,param2,param3) \
248 invokeChildren3(METHOD,param1,param2,param3) \
251 #define delegateAndInvokeChildren4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3,PARAM_TYPE4) \
252 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3,PARAM_TYPE4 param4) override { \
253 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
254 invokeChildren4(METHOD,param1,param2,param3,param4) \
329 Component(QString file, QString name, Representation
rep = NO_REPRESENTATION);
354 Representation getRepresentation()
const;
357 bool isTopLevel()
const;
369 virtual void setModified(
bool modified =
true);
372 virtual bool getModified()
const;
390 virtual
void setVisibility(QString,
bool);
393 virtual
bool getVisibility(QString) const;
414 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();
418 virtual
bool isSelected() const;
424 virtual
void setSelected(const
bool b, const
bool recursive = true);
427 const QString getFileName() const;
430 void setFileName(const QString&);
433 bool event(QEvent* e) override;
436 QMenu* getActionMenu();
446 virtual QVariant toVariant() const override;
449 virtual
void fromVariant(const QVariant&) override;
459 QStringList getHierarchy() const override;
462 bool isInstanceOf(QString className) const override;
468 unsigned int getNumberOfPropertyWidget()
override {
501 void updateProperty(QString name, QVariant value)
override;
511 indexOfPropertyExplorerTab = index;
522 return indexOfPropertyExplorerTab;
541 bool addProperty(
Property*)
override;
561 bool doubleClicked()
override;
566 void deleteChildren() override final;
567 QString getName() const override;
568 void setName(const QString&) override;
571 QPixmap getIcon() override;
572 void setNodeModified(
bool) override final;
573 bool getNodeModified() const override;
578 bool inItalic() const override;
581 QMenu* getPopupMenu(QWidget* parent =
nullptr)
override {
592 const QString getLabel()
const override;
595 void setLabel(QString newName)
override;
599 delegate1(myGeometry, setPointSet, vtkSmartPointer<vtkPointSet>)
601 delegate1(myGeometry, setPointData, vtkSmartPointer<vtkDataArray>)
605 delegate1(myGeometry, setDataConnection, vtkSmartPointer<vtkAlgorithmOutput>)
607 delegateGet1(myGeometry, getActor, vtkSmartPointer<vtkActor>, const RenderingModes)
613 vtkSmartPointer<vtkProp> getProp(const QString& param)
override {
615 return myGeometry->getProp(param);
618 return mySlice->getProp(param);
626 return myGeometry->getNumberOfProp();
629 return mySlice->getNumberOfProp();
635 vtkSmartPointer<vtkProp>
getProp(
unsigned int index)
override {
637 return myGeometry->getProp(index);
640 return mySlice->getProp(index);
646 bool addProp(
const QString& name, vtkSmartPointer<vtkProp> prop)
override {
648 return myGeometry->addProp(name, prop);
651 return mySlice->addProp(name, prop);
660 return myGeometry->removeProp(name);
663 return mySlice->removeProp(name);
682 void getBounds(
double* bounds)
override;
687 double getBoundingRadius()
override;
689 delegate4(myGeometry, setPointPosition,
const unsigned int,
const double,
const double,
const double)
699 virtual const EnhancedModes getEnhancedModes()
const override {
701 return myGeometry->getEnhancedModes();
704 return EnhancedModes();
713 void getActorColor(const RenderingModes,
double [4]) const override;
725 delegate2(myGeometry, setMapperScalarRange,
double,
double)
727 delegate1(myGeometry, setTexture, vtkSmartPointer<vtkTexture>)
729 void setGlyphType(const GlyphTypes type, const
double size = 0.0) override;
731 virtual
void setLinesAsTubes(
bool isTubes = true,
bool radiusFromLength = true,
double radiusFactor = 1.0 / 40.0,
int numberOfSides = 5)
override {
733 myGeometry->setLinesAsTubes(isTubes, radiusFromLength, radiusFactor, numberOfSides);
737 delegate1(myGeometry, setMeshWorldTransform, vtkSmartPointer<vtkTransform>)
748 delegate1(mySlice, setOriginalVolume, vtkSmartPointer<vtkImageData>)
768 delegate3(mySlice, setPixelRealPosition,
double,
double,
double)
770 delegate1(mySlice, setImageWorldTransform, vtkSmartPointer<vtkTransform>)
772 delegate1(mySlice, setArbitraryTransform, vtkSmartPointer<vtkTransform>)
775 int getNumberOfSlices() const override;
778 int getSlice() const override;
787 const QString& getFrameName() const override;
793 void setParentFrame(
InterfaceFrame* frame,
bool keepTransform = true) override;
795 const QVector<
InterfaceFrame*>& getChildrenFrame() const override;
797 const vtkSmartPointer<vtkTransform> getTransformFromWorld() const override;
799 const vtkSmartPointer<vtkTransform> getTransform() const override;
801 const vtkSmartPointer<vtkTransform> getTransformFromFrame(
InterfaceFrame* frame) const override;
803 delegate1(myFrame, setTransform, vtkSmartPointer<vtkTransform>)
813 delegate3(myFrame, setTransformTranslation,
double,
double,
double)
815 delegate3(myFrame, setTransformTranslationVTK,
double,
double,
double)
817 delegate3(myFrame, setTransformRotation,
double,
double,
double)
819 delegate3(myFrame, setTransformRotationVTK,
double,
double,
double)
821 vtkSmartPointer<vtkAxesActor> getFrameAxisActor() override;
831 virtual
void setFrameVisibility(
Viewer*,
bool) override;
833 virtual
bool getFrameVisibility(
Viewer*) const override;
838 bool getFrameVisibility(QString) const override;
872 unsigned int indexOfPropertyExplorerTab;
893 virtual
void initRepresentation() = 0;
896 QMap<QString,
bool> myViewers;
902 QMenu* visibilityMenu;
905 QMap<QString,
Property*> propertyMap;
908 bool interfaceNodeModifiedFlag;
917 return isSelectedFlag;
927 return childrenComponent;
947 return QPixmap(0, 0);
960 myGeometry->setLabel(n);
963 setNodeModified(
true);
968 modifiedFlag = modification;
988 interfaceNodeModifiedFlag = nodeModified;
993 return interfaceNodeModifiedFlag;
#define CAMITK_API_DEPRECATED(X)
Definition: CamiTKAPI.h:94
#define CAMITK_API
Definition: CamiTKAPI.h:49
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
Interface for all objects that should be serialized by the PersistenceManager.
Definition: InterfacePersistence.h:36
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:303
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:510
delegateGet0(myGeometry, getPointSet, vtkSmartPointer< vtkPointSet >) delegate1(myGeometry
Representation
The different representation that can be implemented to represent this Component in the InteractiveVi...
Definition: sdk/libraries/core/component/Component.h:312
@ GEOMETRY
this Component can be displayed as a GEOMETRY
Definition: sdk/libraries/core/component/Component.h:313
@ SLICE
this Component can be displayed as a SLICE
Definition: sdk/libraries/core/component/Component.h:314
unsigned int getNumberOfProp() const override
return the number of additional prop
Definition: sdk/libraries/core/component/Component.h:624
unsigned int getIndexOfPropertyExplorerTab() override
Get the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:521
InterfaceNode * getParent() override
get the parent Component
Definition: sdk/libraries/core/component/Component.h:936
const QObject * getPropertyObject() const override
Definition: sdk/libraries/core/component/Component.h:491
delegate4(myGeometry, setPointPosition, const unsigned int, const double, const double, const double) delegateAndInvokeChildren1(myGeometry
InterfaceFrame * getFrame()
get the associated frame
Definition: sdk/libraries/core/component/Component.h:941
vtkSmartPointer< vtkProp > getProp(unsigned int index) override
return an additional prop by its index
Definition: sdk/libraries/core/component/Component.h:635
bool removeProp(const QString &name) override
remove a given additional prop.
Definition: sdk/libraries/core/component/Component.h:658
bool inItalic() const override
A component name is not displayed in italic by default.
Definition: sdk/libraries/core/component/Component.h:951
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:956
virtual void setModified(bool modified=true)
set the modified flag
Definition: sdk/libraries/core/component/Component.h:967
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:931
void pointPicked(vtkIdType, bool) override
an inherited class can redefine this method something specific.
Definition: sdk/libraries/core/component/Component.h:674
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:646
void setNodeModified(bool) override final
Set up the node modification flag.
Definition: sdk/libraries/core/component/Component.h:987
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: sdk/libraries/core/component/Component.h:946
void cellPicked(vtkIdType, bool) override
an inherited class can redefine this method something specific.
Definition: sdk/libraries/core/component/Component.h:679
QObject * getPropertyObject() override
Get the property object that could be understood by PropertyEditor.
Definition: sdk/libraries/core/component/Component.h:488
virtual bool getModified() const
set the modified flag
Definition: sdk/libraries/core/component/Component.h:972
delegateAndInvokeChildren1Array(myGeometry, setActorColor, const RenderingModes, double, 4) delegateAndInvokeChildren4(myGeometry
const QString getLabel() const override
Definition: sdk/libraries/core/component/Component.h:977
bool getNodeModified() const override
Get the current modification flag.
Definition: sdk/libraries/core/component/Component.h:992
bool doubleClicked() override
This method is called each time the InterfaceNode is double clicked by the user.
Definition: sdk/libraries/core/component/Component.h:921
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:982
QWidget * getPropertyWidgetAt(unsigned int) override
Get the ith alternative property widget.
Definition: sdk/libraries/core/component/Component.h:476
const ComponentList & getChildren() override
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: sdk/libraries/core/component/Component.h:926
This class describes what are the methods to implement for a BitMap.
Definition: InterfaceBitMap.h:68
This class describes what are the methods to implement in order to manage a Component position in spa...
Definition: InterfaceFrame.h:64
This class describes what are the methods to implement for a Geometry (rendering parameters,...
Definition: InterfaceGeometry.h:61
This class describe what are the methods to implement for a hierarchical tree node.
Definition: InterfaceNode.h:58
This class describe what are the methods to implement in order to manage dynamic properties.
Definition: InterfaceProperty.h:43
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:280
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:181
Definition: Action.cpp:36
vtkScalarBarRepresentation * rep
Definition: RendererWidget.cpp:554
void refresh()
refresh the display
#define delegate3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:170
#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:155
#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:227
#define delegateConstGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:216
#define delegateAndInvokeChildren2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:233
#define delegate2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: sdk/libraries/core/component/Component.h:165
#define delegate1(HANDLER, METHOD, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:160
#define delegateAndInvokeChildren4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: sdk/libraries/core/component/Component.h:251
#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:186
#define delegateAndInvokeChildren3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: sdk/libraries/core/component/Component.h:245
#define delegateGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: sdk/libraries/core/component/Component.h:193
#define delegateConstGet0(HANDLER, METHOD, TYPE)
delegateConstGet macros: Same as delegateGet but for const METHOD
Definition: sdk/libraries/core/component/Component.h:209