CustusX  15.8
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 class ProbeData;
50 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
51 
52 
68 class cxResourceVisualization_EXPORT ToolRep2D : public RepImpl
69 {
70  Q_OBJECT
71  public:
72  static ToolRep2DPtr New(SpaceProviderPtr spaceProvider, const QString& uid="");
73  ~ToolRep2D();
74  virtual QString getType() const;
75 
76  void setSliceProxy(SliceProxyPtr slicer);
77  void setViewportData(const Transform3D& vpMs, const DoubleBoundingBox3D& vp);
78 
79  void setUseOffset(bool on);
80  void setUseCrosshair(bool on);
81  void setUseToolLine(bool on);
82  void setUseOffsetText(bool on);
83  void setMergeOffsetAndToolLine(bool on);
84  void setTooltipPointColor(QColor c) { mTooltipPointColor = c; }
85  void setOffsetPointColor(QColor c) { mOffsetPointColor = c; }
86  void setTooltipLineColor(QColor c) { mTooltipLineColor = c; }
87  void setOffsetLineColor(QColor c) { mOffsetLineColor = c; }
88  void setOffsetStipplePattern(int pattern) { mStipplePattern = pattern; }
89 
90  private slots:
91  void sliceTransformChangedSlot(Transform3D sMr);
92  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
93  void toolVisibleSlot(bool visible);
94  void update();
95 
96  protected:
97  bool showProbe();
98  bool showOffset();
99 
100  virtual void addRepActorsToViewRenderer(ViewPtr view);
101  virtual void removeRepActorsFromViewRenderer(ViewPtr view);
102  virtual void onModifiedStartRender();
103 
104  private:
105  ToolRep2D(SpaceProviderPtr spaceProvider);
106 
107  void setProbeSector(ProbeData data);
108  double getOffset();
109  void createCrossHair(vtkRendererPtr renderer);
110  void setVisibility();
111  void createToolLine(vtkRendererPtr renderer, const Vector3D& centerPos );
112  void createOffsetText(vtkRendererPtr renderer, const Vector3D& pos );
113 
114  void updateToolLine(const Vector3D& crossPos, const Vector3D& toolTipPos, const Vector3D toolTipBackPos);
115  void updateOffsetText();
116  void crossHairResized();
117 
118  SpaceProviderPtr mSpaceProvider;
119  SliceProxyPtr mSlicer;
120  Transform3D m_vpMs;
121  DoubleBoundingBox3D mBB_vp;
122 
123  bool mUseOffset;
124  bool mUseCrosshair;
125  bool mUseToolLine;
126  bool mUseOffsetText;
127  bool mMergeOffsetAndToolLine;
128 
129  RGBColor mTooltipPointColor;
130  RGBColor mOffsetPointColor;
131  RGBColor mTooltipLineColor;
132  RGBColor mOffsetLineColor;
133  int mStipplePattern;
134 
135  CrossHair2DPtr cursor;
136  LineSegmentPtr center2Tool;
137  LineSegmentPtr tool2Back;
138  OffsetPointPtr centerPoint;
139  OffsetPointPtr toolPoint;
140  TextDisplayPtr distanceText;
141 
142  //US Probe sector
143  ProbeSectorPtr mProbeSector;
144  vtkPolyDataMapperPtr mProbeSectorPolyDataMapper;
145  vtkActorPtr mProbeSectorActor;
146 };
147 
148 
149 } // namespace vm
150 
151 #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:88
void setOffsetLineColor(QColor c)
Definition: cxToolRep2D.h:87
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class ToolRep2D > ToolRep2DPtr
Display a Tool in 2D.
Definition: cxToolRep2D.h:68
RGB color data.
void setTooltipLineColor(QColor c)
Definition: cxToolRep2D.h:86
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
void setOffsetPointColor(QColor c)
Definition: cxToolRep2D.h:85
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:84