Computer Assited Medical Intervention Tool Kit  version 5.0
Frame.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 #ifndef FRAME_H
26 #define FRAME_H
27 
28 #include "CamiTKAPI.h"
29 
30 #include "InterfaceFrame.h"
31 
32 class vtkTransformPolyDataFilter;
33 class vtkAxesActor;
34 
35 namespace camitk {
53 public:
60  Frame(vtkSmartPointer<vtkTransform> transform = nullptr, Frame* parentFrame = nullptr);
61 
63  ~Frame() override;
64 
69  const QString& getFrameName() const override final;
71 
73  void setFrameName(QString name) override;
74 
76  InterfaceFrame* getParentFrame() const override;
77 
89  void setParentFrame(InterfaceFrame* parent, bool keepTransform = true) override final;
90 
95  const QVector<InterfaceFrame*>& getChildrenFrame() const override;
102  const vtkSmartPointer<vtkTransform> getTransformFromWorld() const override;
104 
106  const vtkSmartPointer<vtkTransform> getTransform() const override;
107 
109  const vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame* frame) const override;
110 
115  void setTransform(vtkSmartPointer<vtkTransform> transform) override final;
116 
121  void resetTransform() override;
122 
126  void translate(double x, double y, double z) override;
127 
133  void rotate(double aroundX, double aroundY, double aroundZ) override;
134 
139  void rotateVTK(double aroundX, double aroundY, double aroundZ) override;
140 
146  void setTransformTranslation(double x, double y, double z) override;
147 
154  void setTransformTranslationVTK(double x, double y, double z) override;
155 
161  void setTransformRotation(double aroundX, double aroundY, double aroundZ) override;
162 
169  void setTransformRotationVTK(double aroundX, double aroundY, double aroundZ) override;
170 
176  vtkSmartPointer<vtkAxesActor> getFrameAxisActor() override;
177 
179 
189  CAMITK_API_DEPRECATED("Please use Frame::setFrameVisibility(QString viewerName, bool) instead") void setFrameVisibility(Viewer*, bool) override;
190 
194  CAMITK_API_DEPRECATED("Please use Frame::getFrameVisibility(QString viewerName, bool) instead") bool getFrameVisibility(Viewer*) const override;
196 
200  void setFrameVisibility(QString, bool) override;
201 
205  bool getFrameVisibility(QString) const override;
206 
211  void removeFrameChild(InterfaceFrame* frame) override final;
212 
215  void initAttributes();
217 
218 protected:
219 
223  QString frameName;
224 
230 
235  vtkSmartPointer<vtkTransform> transformParentToMe;
236 
244  vtkSmartPointer<vtkTransform> transformWorldToMe;
245 
249  vtkSmartPointer<vtkTransformPolyDataFilter> representationTransformFilter;
250 
254  QVector<InterfaceFrame*> childrenFrame;
255 
259  QVector<InterfaceFrame*> computeDescendants(InterfaceFrame*);
260 
261 private:
262 
264  void addFrameChild(InterfaceFrame* frame) override;
265 
267  static int nbTotalFrames;
268 
270  vtkSmartPointer<vtkAxesActor> axes;
271 
273  QMap<Viewer*, bool> frameViewers;
274 
275 };
276 }
277 #endif // FRAME_H
camitk::Frame::getParentFrame
InterfaceFrame * getParentFrame() const override
Get the parent frame.
Definition: Frame.cpp:146
camitk::Frame::initAttributes
void initAttributes()
Definition: Frame.cpp:96
CAMITK_WARNING_ALT
#define CAMITK_WARNING_ALT(MSG)
Definition: Log.h:267
camitk::Frame::translate
void translate(double x, double y, double z) override
Apply a translation relative to the current position.
Definition: Frame.cpp:279
camitk::Frame::nbTotalFrames
static int nbTotalFrames
To be able to give a default unique identifier to each created frame.
Definition: Frame.h:267
camitk::Frame::getChildrenFrame
const QVector< InterfaceFrame * > & getChildrenFrame() const override
Get the Children Frames from the current Frame in the Frame Hierarchy The Frame hierarchy may not be ...
Definition: Frame.cpp:151
camitk::Frame::Frame
Frame(vtkSmartPointer< vtkTransform > transform=nullptr, Frame *parentFrame=nullptr)
Default constructor with transformation.
Definition: Frame.cpp:73
camitk::InterfaceFrame::removeFrameChild
virtual void removeFrameChild(InterfaceFrame *frame)=0
Remove the input frame as a child of the current frame.
camitk::Frame::computeDescendants
QVector< InterfaceFrame * > computeDescendants(InterfaceFrame *)
Compute all the descendants of the input frame.
Definition: Frame.cpp:551
CamiTKAPI.h
if
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
camitk::Frame::frameName
QString frameName
Frame unique identifier.
Definition: Frame.h:223
camitk::Frame::setFrameVisibility
void setFrameVisibility(QString, bool) override
Set the Component Frame visible for a given viewer.
Definition: Frame.cpp:487
camitk::Frame::getTransformFromFrame
const vtkSmartPointer< vtkTransform > getTransformFromFrame(InterfaceFrame *frame) const override
Get a COPY of the transformation with respect to another frame.
Definition: Frame.cpp:233
camitk::Frame::transformParentToMe
vtkSmartPointer< vtkTransform > transformParentToMe
Transformation to represent my points (expressed in my frame) in my parent's frame.
Definition: Frame.h:235
camitk::Frame::setParentFrame
void setParentFrame(InterfaceFrame *parent, bool keepTransform=true) override final
Set the parent frame to the parameter frame.
Definition: Frame.cpp:156
camitk::Frame::representationTransformFilter
vtkSmartPointer< vtkTransformPolyDataFilter > representationTransformFilter
Transform Filter to store the transformation for the Frame's 3D representation.
Definition: Frame.h:249
camitk::Frame::axes
vtkSmartPointer< vtkAxesActor > axes
Geometric representation of the frame (vtkAxes)
Definition: Frame.h:270
camitk::Frame::removeFrameChild
void removeFrameChild(InterfaceFrame *frame) override final
If the parent frame keeps track of its children, when a child is deleted it should warn its parent.
Definition: Frame.cpp:216
camitk::Frame::setFrameName
void setFrameName(QString name) override
Set the Frame Unique identifyer.
Definition: Frame.cpp:141
camitk::Frame::setTransformRotation
void setTransformRotation(double aroundX, double aroundY, double aroundZ) override
Set the rotation part of the 3D space transformation of the current frame.
Definition: Frame.cpp:405
camitk::Frame::setTransformTranslation
void setTransformTranslation(double x, double y, double z) override
Set the translation part of the 3D space transformation of the current frame.
Definition: Frame.cpp:327
camitk::Frame::resetTransform
void resetTransform() override
Set the current frame transform to identity.
Definition: Frame.cpp:271
camitk::InterfaceFrame::getTransformFromWorld
virtual const vtkSmartPointer< vtkTransform > getTransformFromWorld() const =0
Transforms accessors / Modifyers.
camitk::Frame::~Frame
~Frame() override
Default Destructor.
Definition: Frame.cpp:119
camitk::Frame::setTransformTranslationVTK
void setTransformTranslationVTK(double x, double y, double z) override
Set the translation part of the 3D space transformation of the current frame.
Definition: Frame.cpp:386
camitk::InterfaceFrame::addFrameChild
virtual void addFrameChild(InterfaceFrame *frame)=0
Add the input frame as a child of the current frame.
Log.h
camitk::Frame::getFrameName
const QString & getFrameName() const override final
Hierarchy accessors / Modifyers.
Definition: Frame.cpp:136
camitk::InterfaceFrame::getFrameName
virtual const QString & getFrameName() const =0
Hierarchy accessors / Modifyers.
camitk::Application::getViewer
static Viewer * getViewer(QString name)
get the pointer to a registered viewer given its name
Definition: Application.cpp:882
camitk::Frame::getTransform
const vtkSmartPointer< vtkTransform > getTransform() const override
Get a the transformation with respect to the parent frame.
Definition: Frame.cpp:228
camitk::axeYTextProp
vtkSmartPointer< vtkTextProperty > axeYTextProp
Definition: RendererWidget.cpp:340
InterfaceFrame.h
camitk::Frame::addFrameChild
void addFrameChild(InterfaceFrame *frame) override
When the current Frame is set to parent, it must update its children list.
Definition: Frame.cpp:209
camitk::Frame::rotate
void rotate(double aroundX, double aroundY, double aroundZ) override
Apply rotations relative to the current position in the alphabetical order (X, Y, Z).
Definition: Frame.cpp:289
camitk::Frame::setTransform
void setTransform(vtkSmartPointer< vtkTransform > transform) override final
Set the current input frame position (according to its parent Frame)
Definition: Frame.cpp:263
camitk::Frame
Represents a hierarchy of frames.
Definition: Frame.h:52
camitk::axeZTextProp
vtkSmartPointer< vtkTextProperty > axeZTextProp
Definition: RendererWidget.cpp:347
Frame.h
camitk::InterfaceFrame
This class describes what are the methods to implement in order to manage a Component position in spa...
Definition: InterfaceFrame.h:64
camitk::InterfaceFrame::setParentFrame
virtual void setParentFrame(InterfaceFrame *parent, bool keepTransform=true)=0
Set the parent frame and update or not its transform during the parent transition.
camitk::transform
vtkSmartPointer< vtkTransform > transform
Definition: RendererWidget.cpp:372
camitk::Frame::rotateVTK
void rotateVTK(double aroundX, double aroundY, double aroundZ) override
Apply a rotation relative to the current position, using the VTK rotation order (Z,...
Definition: Frame.cpp:308
camitk::Frame::getTransformFromWorld
const vtkSmartPointer< vtkTransform > getTransformFromWorld() const override
Transforms accessors / Modifyers.
Definition: Frame.cpp:223
camitk::axeXTextProp
vtkSmartPointer< vtkTextProperty > axeXTextProp
Definition: RendererWidget.cpp:326
camitk::Viewer
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
camitk::Frame::childrenFrame
QVector< InterfaceFrame * > childrenFrame
List of children Frames to keep track of Frame hierarchy.
Definition: Frame.h:254
Viewer.h
camitk::Frame::setTransformRotationVTK
void setTransformRotationVTK(double aroundX, double aroundY, double aroundZ) override
Set the rotation part of the 3D space transformation of the current frame.
Definition: Frame.cpp:423
camitk::Frame::frameViewers
QMap< Viewer *, bool > frameViewers
List of Viewers in which the frame is visible.
Definition: Frame.h:273
camitk::Frame::getFrameVisibility
bool getFrameVisibility(QString) const override
Get the Component Frame visibility for a given viewer.
Definition: Frame.cpp:519
camitk::Frame::parentFrame
InterfaceFrame * parentFrame
The Parent Frame.
Definition: Frame.h:229
CAMITK_API_DEPRECATED
#define CAMITK_API_DEPRECATED(X)
Definition: CamiTKAPI.h:94
camitk::Frame::getFrameAxisActor
vtkSmartPointer< vtkAxesActor > getFrameAxisActor() override
Gives the 3D representation of the frame (based on xyd arrows)
Definition: Frame.cpp:442
Application.h
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35
camitk::Frame::transformWorldToMe
vtkSmartPointer< vtkTransform > transformWorldToMe
Transformation to represent my points (expressed in my frame) in the world's frame.
Definition: Frame.h:244