-
Notifications
You must be signed in to change notification settings - Fork 5
/
initialProperties.cpp
144 lines (111 loc) · 4.18 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
#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_FINISHCOMPOSED, InitialProperties::OnButton)
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(600,800),wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP|wxMAXIMIZE_BOX )
{
mainWin=(MainWindow*)parent;
b_sel=true;
worldView=true;
node=obj;
wID=id;
if((wID!=ID_ADDIRRPRI)&&(wID!=ID_ADDFACESET))
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,wxSize(1040,700));
vbox->Add(face,0,wxEXPAND);
}
else if(wID==ID_ADDCUSTOM)
{
node->pointer.composedentity=dynamic_cast<ComposedEntity *>(node->pointer.positionableentity);
comp=new CreateComposed(this,node,wxID_ANY,wxDefaultPosition,wxSize(1000,800));
tbox->Add(comp,0,wxEXPAND);
SetSizer(tbox);
tbox->SetSizeHints(this);
return;
}
else if(wID==ID_ADDIRRPRI)
{
node->pointer.prismaticpart=dynamic_cast<PrismaticPart *>(node->pointer.positionableentity);
priW=new PrismWindow(this,node,wxEmptyString,wxDefaultPosition,wxDefaultSize);
vbox->Add(priW,0,wxEXPAND);
}
else
{
dp=new DesignWidget(this,node,wxEmptyString,wxDefaultPosition , wxDefaultSize,mainWin->getDesignValue());
pw=new PositionableWidget(this,node,wxT("Positionable Parameters"),wxDefaultPosition,wxDefaultSize,mainWin->getSliderValue(),color);
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);
}
////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_FINISHCOMPOSED)
{
if(comp->getcheckAddition()==true)
{
node->pointer.composedentity=comp->getCreation();
node->getSimu()->getTree()->UpdateTree(node->getSimu());
Destroy();
}
else
{
wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Last item needs to be added"), wxT("Error"),wxOK | wxICON_EXCLAMATION);
dial->ShowModal();
}
}
if((id == ID_DEFAULT)&&(wID!=ID_ADDIRRPRI))
{
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());
}
if(id==ID_CANCEL)
Close(true);
}