Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1998-09-01 |
2 | // Created by: Robert COUBLANC | |
3 | // Copyright (c) 1998-1999 Matra Datavision | |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS | |
5 | // | |
6 | // The content of this file is subject to the Open CASCADE Technology Public | |
7 | // License Version 6.5 (the "License"). You may not use the content of this file | |
8 | // except in compliance with the License. Please obtain a copy of the License | |
9 | // at http://www.opencascade.org and read it completely before using this file. | |
10 | // | |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
13 | // | |
14 | // The Original Code and all software distributed under the License is | |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
16 | // Initial Developer hereby disclaims all such warranties, including without | |
17 | // limitation, any warranties of merchantability, fitness for a particular | |
18 | // purpose or non-infringement. Please see the License for the specific terms | |
19 | // and conditions governing the rights and limitations under the License. | |
20 | ||
7fd59977 | 21 | |
22 | // Robert Boehne 30 May 2000 : Dec Osf | |
23 | ||
24 | #ifdef HAVE_CONFIG_H | |
25 | # include <config.h> | |
26 | #endif | |
27 | ||
28 | #ifdef WNT | |
29 | #include <windows.h> | |
30 | #endif | |
31 | ||
2bd4c032 | 32 | #include <Graphic3d_AspectMarker3d.hxx> |
7fd59977 | 33 | #include <Graphic3d_ExportFormat.hxx> |
34 | #include <ViewerTest.hxx> | |
35 | #include <ViewerTest_EventManager.hxx> | |
36 | #include <Visual3d_View.hxx> | |
25289ec1 | 37 | #include <Visual3d_ViewManager.hxx> |
38 | #include <V3d_LayerMgr.hxx> | |
7fd59977 | 39 | #include <NIS_View.hxx> |
40 | #include <NIS_Triangulated.hxx> | |
41 | #include <NIS_InteractiveContext.hxx> | |
42 | #include <AIS_InteractiveContext.hxx> | |
43 | #include <Draw_Interpretor.hxx> | |
44 | #include <Draw.hxx> | |
45 | #include <Draw_Appli.hxx> | |
7edf74fd A |
46 | #include <Aspect_PrintAlgo.hxx> |
47 | #include <Image_PixMap.hxx> | |
59f45b7c | 48 | #include <TColStd_SequenceOfInteger.hxx> |
20637bd2 | 49 | #include <Visual3d_LayerItem.hxx> |
50 | #include <V3d_LayerMgr.hxx> | |
51 | #include <V3d_LayerMgrPointer.hxx> | |
52 | #include <Aspect_TypeOfLine.hxx> | |
7fd59977 | 53 | |
25289ec1 | 54 | #ifdef WNT |
55 | #undef DrawText | |
56 | #endif | |
57 | ||
58 | #include <Visual3d_Layer.hxx> | |
59 | ||
7fd59977 | 60 | #ifndef WNT |
61 | #include <Graphic3d_GraphicDevice.hxx> | |
62 | #include <Xw_GraphicDevice.hxx> | |
63 | #include <Xw_WindowQuality.hxx> | |
64 | #include <Xw_Window.hxx> | |
65 | #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */ | |
66 | #include <X11/Xutil.h> | |
67 | #include <tk.h> | |
68 | ||
69 | #else | |
70 | ||
71 | #include <Graphic3d_WNTGraphicDevice.hxx> | |
72 | #include <WNT_WClass.hxx> | |
73 | #include <WNT_Window.hxx> | |
74 | ||
75 | #define _CRT_SECURE_NO_DEPRECATE | |
76 | #pragma warning (disable:4996) | |
77 | ||
78 | #endif | |
79 | ||
80 | #define OCC120 | |
81 | ||
82 | //============================================================================== | |
83 | ||
84 | //============================================================================== | |
85 | // VIEWER GLOBAL VARIABLES | |
86 | //============================================================================== | |
87 | ||
88 | Standard_IMPORT Standard_Boolean Draw_VirtualWindows; | |
89 | ||
90 | Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv); | |
91 | extern const Handle(NIS_InteractiveContext)& TheNISContext(); | |
92 | ||
93 | #ifdef WNT | |
94 | static Handle(Graphic3d_WNTGraphicDevice)& GetG3dDevice(){ | |
95 | static Handle(Graphic3d_WNTGraphicDevice) GD; | |
96 | return GD; | |
97 | } | |
98 | ||
99 | static Handle(WNT_Window)& VT_GetWindow() { | |
100 | static Handle(WNT_Window) WNTWin; | |
101 | return WNTWin; | |
102 | } | |
103 | ||
104 | #else | |
105 | static Handle(Graphic3d_GraphicDevice)& GetG3dDevice(){ | |
106 | static Handle(Graphic3d_GraphicDevice) GD; | |
107 | return GD; | |
108 | } | |
109 | static Handle(Xw_Window)& VT_GetWindow(){ | |
110 | static Handle(Xw_Window) XWWin; | |
111 | return XWWin; | |
112 | } | |
113 | static Display *display; | |
114 | ||
115 | static void VProcessEvents(ClientData,int); | |
116 | #endif | |
117 | ||
118 | #ifdef OCC120 | |
119 | static Standard_Boolean DegenerateMode = Standard_True; | |
120 | #endif | |
121 | ||
122 | #define ZCLIPWIDTH 1. | |
123 | ||
124 | static void OSWindowSetup(); | |
125 | ||
126 | //============================================================================== | |
127 | // EVENT GLOBAL VARIABLES | |
128 | //============================================================================== | |
129 | ||
130 | static int Start_Rot = 0; | |
131 | static int ZClipIsOn = 0; | |
132 | static int X_Motion= 0,Y_Motion=0; // Current cursor position | |
133 | static int X_ButtonPress = 0, Y_ButtonPress = 0; // Last ButtonPress position | |
134 | ||
135 | ||
136 | //============================================================================== | |
137 | ||
138 | #ifdef WNT | |
139 | static LRESULT WINAPI ViewerWindowProc( | |
140 | HWND hwnd, | |
141 | UINT uMsg, | |
142 | WPARAM wParam, | |
143 | LPARAM lParam ); | |
144 | static LRESULT WINAPI AdvViewerWindowProc( | |
145 | HWND hwnd, | |
146 | UINT uMsg, | |
147 | WPARAM wParam, | |
148 | LPARAM lParam ); | |
149 | #endif | |
150 | ||
151 | ||
152 | //============================================================================== | |
153 | //function : WClass | |
154 | //purpose : | |
155 | //============================================================================== | |
156 | ||
157 | const Handle(MMgt_TShared)& ViewerTest::WClass() | |
158 | { | |
159 | static Handle(MMgt_TShared) theWClass; | |
160 | #ifdef WNT | |
161 | if (theWClass.IsNull()) { | |
162 | theWClass = new WNT_WClass ("GW3D_Class", AdvViewerWindowProc, | |
163 | CS_VREDRAW | CS_HREDRAW, 0, 0, | |
164 | ::LoadCursor (NULL, IDC_ARROW)); | |
165 | } | |
166 | #endif | |
167 | return theWClass; | |
168 | } | |
169 | ||
170 | //============================================================================== | |
171 | //function : ViewerInit | |
172 | //purpose : Create the window viewer and initialize all the global variable | |
173 | //============================================================================== | |
174 | ||
175 | void ViewerTest::ViewerInit (const Standard_Integer thePxLeft, const Standard_Integer thePxTop, | |
176 | const Standard_Integer thePxWidth, const Standard_Integer thePxHeight) | |
177 | { | |
178 | static Standard_Boolean isFirst = Standard_True; | |
179 | ||
180 | Standard_Integer aPxLeft = 0; | |
181 | Standard_Integer aPxTop = 460; | |
182 | Standard_Integer aPxWidth = 409; | |
183 | Standard_Integer aPxHeight = 409; | |
184 | if (thePxWidth != 0 && thePxHeight != 0) | |
185 | { | |
186 | aPxLeft = thePxLeft; | |
187 | aPxTop = thePxTop; | |
188 | aPxWidth = thePxWidth; | |
189 | aPxHeight = thePxHeight; | |
190 | } | |
191 | ||
192 | if (isFirst) | |
193 | { | |
194 | // Create the Graphic device | |
195 | #ifdef WNT | |
196 | if (GetG3dDevice().IsNull()) GetG3dDevice() = new Graphic3d_WNTGraphicDevice(); | |
197 | if (VT_GetWindow().IsNull()) | |
198 | { | |
199 | // Create the Graphic device and the window | |
200 | Handle(WNT_GraphicDevice) g_Device = new WNT_GraphicDevice(); | |
201 | ||
202 | VT_GetWindow() = new WNT_Window (g_Device, "Test3d", | |
203 | Handle(WNT_WClass)::DownCast (WClass()), | |
204 | WS_OVERLAPPEDWINDOW, | |
205 | aPxLeft, aPxTop, | |
206 | aPxWidth, aPxHeight, | |
207 | Quantity_NOC_BLACK); | |
208 | VT_GetWindow()->SetVirtual (Draw_VirtualWindows); | |
209 | } | |
210 | #else | |
211 | if (GetG3dDevice().IsNull()) GetG3dDevice() = | |
212 | new Graphic3d_GraphicDevice (getenv ("DISPLAY"), Xw_TOM_READONLY); | |
213 | if (VT_GetWindow().IsNull()) | |
214 | { | |
215 | VT_GetWindow() = new Xw_Window (GetG3dDevice(), | |
216 | "Test3d", | |
217 | aPxLeft, aPxTop, | |
218 | aPxWidth, aPxHeight, | |
219 | Xw_WQ_3DQUALITY, | |
220 | Quantity_NOC_BLACK); | |
221 | VT_GetWindow()->SetVirtual (Draw_VirtualWindows); | |
222 | } | |
223 | #endif | |
224 | ||
225 | Handle(V3d_Viewer) a3DViewer, a3DCollector; | |
226 | // Viewer and View creation | |
227 | ||
228 | TCollection_ExtendedString NameOfWindow("Visu3D"); | |
229 | ||
230 | a3DViewer = new V3d_Viewer(GetG3dDevice(), NameOfWindow.ToExtString()); | |
231 | NameOfWindow = TCollection_ExtendedString("Collector"); | |
232 | a3DCollector = new V3d_Viewer(GetG3dDevice(), NameOfWindow.ToExtString()); | |
233 | a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); | |
234 | a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE); | |
235 | Handle(NIS_View) aView = | |
236 | Handle(NIS_View)::DownCast(ViewerTest::CurrentView()); | |
237 | if ( aView.IsNull() ) { | |
238 | // Handle (V3d_View) V = a3DViewer->CreateView(); | |
239 | aView = new NIS_View (a3DViewer, VT_GetWindow()); | |
240 | ViewerTest::CurrentView(aView); | |
241 | TheNISContext()->AttachView (aView); | |
242 | } | |
243 | Handle(V3d_View) a3DViewCol; | |
244 | if ( a3DViewCol.IsNull() ) a3DViewCol = a3DViewer->CreateView(); | |
245 | ||
246 | // AIS setup | |
247 | if ( ViewerTest::GetAISContext().IsNull() ) { | |
248 | Handle(AIS_InteractiveContext) C = | |
249 | new AIS_InteractiveContext(a3DViewer,a3DCollector); | |
250 | ViewerTest::SetAISContext(C); | |
251 | } | |
252 | ||
253 | // Setup for X11 or NT | |
254 | OSWindowSetup(); | |
255 | // Viewer and View creation | |
256 | ||
257 | a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); | |
258 | ||
259 | Handle (V3d_View) V = ViewerTest::CurrentView(); | |
260 | ||
261 | V->SetDegenerateModeOn(); | |
262 | #ifdef OCC120 | |
263 | DegenerateMode = V->DegenerateModeIsOn(); | |
264 | #endif | |
265 | // V->SetWindow(VT_GetWindow(), NULL, MyViewProc, NULL); | |
266 | ||
267 | V->SetZClippingDepth(0.5); | |
268 | V->SetZClippingWidth(ZCLIPWIDTH/2.); | |
269 | a3DViewer->SetDefaultLights(); | |
270 | a3DViewer->SetLightOn(); | |
271 | ||
272 | #ifndef WNT | |
273 | #if TCL_MAJOR_VERSION < 8 | |
274 | Tk_CreateFileHandler((void*)ConnectionNumber(display), | |
275 | TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() ); | |
276 | #else | |
277 | Tk_CreateFileHandler(ConnectionNumber(display), | |
278 | TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() ); | |
279 | #endif | |
280 | #endif | |
281 | ||
282 | isFirst = Standard_False; | |
283 | } | |
284 | VT_GetWindow()->Map(); | |
285 | } | |
286 | ||
287 | //============================================================================== | |
288 | //function : Vinit | |
289 | //purpose : Create the window viewer and initialize all the global variable | |
290 | // Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event | |
291 | //============================================================================== | |
292 | ||
293 | static int VInit (Draw_Interpretor& , Standard_Integer argc, const char** argv) | |
294 | { | |
295 | Standard_Integer aPxLeft = (argc > 1) ? atoi (argv[1]) : 0; | |
296 | Standard_Integer aPxTop = (argc > 2) ? atoi (argv[2]) : 0; | |
297 | Standard_Integer aPxWidth = (argc > 3) ? atoi (argv[3]) : 0; | |
298 | Standard_Integer aPxHeight = (argc > 4) ? atoi (argv[4]) : 0; | |
299 | ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight); | |
300 | return 0; | |
301 | } | |
302 | ||
303 | //============================================================================== | |
304 | //function : ProcessKeyPress | |
305 | //purpose : Handle KeyPress event from a CString | |
306 | //============================================================================== | |
307 | ||
308 | static void ProcessKeyPress( char *buf_ret ) | |
309 | { | |
310 | //cout << "KeyPress" << endl; | |
311 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
312 | const Handle(NIS_View) aNisView = Handle(NIS_View)::DownCast (aView); | |
313 | // Letter in alphabetic order | |
314 | ||
315 | if ( !strcasecmp(buf_ret, "A") ) { | |
316 | // AXO | |
317 | aView->SetProj(V3d_XposYnegZpos); | |
318 | } | |
319 | else if ( !strcasecmp(buf_ret, "D") ) { | |
320 | // Reset | |
321 | aView->Reset(); | |
322 | } | |
323 | else if ( !strcasecmp(buf_ret, "F") ) { | |
324 | // FitAll | |
325 | if (aNisView.IsNull()) | |
326 | aView->FitAll(); | |
327 | else | |
328 | aNisView->FitAll3d(); | |
329 | } | |
330 | else if ( !strcasecmp(buf_ret, "H") ) { | |
331 | // HLR | |
332 | cout << "HLR" << endl; | |
333 | #ifdef OCC120 | |
334 | if (aView->DegenerateModeIsOn()) ViewerTest::CurrentView()->SetDegenerateModeOff(); | |
335 | else aView->SetDegenerateModeOn(); | |
336 | DegenerateMode = aView->DegenerateModeIsOn(); | |
337 | #else | |
338 | ViewerTest::CurrentView()->SetDegenerateModeOff(); | |
339 | #endif | |
340 | } | |
341 | else if ( !strcasecmp(buf_ret, "D") ) { | |
342 | // Reset | |
343 | aView->Reset(); | |
344 | } | |
345 | else if ( !strcasecmp(buf_ret, "S") ) { | |
346 | // SHADING | |
347 | cout << "passage en mode 1 (shading pour les shapes)" << endl; | |
348 | #ifndef OCC120 | |
349 | ViewerTest::CurrentView()->SetDegenerateModeOn(); | |
350 | #endif | |
351 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); | |
352 | if(Ctx->NbCurrents()==0 || | |
353 | Ctx->NbSelected()==0) | |
354 | Ctx->SetDisplayMode(AIS_Shaded); | |
355 | else{ | |
356 | if(Ctx->HasOpenedContext()){ | |
357 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) | |
358 | Ctx->SetDisplayMode(Ctx->Interactive(),1,Standard_False); | |
359 | } | |
360 | else{ | |
361 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) | |
362 | Ctx->SetDisplayMode(Ctx->Current(),1,Standard_False); | |
363 | } | |
364 | Ctx->UpdateCurrentViewer(); | |
365 | } | |
366 | } | |
367 | else if ( !strcasecmp(buf_ret, "U") ) { | |
368 | // SHADING | |
369 | cout<<"passage au mode par defaut"<<endl; | |
370 | #ifndef OCC120 | |
371 | ViewerTest::CurrentView()->SetDegenerateModeOn(); | |
372 | #endif | |
373 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); | |
374 | if(Ctx->NbCurrents()==0 || | |
375 | Ctx->NbSelected()==0) | |
376 | Ctx->SetDisplayMode(AIS_WireFrame); | |
377 | else{ | |
378 | if(Ctx->HasOpenedContext()){ | |
379 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) | |
380 | Ctx->UnsetDisplayMode(Ctx->Interactive(),Standard_False); | |
381 | } | |
382 | else{ | |
383 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) | |
384 | Ctx->UnsetDisplayMode(Ctx->Current(),Standard_False); | |
385 | } | |
386 | Ctx->UpdateCurrentViewer(); | |
387 | } | |
388 | ||
389 | } | |
390 | else if ( !strcasecmp(buf_ret, "T") ) { | |
391 | // Top | |
392 | aView->SetProj(V3d_Zpos); | |
393 | } | |
394 | else if ( !strcasecmp(buf_ret, "B") ) { | |
395 | // Top | |
396 | aView->SetProj(V3d_Zneg); | |
397 | } | |
398 | else if ( !strcasecmp(buf_ret, "L") ) { | |
399 | // Top | |
400 | aView->SetProj(V3d_Xneg); | |
401 | } | |
402 | else if ( !strcasecmp(buf_ret, "R") ) { | |
403 | // Top | |
404 | aView->SetProj(V3d_Xpos); | |
405 | } | |
406 | ||
407 | else if ( !strcasecmp(buf_ret, "W") ) { | |
408 | // WIREFRAME | |
409 | #ifndef OCC120 | |
410 | ViewerTest::CurrentView()->SetDegenerateModeOn(); | |
411 | #endif | |
412 | cout << "passage en mode 0 (filaire pour les shapes)" << endl; | |
413 | #ifndef OCC120 | |
414 | ViewerTest::CurrentView()->SetDegenerateModeOn(); | |
415 | #endif | |
416 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); | |
417 | if(Ctx->NbCurrents()==0 || | |
418 | Ctx->NbSelected()==0) | |
419 | Ctx->SetDisplayMode(AIS_WireFrame); | |
420 | else{ | |
421 | if(Ctx->HasOpenedContext()){ | |
422 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) | |
423 | Ctx->SetDisplayMode(Ctx->Interactive(),0,Standard_False); | |
424 | } | |
425 | else{ | |
426 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) | |
427 | Ctx->SetDisplayMode(Ctx->Current(),0,Standard_False); | |
428 | } | |
429 | Ctx->UpdateCurrentViewer(); | |
430 | } | |
431 | } | |
432 | else if ( !strcasecmp(buf_ret, "Z") ) { | |
433 | // ZCLIP | |
434 | ||
435 | if ( ZClipIsOn ) { | |
436 | cout << "ZClipping OFF" << endl; | |
437 | ZClipIsOn = 0; | |
438 | ||
439 | aView->SetZClippingType(V3d_OFF); | |
440 | aView->Redraw(); | |
441 | } | |
442 | else { | |
443 | cout << "ZClipping ON" << endl; | |
444 | ZClipIsOn = 1; | |
445 | ||
446 | aView->SetZClippingType(V3d_FRONT); | |
447 | aView->Redraw(); | |
448 | } | |
449 | } | |
450 | else if ( !strcasecmp(buf_ret, ",") ) { | |
451 | ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView()); | |
452 | ||
453 | ||
454 | } | |
455 | else if ( !strcasecmp(buf_ret, ".") ) { | |
456 | ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView()); | |
457 | } | |
458 | // Number | |
459 | else{ | |
460 | Standard_Integer Num = atoi(buf_ret); | |
461 | if(Num>=0 && Num<=7) | |
462 | ViewerTest::StandardModeActivation(Num); | |
463 | } | |
464 | } | |
465 | ||
466 | //============================================================================== | |
467 | //function : ProcessExpose | |
468 | //purpose : Redraw the View on an Expose Event | |
469 | //============================================================================== | |
470 | ||
471 | static void ProcessExpose( ) | |
472 | { //cout << "Expose" << endl; | |
473 | ViewerTest::CurrentView()->Redraw(); | |
474 | } | |
475 | ||
476 | //============================================================================== | |
477 | //function : ProcessConfigure | |
478 | //purpose : Resize the View on an Configure Event | |
479 | //============================================================================== | |
480 | ||
481 | static void ProcessConfigure() | |
482 | { | |
483 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
484 | V->MustBeResized(); | |
485 | V->Update(); | |
486 | V->Redraw(); | |
487 | } | |
488 | ||
489 | //============================================================================== | |
490 | //function : ProcessButton1Press | |
491 | //purpose : Picking | |
492 | //============================================================================== | |
493 | ||
494 | static Standard_Boolean ProcessButton1Press( | |
495 | Standard_Integer , | |
496 | const char** argv, | |
497 | Standard_Boolean pick, | |
498 | Standard_Boolean shift ) | |
499 | { | |
500 | Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); | |
501 | if ( pick ) { | |
502 | Standard_Real X, Y, Z; | |
503 | ||
504 | ViewerTest::CurrentView()->Convert(X_Motion, Y_Motion, X, Y, Z); | |
505 | ||
506 | Draw::Set(argv[1], X); | |
507 | Draw::Set(argv[2], Y); | |
508 | Draw::Set(argv[3], Z);} | |
509 | ||
510 | if(shift) | |
511 | EM->ShiftSelect(); | |
512 | else | |
513 | EM->Select(); | |
514 | ||
515 | pick = 0; | |
516 | return pick; | |
517 | } | |
518 | ||
519 | //============================================================================== | |
520 | //function : ProcessButton3Press | |
521 | //purpose : Start Rotation | |
522 | //============================================================================== | |
523 | ||
524 | static void ProcessButton3Press() | |
525 | ||
526 | { // Start rotation | |
527 | Start_Rot = 1; | |
528 | ViewerTest::CurrentView()->SetDegenerateModeOn(); | |
529 | ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress ); | |
530 | ||
531 | } | |
532 | //============================================================================== | |
533 | //function : ProcessButtonRelease | |
534 | //purpose : Start Rotation | |
535 | //============================================================================== | |
536 | ||
537 | static void ProcessButtonRelease() | |
538 | ||
539 | { // End rotation | |
540 | #ifdef OCC120 | |
541 | if (Start_Rot) { | |
542 | Start_Rot = 0; | |
543 | if (!DegenerateMode) ViewerTest::CurrentView()->SetDegenerateModeOff(); | |
544 | } | |
545 | #else | |
546 | Start_Rot = 0; | |
547 | ViewerTest::CurrentView()->SetDegenerateModeOff(); | |
548 | #endif | |
549 | } | |
550 | ||
551 | //============================================================================== | |
552 | //function : ProcessZClipMotion | |
553 | //purpose : Zoom | |
554 | //============================================================================== | |
555 | ||
556 | void ProcessZClipMotion() | |
557 | { | |
558 | Handle(V3d_View) a3DView = ViewerTest::CurrentView(); | |
559 | if ( Abs(X_Motion - X_ButtonPress) > 2 ) { | |
560 | static Standard_Real CurZPos = 0.; | |
561 | ||
562 | //Quantity_Length VDX, VDY; | |
563 | //a3DView->Size(VDX,VDY); | |
564 | //Standard_Real VDZ = a3DView->ZSize(); | |
565 | //printf("View size (%lf,%lf,%lf)\n", VDX, VDY, VDZ); | |
566 | ||
567 | Quantity_Length dx = a3DView->Convert(X_Motion - X_ButtonPress); | |
568 | ||
569 | // Front = Depth + width/2. | |
570 | Standard_Real D = 0.5; | |
571 | Standard_Real W = 0.1; | |
572 | ||
573 | CurZPos += (dx); | |
574 | ||
575 | D += CurZPos; | |
576 | ||
577 | //printf("dx %lf Depth %lf Width %lf\n", dx, D, W); | |
578 | ||
579 | a3DView->SetZClippingType(V3d_OFF); | |
580 | a3DView->SetZClippingDepth(D); | |
581 | a3DView->SetZClippingWidth(W); | |
582 | a3DView->SetZClippingType(V3d_FRONT); | |
583 | ||
584 | a3DView->Redraw(); | |
585 | ||
586 | X_ButtonPress = X_Motion; | |
587 | Y_ButtonPress = Y_Motion; | |
588 | } | |
589 | } | |
590 | ||
591 | //============================================================================== | |
592 | //function : ProcessControlButton1Motion | |
593 | //purpose : Zoom | |
594 | //============================================================================== | |
595 | ||
596 | static void ProcessControlButton1Motion() | |
597 | { | |
598 | ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion); | |
599 | ||
600 | X_ButtonPress = X_Motion; | |
601 | Y_ButtonPress = Y_Motion; | |
602 | } | |
603 | ||
604 | //============================================================================== | |
605 | //function : ProcessControlButton2Motion | |
606 | //purpose : Pann | |
607 | //============================================================================== | |
608 | ||
609 | static void ProcessControlButton2Motion() | |
610 | { | |
611 | Quantity_Length dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress); | |
612 | Quantity_Length dy = ViewerTest::CurrentView()->Convert(Y_Motion - Y_ButtonPress); | |
613 | ||
614 | dy = -dy; // Xwindow Y axis is from top to Bottom | |
615 | ||
616 | ViewerTest::CurrentView()->Panning( dx, dy ); | |
617 | ||
618 | X_ButtonPress = X_Motion; | |
619 | Y_ButtonPress = Y_Motion; | |
620 | } | |
621 | ||
622 | //============================================================================== | |
623 | //function : ProcessControlButton3Motion | |
624 | //purpose : Rotation | |
625 | //============================================================================== | |
626 | ||
627 | static void ProcessControlButton3Motion() | |
628 | { | |
629 | if ( Start_Rot ) ViewerTest::CurrentView()->Rotation( X_Motion, Y_Motion); | |
630 | } | |
631 | ||
632 | //============================================================================== | |
633 | //function : ProcessPointerMotion | |
634 | //purpose : Rotation | |
635 | //============================================================================== | |
636 | ||
637 | static void ProcessMotion() | |
638 | { | |
639 | //pre-hilights detected objects at mouse position | |
640 | ||
641 | Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); | |
642 | EM->MoveTo(X_Motion, Y_Motion); | |
643 | } | |
644 | ||
645 | ||
646 | void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix) | |
647 | { | |
648 | Xpix = X_Motion;Ypix=Y_Motion; | |
649 | } | |
650 | ||
651 | //============================================================================== | |
652 | //function : VAxo | |
653 | //purpose : Switch to an Axonometric view | |
654 | //Draw arg : No args | |
655 | //============================================================================== | |
656 | ||
657 | static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** ) | |
658 | { if ( ViewerTest::CurrentView().IsNull() ) { | |
659 | di<<"La commande vinit n'a pas ete appele avant"<<"\n"; | |
660 | // VInit(di, argc, argv); | |
661 | } | |
662 | ||
663 | ViewerTest::CurrentView()->SetProj(V3d_XposYnegZpos); | |
664 | ||
665 | return 0; | |
666 | } | |
667 | ||
668 | //============================================================================== | |
669 | //function : VTop | |
670 | //purpose : Switch to a Top View | |
671 | //Draw arg : No args | |
672 | //============================================================================== | |
673 | ||
674 | static int VTop(Draw_Interpretor& di, Standard_Integer , const char** ) | |
675 | { | |
676 | ||
677 | if ( ViewerTest::CurrentView().IsNull() ) { | |
678 | di<<"La commande vinit n'a pas ete appele avant"<<"\n"; | |
679 | ||
680 | // VInit(di, , argv); | |
681 | } | |
682 | ||
683 | ViewerTest::CurrentView()->SetProj(V3d_Zpos); | |
684 | return 0; | |
685 | ||
686 | } | |
687 | ||
688 | //============================================================================== | |
689 | //function : VHelp | |
690 | //purpose : Dsiplay help on viewer Keyboead and mouse commands | |
691 | //Draw arg : No args | |
692 | //============================================================================== | |
693 | ||
694 | static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** ) | |
695 | { | |
696 | ||
697 | di << "Q : Quit the application" << "\n"; | |
698 | ||
699 | di << "========================="<<"\n"; | |
700 | di << "F : FitAll" << "\n"; | |
701 | di << "T : TopView" << "\n"; | |
702 | di << "A : AxonometricView" << "\n"; | |
703 | di << "R : ResetView" << "\n"; | |
704 | ||
705 | di << "========================="<<"\n"; | |
706 | di << "S : Shading" << "\n"; | |
707 | di << "W : Wireframe" << "\n"; | |
708 | di << "H : HidelLineRemoval" << "\n"; | |
709 | ||
710 | di << "========================="<<"\n"; | |
711 | di << "Selection mode "<<"\n"; | |
712 | di << "0 : Shape" <<"\n"; | |
713 | di << "1 : Vertex" <<"\n"; | |
714 | di << "2 : Edge" <<"\n"; | |
715 | di << "3 : Wire" <<"\n"; | |
716 | di << "4 : Face" <<"\n"; | |
717 | di << "5 : Shell" <<"\n"; | |
718 | di << "6 : Solid" <<"\n"; | |
719 | di << "7 : Compound" <<"\n"; | |
720 | ||
721 | di << "=========================="<<"\n"; | |
722 | di << "D : Remove Selected Object"<<"\n"; | |
723 | di << "=========================="<<"\n"; | |
724 | ||
725 | return 0; | |
726 | } | |
727 | ||
728 | Standard_Boolean IsDragged = Standard_False; | |
729 | ||
730 | Standard_Integer xx1, yy1, xx2, yy2; | |
731 | //the first and last point in viewer co-ordinates | |
732 | ||
733 | Standard_Boolean DragFirst; | |
734 | ||
735 | ||
736 | #ifdef WNT | |
737 | ||
738 | static Standard_Boolean Ppick = 0; | |
739 | static Standard_Integer Pargc = 0; | |
740 | static const char** Pargv = NULL; | |
741 | ||
742 | ||
743 | static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd, | |
744 | UINT Msg, | |
745 | WPARAM wParam, | |
746 | LPARAM lParam ) | |
747 | { | |
748 | if ( !ViewerTest::CurrentView().IsNull() ) { | |
749 | ||
750 | WPARAM fwKeys = wParam; | |
751 | ||
752 | switch( Msg ) { | |
753 | ||
754 | case WM_LBUTTONUP: | |
755 | IsDragged = Standard_False; | |
756 | if( !DragFirst ) | |
757 | { | |
758 | HDC hdc = GetDC( hwnd ); | |
759 | HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) ); | |
760 | SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) ); | |
761 | SetROP2( hdc, R2_NOT ); | |
762 | Rectangle( hdc, xx1, yy1, xx2, yy2 ); | |
763 | ReleaseDC( hwnd, hdc ); | |
764 | ||
765 | const Handle(ViewerTest_EventManager) EM = | |
766 | ViewerTest::CurrentEventManager(); | |
767 | if ( fwKeys & MK_SHIFT ) | |
768 | EM->ShiftSelect( min( xx1, xx2 ), max( yy1, yy2 ), | |
769 | max( xx1, xx2 ), min( yy1, yy2 )); | |
770 | else | |
771 | EM->Select( min( xx1, xx2 ), max( yy1, yy2 ), | |
772 | max( xx1, xx2 ), min( yy1, yy2 )); | |
773 | } | |
774 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
775 | ||
776 | case WM_LBUTTONDOWN: | |
777 | if( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) ) | |
778 | { | |
779 | IsDragged = Standard_True; | |
780 | DragFirst = Standard_True; | |
781 | xx1 = LOWORD(lParam); | |
782 | yy1 = HIWORD(lParam); | |
783 | } | |
784 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
785 | ||
786 | break; | |
787 | ||
788 | case WM_MOUSEMOVE: | |
789 | if( IsDragged ) | |
790 | { | |
791 | HDC hdc = GetDC( hwnd ); | |
792 | ||
793 | HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) ); | |
794 | SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) ); | |
795 | SetROP2( hdc, R2_NOT ); | |
796 | ||
797 | if( !DragFirst ) | |
798 | Rectangle( hdc, xx1, yy1, xx2, yy2 ); | |
799 | ||
800 | DragFirst = Standard_False; | |
801 | xx2 = LOWORD(lParam); | |
802 | yy2 = HIWORD(lParam); | |
803 | ||
804 | Rectangle( hdc, xx1, yy1, xx2, yy2 ); | |
805 | ||
806 | SelectObject( hdc, anObj ); | |
807 | ||
808 | ReleaseDC( hwnd, hdc ); | |
809 | } | |
810 | else | |
811 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
812 | break; | |
813 | ||
814 | default: | |
815 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
816 | } | |
817 | return 0; | |
818 | } | |
819 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
820 | } | |
821 | ||
822 | ||
823 | static LRESULT WINAPI ViewerWindowProc( HWND hwnd, | |
824 | UINT Msg, | |
825 | WPARAM wParam, | |
826 | LPARAM lParam ) | |
827 | { | |
828 | /*static Standard_Boolean Ppick = 0; | |
829 | static Standard_Integer Pargc = 0; | |
830 | static char** Pargv = NULL;*/ | |
831 | ||
832 | static int Up = 1; | |
833 | ||
834 | if ( !ViewerTest::CurrentView().IsNull() ) { | |
835 | PAINTSTRUCT ps; | |
836 | ||
837 | switch( Msg ) { | |
838 | case WM_CLOSE: | |
839 | // do not destroy the window - just hide it! | |
840 | VT_GetWindow()->Unmap(); | |
841 | return 0; | |
842 | case WM_PAINT: | |
843 | //cout << "\t WM_PAINT" << endl; | |
844 | BeginPaint(hwnd, &ps); | |
845 | EndPaint(hwnd, &ps); | |
846 | ProcessExpose(); | |
847 | break; | |
848 | ||
849 | case WM_SIZE: | |
850 | //cout << "\t WM_SIZE" << endl; | |
851 | ProcessConfigure(); | |
852 | break; | |
853 | ||
854 | case WM_KEYDOWN: | |
855 | //cout << "\t WM_KEYDOWN " << (int) wParam << endl; | |
856 | ||
857 | if ( (wParam != VK_SHIFT) && (wParam != VK_CONTROL) ) { | |
858 | char c[2]; | |
859 | c[0] = (char) wParam; | |
860 | c[1] = '\0'; | |
861 | ProcessKeyPress( c); | |
862 | } | |
863 | break; | |
864 | ||
865 | case WM_LBUTTONUP: | |
866 | case WM_MBUTTONUP: | |
867 | case WM_RBUTTONUP: | |
868 | //cout << "\t WM_xBUTTONUP" << endl; | |
869 | Up = 1; | |
870 | ProcessButtonRelease(); | |
871 | break; | |
872 | ||
873 | case WM_LBUTTONDOWN: | |
874 | case WM_MBUTTONDOWN: | |
875 | case WM_RBUTTONDOWN: | |
876 | { | |
877 | //cout << "\t WM_xBUTTONDOWN" << endl; | |
878 | WPARAM fwKeys = wParam; | |
879 | ||
880 | Up = 0; | |
881 | ||
882 | X_ButtonPress = LOWORD(lParam); | |
883 | Y_ButtonPress = HIWORD(lParam); | |
884 | ||
885 | if ( Msg == WM_LBUTTONDOWN) { | |
886 | if(fwKeys & MK_CONTROL) { | |
887 | Ppick = ProcessButton1Press( Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) ); | |
888 | } else | |
889 | ProcessButton1Press( Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) ); | |
890 | } | |
891 | else if ( Msg == WM_RBUTTONDOWN ) { | |
892 | // Start rotation | |
893 | ProcessButton3Press( ); | |
894 | } | |
895 | } | |
896 | break; | |
897 | ||
898 | case WM_MOUSEMOVE: | |
899 | { | |
900 | //cout << "\t WM_MOUSEMOVE" << endl; | |
901 | WPARAM fwKeys = wParam; | |
902 | X_Motion = LOWORD(lParam); | |
903 | Y_Motion = HIWORD(lParam); | |
904 | ||
905 | if ( Up && | |
906 | fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON ) ) { | |
907 | Up = 0; | |
908 | X_ButtonPress = LOWORD(lParam); | |
909 | Y_ButtonPress = HIWORD(lParam); | |
910 | ||
911 | if ( fwKeys & MK_RBUTTON ) { | |
912 | // Start rotation | |
913 | ProcessButton3Press(); | |
914 | } | |
915 | } | |
916 | ||
917 | if ( fwKeys & MK_CONTROL ) { | |
918 | if ( fwKeys & MK_LBUTTON ) { | |
919 | ProcessControlButton1Motion(); | |
920 | } | |
921 | else if ( fwKeys & MK_MBUTTON || | |
922 | ((fwKeys&MK_LBUTTON) && | |
923 | (fwKeys&MK_RBUTTON) ) ){ | |
924 | ProcessControlButton2Motion(); | |
925 | } | |
926 | else if ( fwKeys & MK_RBUTTON ) { | |
927 | ProcessControlButton3Motion(); | |
928 | } | |
929 | } | |
930 | #ifdef BUG | |
931 | else if ( fwKeys & MK_SHIFT ) { | |
932 | if ( fwKeys & MK_MBUTTON || | |
933 | ((fwKeys&MK_LBUTTON) && | |
934 | (fwKeys&MK_RBUTTON) ) ) { | |
935 | cout << "ProcessZClipMotion()" << endl; | |
936 | ProcessZClipMotion(); | |
937 | } | |
938 | } | |
939 | #endif | |
940 | else | |
941 | if (( fwKeys & MK_MBUTTON || ((fwKeys&MK_LBUTTON) && (fwKeys&MK_RBUTTON) ) )){ | |
942 | ProcessZClipMotion(); | |
943 | } | |
944 | else { | |
945 | ProcessMotion(); | |
946 | } | |
947 | } | |
948 | break; | |
949 | ||
950 | default: | |
951 | return( DefWindowProc( hwnd, Msg, wParam, lParam )); | |
952 | } | |
953 | return 0L; | |
954 | } | |
955 | ||
956 | return DefWindowProc( hwnd, Msg, wParam, lParam ); | |
957 | } | |
958 | ||
959 | ||
960 | ||
961 | ||
962 | //============================================================================== | |
963 | //function : ViewerMainLoop | |
964 | //purpose : Get a Event on the view and dispatch it | |
965 | //============================================================================== | |
966 | ||
967 | ||
968 | static int ViewerMainLoop(Standard_Integer argc, const char** argv) | |
969 | { | |
970 | ||
971 | //cout << "No yet implemented on WNT" << endl; | |
972 | /*static Standard_Boolean Ppick = 0; | |
973 | static Standard_Integer Pargc = 0; | |
974 | static char** Pargv = NULL;*/ | |
975 | ||
976 | //Ppick = (argc > 0)? -1 : 0; | |
977 | Ppick = (argc > 0)? 1 : 0; | |
978 | Pargc = argc; | |
979 | Pargv = argv; | |
980 | ||
981 | if ( Ppick ) { | |
982 | MSG msg; | |
983 | msg.wParam = 1; | |
984 | ||
985 | cout << "Start picking" << endl; | |
986 | ||
987 | //while ( Ppick == -1 ) { | |
988 | while ( Ppick == 1 ) { | |
989 | // Wait for a ProcessButton1Press() to toggle pick to 1 or 0 | |
990 | if (GetMessage(&msg, NULL, 0, 0) ) { | |
991 | TranslateMessage(&msg); | |
992 | DispatchMessage(&msg); | |
993 | } | |
994 | } | |
995 | ||
996 | cout << "Picking done" << endl; | |
997 | } | |
998 | ||
999 | return Ppick; | |
1000 | } | |
1001 | ||
1002 | ||
1003 | #else | |
1004 | ||
1005 | int min( int a, int b ) | |
1006 | { | |
1007 | if( a<b ) | |
1008 | return a; | |
1009 | else | |
1010 | return b; | |
1011 | } | |
1012 | ||
1013 | int max( int a, int b ) | |
1014 | { | |
1015 | if( a>b ) | |
1016 | return a; | |
1017 | else | |
1018 | return b; | |
1019 | } | |
1020 | ||
1021 | int ViewerMainLoop(Standard_Integer argc, const char** argv) | |
1022 | ||
1023 | { Standard_Boolean pick = argc > 0; | |
1024 | ||
1025 | // X11 Event loop | |
1026 | ||
1027 | static XEvent report; | |
1028 | ||
1029 | XNextEvent( display, &report ); | |
1030 | // cout << "rep type = " << report.type << endl; | |
1031 | // cout << "rep button = " << report.xbutton.button << endl; | |
1032 | ||
1033 | switch ( report.type ) { | |
1034 | case Expose: | |
1035 | { | |
1036 | ProcessExpose(); | |
1037 | } | |
1038 | break; | |
1039 | case ConfigureNotify: | |
1040 | { | |
1041 | ProcessConfigure(); | |
1042 | } | |
1043 | break; | |
1044 | case KeyPress: | |
1045 | { | |
1046 | ||
1047 | KeySym ks_ret ; | |
1048 | char buf_ret[11] ; | |
1049 | int ret_len ; | |
1050 | XComposeStatus status_in_out; | |
1051 | ||
1052 | ret_len = XLookupString( ( XKeyEvent *)&report , | |
1053 | (char *) buf_ret , 10 , | |
1054 | &ks_ret , &status_in_out ) ; | |
1055 | ||
1056 | ||
1057 | buf_ret[ret_len] = '\0' ; | |
1058 | ||
1059 | if ( ret_len ) { | |
1060 | ProcessKeyPress( buf_ret); | |
1061 | } | |
1062 | } | |
1063 | break; | |
1064 | case ButtonPress: | |
1065 | // cout << "ButtonPress" << endl; | |
1066 | { | |
1067 | X_ButtonPress = report.xbutton.x; | |
1068 | Y_ButtonPress = report.xbutton.y; | |
1069 | ||
1070 | if ( report.xbutton.button == Button1 ) | |
1071 | if( report.xbutton.state & ControlMask ) | |
1072 | pick = ProcessButton1Press( argc, argv, pick, | |
1073 | ( report.xbutton.state & ShiftMask) ); | |
1074 | else | |
1075 | { | |
1076 | IsDragged = Standard_True; | |
1077 | xx1 = X_ButtonPress; | |
1078 | yy1 = Y_ButtonPress; | |
1079 | DragFirst = Standard_True; | |
1080 | } | |
1081 | else if ( report.xbutton.button == Button3 ) | |
1082 | // Start rotation | |
1083 | ProcessButton3Press(); | |
1084 | } | |
1085 | break; | |
1086 | case ButtonRelease: | |
1087 | { | |
1088 | // cout<<"relachement du bouton "<<(report.xbutton.button==3 ? "3": "on s'en fout") <<endl; | |
1089 | // cout << IsDragged << endl; | |
1090 | // cout << DragFirst << endl; | |
1091 | ||
1092 | if( IsDragged ) | |
1093 | { | |
1094 | if( !DragFirst ) | |
1095 | { | |
1096 | Aspect_Handle aWindow = VT_GetWindow()->XWindow(); | |
1097 | GC gc = XCreateGC( display, aWindow, 0, 0 ); | |
1098 | // XSetFunction( display, gc, GXinvert ); | |
1099 | XDrawRectangle( display, aWindow, gc, min( xx1, xx2 ), min( yy1, yy2 ), abs( xx2-xx1 ), abs( yy2-yy1 ) ); | |
1100 | } | |
1101 | ||
1102 | Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext(); | |
1103 | if( aContext.IsNull() ) | |
1104 | { | |
1105 | cout << "The context is null. Please use vinit before createmesh" << endl; | |
1106 | return 0; | |
1107 | } | |
1108 | ||
1109 | Standard_Boolean ShiftPressed = ( report.xbutton.state & ShiftMask ); | |
1110 | if( report.xbutton.button==1 ) | |
1111 | if( DragFirst ) | |
1112 | if( ShiftPressed ) | |
1113 | { | |
1114 | aContext->ShiftSelect(); | |
1115 | // cout << "shift select" << endl; | |
1116 | } | |
1117 | else | |
1118 | { | |
1119 | aContext->Select(); | |
1120 | // cout << "select" << endl; | |
1121 | } | |
1122 | else | |
1123 | if( ShiftPressed ) | |
1124 | { | |
1125 | aContext->ShiftSelect( min( xx1, xx2 ), min( yy1, yy2 ), | |
1126 | max( xx1, xx2 ), max( yy1, yy2 ), | |
1127 | ViewerTest::CurrentView()); | |
1128 | // cout << "shift select" << endl; | |
1129 | } | |
1130 | else | |
1131 | { | |
1132 | aContext->Select( min( xx1, xx2 ), min( yy1, yy2 ), | |
1133 | max( xx1, xx2 ), max( yy1, yy2 ), | |
1134 | ViewerTest::CurrentView() ); | |
1135 | // cout << "select" << endl; | |
1136 | } | |
1137 | else | |
1138 | ProcessButtonRelease(); | |
1139 | ||
1140 | IsDragged = Standard_False; | |
1141 | } | |
1142 | else | |
1143 | ProcessButtonRelease(); | |
1144 | } | |
1145 | break; | |
1146 | case MotionNotify: | |
1147 | { | |
1148 | // XEvent dummy; | |
1149 | ||
1150 | X_Motion = report.xmotion.x; | |
1151 | Y_Motion = report.xmotion.y; | |
1152 | ||
1153 | if( IsDragged ) | |
1154 | { | |
1155 | Aspect_Handle aWindow = VT_GetWindow()->XWindow(); | |
1156 | GC gc = XCreateGC( display, aWindow, 0, 0 ); | |
1157 | XSetFunction( display, gc, GXinvert ); | |
1158 | ||
1159 | if( !DragFirst ) | |
1160 | XDrawRectangle( display, aWindow, gc, min( xx1, xx2 ), min( yy1, yy2 ), abs( xx2-xx1 ), abs( yy2-yy1 ) ); | |
1161 | ||
1162 | xx2 = X_Motion; | |
1163 | yy2 = Y_Motion; | |
1164 | DragFirst = Standard_False; | |
1165 | ||
1166 | //cout << "draw rect : " << xx2 << ", " << yy2 << endl; | |
1167 | XDrawRectangle( display, aWindow, gc, min( xx1, xx2 ), min( yy1, yy2 ), abs( xx2-xx1 ), abs( yy2-yy1 ) ); | |
1168 | } | |
1169 | else | |
1170 | { | |
1171 | ||
1172 | //cout << "MotionNotify " << X_Motion << "," << Y_Motion << endl; | |
1173 | ||
1174 | // remove all the ButtonMotionMask | |
1175 | while( XCheckMaskEvent( display, ButtonMotionMask, &report) ) ; | |
1176 | ||
1177 | if ( ZClipIsOn && report.xmotion.state & ShiftMask ) { | |
1178 | if ( Abs(X_Motion - X_ButtonPress) > 2 ) { | |
1179 | ||
1180 | Quantity_Length VDX, VDY; | |
1181 | ||
1182 | ViewerTest::CurrentView()->Size(VDX,VDY); | |
1183 | Standard_Real VDZ =0 ; | |
1184 | VDZ = ViewerTest::CurrentView()->ZSize(); | |
1185 | ||
1186 | // printf("%lf,%lf,%lf\n", VDX, VDY, VDZ); | |
1187 | printf("%f,%f,%f\n", VDX, VDY, VDZ); | |
1188 | ||
1189 | Quantity_Length dx = 0 ; | |
1190 | dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress); | |
1191 | ||
1192 | cout << dx << endl; | |
1193 | ||
1194 | dx = dx / VDX * VDZ; | |
1195 | ||
1196 | cout << dx << endl; | |
1197 | ||
1198 | // Front = Depth + width/2. | |
1199 | //ViewerTest::CurrentView()->SetZClippingDepth(dx); | |
1200 | //ViewerTest::CurrentView()->SetZClippingWidth(0.); | |
1201 | ||
1202 | ViewerTest::CurrentView()->Redraw(); | |
1203 | } | |
1204 | } | |
1205 | ||
1206 | if ( report.xmotion.state & ControlMask ) { | |
1207 | if ( report.xmotion.state & Button1Mask ) { | |
1208 | ProcessControlButton1Motion(); | |
1209 | } | |
1210 | else if ( report.xmotion.state & Button2Mask ) { | |
1211 | ProcessControlButton2Motion(); | |
1212 | } | |
1213 | else if ( report.xmotion.state & Button3Mask ) { | |
1214 | ProcessControlButton3Motion(); | |
1215 | } | |
1216 | } | |
1217 | else { | |
1218 | ProcessMotion(); | |
1219 | } | |
1220 | } | |
1221 | } | |
1222 | break; | |
1223 | } | |
1224 | ||
1225 | ||
1226 | return pick; | |
1227 | } | |
1228 | ||
1229 | //============================================================================== | |
1230 | //function : VProcessEvents | |
1231 | //purpose : call by Tk_CreateFileHandler() to be able to manage the | |
1232 | // event in the Viewer window | |
1233 | //============================================================================== | |
1234 | ||
1235 | static void VProcessEvents(ClientData,int) | |
1236 | { | |
1237 | //cout << "VProcessEvents" << endl; | |
1238 | ||
1239 | // test for X Event | |
1240 | while (XPending(display)) { | |
1241 | ViewerMainLoop( 0, NULL); | |
1242 | } | |
1243 | } | |
1244 | #endif | |
1245 | ||
1246 | //============================================================================== | |
1247 | //function : OSWindowSetup | |
1248 | //purpose : Setup for the X11 window to be able to cath the event | |
1249 | //============================================================================== | |
1250 | ||
1251 | ||
1252 | static void OSWindowSetup() | |
1253 | { | |
1254 | #ifndef WNT | |
1255 | // X11 | |
1256 | ||
1257 | Window window = VT_GetWindow()->XWindow(); | |
1258 | ||
1259 | Standard_Address theDisplay = GetG3dDevice()->XDisplay(); | |
1260 | display = (Display * ) theDisplay; | |
1261 | // display = (Display *)GetG3dDevice()->XDisplay(); | |
1262 | ||
1263 | XSynchronize(display, 1); | |
1264 | ||
1265 | VT_GetWindow()->Map(); | |
1266 | ||
1267 | // X11 : For keyboard on SUN | |
1268 | XWMHints wmhints; | |
1269 | wmhints.flags = InputHint; | |
1270 | wmhints.input = 1; | |
1271 | ||
1272 | XSetWMHints( display, window, &wmhints); | |
1273 | ||
1274 | XSelectInput( display, window, ExposureMask | KeyPressMask | | |
1275 | ButtonPressMask | ButtonReleaseMask | | |
1276 | StructureNotifyMask | | |
1277 | PointerMotionMask | | |
1278 | Button1MotionMask | Button2MotionMask | | |
1279 | Button3MotionMask | |
1280 | ); | |
1281 | ||
1282 | XSynchronize(display, 0); | |
1283 | ||
1284 | #else | |
1285 | // WNT | |
1286 | #endif | |
1287 | ||
1288 | } | |
1289 | ||
1290 | ||
1291 | //============================================================================== | |
1292 | //function : VFit | |
1293 | ||
1294 | //purpose : Fitall, no DRAW arguments | |
1295 | //Draw arg : No args | |
1296 | //============================================================================== | |
1297 | ||
1298 | static int VFit(Draw_Interpretor& , Standard_Integer , const char** ) | |
1299 | { | |
1300 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
1301 | Handle(NIS_View) V = Handle(NIS_View)::DownCast(aView); | |
1302 | if (V.IsNull() == Standard_False) { | |
1303 | V->FitAll3d(); | |
1304 | } else if (aView.IsNull() == Standard_False) { | |
1305 | aView->FitAll(); | |
1306 | } | |
1307 | return 0; | |
1308 | } | |
1309 | ||
1310 | //============================================================================== | |
1311 | //function : VZFit | |
1312 | //purpose : ZFitall, no DRAW arguments | |
1313 | //Draw arg : No args | |
1314 | //============================================================================== | |
1315 | ||
1316 | static int VZFit(Draw_Interpretor& , Standard_Integer , const char** ) | |
1317 | { | |
1318 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
1319 | if ( !V.IsNull() ) V->ZFitAll(); return 0; } | |
1320 | ||
1321 | ||
1322 | static int VRepaint(Draw_Interpretor& , Standard_Integer , const char** ) | |
1323 | { | |
1324 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
1325 | if ( !V.IsNull() ) V->Redraw(); return 0; | |
1326 | } | |
1327 | ||
1328 | ||
1329 | //============================================================================== | |
1330 | //function : VClear | |
1331 | //purpose : Remove all the object from the viewer | |
1332 | //Draw arg : No args | |
1333 | //============================================================================== | |
1334 | ||
1335 | static int VClear(Draw_Interpretor& , Standard_Integer , const char** ) | |
1336 | { | |
1337 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
1338 | if(!V.IsNull()) | |
1339 | ViewerTest::Clear(); | |
1340 | return 0; | |
1341 | } | |
1342 | ||
1343 | //============================================================================== | |
1344 | //function : VPick | |
1345 | //purpose : | |
1346 | //============================================================================== | |
1347 | ||
1348 | static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1349 | { if (ViewerTest::CurrentView().IsNull() ) return 1; | |
1350 | ||
1351 | if ( argc < 4 ) { | |
1352 | di << argv[0] << "Invalid number of arguments" << "\n"; | |
1353 | return 1; | |
1354 | } | |
1355 | ||
1356 | while (ViewerMainLoop( argc, argv)) { | |
1357 | } | |
1358 | ||
1359 | return 0; | |
1360 | } | |
1361 | ||
1362 | ||
1363 | ||
1364 | //============================================================================== | |
1365 | //function : InitViewerTest | |
1366 | //purpose : initialisation de toutes les variables static de ViewerTest (dp) | |
1367 | //============================================================================== | |
1368 | ||
1369 | void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)& context) | |
1370 | { | |
1371 | Handle(V3d_Viewer) viewer = context->CurrentViewer(); | |
1372 | ViewerTest::SetAISContext(context); | |
1373 | viewer->InitActiveViews(); | |
1374 | Handle(V3d_View) view = viewer->ActiveView(); | |
1375 | if (viewer->MoreActiveViews()) ViewerTest::CurrentView(view); | |
1376 | ViewerTest::ResetEventManager(); | |
1377 | Handle(Aspect_GraphicDevice) device = viewer->Device(); | |
1378 | Handle(Aspect_Window) window = view->Window(); | |
1379 | #ifndef WNT | |
1380 | // X11 | |
1381 | VT_GetWindow() = Handle(Xw_Window)::DownCast(window); | |
1382 | GetG3dDevice() = Handle(Graphic3d_GraphicDevice)::DownCast(device); | |
1383 | OSWindowSetup(); | |
1384 | static int first = 1; | |
1385 | if ( first ) { | |
1386 | #if TCL_MAJOR_VERSION < 8 | |
1387 | Tk_CreateFileHandler((void*)ConnectionNumber(display), | |
1388 | TK_READABLE, VProcessEvents, (ClientData) 0); | |
1389 | #else | |
1390 | Tk_CreateFileHandler(ConnectionNumber(display), | |
1391 | TK_READABLE, VProcessEvents, (ClientData) 0); | |
1392 | #endif | |
1393 | first = 0; | |
1394 | } | |
1395 | #endif | |
1396 | } | |
1397 | ||
1398 | ||
1399 | //============================================================================== | |
1400 | //function : VSetBg | |
1401 | //purpose : Load image as background | |
1402 | //============================================================================== | |
1403 | ||
1404 | static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1405 | { | |
1406 | if (argc < 2 || argc > 3) | |
1407 | { | |
1408 | di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n"; | |
f8b2ed36 | 1409 | di << "filltype can be one of CENTERED, TILED, STRETCH, NONE" << "\n"; |
7fd59977 | 1410 | return 1; |
1411 | } | |
1412 | ||
1413 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
1414 | if(AISContext.IsNull()) | |
1415 | { | |
1416 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1417 | return 1; | |
1418 | } | |
1419 | ||
1420 | Aspect_FillMethod aFillType = Aspect_FM_CENTERED; | |
1421 | if (argc == 3) | |
1422 | { | |
1423 | const char* szType = argv[2]; | |
1424 | if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; | |
1425 | else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; | |
1426 | else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; | |
1427 | else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; | |
1428 | else | |
1429 | { | |
1430 | di << "Wrong fill type : " << szType << "\n"; | |
1431 | di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; | |
1432 | return 1; | |
1433 | } | |
1434 | } | |
1435 | ||
1436 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1437 | V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True); | |
1438 | ||
1439 | return 0; | |
1440 | } | |
1441 | ||
f8b2ed36 | 1442 | //============================================================================== |
1443 | //function : VSetBgMode | |
1444 | //purpose : Change background image fill type | |
1445 | //============================================================================== | |
1446 | ||
1447 | static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1448 | { | |
1449 | if (argc != 2) | |
1450 | { | |
1451 | di << "Usage : " << argv[0] << " filltype : Change background image mode" << "\n"; | |
1452 | di << "filltype must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; | |
1453 | return 1; | |
1454 | } | |
1455 | ||
1456 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
1457 | if(AISContext.IsNull()) | |
1458 | { | |
1459 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1460 | return 1; | |
1461 | } | |
1462 | ||
1463 | Aspect_FillMethod aFillType; | |
1464 | if (argc == 2) | |
1465 | { | |
1466 | const char* szType = argv[1]; | |
1467 | if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; | |
1468 | else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; | |
1469 | else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; | |
1470 | else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; | |
1471 | else | |
1472 | { | |
1473 | di << "Wrong fill type : " << szType << "\n"; | |
1474 | di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; | |
1475 | return 1; | |
1476 | } | |
1477 | } | |
1478 | ||
1479 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1480 | V3dView->SetBgImageStyle(aFillType, Standard_True); | |
1481 | ||
1482 | return 0; | |
1483 | } | |
1484 | ||
7fd59977 | 1485 | //============================================================================== |
1486 | //function : VSetGradientBg | |
1487 | //purpose : Mount gradient background | |
1488 | //============================================================================== | |
1489 | static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1490 | { | |
1491 | if (argc != 8 ) | |
1492 | { | |
1493 | di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background" << "\n"; | |
1494 | di << "R1,G1,B1,R2,G2,B2 = [0..255]" << "\n"; | |
1495 | di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
1496 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
1497 | return 1; | |
1498 | } | |
1499 | ||
1500 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
1501 | if(AISContext.IsNull()) | |
1502 | { | |
1503 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1504 | return 1; | |
1505 | } | |
1506 | if (argc == 8) | |
1507 | { | |
1508 | ||
1509 | Standard_Real R1 = atof(argv[1])/255.; | |
1510 | Standard_Real G1 = atof(argv[2])/255.; | |
1511 | Standard_Real B1 = atof(argv[3])/255.; | |
1512 | Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB); | |
1513 | ||
1514 | Standard_Real R2 = atof(argv[4])/255.; | |
1515 | Standard_Real G2 = atof(argv[5])/255.; | |
1516 | Standard_Real B2 = atof(argv[6])/255.; | |
1517 | ||
1518 | Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB); | |
1519 | int aType = atoi(argv[7]); | |
1520 | if( aType < 0 || aType > 8 ) | |
1521 | { | |
1522 | di << "Wrong fill type " << "\n"; | |
1523 | di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
1524 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
1525 | return 1; | |
1526 | } | |
1527 | ||
1528 | Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType); | |
1529 | ||
1530 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1531 | V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1); | |
1532 | } | |
1533 | ||
1534 | return 0; | |
1535 | } | |
1536 | ||
f8b2ed36 | 1537 | //============================================================================== |
1538 | //function : VSetGradientBgMode | |
1539 | //purpose : Change gradient background fill style | |
1540 | //============================================================================== | |
1541 | static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1542 | { | |
1543 | if (argc != 2 ) | |
1544 | { | |
1545 | di << "Usage : " << argv[0] << " Type : Change gradient background fill type" << "\n"; | |
1546 | di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
1547 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
1548 | return 1; | |
1549 | } | |
1550 | ||
1551 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
1552 | if(AISContext.IsNull()) | |
1553 | { | |
1554 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1555 | return 1; | |
1556 | } | |
1557 | if (argc == 2) | |
1558 | { | |
1559 | int aType = atoi(argv[1]); | |
1560 | if( aType < 0 || aType > 8 ) | |
1561 | { | |
1562 | di << "Wrong fill type " << "\n"; | |
1563 | di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
1564 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
1565 | return 1; | |
1566 | } | |
1567 | ||
1568 | Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType); | |
1569 | ||
1570 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1571 | V3dView->SetBgGradientStyle( aMethod, 1 ); | |
1572 | } | |
1573 | ||
1574 | return 0; | |
1575 | } | |
1576 | ||
1577 | //============================================================================== | |
1578 | //function : VSetColorBg | |
1579 | //purpose : Set color background | |
1580 | //============================================================================== | |
1581 | static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1582 | { | |
1583 | if (argc != 4 ) | |
1584 | { | |
1585 | di << "Usage : " << argv[0] << " R G B : Set color background" << "\n"; | |
1586 | di << "R,G,B = [0..255]" << "\n"; | |
1587 | return 1; | |
1588 | } | |
1589 | ||
1590 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
1591 | if(AISContext.IsNull()) | |
1592 | { | |
1593 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1594 | return 1; | |
1595 | } | |
1596 | if (argc == 4) | |
1597 | { | |
1598 | ||
1599 | Standard_Real R = atof(argv[1])/255.; | |
1600 | Standard_Real G = atof(argv[2])/255.; | |
1601 | Standard_Real B = atof(argv[3])/255.; | |
1602 | Quantity_Color aColor(R,G,B,Quantity_TOC_RGB); | |
1603 | ||
1604 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1605 | V3dView->SetBackgroundColor( aColor ); | |
1606 | V3dView->Update(); | |
1607 | } | |
1608 | ||
1609 | return 0; | |
1610 | } | |
1611 | ||
7fd59977 | 1612 | //============================================================================== |
1613 | //function : VScale | |
1614 | //purpose : View Scaling | |
1615 | //============================================================================== | |
1616 | ||
1617 | static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1618 | { | |
1619 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1620 | if ( V3dView.IsNull() ) return 1; | |
1621 | ||
1622 | if ( argc != 4 ) { | |
1623 | di << argv[0] << "Invalid number of arguments" << "\n"; | |
1624 | return 1; | |
1625 | } | |
1626 | V3dView->SetAxialScale( atof(argv[1]), atof(argv[2]), atof(argv[3]) ); | |
1627 | return 0; | |
1628 | } | |
1629 | //============================================================================== | |
1630 | //function : VTestZBuffTrihedron | |
7c8a8fcc | 1631 | //purpose : Displays a V3d_ZBUFFER'ed or V3d_WIREFRAME'd trihedron |
7fd59977 | 1632 | //============================================================================== |
1633 | ||
1634 | static int VTestZBuffTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1635 | { | |
1636 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1637 | if ( V3dView.IsNull() ) return 1; | |
1638 | ||
7fd59977 | 1639 | V3dView->ZBufferTriedronSetup(); |
7c8a8fcc | 1640 | |
1641 | if ( argc == 1 ) { | |
1642 | // Set up default trihedron parameters | |
1643 | V3dView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.1, V3d_ZBUFFER ); | |
1644 | } else | |
1645 | if ( argc == 7 ) | |
1646 | { | |
1647 | Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER; | |
1648 | const char* aPosType = argv[1]; | |
1649 | ||
1650 | if ( strcmp(aPosType, "center") == 0 ) | |
1651 | { | |
1652 | aPosition = Aspect_TOTP_CENTER; | |
1653 | } else | |
1654 | if (strcmp(aPosType, "left_lower") == 0) | |
1655 | { | |
1656 | aPosition = Aspect_TOTP_LEFT_LOWER; | |
1657 | } else | |
1658 | if (strcmp(aPosType, "left_upper") == 0) | |
1659 | { | |
1660 | aPosition = Aspect_TOTP_LEFT_UPPER; | |
1661 | } else | |
1662 | if (strcmp(aPosType, "right_lower") == 0) | |
1663 | { | |
1664 | aPosition = Aspect_TOTP_RIGHT_LOWER; | |
1665 | } else | |
1666 | if (strcmp(aPosType, "right_upper") == 0) | |
1667 | { | |
1668 | aPosition = Aspect_TOTP_RIGHT_UPPER; | |
1669 | } else | |
1670 | { | |
1671 | di << argv[1] << " Invalid type of alignment" << "\n"; | |
1672 | di << "Must be one of [ center, left_lower," << "\n"; | |
1673 | di << "left_upper, right_lower, right_upper ]" << "\n"; | |
1674 | return 1; | |
1675 | } | |
1676 | ||
1677 | Standard_Real R = atof(argv[2])/255.; | |
1678 | Standard_Real G = atof(argv[3])/255.; | |
1679 | Standard_Real B = atof(argv[4])/255.; | |
1680 | Quantity_Color aColor(R, G, B, Quantity_TOC_RGB); | |
1681 | ||
1682 | Standard_Real aScale = atof(argv[5]); | |
1683 | ||
1684 | if( aScale <= 0.0 ) | |
1685 | { | |
1686 | di << argv[5] << " Invalid value. Must be > 0" << "\n"; | |
1687 | return 1; | |
1688 | } | |
1689 | ||
1690 | V3d_TypeOfVisualization aPresentation = V3d_ZBUFFER; | |
1691 | const char* aPresType = argv[6]; | |
1692 | ||
1693 | if ( strcmp(aPresType, "wireframe") == 0 ) | |
1694 | { | |
1695 | aPresentation = V3d_WIREFRAME; | |
1696 | } else | |
1697 | if (strcmp(aPresType, "zbuffer") == 0) | |
1698 | { | |
1699 | aPresentation = V3d_ZBUFFER; | |
1700 | } else | |
1701 | { | |
1702 | di << argv[6] << " Invalid type of visualization" << "\n"; | |
1703 | di << "Must be one of [ wireframe, zbuffer ]" << "\n"; | |
1704 | return 1; | |
1705 | } | |
1706 | ||
1707 | V3dView->TriedronDisplay( aPosition, aColor.Name(), aScale, aPresentation ); | |
1708 | ||
1709 | } else | |
1710 | { | |
1711 | di << argv[0] << " Invalid number of arguments" << "\n"; | |
1712 | return 1; | |
1713 | } | |
1714 | ||
7fd59977 | 1715 | V3dView->ZFitAll(); |
7c8a8fcc | 1716 | |
7fd59977 | 1717 | return 0; |
1718 | } | |
1719 | ||
1720 | //============================================================================== | |
1721 | //function : VRotate | |
1722 | //purpose : Camera Rotating | |
1723 | //============================================================================== | |
1724 | ||
1725 | static int VRotate( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
1726 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1727 | if ( V3dView.IsNull() ) { | |
1728 | return 1; | |
1729 | } | |
1730 | ||
1731 | if ( argc == 4 ) { | |
1732 | V3dView->Rotate( atof(argv[1]), atof(argv[2]), atof(argv[3]) ); | |
1733 | return 0; | |
1734 | } else if ( argc == 7 ) { | |
1735 | V3dView->Rotate( atof(argv[1]), atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5]), atof(argv[6]) ); | |
1736 | return 0; | |
1737 | } else { | |
1738 | di << argv[0] << " Invalid number of arguments" << "\n"; | |
1739 | return 1; | |
1740 | } | |
1741 | } | |
1742 | ||
1743 | //============================================================================== | |
1744 | //function : VZoom | |
1745 | //purpose : View zoom in / out (relative to current zoom) | |
1746 | //============================================================================== | |
1747 | ||
1748 | static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
1749 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1750 | if ( V3dView.IsNull() ) { | |
1751 | return 1; | |
1752 | } | |
1753 | ||
1754 | if ( argc == 2 ) { | |
1755 | Standard_Real coef = atof(argv[1]); | |
1756 | if ( coef <= 0.0 ) { | |
1757 | di << argv[1] << "Invalid value" << "\n"; | |
1758 | return 1; | |
1759 | } | |
1760 | V3dView->SetZoom( atof(argv[1]) ); | |
1761 | return 0; | |
1762 | } else { | |
1763 | di << argv[0] << " Invalid number of arguments" << "\n"; | |
1764 | return 1; | |
1765 | } | |
1766 | } | |
1767 | ||
1768 | //============================================================================== | |
1769 | //function : VPan | |
1770 | //purpose : View panning (in pixels) | |
1771 | //============================================================================== | |
1772 | ||
1773 | static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
1774 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
1775 | if ( V3dView.IsNull() ) return 1; | |
1776 | ||
1777 | if ( argc == 3 ) { | |
1778 | V3dView->Pan( atoi(argv[1]), atoi(argv[2]) ); | |
1779 | return 0; | |
1780 | } else { | |
1781 | di << argv[0] << " Invalid number of arguments" << "\n"; | |
1782 | return 1; | |
1783 | } | |
1784 | } | |
1785 | ||
1786 | ||
1787 | //============================================================================== | |
1788 | //function : VExport | |
5cedc27f | 1789 | //purpose : Export the view to a vector graphic format (PS, EMF, PDF) |
7fd59977 | 1790 | //============================================================================== |
1791 | ||
1792 | static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1793 | { | |
1794 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
5cedc27f K |
1795 | if (V3dView.IsNull()) |
1796 | return 1; | |
7fd59977 | 1797 | |
5cedc27f K |
1798 | if (argc == 1) |
1799 | { | |
1800 | std::cout << "Usage: " << argv[0] << " Filename [Format]\n"; | |
7fd59977 | 1801 | return 1; |
1802 | } | |
1803 | ||
5cedc27f K |
1804 | Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF; |
1805 | TCollection_AsciiString aFormatStr; | |
1806 | ||
1807 | TCollection_AsciiString aFileName (argv[1]); | |
1808 | Standard_Integer aLen = aFileName.Length(); | |
1809 | ||
1810 | if (argc > 2) | |
1811 | { | |
1812 | aFormatStr = TCollection_AsciiString (argv[2]); | |
1813 | } | |
1814 | else if (aLen >= 4) | |
1815 | { | |
1816 | if (aFileName.Value (aLen - 2) == '.') | |
1817 | { | |
1818 | aFormatStr = aFileName.SubString (aLen - 1, aLen); | |
1819 | } | |
1820 | else if (aFileName.Value (aLen - 3) == '.') | |
1821 | { | |
1822 | aFormatStr = aFileName.SubString (aLen - 2, aLen); | |
1823 | } | |
1824 | else | |
1825 | { | |
1826 | std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n"; | |
1827 | return 1; | |
1828 | } | |
1829 | } | |
1830 | else | |
1831 | { | |
1832 | std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n"; | |
1833 | return 1; | |
1834 | } | |
1835 | ||
1836 | aFormatStr.UpperCase(); | |
1837 | if (aFormatStr == "PS") | |
1838 | anExpFormat = Graphic3d_EF_PostScript; | |
1839 | else if (aFormatStr == "EPS") | |
1840 | anExpFormat = Graphic3d_EF_EnhPostScript; | |
1841 | else if (aFormatStr == "TEX") | |
1842 | anExpFormat = Graphic3d_EF_TEX; | |
1843 | else if (aFormatStr == "PDF") | |
1844 | anExpFormat = Graphic3d_EF_PDF; | |
1845 | else if (aFormatStr == "SVG") | |
1846 | anExpFormat = Graphic3d_EF_SVG; | |
1847 | else if (aFormatStr == "PGF") | |
1848 | anExpFormat = Graphic3d_EF_PGF; | |
1849 | else if (aFormatStr == "EMF") | |
1850 | anExpFormat = Graphic3d_EF_EMF; | |
1851 | else | |
1852 | { | |
1853 | std::cout << "Invalid export format '" << aFormatStr << "'\n"; | |
1854 | return 1; | |
1855 | } | |
1856 | ||
1857 | if (!V3dView->View()->Export (argv[1], anExpFormat)) | |
1858 | { | |
1859 | std::cout << "Export failed!\n"; | |
1860 | return 1; | |
1861 | } | |
7fd59977 | 1862 | return 0; |
1863 | } | |
1864 | ||
1865 | //============================================================================== | |
1866 | //function : VColorScale | |
1867 | //purpose : representation color scale | |
1868 | //============================================================================== | |
1869 | #include <V3d_ColorScale.hxx> | |
1870 | ||
1871 | static int VColorScale (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1872 | { | |
1873 | if ( argc != 1 && argc != 4 && argc != 5 && argc != 6 && argc != 8 ) | |
1874 | { | |
1875 | di << "Usage : " << argv[0] << " [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = Right X = 0 Y = 0] " << "\n"; | |
1876 | return 1; | |
1877 | } | |
1878 | ||
1879 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
1880 | if(aContext.IsNull()) { | |
1881 | di << argv[0] << " ERROR : use 'vinit' command before " << "\n"; | |
1882 | return -1; | |
1883 | } | |
1884 | ||
1885 | Standard_Real minRange = 0. , maxRange = 100. ; | |
1886 | ||
1887 | Standard_Integer numIntervals = 10 ; | |
1888 | Standard_Real textHeight = 16. ; | |
1889 | Aspect_TypeOfColorScalePosition position = Aspect_TOCSP_RIGHT; | |
1890 | Standard_Real X = 0., Y = 0. ; | |
1891 | ||
1892 | if ( argc < 9 ) | |
1893 | { | |
1894 | if( argc > 3 ) | |
1895 | { | |
1896 | minRange = atof( argv[1] ); | |
1897 | maxRange = atof( argv[2] ); | |
1898 | numIntervals = atoi( argv[3] ); | |
1899 | } | |
1900 | if ( argc > 4 ) | |
1901 | textHeight = atof( argv[4] ); | |
1902 | if ( argc > 5 ) | |
1903 | position = (Aspect_TypeOfColorScalePosition)atoi( argv[5] ); | |
1904 | if ( argc > 7 ) | |
1905 | { | |
1906 | X = atof( argv[6] ); | |
1907 | Y = atof( argv[7] ); | |
1908 | } | |
1909 | } | |
1910 | Handle(V3d_View) curView = ViewerTest::CurrentView( ); | |
1911 | if ( curView.IsNull( ) ) | |
1912 | return 1; | |
1913 | Handle(Aspect_ColorScale) aCSV = curView->ColorScale( ); | |
1914 | Handle(V3d_ColorScale) aCS = ( Handle( V3d_ColorScale )::DownCast( aCSV ) ); | |
1915 | if( ! aCS.IsNull( ) ) | |
1916 | { | |
1917 | aCS->SetPosition( X , Y ); | |
1918 | aCS->SetHeight( 0.95) ; | |
1919 | aCS->SetTextHeight( textHeight ); | |
1920 | aCS->SetRange( minRange , maxRange ); | |
1921 | aCS->SetNumberOfIntervals( numIntervals ); | |
1922 | aCS->SetLabelPosition( position ); | |
1923 | if( !curView->ColorScaleIsDisplayed() ) | |
1924 | curView->ColorScaleDisplay( ); | |
1925 | } | |
1926 | return 0; | |
1927 | } | |
1928 | ||
1929 | //============================================================================== | |
1930 | //function : VGraduatedTrihedron | |
1931 | //purpose : Displays a graduated trihedron | |
1932 | //============================================================================== | |
13a22457 S |
1933 | |
1934 | static void AddMultibyteString (TCollection_ExtendedString &name, const char *arg) | |
1935 | { | |
1936 | const char *str = arg; | |
1937 | while (*str) | |
1938 | { | |
1939 | unsigned short c1 = *str++; | |
1940 | unsigned short c2 = *str++; | |
1941 | if (!c1 || !c2) break; | |
1942 | name += (Standard_ExtCharacter)((c1 << 8) | c2); | |
1943 | } | |
1944 | } | |
1945 | ||
7fd59977 | 1946 | static int VGraduatedTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1947 | { | |
13a22457 S |
1948 | // Check arguments |
1949 | if (argc != 2 && argc < 5) | |
1950 | { | |
1951 | di<<"Error: "<<argv[0]<<" - invalid number of arguments\n"; | |
1952 | di<<"Usage: type help "<<argv[0]<<"\n"; | |
1953 | return 1; //TCL_ERROR | |
1954 | } | |
7fd59977 | 1955 | |
13a22457 S |
1956 | Handle(V3d_View) aV3dView = ViewerTest::CurrentView(); |
1957 | ||
1958 | // Create 3D view if it doesn't exist | |
1959 | if ( aV3dView.IsNull() ) | |
7fd59977 | 1960 | { |
13a22457 S |
1961 | ViewerTest::ViewerInit(); |
1962 | aV3dView = ViewerTest::CurrentView(); | |
1963 | if( aV3dView.IsNull() ) | |
1964 | { | |
1965 | di << "Error: Cannot create a 3D view\n"; | |
1966 | return 1; //TCL_ERROR | |
1967 | } | |
7fd59977 | 1968 | } |
1969 | ||
13a22457 S |
1970 | // Erase (==0) or display (!=0) |
1971 | const int display = atoi(argv[1]); | |
7fd59977 | 1972 | |
13a22457 | 1973 | if (display) |
7fd59977 | 1974 | { |
13a22457 S |
1975 | // Text font |
1976 | TCollection_AsciiString font; | |
1977 | if (argc < 6) | |
1978 | font.AssignCat("Courier"); | |
1979 | else | |
1980 | font.AssignCat(argv[5]); | |
1981 | ||
1982 | // Text is multibyte | |
1983 | const Standard_Boolean isMultibyte = (argc < 7)? Standard_False : (atoi(argv[6]) != 0); | |
1984 | ||
1985 | // Set axis names | |
1986 | TCollection_ExtendedString xname, yname, zname; | |
1987 | if (argc >= 5) | |
1988 | { | |
1989 | if (isMultibyte) | |
7fd59977 | 1990 | { |
13a22457 S |
1991 | AddMultibyteString(xname, argv[2]); |
1992 | AddMultibyteString(yname, argv[3]); | |
1993 | AddMultibyteString(zname, argv[4]); | |
7fd59977 | 1994 | } |
13a22457 S |
1995 | else |
1996 | { | |
1997 | xname += argv[2]; | |
1998 | yname += argv[3]; | |
1999 | zname += argv[4]; | |
2000 | } | |
2001 | } | |
2002 | else | |
2003 | { | |
2004 | xname += "X (mm)"; | |
2005 | yname += "Y (mm)"; | |
2006 | zname += "Z (mm)"; | |
2007 | } | |
7fd59977 | 2008 | |
13a22457 S |
2009 | aV3dView->GraduatedTrihedronDisplay(xname, yname, zname, |
2010 | Standard_True/*xdrawname*/, Standard_True/*ydrawname*/, Standard_True/*zdrawname*/, | |
2011 | Standard_True/*xdrawvalues*/, Standard_True/*ydrawvalues*/, Standard_True/*zdrawvalues*/, | |
2012 | Standard_True/*drawgrid*/, | |
2013 | Standard_True/*drawaxes*/, | |
2014 | 5/*nbx*/, 5/*nby*/, 5/*nbz*/, | |
2015 | 10/*xoffset*/, 10/*yoffset*/, 10/*zoffset*/, | |
2016 | 30/*xaxisoffset*/, 30/*yaxisoffset*/, 30/*zaxisoffset*/, | |
2017 | Standard_True/*xdrawtickmarks*/, Standard_True/*ydrawtickmarks*/, Standard_True/*zdrawtickmarks*/, | |
2018 | 10/*xtickmarklength*/, 10/*ytickmarklength*/, 10/*ztickmarklength*/, | |
2019 | Quantity_NOC_WHITE/*gridcolor*/, | |
2020 | Quantity_NOC_RED/*xnamecolor*/,Quantity_NOC_GREEN/*ynamecolor*/,Quantity_NOC_BLUE1/*znamecolor*/, | |
2021 | Quantity_NOC_RED/*xcolor*/,Quantity_NOC_GREEN/*ycolor*/,Quantity_NOC_BLUE1/*zcolor*/,font); | |
2022 | } | |
7fd59977 | 2023 | else |
13a22457 | 2024 | aV3dView->GraduatedTrihedronErase(); |
7fd59977 | 2025 | |
2026 | ViewerTest::GetAISContext()->UpdateCurrentViewer(); | |
13a22457 S |
2027 | aV3dView->Redraw(); |
2028 | ||
7fd59977 | 2029 | return 0; |
2030 | } | |
2031 | ||
7edf74fd A |
2032 | //============================================================================== |
2033 | //function : VPrintView | |
2034 | //purpose : Test printing algorithm, print the view to image file with given | |
2035 | // width and height. Printing implemented only for WNT. | |
2036 | //============================================================================== | |
2037 | static int VPrintView (Draw_Interpretor& di, Standard_Integer argc, | |
2038 | const char** argv) | |
2039 | { | |
2040 | #ifndef WNT | |
2041 | di << "Printing implemented only for wnt!\n"; | |
2042 | return 1; | |
2043 | #else | |
2044 | ||
2045 | Handle(AIS_InteractiveContext) aContextAIS = NULL; | |
2046 | Handle(V3d_View) aView = NULL; | |
2047 | aContextAIS = ViewerTest::GetAISContext(); | |
2048 | if (!aContextAIS.IsNull()) | |
2049 | { | |
2050 | const Handle(V3d_Viewer)& Vwr = aContextAIS->CurrentViewer(); | |
2051 | Vwr->InitActiveViews(); | |
2052 | if(Vwr->MoreActiveViews()) | |
2053 | aView = Vwr->ActiveView(); | |
2054 | } | |
2055 | ||
2056 | // check for errors | |
2057 | if (aView.IsNull()) | |
2058 | { | |
2059 | di << "Call vinit before!\n"; | |
2060 | return 1; | |
2061 | } | |
2062 | else if (argc < 4) | |
2063 | { | |
2064 | di << "Use: " << argv[0]; | |
2065 | di << " width height filename [print algo=0]\n"; | |
2066 | di << "width, height of the intermediate buffer for operation\n"; | |
2067 | di << "algo : {0|1}\n"; | |
2068 | di << " 0 - stretch algorithm\n"; | |
2069 | di << " 1 - tile algorithm\n"; | |
2070 | di << "test printing algorithms into an intermediate buffer\n"; | |
2071 | di << "with saving output to an image file\n"; | |
2072 | return 1; | |
2073 | } | |
2074 | ||
2075 | // get the input params | |
2076 | Standard_Integer aWidth = atoi (argv[1]); | |
2077 | Standard_Integer aHeight = atoi (argv[2]); | |
2078 | Standard_Integer aMode = 0; | |
2079 | TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]); | |
2080 | if (argc==5) | |
2081 | aMode = atoi (argv[4]); | |
2082 | ||
2083 | // check the input parameters | |
2084 | if (aWidth <= 0 || aHeight <= 0) | |
2085 | { | |
2086 | di << "Width and height must be positive values!\n"; | |
2087 | return 1; | |
2088 | } | |
2089 | if (aMode != 0 && aMode != 1) | |
2090 | aMode = 0; | |
2091 | ||
2092 | Image_CRawBufferData aRawBuffer; | |
2093 | HDC anDC = CreateCompatibleDC(0); | |
2094 | ||
2095 | // define compatible bitmap | |
2096 | BITMAPINFO aBitmapData; | |
2097 | memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER)); | |
2098 | aBitmapData.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); | |
2099 | aBitmapData.bmiHeader.biWidth = aWidth ; | |
2100 | aBitmapData.bmiHeader.biHeight = aHeight; | |
2101 | aBitmapData.bmiHeader.biPlanes = 1; | |
2102 | aBitmapData.bmiHeader.biBitCount = 24; | |
2103 | aBitmapData.bmiHeader.biXPelsPerMeter = 0; | |
2104 | aBitmapData.bmiHeader.biYPelsPerMeter = 0; | |
2105 | aBitmapData.bmiHeader.biClrUsed = 0; | |
2106 | aBitmapData.bmiHeader.biClrImportant = 0; | |
2107 | aBitmapData.bmiHeader.biCompression = BI_RGB; | |
2108 | aBitmapData.bmiHeader.biSizeImage = 0; | |
2109 | ||
2110 | // Create Device Independent Bitmap | |
2111 | HBITMAP aMemoryBitmap = CreateDIBSection (anDC, &aBitmapData, DIB_RGB_COLORS, | |
2112 | &aRawBuffer.dataPtr, NULL, 0); | |
2113 | HGDIOBJ anOldBitmap = SelectObject(anDC, aMemoryBitmap); | |
2114 | ||
2115 | Standard_Boolean isSaved = Standard_False, isPrinted = Standard_False; | |
2116 | if (aRawBuffer.dataPtr != 0) | |
2117 | { | |
2118 | if (aMode == 0) | |
2119 | isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH); | |
2120 | else | |
2121 | isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_TILE); | |
2122 | ||
2123 | // succesfully printed into an intermediate buffer | |
2124 | if (isPrinted) | |
2125 | { | |
2126 | Handle(Image_PixMap) anImageBitmap = | |
2127 | new Image_PixMap ((Standard_PByte)aRawBuffer.dataPtr, | |
2128 | aWidth, aHeight, | |
2129 | aWidth*3 + aWidth%4, 24, 0); | |
2130 | isSaved = anImageBitmap->Dump(aFileName.ToCString()); | |
2131 | } | |
2132 | else | |
2133 | { | |
2134 | di << "Print operation failed due to printing errors or\n"; | |
2135 | di << "insufficient memory available\n"; | |
2136 | di << "Please, try to use smaller dimensions for this test\n"; | |
2137 | di << "command, as it allocates intermediate buffer for storing\n"; | |
2138 | di << "the result\n"; | |
2139 | } | |
2140 | } | |
2141 | else | |
2142 | { | |
2143 | di << "Can't allocate memory for intermediate buffer\n"; | |
2144 | di << "Please use smaller dimensions\n"; | |
2145 | } | |
2146 | ||
2147 | if (aMemoryBitmap) | |
2148 | { | |
2149 | SelectObject (anDC, anOldBitmap); | |
2150 | DeleteObject (aMemoryBitmap); | |
2151 | DeleteDC(anDC); | |
2152 | } | |
2153 | ||
2154 | if (!isSaved) | |
2155 | { | |
2156 | di << "Save to file operation failed. This operation may fail\n"; | |
2157 | di << "if you don't have enough available memory, then you can\n"; | |
2158 | di << "use smaller dimensions for the output file\n"; | |
2159 | return 1; | |
2160 | } | |
2161 | ||
2162 | return 0; | |
2163 | ||
2164 | #endif | |
2165 | } | |
2166 | ||
59f45b7c | 2167 | //============================================================================== |
2168 | //function : VZLayer | |
2169 | //purpose : Test z layer operations for v3d viewer | |
2170 | //============================================================================== | |
2171 | static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2172 | { | |
2173 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext (); | |
2174 | if (aContextAIS.IsNull()) | |
2175 | { | |
2176 | di << "Call vinit before!\n"; | |
2177 | return 1; | |
2178 | } | |
2179 | else if (argc < 2) | |
2180 | { | |
2181 | di << "Use: vzlayer " << argv[0]; | |
2182 | di << " add/del/get [id]\n"; | |
2183 | di << " add - add new z layer to viewer and print its id\n"; | |
2184 | di << " del - del z layer by its id\n"; | |
2185 | di << " get - print sequence of z layers in increasing order of their overlay level\n"; | |
2186 | di << "id - the layer identificator value defined when removing z layer\n"; | |
2187 | return 1; | |
2188 | } | |
2189 | ||
2190 | const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer(); | |
2191 | if (aViewer.IsNull()) | |
2192 | { | |
2193 | di << "No active viewer!\n"; | |
2194 | return 1; | |
2195 | } | |
2196 | ||
2197 | // perform operation | |
2198 | TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]); | |
2199 | if (anOp == "add") | |
2200 | { | |
2201 | Standard_Integer aNewId; | |
2202 | if (!aViewer->AddZLayer (aNewId)) | |
2203 | { | |
2204 | di << "Impossible to add new z layer!\n"; | |
2205 | return 1; | |
2206 | } | |
2207 | ||
2208 | di << "New z layer added with index: " << aNewId << "\n"; | |
2209 | } | |
2210 | else if (anOp == "del") | |
2211 | { | |
2212 | if (argc < 3) | |
2213 | { | |
2214 | di << "Please also provide as argument id of z layer to remove\n"; | |
2215 | return 1; | |
2216 | } | |
2217 | ||
2218 | Standard_Integer aDelId = atoi (argv[2]); | |
2219 | if (!aViewer->RemoveZLayer (aDelId)) | |
2220 | { | |
2221 | di << "Impossible to remove the z layer or invalid id!\n"; | |
2222 | return 1; | |
2223 | } | |
2224 | ||
2225 | di << "Z layer " << aDelId << " has been removed\n"; | |
2226 | } | |
2227 | else if (anOp == "get") | |
2228 | { | |
2229 | TColStd_SequenceOfInteger anIds; | |
2230 | aViewer->GetAllZLayers (anIds); | |
2231 | for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++) | |
2232 | { | |
2233 | di << anIds.Value (aSeqIdx) << " "; | |
2234 | } | |
2235 | ||
2236 | di << "\n"; | |
2237 | } | |
2238 | else | |
2239 | { | |
2240 | di << "Invalid operation, please use { add / del / get }\n"; | |
2241 | return 1; | |
2242 | } | |
2243 | ||
2244 | return 0; | |
2245 | } | |
2246 | ||
25289ec1 | 2247 | DEFINE_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem) |
2248 | ||
2249 | // this class provides a presentation of text item in v3d view under-/overlayer | |
2250 | class V3d_TextItem : public Visual3d_LayerItem | |
2251 | { | |
2252 | public: | |
2253 | ||
2254 | // CASCADE RTTI | |
2255 | DEFINE_STANDARD_RTTI(V3d_TextItem) | |
2256 | ||
2257 | // constructor | |
2258 | Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText, | |
2259 | const Standard_Real theX1, | |
2260 | const Standard_Real theY1, | |
2261 | const Standard_Real theHeight, | |
2262 | const TCollection_AsciiString& theFontName, | |
2263 | const Quantity_Color& theColor, | |
2264 | const Quantity_Color& theSubtitleColor, | |
2265 | const Aspect_TypeOfDisplayText& theTypeOfDisplay, | |
2266 | const Handle(Visual3d_Layer)& theLayer); | |
2267 | ||
2268 | // redraw method | |
2269 | Standard_EXPORT void RedrawLayerPrs(); | |
2270 | ||
2271 | private: | |
2272 | ||
2273 | Standard_Real myX1; | |
2274 | Standard_Real myY1; | |
2275 | Standard_Real myHeight; | |
2276 | TCollection_AsciiString myText; | |
2277 | TCollection_AsciiString myFontName; | |
2278 | Quantity_Color myColor; | |
2279 | Quantity_Color mySubtitleColor; | |
2280 | Aspect_TypeOfDisplayText myType; | |
2281 | Handle(Visual3d_Layer) myLayer; | |
2282 | ||
2283 | }; | |
2284 | ||
2285 | IMPLEMENT_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem) | |
2286 | IMPLEMENT_STANDARD_RTTIEXT(V3d_TextItem, Visual3d_LayerItem) | |
2287 | ||
2288 | // create and add to display the text item | |
2289 | V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText, | |
2290 | const Standard_Real theX1, | |
2291 | const Standard_Real theY1, | |
2292 | const Standard_Real theHeight, | |
2293 | const TCollection_AsciiString& theFontName, | |
2294 | const Quantity_Color& theColor, | |
2295 | const Quantity_Color& theSubtitleColor, | |
2296 | const Aspect_TypeOfDisplayText& theTypeOfDisplay, | |
2297 | const Handle(Visual3d_Layer)& theLayer) | |
2298 | : myX1 (theX1), myY1 (theY1), | |
2299 | myText (theText), | |
2300 | myHeight (theHeight), | |
2301 | myLayer (theLayer), | |
2302 | myColor (theColor), | |
2303 | mySubtitleColor (theSubtitleColor), | |
2304 | myType (theTypeOfDisplay), | |
2305 | myFontName (theFontName) | |
2306 | { | |
2307 | if (!myLayer.IsNull ()) | |
2308 | myLayer->AddLayerItem (this); | |
2309 | } | |
2310 | ||
2311 | // render item | |
2312 | void V3d_TextItem::RedrawLayerPrs () | |
2313 | { | |
2314 | if (myLayer.IsNull ()) | |
2315 | return; | |
2316 | ||
2317 | myLayer->SetColor (myColor); | |
2318 | myLayer->SetTextAttributes (myFontName.ToCString (), myType, mySubtitleColor); | |
2319 | myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight); | |
2320 | } | |
2321 | ||
20637bd2 | 2322 | DEFINE_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem) |
2323 | ||
2324 | // The Visual3d_LayerItem line item for "vlayerline" command | |
2325 | // it provides a presentation of line with user-defined | |
2326 | // linewidth, linetype and transparency. | |
2327 | class V3d_LineItem : public Visual3d_LayerItem | |
2328 | { | |
2329 | public: | |
2330 | // CASCADE RTTI | |
2331 | DEFINE_STANDARD_RTTI(V3d_LineItem) | |
2332 | ||
2333 | // constructor | |
2334 | Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1, | |
2335 | Standard_Real X2, Standard_Real Y2, | |
2336 | V3d_LayerMgrPointer theLayerMgr, | |
2337 | Aspect_TypeOfLine theType = Aspect_TOL_SOLID, | |
2338 | Standard_Real theWidth = 0.5, | |
2339 | Standard_Real theTransp = 1.0); | |
2340 | ||
2341 | // redraw method | |
2342 | Standard_EXPORT void RedrawLayerPrs(); | |
2343 | ||
2344 | private: | |
2345 | ||
2346 | Standard_Real myX1, myY1, myX2, myY2; | |
2347 | Standard_Real myWidth; | |
2348 | Standard_Real myTransparency; | |
2349 | Aspect_TypeOfLine myType; | |
2350 | V3d_LayerMgrPointer myLayerMgr; | |
2351 | }; | |
2352 | ||
2353 | IMPLEMENT_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem) | |
2354 | IMPLEMENT_STANDARD_RTTIEXT(V3d_LineItem, Visual3d_LayerItem) | |
2355 | ||
2356 | // default constructor for line item | |
2357 | V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1, | |
2358 | Standard_Real X2, Standard_Real Y2, | |
2359 | V3d_LayerMgrPointer theLayerMgr, | |
2360 | Aspect_TypeOfLine theType, | |
2361 | Standard_Real theWidth, | |
2362 | Standard_Real theTransp) : | |
2363 | myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), myLayerMgr(theLayerMgr), | |
2364 | myType(theType), myWidth(theWidth), myTransparency(theTransp) | |
2365 | { | |
2366 | if (myLayerMgr && myLayerMgr->Overlay()) | |
2367 | myLayerMgr->Overlay()->AddLayerItem (this); | |
2368 | } | |
2369 | ||
2370 | // render line | |
2371 | void V3d_LineItem::RedrawLayerPrs () | |
2372 | { | |
2373 | Handle (Visual3d_Layer) aOverlay; | |
2374 | ||
2375 | if (myLayerMgr) | |
2376 | aOverlay = myLayerMgr->Overlay(); | |
2377 | ||
2378 | if (!aOverlay.IsNull()) | |
2379 | { | |
2380 | Quantity_Color aColor(1.0, 0, 0, Quantity_TOC_RGB); | |
2381 | aOverlay->SetColor(aColor); | |
2382 | aOverlay->SetTransparency((Standard_ShortReal)myTransparency); | |
2383 | aOverlay->SetLineAttributes((Aspect_TypeOfLine)myType, myWidth); | |
2384 | aOverlay->BeginPolyline(); | |
2385 | aOverlay->AddVertex(myX1, myY1); | |
2386 | aOverlay->AddVertex(myX2, myY2); | |
2387 | aOverlay->ClosePrimitive(); | |
2388 | } | |
2389 | } | |
2390 | ||
2391 | //============================================================================= | |
2392 | //function : VLayerLine | |
2393 | //purpose : Draws line in the v3d view layer with given attributes: linetype, | |
2394 | // : linewidth, transparency coefficient | |
2395 | //============================================================================ | |
2396 | static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2397 | { | |
2398 | // get the active view | |
2399 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2400 | if (aView.IsNull()) | |
2401 | { | |
2402 | di << "Call vinit before!\n"; | |
2403 | return 1; | |
2404 | } | |
2405 | else if (argc < 5) | |
2406 | { | |
2407 | di << "Use: " << argv[0]; | |
2408 | di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n"; | |
2409 | di << " linetype : { 0 | 1 | 2 | 3 } \n"; | |
2410 | di << " 0 - solid \n"; | |
2411 | di << " 1 - dashed \n"; | |
2412 | di << " 2 - dot \n"; | |
2413 | di << " 3 - dashdot\n"; | |
2414 | di << " transparency : { 0.0 - 1.0 } \n"; | |
2415 | di << " 0.0 - transparent\n"; | |
2416 | di << " 1.0 - visible \n"; | |
2417 | return 1; | |
2418 | } | |
2419 | ||
2420 | // get the input params | |
2421 | Standard_Real X1 = atof(argv[1]); | |
2422 | Standard_Real Y1 = atof(argv[2]); | |
2423 | Standard_Real X2 = atof(argv[3]); | |
2424 | Standard_Real Y2 = atof(argv[4]); | |
2425 | ||
2426 | Standard_Real aWidth = 0.5; | |
2427 | Standard_Integer aType = 0; | |
2428 | Standard_Real aTransparency = 1.0; | |
2429 | ||
2430 | // has width | |
2431 | if (argc > 5) | |
2432 | aWidth = atof(argv[5]); | |
2433 | ||
2434 | // has type | |
2435 | if (argc > 6) | |
2436 | aType = (Standard_Integer) atoi(argv[6]); | |
2437 | ||
2438 | // has transparency | |
2439 | if (argc > 7) | |
2440 | { | |
2441 | aTransparency = atof(argv[7]); | |
2442 | if (aTransparency < 0 || aTransparency > 1.0) | |
2443 | aTransparency = 1.0; | |
2444 | } | |
2445 | ||
2446 | // select appropriate line type | |
2447 | Aspect_TypeOfLine aLineType; | |
2448 | switch (aType) | |
2449 | { | |
2450 | case 1: | |
2451 | aLineType = Aspect_TOL_DASH; | |
2452 | break; | |
2453 | ||
2454 | case 2: | |
2455 | aLineType = Aspect_TOL_DOT; | |
2456 | break; | |
2457 | ||
2458 | case 3: | |
2459 | aLineType = Aspect_TOL_DOTDASH; | |
2460 | break; | |
2461 | ||
2462 | default: | |
2463 | aLineType = Aspect_TOL_SOLID; | |
2464 | } | |
2465 | ||
2466 | // replace layer manager | |
2467 | Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr(aView); | |
2468 | aView->SetLayerMgr(aMgr); | |
2469 | ||
2470 | // add line item | |
2471 | Handle (V3d_LineItem) anItem = new V3d_LineItem(X1, Y1, X2, Y2, | |
2472 | aMgr.operator->(), | |
2473 | aLineType, aWidth, | |
2474 | aTransparency); | |
2475 | ||
2476 | // update view | |
2477 | aView->MustBeResized(); | |
2478 | aView->Redraw(); | |
2479 | ||
2480 | return 0; | |
2481 | } | |
2482 | ||
25289ec1 | 2483 | //======================================================================= |
2484 | //function : VOverlayText | |
2485 | //purpose : Test text displaying in view overlay | |
2486 | //======================================================================= | |
2487 | static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char**argv) | |
2488 | { | |
2489 | // get the active view | |
2490 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2491 | if (aView.IsNull()) | |
2492 | { | |
2493 | di << "No active view. Please call vinit.\n"; | |
2494 | return 1; | |
2495 | } | |
2496 | else if (argc < 4 || argc > 13) | |
2497 | { | |
2498 | di << "Use: " << argv[0]; | |
2499 | di << " text x y [height] [font_name] [text_color: R G B] [displayType]\n"; | |
2500 | di << "[background_color: R G B]\n"; | |
2501 | di << " height - pixel height of the text (default=10.0)\n"; | |
2502 | di << " font_name - name of font (default=courier)\n"; | |
2503 | di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n"; | |
2504 | di << " display_type = {normal/subtitle/decal/blend}, (default=normal)\n"; | |
2505 | di << " background_color- R G B values used for subtitle and decal text\n"; | |
2506 | di << "(default=255.0 255.0 255.0)\n"; | |
2507 | return 1; | |
2508 | } | |
2509 | ||
2510 | TCollection_AsciiString aText (argv[1]); | |
2511 | Standard_Real aPosX = atof(argv[2]); | |
2512 | Standard_Real aPosY = atof(argv[3]); | |
2513 | Standard_Real aHeight = (argc >= 5) ? atof (argv[4]) : 10.0; | |
2514 | ||
2515 | // font name | |
2516 | TCollection_AsciiString aFontName = "Courier"; | |
2517 | if (argc >= 6) | |
2518 | aFontName = TCollection_AsciiString (argv[5]); | |
2519 | ||
2520 | // text colors | |
2521 | Quantity_Parameter aColorRed = 1.0; | |
2522 | Quantity_Parameter aColorGreen = 1.0; | |
2523 | Quantity_Parameter aColorBlue = 1.0; | |
2524 | if (argc >= 9) | |
2525 | { | |
2526 | aColorRed = atof (argv[6])/255.; | |
2527 | aColorGreen = atof (argv[7])/255.; | |
2528 | aColorBlue = atof (argv[8])/255.; | |
2529 | } | |
2530 | ||
2531 | // display type | |
2532 | TCollection_AsciiString aDispStr; | |
2533 | if (argc >= 10) | |
2534 | aDispStr = TCollection_AsciiString (argv[9]); | |
2535 | ||
2536 | Aspect_TypeOfDisplayText aTextType = Aspect_TODT_NORMAL; | |
2537 | if (aDispStr.IsEqual ("subtitle")) | |
2538 | aTextType = Aspect_TODT_SUBTITLE; | |
2539 | else if (aDispStr.IsEqual ("decal")) | |
2540 | aTextType = Aspect_TODT_DEKALE; | |
2541 | else if (aDispStr.IsEqual ("blend")) | |
2542 | aTextType = Aspect_TODT_BLEND; | |
2543 | ||
2544 | // subtitle color | |
2545 | Quantity_Parameter aSubRed = 1.0; | |
2546 | Quantity_Parameter aSubGreen = 1.0; | |
2547 | Quantity_Parameter aSubBlue = 1.0; | |
2548 | if (argc == 13) | |
2549 | { | |
2550 | aSubRed = atof (argv[10])/255.; | |
2551 | aSubGreen = atof (argv[11])/255.; | |
2552 | aSubBlue = atof (argv[12])/255.; | |
2553 | } | |
2554 | ||
2555 | // check fo current overlay | |
2556 | Handle(Visual3d_Layer) anOverlay = aView->Viewer()->Viewer()->OverLayer (); | |
2557 | if (anOverlay.IsNull ()) | |
2558 | { | |
2559 | Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (aView); | |
2560 | anOverlay = aMgr->Overlay (); | |
2561 | aView->SetLayerMgr (aMgr); | |
2562 | } | |
2563 | ||
2564 | Quantity_Color aTextColor (aColorRed, aColorGreen, | |
2565 | aColorBlue, Quantity_TOC_RGB); | |
2566 | Quantity_Color aSubtColor (aSubRed, aSubGreen, | |
2567 | aSubBlue, Quantity_TOC_RGB); | |
2568 | ||
2569 | // add text item | |
2570 | Handle(V3d_TextItem) anItem = new V3d_TextItem (aText, aPosX, aPosY, | |
2571 | aHeight, aFontName, aTextColor, aSubtColor, aTextType, anOverlay); | |
2572 | ||
2573 | // update view | |
2574 | aView->MustBeResized(); | |
2575 | aView->Redraw(); | |
2576 | ||
2577 | return 0; | |
2578 | } | |
2579 | ||
2bd4c032 | 2580 | //============================================================================== |
2581 | //function : VGrid | |
2582 | //purpose : | |
2583 | //============================================================================== | |
2584 | ||
2585 | static int VGrid (Draw_Interpretor& theDI, | |
2586 | Standard_Integer theArgNb, | |
2587 | const char** theArgVec) | |
2588 | { | |
2589 | // get the active view | |
2590 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2591 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
2592 | if (aView.IsNull() || aViewer.IsNull()) | |
2593 | { | |
2594 | std::cerr << "No active view. Please call vinit.\n"; | |
2595 | return 1; | |
2596 | } | |
2597 | ||
2598 | Aspect_GridType aType = aViewer->GridType(); | |
2599 | Aspect_GridDrawMode aMode = aViewer->GridDrawMode(); | |
2600 | ||
2601 | Standard_Integer anIter = 1; | |
2602 | for (; anIter < theArgNb; ++anIter) | |
2603 | { | |
2604 | const char* aValue = theArgVec[anIter]; | |
2605 | if (*aValue == 'r') | |
2606 | { | |
2607 | aType = Aspect_GT_Rectangular; | |
2608 | } | |
2609 | else if (*aValue == 'c') | |
2610 | { | |
2611 | aType = Aspect_GT_Circular; | |
2612 | } | |
2613 | else if (*aValue == 'l') | |
2614 | { | |
2615 | aMode = Aspect_GDM_Lines; | |
2616 | } | |
2617 | else if (*aValue == 'p') | |
2618 | { | |
2619 | aMode = Aspect_GDM_Points; | |
2620 | } | |
2621 | else if (strcmp (aValue, "off" ) == 0) | |
2622 | { | |
2623 | aViewer->DeactivateGrid(); | |
2624 | return 0; | |
2625 | } | |
2626 | else | |
2627 | { | |
2628 | break; | |
2629 | } | |
2630 | } | |
2631 | ||
2632 | Standard_Integer aTail = (theArgNb - anIter); | |
2633 | if (aTail == 0) | |
2634 | { | |
2635 | aViewer->ActivateGrid (aType, aMode); | |
2636 | return 0; | |
2637 | } | |
2638 | else if (aTail != 2 && aTail != 5) | |
2639 | { | |
2640 | std::cerr << "Incorrect arguments number! Usage:\n" | |
2641 | << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n"; | |
2642 | return 1; | |
2643 | } | |
2644 | ||
2645 | Quantity_Length anOriginX, anOriginY; | |
2646 | Quantity_PlaneAngle aRotAngle; | |
2647 | if (aType == Aspect_GT_Rectangular) | |
2648 | { | |
2649 | Quantity_Length aRStepX, aRStepY; | |
2650 | aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle); | |
2651 | ||
2652 | anOriginX = atof (theArgVec[anIter++]); | |
2653 | anOriginY = atof (theArgVec[anIter++]); | |
2654 | if (aTail == 5) | |
2655 | { | |
2656 | aRStepX = atof (theArgVec[anIter++]); | |
2657 | aRStepY = atof (theArgVec[anIter++]); | |
2658 | aRotAngle = atof (theArgVec[anIter++]); | |
2659 | } | |
2660 | aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle); | |
2661 | aViewer->ActivateGrid (aType, aMode); | |
2662 | } | |
2663 | else if (aType == Aspect_GT_Circular) | |
2664 | { | |
2665 | Quantity_Length aRadiusStep; | |
2666 | Standard_Integer aDivisionNumber; | |
2667 | aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle); | |
2668 | ||
2669 | anOriginX = atof (theArgVec[anIter++]); | |
2670 | anOriginY = atof (theArgVec[anIter++]); | |
2671 | if (aTail == 5) | |
2672 | { | |
2673 | aRadiusStep = atof (theArgVec[anIter++]); | |
2674 | aDivisionNumber = atof (theArgVec[anIter++]); | |
2675 | aRotAngle = atof (theArgVec[anIter++]); | |
2676 | } | |
2677 | ||
2678 | aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle); | |
2679 | aViewer->ActivateGrid (aType, aMode); | |
2680 | } | |
2681 | ||
2682 | return 0; | |
2683 | } | |
2684 | ||
7fd59977 | 2685 | //======================================================================= |
2686 | //function : ViewerCommands | |
2687 | //purpose : | |
2688 | //======================================================================= | |
2689 | ||
2690 | void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) | |
2691 | { | |
2692 | ||
2693 | const char *group = "ZeViewer"; | |
2694 | theCommands.Add("vinit" , | |
2695 | "vinit : vinit [leftPx topPx widthPx heightPx] : Create the Viewer window", | |
2696 | __FILE__,VInit,group); | |
2697 | theCommands.Add("vhelp" , | |
2698 | "vhelp : display help on the viewer commands", | |
2699 | __FILE__,VHelp,group); | |
2700 | theCommands.Add("vtop" , | |
2701 | "vtop or <T> : Top view" , | |
2702 | __FILE__,VTop,group); | |
2703 | theCommands.Add("vaxo" , | |
2704 | " vaxo or <A> : Axonometric view ", | |
2705 | __FILE__,VAxo,group); | |
2706 | theCommands.Add("vpick" , | |
2707 | "vpick : vpick X Y Z [shape subshape] ( all variables as string )", | |
2708 | VPick,group); | |
2709 | theCommands.Add("vfit" , | |
2710 | "vfit or <F> : vfit", | |
2711 | __FILE__,VFit,group); | |
2712 | theCommands.Add("vzfit" , | |
2713 | "vzfit", | |
2714 | __FILE__,VZFit,group); | |
2715 | theCommands.Add("vrepaint", | |
2716 | "vrepaint : vrepaint, force redraw", | |
2717 | __FILE__,VRepaint,group); | |
2718 | theCommands.Add("vclear", | |
2719 | "vclear : vclear", | |
2720 | __FILE__,VClear,group); | |
2721 | theCommands.Add("vsetbg", | |
2722 | "vsetbg : vsetbg imagefile [filltype] : Load image as background", | |
2723 | __FILE__,VSetBg,group); | |
f8b2ed36 | 2724 | theCommands.Add("vsetbgmode", |
2725 | "vsetbgmode : vsetbgmode filltype : Change background image fill type", | |
2726 | __FILE__,VSetBgMode,group); | |
7fd59977 | 2727 | theCommands.Add("vsetgradientbg", |
f8b2ed36 | 2728 | "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background", |
7fd59977 | 2729 | __FILE__,VSetGradientBg,group); |
f8b2ed36 | 2730 | theCommands.Add("vsetgrbgmode", |
2731 | "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type", | |
2732 | __FILE__,VSetGradientBgMode,group); | |
2733 | theCommands.Add("vsetcolorbg", | |
2734 | "vsetcolorbg : vsetcolorbg r g b : Set background color", | |
2735 | __FILE__,VSetColorBg,group); | |
7fd59977 | 2736 | theCommands.Add("vscale", |
2737 | "vscale : vscale X Y Z", | |
2738 | __FILE__,VScale,group); | |
2739 | theCommands.Add("vzbufftrihedron", | |
7c8a8fcc | 2740 | "vzbufftrihedron [center|left_lower|left_upper|right_lower|right_upper" |
2741 | " textR=255 textG=255 textB=255 scale=0.1 wireframe|zbuffer]" | |
2742 | " : Displays a V3d_ZBUFFER'ed or V3d_WIREFRAME'd trihedron", | |
7fd59977 | 2743 | __FILE__,VTestZBuffTrihedron,group); |
2744 | theCommands.Add("vrotate", | |
2745 | "vrotate : vrotate AX AY AZ [X Y Z]", | |
2746 | __FILE__,VRotate,group); | |
2747 | theCommands.Add("vzoom", | |
2748 | "vzoom : vzoom coef", | |
2749 | __FILE__,VZoom,group); | |
2750 | theCommands.Add("vpan", | |
2751 | "vpan : vpan dx dy", | |
2752 | __FILE__,VPan,group); | |
2753 | theCommands.Add("vexport", | |
5cedc27f K |
2754 | "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }" |
2755 | " : exports the view to a vector file of a given format" | |
2756 | " : notice that EMF format requires patched gl2ps", | |
7fd59977 | 2757 | __FILE__,VExport,group); |
2758 | theCommands.Add("vcolorscale", | |
2759 | "vcolorscale : vcolorscale [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = 2 X = 0 Y = 0]: draw color scale", | |
2760 | __FILE__,VColorScale,group); | |
2761 | theCommands.Add("vgraduatedtrihedron", | |
13a22457 | 2762 | "vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname [Font [isMultibyte]]]", |
7fd59977 | 2763 | __FILE__,VGraduatedTrihedron,group); |
7edf74fd A |
2764 | theCommands.Add("vprintview" , |
2765 | "vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile", | |
2766 | __FILE__,VPrintView,group); | |
59f45b7c | 2767 | theCommands.Add("vzlayer", |
2768 | "vzlayer : add/del/get [id] : Z layer operations in v3d viewer: add new z layer, delete z layer, get z layer ids", | |
2769 | __FILE__,VZLayer,group); | |
25289ec1 | 2770 | theCommands.Add("voverlaytext", |
2771 | "voverlaytext : text x y [height] [font_name] [text_color: R G B] [display_type] [background_color: R G B]" | |
2772 | " : height - pixel height of the text (default=10.0)" | |
2773 | " : font_name - name of font (default=courier)" | |
2774 | " : text_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0) " | |
2775 | " : display_type = {normal/subtitle/decal/blend}, (default=normal) " | |
2776 | " : background_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0), the parameter is defined for subtitle and decal display types ", | |
2777 | __FILE__,VOverlayText,group); | |
20637bd2 | 2778 | theCommands.Add("vlayerline", |
2779 | "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]", | |
2780 | __FILE__,VLayerLine,group); | |
2bd4c032 | 2781 | theCommands.Add ("vgrid", |
2782 | "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]" | |
2783 | " : Mode - rectangular or circular" | |
2784 | " : Type - lines or points", | |
2785 | __FILE__, VGrid, group); | |
7fd59977 | 2786 | } |