forked from mhernando/Apolo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialProperties.cpp
148 lines (99 loc) · 3.66 KB
/
initialProperties.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
#include "initialProperties.h"
#include "tree.h"
BEGIN_EVENT_TABLE(InitialProperties, wxDialog)
EVT_BUTTON(ID_ACCEPT, InitialProperties::OnButton)
EVT_BUTTON(ID_CANCEL, InitialProperties::OnButton)
EVT_BUTTON(ID_DEFAULT, InitialProperties::OnButton)
EVT_COMMAND(wxID_ANY, wxEVT_GENERIC_SLIDER_CHANGE, InitialProperties::RefreshCanvas)
EVT_CLOSE(InitialProperties::OnClose)
END_EVENT_TABLE()
InitialProperties::InitialProperties(wxWindow *parent, NodeTree *obj, const wxString& title,wxWindowID id)
:wxDialog(parent,id, title, wxPoint(0,0), wxSize(300,500),wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP|wxMAXIMIZE_BOX )
{
mainWin=(MainWindow*)parent;
b_sel=true;
worldView=true;
node=obj;
wID=id;
defName=node->getSimu()->tree->GetItemText(node->getSimu()->tree->GetLastChild(node->getSimu()->tree->GetSelection()));
CreatePanel();
}
void InitialProperties::CreatePanel()
{
wxBoxSizer *vbox=new wxBoxSizer(wxVERTICAL);
wxBoxSizer *tbox=new wxBoxSizer(wxHORIZONTAL);
tbox->Add(vbox,1,wxEXPAND);
bool color=true;
if(node->getSimu()->mainWin->getToogleReference())
{ Tree *tree=node->getSimu()->tree;
node->getSimu()->mainWin->Search(tree->GetLastChild(tree->GetSelection()),true);
}
if(dynamic_cast<ComposedEntity *>(node->pointer.positionableentity))
color=false;
if(wID==ID_ADDFACESET)
{
node->pointer.facesetpart=dynamic_cast<FaceSetPart *>(node->pointer.positionableentity);
face=new FaceWindow(this,node,wxEmptyString,wxDefaultPosition,wxDefaultSize);
vbox->Add(face,0,wxEXPAND);
}
else
{
dp=new DesignWidget(this,node,wxEmptyString,wxDefaultPosition , wxDefaultSize,mainWin->getDesignValue());
if (wID!=ID_ADDIRRPRI)
pw=new PositionableWidget(this,node,wxT("Positionable Parameters"),wxDefaultPosition,wxDefaultSize,mainWin->getSliderValue(),color);
else
pw=new PositionableWidget(this,node,wxT("Positionable Parameters"),wxDefaultPosition,wxDefaultSize,mainWin->getSliderValue(),color,ID_ADDIRRPRI);
wxButton *df = new wxButton(this,ID_DEFAULT,wxT("Create object with default parameters"),wxDefaultPosition,wxDefaultSize);
vbox->Add(df,0,wxEXPAND);
vbox->Add(pw,0,wxEXPAND);
vbox->Add(dp,0,wxEXPAND);
//vbox->AddSpacer(40);
if(wID==ID_ADDIRRPRI)
{
priW=new PrismWindow(this,node,wxEmptyString,wxDefaultPosition,wxDefaultSize);
tbox->Add(priW,0,wxEXPAND);
}
}
////Buttom box///
wxBoxSizer *b_box=new wxBoxSizer(wxHORIZONTAL);
wxButton *accept = new wxButton(this,ID_ACCEPT,wxT("Accept"),wxDefaultPosition,wxDefaultSize);
wxButton *cancel = new wxButton(this,ID_CANCEL,wxT("Cancel"),wxDefaultPosition,wxDefaultSize);
b_box->Add(accept,1,wxALIGN_BOTTOM);
b_box->Add(cancel,1,wxALIGN_BOTTOM);
//Close Dialog Design//
vbox->Add(b_box,1,wxEXPAND);
vbox->SetMinSize(vbox->GetMinSize());
SetSizer(tbox);
tbox->SetSizeHints(this);
}
void InitialProperties::OnButton(wxCommandEvent& event)
{
int id=event.GetId();
if(id == ID_ACCEPT)
{
if(wID==ID_ADDFACESET)
{
face->AddFace();
}
Destroy();
}
if(id == ID_DEFAULT)
{
Transformation3D t;
t.position=pw->getDefPosition();
Vector3D defOrientation=pw->getDefOrientation();
t.orientation.setRPY(defOrientation.x,defOrientation.y,defOrientation.z);
node->pointer.positionableentity->setRelativeT3D(t);
dp->SetSpecificValues(true);
node->getSimu()->tree->SetItemText(node->getSimu()->tree->GetLastChild(node->getSimu()->tree->GetSelection()),defName);
node->pointer.solidentity->setColor(pw->getDefRedColor(),pw->getDefGreenColor(),pw->getDefBlueColor());
Destroy();
}
if(id==ID_CANCEL)
Close(true);
}
void InitialProperties::RefreshCanvas(wxCommandEvent &event)
{
if(wID==ID_ADDIRRPRI)
priW->RefreshCanvas();
}