1 |
//---------------------------------------------------------------------------
|
2 |
#include <vcl\vcl.h>
|
3 |
#pragma hdrstop
|
4 |
|
5 |
#include "tool.h"
|
6 |
#include "fenetre.h"
|
7 |
#include "s_valeur.h"
|
8 |
|
9 |
//---------------------------------------------------------------------------
|
10 |
#pragma resource "*.dfm"
|
11 |
TToolbar *Toolbar;
|
12 |
//---------------------------------------------------------------------------
|
13 |
__fastcall TToolbar::TToolbar(TComponent* Owner)
|
14 |
: TForm(Owner)
|
15 |
{
|
16 |
}
|
17 |
//---------------------------------------------------------------------------
|
18 |
void __fastcall TToolbar::FormCreate(TObject *Sender)
|
19 |
{
|
20 |
Fenp->existetool=1;
|
21 |
if (Fenp->existetool!=0)
|
22 |
if (Fenp->Barrevisible1->Checked==false) Toolbar->FormStyle=fsNormal;
|
23 |
else Toolbar->FormStyle=fsStayOnTop;
|
24 |
Toolbar->Caption="Outil pour "+Fenp->Caption;
|
25 |
Toolbar->Left=Fenp->toolx;
|
26 |
Toolbar->Top=Fenp->tooly;
|
27 |
}
|
28 |
//---------------------------------------------------------------------------
|
29 |
void __fastcall TToolbar::FormClose(TObject *Sender, TCloseAction &Action)
|
30 |
{
|
31 |
Action=caFree;
|
32 |
Fenp->existetool=0;
|
33 |
}
|
34 |
//---------------------------------------------------------------------------
|
35 |
void __fastcall TToolbar::BitBtn3Click(TObject *Sender)
|
36 |
{
|
37 |
Fenp->zoom=Fenp->zoom*1.1;
|
38 |
Fenp->xcentre=(Fenp->ClientWidth/2.-1.1*(Fenp->ClientWidth/2.-Fenp->xcentre));
|
39 |
Fenp->ycentre=(Fenp->ClientHeight/2.-1.1*(Fenp->ClientHeight/2.-Fenp->ycentre));
|
40 |
Fenp->Invalidate();
|
41 |
}
|
42 |
//---------------------------------------------------------------------------
|
43 |
void __fastcall TToolbar::BitBtn1Click(TObject *Sender)
|
44 |
{
|
45 |
Fenp->zoom=Fenp->zoom/1.1;
|
46 |
Fenp->xcentre=(Fenp->ClientWidth/2.-0.9090909090*(Fenp->ClientWidth/2.-Fenp->xcentre));
|
47 |
Fenp->ycentre=(Fenp->ClientHeight/2.-0.9090909090*(Fenp->ClientHeight/2.-Fenp->ycentre));
|
48 |
Fenp->Invalidate();
|
49 |
}
|
50 |
//---------------------------------------------------------------------------
|
51 |
void __fastcall TToolbar::BitBtn12Click(TObject *Sender)
|
52 |
{
|
53 |
Fenp->rot[0][0]=1.0;Fenp->rot[1][0]=0.0;Fenp->rot[2][0]=0.0;
|
54 |
Fenp->rot[0][1]=0.0;Fenp->rot[1][1]=1.0;Fenp->rot[2][1]=0.0;
|
55 |
Fenp->rot[0][2]=0.0;Fenp->rot[1][2]=0.0;Fenp->rot[2][2]=1.0;
|
56 |
Fenp->norme();
|
57 |
Fenp->Invalidate();
|
58 |
|
59 |
}
|
60 |
//---------------------------------------------------------------------------
|
61 |
void __fastcall TToolbar::BitBtn8Click(TObject *Sender)
|
62 |
{
|
63 |
Fenp->norme();
|
64 |
Fenp->Invalidate();
|
65 |
|
66 |
}
|
67 |
//---------------------------------------------------------------------------
|
68 |
void __fastcall TToolbar::BitBtn2Click(TObject *Sender)
|
69 |
{
|
70 |
if (Fenp->fc==1) Fenp->fc=0; else Fenp->fc=1;
|
71 |
Fenp->Invalidate();
|
72 |
|
73 |
}
|
74 |
//---------------------------------------------------------------------------
|
75 |
void __fastcall TToolbar::BitBtn11Click(TObject *Sender)
|
76 |
{
|
77 |
char mess[255];
|
78 |
|
79 |
sprintf(Fenp->info,"numero de noeud a afficher (0-%d)?",Fenp->nb_point);
|
80 |
Valeur->ShowModal();
|
81 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
82 |
sscanf(mess,"%d",&Fenp->numero_noeud);
|
83 |
if (Fenp->numero_noeud>=Fenp->nb_point) Fenp->numero_noeud=Fenp->nb_point;
|
84 |
Fenp->Invalidate();
|
85 |
}
|
86 |
//---------------------------------------------------------------------------
|
87 |
void __fastcall TToolbar::BitBtn10Click(TObject *Sender)
|
88 |
{
|
89 |
int nb_maille;
|
90 |
char mess[255];
|
91 |
|
92 |
nb_maille=Fenp->nb_segment+Fenp->nb_triangle+Fenp->nb_tetra;
|
93 |
sprintf(Fenp->info,"numero de maille a afficher (0-%d)?",nb_maille);
|
94 |
Valeur->ShowModal();
|
95 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
96 |
sscanf(mess,"%d",&Fenp->numero_maille);
|
97 |
if (Fenp->numero_maille>=nb_maille) Fenp->numero_maille=nb_maille;
|
98 |
Fenp->Invalidate();
|
99 |
|
100 |
}
|
101 |
//---------------------------------------------------------------------------
|
102 |
void __fastcall TToolbar::BitBtn9Click(TObject *Sender)
|
103 |
{
|
104 |
char mess[255];
|
105 |
float val;
|
106 |
|
107 |
strcpy(Fenp->info,"Valeur du zoom ?");
|
108 |
Valeur->ShowModal();
|
109 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
110 |
sscanf(mess,"%f",&val);
|
111 |
Fenp->zoom=Fenp->zoom*val;
|
112 |
Fenp->xcentre=(Fenp->ClientWidth/2.-val*(Fenp->ClientWidth/2.-Fenp->xcentre));
|
113 |
Fenp->ycentre=(Fenp->ClientHeight/2.-val*(Fenp->ClientHeight/2.-Fenp->ycentre));
|
114 |
Fenp->Invalidate();
|
115 |
}
|
116 |
//---------------------------------------------------------------------------
|
117 |
void __fastcall TToolbar::BitBtn13Click(TObject *Sender)
|
118 |
{
|
119 |
char mess[255];
|
120 |
float val;
|
121 |
|
122 |
strcpy(Fenp->info,"Valeur de la rotation suivant x ?");
|
123 |
Valeur->ShowModal();
|
124 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
125 |
sscanf(mess,"%f",&val);
|
126 |
Fenp->rotation(val/180.*PI,1);
|
127 |
Fenp->Invalidate();
|
128 |
|
129 |
}
|
130 |
//---------------------------------------------------------------------------
|
131 |
void __fastcall TToolbar::BitBtn14Click(TObject *Sender)
|
132 |
{
|
133 |
char mess[255];
|
134 |
float val;
|
135 |
|
136 |
strcpy(Fenp->info,"Valeur de la rotation suivant y ?");
|
137 |
Valeur->ShowModal();
|
138 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
139 |
sscanf(mess,"%f",&val);
|
140 |
Fenp->rotation(val/180.*PI,2);
|
141 |
Fenp->Invalidate();
|
142 |
|
143 |
}
|
144 |
//---------------------------------------------------------------------------
|
145 |
void __fastcall TToolbar::BitBtn15Click(TObject *Sender)
|
146 |
{
|
147 |
char mess[255];
|
148 |
float val;
|
149 |
|
150 |
strcpy(Fenp->info,"Valeur de la rotation suivant z ?");
|
151 |
Valeur->ShowModal();
|
152 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
153 |
sscanf(mess,"%f",&val);
|
154 |
Fenp->rotation(val/180.*PI,3);
|
155 |
Fenp->Invalidate();
|
156 |
|
157 |
}
|
158 |
//---------------------------------------------------------------------------
|
159 |
void __fastcall TToolbar::BitBtn4Click(TObject *Sender)
|
160 |
{
|
161 |
Fenp->ycentre=Fenp->ycentre+4;
|
162 |
Fenp->Invalidate();
|
163 |
|
164 |
}
|
165 |
//---------------------------------------------------------------------------
|
166 |
void __fastcall TToolbar::BitBtn6Click(TObject *Sender)
|
167 |
{
|
168 |
Fenp->ycentre=Fenp->ycentre-4;
|
169 |
Fenp->Invalidate();
|
170 |
|
171 |
}
|
172 |
//---------------------------------------------------------------------------
|
173 |
void __fastcall TToolbar::BitBtn5Click(TObject *Sender)
|
174 |
{
|
175 |
Fenp->xcentre=Fenp->xcentre-4;
|
176 |
Fenp->Invalidate();
|
177 |
|
178 |
}
|
179 |
//---------------------------------------------------------------------------
|
180 |
void __fastcall TToolbar::BitBtn7Click(TObject *Sender)
|
181 |
{
|
182 |
Fenp->xcentre=Fenp->xcentre+4;
|
183 |
Fenp->Invalidate();
|
184 |
|
185 |
}
|
186 |
//---------------------------------------------------------------------------
|
187 |
void __fastcall TToolbar::BitBtn16Click(TObject *Sender)
|
188 |
{
|
189 |
Fenp->rotation(0.1,1);
|
190 |
Fenp->Invalidate();
|
191 |
}
|
192 |
//---------------------------------------------------------------------------
|
193 |
void __fastcall TToolbar::BitBtn17Click(TObject *Sender)
|
194 |
{
|
195 |
Fenp->rotation(-0.1,1);
|
196 |
Fenp->Invalidate();
|
197 |
}
|
198 |
//---------------------------------------------------------------------------
|
199 |
void __fastcall TToolbar::BitBtn18Click(TObject *Sender)
|
200 |
{
|
201 |
Fenp->rotation(0.1,2);
|
202 |
Fenp->Invalidate();
|
203 |
}
|
204 |
//---------------------------------------------------------------------------
|
205 |
void __fastcall TToolbar::BitBtn19Click(TObject *Sender)
|
206 |
{
|
207 |
Fenp->rotation(-0.1,2);
|
208 |
Fenp->Invalidate();
|
209 |
}
|
210 |
//---------------------------------------------------------------------------
|
211 |
void __fastcall TToolbar::BitBtn20Click(TObject *Sender)
|
212 |
{
|
213 |
Fenp->rotation(0.1,3);
|
214 |
Fenp->Invalidate();
|
215 |
}
|
216 |
//---------------------------------------------------------------------------
|
217 |
void __fastcall TToolbar::BitBtn21Click(TObject *Sender)
|
218 |
{
|
219 |
Fenp->rotation(-0.1,3);
|
220 |
Fenp->Invalidate();
|
221 |
}
|
222 |
//---------------------------------------------------------------------------
|
223 |
void __fastcall TToolbar::BitBtn22Click(TObject *Sender)
|
224 |
{
|
225 |
if (Fenp->horizon==1) Fenp->horizon=0;
|
226 |
else Fenp->horizon=1;
|
227 |
Invalidate();
|
228 |
}
|
229 |
//---------------------------------------------------------------------------
|
230 |
void __fastcall TToolbar::FormPaint(TObject *Sender)
|
231 |
{
|
232 |
if (Fenp->horizon==1)
|
233 |
{
|
234 |
Toolbar->Width=630;
|
235 |
Toolbar->Height=94;
|
236 |
TrackBar1->Left=40;
|
237 |
TrackBar1->Top=32;
|
238 |
TrackBar1->Height=40;
|
239 |
TrackBar1->Width=570;
|
240 |
TrackBar1->Orientation=trHorizontal;
|
241 |
Button1->Left=23;
|
242 |
Button1->Top=29;
|
243 |
Button1->Height=41;
|
244 |
Button1->Width=17;
|
245 |
BitBtn22->Left=8;
|
246 |
BitBtn22->Top=0;
|
247 |
BitBtn3->Left=40;
|
248 |
BitBtn3->Top=0;
|
249 |
BitBtn1->Left=64;
|
250 |
BitBtn1->Top=0;
|
251 |
BitBtn12->Left=88;
|
252 |
BitBtn12->Top=0;
|
253 |
BitBtn8->Left=112;
|
254 |
BitBtn8->Top=0;
|
255 |
BitBtn2->Left=136;
|
256 |
BitBtn2->Top=0;
|
257 |
BitBtn11->Left=160;
|
258 |
BitBtn11->Top=0;
|
259 |
BitBtn10->Left=184;
|
260 |
BitBtn10->Top=0;
|
261 |
BitBtn9->Left=208;
|
262 |
BitBtn9->Top=0;
|
263 |
BitBtn13->Left=232;
|
264 |
BitBtn13->Top=0;
|
265 |
BitBtn14->Left=256;
|
266 |
BitBtn14->Top=0;
|
267 |
BitBtn15->Left=280;
|
268 |
BitBtn15->Top=0;
|
269 |
BitBtn4->Left=304;
|
270 |
BitBtn4->Top=0;
|
271 |
BitBtn6->Left=328;
|
272 |
BitBtn6->Top=0;
|
273 |
BitBtn5->Left=352;
|
274 |
BitBtn5->Top=0;
|
275 |
BitBtn7->Left=376;
|
276 |
BitBtn7->Top=0;
|
277 |
BitBtn16->Left=400;
|
278 |
BitBtn16->Top=0;
|
279 |
BitBtn17->Left=424;
|
280 |
BitBtn17->Top=0;
|
281 |
BitBtn18->Left=448;
|
282 |
BitBtn18->Top=0;
|
283 |
BitBtn19->Left=472;
|
284 |
BitBtn19->Top=0;
|
285 |
BitBtn20->Left=496;
|
286 |
BitBtn20->Top=0;
|
287 |
BitBtn21->Left=520;
|
288 |
BitBtn21->Top=0;
|
289 |
BitBtn23->Left=544;
|
290 |
BitBtn23->Top=0;
|
291 |
BitBtn24->Left=568;
|
292 |
BitBtn24->Top=0;
|
293 |
BitBtn25->Left=592;
|
294 |
BitBtn25->Top=0;
|
295 |
}
|
296 |
else
|
297 |
{
|
298 |
Toolbar->Width=107;
|
299 |
Toolbar->Height=350;
|
300 |
TrackBar1->Left=57;
|
301 |
TrackBar1->Top=40;
|
302 |
TrackBar1->Height=290;
|
303 |
TrackBar1->Width=40;
|
304 |
TrackBar1->Orientation=trVertical;
|
305 |
Button1->Left=56;
|
306 |
Button1->Top=23;
|
307 |
Button1->Height=17;
|
308 |
Button1->Width=41;
|
309 |
BitBtn22->Left=14;
|
310 |
BitBtn22->Top=8;
|
311 |
BitBtn3->Left=1;
|
312 |
BitBtn3->Top=40;
|
313 |
BitBtn1->Left=1;
|
314 |
BitBtn1->Top=64;
|
315 |
BitBtn12->Left=1;
|
316 |
BitBtn12->Top=88;
|
317 |
BitBtn8->Left=1;
|
318 |
BitBtn8->Top=112;
|
319 |
BitBtn2->Left=1;
|
320 |
BitBtn2->Top=136;
|
321 |
BitBtn11->Left=1;
|
322 |
BitBtn11->Top=160;
|
323 |
BitBtn10->Left=1;
|
324 |
BitBtn10->Top=184;
|
325 |
BitBtn9->Left=1;
|
326 |
BitBtn9->Top=208;
|
327 |
BitBtn13->Left=1;
|
328 |
BitBtn13->Top=232;
|
329 |
BitBtn14->Left=1;
|
330 |
BitBtn14->Top=256;
|
331 |
BitBtn15->Left=1;
|
332 |
BitBtn15->Top=280;
|
333 |
BitBtn4->Left=25;
|
334 |
BitBtn4->Top=40;
|
335 |
BitBtn6->Left=25;
|
336 |
BitBtn6->Top=64;
|
337 |
BitBtn5->Left=25;
|
338 |
BitBtn5->Top=88;
|
339 |
BitBtn7->Left=25;
|
340 |
BitBtn7->Top=112;
|
341 |
BitBtn16->Left=25;
|
342 |
BitBtn16->Top=136;
|
343 |
BitBtn17->Left=25;
|
344 |
BitBtn17->Top=160;
|
345 |
BitBtn18->Left=25;
|
346 |
BitBtn18->Top=184;
|
347 |
BitBtn19->Left=25;
|
348 |
BitBtn19->Top=208;
|
349 |
BitBtn20->Left=25;
|
350 |
BitBtn20->Top=232;
|
351 |
BitBtn21->Left=25;
|
352 |
BitBtn21->Top=256;
|
353 |
BitBtn23->Left=25;
|
354 |
BitBtn23->Top=280;
|
355 |
BitBtn24->Left=0;
|
356 |
BitBtn24->Top=304;
|
357 |
BitBtn25->Left=25;
|
358 |
BitBtn25->Top=304;
|
359 |
|
360 |
}
|
361 |
TrackBar1->Position=(int)(Fenp->loin*100.);
|
362 |
}
|
363 |
//---------------------------------------------------------------------------
|
364 |
void __fastcall TToolbar::BitBtn23Click(TObject *Sender)
|
365 |
{
|
366 |
char mess[255];
|
367 |
|
368 |
strcpy(Fenp->info,"Valeur de l'echelle ?");
|
369 |
sprintf(mess,"%f",Fenp->zoom);
|
370 |
Valeur->Edit1->Text=mess;
|
371 |
Valeur->ShowModal();
|
372 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
373 |
sscanf(mess,"%f",&(Fenp->zoom));
|
374 |
Fenp->Invalidate();
|
375 |
|
376 |
}
|
377 |
//---------------------------------------------------------------------------
|
378 |
void __fastcall TToolbar::BitBtn24Click(TObject *Sender)
|
379 |
{
|
380 |
Fenp->homo=Fenp->homo/1.1;
|
381 |
if (Fenp->homo<0.0001) Fenp->homo= 0.0001;
|
382 |
Fenp->Invalidate();
|
383 |
}
|
384 |
//---------------------------------------------------------------------------
|
385 |
void __fastcall TToolbar::BitBtn25Click(TObject *Sender)
|
386 |
{
|
387 |
Fenp->homo=Fenp->homo*1.1;
|
388 |
if (Fenp->homo>1) Fenp->homo=1.;
|
389 |
Fenp->Invalidate();
|
390 |
}
|
391 |
//---------------------------------------------------------------------------
|
392 |
void __fastcall TToolbar::TrackBar1Change(TObject *Sender)
|
393 |
{
|
394 |
float pos;
|
395 |
|
396 |
pos=(float)(TrackBar1->Position);
|
397 |
Fenp->loin=pos*0.01;
|
398 |
Fenp->Invalidate();
|
399 |
}
|
400 |
//---------------------------------------------------------------------------
|
401 |
void __fastcall TToolbar::Button1Click(TObject *Sender)
|
402 |
{
|
403 |
|
404 |
Fenp->loin=1.;
|
405 |
Toolbar->TrackBar1->Position=(int)(Fenp->loin*100.);
|
406 |
Fenp->Invalidate();
|
407 |
|
408 |
}
|
409 |
//---------------------------------------------------------------------------
|