ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/mesh/prop.cpp
Revision: 3
Committed: Tue Jun 12 12:42:51 2007 UTC (17 years, 11 months ago)
File size: 12429 byte(s)
Log Message:

File Contents

# Content
1 //---------------------------------------------------------------------------
2 #include <vcl.h>
3 #include <vcl\printers.hpp>
4 #pragma hdrstop
5
6 #include "prop.h"
7 #include "fenetre.h"
8 #include "debug.h"
9 //---------------------------------------------------------------------------
10 #pragma package(smart_init)
11 #pragma resource "*.dfm"
12 TPropriete *Propriete;
13 //---------------------------------------------------------------------------
14 __fastcall TPropriete::TPropriete(TComponent* Owner)
15 : TForm(Owner)
16 {
17 }
18 //---------------------------------------------------------------------------
19 void __fastcall TPropriete::FormClose(TObject *Sender,
20 TCloseAction &Action)
21 {
22 Action=caFree;
23 }
24 //---------------------------------------------------------------------------
25 void __fastcall TPropriete::Button1Click(TObject *Sender)
26 {
27 Propriete->Close();
28 }
29 //---------------------------------------------------------------------------
30 void __fastcall TPropriete::FormCreate(TObject *Sender)
31 {
32 if (Fendebug->type==2)
33 {
34 Edit10->Visible=False;
35 Edit11->Visible=False;
36 Edit12->Visible=False;
37 Edit13->Visible=False;
38 Edit14->Visible=False;
39 Edit15->Visible=False;
40 Edit16->Visible=False;
41 Edit17->Visible=False;
42 Label1->Caption="Segment";
43 if (Fendebug->type2==2) Listbox=Fendebug->ListBox2;
44 if (Fendebug->type2==1) Listbox=Fendebug->ListBox1;
45 Propriete->Caption="Propriéte de segment";
46 }
47 if (Fendebug->type==3)
48 {
49 Edit14->Visible=False;
50 Edit15->Visible=False;
51 Edit16->Visible=False;
52 Edit17->Visible=False;
53 Label1->Caption="Triangle";
54 if (Fendebug->type2==2) Listbox=Fendebug->ListBox4;
55 if (Fendebug->type2==1) Listbox=Fendebug->ListBox3;
56 Propriete->Caption="Propriéte de triangle";
57 }
58 if (Fendebug->type==4)
59 {
60 Label1->Caption="Tetraédre";
61 if (Fendebug->type2==2) Listbox=Fendebug->ListBox6;
62 if (Fendebug->type2==1) Listbox=Fendebug->ListBox5;
63 Propriete->Caption="Propriéte de tetraédre";
64 }
65
66
67 numcour=0;
68 while (!Listbox->Selected[numcour]) numcour++;
69 Edit1->Text=Listbox->Items->Strings[numcour];
70 }
71 //---------------------------------------------------------------------------
72 void __fastcall TPropriete::SpeedButton2Click(TObject *Sender)
73 {
74 numcour++;
75 if (numcour>Listbox->Items->Count-1) numcour=0;
76 while (!Listbox->Selected[numcour])
77 {
78 numcour++;
79 if (numcour>Listbox->Items->Count-1) numcour=0;
80 }
81 Edit1->Text=Listbox->Items->Strings[numcour];
82 }
83 //---------------------------------------------------------------------------
84 void __fastcall TPropriete::SpeedButton1Click(TObject *Sender)
85 {
86 numcour--;
87 if (numcour<0) numcour=Listbox->Items->Count-1;
88 while (!Listbox->Selected[numcour])
89 {
90 numcour--;
91 if (numcour<0) numcour=Listbox->Items->Count-1;
92 }
93 Edit1->Text=Listbox->Items->Strings[numcour];
94
95 }
96 //---------------------------------------------------------------------------
97 void __fastcall TPropriete::Edit1Change(TObject *Sender)
98 {
99 struct s_triangle *tri;
100 struct s_tetra *tet;
101 struct s_segment *seg;
102 int num;
103
104 if (Fendebug->type==2)
105 {
106 sscanf(Listbox->Items->Strings[numcour].c_str(),"%d",&num);
107 seg=&(Fenp->segment[num]);
108 Edit5->Text=seg->n1;
109 Edit2->Text=Fenp->point[seg->n1].x;
110 Edit3->Text=Fenp->point[seg->n1].y;
111 Edit4->Text=Fenp->point[seg->n1].z;
112 Edit6->Text=seg->n2;
113 Edit7->Text=Fenp->point[seg->n2].x;
114 Edit8->Text=Fenp->point[seg->n2].y;
115 Edit9->Text=Fenp->point[seg->n2].z;
116 }
117 if (Fendebug->type==3)
118 {
119 sscanf(Listbox->Items->Strings[numcour].c_str(),"%d",&num);
120 tri=&(Fenp->triangle[num]);
121 Edit5->Text=tri->n1;
122 Edit2->Text=Fenp->point[tri->n1].x;
123 Edit3->Text=Fenp->point[tri->n1].y;
124 Edit4->Text=Fenp->point[tri->n1].z;
125 Edit6->Text=tri->n2;
126 Edit7->Text=Fenp->point[tri->n2].x;
127 Edit8->Text=Fenp->point[tri->n2].y;
128 Edit9->Text=Fenp->point[tri->n2].z;
129 Edit10->Text=tri->n3;
130 Edit11->Text=Fenp->point[tri->n3].x;
131 Edit12->Text=Fenp->point[tri->n3].y;
132 Edit13->Text=Fenp->point[tri->n3].z;
133 }
134 if (Fendebug->type==4)
135 {
136 sscanf(Listbox->Items->Strings[numcour].c_str(),"%d",&num);
137 tet=&(Fenp->tetra[num]);
138 Edit5->Text=tet->n1;
139 Edit2->Text=Fenp->point[tet->n1].x;
140 Edit3->Text=Fenp->point[tet->n1].y;
141 Edit4->Text=Fenp->point[tet->n1].z;
142 Edit6->Text=tet->n2;
143 Edit7->Text=Fenp->point[tet->n2].x;
144 Edit8->Text=Fenp->point[tet->n2].y;
145 Edit9->Text=Fenp->point[tet->n2].z;
146 Edit10->Text=tet->n3;
147 Edit11->Text=Fenp->point[tet->n3].x;
148 Edit12->Text=Fenp->point[tet->n3].y;
149 Edit13->Text=Fenp->point[tet->n3].z;
150 Edit14->Text=tet->n4;
151 Edit15->Text=Fenp->point[tet->n4].x;
152 Edit16->Text=Fenp->point[tet->n4].y;
153 Edit17->Text=Fenp->point[tet->n4].z;
154 }
155
156
157 }
158 //---------------------------------------------------------------------------
159 void __fastcall TPropriete::Button2Click(TObject *Sender)
160 {
161 struct s_triangle *tri;
162 struct s_tetra *tet;
163 struct s_segment *seg;
164 int wtot,htot,w,h;
165 int i,n,nb_sel;
166 char mess[500];
167 int num;
168
169 if (!PrintDialog1->Execute()) return;
170 Printer()->Title=Fenp->Fichier;
171 Printer()->BeginDoc();
172
173 htot=Printer()->PageHeight;
174 wtot=Printer()->PageWidth;
175
176 w=(int)(0.1*wtot);h=(int)(0.1*htot);
177 Printer()->Canvas->Font->Name="times";
178 Printer()->Canvas->Font->Size=10;
179
180 nb_sel=Listbox->SelCount;
181 for (i=0,n=0;n<nb_sel;i++)
182 if (Listbox->Selected[i])
183 {
184 n++;
185 if (Fendebug->type==2)
186 {
187 sscanf(Listbox->Items->Strings[i].c_str(),"%d",&num);
188 seg=&(Fenp->segment[num]);
189 sprintf(mess,"Segment %d",num);
190 Printer()->Canvas->TextOut(w,h,mess);
191 h=h+(int)(0.03*htot);
192 if (h>(int)(0.9*htot))
193 {
194 Printer()->NewPage();
195 h=(int)(0.1*htot);
196 }
197 sprintf(mess,"n1 : %d;",seg->n1);
198 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
199 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[seg->n1].x,Fenp->point[seg->n1].y,Fenp->point[seg->n1].z);
200 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
201 h=h+(int)(0.03*htot);
202 if (h>(int)(0.9*htot))
203 {
204 Printer()->NewPage();
205 h=(int)(0.1*htot);
206 }
207 sprintf(mess,"n2 : %d;",seg->n2);
208 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
209 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[seg->n2].x,Fenp->point[seg->n2].y,Fenp->point[seg->n2].z);
210 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
211 h=h+(int)(0.03*htot);
212 if (h>(int)(0.9*htot))
213 {
214 Printer()->NewPage();
215 h=(int)(0.1*htot);
216 }
217 }
218 if (Fendebug->type==3)
219 {
220 sscanf(Listbox->Items->Strings[i].c_str(),"%d",&num);
221 tri=&(Fenp->triangle[num]);
222 sprintf(mess,"Triangle %d",num);
223 Printer()->Canvas->TextOut(w,h,mess);
224 h=h+(int)(0.03*htot);
225 if (h>(int)(0.9*htot))
226 {
227 Printer()->NewPage();
228 h=(int)(0.1*htot);
229 }
230 sprintf(mess,"n1 : %d;",tri->n1);
231 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
232 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tri->n1].x,Fenp->point[tri->n1].y,Fenp->point[tri->n1].z);
233 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
234 h=h+(int)(0.03*htot);
235 if (h>(int)(0.9*htot))
236 {
237 Printer()->NewPage();
238 h=(int)(0.1*htot);
239 }
240 sprintf(mess,"n2 : %d;",tri->n2);
241 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
242 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tri->n2].x,Fenp->point[tri->n2].y,Fenp->point[tri->n2].z);
243 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
244 h=h+(int)(0.03*htot);
245 if (h>(int)(0.9*htot))
246 {
247 Printer()->NewPage();
248 h=(int)(0.1*htot);
249 }
250 sprintf(mess,"n3 : %d;",tri->n3);
251 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
252 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tri->n3].x,Fenp->point[tri->n3].y,Fenp->point[tri->n3].z);
253 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
254 h=h+(int)(0.03*htot);
255 if (h>(int)(0.9*htot))
256 {
257 Printer()->NewPage();
258 h=(int)(0.1*htot);
259 }
260 }
261 if (Fendebug->type==4)
262 {
263 sscanf(Listbox->Items->Strings[i].c_str(),"%d",&num);
264 tet=&(Fenp->tetra[num]);
265 sprintf(mess,"Tétraèdre %d",num);
266 Printer()->Canvas->TextOut(w,h,mess);
267 h=h+(int)(0.03*htot);
268 if (h>(int)(0.9*htot))
269 {
270 Printer()->NewPage();
271 h=(int)(0.1*htot);
272 }
273 sprintf(mess,"n1 : %d;",tet->n1);
274 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
275 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tet->n1].x,Fenp->point[tet->n1].y,Fenp->point[tet->n1].z);
276 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
277 h=h+(int)(0.03*htot);
278 if (h>(int)(0.9*htot))
279 {
280 Printer()->NewPage();
281 h=(int)(0.1*htot);
282 }
283 sprintf(mess,"n2 : %d;",tet->n2);
284 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
285 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tet->n2].x,Fenp->point[tet->n2].y,Fenp->point[tet->n2].z);
286 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
287 h=h+(int)(0.03*htot);
288 if (h>(int)(0.9*htot))
289 {
290 Printer()->NewPage();
291 h=(int)(0.1*htot);
292 }
293 sprintf(mess,"n3 : %d;",tet->n3);
294 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
295 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tet->n3].x,Fenp->point[tet->n3].y,Fenp->point[tet->n3].z);
296 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
297 h=h+(int)(0.03*htot);
298 if (h>(int)(0.9*htot))
299 {
300 Printer()->NewPage();
301 h=(int)(0.1*htot);
302 }
303 sprintf(mess,"n4 : %d;",tet->n4);
304 Printer()->Canvas->TextOut(w+(int)(0.1*wtot),h,mess);
305 sprintf(mess,"X=%f; Y=%f; Z=%f;",Fenp->point[tet->n4].x,Fenp->point[tet->n4].y,Fenp->point[tet->n4].z);
306 Printer()->Canvas->TextOut(w+(int)(0.3*wtot),h,mess);
307 h=h+(int)(0.03*htot);
308 if (h>(int)(0.9*htot))
309 {
310 Printer()->NewPage();
311 h=(int)(0.1*htot);
312 }
313
314 }
315
316 }
317
318 Printer()->EndDoc();
319
320 }
321 //---------------------------------------------------------------------------
322