Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

InterfaceGeometry.h 12.6 KB
Newer Older
1
/*****************************************************************************
2
3
4
 * $CAMITK_LICENCE_BEGIN$
 *
 * CamiTK - Computer Assisted Medical Intervention ToolKit
5
 * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 *
 * Visit http://camitk.imag.fr for more information
 *
 * This file is part of CamiTK.
 *
 * CamiTK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * CamiTK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with CamiTK.  If not, see <http://www.gnu.org/licenses/>.
 *
 * $CAMITK_LICENCE_END$
 ****************************************************************************/
25
26
27
28
29
30
31
32
33
34
35
36

#ifndef INTERFACEGEOMETRY_H
#define INTERFACEGEOMETRY_H

// -- vtk stuff
#include <vtkType.h>
#include <vtkSmartPointer.h>

// -- vtk stuff classes
class vtkPointSet;
class vtkTexture;
class vtkActor;
37
class vtkProp;
38
39
40
class vtkDataArray;
class vtkAlgorithm;
class vtkAlgorithmOutput;
41
class vtkTransform;
42
43


44
namespace camitk {
45
46
/**
 * @ingroup group_sdk_libraries_core_component
47
48
 *
 * @brief
49
 * This class describes what are the methods to implement
50
51
52
53
54
55
56
57
 * for a Geometry (rendering parameters, input/output, filters, picking parameters...)
 *
 * An InterfaceGeometry is a kind of simplifier/wrapper for vtkPointSet.
 *
 * This class defines an "interface" (in the OOP/java meaning of the term).
 * See the introduction of GoF: "Program to an interface, not an implementation."
 * To see what Erich Gamma has to say about it: http://www.artima.com/lejava/articles/designprinciplesP.html
 * To see what Bjarne Stroustrup has to say about it: http://www.artima.com/intv/modern.html
58
 *
59
60
61
62
 * @see Geometry
 */
class InterfaceGeometry {

63
public:
64
65
    /// @enum RenderingMode (and QFlags RenderingModes) handle actor rendering options (render this InterfaceGeometry as a surface, a wireframe and set of points).
    enum RenderingMode {
66
67
68
69
        None = 0x0,      ///< no rendering mode, the InterfaceGeometry is not visible
        Surface = 0x1,   ///< the surface is visible
        Wireframe = 0x2, ///< the wireframe is visible
        Points = 0x4    ///< the points are visible
70
71
72
73
74
    };
    Q_DECLARE_FLAGS(RenderingModes, RenderingMode)

    /// @enum EnhancedMode (and QFlags EnhancedModes) handle the way the rendering actors will be enhanced or not (from completely hidden to highlighted)
    enum EnhancedMode {
75
76
77
78
        Normal = 0x0,       ///< the object is normally displayed
        Hidden = 0x1,       ///< the object is hidden
        Shaded = 0x2,       ///< the object is shaded
        Highlighted = 0x4  ///< the object is highlighted
79
80
81
82
83
    };
    Q_DECLARE_FLAGS(EnhancedModes, EnhancedMode)

    /// @enum GlyphType (and QFlags GlyphTypes) is the type of glyph attached to the geometry representation
    enum GlyphType {
84
85
        NoGlyph = 0x0,      ///< there are no glyph type attached to the geometry
        Sphere = 0x1       ///< the glyph is a nice sphere
86
87
88
89
    };
    Q_DECLARE_FLAGS(GlyphTypes, GlyphType)

    /// empty virtual destructor, to avoid memory leak
90
    virtual ~InterfaceGeometry() = default;
91
92
93

    /// get the string used to display the label
    virtual const QString getLabel() const = 0;
94

95
96
97
98
99
100
101
102
    /// set the string used to display the label
    virtual void setLabel(QString newName) = 0;

    /// @name Vtk related
    /// @{
    /// get the low-level vtk data
    virtual vtkSmartPointer<vtkPointSet> getPointSet() = 0;

103
104
    /** set the low-level data set.
     * \note if there is already a vtkPointSet, this method calls DeepCopy(ds)
105
     *
106
     * \note it is very important to overload this method in your Component subclass as this will be called by all the operators
107
108
109
110
     *  that operates a change directly on the data.
     */
    virtual void setPointSet(vtkSmartPointer<vtkPointSet>) = 0;

111
    /// set the point data (may contains a lookup table). \note values have to be in interval [0..1]
112
    virtual void setPointData(vtkSmartPointer<vtkDataArray>) = 0;
113

114
    /// set the transformation for 3D representation
115
    virtual void setMeshWorldTransform(vtkSmartPointer<vtkTransform>) = 0;
116

117
118
119
120
121
122
123

