ALBA
albaInteractor2DDistance.h
Go to the documentation of this file.
1/*=========================================================================
2Program: ALBA (Agile Library for Biomedical Applications)
3Module: albaInteractor2DDistance.h
4Language: C++
5Date: $Date: 2021-01-01 12:00:00 $
6Version: $Revision: 1.0.0.0 $
7Authors: Daniele Giunchi - Roberto Mucci
8==========================================================================
9Copyright (c) BIC-IOR 2021 (https://github.com/IOR-BIC)
10
11This software is distributed WITHOUT ANY WARRANTY; without even
12the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the above copyright notice for more information.
14=========================================================================*/
15
16#ifndef __albaInteractor2DDistance_h
17#define __albaInteractor2DDistance_h
18
19#include "albaInteractorPER.h"
20#include "albaEvent.h"
21#include "vtkALBATextActorMeter.h"
22#include "albaInteractor.h"
23
24
25//----------------------------------------------------------------------------
26// forward refs
27//----------------------------------------------------------------------------
28class albaRWI;
29class albaRWIBase;
31class vtkCamera;
32
33class vtkLineSource;
34class vtkCoordinate;
35class vtkPolyDataMapper2D;
36class vtkActor2D;
37class vtkRenderWindow;
38class vtkRenderer;
39class vtkXYPlotActor;
40class vtkTextActor;
41class vtkConeSource;
42
44
54//----------------------------------------------------------------------------
56 //----------------------------------------------------------------------------
57{
58public:
60
62 {
63 DISTANCE_BETWEEN_POINTS = 0,
65
67
68 };
69
72 void SetMeasureType(int t);
75 void SetMeasureTypeToDistanceBetweenPoints() {SetMeasureType(DISTANCE_BETWEEN_POINTS);};
78 void SetMeasureTypeToDistanceBetweenLines() {SetMeasureType(DISTANCE_BETWEEN_LINES);};
79
80
84
87 void GenerateHistogram(bool generate);
88
91 void GenerateHistogramOn() {GenerateHistogram(true);};
92
95 void GenerateHistogramOff() {GenerateHistogram(false);};
96
100
101
105
108 void SetManualDistance(double manualDistance);
109
113 if(m_Measure.size())
114 return m_Measure[m_Measure.size()-1];
115 else
116 return 0;
117 }
118
121 bool GetRegisterMeasure(){return m_RegisterMeasure;}
122
125 void SetLabel(albaString label);
126
129 albaString GetLabel() { if(m_MeterVector.size())
130 return albaString(m_MeterVector[m_MeterVector.size()-1]->GetText());
131 else
132 return albaString("");
133 }
137 int SizeMeasureVector(){ return m_Measure.size(); }
138
140 void ShowOnlyLastMeasure(bool show);
141
143 void ShowAllMeasures(bool show);
144
147
148 void SetColor(double r,double g,double b);
149
150protected:
153
154 albaInteractor2DDistance(bool testMode = false);
156
158 virtual void OnEvent(albaEventBase *event);
159
165 virtual void OnMove (albaEventInteraction *e);
167 virtual void OnChar (albaEventInteraction *e) {};
168
171 void DrawMeasureTool(double x, double y);
175
179
180 //persistent measure BEGIN
181 std::vector<vtkActor2D *> m_LineActorVector1;
182 std::vector<vtkPolyDataMapper2D *> m_LineMapperVector1;
183 std::vector<vtkLineSource *> m_LineSourceVector1;
184
185/* CONE
186 std::vector<vtkActor2D *> m_ConeActorVector;
187 std::vector<vtkPolyDataMapper2D *> m_ConeMapperVector;
188 std::vector<vtkConeSource *> m_ConeSourceVector;
189*/
190
191 std::vector<vtkActor2D *> m_LineActorVector2;
192 std::vector<vtkPolyDataMapper2D *> m_LineMapperVector2;
193 std::vector<vtkLineSource *> m_LineSourceVector2;
194
195 std::vector<vtkALBATextActorMeter *> m_MeterVector;
196
197
198 std::vector<vtkRenderer *> m_RendererVector;
199 //persistent measure END
200
201 vtkLineSource *m_ProbingLine;
202
203 vtkLineSource *m_Line;
204 vtkCoordinate *m_Coordinate;
205 vtkPolyDataMapper2D *m_LineMapper;
206 vtkActor2D *m_LineActor;
207
208 vtkLineSource *m_Line2;
209 vtkPolyDataMapper2D *m_LineMapper2;
210 vtkActor2D *m_LineActor2;
211 vtkRenderer *m_LastRenderer;
212 vtkRenderer *m_CurrentRenderer;
213 vtkRenderer *m_PreviousRenderer;
214
216
219 vtkXYPlotActor *m_PlotActor;
220
231
233
234 std::vector<int> m_FlagMeasureType;
235 std::vector<double> m_Measure;
236
237
239
240 double m_PickedPoint[3];
242
243 double m_Color[3];
244
245
246private:
247 albaInteractor2DDistance(const albaInteractor2DDistance&); // Not implemented.
248 void operator=(const albaInteractor2DDistance&); // Not implemented.
249
250 bool m_TestMode;
251
252 friend class albaInteractor2DDistanceTest;
253};
254#endif
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
Event class to transport a triggering button and a position from pointing devices.
albaGUIDialogPreview - a dialog widget with a render window.
Class implementing an interactor for creating 2D measure tool.
int SizeMeasureVector()
Return the dimension of Measure Vector.
void UndoMeasure()
Undo the last measure.
void GenerateHistogramOn()
Turn On the generation of the histogram from the measured line.
void SetMeasureType(int t)
Set the type of the measure, selectable from DISTANCE_BETWEEN_POINTS, DISTANCE_BETWEEN_LINES and ANGL...
virtual void OnLeftButtonUp(albaEventInteraction *e)
albaString GetLabel()
Get the label.
std::vector< vtkActor2D * > m_LineActorVector1
std::vector< vtkALBATextActorMeter * > m_MeterVector
void SetManualDistance(double manualDistance)
Set manual distance.
bool IsDisableUndoAndOkCancel()
Control if disabling various buttons.
virtual void OnChar(albaEventInteraction *e)
std::vector< vtkPolyDataMapper2D * > m_LineMapperVector1
virtual ~albaInteractor2DDistance()
vtkLineSource * m_Line2
Second line of the measure tool (used for angle measures)
void SetLabel(albaString label)
Set the label.
void GenerateHistogramOff()
Turn Off the generation of the histogram.
void ShowOnlyLastMeasure(bool show)
Show On/Off only last measure.
std::vector< vtkPolyDataMapper2D * > m_LineMapperVector2
virtual void OnButtonDown2D(albaEventInteraction *e)
albaVME * m_ProbedVME
VME probed by the m_ProbingLine.
albaGUIDialogPreview * m_HistogramDialog
virtual void OnMiddleButtonUp(albaEventInteraction *e)
virtual void OnEvent(albaEventBase *event)
Process events coming from tracker.
albaRWIBase * GetCurrentRwi()
return the current rwi
void SetColor(double r, double g, double b)
void GenerateHistogram(bool generate)
Turn On/Off the creation of the histogram.
std::vector< vtkLineSource * > m_LineSourceVector2
double GetLastDistance()
Get Last Distance.
void SetMeasureTypeToDistanceBetweenPoints()
Set the type of the measure to DISTANCE_BETWEEN_POINTS.
void RemoveMeter()
Remove the meters from the render window.
virtual void OnLeftButtonDown(albaEventInteraction *e)
virtual void OnButtonUp(albaEventInteraction *e)
albaDeviceButtonsPadMouse * m_Mouse
std::vector< vtkActor2D * > m_LineActorVector2
vtkPolyDataMapper2D * m_LineMapper2
void ShowAllMeasures(bool show)
Show On/Off all measures.
vtkLineSource * m_Line
First line of the measure tool.
std::vector< vtkLineSource * > m_LineSourceVector1
vtkRenderer * m_LastRenderer
Renderer used for the first line.
virtual void OnMiddleButtonDown(albaEventInteraction *e)
void DrawMeasureTool(double x, double y)
Draw the measure tool according to the measure type selected.
bool GetRegisterMeasure()
Get the boolean value of end measure.
virtual void OnMove(albaEventInteraction *e)
std::vector< vtkRenderer * > m_RendererVector
void CalculateMeasure()
Calculate the measure according to the measure type selected.
static albaInteractor2DDistance * NewTestInstance()
Implemented a New() function for testing mode.
albaTypeMacro(albaInteractor2DDistance, albaInteractorPER)
albaInteractor2DDistance(bool testMode=false)
vtkPolyDataMapper2D * m_LineMapper
void SetMeasureTypeToDistanceBetweenLines()
Set the type of the measure to DISTANCE_BETWEEN_LINES.
void CreateHistogram()
Create the histogram.
Class implementing routing of events based on picking.
bool m_TestMode
Flag used with cppunitTest.
albaRWIBase is a vtkRenderWindowInteractor placed on a wxWindow
Definition: albaRWIBase.h:61
albaString - performs common string operations on c-strings.
Definition: albaString.h:43
albaVME -
Definition: albaVME.h:150