Fraxinus  16.5.0-fx-rc5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxToolRep2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 
35 #ifndef CXTOOLREP2D_H_
36 #define CXTOOLREP2D_H_
37 
38 #include "cxResourceVisualizationExport.h"
39 
40 #include "vtkForwardDeclarations.h"
41 #include "cxForwardDeclarations.h"
42 #include "cxVtkHelperClasses.h"
43 #include "cxRepImpl.h"
44 #include "cxTransform3D.h"
45 #include "cxBoundingBox3D.h"
46 
47 namespace cx
48 {
49 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
50 
51 
67 class cxResourceVisualization_EXPORT ToolRep2D : public RepImpl
68 {
69  Q_OBJECT
70  public:
71  static ToolRep2DPtr New(SpaceProviderPtr spaceProvider, const QString& uid="");
72  ~ToolRep2D();
73  virtual QString getType() const;
74 
75  void setSliceProxy(SliceProxyPtr slicer);
76  void setViewportData(const Transform3D& vpMs, const DoubleBoundingBox3D& vp);
77 
78  void setUseOffset(bool on);
79  void setUseCrosshair(bool on);
80  void setUseToolLine(bool on);
81  void setUseOffsetText(bool on);
82  void setMergeOffsetAndToolLine(bool on);
83  void setTooltipPointColor(QColor c) { mTooltipPointColor = c; }
84  void setOffsetPointColor(QColor c) { mOffsetPointColor = c; }
85  void setTooltipLineColor(QColor c) { mTooltipLineColor = c; }
86  void setOffsetLineColor(QColor c) { mOffsetLineColor = c; }
87  void setOffsetStipplePattern(int pattern) { mStipplePattern = pattern; }
88 
89  private slots:
90  void sliceTransformChangedSlot(Transform3D sMr);
91  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
92  void toolVisibleSlot(bool visible);
93  void update();
94 
95  protected:
96  bool showProbe();
97  bool showOffset();
98 
99  virtual void addRepActorsToViewRenderer(ViewPtr view);
100  virtual void removeRepActorsFromViewRenderer(ViewPtr view);
101  virtual void onModifiedStartRender();
102 
103  private:
104  ToolRep2D(SpaceProviderPtr spaceProvider);
105 
106  double getOffset();
107  void createCrossHair(vtkRendererPtr renderer);
108  void setVisibility();
109  void createToolLine(vtkRendererPtr renderer, const Vector3D& centerPos );
110  void createOffsetText(vtkRendererPtr renderer, const Vector3D& pos );
111 
112  void updateToolLine(const Vector3D& crossPos, const Vector3D& toolTipPos, const Vector3D toolTipBackPos);
113  void updateOffsetText();
114  void crossHairResized();
115 
116  SpaceProviderPtr mSpaceProvider;
117  SliceProxyPtr mSlicer;
118  Transform3D m_vpMs;
119  DoubleBoundingBox3D mBB_vp;
120 
121  bool mUseOffset;
122  bool mUseCrosshair;
123  bool mUseToolLine;
124  bool mUseOffsetText;
125  bool mMergeOffsetAndToolLine;
126 
127  RGBColor mTooltipPointColor;
128  RGBColor mOffsetPointColor;
129  RGBColor mTooltipLineColor;
130  RGBColor mOffsetLineColor;
131  int mStipplePattern;
132 
133  CrossHair2DPtr cursor;
134  LineSegmentPtr center2Tool;
135  LineSegmentPtr tool2Back;
136  OffsetPointPtr centerPoint;
137  OffsetPointPtr toolPoint;
138  TextDisplayPtr distanceText;
139 
140  //US Probe sector
141  ProbeSectorPtr mProbeSector;
142  vtkPolyDataMapperPtr mProbeSectorPolyDataMapper;
143  vtkActorPtr mProbeSectorActor;
144 };
145 
146 
147 } // namespace vm
148 
149 #endif
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkActor > vtkActorPtr
boost::shared_ptr< class CrossHair2D > CrossHair2DPtr
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class SliceProxy > SliceProxyPtr
void setOffsetStipplePattern(int pattern)
Definition: cxToolRep2D.h:87
void setOffsetLineColor(QColor c)
Definition: cxToolRep2D.h:86
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class ToolRep2D > ToolRep2DPtr
Display a Tool in 2D.
Definition: cxToolRep2D.h:67
RGB color data.
void setTooltipLineColor(QColor c)
Definition: cxToolRep2D.h:85
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
void setOffsetPointColor(QColor c)
Definition: cxToolRep2D.h:84
boost::shared_ptr< class TextDisplay > TextDisplayPtr
boost::shared_ptr< class LineSegment > LineSegmentPtr
Default implementation of Rep.
Definition: cxRepImpl.h:63
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
boost::shared_ptr< class ProbeSector > ProbeSectorPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
boost::shared_ptr< class OffsetPoint > OffsetPointPtr
void setTooltipPointColor(QColor c)
Definition: cxToolRep2D.h:83