    /** get the custom algorithm pipeline input.
      * This method returns the unmodified data that you have to use
      * as an input for your filter/algorithm.
      * I.e. if you want to temporarily apply some filter/algorithm to the InterfaceGeometry
      * call this method to get the input of your filter/algorithm pipeline.
      * Typically, your custom filter/algorithm connection should start with:
124
      * \code
125
126
127
128
      *    vtkSomeAlgorithm *startFilter = vtkSomeAlgorithm::New();
      *    startFilter->SetInputConnection(theAbstractGeometry->getDataPort());
      *    ...
      *    // in the end call setDataConnection()
129
      * \endcode
130
      *
131
132
      * @see setDataConnection()
      * @see Geometry
133
134
135
136
137
138
139
140
141
      */
    virtual vtkSmartPointer<vtkAlgorithmOutput> getDataPort() const = 0;

    /** Set/reset the connection for the InterfaceGeometry internal algorithm.
      * This method sets the input for the InterfaceGeometry mapping/rendering pipeline.
      * Your should call this method to have the correct rendering of
      * your custom filter/algorithm pipelines.
      * Typically, your custom filter/algorithm connection should end with:
      *
142
      * \code
143
144
145
      *    // begining of the custom filter/algorithm pipelines (don't forget to call getDataPort()!)
      *    ...
      *    theAbstractGeometry->setDataConnection(endFilter->GetOutputPort());
146
      * \endcode
147
148
149
150
      *
      * To remove your custom pipeline, either call setDataConnection(NULL) or
      * theAbstractGeometry->setDataConnection(theAbstractGeometry->getDataPort())
      *
151
152
      * @see getDataPort()
      * @see Geometry
153
154
      */
    virtual void setDataConnection(vtkSmartPointer<vtkAlgorithmOutput>) = 0;
155
    
156
157
158
159
160
161
162
163
164
    /// Set a texture to this object.
    virtual void setTexture(vtkSmartPointer<vtkTexture>) = 0;

    /** This method is called when a vtkPoint included in the vtk representation was picked.
     *
     *  When the picking mode is set in InteractiveViewer to POINT_PICKING
     *  the vtk picker can select a specific vtkPoint in the big Geometry.
     *
     *  A Component re-implementing this method can manage a specific selection process (or any other suitable
165
     *  action).
166
167
168
     *
     *  @param pointId the vtkPoint id that was selected by picking
     *  @param pickingIsSelecting indicates if the current picking session is selecting or unselecting
169
     *  @see InteractiveViewer
170
171
172
173
174
175
176
177
178
179
180
181
     */
    virtual void pointPicked(vtkIdType pointId, bool pickingIsSelecting) = 0;

    /** This method is called when a vtkCell included in the vtk representation was picked.
     *
     *  This is the same as method getChildComponentFromVtkPointId, but for CELL_PICKING.
     *
     *  A Component re-implementing this method can manage a specific selection process (or any other suitable
     *  action).
     *
     *  @param cellId the vtkCell id that was selected by picking
     *  @param pickingIsSelecting indicates if the current picking session is selecting or unselecting
182
     *  @see InteractiveViewer
183
184
     */
    virtual void cellPicked(vtkIdType cellId, bool pickingIsSelecting) = 0;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

    /// Return the actor for the representation mode, NULL if the actor doesn't exist.
    virtual vtkSmartPointer<vtkActor> getActor(const RenderingModes) = 0;
    ///@}
    
    /// @name manage extra prop associated with an InterfaceGeometry
    /// @{
    /// TODO 
    /// - put all this management into a dedicated interface 
    /// - remove it from InterfaceBitMap and InterfaceGeometry
    /// - remove it from Slice and Geometry helper classes
    /// - create a new associated helper class
    /// - update Component class and all other code using it (if needed)
    /// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors

    /// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
    virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0;

    /// return the number of additional prop
    virtual unsigned int getNumberOfProp() const = 0;

    /// return an additional prop by its index
    virtual vtkSmartPointer<vtkProp> getProp(unsigned int) = 0;

