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 |
|
|
// carte3dform.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 |
|
|
#include <time.h>
|
29 |
|
|
#include <process.h>
|
30 |
|
|
#pragma hdrstop
|
31 |
|
|
|
32 |
|
|
#include "carte3dform.h"
|
33 |
|
|
#include "visuctt.h"
|
34 |
|
|
#include "mg_gestionnaire.h"
|
35 |
|
|
#include "fct_generateur_frontiere.h"
|
36 |
|
|
#include "fct_generateur_constante.h"
|
37 |
|
|
//---------------------------------------------------------------------------
|
38 |
|
|
#pragma package(smart_init)
|
39 |
|
|
#pragma resource "*.dfm"
|
40 |
|
|
Twincarte *wincarte;
|
41 |
|
|
//---------------------------------------------------------------------------
|
42 |
|
|
__fastcall Twincarte::Twincarte(TComponent* Owner,MG_GESTIONNAIRE& mgest): TForm(Owner),gest(mgest)
|
43 |
|
|
{
|
44 |
|
|
}
|
45 |
|
|
//---------------------------------------------------------------------------
|
46 |
|
|
void __fastcall Twincarte::FormClose(TObject *Sender, TCloseAction &Action)
|
47 |
|
|
{
|
48 |
|
|
Action=caFree;
|
49 |
|
|
}
|
50 |
|
|
//---------------------------------------------------------------------------
|
51 |
|
|
void __fastcall Twincarte::Button1Click(TObject *Sender)
|
52 |
|
|
{
|
53 |
|
|
Close();
|
54 |
|
|
}
|
55 |
|
|
//---------------------------------------------------------------------------
|
56 |
|
|
void __fastcall Twincarte::RadioButton1Click(TObject *Sender)
|
57 |
|
|
{
|
58 |
|
|
GroupBox2->Visible=true;
|
59 |
|
|
GroupBox3->Visible=false;
|
60 |
|
|
GroupBox5->Visible=false;
|
61 |
|
|
}
|
62 |
|
|
//---------------------------------------------------------------------------
|
63 |
|
|
void __fastcall Twincarte::TrackBar3Change(TObject *Sender)
|
64 |
|
|
{
|
65 |
|
|
int val=19./50.*TrackBar3->Position+1;
|
66 |
|
|
Edit3->Text=val;
|
67 |
|
|
|
68 |
|
|
}
|
69 |
|
|
//---------------------------------------------------------------------------
|
70 |
|
|
void __fastcall Twincarte::TrackBar4Change(TObject *Sender)
|
71 |
|
|
{
|
72 |
|
|
int val=19./50.*TrackBar4->Position+1;
|
73 |
|
|
Edit4->Text=val;
|
74 |
|
|
}
|
75 |
|
|
//---------------------------------------------------------------------------
|
76 |
|
|
void __fastcall Twincarte::Button2Click(TObject *Sender)
|
77 |
|
|
{
|
78 |
|
|
if (SaveDialog1->Execute())
|
79 |
|
|
{
|
80 |
|
|
Edit5->Text=SaveDialog1->FileName;
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
//---------------------------------------------------------------------------
|
84 |
|
|
void __fastcall Twincarte::Button3Click(TObject *Sender)
|
85 |
|
|
{
|
86 |
|
|
double eng=atof(Edit1->Text.c_str());
|
87 |
|
|
double eps=atof(Edit2->Text.c_str());
|
88 |
|
|
int fechan=atoi(Edit3->Text.c_str());
|
89 |
|
|
int festim=atoi(Edit4->Text.c_str());
|
90 |
|
|
if (eng<0.000001) MessageBox(Handle,"Mauvaise valeur de distance","Erreur",0);
|
91 |
|
|
else if (eps<0.000001) MessageBox(Handle,"Mauvaise valeur de epsilon","Erreur",0);
|
92 |
|
|
else if (fechan<-1) MessageBox(Handle,"Mauvaise valeur de la frequence d'echantillonage","Erreur",0);
|
93 |
|
|
else if (festim<1) MessageBox(Handle,"Mauvaise valeur de la frequence d'estimatione","Erreur",0);
|
94 |
|
|
else if (Edit5->Text=="") MessageBox(Handle,"Mauvais nom de fichier de sortie","Erreur",0);
|
95 |
|
|
else
|
96 |
|
|
{
|
97 |
|
|
DWORD type,taille;
|
98 |
|
|
HKEY clef;
|
99 |
|
|
char name[500];
|
100 |
|
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
|
101 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,0,&taille);
|
102 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,name,&taille);
|
103 |
|
|
strcat(name,"\\generationcarte");
|
104 |
|
|
char fichierentre[500],fichiersortie[500],taux[50];
|
105 |
|
|
sprintf(fichierentre,"\"%s\"",Caption.c_str());
|
106 |
|
|
sprintf(fichiersortie,"\"%s\"",Edit5->Text.c_str());
|
107 |
|
|
sprintf(taux,"%f",0.01*atoi(Edit7->Text.c_str()));
|
108 |
|
|
int nbptctl=atoi(Edit12->Text.c_str());
|
109 |
|
|
if (nbptctl==0)
|
110 |
|
|
spawnl(P_NOWAIT,name,name,"-typecarte","1","-fichier",fichierentre,"-fichout",fichiersortie,"-dg",Edit1->Text.c_str(),"-eps",Edit2->Text.c_str(),"-fechantillonage",Edit3->Text.c_str(),"-festimation",Edit4->Text.c_str(),"-taillezone",Edit6->Text.c_str(),"-tauxtransfert",taux,NULL);
|
111 |
|
|
else
|
112 |
|
|
{
|
113 |
|
|
char* dir=getenv("TEMP");
|
114 |
|
|
char chaine[1000];
|
115 |
|
|
sprintf(chaine,"%s\\point.txt",dir);
|
116 |
|
|
FILE* out=fopen(chaine,"wt");
|
117 |
|
|
fprintf(out,"%d\n",nbptctl);
|
118 |
|
|
for (int i=0;i<nbptctl;i++)
|
119 |
|
|
{
|
120 |
|
|
double x=atof(StringGrid1->Cells[0][i+1].c_str());
|
121 |
|
|
double y=atof(StringGrid1->Cells[1][i+1].c_str());
|
122 |
|
|
double z=atof(StringGrid1->Cells[2][i+1].c_str());
|
123 |
|
|
double val=atof(StringGrid1->Cells[3][i+1].c_str());
|
124 |
|
|
fprintf(out,"%f %f %f %f\n",x,y,z,val);
|
125 |
|
|
}
|
126 |
|
|
fclose(out);
|
127 |
|
|
spawnl(P_NOWAIT,name,name,"-typecarte","1","-fichier",fichierentre,"-fichout",fichiersortie,"-dg",Edit1->Text.c_str(),"-eps",Edit2->Text.c_str(),"-fechantillonage",Edit3->Text.c_str(),"-festimation",Edit4->Text.c_str(),"-taillezone",Edit6->Text.c_str(),"-tauxtransfert",taux,"-point",chaine,NULL);
|
128 |
|
|
}
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
}
|
132 |
|
|
//---------------------------------------------------------------------------
|
133 |
|
|
void __fastcall Twincarte::Button4Click(TObject *Sender)
|
134 |
|
|
{
|
135 |
|
|
if (SaveDialog1->Execute())
|
136 |
|
|
{
|
137 |
|
|
Edit16->Text=SaveDialog1->FileName;
|
138 |
|
|
}
|
139 |
|
|
}
|
140 |
|
|
//---------------------------------------------------------------------------
|
141 |
|
|
void __fastcall Twincarte::TrackBar1Change(TObject *Sender)
|
142 |
|
|
{
|
143 |
|
|
Edit6->Text=TrackBar1->Position;
|
144 |
|
|
}
|
145 |
|
|
//---------------------------------------------------------------------------
|
146 |
|
|
|
147 |
|
|
void __fastcall Twincarte::TrackBar2Change(TObject *Sender)
|
148 |
|
|
{
|
149 |
|
|
Edit7->Text=TrackBar2->Position;
|
150 |
|
|
}
|
151 |
|
|
//---------------------------------------------------------------------------
|
152 |
|
|
|
153 |
|
|
void __fastcall Twincarte::CheckBox1Click(TObject *Sender)
|
154 |
|
|
{
|
155 |
|
|
if (CheckBox1->Checked)
|
156 |
|
|
{
|
157 |
|
|
TrackBar3->Visible=false;
|
158 |
|
|
Edit3->Text="-1";
|
159 |
|
|
Edit3->Visible=false;
|
160 |
|
|
}
|
161 |
|
|
else
|
162 |
|
|
{
|
163 |
|
|
TrackBar3->Visible=true;
|
164 |
|
|
Edit3->Visible=true;
|
165 |
|
|
int val=19./50.*TrackBar3->Position+1;
|
166 |
|
|
Edit3->Text=val;
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
//---------------------------------------------------------------------------
|
170 |
|
|
|
171 |
|
|
void __fastcall Twincarte::RadioButton2Click(TObject *Sender)
|
172 |
|
|
{
|
173 |
|
|
GroupBox2->Visible=false;
|
174 |
|
|
GroupBox3->Top=GroupBox2->Top;
|
175 |
|
|
GroupBox3->Left=GroupBox2->Left;
|
176 |
|
|
GroupBox3->Width=GroupBox2->Width;
|
177 |
|
|
GroupBox3->Height=GroupBox2->Height;
|
178 |
|
|
GroupBox3->Visible=true;
|
179 |
|
|
GroupBox5->Visible=false;
|
180 |
|
|
}
|
181 |
|
|
//---------------------------------------------------------------------------
|
182 |
|
|
|
183 |
|
|
void __fastcall Twincarte::TrackBar5Change(TObject *Sender)
|
184 |
|
|
{
|
185 |
|
|
int val=19./50.*TrackBar5->Position+1;
|
186 |
|
|
Edit9->Text=val;
|
187 |
|
|
}
|
188 |
|
|
//---------------------------------------------------------------------------
|
189 |
|
|
|
190 |
|
|
void __fastcall Twincarte::TrackBar6Change(TObject *Sender)
|
191 |
|
|
{
|
192 |
|
|
int val=19./50.*TrackBar6->Position+1;
|
193 |
|
|
Edit10->Text=val;
|
194 |
|
|
|
195 |
|
|
}
|
196 |
|
|
//---------------------------------------------------------------------------
|
197 |
|
|
|
198 |
|
|
void __fastcall Twincarte::Button5Click(TObject *Sender)
|
199 |
|
|
{
|
200 |
|
|
if (SaveDialog1->Execute())
|
201 |
|
|
{
|
202 |
|
|
Edit11->Text=SaveDialog1->FileName;
|
203 |
|
|
}
|
204 |
|
|
}
|
205 |
|
|
//---------------------------------------------------------------------------
|
206 |
|
|
|
207 |
|
|
void __fastcall Twincarte::Button6Click(TObject *Sender)
|
208 |
|
|
{
|
209 |
|
|
double eng=atof(Edit8->Text.c_str());
|
210 |
|
|
int fechan=atoi(Edit9->Text.c_str());
|
211 |
|
|
int festim=atoi(Edit10->Text.c_str());
|
212 |
|
|
if (eng<0.000001) MessageBox(Handle,"Mauvaise valeur de distance","Erreur",0);
|
213 |
|
|
else if (fechan<1) MessageBox(Handle,"Mauvaise valeur de la frequence d'echantillonage","Erreur",0);
|
214 |
|
|
else if (festim<1) MessageBox(Handle,"Mauvaise valeur de la frequence d'estimatione","Erreur",0);
|
215 |
|
|
else if (Edit11->Text=="") MessageBox(Handle,"Mauvais nom de fichier de sortie","Erreur",0);
|
216 |
|
|
else
|
217 |
|
|
{
|
218 |
|
|
DWORD type,taille;
|
219 |
|
|
HKEY clef;
|
220 |
|
|
char name[500];
|
221 |
|
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
|
222 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,0,&taille);
|
223 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,name,&taille);
|
224 |
|
|
strcat(name,"\\generationcarte");
|
225 |
|
|
char fichierentre[500],fichiersortie[500];
|
226 |
|
|
sprintf(fichierentre,"\"%s\"",Caption.c_str());
|
227 |
|
|
sprintf(fichiersortie,"\"%s\"",Edit11->Text.c_str());
|
228 |
|
|
spawnl(P_NOWAIT,name,name,"-typecarte","0","-fichier",fichierentre,"-fichout",fichiersortie,"-dg",Edit8->Text.c_str(),"-fechantillonage",Edit9->Text.c_str(),"-festimation",Edit10->Text.c_str(),NULL);
|
229 |
|
|
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
//---------------------------------------------------------------------------
|
233 |
|
|
|
234 |
|
|
void __fastcall Twincarte::Button7Click(TObject *Sender)
|
235 |
|
|
{
|
236 |
|
|
int festim=atoi(Edit15->Text.c_str());
|
237 |
|
|
if (festim<1) MessageBox(Handle,"Mauvaise valeur de la frequence d'estimation","Erreur",0);
|
238 |
|
|
else if (Edit16->Text=="") MessageBox(Handle,"Mauvais nom de fichier de sortie","Erreur",0);
|
239 |
|
|
else if (Edit14->Text=="") MessageBox(Handle,"Mauvais nom de fichier d'entree","Erreur",0);
|
240 |
|
|
else
|
241 |
|
|
{
|
242 |
|
|
DWORD type,taille;
|
243 |
|
|
HKEY clef;
|
244 |
|
|
char name[500];
|
245 |
|
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
|
246 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,0,&taille);
|
247 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,name,&taille);
|
248 |
|
|
strcat(name,"\\generationcarte");
|
249 |
|
|
char fichierentre[500],fichiersortie[500],taux[50];
|
250 |
|
|
sprintf(fichierentre,"\"%s\"",Edit14->Text.c_str());
|
251 |
|
|
sprintf(fichiersortie,"\"%s\"",Edit16->Text.c_str());
|
252 |
|
|
sprintf(taux,"%f",0.01*atoi(Edit17->Text.c_str()));
|
253 |
|
|
spawnl(P_NOWAIT,name,name,"-typecarte","2","-fichier",fichierentre,"-fichout",fichiersortie,"-dg",Edit19->Text.c_str(),"-festimation",Edit15->Text.c_str(),"-taillezone",Edit18->Text.c_str(),"-tauxtransfert",taux,NULL);
|
254 |
|
|
}
|
255 |
|
|
}
|
256 |
|
|
//---------------------------------------------------------------------------
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
void __fastcall Twincarte::UpDown1Click(TObject *Sender, TUDBtnType Button)
|
260 |
|
|
{
|
261 |
|
|
Edit12->Text=UpDown1->Position;
|
262 |
|
|
}
|
263 |
|
|
//---------------------------------------------------------------------------
|
264 |
|
|
|
265 |
|
|
void __fastcall Twincarte::Edit12Change(TObject *Sender)
|
266 |
|
|
{
|
267 |
|
|
StringGrid1->RowCount=atoi(Edit12->Text.c_str())+2;
|
268 |
|
|
StringGrid1->FixedRows=1;
|
269 |
|
|
}
|
270 |
|
|
//---------------------------------------------------------------------------
|
271 |
|
|
|
272 |
|
|
void __fastcall Twincarte::FormCreate(TObject *Sender)
|
273 |
|
|
{
|
274 |
|
|
StringGrid1->Cells[0][0]="X";
|
275 |
|
|
StringGrid1->Cells[1][0]="Y";
|
276 |
|
|
StringGrid1->Cells[2][0]="Z";
|
277 |
|
|
StringGrid1->Cells[3][0]="Ecart nodal";
|
278 |
|
|
}
|
279 |
|
|
//---------------------------------------------------------------------------
|
280 |
|
|
|
281 |
|
|
void __fastcall Twincarte::StringGrid1Click(TObject *Sender)
|
282 |
|
|
{
|
283 |
|
|
Edit13->Text=StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row];
|
284 |
|
|
Edit13->SetFocus();
|
285 |
|
|
}
|
286 |
|
|
//---------------------------------------------------------------------------
|
287 |
|
|
|
288 |
|
|
void __fastcall Twincarte::Edit13Change(TObject *Sender)
|
289 |
|
|
{
|
290 |
|
|
StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row]=Edit13->Text;
|
291 |
|
|
}
|
292 |
|
|
//---------------------------------------------------------------------------
|
293 |
|
|
|
294 |
|
|
void __fastcall Twincarte::Edit13KeyPress(TObject *Sender, char &Key)
|
295 |
|
|
{
|
296 |
|
|
if (Key==13) StringGrid1->SetFocus();
|
297 |
|
|
}
|
298 |
|
|
//---------------------------------------------------------------------------
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
void __fastcall Twincarte::RadioButton3Click(TObject *Sender)
|
302 |
|
|
{
|
303 |
|
|
GroupBox2->Visible=false;
|
304 |
|
|
GroupBox3->Visible=false;
|
305 |
|
|
GroupBox5->Top=GroupBox2->Top;
|
306 |
|
|
GroupBox5->Left=GroupBox2->Left;
|
307 |
|
|
GroupBox5->Width=GroupBox2->Width;
|
308 |
|
|
GroupBox5->Height=GroupBox2->Height;
|
309 |
|
|
GroupBox5->Visible=true;
|
310 |
|
|
|
311 |
|
|
}
|
312 |
|
|
//---------------------------------------------------------------------------
|
313 |
|
|
|
314 |
|
|
void __fastcall Twincarte::TrackBar7Change(TObject *Sender)
|
315 |
|
|
{
|
316 |
|
|
int val=19./50.*TrackBar7->Position+1;
|
317 |
|
|
Edit15->Text=val;
|
318 |
|
|
}
|
319 |
|
|
//---------------------------------------------------------------------------
|
320 |
|
|
|
321 |
|
|
void __fastcall Twincarte::Button8Click(TObject *Sender)
|
322 |
|
|
{
|
323 |
|
|
if (OpenDialog1->Execute())
|
324 |
|
|
{
|
325 |
|
|
Edit14->Text=OpenDialog1->FileName;
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
//---------------------------------------------------------------------------
|
329 |
|
|
|
330 |
|
|
void __fastcall Twincarte::TrackBar9Change(TObject *Sender)
|
331 |
|
|
{
|
332 |
|
|
Edit18->Text=TrackBar9->Position;
|
333 |
|
|
}
|
334 |
|
|
//---------------------------------------------------------------------------
|
335 |
|
|
|
336 |
|
|
void __fastcall Twincarte::TrackBar8Change(TObject *Sender)
|
337 |
|
|
{
|
338 |
|
|
Edit17->Text=TrackBar8->Position;
|
339 |
|
|
}
|
340 |
|
|
//---------------------------------------------------------------------------
|
341 |
|
|
|
342 |
|
|
void __fastcall Twincarte::Edit14Change(TObject *Sender)
|
343 |
|
|
{
|
344 |
|
|
FILE* in=fopen(Edit14->Text.c_str(),"rt");
|
345 |
|
|
if (in!=NULL)
|
346 |
|
|
{
|
347 |
|
|
char chaine[500];
|
348 |
|
|
double val1,val2;
|
349 |
|
|
fgets(chaine,500,in);
|
350 |
|
|
fgets(chaine,500,in);
|
351 |
|
|
int nb=sscanf(chaine,"%lf %lf",&val1,&val2);
|
352 |
|
|
if (nb==1)
|
353 |
|
|
{
|
354 |
|
|
char mess[255];
|
355 |
|
|
sprintf(mess,"%lf",val1);
|
356 |
|
|
Edit19->Text=mess;
|
357 |
|
|
Edit19->Enabled=false;
|
358 |
|
|
}
|
359 |
|
|
else
|
360 |
|
|
{
|
361 |
|
|
Edit19->Text="";
|
362 |
|
|
Edit19->Enabled=true;
|
363 |
|
|
}
|
364 |
|
|
fclose(in);
|
365 |
|
|
}
|
366 |
|
|
}
|
367 |
|
|
//---------------------------------------------------------------------------
|
368 |
|
|
|