0023791: Remove obsolete functionality - animation mode and degeneration presentation...
[occt.git] / samples / CSharp / shell / shell.h
CommitLineData
7fd59977 1#pragma once
2#using <mscorlib.dll>
3#include "OCCViewer.h"
4#include "StdAfx.h"
5
6public ref class shell
7{
8
9private:
10 OCCViewer* myOCCViewer;
11public:
12
13 bool InitViewer(System::IntPtr wnd)
14 {
15 if (myOCCViewer != NULL)
16 return myOCCViewer->InitViewer(wnd.ToPointer());
17 else
18 return false;
19 }
20
21 bool ImportBrep(System::String^ filename)
22 {
23 if (myOCCViewer == NULL)
24 return false;
25 int length = filename->Length;
26 char * fname = new char[length+1];
27 for(int i = 0; i<length; i++)
28 fname[i] = (char)filename->ToCharArray()[i];
29
30 fname[length] = '\0';
31 bool res = myOCCViewer->ImportBRep(fname);
32 delete [] fname;
33 return res;
34 }
35
36 void RedrawView(void)
37 {
38 if (myOCCViewer != NULL)
39 myOCCViewer->RedrawView();
40 }
41
42 void UpdateView(void)
43 {
44 if (myOCCViewer != NULL)
45 myOCCViewer->UpdateView();
46 }
47
48 void SetDegenerateModeOn(void)
49 {
50 if (myOCCViewer != NULL)
51 myOCCViewer->SetDegenerateModeOn();
52 }
53
54 void SetDegenerateModeOff(void)
55 {
56 if (myOCCViewer != NULL)
57 myOCCViewer->SetDegenerateModeOff();
58 }
59
60 void WindowFitAll(int Xmin, int Ymin, int Xmax, int Ymax)
61 {
62 if (myOCCViewer != NULL)
63 myOCCViewer->WindowFitAll(Xmin, Ymin, Xmax, Ymax);
64 }
65
66 void Place(int x, int y, float zoomFactor)
67 {
68 if (myOCCViewer != NULL)
69 myOCCViewer->Place(x, y, zoomFactor);
70 }
71
72 void Zoom(int x1, int y1, int x2, int y2)
73 {
74 if (myOCCViewer != NULL)
75 myOCCViewer->Zoom(x1, y1, x2, y2);
76 }
77
78 void Pan(int x, int y)
79 {
80 if (myOCCViewer != NULL)
81 myOCCViewer->Pan(x, y);
82 }
83
84 void Rotation(int x, int y)
85 {
86 if (myOCCViewer != NULL)
87 myOCCViewer->Rotation(x, y);
88 }
89
90 void StartRotation(int x, int y)
91 {
92 if (myOCCViewer != NULL)
93 myOCCViewer->StartRotation(x, y);
94 }
95
96 void Select(int x1, int y1, int x2, int y2)
97 {
98 if (myOCCViewer != NULL)
99 myOCCViewer->Select(x1, y1, x2, y2);
100 }
101
102 void Select(void)
103 {
104 if (myOCCViewer != NULL)
105 myOCCViewer->Select();
106 }
107
108 void MoveTo(int x, int y)
109 {
110 if (myOCCViewer != NULL)
111 myOCCViewer->MoveTo(x, y);
112 }
113
114 void ShiftSelect(int x1, int y1, int x2, int y2)
115 {
116 if (myOCCViewer != NULL)
117 myOCCViewer->ShiftSelect(x1, y1, x2, y2);
118 }
119
120 void ShiftSelect(void)
121 {
122 if (myOCCViewer != NULL)
123 myOCCViewer->ShiftSelect();
124 }
125
126 int GetBGColR(void)
127 {
128 int r, b, g;
129 if (myOCCViewer != NULL)
130 myOCCViewer->BackgroundColor(r,g,b);
131 return r;
132 }
133
134 int GetBGColG(void)
135 {
136 int r, b, g;
137 if (myOCCViewer != NULL)
138 myOCCViewer->BackgroundColor(r,g,b);
139 return g;
140 }
141
142 int GetBGColB(void)
143 {
144 int r, b, g;
145 if (myOCCViewer != NULL)
146 myOCCViewer->BackgroundColor(r,g,b);
147 return b;
148 }
149
150 void UpdateCurrentViewer(void)
151 {
152 if (myOCCViewer != NULL)
153 myOCCViewer->UpdateCurrentViewer();
154 }
155
156 void FrontView(void)
157 {
158 if (myOCCViewer != NULL)
159 myOCCViewer->FrontView();
160 }
161
162 void TopView(void)
163 {
164 if (myOCCViewer != NULL)
165 myOCCViewer->TopView();
166 }
167
168 void LeftView(void)
169 {
170 if (myOCCViewer != NULL)
171 myOCCViewer->LeftView();
172 }
173
174 void BackView(void)
175 {
176 if (myOCCViewer != NULL)
177 myOCCViewer->BackView();
178 }
179
180 void RightView(void)
181 {
182 if (myOCCViewer != NULL)
183 myOCCViewer->RightView();
184 }
185
186 void BottomView(void)
187 {
188 if (myOCCViewer != NULL)
189 myOCCViewer->BottomView();
190 }
191
192 void AxoView(void)
193 {
194 if (myOCCViewer != NULL)
195 myOCCViewer->AxoView();
196 }
197
198 float Scale(void)
199 {
200 if (myOCCViewer != NULL)
201 return myOCCViewer->Scale();
202 else
203 return -1;
204 }
205
206 void ZoomAllView(void)
207 {
208 if (myOCCViewer != NULL)
209 myOCCViewer->ZoomAllView();
210 }
211
212 void Reset(void)
213 {
214 if (myOCCViewer != NULL)
215 myOCCViewer->ResetView();
216 }
217
218 void SetDisplayMode(int aMode)
219 {
220 if (myOCCViewer != NULL)
221 myOCCViewer->SetDisplayMode(aMode);
222 }
223
224 void SetColor(int r, int g, int b)
225 {
226 if (myOCCViewer != NULL)
227 myOCCViewer->SetColor(r, g, b);
228 }
229
230 int GetObjColR(void)
231 {
232 int r, g, b;
233 if (myOCCViewer != NULL)
234 myOCCViewer->ObjectColor(r, g, b);
235 return r;
236 }
237
238 int GetObjColG(void)
239 {
240 int r, g, b;
241 if (myOCCViewer != NULL)
242 myOCCViewer->ObjectColor(r, g, b);
243 return g;
244 }
245
246 int GetObjColB(void)
247 {
248 int r, g, b;
249 if (myOCCViewer != NULL)
250 myOCCViewer->ObjectColor(r, g, b);
251 return b;
252 }
253
254 void SetBackgroundColor(int r, int g, int b)
255 {
256 if (myOCCViewer != NULL)
257 myOCCViewer->SetBackgroundColor(r, g, b);
258 }
259
260 void EraseObjects(void)
261 {
262 if (myOCCViewer != NULL)
263 myOCCViewer->EraseObjects();
264 }
265
266 float GetOCCVersion(void)
267 {
268 if (myOCCViewer == NULL)
269 return 0.0;
270 else
271 return myOCCViewer->GetVersion();
272 }
273
274 void SetMaterial(int theMaterial)
275 {
276 if (myOCCViewer != NULL)
277 myOCCViewer->SetMaterial(theMaterial);
278 }
279
280 void SetTransparency(int TheTrans)
281 {
282 if (myOCCViewer != NULL)
283 myOCCViewer->SetTransparency(TheTrans);
284 }
285
286 bool TranslateModel(System::String^ filename, int format, bool IsImport)
287 {
288 if (myOCCViewer == NULL)
289 return false;
290 int length = filename->Length;
291 char * fname = new char[length+1];
292 for(int i = 0; i<length; i++)
293 fname[i] = (char)filename->ToCharArray()[i];
294
295 fname[length] = '\0';
296 bool res;
297 if (IsImport)
298 {
299 switch(format)
300 {
301 case 0:
302 res=myOCCViewer->ImportBRep(fname);
303 break;
304 case 1:
305 res=myOCCViewer->ImportCsfdb(fname);
306 break;
307 case 2:
308 res=myOCCViewer->ImportStep(fname);
309 break;
310 case 3:
311 res=myOCCViewer->ImportIges(fname);
312 break;
313 default:
314 res=false;
315 }
316 } else
317 {
318 switch(format)
319 {
320 case 0:
321 res=myOCCViewer->ExportBRep(fname);
322 break;
323 case 2:
324 res=myOCCViewer->ExpotStep(fname);
325 break;
326 case 3:
327 res=myOCCViewer->ExportIges(fname);
328 break;
329 case 4:
330 res=myOCCViewer->ExportVrml(fname);
331 break;
332 case 5:
333 res=myOCCViewer->ExportStl(fname);
334 break;
335 case 6:
336 res=myOCCViewer->Dump(fname);
337 default:
338 res=false;
339 }
340 }
341 delete [] fname;
342 return res;
343 }
344
345 bool IsObjectSelected(void)
346 {
347 if (myOCCViewer != NULL)
348 return myOCCViewer->IsObjectSelected();
349 else
350 return false;
351 }
352
353 int DisplayMode(void)
354 {
355 if (myOCCViewer != NULL)
356 return myOCCViewer->DisplayMode();
357 else return -1;
358 }
359
360 void CreateNewView(System::IntPtr wnd)
361 {
362 if (myOCCViewer != NULL)
363 myOCCViewer->CreateNewView(wnd.ToPointer());
364 }
365
366 bool SetAISContext(shell^ v)
367 {
368 if (myOCCViewer != NULL)
369 return this->myOCCViewer->SetAISContext(v->GetOCCViewer());
370 else
371 return false;
372 }
373
374 OCCViewer* GetOCCViewer(void)
375 {
376 return myOCCViewer;
377 }
378
379 void InitOCCViewer(void)
380 {
381 myOCCViewer = new OCCViewer();
382 }
383
384 int CharToInt(System::String^ symbol)
385 {
386 if (myOCCViewer == NULL)
387 return -1;
388 char s = (char)symbol->ToCharArray()[0];
389 return myOCCViewer->CharToInt(s);
390 }
391};