ALBA
albaInteractor2DAngle.h
Go to the documentation of this file.
1/*=========================================================================
2Program: ALBA (Agile Library for Biomedical Applications)
3Module: albaInteractor2DAngle.h
4Language: C++
5Date: $Date: 2021-01-01 12:00:00 $
6Version: $Revision: 1.0.0.0 $
7Authors: Paolo Quadrani
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 __albaInteractor2DAngle_h
17#define __albaInteractor2DAngle_h
18
19#include "albaInteractorPER.h"
20#include "albaEvent.h"
21#include "vtkALBATextActorMeter.h"
22
23//----------------------------------------------------------------------------
24// forward refs
25//----------------------------------------------------------------------------
26class albaRWI;
27class albaRWIBase;
29class vtkLineSource;
30class vtkCoordinate;
31class vtkPolyDataMapper2D;
32class vtkActor2D;
33class vtkRenderWindow;
34class vtkRenderer;
35class vtkTextActor;
36
37
38
48//----------------------------------------------------------------------------
49class ALBA_EXPORT albaInteractor2DAngle : public albaInteractorPER
50 //----------------------------------------------------------------------------
51{
52public:
54
56 {
57
58 ANGLE_BETWEEN_LINES = 0,
62 };
63
66 void SetMeasureType(int t);
67
68
71 void SetMeasureTypeToAngleBetweenLines() {SetMeasureType(ANGLE_BETWEEN_LINES);};
72
75 void SetMeasureTypeToAngleBetweenPoints() {SetMeasureType(ANGLE_BETWEEN_POINTS);};
76
80
84
85
89
92 void SetManualAngle(double manualAngle);
93
96 double GetLastAngle() {
97 if(m_Measure.size())
98 return m_Measure[m_Measure.size()-1];
99 else
100 return 0;
101 }
102
105 bool GetRegisterMeasure(){return m_RegisterMeasure;}
106
109 void SetLabel(albaString label);
110
113 albaString GetLabel() { if(m_MeterVector.size())
114 return albaString(m_MeterVector[m_MeterVector.size()-1]->GetText());
115 else
116 return albaString("");
117 }
118
122 int SizeMeasureVector(){ return m_Measure.size(); }
123
125 void ShowOnlyLastMeasure(bool show);
126
128 void ShowAllMeasures(bool show);
129
132
133 void SetColor(double r,double g,double b);
134
135protected:
138
146 virtual void OnMove (albaEventInteraction *e);
148 virtual void OnChar (albaEventInteraction *e) {};
149
152 void DrawMeasureTool(double x, double y);
156
157
158 //persistent measure BEGIN
159 std::vector<vtkActor2D *> m_LineActorVector1;
160 std::vector<vtkPolyDataMapper2D *> m_LineMapperVector1;
161 std::vector<vtkLineSource *> m_LineSourceVector1;
162
163 std::vector<vtkActor2D *> m_LineActorVector2;
164 std::vector<vtkPolyDataMapper2D *> m_LineMapperVector2;
165 std::vector<vtkLineSource *> m_LineSourceVector2;
166
167 std::vector<vtkALBATextActorMeter *> m_MeterVector;
168
169
170 std::vector<vtkRenderer *> m_RendererVector;
171 //persistent measure END
172
173 vtkLineSource *m_ProbingLine;
174
175 vtkLineSource *m_Line;
176 vtkCoordinate *m_Coordinate;
177 vtkPolyDataMapper2D *m_LineMapper;
178 vtkActor2D *m_LineActor;
179
180 vtkLineSource *m_Line2;
181 vtkPolyDataMapper2D *m_LineMapper2;
182 vtkActor2D *m_LineActor2;
183 vtkRenderer *m_LastRenderer;
184 vtkRenderer *m_CurrentRenderer;
185 vtkRenderer *m_PreviousRenderer;
186
188
199
200 std::vector<int> m_FlagMeasureType;
201 std::vector<double> m_Measure;
202
203
204
205 double m_Angle;
207 double m_PickedPoint[3];
209
210 double m_Color[3];
211
212private:
213 albaInteractor2DAngle(const albaInteractor2DAngle&); // Not implemented.
214 void operator=(const albaInteractor2DAngle&); // Not implemented.
215 friend class albaInteractor2DAngleTest;
216};
217#endif
218
Event class to transport a triggering button and a position from pointing devices.
Class implementing an interactor for creating 2D measure tool.
void SetMeasureType(int t)
Set the type of the measure, selectable from DISTANCE_BETWEEN_POINTS, DISTANCE_BETWEEN_LINES and ANGL...
void SetManualAngle(double manualAngle)
Set manually the angle.
void ShowOnlyLastMeasure(bool show)
Show On/Off only last measure.
virtual void OnButtonDown(albaEventInteraction *e)
Perform a pick on start of interaction to find if the user pointed an object in the scene,...
virtual void OnMiddleButtonUp(albaEventInteraction *e)
bool GetRegisterMeasure()
Get the boolean value of end measure.
std::vector< vtkPolyDataMapper2D * > m_LineMapperVector2
virtual void OnRightButtonDown(albaEventInteraction *e)
std::vector< int > m_FlagMeasureType
vtkRenderer * m_LastRenderer
Renderer used for the first line.
albaDeviceButtonsPadMouse * m_Mouse
virtual ~albaInteractor2DAngle()
std::vector< vtkPolyDataMapper2D * > m_LineMapperVector1
albaVME * m_ProbedVME
VME probed by the m_ProbingLine.
double GetLastAngle()
Get Last Angle.
virtual void OnMiddleButtonDown(albaEventInteraction *e)
void CalculateMeasure()
Calculate the measure according to the measure type selected.
albaString GetLabel()
Get the label.
std::vector< vtkLineSource * > m_LineSourceVector1
vtkPolyDataMapper2D * m_LineMapper2
std::vector< vtkALBATextActorMeter * > m_MeterVector
vtkLineSource * m_Line2
Second line of the measure tool (used for angle measures)
virtual void OnLeftButtonUp(albaEventInteraction *e)
int SizeMeasureVector()
Return the dimension of Measure Vector.
std::vector< double > m_Measure
std::vector< vtkActor2D * > m_LineActorVector2
void SetLabel(albaString label)
Set the label.
void DrawMeasureTool(double x, double y)
Draw the measure tool according to the measure type selected.
virtual void OnRightButtonUp(albaEventInteraction *e)
vtkLineSource * m_Line
First line of the measure tool.
void SetColor(double r, double g, double b)
virtual void OnLeftButtonDown(albaEventInteraction *e)
virtual void OnMove(albaEventInteraction *e)
albaRWIBase * GetCurrentRwi()
return the current rwi
bool IsDisableUndoAndOkCancel()
Control if disabling various buttons.
vtkPolyDataMapper2D * m_LineMapper
std::vector< vtkLineSource * > m_LineSourceVector2
virtual void OnButtonUp(albaEventInteraction *e)
void UndoMeasure()
Undo the last measure.
std::vector< vtkRenderer * > m_RendererVector
void RemoveMeter()
Remove the meters from the render window.
albaTypeMacro(albaInteractor2DAngle, albaInteractorPER)
void SetMeasureTypeToAngleBetweenPoints()
Set the type of the measure to ANGLE_BETWEEN_POINTS.
virtual void OnChar(albaEventInteraction *e)
void SetMeasureTypeToAngleBetweenLines()
Set the type of the measure to ANGLE_BETWEEN_LINES.
void ShowAllMeasures(bool show)
Show On/Off all measures.
std::vector< vtkActor2D * > m_LineActorVector1
Class implementing routing of events based on picking.
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