forked from mhernando/Apolo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
faceWindow.cpp
192 lines (139 loc) · 5.74 KB
/
faceWindow.cpp
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include "faceWindow.h"
BEGIN_EVENT_TABLE(FaceWindow, wxPanel)
EVT_BUTTON(ID_OTHERFACE, FaceWindow::FaceButton)
EVT_BUTTON(ID_CHANGEVIEW, FaceWindow::FaceButton)
EVT_BUTTON(ID_COLOR, FaceWindow::ColorChanged)
EVT_COMMAND(wxID_ANY, wxEVT_GENERIC_SLIDER_CHANGE, FaceWindow::FaceOrientation)
EVT_RADIOBOX(wxID_ANY, FaceWindow::FaceAlign)
END_EVENT_TABLE()
FaceWindow::FaceWindow(wxWindow *parent,NodeTree *obj,const wxString& title, const wxPoint& pos,const wxSize& size)
: wxPanel(parent, wxID_ANY, pos, size)
{
mainWin=(MainWindow*)parent->GetParent();;
node=obj;
worldView=false;
red=green=blue=1.0f;
CreatePanel();
align->SetSelection(1); //Set align OFF to start
}
void FaceWindow::CreatePanel()
{
wxBoxSizer *fbox=new wxBoxSizer(wxHORIZONTAL);//general box
wxBoxSizer *rbox=new wxBoxSizer(wxVERTICAL);
wxBoxSizer *sbox=new wxBoxSizer(wxVERTICAL);
PointsList *points=new PointsList(this,wxT("Face Coordenates"));
wxButton *af = new wxButton(this,ID_OTHERFACE,wxT("Add another face"),wxDefaultPosition,wxDefaultSize);
cView = new wxButton(this,ID_CHANGEVIEW,wxT("World View3D"),wxDefaultPosition,wxDefaultSize);
canvas=new FaceWidget(this,node->getSimu(),wxDefaultPosition,wxDefaultSize);
canvas->AssociatePointTable(points);
PositionableWidget *pw=new PositionableWidget(this,node,wxT("Face Set Orientation"),wxDefaultPosition,wxDefaultSize,mainWin->getSliderValue(),false);
FaceControlButtons* controlButtons=new FaceControlButtons(this,ID_ADDFACESET,wxDefaultPosition,wxDefaultSize,canvas);
wxBoxSizer *pbox=new wxBoxSizer(wxHORIZONTAL);
wxStaticBoxSizer *buttons=new wxStaticBoxSizer(wxVERTICAL,this,wxT("Canvas3D"));
wxStaticBoxSizer *obox=new wxStaticBoxSizer(wxVERTICAL,this,wxT("Face Properties"));
roll = new GenericSlider(this,wxT("Face Roll"),wxDefaultPosition,wxDefaultSize,false);//true = vertical
pitch = new GenericSlider(this,wxT("Face Pitch"),wxDefaultPosition,wxDefaultSize,false);
x_pos = new GenericSlider(this,wxT("X position"),wxDefaultPosition,wxDefaultSize,false);
y_pos = new GenericSlider(this,wxT("Y position)"),wxDefaultPosition,wxDefaultSize,false);
plane_dis = new GenericSlider(this,wxT("Normal Distance (Z)"),wxDefaultPosition,wxDefaultSize,false);
wxString string[2]={wxT("1"), wxT("0")};
wxString string2[2]={wxT("On"), wxT("Off")};
transparency = new GenericSlider(this,wxT("Face Transparency"),wxDefaultPosition,wxDefaultSize,false);
align = new wxRadioBox(this,wxID_ANY,wxT("Align Face Drawing "),wxDefaultPosition,wxDefaultSize,2,string2);
wxBitmapButton *color_box = new wxBitmapButton(this,ID_COLOR,wxIcon(colour_xpm),wxDefaultPosition,wxSize(100,50),4,wxDefaultValidator,wxT("Change face color"));
//sliders
roll->setProperties(-180,180);
roll->setValue(0);
pitch->setProperties(-180,180);
pitch->setValue(0);
x_pos->setProperties(-10,10,false);
x_pos->setValue(0);
y_pos->setProperties(-10,10,false);
y_pos->setValue(0);
plane_dis->setProperties(-10,10,false);
plane_dis->setValue(0);
transparency->setProperties(0,1);
transparency->setValue(1);
//sliders in box
obox->Add(roll,0,wxALL|wxEXPAND,5);
obox->Add(pitch,0,wxALL|wxEXPAND,5);
obox->Add(x_pos,0,wxALL|wxEXPAND,5);
obox->Add(y_pos,0,wxALL|wxEXPAND,5);
obox->Add(plane_dis,0,wxALL|wxEXPAND,5);
obox->Add(transparency,0,wxEXPAND|wxALL,5);
obox->Add(align,0,wxEXPAND|wxALL,5);
obox->Add(color_box,0,wxEXPAND|wxALL,5);
buttons->Add(cView,0,wxEXPAND);
pbox->Add(controlButtons,1,wxEXPAND |wxALL);//horizontal
pbox->Add(buttons,1,wxEXPAND |wxALL);
sbox->Add(canvas,0,wxEXPAND );//vertical
sbox->Add(pbox,0,wxEXPAND);
sbox->Add(pw,0,wxEXPAND);
rbox->Add(points,1,wxEXPAND|wxALL,5);//vertical
rbox->Add(af,0,wxEXPAND|wxALL,5);
fbox->Add(obox,0,wxEXPAND|wxALL,5); //horizontal
fbox->Add(sbox,0,wxEXPAND|wxALL,5);
fbox->Add(rbox,0,wxEXPAND);
SetSizer(fbox);
}
void FaceWindow::FaceAlign(wxCommandEvent& event)
{
if(align->GetSelection()==0)
canvas->design1->SetAlign(true);
else
canvas->design1->SetAlign(false);
}
void FaceWindow::FaceOrientation(wxCommandEvent& WXUNUSED(event))
{
Transformation3D trans;
trans.position.x=x_pos->getValue();
trans.position.y=y_pos->getValue();
trans.position.z=plane_dis->getValue();
trans.orientation.setRPY(deg2rad(roll->getValue()),deg2rad(pitch->getValue()),0);
canvas->GetFace()->setBase(trans);
canvas->GetFace()->setColor(red,green,blue,transparency->getValue());
canvas->RefreshCanvas();
}
void FaceWindow::FaceButton(wxCommandEvent& event)
{
int id=event.GetId();
if(id==ID_CHANGEVIEW)
{
worldView=!worldView;
canvas->ChangeView(worldView);
if(worldView) cView->SetLabel(wxT("Face View3D"));
else cView->SetLabel(wxT("World View3D"));
}
else
{
node->pointer.facesetpart->addFace((*canvas->GetFace()));
canvas->GetCanvas3D()->ClearObjects();
canvas->GetCanvas3D()->UpdateWorld(node->getSimu()->getWorld());
roll->setValue(0);
pitch->setValue(0);
plane_dis->setValue(0);
canvas->CreateFace();
}
}
void FaceWindow::AddFace()
{
node->pointer.facesetpart->addFace((*canvas->GetFace()));
canvas->GetCanvas3D()->ClearObjects();
canvas->GetCanvas3D()->UpdateWorld(node->getSimu()->getWorld());
roll->setValue(0);
pitch->setValue(0);
plane_dis->setValue(0);
canvas->CreateFace();
}
void FaceWindow::ColorChanged(wxCommandEvent& event)
{
wxColor color=wxGetColourFromUser(this);
if(color.IsOk())
{
red = color.Red();
green = color.Green();
blue = color.Blue();
canvas->GetFace()->setColor(red/255,green/255,blue/255,transparency->getValue());
canvas->RefreshCanvas();
}
}