Fraxinus  17.12-rc2
An IGT application
cxToolRep3D.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 #ifndef CXTOOLREP3D_H_
35 #define CXTOOLREP3D_H_
36 
37 #include "cxResourceVisualizationExport.h"
38 
39 #include "cxRepImpl.h"
40 #include "cxTransform3D.h"
41 
42 #include "vtkForwardDeclarations.h"
43 #include "cxForwardDeclarations.h"
44 #include "cxVtkHelperClasses.h"
45 #include "cxViewportListener.h"
46 
47 namespace cx
48 {
49 
50 typedef boost::shared_ptr<class VideoSourceGraphics> VideoSourceGraphicsPtr;
51 typedef boost::shared_ptr<class ToolTracer> ToolTracerPtr;
52 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
53 
54 
72 class cxResourceVisualization_EXPORT ToolRep3D : public RepImpl
73 {
74  Q_OBJECT
75 public:
76  static ToolRep3DPtr New(SpaceProviderPtr spaceProvider, const QString& uid="");
77  virtual ~ToolRep3D();
78  virtual QString getType() const;
79 
80  virtual void setTool(ToolPtr tool);
81  virtual bool hasTool(ToolPtr tool) const;
82  virtual ToolPtr getTool();
83  ToolTracerPtr getTracer();
84  void setSphereRadius(double radius);
85 
86  void setStayHiddenAfterVisible(bool val);
87  void setStayVisibleAfterHide(bool val);
88  void setOffsetPointVisibleAtZeroOffset(bool val);
89  void setSphereRadiusInNormalizedViewport(bool on);
90  void setTooltipPointColor(const QColor& color);
91  void setToolOffsetPointColor(const QColor& color);
92  void setToolOffsetLineColor(const QColor& color);
93 
94 protected:
95  ToolRep3D(SpaceProviderPtr spaceProvider);
96  virtual void addRepActorsToViewRenderer(ViewPtr view);
97  virtual void removeRepActorsFromViewRenderer(ViewPtr view);
98  bool showProbe();
99  virtual void onModifiedStartRender();
100 
101 private slots:
102  void probeSectorChanged();
107  void receiveVisible(bool visible);
108  void tooltipOffsetSlot(double val);
109  void updateToolActor();
110 
111 private:
112  void update();
113  void updateOffsetGraphics();
114  void scaleSpheres();
115 
116  double mSphereRadius;
117  ToolPtr mTool;
118  vtkActorPtr mToolActor;
119  vtkPolyDataMapperPtr mPolyDataMapper;
120  GraphicalPoint3DPtr mTooltipPoint;
121  GraphicalPoint3DPtr mOffsetPoint;
122  GraphicalLine3DPtr mOffsetLine;
123  bool mStayHiddenAfterVisible;
124  bool mStayVisibleAfterHide;
125  bool mOffsetPointVisibleAtZeroOffset;
126  bool mSphereRadiusInNormalizedViewport;
127  ToolTracerPtr mTracer;
128  ViewportListenerPtr mViewportListener;
129  SpaceProviderPtr mSpaceProvider;
130 
131  //US Probe sector
132  ProbeSectorPtr mProbeSector;
133  vtkPolyDataMapperPtr mProbeSectorPolyDataMapper;
134  vtkActorPtr mProbeSectorActor;
135  QColor mTooltipPointColor;
136  QColor mOffsetPointColor;
137  QColor mOffsetLineColor;
138  int mStipplePattern;
139 };
140 } // namespace cx
141 
142 #endif /*CXTOOLREP3D_H_*/
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkActor > vtkActorPtr
boost::shared_ptr< class GraphicalPoint3D > GraphicalPoint3DPtr
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
boost::shared_ptr< class ViewportListener > ViewportListenerPtr
boost::shared_ptr< class ToolTracer > ToolTracerPtr
boost::shared_ptr< class View > ViewPtr
Display a Tool in 3D.
Definition: cxToolRep3D.h:72
boost::shared_ptr< class VideoSourceGraphics > VideoSourceGraphicsPtr
Default implementation of Rep.
Definition: cxRepImpl.h:63
boost::shared_ptr< class ProbeSector > ProbeSectorPtr
boost::shared_ptr< class GraphicalLine3D > GraphicalLine3DPtr
boost::shared_ptr< class ToolRep3D > ToolRep3DPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr