1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// matwin.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H26
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
|
27 |
|
|
#include <vcl.h>
|
28 |
|
|
#pragma hdrstop
|
29 |
|
|
|
30 |
|
|
#include "matwin.h"
|
31 |
|
|
#include "mt_gestionnaire.h"
|
32 |
|
|
#include "mg_gestionnaire.h"
|
33 |
|
|
#include "mt_materiau.h"
|
34 |
|
|
#include "mt_propriete.h"
|
35 |
|
|
|
36 |
|
|
//---------------------------------------------------------------------------
|
37 |
|
|
#pragma package(smart_init)
|
38 |
|
|
#pragma resource "*.dfm"
|
39 |
|
|
Tmatwinform *matwinform;
|
40 |
|
|
//---------------------------------------------------------------------------
|
41 |
|
|
__fastcall Tmatwinform::Tmatwinform(TComponent* Owner)
|
42 |
|
|
: TForm(Owner)
|
43 |
|
|
{
|
44 |
|
|
}
|
45 |
|
|
//---------------------------------------------------------------------------
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
void __fastcall Tmatwinform::FormCreate(TObject *Sender)
|
49 |
|
|
{
|
50 |
|
|
StringGrid1->Cells[0][0]="Nom";
|
51 |
|
|
StringGrid1->Cells[1][0]="Valeur";
|
52 |
|
|
StringGrid1->Cells[2][0]="Unités";
|
53 |
|
|
StringGrid1->Cells[3][0]="Valeur";
|
54 |
|
|
StringGrid1->Cells[4][0]="Unités";
|
55 |
|
|
StringGrid1->Cells[5][0]="Valeur";
|
56 |
|
|
StringGrid1->Cells[6][0]="Unités";
|
57 |
|
|
int res;
|
58 |
|
|
HKEY clef;
|
59 |
|
|
DWORD type,taille;
|
60 |
|
|
char *name;
|
61 |
|
|
char mess[255];
|
62 |
|
|
res=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
|
63 |
|
|
if (res!=ERROR_SUCCESS)
|
64 |
|
|
{
|
65 |
|
|
MessageBox(Handle,"Problème d'installation.","Erreur", MB_OK);
|
66 |
|
|
TerminateProcess(GetCurrentProcess(),0);
|
67 |
|
|
}
|
68 |
|
|
res=RegQueryValueEx(clef,"Materiau",0,&type,0,&taille);
|
69 |
|
|
if (res!=ERROR_SUCCESS)
|
70 |
|
|
{
|
71 |
|
|
MessageBox(Handle,"Problème d'installation","Erreur", MB_OK);
|
72 |
|
|
TerminateProcess(GetCurrentProcess(),0);
|
73 |
|
|
}
|
74 |
|
|
name=new char[taille];
|
75 |
|
|
RegQueryValueEx(clef,"Materiau",0,&type,name,&taille);
|
76 |
|
|
mgest=new MT_GESTIONNAIRE(name);
|
77 |
|
|
int nbmat=mgest->get_nb_materiau();
|
78 |
|
|
for (int i=0;i<nbmat;i++)
|
79 |
|
|
{
|
80 |
|
|
MT_MATERIAU* mat=mgest->get_materiau(i);
|
81 |
|
|
ComboBox1->Items->Add(mat->get_nom());
|
82 |
|
|
}
|
83 |
|
|
MT_MATERIAU* mat=mgest->get_materiau(0);
|
84 |
|
|
delete [] name;
|
85 |
|
|
ComboBox1->ItemIndex=0;
|
86 |
|
|
int nbp=mat->get_nb_propriete();
|
87 |
|
|
StringGrid1->RowCount=nbp+1;
|
88 |
|
|
Label1->Caption=mat->get_nom();
|
89 |
|
|
Label2->Caption=mat->get_description();
|
90 |
|
|
for (int j=0;j<nbp;j++)
|
91 |
|
|
{
|
92 |
|
|
MT_PROPRIETE* prop=mat->get_propriete(j);
|
93 |
|
|
StringGrid1->Cells[0][j+1]=prop->get_nom();
|
94 |
|
|
StringGrid1->Cells[1][j+1]=prop->get_valeur(0);
|
95 |
|
|
StringGrid1->Cells[2][j+1]=prop->get_unite(0);
|
96 |
|
|
StringGrid1->Cells[3][j+1]=prop->get_valeur(1);
|
97 |
|
|
StringGrid1->Cells[4][j+1]=prop->get_unite(1);
|
98 |
|
|
StringGrid1->Cells[5][j+1]=prop->get_valeur(2);
|
99 |
|
|
StringGrid1->Cells[6][j+1]=prop->get_unite(2);
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
//---------------------------------------------------------------------------
|
103 |
|
|
|
104 |
|
|
void __fastcall Tmatwinform::Button2Click(TObject *Sender)
|
105 |
|
|
{
|
106 |
|
|
Close();
|
107 |
|
|
}
|
108 |
|
|
//---------------------------------------------------------------------------
|
109 |
|
|
|
110 |
|
|
void __fastcall Tmatwinform::Button1Click(TObject *Sender)
|
111 |
|
|
{
|
112 |
|
|
MG_GEOMETRIE* mggeo=gest->get_mg_geometrieid(atol(ComboBox2->Text.c_str()));
|
113 |
|
|
if (mggeo!=NULL)
|
114 |
|
|
{
|
115 |
|
|
if (ComboBox4->ItemIndex==0)
|
116 |
|
|
{
|
117 |
|
|
MG_VOLUME* vol=mggeo->get_mg_volumeid(atol(ComboBox3->Text.c_str()));
|
118 |
|
|
if (vol!=NULL)
|
119 |
|
|
{
|
120 |
|
|
mggeo->change_gest_materiau(mgest->get_chemin());
|
121 |
|
|
vol->change_num_materiau(ComboBox1->ItemIndex);
|
122 |
|
|
}
|
123 |
|
|
else
|
124 |
|
|
{
|
125 |
|
|
MessageBox(Handle,"Pas de volume","Erreur",0);
|
126 |
|
|
return;
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
if (ComboBox4->ItemIndex==1)
|
130 |
|
|
{
|
131 |
|
|
MG_COQUE* coq=mggeo->get_mg_coqueid(atol(ComboBox3->Text.c_str()));
|
132 |
|
|
if (coq!=NULL)
|
133 |
|
|
{
|
134 |
|
|
mggeo->change_gest_materiau(mgest->get_chemin());
|
135 |
|
|
coq->change_num_materiau(ComboBox1->ItemIndex);
|
136 |
|
|
}
|
137 |
|
|
else
|
138 |
|
|
{
|
139 |
|
|
MessageBox(Handle,"Pas de coque","Erreur",0);
|
140 |
|
|
return;
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
if (ComboBox4->ItemIndex==2)
|
144 |
|
|
{
|
145 |
|
|
MG_POUTRE* pou=mggeo->get_mg_poutreid(atol(ComboBox3->Text.c_str()));
|
146 |
|
|
if (pou!=NULL)
|
147 |
|
|
{
|
148 |
|
|
mggeo->change_gest_materiau(mgest->get_chemin());
|
149 |
|
|
pou->change_num_materiau(ComboBox1->ItemIndex);
|
150 |
|
|
}
|
151 |
|
|
else
|
152 |
|
|
{
|
153 |
|
|
MessageBox(Handle,"Pas de poutre","Erreur",0);
|
154 |
|
|
return;
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
else
|
159 |
|
|
{
|
160 |
|
|
MessageBox(Handle,"Pas de géometrie","Erreur",0);
|
161 |
|
|
return;
|
162 |
|
|
}
|
163 |
|
|
gest->enregistrer(Label6->Caption.c_str());
|
164 |
|
|
ComboBox3Change(Sender);
|
165 |
|
|
}
|
166 |
|
|
//---------------------------------------------------------------------------
|
167 |
|
|
|
168 |
|
|
void __fastcall Tmatwinform::ComboBox1Change(TObject *Sender)
|
169 |
|
|
{
|
170 |
|
|
MT_MATERIAU* mat=mgest->get_materiau(ComboBox1->ItemIndex);
|
171 |
|
|
int nbp=mat->get_nb_propriete();
|
172 |
|
|
StringGrid1->RowCount=nbp+1;
|
173 |
|
|
Label1->Caption=mat->get_nom();
|
174 |
|
|
Label2->Caption=mat->get_description();
|
175 |
|
|
for (int j=0;j<nbp;j++)
|
176 |
|
|
{
|
177 |
|
|
MT_PROPRIETE* prop=mat->get_propriete(j);
|
178 |
|
|
StringGrid1->Cells[0][j+1]=prop->get_nom();
|
179 |
|
|
StringGrid1->Cells[1][j+1]=prop->get_valeur(0);
|
180 |
|
|
StringGrid1->Cells[2][j+1]=prop->get_unite(0);
|
181 |
|
|
StringGrid1->Cells[3][j+1]=prop->get_valeur(1);
|
182 |
|
|
StringGrid1->Cells[4][j+1]=prop->get_unite(1);
|
183 |
|
|
StringGrid1->Cells[5][j+1]=prop->get_valeur(2);
|
184 |
|
|
StringGrid1->Cells[6][j+1]=prop->get_unite(2);
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
}
|
188 |
|
|
//---------------------------------------------------------------------------
|
189 |
|
|
|
190 |
|
|
void __fastcall Tmatwinform::FormActivate(TObject *Sender)
|
191 |
|
|
{
|
192 |
|
|
ComboBox2->Clear();
|
193 |
|
|
int nb=gest->get_nb_mg_geometrie();
|
194 |
|
|
for (int i=0;i<nb;i++)
|
195 |
|
|
{
|
196 |
|
|
MG_GEOMETRIE* geo=gest->get_mg_geometrie(i);
|
197 |
|
|
ComboBox2->Items->Add(geo->get_id());
|
198 |
|
|
}
|
199 |
|
|
}
|
200 |
|
|
//---------------------------------------------------------------------------
|
201 |
|
|
|
202 |
|
|
void __fastcall Tmatwinform::ComboBox2Change(TObject *Sender)
|
203 |
|
|
{
|
204 |
|
|
MG_GEOMETRIE* mggeo=gest->get_mg_geometrieid(atol(ComboBox2->Text.c_str()));
|
205 |
|
|
ComboBox3->Clear();
|
206 |
|
|
if (ComboBox4->ItemIndex==0)
|
207 |
|
|
{
|
208 |
|
|
int nb=mggeo->get_nb_mg_volume();
|
209 |
|
|
for (int i=0;i<nb;i++)
|
210 |
|
|
{
|
211 |
|
|
MG_VOLUME* vol=mggeo->get_mg_volume(i);
|
212 |
|
|
ComboBox3->Items->Add(vol->get_id());
|
213 |
|
|
}
|
214 |
|
|
}
|
215 |
|
|
if (ComboBox4->ItemIndex==1)
|
216 |
|
|
{
|
217 |
|
|
int nb=mggeo->get_nb_mg_coque();
|
218 |
|
|
for (int i=0;i<nb;i++)
|
219 |
|
|
{
|
220 |
|
|
MG_COQUE* coq=mggeo->get_mg_coque(i);
|
221 |
|
|
ComboBox3->Items->Add(coq->get_id());
|
222 |
|
|
}
|
223 |
|
|
}
|
224 |
|
|
if (ComboBox4->ItemIndex==2)
|
225 |
|
|
{
|
226 |
|
|
int nb=mggeo->get_nb_mg_poutre();
|
227 |
|
|
for (int i=0;i<nb;i++)
|
228 |
|
|
{
|
229 |
|
|
MG_POUTRE* pou=mggeo->get_mg_poutre(i);
|
230 |
|
|
ComboBox3->Items->Add(pou->get_id());
|
231 |
|
|
}
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
}
|
235 |
|
|
//---------------------------------------------------------------------------
|
236 |
|
|
|
237 |
|
|
void __fastcall Tmatwinform::FormClose(TObject *Sender,
|
238 |
|
|
TCloseAction &Action)
|
239 |
|
|
{
|
240 |
|
|
delete mgest;
|
241 |
|
|
Action=caFree;
|
242 |
|
|
}
|
243 |
|
|
//---------------------------------------------------------------------------
|
244 |
|
|
|
245 |
|
|
void __fastcall Tmatwinform::ComboBox4Change(TObject *Sender)
|
246 |
|
|
{
|
247 |
|
|
ComboBox2Change(Sender);
|
248 |
|
|
}
|
249 |
|
|
//---------------------------------------------------------------------------
|
250 |
|
|
|
251 |
|
|
void __fastcall Tmatwinform::ComboBox3Change(TObject *Sender)
|
252 |
|
|
{
|
253 |
|
|
MG_GEOMETRIE* mggeo=gest->get_mg_geometrieid(atol(ComboBox2->Text.c_str()));
|
254 |
|
|
if (mggeo!=NULL)
|
255 |
|
|
{
|
256 |
|
|
if (ComboBox4->ItemIndex==0)
|
257 |
|
|
{
|
258 |
|
|
MG_VOLUME* vol=mggeo->get_mg_volumeid(atol(ComboBox3->Text.c_str()));
|
259 |
|
|
Label8->Caption="";
|
260 |
|
|
if (vol!=NULL)
|
261 |
|
|
if (vol->get_num_materiau()>-1)
|
262 |
|
|
Label8->Caption=mgest->get_materiau(vol->get_num_materiau())->get_nom();
|
263 |
|
|
|
264 |
|
|
}
|
265 |
|
|
if (ComboBox4->ItemIndex==1)
|
266 |
|
|
{
|
267 |
|
|
MG_COQUE* coq=mggeo->get_mg_coqueid(atol(ComboBox3->Text.c_str()));
|
268 |
|
|
Label8->Caption="";
|
269 |
|
|
if (coq!=NULL)
|
270 |
|
|
if (coq->get_num_materiau()>-1)
|
271 |
|
|
Label8->Caption=mgest->get_materiau(coq->get_num_materiau())->get_nom();
|
272 |
|
|
}
|
273 |
|
|
if (ComboBox4->ItemIndex==2)
|
274 |
|
|
{
|
275 |
|
|
MG_POUTRE* pou=mggeo->get_mg_poutreid(atol(ComboBox3->Text.c_str()));
|
276 |
|
|
Label8->Caption="";
|
277 |
|
|
if (pou!=NULL)
|
278 |
|
|
if (pou->get_num_materiau()>-1)
|
279 |
|
|
Label8->Caption=mgest->get_materiau(pou->get_num_materiau())->get_nom();
|
280 |
|
|
|
281 |
|
|
}
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
}
|
285 |
|
|
//---------------------------------------------------------------------------
|
286 |
|
|
|