    /** remove a given additional prop.
     * @return true if effictively done
     */
    virtual bool removeProp(const QString&) = 0;

    /** insert an additional prop, defining it by its name  (default visibility = false).
     *  @return true if the additional prop was added (i.e. another additional prop of the same name does not exist)
     */
    virtual bool addProp(const QString&,  vtkSmartPointer<vtkProp>) = 0;

219
220
221
222
    ///@}

    /// @name Helpers methods
    /// @{
223

224
    /// compute the object's bounding box [xmin,xmax, ymin,ymax, zmin,zmax]
225
    /// @param bounds the 6-sized double tab of the bounding box (in 3D).
226
    /// @warning bounds must points a 6 double-sized tab minimum.
227
    virtual void getBounds(double* bounds) = 0;
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

    /// compute the object's bounding sphere radius
    virtual double getBoundingRadius() = 0;

    /// set a given point position
    virtual void setPointPosition(const unsigned int orderNumber, const double x, const double y, const double z) = 0;

    ///@}

    /// @name rendering mode settings
    /// @{
    /// Set the actor associated to a rendering mode visible or not.
    virtual void setRenderingModes(const RenderingModes) = 0;

    /// Return if the actor associated to a rendering mode is currently visible or not.
    virtual const RenderingModes getRenderingModes() const = 0;

    /// set the enhanced mode
    virtual void setEnhancedModes(const EnhancedModes) = 0;

    /// get the current enhanced mode
    virtual const EnhancedModes getEnhancedModes() const = 0;

    /// Set the color of given representation modes.
252
253
254
    /// @param color the 4-sized double tab of color (r,g,b,a) of the actor.
    /// @warning color must points a 4 double-sized tab minimum.
    virtual void setActorColor(const RenderingModes, double* color) = 0;
255
256
257
258

    /// Set the color of given representation modes.
    virtual void setActorColor(const RenderingModes, const double, const double, const double) = 0;

259
260
261
262
    /// Get the color of given representation modes in the second parameter.
    /// @param color the 4-sized double tab of color (r,g,b,a) of the actor.
    /// @warning color must points a 4 double-sized tab minimum.
    virtual void getActorColor(const RenderingModes, double* color) = 0;
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

    /// Set an (r,g,b) color to all representation modes, without changing the opacity.
    virtual void setColor(const double, const double, const double) = 0;

    /// Set an (r,g,b,a) color to all representation modes.
    virtual void setColor(const double, const double, const double, const double) = 0;

    /// Set the opacity of this representation modes. WARNING color field (surfaceColor, ...) are not modified!
    virtual void setActorOpacity(const RenderingModes, const double) = 0;

    /// Return the opacity of a given renderng mode.
    virtual double getActorOpacity(const RenderingModes) const = 0;

    /// Set the opacity of this object. WARNING color field (surfaceColor, ...) are not modified!
    virtual void setOpacity(const double) = 0;
278
279

    /// Set the mapper scalar range
mat's avatar
UPDATED  
mat committed
280
    virtual void setMapperScalarRange(double min, double max) = 0;
281

282
    /** Set the glyph type (a glyph is a geometric representation attached to every point in the input dataset).
283
      * The glyph size is needed when the type is not NoGlyph (the size value is used depending on the current GlyphTypes) :
284
      * - if type is Sphere, size is the radius for the sphere (this is the default)
285
      * - if type is NoGlyph, then no glyph are shown
286
287
      *
      * To show the glyph call getProp("glyph")->SetVisibility(true) or getProp("glyph")->VisibilityOn().
288
      *
289
290
291
      * @param type the glyph type
      * @param size size of the glyph (default is 0.0)
      */
292
    virtual void setGlyphType(const GlyphTypes type, const double size = 0.0) = 0;
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

    /// set the lines as tubes (<b>works only for vtkDataSet representation that contains lines</b>)
    virtual void setLinesAsTubes(bool) = 0;

    ///@}
};


}

// declare the | aka OR operators
Q_DECLARE_OPERATORS_FOR_FLAGS(camitk::InterfaceGeometry::RenderingModes)
Q_DECLARE_OPERATORS_FOR_FLAGS(camitk::InterfaceGeometry::GlyphTypes)
Q_DECLARE_OPERATORS_FOR_FLAGS(camitk::InterfaceGeometry::EnhancedModes)


#endif