-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInteractorActor.h
More file actions
130 lines (108 loc) · 3.44 KB
/
InteractorActor.h
File metadata and controls
130 lines (108 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#pragma once
#ifndef InteractorActor_H
#define InteractorActor_H
#include "VTK_Def.h"
#include "vtkRotationalExtrusionFilter.h"
#include <vtkOBBTree.h>
#include <vtkPointSource.h>
#include <vtkNamedColors.h>
#include <vtkGlyph3DMapper.h>
#include <vtkSuperquadricSource.h>
#include <vtkKdTreePointLocator.h>
#include <vtkMatrix4x4.h>
#include <vtkInteractorStyleTrackballActor.h>
#include "vtkAssembly.h"
#include "vtkAssemblyPath.h"
#include <vector>
class vtkPositionCallback : public vtkCommand
{
public:
static vtkPositionCallback *New()
{
return new vtkPositionCallback;
}
static bool firstStart;
//static vector<vtkSmartPointer<vtkFollower>> conLabels;
static vtkSmartPointer<vtkFollower> xLabel;
static vtkSmartPointer<vtkFollower> yLabel;
static vtkSmartPointer<vtkFollower> zLabel;
static vtkSmartPointer<vtkAssembly> Axes;
void Execute(vtkObject* vtkNotUsed(caller), unsigned long vtkNotUsed(event),
void *vtkNotUsed(callData))
{
if (!Axes) return;
int followerId = 0;
Axes->InitPathTraversal();
vtkAssemblyPath *path = 0;
vtkSmartPointer<vtkFollower> followers[3] = { vtkPositionCallback::xLabel, vtkPositionCallback::yLabel, vtkPositionCallback::zLabel };
//Axes는 arrow3개와 라벨 3개로 구성. 라벨만 follower 적용하기 위하여 path 시작점 변경
path = Axes->GetNextPath();
path = Axes->GetNextPath();
path = Axes->GetNextPath();
for (int i = 0; i < 3; i++)
{
path = Axes->GetNextPath();
vtkProp3D *prop3D = static_cast<vtkProp3D *>(path->GetLastNode()->GetViewProp());
if (prop3D)
{
prop3D->PokeMatrix(path->GetLastNode()->GetMatrix());
double* pos = prop3D->GetCenter();
pos[i] = pos[i] + 2;//tip과 텍스트간의 간격을 두기 위하여 +2
followers[followerId]->SetPosition(pos);
followerId++;
prop3D->PokeMatrix(NULL);
}
}
}
vtkPositionCallback(){
//for (int i = 0; i<3; i++)
// conLabels[i] = vtkSmartPointer<vtkFollower>::New();
}
};
class InteractorActor : public vtkInteractorStyleTrackballActor
{
friend class Arrow;
private:
bool bSetState;
vtkSmartPointer<vtkTransformPolyDataFilter> readerTransFilter;
bool bActorMouseDown;
static vtkPositionCallback* callback;
protected:
vtkMatrix4x4* currentMatrix;
vtkPolyData* currentPolydata = 0;
vtkSmartPointer<vtkRenderWindowInteractor> renwinin;
virtual void SetInformation(vtkPolyData* polydata,
vtkMatrix4x4* matrix,
vtkRenderWindowInteractor* renwinin);
virtual void GetInformation(vtkPolyData* polydata,
vtkMatrix4x4* matrix,
vtkRenderWindowInteractor* renwinin);
public:
static InteractorActor* New()
{
return new InteractorActor;
}
void SetLabelnAxes(vtkSmartPointer<vtkFollower> xL,
vtkSmartPointer<vtkFollower> yL,
vtkSmartPointer<vtkFollower> zL,
vtkSmartPointer<vtkAssembly> axes)
{
vtkPositionCallback::xLabel = xL;
vtkPositionCallback::yLabel = yL;
vtkPositionCallback::zLabel = zL;
vtkPositionCallback::Axes = axes;
}
InteractorActor()
{
readerTransFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
bSetState = false;
bActorMouseDown = true;
renwinin = vtkSmartPointer<vtkRenderWindowInteractor>::New();
callback = vtkPositionCallback::New();
this->AddObserver(vtkCommand::InteractionEvent, callback);
}
~InteractorActor() {}
virtual void OnLeftButtonDown();
vtkTypeMacro(InteractorActor, vtkInteractorStyleTrackballActor);
};
#endif