26 #ifndef CAMITK_COMPONENT_H
27 #define CAMITK_COMPONENT_H
41 #include <vtkWindowLevelLookupTable.h>
42 #include <vtkImageData.h>
43 #include <vtkPointSet.h>
44 #include <vtkSmartPointer.h>
45 #include <vtkAlgorithmOutput.h>
47 #include <vtkActor2D.h>
48 #include <vtkImageActor.h>
53 class vtkUnstructuredGridAlgorithm;
54 class vtkDataSetToUnstructuredGridFilter;
55 class vtkWindowLevelLookupTable;
68 #define invoke0(HANDLER,METHOD) \
72 #define invoke1(HANDLER,METHOD,PARAM) \
74 HANDLER->METHOD(PARAM);
76 #define invoke2(HANDLER,METHOD,PARAM1,PARAM2) \
78 HANDLER->METHOD(PARAM1,PARAM2);
80 #define invoke3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
82 HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
84 #define invoke4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
86 HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
92 #define invokeGet0(HANDLER,METHOD) \
94 return HANDLER->METHOD();
96 #define invokeGet1(HANDLER,METHOD,PARAM) \
98 return HANDLER->METHOD(PARAM);
100 #define invokeGet2(HANDLER,METHOD,PARAM1,PARAM2) \
102 return HANDLER->METHOD(PARAM1,PARAM2);
104 #define invokeGet3(HANDLER,METHOD,PARAM1,PARAM2,PARAM3) \
106 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3);
108 #define invokeGet4(HANDLER,METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
110 return HANDLER->METHOD(PARAM1,PARAM2,PARAM3,PARAM4);
115 #define invokeChildren0(METHOD) \
116 foreach (Component *child, childrenComponent) { \
120 #define invokeChildren1(METHOD,PARAM) \
121 foreach (Component *child, childrenComponent) { \
122 child->METHOD(PARAM); \
125 #define invokeChildren2(METHOD,PARAM1,PARAM2) \
126 foreach (Component *child, childrenComponent) { \
127 child->METHOD(PARAM1,PARAM2); \
130 #define invokeChildren3(METHOD,PARAM1,PARAM2,PARAM3) \
131 foreach (Component *child, childrenComponent) { \
132 child->METHOD(PARAM1,PARAM2,PARAM3); \
135 #define invokeChildren4(METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \
136 foreach (Component *child, childrenComponent) { \
137 child->METHOD(PARAM1,PARAM2,PARAM3,PARAM4); \
145 #define delegate0(HANDLER,METHOD) \
146 virtual void METHOD() { \
147 invoke0(HANDLER,METHOD) \
150 #define delegate1(HANDLER,METHOD,PARAM_TYPE) \
151 virtual void METHOD(PARAM_TYPE param) { \
152 invoke1(HANDLER,METHOD,param) \
155 #define delegate2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
156 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) { \
157 invoke2(HANDLER,METHOD,param1,param2) \
160 #define delegate3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
161 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) { \
162 invoke3(HANDLER,METHOD,param1,param2,param3) \
165 #define delegate4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3, PARAM_TYPE4) \
166 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3, PARAM_TYPE4 param4) { \
167 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
176 #define delegateGet0(HANDLER,METHOD,TYPE) \
177 virtual TYPE METHOD() { \
178 invokeGet0(HANDLER,METHOD) \
183 #define delegateGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
184 virtual TYPE METHOD(PARAM_TYPE param) { \
185 invokeGet1(HANDLER,METHOD,param) \
190 #define delegateGet2(HANDLER,METHOD,TYPE,PARAM1_TYPE,PARAM2_TYPE) \
191 virtual TYPE METHOD(PARAM1_TYPE param1, PARAM2_TYPE param2) { \
192 invokeGet2(HANDLER,METHOD,param1,param2) \
199 #define delegateConstGet0(HANDLER,METHOD,TYPE) \
200 virtual TYPE METHOD() const { \
201 invokeGet0(HANDLER,METHOD) \
206 #define delegateConstGet1(HANDLER,METHOD,TYPE,PARAM_TYPE) \
207 virtual TYPE METHOD(PARAM_TYPE param) const { \
208 invokeGet1(HANDLER,METHOD,param) \
217 #define delegateAndInvokeChildren1(HANDLER,METHOD,PARAM_TYPE) \
218 virtual void METHOD(PARAM_TYPE param) { \
219 invoke1(HANDLER,METHOD,param) \
220 invokeChildren1(METHOD,param) \
223 #define delegateAndInvokeChildren2(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2) \
224 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2) { \
225 invoke2(HANDLER,METHOD,param1,param2) \
226 invokeChildren2(METHOD,param1,param2) \
229 #define delegateAndInvokeChildren1Array(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,DIM) \
230 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2[DIM]) { \
231 invoke2(HANDLER,METHOD,param1,param2) \
232 invokeChildren2(METHOD,param1,param2) \
235 #define delegateAndInvokeChildren3(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3) \
236 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3) { \
237 invoke3(HANDLER,METHOD,param1,param2,param3) \
238 invokeChildren3(METHOD,param1,param2,param3) \
241 #define delegateAndInvokeChildren4(HANDLER,METHOD,PARAM_TYPE1,PARAM_TYPE2,PARAM_TYPE3,PARAM_TYPE4) \
242 virtual void METHOD(PARAM_TYPE1 param1, PARAM_TYPE2 param2, PARAM_TYPE3 param3,PARAM_TYPE4 param4) { \
243 invoke4(HANDLER,METHOD,param1,param2,param3,param4) \
244 invokeChildren4(METHOD,param1,param2,param3,param4) \
313 Component(
const QString & file,
const QString & name, Representation rep = NO_REPRESENTATION);
330 Representation getRepresentation() const;
333 bool isTopLevel() const;
336 virtual Component * getParentComponent();
339 virtual Component * getTopLevelComponent();
342 virtual
void setModified(
bool modified = true);
345 virtual
bool getModified() const;
348 virtual
void setVisibility(
Viewer *,
bool);
351 virtual
bool getVisibility(Viewer *) const;
354 virtual
void refresh() const;
362 virtual
void refreshInterfaceNode();
365 virtual
bool isSelected() const;
371 virtual
void setSelected(const
bool b, const
bool recursive = true);
374 const QString getFileName() const;
377 void setFileName(const QString &);
380 bool event(QEvent* e);
386 QMenu * getActionAndPopupMenu();
393 QStringList getHierarchy();
398 bool isInstanceOf(QString className);
404 virtual QWidget * getPropertyWidget(QWidget* parent = 0) {
426 void updateProperty(QString name, QVariant value);
435 virtual bool setDynamicProperty(
const char *name,
const QVariant &value,
const char *description =
"",
bool isReadOnly=
false);
455 virtual void deleteChildren();
456 virtual QString getName()
const;
457 virtual void setName(
const QString&);
459 virtual bool doubleClicked();
461 virtual QPixmap getIcon();
466 virtual bool inItalic()
const;
478 const QString getLabel()
const;
483 void setLabel(QString newName);
485 delegateGet0(myGeometry, getPointSet, vtkSmartPointer<vtkPointSet> )
487 delegate1(myGeometry, setPointSet, vtkSmartPointer<vtkPointSet> )
489 delegate1(myGeometry, setPointData, vtkSmartPointer<vtkDataArray> )
493 delegate1(myGeometry, setDataConnection, vtkSmartPointer<vtkAlgorithmOutput> )
495 delegateGet1(myGeometry, getActor, vtkSmartPointer<vtkActor>, const RenderingModes)
499 virtual vtkSmartPointer<vtkProp> getProp(const QString ¶m)
502 return myGeometry->getProp(param);
504 return mySlice->getProp(param);
510 return myGeometry->getNumberOfProp();
512 return mySlice->getNumberOfProp();
516 virtual vtkSmartPointer<vtkProp>
getProp(
unsigned int index) {
518 return myGeometry->getProp(index);
520 return mySlice->getProp(index);
524 virtual bool addProp(
const QString &name, vtkSmartPointer<vtkProp> prop) {
526 return myGeometry->addProp(name, prop);
528 return mySlice->addProp(name, prop);
535 return myGeometry->removeProp(name);
537 return mySlice->removeProp(name);
556 virtual void getBounds(
double bounds[6]);
561 virtual double getBoundingRadius();
563 delegate4(myGeometry, setPointPosition,
const unsigned int,
const double,
const double,
const double);
568 virtual const InterfaceGeometry::RenderingModes getRenderingModes()
const;
579 virtual
void getActorColor(const RenderingModes,
double [4]);
591 delegate1(myGeometry, setTexture, vtkSmartPointer<vtkTexture>)
593 virtual
void setGlyphType(const GlyphTypes type, const
double size = 0.0);
595 delegate1(myGeometry, setLinesAsTubes,
bool);
606 delegate1(mySlice, setOriginalVolume, vtkSmartPointer<vtkImageData>)
614 delegateGet0(mySlice, getPixelActor, vtkSmartPointer<vtkActor>)
616 delegate3(mySlice, pixelPicked,
double,
double,
double)
622 delegate3(mySlice, setSlice,
double,
double,
double);
632 delegate3(mySlice, setPixelRealPosition,
double,
double,
double);
635 virtual
double getRotationX() const;
638 virtual
double getRotationY() const;
641 virtual
double getRotationZ() const;
644 virtual
int getNumberOfSlices() const;
647 virtual
int getSlice() const;
692 virtual
void initRepresentation() = 0;
704 static QSet<Viewer*> allViewers;
714 return isSelectedFlag;
725 return childrenComponent;
752 myGeometry->setLabel(n);
757 modifiedFlag = modification;
#define delegateAndInvokeChildren3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: Component.h:235
This class describe what are the methods to implement in order to manage dynamic properties.
Definition: InterfaceProperty.h:38
This class describes what are the methods to implement for a BitMap.
Definition: InterfaceBitMap.h:59
#define delegateAndInvokeChildren2(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2)
Definition: Component.h:223
virtual void setName(const QString &)
set the name to be displayed
Definition: Component.h:749
virtual bool inItalic() const
A component name is not displayed in italic by default.
Definition: Component.h:744
#define delegate4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: Component.h:165
Exception class to handle abortion in component instanciation.
Definition: AbortException.h:40
#define delegateAndInvokeChildren1Array(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, DIM)
Definition: Component.h:229
#define delegate3(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3)
Definition: Component.h:160
#define delegateConstGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: Component.h:206
Viewer is an abstract viewer.
Definition: Viewer.h:50
virtual void pointPicked(vtkIdType, bool)
an inherited class can redefine this method something specific.
Definition: Component.h:546
this Component can be displayed as a SLICE
Definition: Component.h:298
const QString getLabel() const
Definition: Component.h:766
#define delegateGet0(HANDLER, METHOD, TYPE)
delegateGet macros: Same as delegate macro but for an accessor non-const METHOD, returns a value of t...
Definition: Component.h:176
This class describe what are the methods to implement for a hierarchical tree node.
Definition: InterfaceNode.h:54
#define delegate0(HANDLER, METHOD)
delegate macros: completely delegates METHOD to HANDLER, eventually using parameters of given PARAM_T...
Definition: Component.h:145
this Component can be displayed as a GEOMETRY
Definition: Component.h:297
#define delegateAndInvokeChildren1(HANDLER, METHOD, PARAM_TYPE)
delegateAndInvokeChildren macros: Same as delegate but also calls METHOD, eventually with PARAM_TYPE...
Definition: Component.h:217
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: Component.h:287
CAMITK_API QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:87
#define CAMITK_API
Definition: CamiTKAPI.h:49
void setLabel(QString newName)
set the string used to display the label, do the same as setName
Definition: Component.h:770
virtual bool getModified() const
set the modified flag
Definition: Component.h:761
virtual QMenu * getPopupMenu(QWidget *parent=0)
get the popup menu to display (always return NULL, overwrite this method if you want to give here you...
Definition: Component.h:469
#define delegate1(HANDLER, METHOD, PARAM_TYPE)
Definition: Component.h:150
virtual InterfaceNode * getParent()
get the parent Component
Definition: Component.h:734
virtual bool doubleClicked()
this method is called each time the InterfaceNode is double clicked by the user.
Definition: Component.h:718
virtual QString getName() const
get the name to be displayed
Definition: Component.h:729
virtual const ComponentList & getChildren()
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: Component.h:724
virtual QPixmap getIcon()
Get the pixmap that will be displayed for this node.
Definition: Component.h:739
#define delegateAndInvokeChildren4(HANDLER, METHOD, PARAM_TYPE1, PARAM_TYPE2, PARAM_TYPE3, PARAM_TYPE4)
Definition: Component.h:241
#define delegateGet1(HANDLER, METHOD, TYPE, PARAM_TYPE)
Definition: Component.h:183
virtual unsigned int getNumberOfProp() const
return the number of additional prop
Definition: Component.h:508
Representation
The different representation that can be implemented to represent this Component in the InteractiveVi...
Definition: Component.h:296
virtual QObject * getPropertyObject()
get the property object that could be understood by PropertyEditor.
Definition: Component.h:416
#define delegateConstGet0(HANDLER, METHOD, TYPE)
delegateConstGet macros: Same as delegateGet but for const METHOD
Definition: Component.h:199
This class describes what are the methods to implement for a Geometry (rendering parameters, input/output, filters, picking parameters...)
Definition: InterfaceGeometry.h:57
virtual void setModified(bool modified=true)
set the modified flag
Definition: Component.h:756
virtual vtkSmartPointer< vtkProp > getProp(unsigned int index)
return an additional prop by its index
Definition: Component.h:516
virtual bool addProp(const QString &name, vtkSmartPointer< vtkProp > prop)
insert an additional prop, defining it by its name (default visibility = false)
Definition: Component.h:524
virtual bool removeProp(const QString &name)
remove a given additional prop.
Definition: Component.h:533
virtual void cellPicked(vtkIdType, bool)
an inherited class can redefine this method something specific.
Definition: Component.h:551