Fraxinus  2023.01.05-dev+develop.0da12
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 
14 #ifndef CXTOOLREP2D_H_
15 #define CXTOOLREP2D_H_
16 
17 #include "cxResourceVisualizationExport.h"
18 
19 #include "vtkForwardDeclarations.h"
20 #include "cxForwardDeclarations.h"
21 #include "cxVtkHelperClasses.h"
22 #include "cxRepImpl.h"
23 #include "cxTransform3D.h"
24 #include "cxBoundingBox3D.h"
25 
26 namespace cx
27 {
28 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
29 
30 
46 class cxResourceVisualization_EXPORT ToolRep2D : public RepImpl
47 {
48  Q_OBJECT
49  public:
50  static ToolRep2DPtr New(SpaceProviderPtr spaceProvider, const QString& uid="");
51  ~ToolRep2D();
52  virtual QString getType() const;
53 
54  void setSliceProxy(SliceProxyPtr slicer);
55  void setViewportData(const Transform3D& vpMs, const DoubleBoundingBox3D& vp);
56 
57  void setUseCrosshair(bool on);
58  void setCrosshairColor(const QColor& color);
59  void setTooltipLineColor(const QColor& color);
60  void setTooltipPointColor(const QColor& color);
61  void setToolOffsetPointColor(const QColor& color);
62  void setToolOffsetLineColor(const QColor& color);
63 
64  private slots:
65  void sliceTransformChangedSlot(Transform3D sMr);
66  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
67  void toolVisibleSlot(bool visible);
68  void update();
69 
70  protected:
71  bool showProbe();
72  bool showOffset();
73 
74  virtual void addRepActorsToViewRenderer(ViewPtr view);
75  virtual void removeRepActorsFromViewRenderer(ViewPtr view);
76  virtual void onModifiedStartRender();
77 
78  private:
79  ToolRep2D(SpaceProviderPtr spaceProvider);
80 
81  double getOffset();
82  void createCrossHair(vtkRendererPtr renderer);
83  void setVisibility();
84  void createToolLine(vtkRendererPtr renderer, const Vector3D& centerPos );
85  void createOffsetText(vtkRendererPtr renderer, const Vector3D& pos );
86 
87  void updateToolLine(const Vector3D& crossPos, const Vector3D& toolTipPos, const Vector3D toolTipBackPos);
88  void updateOffsetText();
89  void crossHairResized();
90 
91  SpaceProviderPtr mSpaceProvider;
92  SliceProxyPtr mSlicer;
93  Transform3D m_vpMs;
94  DoubleBoundingBox3D mBB_vp;
95 
96  bool mUseOffset;
97  bool mUseCrosshair;
98  bool mUseToolLine;
99  bool mUseOffsetText;
100  bool mMergeOffsetAndToolLine;
101 
102  RGBColor mTooltipPointColor;
103  RGBColor mOffsetPointColor;
104  RGBColor mTooltipLineColor;
105  RGBColor mOffsetLineColor;
106  int mStipplePattern;
107 
108  CrossHair2DPtr cursor;
109  LineSegmentPtr center2Tool;
110  LineSegmentPtr tool2Back;
111  OffsetPointPtr centerPoint;
112  OffsetPointPtr toolPoint;
113  TextDisplayPtr distanceText;
114 
115  //US Probe sector
116  ProbeSectorPtr mProbeSector;
117  vtkPolyDataMapperPtr mProbeSectorPolyDataMapper;
118  vtkActorPtr mProbeSectorActor;
119 };
120 
121 
122 } // namespace vm
123 
124 #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:46
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:42
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:42
boost::shared_ptr< class OffsetPoint > OffsetPointPtr
Namespace for all CustusX production code.