Fraxinus  17.12
An IGT application
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 setUseCrosshair(bool on);
79  void setCrosshairColor(const QColor& color);
80  void setTooltipLineColor(const QColor& color);
81  void setTooltipPointColor(const QColor& color);
82  void setToolOffsetPointColor(const QColor& color);
83  void setToolOffsetLineColor(const QColor& color);
84 
85  private slots:
86  void sliceTransformChangedSlot(Transform3D sMr);
87  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
88  void toolVisibleSlot(bool visible);
89  void update();
90 
91  protected:
92  bool showProbe();
93  bool showOffset();
94 
95  virtual void addRepActorsToViewRenderer(ViewPtr view);
96  virtual void removeRepActorsFromViewRenderer(ViewPtr view);
97  virtual void onModifiedStartRender();
98 
99  private:
100  ToolRep2D(SpaceProviderPtr spaceProvider);
101 
102  double getOffset();
103  void createCrossHair(vtkRendererPtr renderer);
104  void setVisibility();
105  void createToolLine(vtkRendererPtr renderer, const Vector3D& centerPos );
106  void createOffsetText(vtkRendererPtr renderer, const Vector3D& pos );
107 
108  void updateToolLine(const Vector3D& crossPos, const Vector3D& toolTipPos, const Vector3D toolTipBackPos);
109  void updateOffsetText();
110  void crossHairResized();
111 
112  SpaceProviderPtr mSpaceProvider;
113  SliceProxyPtr mSlicer;
114  Transform3D m_vpMs;
115  DoubleBoundingBox3D mBB_vp;
116 
117  bool mUseOffset;
118  bool mUseCrosshair;
119  bool mUseToolLine;
120  bool mUseOffsetText;
121  bool mMergeOffsetAndToolLine;
122 
123  RGBColor mTooltipPointColor;
124  RGBColor mOffsetPointColor;
125  RGBColor mTooltipLineColor;
126  RGBColor mOffsetLineColor;
127  int mStipplePattern;
128 
129  CrossHair2DPtr cursor;
130  LineSegmentPtr center2Tool;
131  LineSegmentPtr tool2Back;
132  OffsetPointPtr centerPoint;
133  OffsetPointPtr toolPoint;
134  TextDisplayPtr distanceText;
135 
136  //US Probe sector
137  ProbeSectorPtr mProbeSector;
138  vtkPolyDataMapperPtr mProbeSectorPolyDataMapper;
139  vtkActorPtr mProbeSectorActor;
140 };
141 
142 
143 } // namespace vm
144 
145 #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
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class ToolRep2D > ToolRep2DPtr
Display a Tool in 2D.
Definition: cxToolRep2D.h:67
RGB color data.
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
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.
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
Namespace for all CustusX production code.