Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1998-09-01 |
2 | // Created by: Robert COUBLANC | |
3 | // Copyright (c) 1998-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
b311480e | 16 | |
58655684 | 17 | #include <OpenGl_GlCore20.hxx> |
0a768f56 | 18 | #include <AIS_Shape.hxx> |
0a768f56 | 19 | #include <AIS_InteractiveObject.hxx> |
20 | #include <AIS_ListOfInteractive.hxx> | |
21 | #include <AIS_ListIteratorOfListOfInteractive.hxx> | |
22 | #include <DBRep.hxx> | |
2bd4c032 | 23 | #include <Graphic3d_AspectMarker3d.hxx> |
7fd59977 | 24 | #include <Graphic3d_ExportFormat.hxx> |
269294d6 | 25 | #include <Graphic3d_NameOfTextureEnv.hxx> |
a79f67f8 | 26 | #include <Graphic3d_GraduatedTrihedron.hxx> |
269294d6 | 27 | #include <Graphic3d_TextureEnv.hxx> |
28 | #include <Graphic3d_TextureParams.hxx> | |
29 | #include <Graphic3d_TypeOfTextureFilter.hxx> | |
4269bd1b | 30 | #include <Graphic3d_AspectFillArea3d.hxx> |
7fd59977 | 31 | #include <ViewerTest.hxx> |
8625ef7e | 32 | #include <ViewerTest_AutoUpdater.hxx> |
7fd59977 | 33 | #include <ViewerTest_EventManager.hxx> |
4754e164 | 34 | #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx> |
4269bd1b | 35 | #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx> |
7fd59977 | 36 | #include <Visual3d_View.hxx> |
25289ec1 | 37 | #include <Visual3d_ViewManager.hxx> |
12381341 | 38 | #include <V3d_AmbientLight.hxx> |
71215351 | 39 | #include <V3d_ColorScale.hxx> |
12381341 | 40 | #include <V3d_DirectionalLight.hxx> |
25289ec1 | 41 | #include <V3d_LayerMgr.hxx> |
12381341 | 42 | #include <V3d_LayerMgrPointer.hxx> |
43 | #include <V3d_PositionalLight.hxx> | |
44 | #include <V3d_SpotLight.hxx> | |
18d715bd | 45 | #include <NCollection_DoubleMap.hxx> |
46 | #include <NCollection_List.hxx> | |
47 | #include <NCollection_Vector.hxx> | |
7fd59977 | 48 | #include <AIS_InteractiveContext.hxx> |
49 | #include <Draw_Interpretor.hxx> | |
50 | #include <Draw.hxx> | |
51 | #include <Draw_Appli.hxx> | |
7edf74fd | 52 | #include <Aspect_PrintAlgo.hxx> |
692613e5 | 53 | #include <Image_AlienPixMap.hxx> |
58655684 | 54 | #include <OpenGl_GraphicDriver.hxx> |
208e6839 | 55 | #include <OSD_Timer.hxx> |
900f7229 | 56 | #include <TColStd_HSequenceOfAsciiString.hxx> |
59f45b7c | 57 | #include <TColStd_SequenceOfInteger.hxx> |
4754e164 | 58 | #include <TColStd_HSequenceOfReal.hxx> |
59 | #include <TColgp_Array1OfPnt2d.hxx> | |
197ac94e | 60 | #include <TColStd_MapOfAsciiString.hxx> |
20637bd2 | 61 | #include <Visual3d_LayerItem.hxx> |
20637bd2 | 62 | #include <Aspect_TypeOfLine.hxx> |
692613e5 | 63 | #include <Image_Diff.hxx> |
dc3fe572 | 64 | #include <Aspect_DisplayConnection.hxx> |
4269bd1b | 65 | #include <gp_Pnt.hxx> |
66 | #include <gp_Dir.hxx> | |
67 | #include <gp_Pln.hxx> | |
68 | #include <PrsMgr_PresentableObject.hxx> | |
69 | #include <Graphic3d_ClipPlane.hxx> | |
70 | #include <NCollection_DataMap.hxx> | |
71 | #include <Graphic3d_Texture2Dmanual.hxx> | |
72 | #include <Prs3d_ShadingAspect.hxx> | |
6262338c | 73 | #include <Prs3d_Drawer.hxx> |
7fd59977 | 74 | |
25289ec1 | 75 | #ifdef WNT |
76 | #undef DrawText | |
77 | #endif | |
78 | ||
79 | #include <Visual3d_Layer.hxx> | |
692613e5 | 80 | #include <cstdlib> |
25289ec1 | 81 | |
58655684 | 82 | #if defined(_WIN32) |
4fe56619 | 83 | #include <WNT_WClass.hxx> |
84 | #include <WNT_Window.hxx> | |
85 | ||
86 | #if defined(_MSC_VER) | |
87 | #define _CRT_SECURE_NO_DEPRECATE | |
88 | #pragma warning (disable:4996) | |
89 | #endif | |
90 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
4fe56619 | 91 | #include <Cocoa_Window.hxx> |
7fd59977 | 92 | #else |
4fe56619 | 93 | #include <Xw_Window.hxx> |
94 | #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */ | |
95 | #include <X11/Xutil.h> | |
96 | #include <tk.h> | |
7fd59977 | 97 | #endif |
98 | ||
8625ef7e | 99 | inline Standard_Boolean parseOnOff (Standard_CString theArg, |
100 | Standard_Boolean& theIsOn) | |
101 | { | |
102 | TCollection_AsciiString aFlag (theArg); | |
103 | aFlag.LowerCase(); | |
104 | if (aFlag == "on" | |
105 | || aFlag == "1") | |
106 | { | |
107 | theIsOn = Standard_True; | |
108 | return Standard_True; | |
109 | } | |
110 | else if (aFlag == "off" | |
111 | || aFlag == "0") | |
112 | { | |
113 | theIsOn = Standard_False; | |
114 | return Standard_True; | |
115 | } | |
116 | return Standard_False; | |
117 | } | |
118 | ||
b514beda | 119 | // Auxiliary definitions |
120 | static const char THE_KEY_DELETE = 127; | |
7fd59977 | 121 | |
122 | //============================================================================== | |
123 | // VIEWER GLOBAL VARIABLES | |
124 | //============================================================================== | |
125 | ||
126 | Standard_IMPORT Standard_Boolean Draw_VirtualWindows; | |
b514beda | 127 | Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand); |
7fd59977 | 128 | |
129 | Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv); | |
4754e164 | 130 | extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); |
7fd59977 | 131 | |
b514beda | 132 | extern int VErase (Draw_Interpretor& theDI, |
133 | Standard_Integer theArgNb, | |
134 | const char** theArgVec); | |
135 | ||
58655684 | 136 | #if defined(_WIN32) |
7fd59977 | 137 | static Handle(WNT_Window)& VT_GetWindow() { |
138 | static Handle(WNT_Window) WNTWin; | |
139 | return WNTWin; | |
140 | } | |
4fe56619 | 141 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) |
4fe56619 | 142 | static Handle(Cocoa_Window)& VT_GetWindow() |
143 | { | |
144 | static Handle(Cocoa_Window) aWindow; | |
145 | return aWindow; | |
146 | } | |
147 | extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow); | |
18d715bd | 148 | extern void SetCocoaWindowTitle (const Handle(Cocoa_Window)& theWindow, Standard_CString theTitle); |
149 | extern void GetCocoaScreenResolution (Standard_Integer& theWidth, Standard_Integer& theHeight); | |
150 | ||
7fd59977 | 151 | #else |
7fd59977 | 152 | static Handle(Xw_Window)& VT_GetWindow(){ |
153 | static Handle(Xw_Window) XWWin; | |
154 | return XWWin; | |
155 | } | |
7fd59977 | 156 | |
157 | static void VProcessEvents(ClientData,int); | |
158 | #endif | |
159 | ||
18d715bd | 160 | static Handle(Aspect_DisplayConnection)& GetDisplayConnection() |
161 | { | |
162 | static Handle(Aspect_DisplayConnection) aDisplayConnection; | |
163 | return aDisplayConnection; | |
164 | } | |
165 | ||
166 | static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDisplayConnection) | |
167 | { | |
168 | GetDisplayConnection() = theDisplayConnection; | |
169 | } | |
170 | ||
58655684 | 171 | #if defined(_WIN32) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) |
18d715bd | 172 | Aspect_Handle GetWindowHandle(const Handle(Aspect_Window)& theWindow) |
dc3fe572 | 173 | { |
0ebaa4db | 174 | Aspect_Handle aWindowHandle = (Aspect_Handle)NULL; |
58655684 | 175 | #if defined(_WIN32) |
18d715bd | 176 | const Handle (WNT_Window) aWindow = Handle(WNT_Window)::DownCast (theWindow); |
177 | if (!aWindow.IsNull()) | |
178 | return aWindow->HWindow(); | |
179 | #elif (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
180 | const Handle (Xw_Window) aWindow = Handle(Xw_Window)::DownCast (theWindow); | |
181 | if (!aWindow.IsNull()) | |
182 | return aWindow->XWindow(); | |
183 | #endif | |
184 | return aWindowHandle; | |
dc3fe572 | 185 | } |
18d715bd | 186 | #endif |
dc3fe572 | 187 | |
de75ed09 | 188 | static Standard_Boolean MyHLRIsOn = Standard_False; |
7fd59977 | 189 | |
18d715bd | 190 | NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews; |
58655684 | 191 | static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts; |
18d715bd | 192 | static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers; |
58655684 | 193 | static OpenGl_Caps ViewerTest_myDefaultCaps; |
18d715bd | 194 | |
7fd59977 | 195 | #define ZCLIPWIDTH 1. |
196 | ||
197 | static void OSWindowSetup(); | |
198 | ||
199 | //============================================================================== | |
200 | // EVENT GLOBAL VARIABLES | |
201 | //============================================================================== | |
202 | ||
203 | static int Start_Rot = 0; | |
204 | static int ZClipIsOn = 0; | |
4fe56619 | 205 | int X_Motion = 0; // Current cursor position |
206 | int Y_Motion = 0; | |
207 | int X_ButtonPress = 0; // Last ButtonPress position | |
208 | int Y_ButtonPress = 0; | |
209 | Standard_Boolean IsDragged = Standard_False; | |
8abada55 | 210 | Standard_Boolean DragFirst = Standard_False; |
7fd59977 | 211 | |
212 | //============================================================================== | |
213 | ||
214 | #ifdef WNT | |
215 | static LRESULT WINAPI ViewerWindowProc( | |
216 | HWND hwnd, | |
217 | UINT uMsg, | |
218 | WPARAM wParam, | |
219 | LPARAM lParam ); | |
220 | static LRESULT WINAPI AdvViewerWindowProc( | |
221 | HWND hwnd, | |
222 | UINT uMsg, | |
223 | WPARAM wParam, | |
224 | LPARAM lParam ); | |
225 | #endif | |
226 | ||
227 | ||
228 | //============================================================================== | |
229 | //function : WClass | |
230 | //purpose : | |
231 | //============================================================================== | |
232 | ||
233 | const Handle(MMgt_TShared)& ViewerTest::WClass() | |
234 | { | |
235 | static Handle(MMgt_TShared) theWClass; | |
58655684 | 236 | #if defined(_WIN32) |
4fe56619 | 237 | if (theWClass.IsNull()) |
238 | { | |
7fd59977 | 239 | theWClass = new WNT_WClass ("GW3D_Class", AdvViewerWindowProc, |
240 | CS_VREDRAW | CS_HREDRAW, 0, 0, | |
241 | ::LoadCursor (NULL, IDC_ARROW)); | |
242 | } | |
243 | #endif | |
244 | return theWClass; | |
245 | } | |
246 | ||
18d715bd | 247 | //============================================================================== |
248 | //function : CreateName | |
249 | //purpose : Create numerical name for new object in theMap | |
250 | //============================================================================== | |
251 | template <typename ObjectType> | |
252 | TCollection_AsciiString CreateName (const NCollection_DoubleMap <TCollection_AsciiString, ObjectType>& theObjectMap, | |
253 | const TCollection_AsciiString& theDefaultString) | |
254 | { | |
255 | if (theObjectMap.IsEmpty()) | |
256 | return theDefaultString + TCollection_AsciiString(1); | |
257 | ||
258 | Standard_Integer aNextKey = 1; | |
259 | Standard_Boolean isFound = Standard_False; | |
260 | while (!isFound) | |
261 | { | |
262 | TCollection_AsciiString aStringKey = theDefaultString + TCollection_AsciiString(aNextKey); | |
263 | // Look for objects with default names | |
264 | if (theObjectMap.IsBound1(aStringKey)) | |
265 | { | |
266 | aNextKey++; | |
267 | } | |
268 | else | |
269 | isFound = Standard_True; | |
270 | } | |
271 | ||
272 | return theDefaultString + TCollection_AsciiString(aNextKey); | |
273 | } | |
274 | ||
275 | //============================================================================== | |
276 | //structure : ViewerTest_Names | |
277 | //purpose : Allow to operate with full view name: driverName/viewerName/viewName | |
278 | //============================================================================== | |
279 | struct ViewerTest_Names | |
280 | { | |
281 | private: | |
282 | TCollection_AsciiString myDriverName; | |
283 | TCollection_AsciiString myViewerName; | |
284 | TCollection_AsciiString myViewName; | |
285 | ||
286 | public: | |
287 | ||
288 | const TCollection_AsciiString& GetDriverName () const | |
289 | { | |
290 | return myDriverName; | |
291 | } | |
292 | void SetDriverName (const TCollection_AsciiString& theDriverName) | |
293 | { | |
294 | myDriverName = theDriverName; | |
295 | } | |
296 | const TCollection_AsciiString& GetViewerName () const | |
297 | { | |
298 | return myViewerName; | |
299 | } | |
300 | void SetViewerName (const TCollection_AsciiString& theViewerName) | |
301 | { | |
302 | myViewerName = theViewerName; | |
303 | } | |
304 | const TCollection_AsciiString& GetViewName () const | |
305 | { | |
306 | return myViewName; | |
307 | } | |
308 | void SetViewName (const TCollection_AsciiString& theViewName) | |
309 | { | |
310 | myViewName = theViewName; | |
311 | } | |
312 | ||
313 | //=========================================================================== | |
314 | //function : Constructor for ViewerTest_Names | |
315 | //purpose : Get view, viewer, driver names from custom string | |
316 | //=========================================================================== | |
317 | ||
318 | ViewerTest_Names (const TCollection_AsciiString& theInputString) | |
319 | { | |
320 | TCollection_AsciiString aName(theInputString); | |
321 | if (theInputString.IsEmpty()) | |
322 | { | |
323 | // Get current configuration | |
324 | if (ViewerTest_myDrivers.IsEmpty()) | |
325 | myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)> | |
326 | (ViewerTest_myDrivers, TCollection_AsciiString("Driver")); | |
327 | else | |
328 | myDriverName = ViewerTest_myDrivers.Find2 | |
329 | (ViewerTest::GetAISContext()->CurrentViewer()->Driver()); | |
330 | ||
331 | if(ViewerTest_myContexts.IsEmpty()) | |
332 | { | |
333 | myViewerName = CreateName <Handle(AIS_InteractiveContext)> | |
334 | (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer")); | |
335 | } | |
336 | else | |
337 | myViewerName = ViewerTest_myContexts.Find2 (ViewerTest::GetAISContext()); | |
338 | ||
339 | myViewName = CreateName <Handle(V3d_View)> | |
340 | (ViewerTest_myViews, TCollection_AsciiString(myViewerName + "/View")); | |
341 | } | |
342 | else | |
343 | { | |
344 | // There is at least view name | |
345 | Standard_Integer aParserNumber = 0; | |
346 | for (Standard_Integer i = 0; i < 3; ++i) | |
347 | { | |
348 | Standard_Integer aParserPos = aName.SearchFromEnd("/"); | |
349 | if(aParserPos != -1) | |
350 | { | |
351 | aParserNumber++; | |
352 | aName.Split(aParserPos-1); | |
353 | } | |
354 | else | |
355 | break; | |
356 | } | |
357 | if (aParserNumber == 0) | |
358 | { | |
359 | // Only view name | |
360 | if (!ViewerTest::GetAISContext().IsNull()) | |
361 | { | |
362 | myDriverName = ViewerTest_myDrivers.Find2 | |
363 | (ViewerTest::GetAISContext()->CurrentViewer()->Driver()); | |
364 | myViewerName = ViewerTest_myContexts.Find2 | |
365 | (ViewerTest::GetAISContext()); | |
366 | } | |
367 | else | |
368 | { | |
369 | // There is no opened contexts here, need to create names for viewer and driver | |
370 | myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)> | |
371 | (ViewerTest_myDrivers, TCollection_AsciiString("Driver")); | |
372 | ||
373 | myViewerName = CreateName <Handle(AIS_InteractiveContext)> | |
374 | (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer")); | |
375 | } | |
376 | myViewName = TCollection_AsciiString(myViewerName + "/" + theInputString); | |
377 | } | |
378 | else if (aParserNumber == 1) | |
379 | { | |
380 | // Here is viewerName/viewName | |
381 | if (!ViewerTest::GetAISContext().IsNull()) | |
382 | myDriverName = ViewerTest_myDrivers.Find2 | |
383 | (ViewerTest::GetAISContext()->CurrentViewer()->Driver()); | |
384 | else | |
385 | { | |
386 | // There is no opened contexts here, need to create name for driver | |
387 | myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)> | |
388 | (ViewerTest_myDrivers, TCollection_AsciiString("Driver")); | |
389 | } | |
390 | myViewerName = TCollection_AsciiString(myDriverName + "/" + aName); | |
391 | ||
392 | myViewName = TCollection_AsciiString(myDriverName + "/" + theInputString); | |
393 | } | |
394 | else | |
395 | { | |
396 | //Here is driverName/viewerName/viewName | |
397 | myDriverName = TCollection_AsciiString(aName); | |
398 | ||
399 | TCollection_AsciiString aViewerName(theInputString); | |
400 | aViewerName.Split(aViewerName.SearchFromEnd("/") - 1); | |
401 | myViewerName = TCollection_AsciiString(aViewerName); | |
402 | ||
403 | myViewName = TCollection_AsciiString(theInputString); | |
404 | } | |
405 | } | |
406 | } | |
407 | }; | |
408 | ||
409 | //============================================================================== | |
410 | //function : FindContextByView | |
411 | //purpose : Find AIS_InteractiveContext by View | |
412 | //============================================================================== | |
413 | ||
414 | Handle(AIS_InteractiveContext) FindContextByView (const Handle(V3d_View)& theView) | |
415 | { | |
416 | Handle(AIS_InteractiveContext) anAISContext; | |
417 | ||
418 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
419 | anIter (ViewerTest_myContexts); anIter.More(); anIter.Next()) | |
420 | { | |
421 | if (anIter.Value()->CurrentViewer() == theView->Viewer()) | |
422 | return anIter.Key2(); | |
423 | } | |
424 | return anAISContext; | |
425 | } | |
426 | ||
427 | ||
428 | //============================================================================== | |
429 | //function : SetWindowTitle | |
430 | //purpose : Set window title | |
431 | //============================================================================== | |
432 | ||
433 | void SetWindowTitle (const Handle(Aspect_Window)& theWindow, | |
434 | Standard_CString theTitle) | |
435 | { | |
58655684 | 436 | #if defined(_WIN32) |
18d715bd | 437 | SetWindowText ((HWND)Handle(WNT_Window)::DownCast(theWindow)->HWindow(), |
438 | theTitle); | |
439 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
440 | SetCocoaWindowTitle (Handle(Cocoa_Window)::DownCast(theWindow), theTitle); | |
441 | #else | |
442 | if(GetDisplayConnection()->GetDisplay()) | |
443 | { | |
444 | Window aWindow = | |
445 | Handle(Xw_Window)::DownCast(theWindow)->XWindow(); | |
446 | XStoreName (GetDisplayConnection()->GetDisplay(), aWindow , theTitle); | |
447 | } | |
448 | #endif | |
449 | } | |
450 | ||
451 | //============================================================================== | |
452 | //function : IsWindowOverlapped | |
453 | //purpose : Check if theWindow overlapp another view | |
454 | //============================================================================== | |
455 | ||
456 | Standard_Boolean IsWindowOverlapped (const Standard_Integer thePxLeft, | |
457 | const Standard_Integer thePxTop, | |
458 | const Standard_Integer thePxRight, | |
459 | const Standard_Integer thePxBottom, | |
460 | TCollection_AsciiString& theViewId) | |
461 | { | |
462 | for(NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator | |
463 | anIter(ViewerTest_myViews); anIter.More(); anIter.Next()) | |
464 | { | |
465 | Standard_Integer aTop = 0, | |
466 | aLeft = 0, | |
467 | aRight = 0, | |
468 | aBottom = 0; | |
469 | anIter.Value()->Window()->Position(aLeft, aTop, aRight, aBottom); | |
470 | if ((thePxLeft >= aLeft && thePxLeft <= aRight && thePxTop >= aTop && thePxTop <= aBottom) || | |
471 | (thePxLeft >= aLeft && thePxLeft <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom) || | |
472 | (thePxRight >= aLeft && thePxRight <= aRight && thePxTop >= aTop && thePxTop <= aBottom) || | |
473 | (thePxRight >= aLeft && thePxRight <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom)) | |
474 | { | |
475 | theViewId = anIter.Key1(); | |
476 | return Standard_True; | |
477 | } | |
478 | } | |
479 | return Standard_False; | |
480 | } | |
481 | ||
482 | // Workaround: to create and delete non-orthographic views outside ViewerTest | |
483 | void ViewerTest::RemoveViewName (const TCollection_AsciiString& theName) | |
484 | { | |
485 | ViewerTest_myViews.UnBind1 (theName); | |
486 | } | |
487 | ||
488 | void ViewerTest::InitViewName (const TCollection_AsciiString& theName, | |
489 | const Handle(V3d_View)& theView) | |
490 | { | |
491 | ViewerTest_myViews.Bind (theName, theView); | |
492 | } | |
493 | ||
494 | TCollection_AsciiString ViewerTest::GetCurrentViewName () | |
495 | { | |
496 | return ViewerTest_myViews.Find2( ViewerTest::CurrentView()); | |
497 | } | |
7fd59977 | 498 | //============================================================================== |
499 | //function : ViewerInit | |
500 | //purpose : Create the window viewer and initialize all the global variable | |
501 | //============================================================================== | |
502 | ||
18d715bd | 503 | TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft, |
504 | const Standard_Integer thePxTop, | |
505 | const Standard_Integer thePxWidth, | |
506 | const Standard_Integer thePxHeight, | |
507 | Standard_CString theViewName, | |
508 | Standard_CString theDisplayName) | |
7fd59977 | 509 | { |
8c3c9904 | 510 | // Default position and dimension of the viewer window. |
4fe56619 | 511 | // Note that left top corner is set to be sufficiently small to have |
8c3c9904 | 512 | // window fit in the small screens (actual for remote desktops, see #23003). |
4fe56619 | 513 | // The position corresponds to the window's client area, thus some |
8c3c9904 | 514 | // gap is added for window frame to be visible. |
515 | Standard_Integer aPxLeft = 20; | |
516 | Standard_Integer aPxTop = 40; | |
7fd59977 | 517 | Standard_Integer aPxWidth = 409; |
518 | Standard_Integer aPxHeight = 409; | |
18d715bd | 519 | Standard_Boolean toCreateViewer = Standard_False; |
520 | ||
58655684 | 521 | Handle(OpenGl_GraphicDriver) aGraphicDriver; |
18d715bd | 522 | ViewerTest_Names aViewNames(theViewName); |
523 | if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ())) | |
524 | aViewNames.SetViewName (aViewNames.GetViewerName() + "/" + CreateName<Handle(V3d_View)>(ViewerTest_myViews, "View")); | |
525 | ||
526 | if (thePxLeft != 0) | |
527 | aPxLeft = thePxLeft; | |
528 | if (thePxTop != 0) | |
529 | aPxTop = thePxTop; | |
530 | if (thePxWidth != 0) | |
531 | aPxWidth = thePxWidth; | |
532 | if (thePxHeight != 0) | |
7fd59977 | 533 | aPxHeight = thePxHeight; |
4269bd1b | 534 | |
18d715bd | 535 | // Get graphic driver (create it or get from another view) |
536 | if (!ViewerTest_myDrivers.IsBound1 (aViewNames.GetDriverName())) | |
537 | { | |
538 | // Get connection string | |
58655684 | 539 | #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) |
18d715bd | 540 | TCollection_AsciiString aDisplayName(theDisplayName); |
498ce76b | 541 | if (!aDisplayName.IsEmpty()) |
18d715bd | 542 | SetDisplayConnection (new Aspect_DisplayConnection ()); |
543 | else | |
544 | SetDisplayConnection (new Aspect_DisplayConnection (aDisplayName)); | |
18d715bd | 545 | #else |
498ce76b | 546 | (void)theDisplayName; // avoid warning on unused argument |
18d715bd | 547 | SetDisplayConnection (new Aspect_DisplayConnection ()); |
548 | #endif | |
65993a95 | 549 | aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection()); |
58655684 | 550 | aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps; |
18d715bd | 551 | ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver); |
552 | toCreateViewer = Standard_True; | |
553 | } | |
554 | else | |
555 | { | |
58655684 | 556 | aGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast (ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName())); |
7fd59977 | 557 | } |
558 | ||
18d715bd | 559 | //Dispose the window if input parameters are default |
560 | if (!ViewerTest_myViews.IsEmpty() && thePxLeft == 0 && thePxTop == 0) | |
7fd59977 | 561 | { |
18d715bd | 562 | Standard_Integer aTop = 0, |
563 | aLeft = 0, | |
564 | aRight = 0, | |
565 | aBottom = 0, | |
566 | aScreenWidth = 0, | |
567 | aScreenHeight = 0; | |
568 | ||
569 | // Get screen resolution | |
570 | #if defined(_WIN32) || defined(__WIN32__) | |
571 | RECT aWindowSize; | |
572 | GetClientRect(GetDesktopWindow(), &aWindowSize); | |
573 | aScreenHeight = aWindowSize.bottom; | |
574 | aScreenWidth = aWindowSize.right; | |
575 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
576 | GetCocoaScreenResolution (aScreenWidth, aScreenHeight); | |
577 | #else | |
578 | Screen *aScreen = DefaultScreenOfDisplay(GetDisplayConnection()->GetDisplay()); | |
579 | aScreenWidth = WidthOfScreen(aScreen); | |
580 | aScreenHeight = HeightOfScreen(aScreen); | |
581 | #endif | |
582 | ||
583 | TCollection_AsciiString anOverlappedViewId(""); | |
773f53f1 | 584 | |
585 | while (IsWindowOverlapped (aPxLeft, aPxTop, aPxLeft + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId)) | |
dc3fe572 | 586 | { |
18d715bd | 587 | ViewerTest_myViews.Find1(anOverlappedViewId)->Window()->Position (aLeft, aTop, aRight, aBottom); |
588 | ||
589 | if (IsWindowOverlapped (aRight + 20, aPxTop, aRight + 20 + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId) | |
590 | && aRight + 2*aPxWidth + 40 > aScreenWidth) | |
591 | { | |
592 | if (aBottom + aPxHeight + 40 > aScreenHeight) | |
593 | { | |
594 | aPxLeft = 20; | |
595 | aPxTop = 40; | |
596 | break; | |
597 | } | |
598 | aPxLeft = 20; | |
599 | aPxTop = aBottom + 40; | |
600 | } | |
601 | else | |
602 | aPxLeft = aRight + 20; | |
dc3fe572 | 603 | } |
18d715bd | 604 | } |
605 | ||
606 | // Get viewer name | |
607 | TCollection_AsciiString aTitle("3D View - "); | |
608 | aTitle = aTitle + aViewNames.GetViewName() + "(*)"; | |
609 | ||
610 | // Change name of current active window | |
611 | if (!ViewerTest::CurrentView().IsNull()) | |
612 | { | |
613 | TCollection_AsciiString aTitle("3D View - "); | |
614 | aTitle = aTitle | |
615 | + ViewerTest_myViews.Find2 (ViewerTest::CurrentView()); | |
616 | SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString()); | |
617 | } | |
618 | ||
619 | // Create viewer | |
eb4320f2 | 620 | Handle(V3d_Viewer) a3DViewer; |
18d715bd | 621 | // If it's the single view, we first look for empty context |
622 | if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty()) | |
623 | { | |
624 | NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
625 | anIter(ViewerTest_myContexts); | |
626 | if (anIter.More()) | |
627 | ViewerTest::SetAISContext (anIter.Value()); | |
628 | a3DViewer = ViewerTest::GetAISContext()->CurrentViewer(); | |
18d715bd | 629 | } |
630 | else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())) | |
631 | { | |
632 | ViewerTest::SetAISContext(ViewerTest_myContexts.Find1(aViewNames.GetViewerName())); | |
633 | a3DViewer = ViewerTest::GetAISContext()->CurrentViewer(); | |
18d715bd | 634 | } |
eb4320f2 | 635 | else if (a3DViewer.IsNull()) |
18d715bd | 636 | { |
637 | toCreateViewer = Standard_True; | |
638 | TCollection_ExtendedString NameOfWindow("Viewer3D"); | |
639 | a3DViewer = new V3d_Viewer(aGraphicDriver, NameOfWindow.ToExtString()); | |
640 | ||
641 | NameOfWindow = TCollection_ExtendedString("Collector"); | |
18d715bd | 642 | |
643 | a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); | |
18d715bd | 644 | } |
645 | ||
646 | // AIS context setup | |
647 | if (ViewerTest::GetAISContext().IsNull() || | |
648 | !(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))) | |
649 | { | |
e79a94b9 | 650 | Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer); |
18d715bd | 651 | ViewerTest::SetAISContext (aContext); |
652 | ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext()); | |
653 | } | |
654 | else | |
e79a94b9 | 655 | { |
18d715bd | 656 | ViewerTest::ResetEventManager(); |
e79a94b9 | 657 | } |
18d715bd | 658 | |
659 | // Create window | |
e79a94b9 | 660 | #if defined(_WIN32) |
661 | VT_GetWindow() = new WNT_Window (aTitle.ToCString(), | |
662 | Handle(WNT_WClass)::DownCast (WClass()), | |
663 | Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW, | |
664 | aPxLeft, aPxTop, | |
665 | aPxWidth, aPxHeight, | |
666 | Quantity_NOC_BLACK); | |
4fe56619 | 667 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) |
e79a94b9 | 668 | VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(), |
669 | aPxLeft, aPxTop, | |
670 | aPxWidth, aPxHeight); | |
671 | ViewerTest_SetCocoaEventManagerView (VT_GetWindow()); | |
7fd59977 | 672 | #else |
e79a94b9 | 673 | VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(), |
674 | aTitle.ToCString(), | |
675 | aPxLeft, aPxTop, | |
676 | aPxWidth, aPxHeight); | |
7fd59977 | 677 | #endif |
18d715bd | 678 | VT_GetWindow()->SetVirtual (Draw_VirtualWindows); |
7fd59977 | 679 | |
d09dda09 | 680 | // View setup |
681 | Handle(V3d_View) aView = a3DViewer->CreateView(); | |
682 | aView->SetWindow (VT_GetWindow()); | |
4269bd1b | 683 | |
18d715bd | 684 | ViewerTest::CurrentView(aView); |
685 | ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView); | |
7fd59977 | 686 | |
18d715bd | 687 | // Setup for X11 or NT |
688 | OSWindowSetup(); | |
7fd59977 | 689 | |
18d715bd | 690 | // Set parameters for V3d_View and V3d_Viewer |
691 | const Handle (V3d_View) aV3dView = ViewerTest::CurrentView(); | |
692 | aV3dView->SetComputedMode(Standard_False); | |
693 | MyHLRIsOn = aV3dView->ComputedMode(); | |
694 | aV3dView->SetZClippingDepth(0.5); | |
695 | aV3dView->SetZClippingWidth(ZCLIPWIDTH/2.); | |
7fd59977 | 696 | |
18d715bd | 697 | a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); |
698 | if (toCreateViewer) | |
699 | { | |
7fd59977 | 700 | a3DViewer->SetDefaultLights(); |
701 | a3DViewer->SetLightOn(); | |
18d715bd | 702 | } |
7fd59977 | 703 | |
e79a94b9 | 704 | #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) |
4fe56619 | 705 | #if TCL_MAJOR_VERSION < 8 |
18d715bd | 706 | Tk_CreateFileHandler((void*)XConnectionNumber(GetDisplayConnection()->GetDisplay()), |
7fd59977 | 707 | TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() ); |
4fe56619 | 708 | #else |
18d715bd | 709 | Tk_CreateFileHandler(XConnectionNumber(GetDisplayConnection()->GetDisplay()), |
7fd59977 | 710 | TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() ); |
4fe56619 | 711 | #endif |
712 | #endif | |
7fd59977 | 713 | |
7fd59977 | 714 | VT_GetWindow()->Map(); |
4269bd1b | 715 | |
18d715bd | 716 | // Set the handle of created view in the event manager |
717 | ViewerTest::ResetEventManager(); | |
718 | ||
4fe56619 | 719 | ViewerTest::CurrentView()->Redraw(); |
18d715bd | 720 | |
721 | aView.Nullify(); | |
722 | a3DViewer.Nullify(); | |
18d715bd | 723 | |
724 | return aViewNames.GetViewName(); | |
725 | } | |
726 | ||
4269bd1b | 727 | //============================================================================== |
728 | //function : RedrawAllViews | |
729 | //purpose : Redraw all created views | |
730 | //============================================================================== | |
731 | void ViewerTest::RedrawAllViews() | |
732 | { | |
733 | NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews); | |
734 | for (; aViewIt.More(); aViewIt.Next()) | |
735 | { | |
736 | const Handle(V3d_View)& aView = aViewIt.Key2(); | |
737 | aView->Redraw(); | |
738 | } | |
739 | } | |
740 | ||
7fd59977 | 741 | //============================================================================== |
742 | //function : Vinit | |
743 | //purpose : Create the window viewer and initialize all the global variable | |
e79a94b9 | 744 | // Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event |
7fd59977 | 745 | //============================================================================== |
746 | ||
18d715bd | 747 | static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) |
7fd59977 | 748 | { |
e79a94b9 | 749 | if (theArgsNb > 9) |
18d715bd | 750 | { |
e79a94b9 | 751 | std::cerr << theArgVec[0] << ": incorrect number of command arguments.\n" |
752 | << "Type help for more information.\n"; | |
18d715bd | 753 | return 1; |
754 | } | |
18d715bd | 755 | |
e79a94b9 | 756 | TCollection_AsciiString aViewName, aDisplayName; |
757 | Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0; | |
758 | TCollection_AsciiString aName, aValue; | |
759 | for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) | |
18d715bd | 760 | { |
e79a94b9 | 761 | const TCollection_AsciiString anArg = theArgVec[anArgIt]; |
762 | TCollection_AsciiString anArgCase = anArg; | |
763 | anArgCase.UpperCase(); | |
1d7ca641 | 764 | if (ViewerTest::SplitParameter (anArg, aName, aValue)) |
18d715bd | 765 | { |
e79a94b9 | 766 | aName.UpperCase(); |
767 | if (aName.IsEqual ("NAME")) | |
18d715bd | 768 | { |
769 | aViewName = aValue; | |
770 | } | |
e79a94b9 | 771 | else if (aName.IsEqual ("L") |
772 | || aName.IsEqual ("LEFT")) | |
773 | { | |
18d715bd | 774 | aPxLeft = aValue.IntegerValue(); |
e79a94b9 | 775 | } |
776 | else if (aName.IsEqual ("T") | |
777 | || aName.IsEqual ("TOP")) | |
778 | { | |
18d715bd | 779 | aPxTop = aValue.IntegerValue(); |
e79a94b9 | 780 | } |
781 | #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
782 | else if (aName.IsEqual ("DISP") | |
783 | || aName.IsEqual ("DISPLAY")) | |
784 | { | |
18d715bd | 785 | aDisplayName = aValue; |
e79a94b9 | 786 | } |
787 | #endif | |
788 | else if (aName.IsEqual ("W") | |
789 | || aName.IsEqual ("WIDTH")) | |
790 | { | |
18d715bd | 791 | aPxWidth = aValue.IntegerValue(); |
e79a94b9 | 792 | } |
793 | else if (aName.IsEqual ("H") | |
794 | || aName.IsEqual ("HEIGHT")) | |
795 | { | |
18d715bd | 796 | aPxHeight = aValue.IntegerValue(); |
e79a94b9 | 797 | } |
18d715bd | 798 | else |
799 | { | |
e79a94b9 | 800 | std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n"; |
18d715bd | 801 | } |
802 | } | |
e79a94b9 | 803 | else if (aViewName.IsEmpty()) |
804 | { | |
805 | aViewName = anArg; | |
806 | } | |
807 | else | |
808 | { | |
809 | std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n"; | |
810 | } | |
18d715bd | 811 | } |
812 | ||
813 | ViewerTest_Names aViewNames (aViewName); | |
e79a94b9 | 814 | if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName())) |
18d715bd | 815 | { |
e79a94b9 | 816 | TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName(); |
817 | theDi.Eval (aCommand.ToCString()); | |
18d715bd | 818 | return 0; |
819 | } | |
820 | ||
821 | TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight, | |
822 | aViewName.ToCString(), | |
823 | aDisplayName.ToCString()); | |
e79a94b9 | 824 | theDi << aViewId; |
7fd59977 | 825 | return 0; |
826 | } | |
827 | ||
0a768f56 | 828 | //============================================================================== |
829 | //function : VHLR | |
830 | //purpose : hidden lines removal algorithm | |
e9224045 | 831 | //draw args: vhlr is_enabled={on|off} [show_hidden={1|0}] |
0a768f56 | 832 | //============================================================================== |
833 | ||
834 | static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
835 | { | |
836 | if (ViewerTest::CurrentView().IsNull()) | |
837 | { | |
838 | di << argv[0] << ": Call vinit before this command, please.\n"; | |
839 | return 1; | |
840 | } | |
841 | ||
e9224045 | 842 | if (argc < 2) |
0a768f56 | 843 | { |
844 | di << argv[0] << ": Wrong number of command arguments.\n" | |
845 | << "Type help " << argv[0] << " for more information.\n"; | |
846 | return 1; | |
847 | } | |
848 | ||
e9224045 | 849 | // Enable or disable HLR mode. |
0a768f56 | 850 | Standard_Boolean isHLROn = |
851 | (!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False; | |
852 | ||
e9224045 | 853 | if (isHLROn != MyHLRIsOn) |
0a768f56 | 854 | { |
e9224045 | 855 | MyHLRIsOn = isHLROn; |
856 | ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn); | |
0a768f56 | 857 | } |
858 | ||
e9224045 | 859 | // Show or hide hidden lines in HLR mode. |
860 | Standard_Boolean isCurrentShowHidden | |
861 | = ViewerTest::GetAISContext()->DefaultDrawer()->DrawHiddenLine(); | |
862 | ||
863 | Standard_Boolean isShowHidden = | |
864 | (argc == 3) ? (atoi(argv[2]) == 1 ? Standard_True : Standard_False) | |
865 | : isCurrentShowHidden; | |
866 | ||
867 | ||
868 | if (isShowHidden != isCurrentShowHidden) | |
869 | { | |
870 | if (isShowHidden) | |
871 | { | |
872 | ViewerTest::GetAISContext()->DefaultDrawer()->EnableDrawHiddenLine(); | |
873 | } | |
874 | else | |
875 | { | |
876 | ViewerTest::GetAISContext()->DefaultDrawer()->DisableDrawHiddenLine(); | |
877 | } | |
878 | ||
879 | // Redisplay shapes. | |
880 | if (MyHLRIsOn) | |
881 | { | |
882 | AIS_ListOfInteractive aListOfShapes; | |
883 | ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes); | |
884 | ||
885 | for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next()) | |
886 | { | |
887 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIter.Value()); | |
888 | if (aShape.IsNull()) | |
889 | { | |
890 | continue; | |
891 | } | |
36132a2e | 892 | ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False); |
e9224045 | 893 | } |
894 | } | |
895 | } | |
0a768f56 | 896 | |
e9224045 | 897 | ViewerTest::CurrentView()->Update(); |
0a768f56 | 898 | return 0; |
899 | } | |
900 | ||
901 | //============================================================================== | |
902 | //function : VHLRType | |
903 | //purpose : change type of using HLR algorithm | |
904 | //============================================================================== | |
905 | ||
906 | static int VHLRType (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
907 | { | |
908 | if (ViewerTest::CurrentView().IsNull()) | |
909 | { | |
910 | di << argv[0] << ": Call vinit before this command, please.\n"; | |
911 | return 1; | |
912 | } | |
913 | ||
914 | if (argc < 2) | |
915 | { | |
916 | di << argv[0] << ": Wrong number of command arguments.\n" | |
917 | << "Type help " << argv[0] << " for more information.\n"; | |
918 | return 1; | |
919 | } | |
920 | ||
921 | Prs3d_TypeOfHLR aTypeOfHLR = | |
922 | (!strcasecmp (argv[1], "algo")) ? Prs3d_TOH_Algo : Prs3d_TOH_PolyAlgo; | |
923 | ||
924 | if (argc == 2) | |
925 | { | |
926 | AIS_ListOfInteractive aListOfShapes; | |
927 | ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes); | |
928 | ViewerTest::GetAISContext()->DefaultDrawer()->SetTypeOfHLR(aTypeOfHLR); | |
929 | for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); | |
930 | anIter.More(); anIter.Next()) | |
931 | { | |
932 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()); | |
933 | if (aShape.IsNull()) | |
934 | continue; | |
935 | if (aShape->TypeOfHLR() != aTypeOfHLR) | |
936 | aShape->SetTypeOfHLR (aTypeOfHLR); | |
937 | if (MyHLRIsOn) | |
36132a2e | 938 | ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False); |
0a768f56 | 939 | } |
940 | ViewerTest::CurrentView()->Update(); | |
941 | return 0; | |
942 | } | |
943 | else | |
944 | { | |
945 | for (Standard_Integer i = 2; i < argc; ++i) | |
946 | { | |
947 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); | |
948 | TCollection_AsciiString aName (argv[i]); | |
949 | ||
950 | if (!aMap.IsBound2 (aName)) | |
951 | { | |
952 | di << argv[0] << ":" << " Wrong shape name:" << aName.ToCString() << ".\n"; | |
953 | continue; | |
954 | } | |
955 | Handle(AIS_Shape) anAISObject = | |
956 | Handle(AIS_Shape)::DownCast (aMap.Find2(aName)); | |
957 | if (anAISObject.IsNull()) | |
958 | continue; | |
959 | anAISObject->SetTypeOfHLR (aTypeOfHLR); | |
960 | if (MyHLRIsOn) | |
36132a2e | 961 | ViewerTest::GetAISContext()->Redisplay (anAISObject, Standard_False); |
0a768f56 | 962 | } |
963 | ViewerTest::CurrentView()->Update(); | |
964 | } | |
965 | ||
966 | return 0; | |
967 | } | |
968 | ||
18d715bd | 969 | //============================================================================== |
970 | //function : FindViewIdByWindowHandle | |
971 | //purpose : Find theView Id in the map of views by window handle | |
972 | //============================================================================== | |
973 | #if defined(_WIN32) || defined(__WIN32__) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
974 | TCollection_AsciiString FindViewIdByWindowHandle(const Aspect_Handle theWindowHandle) | |
975 | { | |
976 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator | |
977 | anIter(ViewerTest_myViews); anIter.More(); anIter.Next()) | |
978 | { | |
979 | Aspect_Handle aWindowHandle = GetWindowHandle(anIter.Value()->Window()); | |
980 | if (aWindowHandle == theWindowHandle) | |
981 | return anIter.Key1(); | |
982 | } | |
983 | return TCollection_AsciiString(""); | |
984 | } | |
985 | #endif | |
986 | ||
987 | //============================================================================== | |
988 | //function : ActivateView | |
989 | //purpose : Make the view active | |
990 | //============================================================================== | |
991 | ||
992 | void ActivateView (const TCollection_AsciiString& theViewName) | |
993 | { | |
994 | const Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName); | |
995 | if (!aView.IsNull()) | |
996 | { | |
997 | Handle(AIS_InteractiveContext) anAISContext = FindContextByView(aView); | |
998 | if (!anAISContext.IsNull()) | |
999 | { | |
1000 | if (!ViewerTest::CurrentView().IsNull()) | |
1001 | { | |
1002 | TCollection_AsciiString aTitle("3D View - "); | |
1003 | aTitle = aTitle + ViewerTest_myViews.Find2 (ViewerTest::CurrentView()); | |
1004 | SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString()); | |
1005 | } | |
1006 | ||
1007 | ViewerTest::CurrentView (aView); | |
1008 | // Update degenerate mode | |
1009 | MyHLRIsOn = ViewerTest::CurrentView()->ComputedMode(); | |
1010 | ViewerTest::SetAISContext (anAISContext); | |
1011 | TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - "); | |
1012 | aTitle = aTitle + theViewName + "(*)"; | |
1013 | SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString()); | |
1014 | #if defined(_WIN32) || defined(__WIN32__) | |
1015 | VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window()); | |
1016 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
1017 | VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window()); | |
1018 | #else | |
1019 | VT_GetWindow() = Handle(Xw_Window)::DownCast(ViewerTest::CurrentView()->Window()); | |
1020 | #endif | |
1021 | SetDisplayConnection(ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection()); | |
1022 | ViewerTest::CurrentView()->Redraw(); | |
1023 | } | |
1024 | } | |
1025 | } | |
1026 | ||
0e93d9e5 | 1027 | //============================================================================== |
1028 | //function : RemoveView | |
1029 | //purpose : | |
1030 | //============================================================================== | |
1031 | void ViewerTest::RemoveView (const Handle(V3d_View)& theView, | |
1032 | const Standard_Boolean theToRemoveContext) | |
1033 | { | |
1034 | if (!ViewerTest_myViews.IsBound2 (theView)) | |
1035 | { | |
1036 | return; | |
1037 | } | |
1038 | ||
1039 | const TCollection_AsciiString aViewName = ViewerTest_myViews.Find2 (theView); | |
1040 | RemoveView (aViewName, theToRemoveContext); | |
1041 | } | |
1042 | ||
18d715bd | 1043 | //============================================================================== |
1044 | //function : RemoveView | |
1045 | //purpose : Close and remove view from display, clear maps if neccessary | |
1046 | //============================================================================== | |
1047 | void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const Standard_Boolean isContextRemoved) | |
1048 | { | |
1049 | if (!ViewerTest_myViews.IsBound1(theViewName)) | |
1050 | { | |
1051 | cout << "Wrong view name\n"; | |
1052 | return; | |
1053 | } | |
1054 | ||
1055 | // Activate another view if it's active now | |
1056 | if (ViewerTest_myViews.Find1(theViewName) == ViewerTest::CurrentView()) | |
1057 | { | |
1058 | if (ViewerTest_myViews.Extent() > 1) | |
1059 | { | |
1060 | TCollection_AsciiString aNewViewName; | |
1061 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> :: Iterator | |
1062 | anIter(ViewerTest_myViews); anIter.More(); anIter.Next()) | |
1063 | if (anIter.Key1() != theViewName) | |
1064 | { | |
1065 | aNewViewName = anIter.Key1(); | |
1066 | break; | |
1067 | } | |
1068 | ActivateView (aNewViewName); | |
1069 | } | |
1070 | else | |
1071 | { | |
1072 | Handle(V3d_View) anEmptyView; | |
1073 | #if defined(_WIN32) || defined(__WIN32__) | |
1074 | Handle(WNT_Window) anEmptyWindow; | |
1075 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
1076 | Handle(Cocoa_Window) anEmptyWindow; | |
1077 | #else | |
1078 | Handle(Xw_Window) anEmptyWindow; | |
1079 | #endif | |
1080 | VT_GetWindow() = anEmptyWindow; | |
1081 | ViewerTest::CurrentView (anEmptyView); | |
1082 | if (isContextRemoved) | |
1083 | { | |
1084 | Handle(AIS_InteractiveContext) anEmptyContext; | |
1085 | ViewerTest::SetAISContext(anEmptyContext); | |
1086 | } | |
1087 | } | |
1088 | } | |
1089 | ||
1090 | // Delete view | |
1091 | Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName); | |
1092 | Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView); | |
1093 | ||
1094 | // Remove view resources | |
18d715bd | 1095 | ViewerTest_myViews.UnBind1(theViewName); |
1096 | aView->Remove(); | |
1097 | ||
1098 | #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
1099 | XFlush (GetDisplayConnection()->GetDisplay()); | |
1100 | #endif | |
1101 | ||
1102 | // Keep context opened only if the closed view is last to avoid | |
1103 | // unused empty contexts | |
1104 | if (!aCurrentContext.IsNull()) | |
1105 | { | |
1106 | // Check if there are more difined views in the viewer | |
1107 | aCurrentContext->CurrentViewer()->InitDefinedViews(); | |
1108 | if ((isContextRemoved || ViewerTest_myContexts.Size() != 1) && !aCurrentContext->CurrentViewer()->MoreDefinedViews()) | |
1109 | { | |
1110 | // Remove driver if there is no viewers that use it | |
1111 | Standard_Boolean isRemoveDriver = Standard_True; | |
1112 | for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
1113 | anIter(ViewerTest_myContexts); anIter.More(); anIter.Next()) | |
1114 | { | |
1115 | if (aCurrentContext != anIter.Key2() && | |
1116 | aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver()) | |
1117 | { | |
1118 | isRemoveDriver = Standard_False; | |
1119 | break; | |
1120 | } | |
1121 | } | |
1122 | if(isRemoveDriver) | |
1123 | { | |
1124 | ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver()); | |
1125 | #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
1126 | #if TCL_MAJOR_VERSION < 8 | |
1127 | Tk_DeleteFileHandler((void*)XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay())); | |
1128 | #else | |
1129 | Tk_DeleteFileHandler(XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay())); | |
1130 | #endif | |
1131 | #endif | |
1132 | } | |
1133 | ||
1134 | ViewerTest_myContexts.UnBind2(aCurrentContext); | |
1135 | } | |
1136 | } | |
1137 | cout << "3D View - " << theViewName << " was deleted.\n"; | |
1138 | ||
1139 | } | |
1140 | ||
1141 | //============================================================================== | |
1142 | //function : VClose | |
1143 | //purpose : Remove the view defined by its name | |
1144 | //============================================================================== | |
1145 | ||
d0cc1cb7 | 1146 | static int VClose (Draw_Interpretor& /*theDi*/, |
1147 | Standard_Integer theArgsNb, | |
1148 | const char** theArgVec) | |
18d715bd | 1149 | { |
18d715bd | 1150 | NCollection_List<TCollection_AsciiString> aViewList; |
d0cc1cb7 | 1151 | if (theArgsNb > 1) |
18d715bd | 1152 | { |
d0cc1cb7 | 1153 | TCollection_AsciiString anArg (theArgVec[1]); |
1154 | anArg.UpperCase(); | |
1155 | if (anArg.IsEqual ("ALL") | |
1156 | || anArg.IsEqual ("*")) | |
1157 | { | |
1158 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews); | |
1159 | anIter.More(); anIter.Next()) | |
1160 | { | |
1161 | aViewList.Append (anIter.Key1()); | |
1162 | } | |
1163 | if (aViewList.IsEmpty()) | |
1164 | { | |
1165 | std::cout << "No view to close\n"; | |
1166 | return 0; | |
1167 | } | |
1168 | } | |
1169 | else | |
18d715bd | 1170 | { |
d0cc1cb7 | 1171 | ViewerTest_Names aViewName (theArgVec[1]); |
1172 | if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName())) | |
1173 | { | |
1174 | std::cerr << "The view with name '" << theArgVec[1] << "' does not exist\n"; | |
1175 | return 1; | |
1176 | } | |
1177 | aViewList.Append (aViewName.GetViewName()); | |
18d715bd | 1178 | } |
1179 | } | |
1180 | else | |
1181 | { | |
d0cc1cb7 | 1182 | // close active view |
1183 | if (ViewerTest::CurrentView().IsNull()) | |
1184 | { | |
1185 | std::cerr << "No active view!\n"; | |
1186 | return 1; | |
1187 | } | |
1188 | aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView())); | |
18d715bd | 1189 | } |
1190 | ||
d0cc1cb7 | 1191 | Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1); |
18d715bd | 1192 | for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList); |
1193 | anIter.More(); anIter.Next()) | |
1194 | { | |
d0cc1cb7 | 1195 | ViewerTest::RemoveView (anIter.Value(), toRemoveContext); |
18d715bd | 1196 | } |
1197 | ||
1198 | return 0; | |
1199 | } | |
1200 | ||
1201 | //============================================================================== | |
1202 | //function : VActivate | |
1203 | //purpose : Activate the view defined by its ID | |
1204 | //============================================================================== | |
1205 | ||
1206 | static int VActivate (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
1207 | { | |
1208 | if (theArgsNb > 2) | |
1209 | { | |
1210 | theDi << theArgVec[0] << ": wrong number of command arguments.\n" | |
1211 | << "Usage: " << theArgVec[0] << " ViewID\n"; | |
1212 | return 1; | |
1213 | } | |
1214 | if(theArgsNb == 1) | |
1215 | { | |
1216 | theDi.Eval("vviewlist"); | |
1217 | return 0; | |
1218 | } | |
1219 | ||
1220 | TCollection_AsciiString aNameString(theArgVec[1]); | |
29cb310a | 1221 | if ( strcasecmp( aNameString.ToCString(), "NONE" ) == 0 ) |
18d715bd | 1222 | { |
1223 | TCollection_AsciiString aTitle("3D View - "); | |
1224 | aTitle = aTitle + ViewerTest_myViews.Find2(ViewerTest::CurrentView()); | |
1225 | SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString()); | |
1226 | Handle(V3d_View) anEmptyView; | |
1227 | #if defined(_WIN32) || defined(__WIN32__) | |
1228 | Handle(WNT_Window) anEmptyWindow; | |
1229 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
1230 | Handle(Cocoa_Window) anEmptyWindow; | |
1231 | #else | |
1232 | Handle(Xw_Window) anEmptyWindow; | |
1233 | #endif | |
1234 | VT_GetWindow() = anEmptyWindow; | |
1235 | ViewerTest::CurrentView (anEmptyView); | |
1236 | ViewerTest::ResetEventManager(); | |
1237 | theDi << theArgVec[0] << ": all views are inactive\n"; | |
1238 | return 0; | |
1239 | } | |
1240 | ||
1241 | ViewerTest_Names aViewNames(aNameString); | |
1242 | ||
1243 | // Check if this view exists in the viewer with the driver | |
1244 | if (!ViewerTest_myViews.IsBound1(aViewNames.GetViewName())) | |
1245 | { | |
1246 | theDi << "Wrong view name\n"; | |
1247 | return 1; | |
1248 | } | |
1249 | ||
1250 | // Check if it is active already | |
1251 | if (ViewerTest::CurrentView() == ViewerTest_myViews.Find1(aViewNames.GetViewName())) | |
1252 | { | |
1253 | theDi << theArgVec[0] << ": the view is active already\n"; | |
1254 | return 0; | |
1255 | } | |
1256 | ||
1257 | ActivateView (aViewNames.GetViewName()); | |
1258 | return 0; | |
1259 | } | |
1260 | ||
1261 | //============================================================================== | |
1262 | //function : VViewList | |
1263 | //purpose : Print current list of views per viewer and graphic driver ID | |
1264 | // shared between viewers | |
1265 | //============================================================================== | |
1266 | ||
1267 | static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
1268 | { | |
1269 | if (theArgsNb > 2) | |
1270 | { | |
1271 | theDi << theArgVec[0] << ": Wrong number of command arguments\n" | |
29cb310a | 1272 | << "Usage: " << theArgVec[0] << " name"; |
18d715bd | 1273 | return 1; |
1274 | } | |
1275 | if (ViewerTest_myContexts.Size() < 1) | |
1276 | return 0; | |
1277 | ||
18d715bd | 1278 | Standard_Boolean isTreeView = |
29cb310a | 1279 | (( theArgsNb==1 ) || ( strcasecmp( theArgVec[1], "long" ) != 0 )); |
18d715bd | 1280 | |
1281 | if (isTreeView) | |
1282 | theDi << theArgVec[0] <<":\n"; | |
1283 | ||
1284 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator | |
1285 | aDriverIter(ViewerTest_myDrivers); aDriverIter.More(); aDriverIter.Next()) | |
1286 | { | |
1287 | if (isTreeView) | |
1288 | theDi << aDriverIter.Key1() << ":\n"; | |
1289 | ||
1290 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
1291 | aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next()) | |
1292 | { | |
1293 | if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1) | |
1294 | { | |
1295 | if (isTreeView) | |
1296 | { | |
1297 | TCollection_AsciiString aContextName(aContextIter.Key1()); | |
1298 | theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":" << "\n"; | |
1299 | } | |
1300 | ||
1301 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator | |
1302 | aViewIter(ViewerTest_myViews); aViewIter.More(); aViewIter.Next()) | |
1303 | { | |
1304 | if (aViewIter.Key1().Search(aContextIter.Key1()) != -1) | |
1305 | { | |
1306 | TCollection_AsciiString aViewName(aViewIter.Key1()); | |
1307 | if (isTreeView) | |
1308 | { | |
1309 | if (aViewIter.Value() == ViewerTest::CurrentView()) | |
1310 | theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)" << "\n"; | |
1311 | else | |
1312 | theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n"; | |
1313 | } | |
1314 | else | |
1315 | { | |
1316 | theDi << aViewName << " "; | |
1317 | } | |
1318 | } | |
1319 | } | |
1320 | } | |
1321 | } | |
1322 | } | |
1323 | return 0; | |
1324 | } | |
1325 | ||
7fd59977 | 1326 | //============================================================================== |
4fe56619 | 1327 | //function : VT_ProcessKeyPress |
7fd59977 | 1328 | //purpose : Handle KeyPress event from a CString |
1329 | //============================================================================== | |
4fe56619 | 1330 | void VT_ProcessKeyPress (const char* buf_ret) |
7fd59977 | 1331 | { |
1332 | //cout << "KeyPress" << endl; | |
1333 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7fd59977 | 1334 | // Letter in alphabetic order |
1335 | ||
b514beda | 1336 | if (!strcasecmp (buf_ret, "A")) |
1337 | { | |
7fd59977 | 1338 | // AXO |
1339 | aView->SetProj(V3d_XposYnegZpos); | |
1340 | } | |
b514beda | 1341 | else if (!strcasecmp (buf_ret, "D")) |
1342 | { | |
7fd59977 | 1343 | // Reset |
1344 | aView->Reset(); | |
1345 | } | |
b514beda | 1346 | else if (!strcasecmp (buf_ret, "F")) |
1347 | { | |
b586500b | 1348 | if (ViewerTest::GetAISContext()->NbSelected() > 0) |
1349 | { | |
1350 | ViewerTest::GetAISContext()->FitSelected (aView); | |
1351 | } | |
1352 | else | |
1353 | { | |
1354 | // FitAll | |
1355 | aView->FitAll(); | |
1356 | } | |
7fd59977 | 1357 | } |
b514beda | 1358 | else if (!strcasecmp (buf_ret, "H")) |
1359 | { | |
7fd59977 | 1360 | // HLR |
1361 | cout << "HLR" << endl; | |
de75ed09 | 1362 | aView->SetComputedMode (!aView->ComputedMode()); |
1363 | MyHLRIsOn = aView->ComputedMode(); | |
7fd59977 | 1364 | } |
b514beda | 1365 | else if (!strcasecmp (buf_ret, "P")) |
1366 | { | |
0a768f56 | 1367 | // Type of HLR |
1368 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
1369 | if (aContext->DefaultDrawer()->TypeOfHLR() == Prs3d_TOH_Algo) | |
1370 | aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_PolyAlgo); | |
1371 | else | |
1372 | aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_Algo); | |
1373 | if (aContext->NbCurrents()==0 || aContext->NbSelected() == 0) | |
1374 | { | |
1375 | AIS_ListOfInteractive aListOfShapes; | |
1376 | aContext->DisplayedObjects(aListOfShapes); | |
1377 | for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); | |
1378 | anIter.More(); anIter.Next()) | |
1379 | { | |
1380 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()); | |
1381 | if (aShape.IsNull()) | |
1382 | continue; | |
1383 | if (aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo) | |
1384 | aShape->SetTypeOfHLR (Prs3d_TOH_Algo); | |
1385 | else | |
1386 | aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo); | |
36132a2e | 1387 | aContext->Redisplay (aShape, Standard_False); |
0a768f56 | 1388 | } |
1389 | } | |
1390 | else | |
1391 | { | |
1392 | for (aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent()) | |
1393 | { | |
1394 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->Current()); | |
1395 | if (aShape.IsNull()) | |
1396 | continue; | |
1397 | if(aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo) | |
1398 | aShape->SetTypeOfHLR (Prs3d_TOH_Algo); | |
1399 | else | |
1400 | aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo); | |
36132a2e | 1401 | aContext->Redisplay (aShape, Standard_False); |
0a768f56 | 1402 | } |
1403 | } | |
1404 | ||
1405 | aContext->UpdateCurrentViewer(); | |
4269bd1b | 1406 | |
0a768f56 | 1407 | } |
b514beda | 1408 | else if (!strcasecmp (buf_ret, "S")) |
1409 | { | |
1410 | std::cout << "setup Shaded display mode" << std::endl; | |
4fe56619 | 1411 | |
7fd59977 | 1412 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
1413 | if(Ctx->NbCurrents()==0 || | |
1414 | Ctx->NbSelected()==0) | |
1415 | Ctx->SetDisplayMode(AIS_Shaded); | |
1416 | else{ | |
1417 | if(Ctx->HasOpenedContext()){ | |
1418 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) | |
1419 | Ctx->SetDisplayMode(Ctx->Interactive(),1,Standard_False); | |
1420 | } | |
1421 | else{ | |
1422 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) | |
1423 | Ctx->SetDisplayMode(Ctx->Current(),1,Standard_False); | |
1424 | } | |
1425 | Ctx->UpdateCurrentViewer(); | |
1426 | } | |
1427 | } | |
b514beda | 1428 | else if (!strcasecmp (buf_ret, "U")) |
1429 | { | |
41811896 | 1430 | // Unset display mode |
b514beda | 1431 | std::cout << "reset display mode to defaults" << std::endl; |
4fe56619 | 1432 | |
7fd59977 | 1433 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
1434 | if(Ctx->NbCurrents()==0 || | |
1435 | Ctx->NbSelected()==0) | |
1436 | Ctx->SetDisplayMode(AIS_WireFrame); | |
1437 | else{ | |
1438 | if(Ctx->HasOpenedContext()){ | |
1439 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) | |
1440 | Ctx->UnsetDisplayMode(Ctx->Interactive(),Standard_False); | |
1441 | } | |
1442 | else{ | |
1443 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) | |
1444 | Ctx->UnsetDisplayMode(Ctx->Current(),Standard_False); | |
1445 | } | |
1446 | Ctx->UpdateCurrentViewer(); | |
1447 | } | |
1448 | ||
1449 | } | |
b514beda | 1450 | else if (!strcasecmp (buf_ret, "T")) |
1451 | { | |
7fd59977 | 1452 | // Top |
1453 | aView->SetProj(V3d_Zpos); | |
1454 | } | |
b514beda | 1455 | else if (!strcasecmp (buf_ret, "B")) |
1456 | { | |
41811896 | 1457 | // Bottom |
7fd59977 | 1458 | aView->SetProj(V3d_Zneg); |
1459 | } | |
b514beda | 1460 | else if (!strcasecmp (buf_ret, "L")) |
1461 | { | |
41811896 | 1462 | // Left |
7fd59977 | 1463 | aView->SetProj(V3d_Xneg); |
1464 | } | |
b514beda | 1465 | else if (!strcasecmp (buf_ret, "R")) |
1466 | { | |
41811896 | 1467 | // Right |
7fd59977 | 1468 | aView->SetProj(V3d_Xpos); |
1469 | } | |
b514beda | 1470 | else if (!strcasecmp (buf_ret, "W")) |
1471 | { | |
1472 | std::cout << "setup WireFrame display mode" << std::endl; | |
7fd59977 | 1473 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
1474 | if(Ctx->NbCurrents()==0 || | |
1475 | Ctx->NbSelected()==0) | |
1476 | Ctx->SetDisplayMode(AIS_WireFrame); | |
1477 | else{ | |
1478 | if(Ctx->HasOpenedContext()){ | |
1479 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) | |
1480 | Ctx->SetDisplayMode(Ctx->Interactive(),0,Standard_False); | |
1481 | } | |
1482 | else{ | |
1483 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) | |
1484 | Ctx->SetDisplayMode(Ctx->Current(),0,Standard_False); | |
1485 | } | |
1486 | Ctx->UpdateCurrentViewer(); | |
1487 | } | |
1488 | } | |
b514beda | 1489 | else if (!strcasecmp (buf_ret, "Z")) |
1490 | { | |
7fd59977 | 1491 | // ZCLIP |
7fd59977 | 1492 | if ( ZClipIsOn ) { |
1493 | cout << "ZClipping OFF" << endl; | |
1494 | ZClipIsOn = 0; | |
1495 | ||
1496 | aView->SetZClippingType(V3d_OFF); | |
1497 | aView->Redraw(); | |
1498 | } | |
1499 | else { | |
1500 | cout << "ZClipping ON" << endl; | |
1501 | ZClipIsOn = 1; | |
1502 | ||
1503 | aView->SetZClippingType(V3d_FRONT); | |
1504 | aView->Redraw(); | |
1505 | } | |
1506 | } | |
b514beda | 1507 | else if (!strcasecmp (buf_ret, ",")) |
1508 | { | |
7fd59977 | 1509 | ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView()); |
7fd59977 | 1510 | } |
b514beda | 1511 | else if (!strcasecmp (buf_ret, ".")) |
1512 | { | |
7fd59977 | 1513 | ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView()); |
1514 | } | |
f978241f | 1515 | else if (!strcasecmp (buf_ret, "/")) |
1516 | { | |
1517 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); | |
1518 | if (aCamera->IsStereo()) | |
1519 | { | |
1520 | aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() - 0.01); | |
1521 | aView->Redraw(); | |
1522 | } | |
1523 | } | |
1524 | else if (!strcasecmp (buf_ret, "*")) | |
1525 | { | |
1526 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); | |
1527 | if (aCamera->IsStereo()) | |
1528 | { | |
1529 | aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() + 0.01); | |
1530 | aView->Redraw(); | |
1531 | } | |
1532 | } | |
b514beda | 1533 | else if (*buf_ret == THE_KEY_DELETE) |
1534 | { | |
1535 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
1536 | if (!aCtx.IsNull() | |
1537 | && aCtx->NbCurrents() > 0 | |
1538 | && aCtx->NbSelected() > 0) | |
1539 | { | |
1540 | Draw_Interprete ("verase"); | |
1541 | } | |
1542 | } | |
1543 | else | |
1544 | { | |
1545 | // Number | |
91322f44 | 1546 | Standard_Integer Num = Draw::Atoi(buf_ret); |
7fd59977 | 1547 | if(Num>=0 && Num<=7) |
1548 | ViewerTest::StandardModeActivation(Num); | |
1549 | } | |
1550 | } | |
1551 | ||
1552 | //============================================================================== | |
4fe56619 | 1553 | //function : VT_ProcessExpose |
7fd59977 | 1554 | //purpose : Redraw the View on an Expose Event |
1555 | //============================================================================== | |
4fe56619 | 1556 | void VT_ProcessExpose() |
1557 | { | |
1558 | Handle(V3d_View) aView3d = ViewerTest::CurrentView(); | |
1559 | if (!aView3d.IsNull()) | |
1560 | { | |
1561 | aView3d->Redraw(); | |
1562 | } | |
7fd59977 | 1563 | } |
1564 | ||
1565 | //============================================================================== | |
4fe56619 | 1566 | //function : VT_ProcessConfigure |
7fd59977 | 1567 | //purpose : Resize the View on an Configure Event |
1568 | //============================================================================== | |
4fe56619 | 1569 | void VT_ProcessConfigure() |
7fd59977 | 1570 | { |
4fe56619 | 1571 | Handle(V3d_View) aView3d = ViewerTest::CurrentView(); |
1572 | if (aView3d.IsNull()) | |
1573 | { | |
1574 | return; | |
1575 | } | |
1576 | ||
1577 | aView3d->MustBeResized(); | |
1578 | aView3d->Update(); | |
1579 | aView3d->Redraw(); | |
7fd59977 | 1580 | } |
1581 | ||
1582 | //============================================================================== | |
4fe56619 | 1583 | //function : VT_ProcessButton1Press |
7fd59977 | 1584 | //purpose : Picking |
1585 | //============================================================================== | |
e79a94b9 | 1586 | Standard_Boolean VT_ProcessButton1Press (Standard_Integer , |
1587 | const char** theArgVec, | |
1588 | Standard_Boolean theToPick, | |
1589 | Standard_Boolean theIsShift) | |
7fd59977 | 1590 | { |
e79a94b9 | 1591 | if (theToPick) |
1592 | { | |
7fd59977 | 1593 | Standard_Real X, Y, Z; |
e79a94b9 | 1594 | ViewerTest::CurrentView()->Convert (X_Motion, Y_Motion, X, Y, Z); |
7fd59977 | 1595 | |
e79a94b9 | 1596 | Draw::Set (theArgVec[1], X); |
1597 | Draw::Set (theArgVec[2], Y); | |
1598 | Draw::Set (theArgVec[3], Z); | |
1599 | } | |
7fd59977 | 1600 | |
e79a94b9 | 1601 | if (theIsShift) |
1602 | { | |
1603 | ViewerTest::CurrentEventManager()->ShiftSelect(); | |
1604 | } | |
7fd59977 | 1605 | else |
e79a94b9 | 1606 | { |
1607 | ViewerTest::CurrentEventManager()->Select(); | |
1608 | } | |
7fd59977 | 1609 | |
e79a94b9 | 1610 | return Standard_False; |
7fd59977 | 1611 | } |
1612 | ||
1613 | //============================================================================== | |
4fe56619 | 1614 | //function : VT_ProcessButton1Release |
1615 | //purpose : End selecting | |
7fd59977 | 1616 | //============================================================================== |
4fe56619 | 1617 | void VT_ProcessButton1Release (Standard_Boolean theIsShift) |
1618 | { | |
1619 | if (IsDragged) | |
1620 | { | |
1621 | IsDragged = Standard_False; | |
1622 | Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); | |
1623 | if (theIsShift) | |
1624 | { | |
2157d6ac | 1625 | EM->ShiftSelect (X_ButtonPress, Y_ButtonPress, |
1626 | X_Motion, Y_Motion); | |
4fe56619 | 1627 | } |
1628 | else | |
1629 | { | |
2157d6ac | 1630 | EM->Select (X_ButtonPress, Y_ButtonPress, |
1631 | X_Motion, Y_Motion); | |
4fe56619 | 1632 | } |
1633 | } | |
1634 | } | |
7fd59977 | 1635 | |
4fe56619 | 1636 | //============================================================================== |
1637 | //function : VT_ProcessButton3Press | |
1638 | //purpose : Start Rotation | |
1639 | //============================================================================== | |
1640 | void VT_ProcessButton3Press() | |
1641 | { | |
7fd59977 | 1642 | Start_Rot = 1; |
de75ed09 | 1643 | if (MyHLRIsOn) |
1644 | { | |
1645 | ViewerTest::CurrentView()->SetComputedMode (Standard_False); | |
1646 | } | |
7fd59977 | 1647 | ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress ); |
7fd59977 | 1648 | } |
4fe56619 | 1649 | |
7fd59977 | 1650 | //============================================================================== |
4fe56619 | 1651 | //function : VT_ProcessButton3Release |
1652 | //purpose : End rotation | |
7fd59977 | 1653 | //============================================================================== |
4fe56619 | 1654 | void VT_ProcessButton3Release() |
1655 | { | |
1656 | if (Start_Rot) | |
1657 | { | |
7fd59977 | 1658 | Start_Rot = 0; |
de75ed09 | 1659 | if (MyHLRIsOn) |
1660 | { | |
1661 | ViewerTest::CurrentView()->SetComputedMode (Standard_True); | |
1662 | } | |
7fd59977 | 1663 | } |
7fd59977 | 1664 | } |
1665 | ||
1666 | //============================================================================== | |
1667 | //function : ProcessZClipMotion | |
1668 | //purpose : Zoom | |
1669 | //============================================================================== | |
1670 | ||
1671 | void ProcessZClipMotion() | |
1672 | { | |
1673 | Handle(V3d_View) a3DView = ViewerTest::CurrentView(); | |
1674 | if ( Abs(X_Motion - X_ButtonPress) > 2 ) { | |
7fd59977 | 1675 | |
1676 | //Quantity_Length VDX, VDY; | |
1677 | //a3DView->Size(VDX,VDY); | |
1678 | //Standard_Real VDZ = a3DView->ZSize(); | |
1679 | //printf("View size (%lf,%lf,%lf)\n", VDX, VDY, VDZ); | |
1680 | ||
58978f9b | 1681 | Quantity_Length aDx = a3DView->Convert(X_Motion - X_ButtonPress); |
7fd59977 | 1682 | |
1683 | // Front = Depth + width/2. | |
58978f9b | 1684 | Standard_Real aDepth = 0.5; |
1685 | Standard_Real aWidth = 0.1; | |
1686 | a3DView->ZClipping(aDepth,aWidth); | |
7fd59977 | 1687 | |
58978f9b | 1688 | aDepth += aDx; |
7fd59977 | 1689 | |
1690 | //printf("dx %lf Depth %lf Width %lf\n", dx, D, W); | |
1691 | ||
58978f9b | 1692 | a3DView->SetZClippingDepth(aDepth); |
7fd59977 | 1693 | |
1694 | a3DView->Redraw(); | |
1695 | ||
1696 | X_ButtonPress = X_Motion; | |
1697 | Y_ButtonPress = Y_Motion; | |
1698 | } | |
1699 | } | |
1700 | ||
1701 | //============================================================================== | |
1702 | //function : ProcessControlButton1Motion | |
1703 | //purpose : Zoom | |
1704 | //============================================================================== | |
1705 | ||
900f7229 | 1706 | #if defined(_WIN32) || ! defined(__APPLE__) || defined(MACOSX_USE_GLX) |
7fd59977 | 1707 | static void ProcessControlButton1Motion() |
1708 | { | |
1709 | ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion); | |
1710 | ||
1711 | X_ButtonPress = X_Motion; | |
1712 | Y_ButtonPress = Y_Motion; | |
1713 | } | |
900f7229 | 1714 | #endif |
7fd59977 | 1715 | |
1716 | //============================================================================== | |
4fe56619 | 1717 | //function : VT_ProcessControlButton2Motion |
1718 | //purpose : Panning | |
7fd59977 | 1719 | //============================================================================== |
4fe56619 | 1720 | void VT_ProcessControlButton2Motion() |
7fd59977 | 1721 | { |
197ac94e | 1722 | Standard_Integer aDx = X_Motion - X_ButtonPress; |
1723 | Standard_Integer aDy = Y_Motion - Y_ButtonPress; | |
7fd59977 | 1724 | |
197ac94e | 1725 | aDy = -aDy; // Xwindow Y axis is from top to Bottom |
7fd59977 | 1726 | |
197ac94e | 1727 | ViewerTest::CurrentView()->Pan (aDx, aDy); |
7fd59977 | 1728 | |
1729 | X_ButtonPress = X_Motion; | |
1730 | Y_ButtonPress = Y_Motion; | |
1731 | } | |
1732 | ||
1733 | //============================================================================== | |
4fe56619 | 1734 | //function : VT_ProcessControlButton3Motion |
7fd59977 | 1735 | //purpose : Rotation |
1736 | //============================================================================== | |
4fe56619 | 1737 | void VT_ProcessControlButton3Motion() |
7fd59977 | 1738 | { |
4fe56619 | 1739 | if (Start_Rot) |
1740 | { | |
1741 | ViewerTest::CurrentView()->Rotation (X_Motion, Y_Motion); | |
1742 | } | |
7fd59977 | 1743 | } |
1744 | ||
1745 | //============================================================================== | |
4fe56619 | 1746 | //function : VT_ProcessMotion |
1747 | //purpose : | |
7fd59977 | 1748 | //============================================================================== |
4fe56619 | 1749 | void VT_ProcessMotion() |
7fd59977 | 1750 | { |
1751 | //pre-hilights detected objects at mouse position | |
1752 | ||
1753 | Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); | |
1754 | EM->MoveTo(X_Motion, Y_Motion); | |
1755 | } | |
1756 | ||
1757 | ||
1758 | void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix) | |
1759 | { | |
1760 | Xpix = X_Motion;Ypix=Y_Motion; | |
1761 | } | |
1762 | ||
44b8f2d6 | 1763 | //============================================================================== |
1764 | //function : ViewProject: implements VAxo, VTop, VLeft, ... | |
1765 | //purpose : Switches to an axonometric, top, left and other views | |
1766 | //============================================================================== | |
1767 | ||
1768 | static int ViewProject(Draw_Interpretor& di, const V3d_TypeOfOrientation ori) | |
1769 | { | |
4fe56619 | 1770 | if ( ViewerTest::CurrentView().IsNull() ) |
44b8f2d6 | 1771 | { |
1772 | di<<"Call vinit before this command, please"<<"\n"; | |
1773 | return 1; | |
1774 | } | |
1775 | ||
1776 | ViewerTest::CurrentView()->SetProj(ori); | |
1777 | return 0; | |
1778 | } | |
1779 | ||
7fd59977 | 1780 | //============================================================================== |
1781 | //function : VAxo | |
1782 | //purpose : Switch to an Axonometric view | |
1783 | //Draw arg : No args | |
1784 | //============================================================================== | |
1785 | ||
1786 | static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** ) | |
44b8f2d6 | 1787 | { |
1788 | return ViewProject(di, V3d_XposYnegZpos); | |
7fd59977 | 1789 | } |
1790 | ||
1791 | //============================================================================== | |
1792 | //function : VTop | |
1793 | //purpose : Switch to a Top View | |
1794 | //Draw arg : No args | |
1795 | //============================================================================== | |
1796 | ||
1797 | static int VTop(Draw_Interpretor& di, Standard_Integer , const char** ) | |
1798 | { | |
44b8f2d6 | 1799 | return ViewProject(di, V3d_Zpos); |
1800 | } | |
7fd59977 | 1801 | |
44b8f2d6 | 1802 | //============================================================================== |
1803 | //function : VBottom | |
1804 | //purpose : Switch to a Bottom View | |
1805 | //Draw arg : No args | |
1806 | //============================================================================== | |
7fd59977 | 1807 | |
44b8f2d6 | 1808 | static int VBottom(Draw_Interpretor& di, Standard_Integer , const char** ) |
1809 | { | |
1810 | return ViewProject(di, V3d_Zneg); | |
1811 | } | |
7fd59977 | 1812 | |
44b8f2d6 | 1813 | //============================================================================== |
1814 | //function : VLeft | |
1815 | //purpose : Switch to a Left View | |
1816 | //Draw arg : No args | |
1817 | //============================================================================== | |
1818 | ||
1819 | static int VLeft(Draw_Interpretor& di, Standard_Integer , const char** ) | |
1820 | { | |
1821 | return ViewProject(di, V3d_Ypos); | |
1822 | } | |
1823 | ||
1824 | //============================================================================== | |
1825 | //function : VRight | |
1826 | //purpose : Switch to a Right View | |
1827 | //Draw arg : No args | |
1828 | //============================================================================== | |
1829 | ||
1830 | static int VRight(Draw_Interpretor& di, Standard_Integer , const char** ) | |
1831 | { | |
1832 | return ViewProject(di, V3d_Yneg); | |
1833 | } | |
7fd59977 | 1834 | |
44b8f2d6 | 1835 | //============================================================================== |
1836 | //function : VFront | |
1837 | //purpose : Switch to a Front View | |
1838 | //Draw arg : No args | |
1839 | //============================================================================== | |
1840 | ||
1841 | static int VFront(Draw_Interpretor& di, Standard_Integer , const char** ) | |
1842 | { | |
1843 | return ViewProject(di, V3d_Xpos); | |
1844 | } | |
1845 | ||
1846 | //============================================================================== | |
1847 | //function : VBack | |
1848 | //purpose : Switch to a Back View | |
1849 | //Draw arg : No args | |
1850 | //============================================================================== | |
1851 | ||
1852 | static int VBack(Draw_Interpretor& di, Standard_Integer , const char** ) | |
1853 | { | |
1854 | return ViewProject(di, V3d_Xneg); | |
7fd59977 | 1855 | } |
1856 | ||
1857 | //============================================================================== | |
1858 | //function : VHelp | |
1859 | //purpose : Dsiplay help on viewer Keyboead and mouse commands | |
1860 | //Draw arg : No args | |
1861 | //============================================================================== | |
1862 | ||
1863 | static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** ) | |
1864 | { | |
1865 | ||
1866 | di << "Q : Quit the application" << "\n"; | |
1867 | ||
1868 | di << "========================="<<"\n"; | |
1869 | di << "F : FitAll" << "\n"; | |
1870 | di << "T : TopView" << "\n"; | |
41811896 | 1871 | di << "B : BottomView" << "\n"; |
1872 | di << "R : RightView" << "\n"; | |
1873 | di << "L : LeftView" << "\n"; | |
7fd59977 | 1874 | di << "A : AxonometricView" << "\n"; |
41811896 | 1875 | di << "D : ResetView" << "\n"; |
7fd59977 | 1876 | |
1877 | di << "========================="<<"\n"; | |
1878 | di << "S : Shading" << "\n"; | |
1879 | di << "W : Wireframe" << "\n"; | |
1880 | di << "H : HidelLineRemoval" << "\n"; | |
41811896 | 1881 | di << "U : Unset display mode" << "\n"; |
b514beda | 1882 | di << "Delete : Remove selection from viewer" << "\n"; |
7fd59977 | 1883 | |
1884 | di << "========================="<<"\n"; | |
1885 | di << "Selection mode "<<"\n"; | |
1886 | di << "0 : Shape" <<"\n"; | |
1887 | di << "1 : Vertex" <<"\n"; | |
1888 | di << "2 : Edge" <<"\n"; | |
1889 | di << "3 : Wire" <<"\n"; | |
1890 | di << "4 : Face" <<"\n"; | |
1891 | di << "5 : Shell" <<"\n"; | |
1892 | di << "6 : Solid" <<"\n"; | |
1893 | di << "7 : Compound" <<"\n"; | |
1894 | ||
41811896 | 1895 | di << "========================="<<"\n"; |
1896 | di << "Z : Switch Z clipping On/Off" << "\n"; | |
1897 | di << ", : Hilight next detected" << "\n"; | |
1898 | di << ". : Hilight previous detected" << "\n"; | |
7fd59977 | 1899 | |
1900 | return 0; | |
1901 | } | |
1902 | ||
7fd59977 | 1903 | #ifdef WNT |
1904 | ||
1905 | static Standard_Boolean Ppick = 0; | |
1906 | static Standard_Integer Pargc = 0; | |
1907 | static const char** Pargv = NULL; | |
1908 | ||
1909 | ||
1910 | static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd, | |
1911 | UINT Msg, | |
1912 | WPARAM wParam, | |
1913 | LPARAM lParam ) | |
1914 | { | |
18d715bd | 1915 | if (!ViewerTest_myViews.IsEmpty()) { |
7fd59977 | 1916 | |
1917 | WPARAM fwKeys = wParam; | |
1918 | ||
1919 | switch( Msg ) { | |
18d715bd | 1920 | case WM_CLOSE: |
1921 | { | |
1922 | // Delete view from map of views | |
1923 | ViewerTest::RemoveView(FindViewIdByWindowHandle(hwnd)); | |
1924 | return 0; | |
1925 | } | |
1926 | break; | |
1927 | case WM_ACTIVATE: | |
1928 | if(LOWORD(wParam) == WA_CLICKACTIVE || LOWORD(wParam) == WA_ACTIVE | |
1929 | || ViewerTest::CurrentView().IsNull()) | |
1930 | { | |
1931 | // Activate inactive window | |
1932 | if(GetWindowHandle(VT_GetWindow()) != hwnd) | |
1933 | { | |
1934 | ActivateView (FindViewIdByWindowHandle(hwnd)); | |
1935 | } | |
1936 | } | |
1937 | break; | |
7fd59977 | 1938 | case WM_LBUTTONUP: |
8abada55 | 1939 | if (!DragFirst) |
7fd59977 | 1940 | { |
1941 | HDC hdc = GetDC( hwnd ); | |
7fd59977 | 1942 | SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) ); |
1943 | SetROP2( hdc, R2_NOT ); | |
4fe56619 | 1944 | Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion ); |
7fd59977 | 1945 | ReleaseDC( hwnd, hdc ); |
8abada55 | 1946 | VT_ProcessButton1Release (fwKeys & MK_SHIFT); |
7fd59977 | 1947 | } |
8abada55 | 1948 | IsDragged = Standard_False; |
7fd59977 | 1949 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); |
1950 | ||
1951 | case WM_LBUTTONDOWN: | |
1952 | if( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) ) | |
1953 | { | |
1954 | IsDragged = Standard_True; | |
1955 | DragFirst = Standard_True; | |
4fe56619 | 1956 | X_ButtonPress = LOWORD(lParam); |
1957 | Y_ButtonPress = HIWORD(lParam); | |
7fd59977 | 1958 | } |
1959 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
1960 | ||
1961 | break; | |
1962 | ||
1963 | case WM_MOUSEMOVE: | |
1964 | if( IsDragged ) | |
1965 | { | |
1966 | HDC hdc = GetDC( hwnd ); | |
1967 | ||
1968 | HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) ); | |
1969 | SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) ); | |
1970 | SetROP2( hdc, R2_NOT ); | |
1971 | ||
1972 | if( !DragFirst ) | |
4fe56619 | 1973 | Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion ); |
7fd59977 | 1974 | |
1975 | DragFirst = Standard_False; | |
4fe56619 | 1976 | X_Motion = LOWORD(lParam); |
1977 | Y_Motion = HIWORD(lParam); | |
7fd59977 | 1978 | |
4fe56619 | 1979 | Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion ); |
7fd59977 | 1980 | |
1981 | SelectObject( hdc, anObj ); | |
1982 | ||
1983 | ReleaseDC( hwnd, hdc ); | |
1984 | } | |
1985 | else | |
1986 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
1987 | break; | |
1988 | ||
1989 | default: | |
1990 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
1991 | } | |
1992 | return 0; | |
1993 | } | |
1994 | return ViewerWindowProc( hwnd, Msg, wParam, lParam ); | |
1995 | } | |
1996 | ||
1997 | ||
1998 | static LRESULT WINAPI ViewerWindowProc( HWND hwnd, | |
1999 | UINT Msg, | |
2000 | WPARAM wParam, | |
2001 | LPARAM lParam ) | |
2002 | { | |
7fd59977 | 2003 | static int Up = 1; |
f978241f | 2004 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); |
2005 | if (aView.IsNull()) | |
2006 | { | |
2007 | return DefWindowProc( hwnd, Msg, wParam, lParam ); | |
2008 | } | |
7fd59977 | 2009 | |
7fd59977 | 2010 | PAINTSTRUCT ps; |
2011 | ||
2012 | switch( Msg ) { | |
7fd59977 | 2013 | case WM_PAINT: |
7fd59977 | 2014 | BeginPaint(hwnd, &ps); |
2015 | EndPaint(hwnd, &ps); | |
4fe56619 | 2016 | VT_ProcessExpose(); |
7fd59977 | 2017 | break; |
2018 | ||
2019 | case WM_SIZE: | |
4fe56619 | 2020 | VT_ProcessConfigure(); |
7fd59977 | 2021 | break; |
f978241f | 2022 | case WM_MOVE: |
2023 | case WM_MOVING: | |
2024 | case WM_SIZING: | |
2025 | switch (aView->RenderingParams().StereoMode) | |
2026 | { | |
2027 | case Graphic3d_StereoMode_RowInterlaced: | |
2028 | case Graphic3d_StereoMode_ColumnInterlaced: | |
2029 | case Graphic3d_StereoMode_ChessBoard: | |
2030 | VT_ProcessConfigure(); // track window moves to reverse stereo pair | |
2031 | break; | |
2032 | default: | |
2033 | break; | |
2034 | } | |
2035 | break; | |
7fd59977 | 2036 | |
2037 | case WM_KEYDOWN: | |
4fe56619 | 2038 | if ((wParam != VK_SHIFT) && (wParam != VK_CONTROL)) |
2039 | { | |
7fd59977 | 2040 | char c[2]; |
2041 | c[0] = (char) wParam; | |
2042 | c[1] = '\0'; | |
b514beda | 2043 | if (wParam == VK_DELETE) |
2044 | { | |
2045 | c[0] = THE_KEY_DELETE; | |
2046 | } | |
4ca4bbe8 | 2047 | // comma |
2048 | else if (wParam == VK_OEM_COMMA) | |
2049 | { | |
2050 | c[0] = ','; | |
2051 | } | |
2052 | // dot | |
2053 | else if (wParam == VK_OEM_PERIOD) | |
2054 | { | |
2055 | c[0] = '.'; | |
2056 | } | |
f978241f | 2057 | else if (wParam == VK_DIVIDE) |
2058 | { | |
2059 | c[0] = '/'; | |
2060 | } | |
2061 | // dot | |
2062 | else if (wParam == VK_MULTIPLY) | |
2063 | { | |
2064 | c[0] = '*'; | |
2065 | } | |
4fe56619 | 2066 | VT_ProcessKeyPress (c); |
7fd59977 | 2067 | } |
2068 | break; | |
2069 | ||
2070 | case WM_LBUTTONUP: | |
2071 | case WM_MBUTTONUP: | |
2072 | case WM_RBUTTONUP: | |
7fd59977 | 2073 | Up = 1; |
4fe56619 | 2074 | VT_ProcessButton3Release(); |
7fd59977 | 2075 | break; |
2076 | ||
2077 | case WM_LBUTTONDOWN: | |
2078 | case WM_MBUTTONDOWN: | |
2079 | case WM_RBUTTONDOWN: | |
2080 | { | |
7fd59977 | 2081 | WPARAM fwKeys = wParam; |
2082 | ||
2083 | Up = 0; | |
2084 | ||
2085 | X_ButtonPress = LOWORD(lParam); | |
2086 | Y_ButtonPress = HIWORD(lParam); | |
2087 | ||
4fe56619 | 2088 | if (Msg == WM_LBUTTONDOWN) |
2089 | { | |
2090 | if (fwKeys & MK_CONTROL) | |
2091 | { | |
2092 | Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT)); | |
2093 | } | |
2094 | else | |
2095 | { | |
2096 | VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT)); | |
2097 | } | |
7fd59977 | 2098 | } |
4fe56619 | 2099 | else if (Msg == WM_RBUTTONDOWN) |
2100 | { | |
7fd59977 | 2101 | // Start rotation |
4fe56619 | 2102 | VT_ProcessButton3Press(); |
7fd59977 | 2103 | } |
2104 | } | |
2105 | break; | |
2106 | ||
f978241f | 2107 | case WM_MOUSEWHEEL: |
2108 | { | |
2109 | int aDelta = GET_WHEEL_DELTA_WPARAM (wParam); | |
2110 | if (wParam & MK_CONTROL) | |
2111 | { | |
2112 | if (aView->Camera()->IsStereo()) | |
2113 | { | |
2114 | Standard_Real aFocus = aView->Camera()->ZFocus() + (aDelta > 0 ? 0.05 : -0.05); | |
2115 | if (aFocus > 0.2 | |
2116 | && aFocus < 2.0) | |
2117 | { | |
2118 | aView->Camera()->SetZFocus (aView->Camera()->ZFocusType(), aFocus); | |
2119 | aView->Redraw(); | |
2120 | } | |
2121 | } | |
2122 | } | |
2123 | else | |
2124 | { | |
2125 | aView->Zoom (0, 0, aDelta / 40, aDelta / 40); | |
2126 | } | |
2127 | break; | |
2128 | } | |
2129 | ||
7fd59977 | 2130 | case WM_MOUSEMOVE: |
2131 | { | |
2132 | //cout << "\t WM_MOUSEMOVE" << endl; | |
2133 | WPARAM fwKeys = wParam; | |
2134 | X_Motion = LOWORD(lParam); | |
2135 | Y_Motion = HIWORD(lParam); | |
2136 | ||
2137 | if ( Up && | |
2138 | fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON ) ) { | |
2139 | Up = 0; | |
2140 | X_ButtonPress = LOWORD(lParam); | |
2141 | Y_ButtonPress = HIWORD(lParam); | |
2142 | ||
2143 | if ( fwKeys & MK_RBUTTON ) { | |
2144 | // Start rotation | |
4fe56619 | 2145 | VT_ProcessButton3Press(); |
7fd59977 | 2146 | } |
2147 | } | |
2148 | ||
2149 | if ( fwKeys & MK_CONTROL ) { | |
2150 | if ( fwKeys & MK_LBUTTON ) { | |
2151 | ProcessControlButton1Motion(); | |
2152 | } | |
2153 | else if ( fwKeys & MK_MBUTTON || | |
2154 | ((fwKeys&MK_LBUTTON) && | |
2155 | (fwKeys&MK_RBUTTON) ) ){ | |
4fe56619 | 2156 | VT_ProcessControlButton2Motion(); |
7fd59977 | 2157 | } |
2158 | else if ( fwKeys & MK_RBUTTON ) { | |
4fe56619 | 2159 | VT_ProcessControlButton3Motion(); |
7fd59977 | 2160 | } |
2161 | } | |
2162 | #ifdef BUG | |
2163 | else if ( fwKeys & MK_SHIFT ) { | |
2164 | if ( fwKeys & MK_MBUTTON || | |
2165 | ((fwKeys&MK_LBUTTON) && | |
2166 | (fwKeys&MK_RBUTTON) ) ) { | |
2167 | cout << "ProcessZClipMotion()" << endl; | |
2168 | ProcessZClipMotion(); | |
2169 | } | |
2170 | } | |
2171 | #endif | |
08398024 | 2172 | else if (GetWindowHandle (VT_GetWindow()) == hwnd) |
2173 | { | |
4fe56619 | 2174 | if ((fwKeys & MK_MBUTTON |
2175 | || ((fwKeys & MK_LBUTTON) && (fwKeys & MK_RBUTTON)))) | |
2176 | { | |
7fd59977 | 2177 | ProcessZClipMotion(); |
2178 | } | |
4fe56619 | 2179 | else |
2180 | { | |
2181 | VT_ProcessMotion(); | |
7fd59977 | 2182 | } |
08398024 | 2183 | } |
7fd59977 | 2184 | } |
2185 | break; | |
2186 | ||
2187 | default: | |
2188 | return( DefWindowProc( hwnd, Msg, wParam, lParam )); | |
2189 | } | |
2190 | return 0L; | |
7fd59977 | 2191 | } |
2192 | ||
2193 | ||
2194 | ||
2195 | ||
2196 | //============================================================================== | |
2197 | //function : ViewerMainLoop | |
2198 | //purpose : Get a Event on the view and dispatch it | |
2199 | //============================================================================== | |
2200 | ||
2201 | ||
8263fcd3 | 2202 | int ViewerMainLoop(Standard_Integer argc, const char** argv) |
7fd59977 | 2203 | { |
7fd59977 | 2204 | Ppick = (argc > 0)? 1 : 0; |
2205 | Pargc = argc; | |
2206 | Pargv = argv; | |
2207 | ||
2208 | if ( Ppick ) { | |
2209 | MSG msg; | |
2210 | msg.wParam = 1; | |
2211 | ||
2212 | cout << "Start picking" << endl; | |
2213 | ||
7fd59977 | 2214 | while ( Ppick == 1 ) { |
4fe56619 | 2215 | // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0 |
7fd59977 | 2216 | if (GetMessage(&msg, NULL, 0, 0) ) { |
2217 | TranslateMessage(&msg); | |
2218 | DispatchMessage(&msg); | |
2219 | } | |
2220 | } | |
2221 | ||
2222 | cout << "Picking done" << endl; | |
2223 | } | |
2224 | ||
2225 | return Ppick; | |
2226 | } | |
2227 | ||
4fe56619 | 2228 | #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX) |
7fd59977 | 2229 | |
2230 | int min( int a, int b ) | |
2231 | { | |
2232 | if( a<b ) | |
2233 | return a; | |
2234 | else | |
2235 | return b; | |
2236 | } | |
2237 | ||
2238 | int max( int a, int b ) | |
2239 | { | |
2240 | if( a>b ) | |
2241 | return a; | |
2242 | else | |
2243 | return b; | |
2244 | } | |
2245 | ||
2246 | int ViewerMainLoop(Standard_Integer argc, const char** argv) | |
2247 | ||
4269bd1b | 2248 | { |
18d715bd | 2249 | static XEvent aReport; |
2250 | Standard_Boolean pick = argc > 0; | |
2251 | Display *aDisplay = GetDisplayConnection()->GetDisplay(); | |
2252 | XNextEvent (aDisplay, &aReport); | |
7fd59977 | 2253 | |
18d715bd | 2254 | // Handle event for the chosen display connection |
2255 | switch (aReport.type) { | |
2256 | case ClientMessage: | |
2257 | { | |
eb1ebea4 | 2258 | if((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW)) |
18d715bd | 2259 | { |
2260 | // Close the window | |
2261 | ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window)); | |
2262 | } | |
2263 | } | |
2264 | return 0; | |
2265 | case FocusIn: | |
2266 | { | |
2267 | // Activate inactive view | |
2268 | Window aWindow = GetWindowHandle(VT_GetWindow()); | |
2269 | if(aWindow != aReport.xfocus.window) | |
2270 | { | |
2271 | ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window)); | |
2272 | } | |
2273 | } | |
2274 | break; | |
7fd59977 | 2275 | case Expose: |
2276 | { | |
4fe56619 | 2277 | VT_ProcessExpose(); |
7fd59977 | 2278 | } |
2279 | break; | |
2280 | case ConfigureNotify: | |
2281 | { | |
4fe56619 | 2282 | VT_ProcessConfigure(); |
7fd59977 | 2283 | } |
2284 | break; | |
2285 | case KeyPress: | |
2286 | { | |
2287 | ||
2288 | KeySym ks_ret ; | |
2289 | char buf_ret[11] ; | |
2290 | int ret_len ; | |
2291 | XComposeStatus status_in_out; | |
2292 | ||
18d715bd | 2293 | ret_len = XLookupString( ( XKeyEvent *)&aReport , |
7fd59977 | 2294 | (char *) buf_ret , 10 , |
2295 | &ks_ret , &status_in_out ) ; | |
2296 | ||
2297 | ||
2298 | buf_ret[ret_len] = '\0' ; | |
2299 | ||
4fe56619 | 2300 | if (ret_len) |
2301 | { | |
2302 | VT_ProcessKeyPress (buf_ret); | |
7fd59977 | 2303 | } |
2304 | } | |
2305 | break; | |
2306 | case ButtonPress: | |
7fd59977 | 2307 | { |
18d715bd | 2308 | X_ButtonPress = aReport.xbutton.x; |
2309 | Y_ButtonPress = aReport.xbutton.y; | |
7fd59977 | 2310 | |
18d715bd | 2311 | if (aReport.xbutton.button == Button1) |
4fe56619 | 2312 | { |
18d715bd | 2313 | if (aReport.xbutton.state & ControlMask) |
4fe56619 | 2314 | { |
18d715bd | 2315 | pick = VT_ProcessButton1Press (argc, argv, pick, (aReport.xbutton.state & ShiftMask)); |
4fe56619 | 2316 | } |
7fd59977 | 2317 | else |
2318 | { | |
2319 | IsDragged = Standard_True; | |
7fd59977 | 2320 | DragFirst = Standard_True; |
2321 | } | |
4fe56619 | 2322 | } |
18d715bd | 2323 | else if (aReport.xbutton.button == Button3) |
4fe56619 | 2324 | { |
7fd59977 | 2325 | // Start rotation |
4fe56619 | 2326 | VT_ProcessButton3Press(); |
2327 | } | |
7fd59977 | 2328 | } |
2329 | break; | |
2330 | case ButtonRelease: | |
2331 | { | |
7fd59977 | 2332 | if( IsDragged ) |
2333 | { | |
2334 | if( !DragFirst ) | |
2335 | { | |
2336 | Aspect_Handle aWindow = VT_GetWindow()->XWindow(); | |
18d715bd | 2337 | GC gc = XCreateGC( aDisplay, aWindow, 0, 0 ); |
2338 | XDrawRectangle( aDisplay, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) ); | |
7fd59977 | 2339 | } |
2340 | ||
2341 | Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext(); | |
2342 | if( aContext.IsNull() ) | |
2343 | { | |
2344 | cout << "The context is null. Please use vinit before createmesh" << endl; | |
2345 | return 0; | |
2346 | } | |
2347 | ||
18d715bd | 2348 | Standard_Boolean ShiftPressed = ( aReport.xbutton.state & ShiftMask ); |
2349 | if( aReport.xbutton.button==1 ) | |
7fd59977 | 2350 | if( DragFirst ) |
2351 | if( ShiftPressed ) | |
2352 | { | |
2353 | aContext->ShiftSelect(); | |
7fd59977 | 2354 | } |
2355 | else | |
2356 | { | |
2357 | aContext->Select(); | |
7fd59977 | 2358 | } |
2359 | else | |
2360 | if( ShiftPressed ) | |
2361 | { | |
4fe56619 | 2362 | aContext->ShiftSelect( min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), |
2363 | max( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ), | |
7fd59977 | 2364 | ViewerTest::CurrentView()); |
7fd59977 | 2365 | } |
2366 | else | |
2367 | { | |
4fe56619 | 2368 | aContext->Select( min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), |
2369 | max( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ), | |
7fd59977 | 2370 | ViewerTest::CurrentView() ); |
7fd59977 | 2371 | } |
2372 | else | |
4fe56619 | 2373 | VT_ProcessButton3Release(); |
7fd59977 | 2374 | |
2375 | IsDragged = Standard_False; | |
2376 | } | |
2377 | else | |
4fe56619 | 2378 | VT_ProcessButton3Release(); |
7fd59977 | 2379 | } |
2380 | break; | |
2381 | case MotionNotify: | |
2382 | { | |
08398024 | 2383 | if (GetWindowHandle (VT_GetWindow()) != aReport.xmotion.window) |
2384 | { | |
2385 | break; | |
2386 | } | |
7fd59977 | 2387 | if( IsDragged ) |
2388 | { | |
2389 | Aspect_Handle aWindow = VT_GetWindow()->XWindow(); | |
18d715bd | 2390 | GC gc = XCreateGC( aDisplay, aWindow, 0, 0 ); |
2391 | XSetFunction( aDisplay, gc, GXinvert ); | |
7fd59977 | 2392 | |
2393 | if( !DragFirst ) | |
18d715bd | 2394 | XDrawRectangle(aDisplay, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) ); |
7fd59977 | 2395 | |
18d715bd | 2396 | X_Motion = aReport.xmotion.x; |
2397 | Y_Motion = aReport.xmotion.y; | |
7fd59977 | 2398 | DragFirst = Standard_False; |
2399 | ||
18d715bd | 2400 | XDrawRectangle( aDisplay, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) ); |
7fd59977 | 2401 | } |
2402 | else | |
2403 | { | |
18d715bd | 2404 | X_Motion = aReport.xmotion.x; |
2405 | Y_Motion = aReport.xmotion.y; | |
7fd59977 | 2406 | |
18d715bd | 2407 | // remove all the ButtonMotionMaskr |
2408 | while( XCheckMaskEvent( aDisplay, ButtonMotionMask, &aReport) ) ; | |
7fd59977 | 2409 | |
18d715bd | 2410 | if ( ZClipIsOn && aReport.xmotion.state & ShiftMask ) { |
7fd59977 | 2411 | if ( Abs(X_Motion - X_ButtonPress) > 2 ) { |
2412 | ||
2413 | Quantity_Length VDX, VDY; | |
2414 | ||
2415 | ViewerTest::CurrentView()->Size(VDX,VDY); | |
2416 | Standard_Real VDZ =0 ; | |
2417 | VDZ = ViewerTest::CurrentView()->ZSize(); | |
2418 | ||
7fd59977 | 2419 | printf("%f,%f,%f\n", VDX, VDY, VDZ); |
2420 | ||
2421 | Quantity_Length dx = 0 ; | |
2422 | dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress); | |
2423 | ||
2424 | cout << dx << endl; | |
2425 | ||
2426 | dx = dx / VDX * VDZ; | |
2427 | ||
2428 | cout << dx << endl; | |
2429 | ||
7fd59977 | 2430 | ViewerTest::CurrentView()->Redraw(); |
2431 | } | |
2432 | } | |
2433 | ||
18d715bd | 2434 | if ( aReport.xmotion.state & ControlMask ) { |
2435 | if ( aReport.xmotion.state & Button1Mask ) { | |
7fd59977 | 2436 | ProcessControlButton1Motion(); |
2437 | } | |
18d715bd | 2438 | else if ( aReport.xmotion.state & Button2Mask ) { |
4fe56619 | 2439 | VT_ProcessControlButton2Motion(); |
7fd59977 | 2440 | } |
18d715bd | 2441 | else if ( aReport.xmotion.state & Button3Mask ) { |
4fe56619 | 2442 | VT_ProcessControlButton3Motion(); |
7fd59977 | 2443 | } |
2444 | } | |
4fe56619 | 2445 | else |
2446 | { | |
2447 | VT_ProcessMotion(); | |
7fd59977 | 2448 | } |
2449 | } | |
2450 | } | |
2451 | break; | |
2452 | } | |
7fd59977 | 2453 | return pick; |
2454 | } | |
2455 | ||
2456 | //============================================================================== | |
2457 | //function : VProcessEvents | |
2458 | //purpose : call by Tk_CreateFileHandler() to be able to manage the | |
2459 | // event in the Viewer window | |
2460 | //============================================================================== | |
2461 | ||
2462 | static void VProcessEvents(ClientData,int) | |
2463 | { | |
18d715bd | 2464 | NCollection_Vector<int> anEventNumbers; |
2465 | // Get number of messages from every display | |
2466 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator | |
2467 | anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next()) | |
2468 | { | |
2469 | anEventNumbers.Append(XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay())); | |
4269bd1b | 2470 | } |
18d715bd | 2471 | // Handle events for every display |
2472 | int anEventIter = 0; | |
2473 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator | |
2474 | anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next(), anEventIter++) | |
2475 | { | |
4269bd1b | 2476 | for (int i = 0; i < anEventNumbers.Value(anEventIter) && |
18d715bd | 2477 | XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()) > 0; ++i) |
2478 | { | |
2479 | SetDisplayConnection (anIter.Key2()->GetDisplayConnection()); | |
2480 | int anEventResult = ViewerMainLoop( 0, NULL); | |
2481 | // If window is closed or context was not found finish current event processing loop | |
2482 | if (!anEventResult) | |
2483 | return; | |
2484 | } | |
7fd59977 | 2485 | } |
4269bd1b | 2486 | |
18d715bd | 2487 | SetDisplayConnection (ViewerTest::GetAISContext()->CurrentViewer()->Driver()->GetDisplayConnection()); |
4269bd1b | 2488 | |
7fd59977 | 2489 | } |
2490 | #endif | |
2491 | ||
2492 | //============================================================================== | |
2493 | //function : OSWindowSetup | |
2494 | //purpose : Setup for the X11 window to be able to cath the event | |
2495 | //============================================================================== | |
2496 | ||
2497 | ||
2498 | static void OSWindowSetup() | |
2499 | { | |
4fe56619 | 2500 | #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) |
7fd59977 | 2501 | // X11 |
2502 | ||
2503 | Window window = VT_GetWindow()->XWindow(); | |
18d715bd | 2504 | SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection()); |
2505 | Display *aDisplay = GetDisplayConnection()->GetDisplay(); | |
2506 | XSynchronize(aDisplay, 1); | |
7fd59977 | 2507 | |
2508 | // X11 : For keyboard on SUN | |
2509 | XWMHints wmhints; | |
2510 | wmhints.flags = InputHint; | |
2511 | wmhints.input = 1; | |
2512 | ||
18d715bd | 2513 | XSetWMHints( aDisplay, window, &wmhints); |
7fd59977 | 2514 | |
18d715bd | 2515 | XSelectInput( aDisplay, window, ExposureMask | KeyPressMask | |
7fd59977 | 2516 | ButtonPressMask | ButtonReleaseMask | |
2517 | StructureNotifyMask | | |
2518 | PointerMotionMask | | |
2519 | Button1MotionMask | Button2MotionMask | | |
18d715bd | 2520 | Button3MotionMask | FocusChangeMask |
7fd59977 | 2521 | ); |
18d715bd | 2522 | Atom aDeleteWindowAtom = GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW); |
2523 | XSetWMProtocols(aDisplay, window, &aDeleteWindowAtom, 1); | |
7fd59977 | 2524 | |
18d715bd | 2525 | XSynchronize(aDisplay, 0); |
7fd59977 | 2526 | |
2527 | #else | |
2528 | // WNT | |
2529 | #endif | |
2530 | ||
2531 | } | |
2532 | ||
7fd59977 | 2533 | //============================================================================== |
2534 | //function : VFit | |
2535 | ||
2536 | //purpose : Fitall, no DRAW arguments | |
2537 | //Draw arg : No args | |
2538 | //============================================================================== | |
2539 | ||
b586500b | 2540 | static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgc, const char** theArgv) |
7fd59977 | 2541 | { |
b586500b | 2542 | if (theArgc > 2) |
2543 | { | |
2544 | std::cout << "Wrong number of arguments! Use: vfit [-selected]" << std::endl; | |
2545 | } | |
2546 | ||
7fd59977 | 2547 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); |
b586500b | 2548 | |
2549 | if (theArgc == 2) | |
2550 | { | |
2551 | TCollection_AsciiString anArg (theArgv[1]); | |
2552 | anArg.LowerCase(); | |
2553 | if (anArg == "-selected") | |
2554 | { | |
fb64064b | 2555 | ViewerTest::GetAISContext()->FitSelected (aView); |
b586500b | 2556 | return 0; |
2557 | } | |
2558 | } | |
fb64064b | 2559 | if (aView.IsNull() == Standard_False) { |
b586500b | 2560 | |
7fd59977 | 2561 | aView->FitAll(); |
2562 | } | |
2563 | return 0; | |
2564 | } | |
2565 | ||
6262a303 | 2566 | //======================================================================= |
2567 | //function : VFitArea | |
2568 | //purpose : Fit view to show area located between two points | |
2569 | // : given in world 2D or 3D coordinates. | |
2570 | //======================================================================= | |
2571 | static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
2572 | { | |
2573 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2574 | if (aView.IsNull()) | |
2575 | { | |
2576 | std::cerr << theArgVec[0] << "Error: No active view.\n"; | |
2577 | return 1; | |
2578 | } | |
2579 | ||
2580 | // Parse arguments. | |
2581 | gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0); | |
2582 | gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0); | |
2583 | ||
2584 | if (theArgNb == 5) | |
2585 | { | |
2586 | aWorldPnt1.SetX (Draw::Atof (theArgVec[1])); | |
2587 | aWorldPnt1.SetY (Draw::Atof (theArgVec[2])); | |
2588 | aWorldPnt2.SetX (Draw::Atof (theArgVec[3])); | |
2589 | aWorldPnt2.SetY (Draw::Atof (theArgVec[4])); | |
2590 | } | |
2591 | else if (theArgNb == 7) | |
2592 | { | |
2593 | aWorldPnt1.SetX (Draw::Atof (theArgVec[1])); | |
2594 | aWorldPnt1.SetY (Draw::Atof (theArgVec[2])); | |
2595 | aWorldPnt1.SetZ (Draw::Atof (theArgVec[3])); | |
2596 | aWorldPnt2.SetX (Draw::Atof (theArgVec[4])); | |
2597 | aWorldPnt2.SetY (Draw::Atof (theArgVec[5])); | |
2598 | aWorldPnt2.SetZ (Draw::Atof (theArgVec[6])); | |
2599 | } | |
2600 | else | |
2601 | { | |
2602 | std::cerr << theArgVec[0] << "Error: Invalid number of arguments.\n"; | |
2603 | theDI.PrintHelp(theArgVec[0]); | |
2604 | return 1; | |
2605 | } | |
2606 | ||
2607 | // Convert model coordinates to view space | |
2608 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); | |
2609 | gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1); | |
2610 | gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2); | |
2611 | ||
2612 | // Determine fit area | |
2613 | gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y())); | |
2614 | gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y())); | |
2615 | ||
2616 | Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner); | |
2617 | ||
2618 | if (aDiagonal < Precision::Confusion()) | |
2619 | { | |
2620 | std::cerr << theArgVec[0] << "Error: view area is too small.\n"; | |
2621 | return 1; | |
2622 | } | |
2623 | ||
2624 | aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y()); | |
2625 | return 0; | |
2626 | } | |
2627 | ||
7fd59977 | 2628 | //============================================================================== |
2629 | //function : VZFit | |
2630 | //purpose : ZFitall, no DRAW arguments | |
2631 | //Draw arg : No args | |
2632 | //============================================================================== | |
197ac94e | 2633 | static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec) |
7fd59977 | 2634 | { |
197ac94e | 2635 | const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView(); |
2636 | ||
2637 | if (aCurrentView.IsNull()) | |
2638 | { | |
2639 | std::cout << theArgVec[0] << ": Call vinit before this command, please.\n"; | |
2640 | return 1; | |
2641 | } | |
2642 | ||
2643 | if (theArgsNb == 1) | |
2644 | { | |
6bc6a6fc | 2645 | aCurrentView->View()->ZFitAll(); |
197ac94e | 2646 | aCurrentView->Redraw(); |
2647 | return 0; | |
2648 | } | |
2649 | ||
2650 | Standard_Real aScale = 1.0; | |
2651 | ||
2652 | if (theArgsNb >= 2) | |
2653 | { | |
2654 | aScale = Draw::Atoi (theArgVec[1]); | |
2655 | } | |
2656 | ||
6bc6a6fc | 2657 | aCurrentView->View()->ZFitAll (aScale); |
197ac94e | 2658 | aCurrentView->Redraw(); |
7fd59977 | 2659 | |
197ac94e | 2660 | return 0; |
2661 | } | |
7fd59977 | 2662 | |
197ac94e | 2663 | //============================================================================== |
2664 | //function : VRepaint | |
2665 | //purpose : | |
2666 | //============================================================================== | |
2667 | static int VRepaint (Draw_Interpretor& , Standard_Integer , const char** ) | |
7fd59977 | 2668 | { |
2669 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
2670 | if ( !V.IsNull() ) V->Redraw(); return 0; | |
2671 | } | |
2672 | ||
7fd59977 | 2673 | //============================================================================== |
2674 | //function : VClear | |
2675 | //purpose : Remove all the object from the viewer | |
2676 | //Draw arg : No args | |
2677 | //============================================================================== | |
2678 | ||
2679 | static int VClear(Draw_Interpretor& , Standard_Integer , const char** ) | |
2680 | { | |
2681 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
2682 | if(!V.IsNull()) | |
2683 | ViewerTest::Clear(); | |
2684 | return 0; | |
2685 | } | |
2686 | ||
2687 | //============================================================================== | |
2688 | //function : VPick | |
2689 | //purpose : | |
2690 | //============================================================================== | |
2691 | ||
2692 | static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2693 | { if (ViewerTest::CurrentView().IsNull() ) return 1; | |
2694 | ||
2695 | if ( argc < 4 ) { | |
2696 | di << argv[0] << "Invalid number of arguments" << "\n"; | |
2697 | return 1; | |
2698 | } | |
2699 | ||
2700 | while (ViewerMainLoop( argc, argv)) { | |
2701 | } | |
2702 | ||
2703 | return 0; | |
2704 | } | |
2705 | ||
7fd59977 | 2706 | //============================================================================== |
2707 | //function : VSetBg | |
2708 | //purpose : Load image as background | |
2709 | //============================================================================== | |
2710 | ||
2711 | static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2712 | { | |
2713 | if (argc < 2 || argc > 3) | |
2714 | { | |
2715 | di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n"; | |
f8b2ed36 | 2716 | di << "filltype can be one of CENTERED, TILED, STRETCH, NONE" << "\n"; |
7fd59977 | 2717 | return 1; |
2718 | } | |
2719 | ||
2720 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
2721 | if(AISContext.IsNull()) | |
2722 | { | |
2723 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
2724 | return 1; | |
2725 | } | |
2726 | ||
2727 | Aspect_FillMethod aFillType = Aspect_FM_CENTERED; | |
2728 | if (argc == 3) | |
2729 | { | |
2730 | const char* szType = argv[2]; | |
2731 | if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; | |
2732 | else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; | |
2733 | else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; | |
2734 | else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; | |
2735 | else | |
2736 | { | |
2737 | di << "Wrong fill type : " << szType << "\n"; | |
2738 | di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; | |
2739 | return 1; | |
2740 | } | |
2741 | } | |
2742 | ||
2743 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
2744 | V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True); | |
2745 | ||
2746 | return 0; | |
2747 | } | |
2748 | ||
f8b2ed36 | 2749 | //============================================================================== |
2750 | //function : VSetBgMode | |
2751 | //purpose : Change background image fill type | |
2752 | //============================================================================== | |
2753 | ||
2754 | static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2755 | { | |
2756 | if (argc != 2) | |
2757 | { | |
2758 | di << "Usage : " << argv[0] << " filltype : Change background image mode" << "\n"; | |
2759 | di << "filltype must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; | |
2760 | return 1; | |
2761 | } | |
2762 | ||
2763 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
2764 | if(AISContext.IsNull()) | |
2765 | { | |
2766 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
2767 | return 1; | |
2768 | } | |
1d47d8d0 | 2769 | Aspect_FillMethod aFillType = Aspect_FM_NONE; |
2770 | const char* szType = argv[1]; | |
2771 | if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; | |
2772 | else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; | |
2773 | else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; | |
2774 | else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; | |
2775 | else | |
f8b2ed36 | 2776 | { |
1d47d8d0 | 2777 | di << "Wrong fill type : " << szType << "\n"; |
2778 | di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; | |
2779 | return 1; | |
f8b2ed36 | 2780 | } |
f8b2ed36 | 2781 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); |
2782 | V3dView->SetBgImageStyle(aFillType, Standard_True); | |
f8b2ed36 | 2783 | return 0; |
2784 | } | |
2785 | ||
7fd59977 | 2786 | //============================================================================== |
2787 | //function : VSetGradientBg | |
2788 | //purpose : Mount gradient background | |
2789 | //============================================================================== | |
2790 | static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2791 | { | |
2792 | if (argc != 8 ) | |
2793 | { | |
2794 | di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background" << "\n"; | |
2795 | di << "R1,G1,B1,R2,G2,B2 = [0..255]" << "\n"; | |
2796 | di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
2797 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
2798 | return 1; | |
2799 | } | |
2800 | ||
2801 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
2802 | if(AISContext.IsNull()) | |
2803 | { | |
2804 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
2805 | return 1; | |
2806 | } | |
2807 | if (argc == 8) | |
2808 | { | |
2809 | ||
91322f44 | 2810 | Standard_Real R1 = Draw::Atof(argv[1])/255.; |
2811 | Standard_Real G1 = Draw::Atof(argv[2])/255.; | |
2812 | Standard_Real B1 = Draw::Atof(argv[3])/255.; | |
7fd59977 | 2813 | Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB); |
2814 | ||
91322f44 | 2815 | Standard_Real R2 = Draw::Atof(argv[4])/255.; |
2816 | Standard_Real G2 = Draw::Atof(argv[5])/255.; | |
2817 | Standard_Real B2 = Draw::Atof(argv[6])/255.; | |
7fd59977 | 2818 | |
2819 | Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB); | |
91322f44 | 2820 | int aType = Draw::Atoi(argv[7]); |
7fd59977 | 2821 | if( aType < 0 || aType > 8 ) |
2822 | { | |
2823 | di << "Wrong fill type " << "\n"; | |
2824 | di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
2825 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
2826 | return 1; | |
2827 | } | |
2828 | ||
2829 | Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType); | |
2830 | ||
2831 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
2832 | V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1); | |
2833 | } | |
2834 | ||
2835 | return 0; | |
2836 | } | |
2837 | ||
f8b2ed36 | 2838 | //============================================================================== |
2839 | //function : VSetGradientBgMode | |
2840 | //purpose : Change gradient background fill style | |
2841 | //============================================================================== | |
2842 | static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2843 | { | |
2844 | if (argc != 2 ) | |
2845 | { | |
2846 | di << "Usage : " << argv[0] << " Type : Change gradient background fill type" << "\n"; | |
2847 | di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
2848 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
2849 | return 1; | |
2850 | } | |
2851 | ||
2852 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
2853 | if(AISContext.IsNull()) | |
2854 | { | |
2855 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
2856 | return 1; | |
2857 | } | |
2858 | if (argc == 2) | |
2859 | { | |
91322f44 | 2860 | int aType = Draw::Atoi(argv[1]); |
f8b2ed36 | 2861 | if( aType < 0 || aType > 8 ) |
2862 | { | |
2863 | di << "Wrong fill type " << "\n"; | |
2864 | di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n"; | |
2865 | di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n"; | |
2866 | return 1; | |
2867 | } | |
2868 | ||
2869 | Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType); | |
2870 | ||
2871 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
2872 | V3dView->SetBgGradientStyle( aMethod, 1 ); | |
2873 | } | |
2874 | ||
2875 | return 0; | |
2876 | } | |
2877 | ||
2878 | //============================================================================== | |
2879 | //function : VSetColorBg | |
2880 | //purpose : Set color background | |
2881 | //============================================================================== | |
2882 | static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2883 | { | |
2884 | if (argc != 4 ) | |
2885 | { | |
2886 | di << "Usage : " << argv[0] << " R G B : Set color background" << "\n"; | |
2887 | di << "R,G,B = [0..255]" << "\n"; | |
2888 | return 1; | |
2889 | } | |
2890 | ||
2891 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); | |
2892 | if(AISContext.IsNull()) | |
2893 | { | |
2894 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
2895 | return 1; | |
2896 | } | |
2897 | if (argc == 4) | |
2898 | { | |
2899 | ||
91322f44 | 2900 | Standard_Real R = Draw::Atof(argv[1])/255.; |
2901 | Standard_Real G = Draw::Atof(argv[2])/255.; | |
2902 | Standard_Real B = Draw::Atof(argv[3])/255.; | |
f8b2ed36 | 2903 | Quantity_Color aColor(R,G,B,Quantity_TOC_RGB); |
2904 | ||
2905 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
2906 | V3dView->SetBackgroundColor( aColor ); | |
2907 | V3dView->Update(); | |
2908 | } | |
2909 | ||
2910 | return 0; | |
2911 | } | |
2912 | ||
7fd59977 | 2913 | //============================================================================== |
2914 | //function : VScale | |
2915 | //purpose : View Scaling | |
2916 | //============================================================================== | |
2917 | ||
2918 | static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2919 | { | |
2920 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
2921 | if ( V3dView.IsNull() ) return 1; | |
2922 | ||
2923 | if ( argc != 4 ) { | |
2924 | di << argv[0] << "Invalid number of arguments" << "\n"; | |
2925 | return 1; | |
2926 | } | |
91322f44 | 2927 | V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) ); |
7fd59977 | 2928 | return 0; |
2929 | } | |
2930 | //============================================================================== | |
536d98e2 | 2931 | //function : VZBuffTrihedron |
2932 | //purpose : | |
7fd59977 | 2933 | //============================================================================== |
2934 | ||
536d98e2 | 2935 | static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/, |
2936 | Standard_Integer theArgNb, | |
2937 | const char** theArgVec) | |
7fd59977 | 2938 | { |
536d98e2 | 2939 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
2940 | if (aView.IsNull()) | |
2941 | { | |
2942 | std::cout << "Error: no active viewer!\n"; | |
2943 | return 1; | |
2944 | } | |
7fd59977 | 2945 | |
536d98e2 | 2946 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
7c8a8fcc | 2947 | |
536d98e2 | 2948 | Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER; |
2949 | V3d_TypeOfVisualization aVisType = V3d_ZBUFFER; | |
2950 | Quantity_Color aLabelsColor = Quantity_NOC_WHITE; | |
2951 | Quantity_Color anArrowColorX = Quantity_NOC_RED; | |
2952 | Quantity_Color anArrowColorY = Quantity_NOC_GREEN; | |
2953 | Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1; | |
2954 | Standard_Real aScale = 0.1; | |
2955 | Standard_Real aSizeRatio = 0.8; | |
2956 | Standard_Real anArrowDiam = 0.05; | |
2957 | Standard_Integer aNbFacets = 12; | |
2958 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
7c8a8fcc | 2959 | { |
536d98e2 | 2960 | Standard_CString anArg = theArgVec[anArgIter]; |
2961 | TCollection_AsciiString aFlag (anArg); | |
2962 | aFlag.LowerCase(); | |
2963 | if (anUpdateTool.parseRedrawMode (aFlag)) | |
7c8a8fcc | 2964 | { |
536d98e2 | 2965 | continue; |
2966 | } | |
2967 | else if (aFlag == "-on") | |
7c8a8fcc | 2968 | { |
536d98e2 | 2969 | continue; |
2970 | } | |
2971 | else if (aFlag == "-off") | |
7c8a8fcc | 2972 | { |
536d98e2 | 2973 | aView->TriedronErase(); |
2974 | return 0; | |
2975 | } | |
2976 | else if (aFlag == "-pos" | |
2977 | || aFlag == "-position" | |
2978 | || aFlag == "-corner") | |
7c8a8fcc | 2979 | { |
536d98e2 | 2980 | if (++anArgIter >= theArgNb) |
2981 | { | |
2982 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
2983 | return 1; | |
2984 | } | |
2985 | ||
2986 | TCollection_AsciiString aPosName (theArgVec[anArgIter]); | |
2987 | aPosName.LowerCase(); | |
2988 | if (aPosName == "center") | |
2989 | { | |
2990 | aPosition = Aspect_TOTP_CENTER; | |
2991 | } | |
2992 | else if (aPosName == "left_lower" | |
2993 | || aPosName == "lower_left" | |
2994 | || aPosName == "leftlower" | |
2995 | || aPosName == "lowerleft") | |
2996 | { | |
2997 | aPosition = Aspect_TOTP_LEFT_LOWER; | |
2998 | } | |
2999 | else if (aPosName == "left_upper" | |
3000 | || aPosName == "upper_left" | |
3001 | || aPosName == "leftupper" | |
3002 | || aPosName == "upperleft") | |
3003 | { | |
3004 | aPosition = Aspect_TOTP_LEFT_UPPER; | |
3005 | } | |
3006 | else if (aPosName == "right_lower" | |
3007 | || aPosName == "lower_right" | |
3008 | || aPosName == "rightlower" | |
3009 | || aPosName == "lowerright") | |
3010 | { | |
3011 | aPosition = Aspect_TOTP_RIGHT_LOWER; | |
3012 | } | |
3013 | else if (aPosName == "right_upper" | |
3014 | || aPosName == "upper_right" | |
3015 | || aPosName == "rightupper" | |
3016 | || aPosName == "upperright") | |
3017 | { | |
3018 | aPosition = Aspect_TOTP_RIGHT_UPPER; | |
3019 | } | |
3020 | else | |
3021 | { | |
3022 | std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'\n"; | |
3023 | return 1; | |
3024 | } | |
3025 | } | |
3026 | else if (aFlag == "-type") | |
7c8a8fcc | 3027 | { |
536d98e2 | 3028 | if (++anArgIter >= theArgNb) |
3029 | { | |
3030 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3031 | return 1; | |
3032 | } | |
3033 | ||
3034 | TCollection_AsciiString aTypeName (theArgVec[anArgIter]); | |
3035 | aTypeName.LowerCase(); | |
3036 | if (aTypeName == "wireframe" | |
3037 | || aTypeName == "wire") | |
3038 | { | |
3039 | aVisType = V3d_WIREFRAME; | |
3040 | } | |
3041 | else if (aTypeName == "zbuffer" | |
3042 | || aTypeName == "shaded") | |
3043 | { | |
3044 | aVisType = V3d_ZBUFFER; | |
3045 | } | |
3046 | else | |
3047 | { | |
3048 | std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'\n"; | |
3049 | } | |
3050 | } | |
3051 | else if (aFlag == "-scale") | |
7c8a8fcc | 3052 | { |
536d98e2 | 3053 | if (++anArgIter >= theArgNb) |
3054 | { | |
3055 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3056 | return 1; | |
3057 | } | |
3058 | ||
3059 | aScale = Draw::Atof (theArgVec[anArgIter]); | |
7c8a8fcc | 3060 | } |
536d98e2 | 3061 | else if (aFlag == "-size" |
3062 | || aFlag == "-sizeratio") | |
3063 | { | |
3064 | if (++anArgIter >= theArgNb) | |
3065 | { | |
3066 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3067 | return 1; | |
3068 | } | |
7c8a8fcc | 3069 | |
536d98e2 | 3070 | aSizeRatio = Draw::Atof (theArgVec[anArgIter]); |
3071 | } | |
3072 | else if (aFlag == "-arrowdiam" | |
3073 | || aFlag == "-arrowdiameter") | |
3074 | { | |
3075 | if (++anArgIter >= theArgNb) | |
3076 | { | |
3077 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3078 | return 1; | |
3079 | } | |
7c8a8fcc | 3080 | |
536d98e2 | 3081 | anArrowDiam = Draw::Atof (theArgVec[anArgIter]); |
3082 | } | |
3083 | else if (aFlag == "-nbfacets") | |
3084 | { | |
3085 | if (++anArgIter >= theArgNb) | |
3086 | { | |
3087 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3088 | return 1; | |
3089 | } | |
7c8a8fcc | 3090 | |
536d98e2 | 3091 | aNbFacets = Draw::Atoi (theArgVec[anArgIter]); |
3092 | } | |
3093 | else if (aFlag == "-colorlabel" | |
3094 | || aFlag == "-colorlabels") | |
7c8a8fcc | 3095 | { |
536d98e2 | 3096 | Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1, |
3097 | theArgVec + anArgIter + 1, | |
3098 | aLabelsColor); | |
3099 | if (aNbParsed == 0) | |
3100 | { | |
3101 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3102 | return 1; | |
3103 | } | |
3104 | anArgIter += aNbParsed; | |
7c8a8fcc | 3105 | } |
536d98e2 | 3106 | else if (aFlag == "-colorarrowx") |
7c8a8fcc | 3107 | { |
536d98e2 | 3108 | Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1, |
3109 | theArgVec + anArgIter + 1, | |
3110 | anArrowColorX); | |
3111 | if (aNbParsed == 0) | |
3112 | { | |
3113 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3114 | return 1; | |
3115 | } | |
3116 | anArgIter += aNbParsed; | |
3117 | } | |
3118 | else if (aFlag == "-colorarrowy") | |
7c8a8fcc | 3119 | { |
536d98e2 | 3120 | Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1, |
3121 | theArgVec + anArgIter + 1, | |
3122 | anArrowColorY); | |
3123 | if (aNbParsed == 0) | |
3124 | { | |
3125 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3126 | return 1; | |
3127 | } | |
3128 | anArgIter += aNbParsed; | |
3129 | } | |
3130 | else if (aFlag == "-colorarrowz") | |
7c8a8fcc | 3131 | { |
536d98e2 | 3132 | Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1, |
3133 | theArgVec + anArgIter + 1, | |
3134 | anArrowColorZ); | |
3135 | if (aNbParsed == 0) | |
3136 | { | |
3137 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
3138 | return 1; | |
3139 | } | |
3140 | anArgIter += aNbParsed; | |
3141 | } | |
3142 | else | |
3143 | { | |
3144 | std::cerr << "Error: wrong syntax at '" << anArg << "'\n"; | |
7c8a8fcc | 3145 | return 1; |
3146 | } | |
7c8a8fcc | 3147 | } |
3148 | ||
536d98e2 | 3149 | aView->ZBufferTriedronSetup (anArrowColorX.Name(), anArrowColorY.Name(), anArrowColorZ.Name(), |
3150 | aSizeRatio, anArrowDiam, aNbFacets); | |
3151 | aView->TriedronDisplay (aPosition, aLabelsColor.Name(), aScale, aVisType); | |
3152 | aView->View()->ZFitAll(); | |
7fd59977 | 3153 | return 0; |
3154 | } | |
3155 | ||
3156 | //============================================================================== | |
3157 | //function : VRotate | |
3158 | //purpose : Camera Rotating | |
3159 | //============================================================================== | |
3160 | ||
4af098ba | 3161 | static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec) |
3162 | { | |
3163 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
3164 | if (aView.IsNull()) | |
3165 | { | |
3166 | std::cout << "No active view!\n"; | |
7fd59977 | 3167 | return 1; |
3168 | } | |
3169 | ||
4af098ba | 3170 | Standard_Boolean hasFlags = Standard_False; |
3171 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
3172 | { | |
3173 | Standard_CString anArg (theArgVec[anArgIter]); | |
3174 | TCollection_AsciiString aFlag (anArg); | |
3175 | aFlag.LowerCase(); | |
3176 | if (aFlag == "-mousestart" | |
3177 | || aFlag == "-mousefrom") | |
3178 | { | |
3179 | hasFlags = Standard_True; | |
3180 | if (anArgIter + 2 >= theArgNb) | |
3181 | { | |
3182 | std::cout << "Error: wrong syntax at '" << anArg << "'\n"; | |
3183 | return 1; | |
3184 | } | |
3185 | ||
3186 | Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]); | |
3187 | Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]); | |
3188 | aView->StartRotation (anX, anY); | |
3189 | } | |
3190 | else if (aFlag == "-mousemove") | |
3191 | { | |
3192 | hasFlags = Standard_True; | |
3193 | if (anArgIter + 2 >= theArgNb) | |
3194 | { | |
3195 | std::cout << "Error: wrong syntax at '" << anArg << "'\n"; | |
3196 | return 1; | |
3197 | } | |
3198 | ||
3199 | Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]); | |
3200 | Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]); | |
3201 | aView->Rotation (anX, anY); | |
3202 | } | |
3203 | else if (theArgNb != 4 | |
3204 | && theArgNb != 7) | |
3205 | { | |
3206 | std::cout << "Error: wrong syntax at '" << anArg << "'\n"; | |
3207 | return 1; | |
3208 | } | |
3209 | } | |
3210 | ||
3211 | if (hasFlags) | |
3212 | { | |
7fd59977 | 3213 | return 0; |
4af098ba | 3214 | } |
3215 | else if (theArgNb == 4) | |
3216 | { | |
3217 | Standard_Real anAX = Draw::Atof (theArgVec[1]); | |
3218 | Standard_Real anAY = Draw::Atof (theArgVec[2]); | |
3219 | Standard_Real anAZ = Draw::Atof (theArgVec[3]); | |
3220 | aView->Rotate (anAX, anAY, anAZ); | |
3221 | return 0; | |
3222 | } | |
3223 | else if (theArgNb == 7) | |
3224 | { | |
3225 | Standard_Real anAX = Draw::Atof (theArgVec[1]); | |
3226 | Standard_Real anAY = Draw::Atof (theArgVec[2]); | |
3227 | Standard_Real anAZ = Draw::Atof (theArgVec[3]); | |
3228 | ||
3229 | Standard_Real anX = Draw::Atof (theArgVec[4]); | |
3230 | Standard_Real anY = Draw::Atof (theArgVec[5]); | |
3231 | Standard_Real anZ = Draw::Atof (theArgVec[6]); | |
3232 | ||
3233 | aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ); | |
7fd59977 | 3234 | return 0; |
7fd59977 | 3235 | } |
4af098ba | 3236 | |
3237 | std::cout << "Error: Invalid number of arguments\n"; | |
3238 | return 1; | |
7fd59977 | 3239 | } |
3240 | ||
3241 | //============================================================================== | |
3242 | //function : VZoom | |
3243 | //purpose : View zoom in / out (relative to current zoom) | |
3244 | //============================================================================== | |
3245 | ||
3246 | static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
3247 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
3248 | if ( V3dView.IsNull() ) { | |
3249 | return 1; | |
3250 | } | |
3251 | ||
3252 | if ( argc == 2 ) { | |
91322f44 | 3253 | Standard_Real coef = Draw::Atof(argv[1]); |
7fd59977 | 3254 | if ( coef <= 0.0 ) { |
3255 | di << argv[1] << "Invalid value" << "\n"; | |
3256 | return 1; | |
3257 | } | |
91322f44 | 3258 | V3dView->SetZoom( Draw::Atof(argv[1]) ); |
7fd59977 | 3259 | return 0; |
3260 | } else { | |
3261 | di << argv[0] << " Invalid number of arguments" << "\n"; | |
3262 | return 1; | |
3263 | } | |
3264 | } | |
3265 | ||
3266 | //============================================================================== | |
3267 | //function : VPan | |
3268 | //purpose : View panning (in pixels) | |
3269 | //============================================================================== | |
3270 | ||
3271 | static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
3272 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
3273 | if ( V3dView.IsNull() ) return 1; | |
3274 | ||
3275 | if ( argc == 3 ) { | |
91322f44 | 3276 | V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) ); |
7fd59977 | 3277 | return 0; |
3278 | } else { | |
3279 | di << argv[0] << " Invalid number of arguments" << "\n"; | |
3280 | return 1; | |
3281 | } | |
3282 | } | |
3283 | ||
49e1a5c7 | 3284 | //============================================================================== |
3285 | //function : VPlace | |
3286 | //purpose : Place the point (in pixels) at the center of the window | |
3287 | //============================================================================== | |
3288 | static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs) | |
3289 | { | |
3290 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
3291 | if (aView.IsNull()) | |
3292 | { | |
3293 | std::cerr << theArgs[0] << "Error: no active view." << std::endl; | |
3294 | return 1; | |
3295 | } | |
3296 | ||
3297 | if (theArgNb != 3) | |
3298 | { | |
3299 | std::cerr << theArgs[0] << "Error: invalid number of arguments." << std::endl; | |
3300 | return 1; | |
3301 | } | |
3302 | ||
3303 | aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale()); | |
3304 | ||
3305 | return 0; | |
3306 | } | |
7fd59977 | 3307 | |
3308 | //============================================================================== | |
3309 | //function : VExport | |
5cedc27f | 3310 | //purpose : Export the view to a vector graphic format (PS, EMF, PDF) |
7fd59977 | 3311 | //============================================================================== |
3312 | ||
3313 | static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
3314 | { | |
3315 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
5cedc27f K |
3316 | if (V3dView.IsNull()) |
3317 | return 1; | |
7fd59977 | 3318 | |
5cedc27f K |
3319 | if (argc == 1) |
3320 | { | |
3321 | std::cout << "Usage: " << argv[0] << " Filename [Format]\n"; | |
7fd59977 | 3322 | return 1; |
3323 | } | |
3324 | ||
5cedc27f K |
3325 | Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF; |
3326 | TCollection_AsciiString aFormatStr; | |
3327 | ||
3328 | TCollection_AsciiString aFileName (argv[1]); | |
3329 | Standard_Integer aLen = aFileName.Length(); | |
3330 | ||
3331 | if (argc > 2) | |
3332 | { | |
3333 | aFormatStr = TCollection_AsciiString (argv[2]); | |
3334 | } | |
3335 | else if (aLen >= 4) | |
3336 | { | |
3337 | if (aFileName.Value (aLen - 2) == '.') | |
3338 | { | |
3339 | aFormatStr = aFileName.SubString (aLen - 1, aLen); | |
3340 | } | |
3341 | else if (aFileName.Value (aLen - 3) == '.') | |
3342 | { | |
3343 | aFormatStr = aFileName.SubString (aLen - 2, aLen); | |
3344 | } | |
3345 | else | |
3346 | { | |
3347 | std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n"; | |
3348 | return 1; | |
3349 | } | |
3350 | } | |
3351 | else | |
3352 | { | |
3353 | std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n"; | |
3354 | return 1; | |
3355 | } | |
3356 | ||
3357 | aFormatStr.UpperCase(); | |
3358 | if (aFormatStr == "PS") | |
3359 | anExpFormat = Graphic3d_EF_PostScript; | |
3360 | else if (aFormatStr == "EPS") | |
3361 | anExpFormat = Graphic3d_EF_EnhPostScript; | |
3362 | else if (aFormatStr == "TEX") | |
3363 | anExpFormat = Graphic3d_EF_TEX; | |
3364 | else if (aFormatStr == "PDF") | |
3365 | anExpFormat = Graphic3d_EF_PDF; | |
3366 | else if (aFormatStr == "SVG") | |
3367 | anExpFormat = Graphic3d_EF_SVG; | |
3368 | else if (aFormatStr == "PGF") | |
3369 | anExpFormat = Graphic3d_EF_PGF; | |
3370 | else if (aFormatStr == "EMF") | |
3371 | anExpFormat = Graphic3d_EF_EMF; | |
3372 | else | |
3373 | { | |
3374 | std::cout << "Invalid export format '" << aFormatStr << "'\n"; | |
3375 | return 1; | |
3376 | } | |
3377 | ||
9753e6de | 3378 | try { |
3379 | if (!V3dView->View()->Export (argv[1], anExpFormat)) | |
3380 | { | |
3381 | di << "Error: export of image to " << aFormatStr << " failed!\n"; | |
3382 | } | |
3383 | } | |
3384 | catch (Standard_Failure) | |
5cedc27f | 3385 | { |
9753e6de | 3386 | di << "Error: export of image to " << aFormatStr << " failed"; |
3387 | di << " (exception: " << Standard_Failure::Caught()->GetMessageString() << ")"; | |
5cedc27f | 3388 | } |
7fd59977 | 3389 | return 0; |
3390 | } | |
3391 | ||
3392 | //============================================================================== | |
3393 | //function : VColorScale | |
3394 | //purpose : representation color scale | |
3395 | //============================================================================== | |
7fd59977 | 3396 | |
71215351 | 3397 | static Standard_Boolean checkColor (const TCollection_AsciiString& theRed, |
3398 | const TCollection_AsciiString& theGreen, | |
3399 | const TCollection_AsciiString& theBlue, | |
3400 | Standard_Real& theRedValue, | |
3401 | Standard_Real& theGreenValue, | |
3402 | Standard_Real& theBlueValue) | |
7fd59977 | 3403 | { |
71215351 | 3404 | if (!theRed.IsRealValue() |
3405 | || !theGreen.IsRealValue() | |
3406 | || !theBlue.IsRealValue()) | |
7fd59977 | 3407 | { |
71215351 | 3408 | std::cout << "Error: RGB color values should be real!\n"; |
3409 | return Standard_True; | |
3410 | } | |
3411 | theRedValue = theRed .RealValue(); | |
3412 | theGreenValue = theGreen.RealValue(); | |
3413 | theBlueValue = theBlue .RealValue(); | |
3414 | if (theRedValue < 0.0 || theRedValue > 1.0 | |
3415 | || theGreenValue < 0.0 || theGreenValue > 1.0 | |
3416 | || theBlueValue < 0.0 || theBlueValue > 1.0) | |
3417 | { | |
3418 | std::cout << "Error: RGB color values should be within range 0..1!\n"; | |
3419 | return Standard_True; | |
7fd59977 | 3420 | } |
71215351 | 3421 | return Standard_False; |
3422 | } | |
7fd59977 | 3423 | |
71215351 | 3424 | static int VColorScale (Draw_Interpretor& theDI, |
3425 | Standard_Integer theArgNb, | |
3426 | const char** theArgVec) | |
3427 | { | |
7fd59977 | 3428 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
71215351 | 3429 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
3430 | if (aContext.IsNull()) | |
3431 | { | |
3432 | std::cout << "Error: no active view!\n"; | |
3433 | return 1; | |
7fd59977 | 3434 | } |
3435 | ||
71215351 | 3436 | Handle(V3d_ColorScale) aCS = Handle(V3d_ColorScale)::DownCast (aView->ColorScale()); |
3437 | if (aCS.IsNull()) | |
3438 | { | |
3439 | std::cout << "Error: color scale is undefined!\n"; | |
7fd59977 | 3440 | return 1; |
7fd59977 | 3441 | } |
71215351 | 3442 | |
3443 | Standard_Real aMinRange = aCS->GetMin(); | |
3444 | Standard_Real aMaxRange = aCS->GetMax(); | |
3445 | Standard_Integer aNbIntervals = aCS->GetNumberOfIntervals(); | |
3446 | Standard_Integer aTextHeight = aCS->GetTextHeight(); | |
3447 | Aspect_TypeOfColorScalePosition aLabPosition = aCS->GetLabelPosition(); | |
3448 | gp_XY aPos (aCS->GetXPosition(), aCS->GetYPosition()); | |
3449 | ||
3450 | ViewerTest_AutoUpdater anUpdateTool (aContext, aView); | |
3451 | ||
3452 | if (theArgNb <= 1) | |
3453 | { | |
3454 | theDI << "Current color scale parameters:\n" | |
3455 | << "Min range: " << aMinRange << "\n" | |
3456 | << "Max range: " << aMaxRange << "\n" | |
3457 | << "Number of intervals: " << aNbIntervals << "\n" | |
3458 | << "Text height: " << aTextHeight << "\n" | |
3459 | << "Color scale position: " << aPos.X() <<" "<< aPos.Y()<< "\n" | |
3460 | << "Color scale title: " << aCS->GetTitle() << "\n" | |
3461 | << "Label position: "; | |
3462 | switch (aLabPosition) | |
3463 | { | |
3464 | case Aspect_TOCSP_NONE: | |
3465 | theDI << "None\n"; | |
3466 | break; | |
3467 | case Aspect_TOCSP_LEFT: | |
3468 | theDI << "Left\n"; | |
3469 | break; | |
3470 | case Aspect_TOCSP_RIGHT: | |
3471 | theDI << "Right\n"; | |
3472 | break; | |
3473 | case Aspect_TOCSP_CENTER: | |
3474 | theDI << "Center\n"; | |
3475 | break; | |
3476 | } | |
3477 | return 0; | |
3478 | } | |
3479 | Standard_CString aFirstArg = theArgVec[1]; | |
3480 | TCollection_AsciiString aFlag (aFirstArg); | |
3481 | aFlag.LowerCase(); | |
3482 | if (aFlag == "-hide" || | |
3483 | aFlag == "-erase") | |
3484 | { | |
3485 | if (theArgNb > 2) | |
3486 | { | |
3487 | std::cout << "Error: wrong syntax at argument '" << theArgVec[1] << "'!\n"; | |
3488 | return 1; | |
3489 | } | |
3490 | if (!aView->ColorScaleIsDisplayed()) | |
3491 | { | |
3492 | std::cout << "Error: color scale is not displayed!\n"; | |
3493 | return 1; | |
3494 | } | |
3495 | else | |
3496 | { | |
3497 | aView->ColorScaleErase(); | |
3498 | return 0; | |
3499 | } | |
3500 | } | |
3501 | else if (aFlag == "-show" || | |
3502 | aFlag == "-display") | |
3503 | { | |
3504 | if (theArgNb > 2) | |
3505 | { | |
3506 | std::cout << "Error: wrong syntax at argument '" << theArgVec[1] << "'!\n"; | |
3507 | return 1; | |
3508 | } | |
3509 | aView->ColorScaleDisplay(); | |
3510 | return 0; | |
3511 | } | |
3512 | ||
3513 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
3514 | { | |
3515 | Standard_CString anArg = theArgVec[anArgIter]; | |
3516 | TCollection_AsciiString aFlag (anArg); | |
3517 | aFlag.LowerCase(); | |
3518 | if (anUpdateTool.parseRedrawMode (aFlag)) | |
3519 | { | |
3520 | continue; | |
3521 | } | |
3522 | else if (aFlag == "-range") | |
3523 | { | |
3524 | if (anArgIter + 3 >= theArgNb) | |
3525 | { | |
3526 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3527 | return 1; | |
3528 | } | |
3529 | ||
3530 | TCollection_AsciiString anArg1 (theArgVec[++anArgIter]); | |
3531 | TCollection_AsciiString anArg2 (theArgVec[++anArgIter]); | |
3532 | TCollection_AsciiString anArg3 (theArgVec[++anArgIter]); | |
3533 | if (!anArg1.IsRealValue()) | |
3534 | { | |
3535 | std::cout << "Error: the minRange value should be real!\n"; | |
3536 | return 1; | |
3537 | } | |
3538 | else if (!anArg2.IsRealValue()) | |
3539 | { | |
3540 | std::cout << "Error: the maxRange value should be real!\n"; | |
3541 | return 1; | |
3542 | } | |
3543 | else if (!anArg3.IsIntegerValue()) | |
3544 | { | |
3545 | std::cout << "Error: the number of intervals should be integer!\n"; | |
3546 | return 1; | |
3547 | } | |
3548 | ||
3549 | aMinRange = anArg1.RealValue(); | |
3550 | aMaxRange = anArg2.RealValue(); | |
3551 | aNbIntervals = anArg3.IntegerValue(); | |
3552 | } | |
3553 | else if (aFlag == "-font") | |
3554 | { | |
3555 | if (anArgIter + 1 >= theArgNb) | |
3556 | { | |
3557 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3558 | return 1; | |
3559 | } | |
3560 | TCollection_AsciiString anArg (theArgVec[anArgIter + 1]); | |
3561 | if (!anArg.IsIntegerValue()) | |
3562 | { | |
3563 | std::cout << "Error: HeightFont value should be integer!\n"; | |
3564 | return 1; | |
3565 | } | |
3566 | ||
3567 | aTextHeight = anArg.IntegerValue(); | |
3568 | anArgIter += 1; | |
3569 | } | |
3570 | else if (aFlag == "-textpos") | |
3571 | { | |
3572 | if (anArgIter + 1 >= theArgNb) | |
3573 | { | |
3574 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3575 | return 1; | |
3576 | } | |
3577 | TCollection_AsciiString anArg (theArgVec[++anArgIter]); | |
3578 | anArg.LowerCase(); | |
3579 | if (anArg == "none") | |
3580 | { | |
3581 | aLabPosition = Aspect_TOCSP_NONE; | |
3582 | } | |
3583 | else if (anArg == "left") | |
3584 | { | |
3585 | aLabPosition = Aspect_TOCSP_LEFT; | |
3586 | } | |
3587 | else if (anArg == "right") | |
3588 | { | |
3589 | aLabPosition = Aspect_TOCSP_RIGHT; | |
3590 | } | |
3591 | else if (anArg == "center") | |
3592 | { | |
3593 | aLabPosition = Aspect_TOCSP_CENTER; | |
3594 | } | |
3595 | else | |
3596 | { | |
3597 | std::cout << "Error: unknown position '" << anArg << "'!\n"; | |
3598 | return 1; | |
3599 | } | |
3600 | } | |
3601 | else if (aFlag == "-xy") | |
3602 | { | |
3603 | if (anArgIter + 2 >= theArgNb) | |
3604 | { | |
3605 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3606 | return 1; | |
3607 | } | |
3608 | ||
3609 | TCollection_AsciiString aX (theArgVec[++anArgIter]); | |
3610 | TCollection_AsciiString aY (theArgVec[++anArgIter]); | |
3611 | if (!aX.IsRealValue() | |
3612 | || !aY.IsRealValue()) | |
3613 | { | |
3614 | std::cout << "Error: coordinates should be real values!\n"; | |
3615 | return 1; | |
3616 | } | |
3617 | ||
3618 | aPos.SetCoord (aX.RealValue(), aY.RealValue()); | |
3619 | } | |
3620 | else if (aFlag == "-color") | |
3621 | { | |
3622 | if (aCS->GetColorType() != Aspect_TOCSD_USER) | |
3623 | { | |
3624 | std::cout << "Error: wrong color type! Call -colors before to set user-specified colors!\n"; | |
3625 | return 1; | |
3626 | } | |
3627 | ||
3628 | Quantity_NameOfColor aColorName; | |
3629 | if (anArgIter + 4 >= theArgNb) | |
3630 | { | |
3631 | if (anArgIter + 2 >= theArgNb) | |
3632 | { | |
3633 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3634 | return 1; | |
3635 | } | |
3636 | else if (!Quantity_Color::ColorFromName (theArgVec[anArgIter + 2], aColorName)) | |
3637 | { | |
3638 | std::cout << "Error: wrong color name: '" << theArgVec[anArgIter + 2] << "' !\n"; | |
3639 | return 1; | |
3640 | } | |
3641 | } | |
3642 | ||
3643 | TCollection_AsciiString anInd (theArgVec[anArgIter + 1]); | |
3644 | if (!anInd.IsIntegerValue()) | |
3645 | { | |
3646 | std::cout << "Error: Index value should be integer!\n"; | |
3647 | return 1; | |
3648 | } | |
3649 | ||
3650 | Standard_Integer anIndex = anInd.IntegerValue(); | |
3651 | if (anIndex < 0 | |
3652 | || anIndex > aNbIntervals - 1) | |
3653 | { | |
3654 | std::cout << "Error: Index value should be within range 0..." << (aNbIntervals - 1) <<"!\n"; | |
3655 | return 1; | |
3656 | } | |
3657 | ||
3658 | if (Quantity_Color::ColorFromName (theArgVec[anArgIter + 2], aColorName)) | |
3659 | { | |
3660 | aCS->SetColor (Quantity_Color (aColorName), anIndex); | |
3661 | aCS->SetColorType(Aspect_TOCSD_USER); | |
3662 | anArgIter += 2; | |
3663 | continue; | |
3664 | } | |
3665 | ||
3666 | TCollection_AsciiString aRed (theArgVec[anArgIter + 2]); | |
3667 | TCollection_AsciiString aGreen (theArgVec[anArgIter + 3]); | |
3668 | TCollection_AsciiString aBlue (theArgVec[anArgIter + 4]); | |
3669 | Standard_Real aRedValue,aGreenValue, aBlueValue; | |
3670 | if(checkColor (aRed, aGreen, aBlue, aRedValue, aGreenValue, aBlueValue)) | |
3671 | { | |
3672 | return 1; | |
3673 | } | |
3674 | aCS->SetColor (Quantity_Color (aRedValue, aGreenValue, aBlueValue, Quantity_TOC_RGB), anIndex); | |
3675 | aCS->SetColorType (Aspect_TOCSD_USER); | |
3676 | anArgIter += 4; | |
3677 | } | |
3678 | else if (aFlag == "-label") | |
3679 | { | |
3680 | if (aCS->GetColorType() != Aspect_TOCSD_USER) | |
3681 | { | |
3682 | std::cout << "Error: wrong label type! Call -labels before to set user-specified labels!\n"; | |
3683 | return 1; | |
3684 | } | |
3685 | else if (anArgIter + 2 >= theArgNb) | |
3686 | { | |
3687 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3688 | return 1; | |
3689 | } | |
3690 | ||
3691 | Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]); | |
3692 | if (anIndex < 0 | |
3693 | || anIndex > aNbIntervals) | |
3694 | { | |
3695 | std::cout << "Error: Index value should be within range 0..." << aNbIntervals <<"!\n"; | |
3696 | return 1; | |
3697 | } | |
3698 | ||
3699 | TCollection_ExtendedString aText (theArgVec[anArgIter + 2]); | |
3700 | aCS->SetLabel (aText, anIndex); | |
3701 | aCS->SetLabelType (Aspect_TOCSD_USER); | |
3702 | anArgIter += 2; | |
3703 | } | |
3704 | else if (aFlag == "-colors") | |
3705 | { | |
3706 | Aspect_SequenceOfColor aSeq; | |
3707 | if (anArgIter + aNbIntervals + 1 > theArgNb) | |
3708 | { | |
3709 | std::cout << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the " | |
3710 | << aNbIntervals << " intervals\n"; | |
3711 | return 1; | |
3712 | } | |
3713 | ||
3714 | Standard_Integer aColorIter = anArgIter + 1; | |
3715 | while (aColorIter < theArgNb) | |
3716 | { | |
3717 | if (theArgVec[aColorIter][0] == '-') | |
3718 | { | |
3719 | break; | |
3720 | } | |
3721 | ||
3722 | else if (theArgVec[aColorIter][0] >= 97 | |
3723 | && theArgVec[aColorIter][0] <= 122) | |
3724 | { | |
3725 | Quantity_NameOfColor aColorName; | |
3726 | if (!Quantity_Color::ColorFromName (theArgVec[aColorIter], aColorName)) | |
3727 | { | |
3728 | std::cout << "Error: wrong color name: " << theArgVec[aColorIter] << " !\n"; | |
3729 | return 1; | |
3730 | } | |
3731 | aSeq.Append (Quantity_Color (aColorName)); | |
3732 | aColorIter++; | |
3733 | anArgIter++; | |
3734 | } | |
3735 | else | |
3736 | { | |
3737 | TCollection_AsciiString aRed (theArgVec[aColorIter]); | |
3738 | TCollection_AsciiString aGreen (theArgVec[aColorIter + 1]); | |
3739 | TCollection_AsciiString aBlue (theArgVec[aColorIter + 2]); | |
3740 | Standard_Real aRedValue,aGreenValue, aBlueValue; | |
3741 | if (checkColor (aRed, aGreen, aBlue, aRedValue, aGreenValue, aBlueValue)) | |
3742 | { | |
3743 | return 1; | |
3744 | } | |
3745 | aSeq.Append (Quantity_Color (aRedValue, aGreenValue, aBlueValue, Quantity_TOC_RGB)); | |
3746 | aColorIter += 3; | |
3747 | anArgIter += 3; | |
3748 | } | |
3749 | } | |
3750 | if (aSeq.Length() < aNbIntervals) | |
3751 | { | |
3752 | std::cout << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the " | |
3753 | << aNbIntervals << " intervals\n"; | |
3754 | return 1; | |
3755 | } | |
3756 | ||
3757 | aCS->SetColors (aSeq); | |
3758 | aCS->SetColorType (Aspect_TOCSD_USER); | |
3759 | } | |
3760 | else if (aFlag == "-labels") | |
3761 | { | |
3762 | if (anArgIter + aNbIntervals + 1 >= theArgNb) | |
3763 | { | |
3764 | std::cout << "Error: not enough arguments! You should provide " << (aNbIntervals + 1) | |
3765 | << " text labels for " << aNbIntervals << " intervals.\n"; | |
3766 | return 1; | |
3767 | } | |
3768 | ||
3769 | TColStd_SequenceOfExtendedString aSeq; | |
3770 | for (int aLabelIter = anArgIter + 1; aLabelIter <= anArgIter + aNbIntervals + 1; aLabelIter += 1) | |
3771 | { | |
3772 | aSeq.Append (TCollection_ExtendedString (theArgVec[aLabelIter])); | |
3773 | } | |
3774 | aCS->SetLabels (aSeq); | |
3775 | aCS->SetLabelType (Aspect_TOCSD_USER); | |
3776 | anArgIter += aSeq.Length(); | |
3777 | } | |
3778 | else if (aFlag == "-title") | |
3779 | { | |
3780 | if (anArgIter + 1 >= theArgNb) | |
3781 | { | |
3782 | std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n"; | |
3783 | return 1; | |
3784 | } | |
3785 | ||
3786 | Standard_Boolean isTwoArgs = Standard_False; | |
3787 | if (anArgIter + 2 < theArgNb) | |
3788 | { | |
3789 | TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]); | |
3790 | aSecondArg.LowerCase(); | |
3791 | if (aSecondArg == "none") | |
3792 | { | |
3793 | aCS->SetTitlePosition (Aspect_TOCSP_NONE); | |
3794 | isTwoArgs = Standard_True; | |
3795 | } | |
3796 | else if (aSecondArg == "left") | |
3797 | { | |
3798 | aCS->SetTitlePosition (Aspect_TOCSP_LEFT); | |
3799 | isTwoArgs = Standard_True; | |
3800 | } | |
3801 | else if (aSecondArg == "right") | |
3802 | { | |
3803 | aCS->SetTitlePosition (Aspect_TOCSP_RIGHT); | |
3804 | isTwoArgs = Standard_True; | |
3805 | } | |
3806 | else if (aSecondArg == "center") | |
3807 | { | |
3808 | aCS->SetTitlePosition (Aspect_TOCSP_CENTER); | |
3809 | isTwoArgs = Standard_True; | |
3810 | } | |
3811 | } | |
3812 | ||
3813 | aCS->SetTitle (theArgVec[anArgIter + 1]); | |
3814 | if (isTwoArgs) | |
3815 | { | |
3816 | anArgIter += 1; | |
3817 | } | |
3818 | anArgIter += 1; | |
3819 | } | |
3820 | else if (aFlag == "-demoversion" | |
3821 | || aFlag == "-demo") | |
3822 | { | |
3823 | aPos.SetCoord (0.0, 0.0); | |
3824 | aTextHeight = 16; | |
3825 | aMinRange = 0.0; | |
3826 | aMaxRange = 100; | |
3827 | aNbIntervals = 10; | |
3828 | aLabPosition = Aspect_TOCSP_RIGHT; | |
3829 | aCS->SetColorType(Aspect_TOCSD_AUTO); | |
3830 | aCS->SetLabelType(Aspect_TOCSD_AUTO); | |
3831 | } | |
3832 | else | |
3833 | { | |
3834 | std::cout << "Error: wrong syntax at " << anArg << " - unknown argument!\n"; | |
3835 | return 1; | |
3836 | } | |
3837 | } | |
3838 | ||
3839 | aCS->SetPosition (aPos.X(), aPos.Y()); | |
3840 | aCS->SetHeight (0.95); | |
3841 | aCS->SetTextHeight (aTextHeight); | |
3842 | aCS->SetRange (aMinRange, aMaxRange); | |
3843 | aCS->SetNumberOfIntervals (aNbIntervals); | |
3844 | aCS->SetLabelPosition (aLabPosition); | |
3845 | ||
3846 | if (!aView->ColorScaleIsDisplayed()) | |
3847 | { | |
3848 | aView->ColorScaleDisplay(); | |
3849 | } | |
3850 | ||
7fd59977 | 3851 | return 0; |
3852 | } | |
3853 | ||
3854 | //============================================================================== | |
3855 | //function : VGraduatedTrihedron | |
a79f67f8 | 3856 | //purpose : Displays or hides a graduated trihedron |
7fd59977 | 3857 | //============================================================================== |
a79f67f8 | 3858 | static Standard_Boolean GetColor (const TCollection_AsciiString& theValue, |
3859 | Quantity_Color& theColor) | |
13a22457 | 3860 | { |
a79f67f8 | 3861 | Quantity_NameOfColor aColorName; |
3862 | TCollection_AsciiString aVal = theValue; | |
3863 | aVal.UpperCase(); | |
3864 | if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName)) | |
13a22457 | 3865 | { |
a79f67f8 | 3866 | return Standard_False; |
13a22457 | 3867 | } |
a79f67f8 | 3868 | theColor = Quantity_Color (aColorName); |
3869 | return Standard_True; | |
13a22457 S |
3870 | } |
3871 | ||
a79f67f8 | 3872 | static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs) |
7fd59977 | 3873 | { |
a79f67f8 | 3874 | if (theArgNum < 2) |
13a22457 | 3875 | { |
a79f67f8 | 3876 | std::cout << theArgs[0] << " error: wrong number of parameters. Type 'help" |
3877 | << theArgs[0] <<"' for more information.\n"; | |
3878 | return 1; //TCL_ERROR | |
13a22457 | 3879 | } |
7fd59977 | 3880 | |
a79f67f8 | 3881 | NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs; |
3882 | TCollection_AsciiString aParseKey; | |
3883 | for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt) | |
3884 | { | |
3885 | TCollection_AsciiString anArg (theArgs [anArgIt]); | |
3886 | ||
3887 | if (anArg.Value (1) == '-' && !anArg.IsRealValue()) | |
3888 | { | |
3889 | aParseKey = anArg; | |
3890 | aParseKey.Remove (1); | |
3891 | aParseKey.LowerCase(); | |
3892 | aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString); | |
3893 | continue; | |
3894 | } | |
13a22457 | 3895 | |
a79f67f8 | 3896 | if (aParseKey.IsEmpty()) |
3897 | { | |
3898 | continue; | |
3899 | } | |
3900 | ||
3901 | aMapOfArgs(aParseKey)->Append (anArg); | |
3902 | } | |
3903 | ||
3904 | // Check parameters | |
3905 | for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs); | |
3906 | aMapIt.More(); aMapIt.Next()) | |
7fd59977 | 3907 | { |
a79f67f8 | 3908 | const TCollection_AsciiString& aKey = aMapIt.Key(); |
3909 | const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value(); | |
3910 | ||
3911 | // Bool key, without arguments | |
3912 | if ((aKey.IsEqual ("on") || aKey.IsEqual ("off")) | |
3913 | && anArgs->IsEmpty()) | |
3914 | { | |
3915 | continue; | |
3916 | } | |
3917 | ||
3918 | // One argument | |
3919 | if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname")) | |
3920 | && anArgs->Length() == 1) | |
3921 | { | |
3922 | continue; | |
3923 | } | |
3924 | ||
3925 | // On/off arguments | |
3926 | if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname") | |
3927 | || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks") | |
536d98e2 | 3928 | || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues") |
3929 | || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes")) | |
a79f67f8 | 3930 | && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off"))) |
3931 | { | |
3932 | continue; | |
3933 | } | |
3934 | ||
3935 | // One string argument | |
3936 | if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor") | |
3937 | || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor")) | |
3938 | && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue()) | |
3939 | { | |
3940 | continue; | |
3941 | } | |
3942 | ||
3943 | // One integer argument | |
3944 | if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks") | |
3945 | || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength") | |
3946 | || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset") | |
3947 | || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset")) | |
3948 | && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue()) | |
3949 | { | |
3950 | continue; | |
3951 | } | |
3952 | ||
3953 | // One real argument | |
3954 | if ( aKey.IsEqual ("arrowlength") | |
3955 | && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue())) | |
3956 | { | |
3957 | continue; | |
3958 | } | |
3959 | ||
3960 | // Two string arguments | |
3961 | if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont")) | |
3962 | && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue()) | |
13a22457 | 3963 | { |
a79f67f8 | 3964 | continue; |
13a22457 | 3965 | } |
a79f67f8 | 3966 | |
3967 | TCollection_AsciiString aLowerKey; | |
3968 | aLowerKey = "-"; | |
3969 | aLowerKey += aKey; | |
3970 | aLowerKey.LowerCase(); | |
3971 | std::cout << theArgs[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n"; | |
3972 | std::cout << "Type help for more information.\n"; | |
3973 | return 1; | |
7fd59977 | 3974 | } |
3975 | ||
a79f67f8 | 3976 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); |
3977 | if (anAISContext.IsNull()) | |
3978 | { | |
3979 | std::cout << theArgs[0] << ": " << " please use 'vinit' command to initialize view.\n"; | |
3980 | return 1; | |
3981 | } | |
7fd59977 | 3982 | |
a79f67f8 | 3983 | Standard_Boolean toDisplay = Standard_True; |
3984 | Quantity_Color aColor; | |
3985 | Graphic3d_GraduatedTrihedron aTrihedronData; | |
3986 | // Process parameters | |
3987 | Handle(TColStd_HSequenceOfAsciiString) aValues; | |
3988 | if (aMapOfArgs.Find ("off", aValues)) | |
7fd59977 | 3989 | { |
a79f67f8 | 3990 | toDisplay = Standard_False; |
3991 | } | |
13a22457 | 3992 | |
a79f67f8 | 3993 | // AXES NAMES |
3994 | if (aMapOfArgs.Find ("xname", aValues)) | |
3995 | { | |
3996 | aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1)); | |
3997 | } | |
3998 | if (aMapOfArgs.Find ("yname", aValues)) | |
3999 | { | |
4000 | aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1)); | |
4001 | } | |
4002 | if (aMapOfArgs.Find ("zname", aValues)) | |
4003 | { | |
4004 | aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1)); | |
4005 | } | |
4006 | if (aMapOfArgs.Find ("xdrawname", aValues)) | |
4007 | { | |
536d98e2 | 4008 | aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4009 | } |
4010 | if (aMapOfArgs.Find ("ydrawname", aValues)) | |
4011 | { | |
536d98e2 | 4012 | aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4013 | } |
4014 | if (aMapOfArgs.Find ("zdrawname", aValues)) | |
4015 | { | |
536d98e2 | 4016 | aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4017 | } |
4018 | if (aMapOfArgs.Find ("xnameoffset", aValues)) | |
4019 | { | |
4020 | aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue()); | |
4021 | } | |
4022 | if (aMapOfArgs.Find ("ynameoffset", aValues)) | |
4023 | { | |
4024 | aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue()); | |
4025 | } | |
4026 | if (aMapOfArgs.Find ("znameoffset", aValues)) | |
4027 | { | |
4028 | aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue()); | |
4029 | } | |
13a22457 | 4030 | |
a79f67f8 | 4031 | // COLORS |
4032 | if (aMapOfArgs.Find ("xnamecolor", aValues)) | |
4033 | { | |
4034 | if (!GetColor (aValues->Value(1), aColor)) | |
13a22457 | 4035 | { |
a79f67f8 | 4036 | std::cout << theArgs[0] << "error: -xnamecolor wrong color name.\n"; |
4037 | return 1; | |
13a22457 | 4038 | } |
a79f67f8 | 4039 | aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor); |
4040 | } | |
4041 | if (aMapOfArgs.Find ("ynamecolor", aValues)) | |
4042 | { | |
4043 | if (!GetColor (aValues->Value(1), aColor)) | |
13a22457 | 4044 | { |
a79f67f8 | 4045 | std::cout << theArgs[0] << "error: -ynamecolor wrong color name.\n"; |
4046 | return 1; | |
4047 | } | |
4048 | aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor); | |
4049 | } | |
4050 | if (aMapOfArgs.Find ("znamecolor", aValues)) | |
4051 | { | |
4052 | if (!GetColor (aValues->Value(1), aColor)) | |
4053 | { | |
4054 | std::cout << theArgs[0] << "error: -znamecolor wrong color name.\n"; | |
4055 | return 1; | |
4056 | } | |
4057 | aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor); | |
4058 | } | |
4059 | if (aMapOfArgs.Find ("xcolor", aValues)) | |
4060 | { | |
4061 | if (!GetColor (aValues->Value(1), aColor)) | |
4062 | { | |
4063 | std::cout << theArgs[0] << "error: -xcolor wrong color name.\n"; | |
4064 | return 1; | |
4065 | } | |
4066 | aTrihedronData.ChangeXAxisAspect().SetColor (aColor); | |
4067 | } | |
4068 | if (aMapOfArgs.Find ("ycolor", aValues)) | |
4069 | { | |
4070 | if (!GetColor (aValues->Value(1), aColor)) | |
4071 | { | |
4072 | std::cout << theArgs[0] << "error: -ycolor wrong color name.\n"; | |
4073 | return 1; | |
4074 | } | |
4075 | aTrihedronData.ChangeYAxisAspect().SetColor (aColor); | |
4076 | } | |
4077 | if (aMapOfArgs.Find ("zcolor", aValues)) | |
4078 | { | |
4079 | if (!GetColor (aValues->Value(1), aColor)) | |
4080 | { | |
4081 | std::cout << theArgs[0] << "error: -zcolor wrong color name.\n"; | |
4082 | return 1; | |
4083 | } | |
4084 | aTrihedronData.ChangeZAxisAspect().SetColor (aColor); | |
4085 | } | |
4086 | ||
4087 | // TICKMARKS | |
4088 | if (aMapOfArgs.Find ("xticks", aValues)) | |
4089 | { | |
536d98e2 | 4090 | aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4091 | } |
4092 | if (aMapOfArgs.Find ("yticks", aValues)) | |
4093 | { | |
536d98e2 | 4094 | aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4095 | } |
4096 | if (aMapOfArgs.Find ("zticks", aValues)) | |
4097 | { | |
536d98e2 | 4098 | aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4099 | } |
4100 | if (aMapOfArgs.Find ("xticklength", aValues)) | |
4101 | { | |
536d98e2 | 4102 | aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4103 | } |
4104 | if (aMapOfArgs.Find ("yticklength", aValues)) | |
4105 | { | |
536d98e2 | 4106 | aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4107 | } |
4108 | if (aMapOfArgs.Find ("zticklength", aValues)) | |
4109 | { | |
536d98e2 | 4110 | aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4111 | } |
4112 | if (aMapOfArgs.Find ("xdrawticks", aValues)) | |
4113 | { | |
536d98e2 | 4114 | aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4115 | } |
4116 | if (aMapOfArgs.Find ("ydrawticks", aValues)) | |
4117 | { | |
536d98e2 | 4118 | aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4119 | } |
4120 | if (aMapOfArgs.Find ("zdrawticks", aValues)) | |
4121 | { | |
536d98e2 | 4122 | aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4123 | } |
4124 | ||
4125 | // VALUES | |
4126 | if (aMapOfArgs.Find ("xdrawvalues", aValues)) | |
4127 | { | |
536d98e2 | 4128 | aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4129 | } |
4130 | if (aMapOfArgs.Find ("ydrawvalues", aValues)) | |
4131 | { | |
536d98e2 | 4132 | aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4133 | } |
4134 | if (aMapOfArgs.Find ("zdrawvalues", aValues)) | |
4135 | { | |
536d98e2 | 4136 | aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4137 | } |
4138 | if (aMapOfArgs.Find ("xvaluesoffset", aValues)) | |
4139 | { | |
4140 | aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue()); | |
4141 | } | |
4142 | if (aMapOfArgs.Find ("yvaluesoffset", aValues)) | |
4143 | { | |
4144 | aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue()); | |
4145 | } | |
4146 | if (aMapOfArgs.Find ("zvaluesoffset", aValues)) | |
4147 | { | |
4148 | aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue()); | |
4149 | } | |
4150 | ||
4151 | // ARROWS | |
4152 | if (aMapOfArgs.Find ("arrowlength", aValues)) | |
4153 | { | |
536d98e2 | 4154 | aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue()); |
a79f67f8 | 4155 | } |
4156 | ||
4157 | // FONTS | |
4158 | if (aMapOfArgs.Find ("namefont", aValues)) | |
4159 | { | |
4160 | aTrihedronData.SetNamesFont (aValues->Value(1)); | |
4161 | } | |
4162 | if (aMapOfArgs.Find ("valuesfont", aValues)) | |
4163 | { | |
4164 | aTrihedronData.SetValuesFont (aValues->Value(1)); | |
4165 | } | |
4166 | ||
536d98e2 | 4167 | if (aMapOfArgs.Find ("drawgrid", aValues)) |
4168 | { | |
4169 | aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on")); | |
4170 | } | |
4171 | if (aMapOfArgs.Find ("drawaxes", aValues)) | |
4172 | { | |
4173 | aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on")); | |
4174 | } | |
4175 | ||
a79f67f8 | 4176 | // The final step: display of erase trihedron |
4177 | if (toDisplay) | |
4178 | { | |
4179 | ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData); | |
13a22457 | 4180 | } |
7fd59977 | 4181 | else |
a79f67f8 | 4182 | { |
4183 | ViewerTest::CurrentView()->GraduatedTrihedronErase(); | |
4184 | } | |
7fd59977 | 4185 | |
4186 | ViewerTest::GetAISContext()->UpdateCurrentViewer(); | |
a79f67f8 | 4187 | ViewerTest::CurrentView()->Redraw(); |
13a22457 | 4188 | |
7fd59977 | 4189 | return 0; |
4190 | } | |
4191 | ||
7edf74fd A |
4192 | //============================================================================== |
4193 | //function : VPrintView | |
4194 | //purpose : Test printing algorithm, print the view to image file with given | |
4195 | // width and height. Printing implemented only for WNT. | |
4196 | //============================================================================== | |
4fe56619 | 4197 | static int VPrintView (Draw_Interpretor& di, Standard_Integer argc, |
7edf74fd A |
4198 | const char** argv) |
4199 | { | |
4200 | #ifndef WNT | |
4201 | di << "Printing implemented only for wnt!\n"; | |
b5ac8292 | 4202 | return 0; |
7edf74fd A |
4203 | #else |
4204 | ||
4205 | Handle(AIS_InteractiveContext) aContextAIS = NULL; | |
4206 | Handle(V3d_View) aView = NULL; | |
4207 | aContextAIS = ViewerTest::GetAISContext(); | |
4208 | if (!aContextAIS.IsNull()) | |
4209 | { | |
4210 | const Handle(V3d_Viewer)& Vwr = aContextAIS->CurrentViewer(); | |
4211 | Vwr->InitActiveViews(); | |
4212 | if(Vwr->MoreActiveViews()) | |
4213 | aView = Vwr->ActiveView(); | |
4214 | } | |
4215 | ||
4216 | // check for errors | |
4217 | if (aView.IsNull()) | |
4218 | { | |
4219 | di << "Call vinit before!\n"; | |
4220 | return 1; | |
4221 | } | |
4222 | else if (argc < 4) | |
4223 | { | |
4224 | di << "Use: " << argv[0]; | |
b5ac8292 | 4225 | di << " width height filename [print algo=0] [tile_width tile_height]\n"; |
7edf74fd A |
4226 | di << "width, height of the intermediate buffer for operation\n"; |
4227 | di << "algo : {0|1}\n"; | |
4228 | di << " 0 - stretch algorithm\n"; | |
4229 | di << " 1 - tile algorithm\n"; | |
4230 | di << "test printing algorithms into an intermediate buffer\n"; | |
b5ac8292 | 4231 | di << "using specific tile size if provided\n"; |
7edf74fd A |
4232 | di << "with saving output to an image file\n"; |
4233 | return 1; | |
4234 | } | |
4235 | ||
4236 | // get the input params | |
91322f44 | 4237 | Standard_Integer aWidth = Draw::Atoi (argv[1]); |
4238 | Standard_Integer aHeight = Draw::Atoi (argv[2]); | |
7edf74fd A |
4239 | Standard_Integer aMode = 0; |
4240 | TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]); | |
b5ac8292 | 4241 | if (argc >= 5) |
91322f44 | 4242 | aMode = Draw::Atoi (argv[4]); |
7edf74fd | 4243 | |
b5ac8292 | 4244 | Standard_Integer aTileWidth = 0; |
4245 | Standard_Integer aTileHeight = 0; | |
4246 | Standard_Boolean isTileSizeProvided = Standard_False; | |
4247 | if (argc == 7) | |
4248 | { | |
4249 | isTileSizeProvided = Standard_True; | |
4250 | aTileWidth = Draw::Atoi (argv[5]); | |
4251 | aTileHeight = Draw::Atoi (argv[6]); | |
4252 | } | |
4253 | ||
7edf74fd A |
4254 | // check the input parameters |
4255 | if (aWidth <= 0 || aHeight <= 0) | |
4256 | { | |
4257 | di << "Width and height must be positive values!\n"; | |
4258 | return 1; | |
4259 | } | |
4260 | if (aMode != 0 && aMode != 1) | |
4261 | aMode = 0; | |
4262 | ||
7edf74fd | 4263 | // define compatible bitmap |
692613e5 | 4264 | HDC anDC = CreateCompatibleDC(0); |
7edf74fd A |
4265 | BITMAPINFO aBitmapData; |
4266 | memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER)); | |
4267 | aBitmapData.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); | |
4268 | aBitmapData.bmiHeader.biWidth = aWidth ; | |
4269 | aBitmapData.bmiHeader.biHeight = aHeight; | |
4270 | aBitmapData.bmiHeader.biPlanes = 1; | |
4271 | aBitmapData.bmiHeader.biBitCount = 24; | |
4272 | aBitmapData.bmiHeader.biXPelsPerMeter = 0; | |
4273 | aBitmapData.bmiHeader.biYPelsPerMeter = 0; | |
4274 | aBitmapData.bmiHeader.biClrUsed = 0; | |
4275 | aBitmapData.bmiHeader.biClrImportant = 0; | |
4276 | aBitmapData.bmiHeader.biCompression = BI_RGB; | |
4277 | aBitmapData.bmiHeader.biSizeImage = 0; | |
4278 | ||
4279 | // Create Device Independent Bitmap | |
692613e5 | 4280 | void* aBitsOut = NULL; |
7edf74fd | 4281 | HBITMAP aMemoryBitmap = CreateDIBSection (anDC, &aBitmapData, DIB_RGB_COLORS, |
692613e5 | 4282 | &aBitsOut, NULL, 0); |
7edf74fd A |
4283 | HGDIOBJ anOldBitmap = SelectObject(anDC, aMemoryBitmap); |
4284 | ||
4285 | Standard_Boolean isSaved = Standard_False, isPrinted = Standard_False; | |
692613e5 | 4286 | if (aBitsOut != NULL) |
4fe56619 | 4287 | { |
7edf74fd A |
4288 | if (aMode == 0) |
4289 | isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH); | |
4290 | else | |
b5ac8292 | 4291 | { |
4292 | if (isTileSizeProvided) | |
4293 | { | |
4294 | Graphic3d_CView* aCView = static_cast<Graphic3d_CView*> (ViewerTest::CurrentView()->View()->CView()); | |
4295 | Graphic3d_PtrFrameBuffer anOldBuffer = static_cast<Graphic3d_PtrFrameBuffer> (aCView->ptrFBO); | |
4296 | aCView->ptrFBO = aView->View()->FBOCreate (aTileWidth, aTileHeight); | |
4297 | ||
4298 | isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE); | |
4299 | ||
4300 | Graphic3d_PtrFrameBuffer aNewBuffer = static_cast<Graphic3d_PtrFrameBuffer> (aCView->ptrFBO); | |
4301 | aView->View()->FBORelease (aNewBuffer); | |
4302 | aCView->ptrFBO = anOldBuffer; | |
4303 | } | |
4304 | else | |
4305 | { | |
4306 | isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE); | |
4307 | } | |
4308 | } | |
7edf74fd A |
4309 | |
4310 | // succesfully printed into an intermediate buffer | |
4311 | if (isPrinted) | |
4312 | { | |
692613e5 | 4313 | Image_PixMap aWrapper; |
4314 | aWrapper.InitWrapper (Image_PixMap::ImgBGR, (Standard_Byte* )aBitsOut, aWidth, aHeight, aWidth * 3 + aWidth % 4); | |
4315 | aWrapper.SetTopDown (false); | |
4316 | ||
4317 | Image_AlienPixMap anImageBitmap; | |
4318 | anImageBitmap.InitCopy (aWrapper); | |
4319 | isSaved = anImageBitmap.Save (aFileName); | |
7edf74fd A |
4320 | } |
4321 | else | |
4322 | { | |
4323 | di << "Print operation failed due to printing errors or\n"; | |
4324 | di << "insufficient memory available\n"; | |
4325 | di << "Please, try to use smaller dimensions for this test\n"; | |
4326 | di << "command, as it allocates intermediate buffer for storing\n"; | |
4327 | di << "the result\n"; | |
4328 | } | |
4329 | } | |
4330 | else | |
4331 | { | |
4332 | di << "Can't allocate memory for intermediate buffer\n"; | |
4333 | di << "Please use smaller dimensions\n"; | |
4334 | } | |
4335 | ||
4336 | if (aMemoryBitmap) | |
4337 | { | |
4338 | SelectObject (anDC, anOldBitmap); | |
4339 | DeleteObject (aMemoryBitmap); | |
4340 | DeleteDC(anDC); | |
4341 | } | |
4342 | ||
4343 | if (!isSaved) | |
4344 | { | |
4345 | di << "Save to file operation failed. This operation may fail\n"; | |
4346 | di << "if you don't have enough available memory, then you can\n"; | |
4347 | di << "use smaller dimensions for the output file\n"; | |
4348 | return 1; | |
4349 | } | |
4350 | ||
4351 | return 0; | |
4352 | ||
4353 | #endif | |
4354 | } | |
4355 | ||
59f45b7c | 4356 | //============================================================================== |
4357 | //function : VZLayer | |
4358 | //purpose : Test z layer operations for v3d viewer | |
4359 | //============================================================================== | |
4360 | static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
4361 | { | |
4362 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext (); | |
4363 | if (aContextAIS.IsNull()) | |
4364 | { | |
4365 | di << "Call vinit before!\n"; | |
4366 | return 1; | |
4367 | } | |
4368 | else if (argc < 2) | |
4369 | { | |
c5751993 | 4370 | di << "Use: vzlayer "; |
4371 | di << " add/del/get/settings/enable/disable [id]\n"; | |
59f45b7c | 4372 | di << " add - add new z layer to viewer and print its id\n"; |
4373 | di << " del - del z layer by its id\n"; | |
4374 | di << " get - print sequence of z layers in increasing order of their overlay level\n"; | |
c5751993 | 4375 | di << " settings - print status of z layer settings\n"; |
4376 | di << " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n"; | |
4377 | di << " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n"; | |
4378 | di << " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n"; | |
4379 | di << "\nWhere id is the layer identificator\n"; | |
4380 | di << "\nExamples:\n"; | |
4381 | di << " vzlayer add\n"; | |
4382 | di << " vzlayer enable poffset 1\n"; | |
4383 | di << " vzlayer disable depthtest 1\n"; | |
4384 | di << " vzlayer del 1\n"; | |
59f45b7c | 4385 | return 1; |
4386 | } | |
4387 | ||
4388 | const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer(); | |
4389 | if (aViewer.IsNull()) | |
4390 | { | |
4391 | di << "No active viewer!\n"; | |
4392 | return 1; | |
4393 | } | |
4394 | ||
4395 | // perform operation | |
4396 | TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]); | |
4397 | if (anOp == "add") | |
4398 | { | |
4399 | Standard_Integer aNewId; | |
4400 | if (!aViewer->AddZLayer (aNewId)) | |
4401 | { | |
4402 | di << "Impossible to add new z layer!\n"; | |
4403 | return 1; | |
4404 | } | |
4405 | ||
4406 | di << "New z layer added with index: " << aNewId << "\n"; | |
4407 | } | |
4408 | else if (anOp == "del") | |
4409 | { | |
4410 | if (argc < 3) | |
4411 | { | |
4412 | di << "Please also provide as argument id of z layer to remove\n"; | |
4413 | return 1; | |
4414 | } | |
4415 | ||
91322f44 | 4416 | Standard_Integer aDelId = Draw::Atoi (argv[2]); |
59f45b7c | 4417 | if (!aViewer->RemoveZLayer (aDelId)) |
4418 | { | |
4419 | di << "Impossible to remove the z layer or invalid id!\n"; | |
4420 | return 1; | |
4421 | } | |
4422 | ||
a1954302 | 4423 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); |
4424 | anObjIter.More(); anObjIter.Next()) | |
4425 | { | |
4426 | Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anObjIter.Key1()); | |
4427 | if (aPrs.IsNull() | |
4428 | || aPrs->ZLayer() != aDelId) | |
4429 | { | |
4430 | continue; | |
4431 | } | |
4432 | aPrs->SetZLayer (Graphic3d_ZLayerId_Default); | |
4433 | } | |
4434 | ||
59f45b7c | 4435 | di << "Z layer " << aDelId << " has been removed\n"; |
4436 | } | |
4437 | else if (anOp == "get") | |
4438 | { | |
4439 | TColStd_SequenceOfInteger anIds; | |
4440 | aViewer->GetAllZLayers (anIds); | |
4441 | for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++) | |
4442 | { | |
4443 | di << anIds.Value (aSeqIdx) << " "; | |
4444 | } | |
4445 | ||
4446 | di << "\n"; | |
4447 | } | |
c5751993 | 4448 | else if (anOp == "settings") |
4449 | { | |
4450 | if (argc < 3) | |
4451 | { | |
4452 | di << "Please also provide an id\n"; | |
4453 | return 1; | |
4454 | } | |
4455 | ||
4456 | Standard_Integer anId = Draw::Atoi (argv[2]); | |
4457 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId); | |
4458 | ||
4459 | di << "Depth test - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthTest) ? "enabled" : "disabled") << "\n"; | |
4460 | di << "Depth write - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthWrite) ? "enabled" : "disabled") << "\n"; | |
4461 | di << "Depth buffer clearing - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthClear) ? "enabled" : "disabled") << "\n"; | |
4462 | di << "Depth offset - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthOffset) ? "enabled" : "disabled") << "\n"; | |
4463 | ||
4464 | } | |
4465 | else if (anOp == "enable") | |
4466 | { | |
4467 | if (argc < 3) | |
4468 | { | |
4469 | di << "Please also provide an option to enable\n"; | |
4470 | return 1; | |
4471 | } | |
4472 | ||
4473 | if (argc < 4) | |
4474 | { | |
4475 | di << "Please also provide a layer id\n"; | |
4476 | return 1; | |
4477 | } | |
4478 | ||
4479 | TCollection_AsciiString aSubOp = TCollection_AsciiString (argv[2]); | |
4480 | Standard_Integer anId = Draw::Atoi (argv[3]); | |
4481 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId); | |
4482 | ||
4483 | if (aSubOp == "depthtest" || aSubOp == "test") | |
4484 | { | |
4485 | aSettings.EnableSetting (Graphic3d_ZLayerDepthTest); | |
4486 | } | |
4487 | else if (aSubOp == "depthwrite" || aSubOp == "write") | |
4488 | { | |
4489 | aSettings.EnableSetting (Graphic3d_ZLayerDepthWrite); | |
4490 | } | |
4491 | else if (aSubOp == "depthclear" || aSubOp == "clear") | |
4492 | { | |
4493 | aSettings.EnableSetting (Graphic3d_ZLayerDepthClear); | |
4494 | } | |
4495 | else if (aSubOp == "depthoffset" || aSubOp == "offset") | |
4496 | { | |
4497 | if (argc < 6) | |
4498 | { | |
4499 | di << "Please also provide a factor and units values for depth offset\n"; | |
4500 | di << "Format is: vzlayer enable offset [factor] [units] [layerId]\n"; | |
4501 | return 1; | |
4502 | } | |
4503 | ||
4504 | Standard_ShortReal aFactor = static_cast<Standard_ShortReal> (Draw::Atof (argv[3])); | |
4505 | Standard_ShortReal aUnits = static_cast<Standard_ShortReal> (Draw::Atof (argv[4])); | |
4506 | anId = Draw::Atoi (argv[5]); | |
4507 | aSettings = aViewer->ZLayerSettings (anId); | |
4508 | ||
4509 | aSettings.DepthOffsetFactor = aFactor; | |
4510 | aSettings.DepthOffsetUnits = aUnits; | |
4511 | ||
4512 | aSettings.EnableSetting (Graphic3d_ZLayerDepthOffset); | |
4513 | } | |
4514 | else if (aSubOp == "positiveoffset" || aSubOp == "poffset") | |
4515 | { | |
4516 | aSettings.SetDepthOffsetPositive(); | |
4517 | } | |
4518 | else if (aSubOp == "negativeoffset" || aSubOp == "noffset") | |
4519 | { | |
4520 | aSettings.SetDepthOffsetNegative(); | |
4521 | } | |
4522 | ||
4523 | aViewer->SetZLayerSettings (anId, aSettings); | |
4524 | } | |
4525 | else if (anOp == "disable") | |
4526 | { | |
4527 | if (argc < 3) | |
4528 | { | |
4529 | di << "Please also provide an option to disable\n"; | |
4530 | return 1; | |
4531 | } | |
4532 | ||
4533 | if (argc < 4) | |
4534 | { | |
4535 | di << "Please also provide a layer id\n"; | |
4536 | return 1; | |
4537 | } | |
4538 | ||
4539 | TCollection_AsciiString aSubOp = TCollection_AsciiString (argv[2]); | |
4540 | Standard_Integer anId = Draw::Atoi (argv[3]); | |
4541 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId); | |
4542 | ||
4543 | if (aSubOp == "depthtest" || aSubOp == "test") | |
4544 | { | |
4545 | aSettings.DisableSetting (Graphic3d_ZLayerDepthTest); | |
4546 | } | |
4547 | else if (aSubOp == "depthwrite" || aSubOp == "write") | |
4548 | { | |
4549 | aSettings.DisableSetting (Graphic3d_ZLayerDepthWrite); | |
4550 | } | |
4551 | else if (aSubOp == "depthclear" || aSubOp == "clear") | |
4552 | { | |
4553 | aSettings.DisableSetting (Graphic3d_ZLayerDepthClear); | |
4554 | } | |
4555 | else if (aSubOp == "depthoffset" || aSubOp == "offset") | |
4556 | { | |
4557 | aSettings.DisableSetting (Graphic3d_ZLayerDepthOffset); | |
4558 | } | |
4559 | ||
4560 | aViewer->SetZLayerSettings (anId, aSettings); | |
4561 | } | |
59f45b7c | 4562 | else |
4563 | { | |
c5751993 | 4564 | di << "Invalid operation, please use { add / del / get / settings / enable / disable}\n"; |
59f45b7c | 4565 | return 1; |
4566 | } | |
4567 | ||
4568 | return 0; | |
4569 | } | |
4570 | ||
25289ec1 | 4571 | // this class provides a presentation of text item in v3d view under-/overlayer |
4572 | class V3d_TextItem : public Visual3d_LayerItem | |
4573 | { | |
4574 | public: | |
4575 | ||
4576 | // CASCADE RTTI | |
ec357c5c | 4577 | DEFINE_STANDARD_RTTI(V3d_TextItem, Visual3d_LayerItem) |
25289ec1 | 4578 | |
4579 | // constructor | |
4580 | Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText, | |
4581 | const Standard_Real theX1, | |
4582 | const Standard_Real theY1, | |
4583 | const Standard_Real theHeight, | |
4584 | const TCollection_AsciiString& theFontName, | |
4585 | const Quantity_Color& theColor, | |
4586 | const Quantity_Color& theSubtitleColor, | |
4587 | const Aspect_TypeOfDisplayText& theTypeOfDisplay, | |
4588 | const Handle(Visual3d_Layer)& theLayer); | |
4589 | ||
4590 | // redraw method | |
4591 | Standard_EXPORT void RedrawLayerPrs(); | |
4592 | ||
4593 | private: | |
4594 | ||
4595 | Standard_Real myX1; | |
4596 | Standard_Real myY1; | |
25289ec1 | 4597 | TCollection_AsciiString myText; |
eafb234b | 4598 | Standard_Real myHeight; |
4599 | Handle(Visual3d_Layer) myLayer; | |
25289ec1 | 4600 | Quantity_Color myColor; |
4601 | Quantity_Color mySubtitleColor; | |
4602 | Aspect_TypeOfDisplayText myType; | |
eafb234b | 4603 | TCollection_AsciiString myFontName; |
25289ec1 | 4604 | }; |
4605 | ||
25289ec1 | 4606 | |
4607 | // create and add to display the text item | |
4608 | V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText, | |
4609 | const Standard_Real theX1, | |
4610 | const Standard_Real theY1, | |
4611 | const Standard_Real theHeight, | |
4612 | const TCollection_AsciiString& theFontName, | |
4613 | const Quantity_Color& theColor, | |
4614 | const Quantity_Color& theSubtitleColor, | |
4615 | const Aspect_TypeOfDisplayText& theTypeOfDisplay, | |
4616 | const Handle(Visual3d_Layer)& theLayer) | |
4617 | : myX1 (theX1), myY1 (theY1), | |
4618 | myText (theText), | |
4619 | myHeight (theHeight), | |
4620 | myLayer (theLayer), | |
4621 | myColor (theColor), | |
4622 | mySubtitleColor (theSubtitleColor), | |
4623 | myType (theTypeOfDisplay), | |
4624 | myFontName (theFontName) | |
4625 | { | |
4626 | if (!myLayer.IsNull ()) | |
4627 | myLayer->AddLayerItem (this); | |
4628 | } | |
4629 | ||
4630 | // render item | |
4631 | void V3d_TextItem::RedrawLayerPrs () | |
4fe56619 | 4632 | { |
25289ec1 | 4633 | if (myLayer.IsNull ()) |
4634 | return; | |
4635 | ||
4636 | myLayer->SetColor (myColor); | |
4637 | myLayer->SetTextAttributes (myFontName.ToCString (), myType, mySubtitleColor); | |
4638 | myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight); | |
4639 | } | |
4640 | ||
20637bd2 | 4641 | // The Visual3d_LayerItem line item for "vlayerline" command |
4fe56619 | 4642 | // it provides a presentation of line with user-defined |
20637bd2 | 4643 | // linewidth, linetype and transparency. |
4fe56619 | 4644 | class V3d_LineItem : public Visual3d_LayerItem |
20637bd2 | 4645 | { |
4646 | public: | |
4647 | // CASCADE RTTI | |
ec357c5c | 4648 | DEFINE_STANDARD_RTTI(V3d_LineItem, Visual3d_LayerItem) |
4fe56619 | 4649 | |
20637bd2 | 4650 | // constructor |
4651 | Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1, | |
4652 | Standard_Real X2, Standard_Real Y2, | |
4653 | V3d_LayerMgrPointer theLayerMgr, | |
4654 | Aspect_TypeOfLine theType = Aspect_TOL_SOLID, | |
4655 | Standard_Real theWidth = 0.5, | |
4656 | Standard_Real theTransp = 1.0); | |
4657 | ||
4658 | // redraw method | |
4659 | Standard_EXPORT void RedrawLayerPrs(); | |
4660 | ||
4661 | private: | |
4662 | ||
4663 | Standard_Real myX1, myY1, myX2, myY2; | |
eafb234b | 4664 | V3d_LayerMgrPointer myLayerMgr; |
4665 | Aspect_TypeOfLine myType; | |
20637bd2 | 4666 | Standard_Real myWidth; |
4667 | Standard_Real myTransparency; | |
20637bd2 | 4668 | }; |
4669 | ||
20637bd2 | 4670 | |
4671 | // default constructor for line item | |
4fe56619 | 4672 | V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1, |
20637bd2 | 4673 | Standard_Real X2, Standard_Real Y2, |
4674 | V3d_LayerMgrPointer theLayerMgr, | |
4675 | Aspect_TypeOfLine theType, | |
4676 | Standard_Real theWidth, | |
4677 | Standard_Real theTransp) : | |
4678 | myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), myLayerMgr(theLayerMgr), | |
4679 | myType(theType), myWidth(theWidth), myTransparency(theTransp) | |
4680 | { | |
9e4c2fbb | 4681 | if (myLayerMgr && !myLayerMgr->Overlay().IsNull()) |
20637bd2 | 4682 | myLayerMgr->Overlay()->AddLayerItem (this); |
4683 | } | |
4684 | ||
4685 | // render line | |
4686 | void V3d_LineItem::RedrawLayerPrs () | |
4687 | { | |
4688 | Handle (Visual3d_Layer) aOverlay; | |
4fe56619 | 4689 | |
20637bd2 | 4690 | if (myLayerMgr) |
4691 | aOverlay = myLayerMgr->Overlay(); | |
4692 | ||
4693 | if (!aOverlay.IsNull()) | |
4694 | { | |
4695 | Quantity_Color aColor(1.0, 0, 0, Quantity_TOC_RGB); | |
4696 | aOverlay->SetColor(aColor); | |
4697 | aOverlay->SetTransparency((Standard_ShortReal)myTransparency); | |
4698 | aOverlay->SetLineAttributes((Aspect_TypeOfLine)myType, myWidth); | |
4699 | aOverlay->BeginPolyline(); | |
4700 | aOverlay->AddVertex(myX1, myY1); | |
4701 | aOverlay->AddVertex(myX2, myY2); | |
4702 | aOverlay->ClosePrimitive(); | |
4703 | } | |
4704 | } | |
4705 | ||
4706 | //============================================================================= | |
4707 | //function : VLayerLine | |
4708 | //purpose : Draws line in the v3d view layer with given attributes: linetype, | |
4709 | // : linewidth, transparency coefficient | |
4710 | //============================================================================ | |
4711 | static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
4712 | { | |
4713 | // get the active view | |
4714 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
4715 | if (aView.IsNull()) | |
4716 | { | |
4717 | di << "Call vinit before!\n"; | |
4718 | return 1; | |
4719 | } | |
4720 | else if (argc < 5) | |
4721 | { | |
4722 | di << "Use: " << argv[0]; | |
4723 | di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n"; | |
4724 | di << " linetype : { 0 | 1 | 2 | 3 } \n"; | |
4725 | di << " 0 - solid \n"; | |
4726 | di << " 1 - dashed \n"; | |
4727 | di << " 2 - dot \n"; | |
4728 | di << " 3 - dashdot\n"; | |
4729 | di << " transparency : { 0.0 - 1.0 } \n"; | |
4730 | di << " 0.0 - transparent\n"; | |
4731 | di << " 1.0 - visible \n"; | |
4732 | return 1; | |
4733 | } | |
4734 | ||
4735 | // get the input params | |
91322f44 | 4736 | Standard_Real X1 = Draw::Atof(argv[1]); |
4737 | Standard_Real Y1 = Draw::Atof(argv[2]); | |
4738 | Standard_Real X2 = Draw::Atof(argv[3]); | |
4739 | Standard_Real Y2 = Draw::Atof(argv[4]); | |
20637bd2 | 4740 | |
4741 | Standard_Real aWidth = 0.5; | |
4742 | Standard_Integer aType = 0; | |
4743 | Standard_Real aTransparency = 1.0; | |
4744 | ||
4745 | // has width | |
4746 | if (argc > 5) | |
91322f44 | 4747 | aWidth = Draw::Atof(argv[5]); |
20637bd2 | 4748 | |
4749 | // has type | |
4750 | if (argc > 6) | |
91322f44 | 4751 | aType = (Standard_Integer) Draw::Atoi(argv[6]); |
20637bd2 | 4752 | |
4753 | // has transparency | |
4754 | if (argc > 7) | |
4755 | { | |
91322f44 | 4756 | aTransparency = Draw::Atof(argv[7]); |
4fe56619 | 4757 | if (aTransparency < 0 || aTransparency > 1.0) |
20637bd2 | 4758 | aTransparency = 1.0; |
4759 | } | |
4760 | ||
4761 | // select appropriate line type | |
4762 | Aspect_TypeOfLine aLineType; | |
4763 | switch (aType) | |
4764 | { | |
4765 | case 1: | |
4766 | aLineType = Aspect_TOL_DASH; | |
4767 | break; | |
4768 | ||
4769 | case 2: | |
4770 | aLineType = Aspect_TOL_DOT; | |
4771 | break; | |
4772 | ||
4773 | case 3: | |
4774 | aLineType = Aspect_TOL_DOTDASH; | |
4775 | break; | |
4776 | ||
4777 | default: | |
4778 | aLineType = Aspect_TOL_SOLID; | |
4779 | } | |
4780 | ||
4781 | // replace layer manager | |
4782 | Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr(aView); | |
4783 | aView->SetLayerMgr(aMgr); | |
4784 | ||
4785 | // add line item | |
4fe56619 | 4786 | Handle (V3d_LineItem) anItem = new V3d_LineItem(X1, Y1, X2, Y2, |
20637bd2 | 4787 | aMgr.operator->(), |
4fe56619 | 4788 | aLineType, aWidth, |
20637bd2 | 4789 | aTransparency); |
4790 | ||
4791 | // update view | |
4792 | aView->MustBeResized(); | |
4793 | aView->Redraw(); | |
4794 | ||
4795 | return 0; | |
4796 | } | |
4797 | ||
25289ec1 | 4798 | //======================================================================= |
4799 | //function : VOverlayText | |
4800 | //purpose : Test text displaying in view overlay | |
4801 | //======================================================================= | |
4802 | static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char**argv) | |
4803 | { | |
4804 | // get the active view | |
4805 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
4806 | if (aView.IsNull()) | |
4807 | { | |
4808 | di << "No active view. Please call vinit.\n"; | |
4809 | return 1; | |
4810 | } | |
4811 | else if (argc < 4 || argc > 13) | |
4812 | { | |
4813 | di << "Use: " << argv[0]; | |
4814 | di << " text x y [height] [font_name] [text_color: R G B] [displayType]\n"; | |
4815 | di << "[background_color: R G B]\n"; | |
4816 | di << " height - pixel height of the text (default=10.0)\n"; | |
4817 | di << " font_name - name of font (default=courier)\n"; | |
4818 | di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n"; | |
a6eb515f | 4819 | di << " display_type = {normal/subtitle/decal/blend/dimension}, (default=normal)\n"; |
25289ec1 | 4820 | di << " background_color- R G B values used for subtitle and decal text\n"; |
4821 | di << "(default=255.0 255.0 255.0)\n"; | |
4822 | return 1; | |
4823 | } | |
4fe56619 | 4824 | |
25289ec1 | 4825 | TCollection_AsciiString aText (argv[1]); |
91322f44 | 4826 | Standard_Real aPosX = Draw::Atof(argv[2]); |
4827 | Standard_Real aPosY = Draw::Atof(argv[3]); | |
4828 | Standard_Real aHeight = (argc >= 5) ? Draw::Atof (argv[4]) : 10.0; | |
25289ec1 | 4829 | |
4830 | // font name | |
4831 | TCollection_AsciiString aFontName = "Courier"; | |
4832 | if (argc >= 6) | |
4833 | aFontName = TCollection_AsciiString (argv[5]); | |
4834 | ||
4835 | // text colors | |
4836 | Quantity_Parameter aColorRed = 1.0; | |
4837 | Quantity_Parameter aColorGreen = 1.0; | |
4838 | Quantity_Parameter aColorBlue = 1.0; | |
4839 | if (argc >= 9) | |
4840 | { | |
91322f44 | 4841 | aColorRed = Draw::Atof (argv[6])/255.; |
4842 | aColorGreen = Draw::Atof (argv[7])/255.; | |
4843 | aColorBlue = Draw::Atof (argv[8])/255.; | |
25289ec1 | 4844 | } |
4845 | ||
4846 | // display type | |
4847 | TCollection_AsciiString aDispStr; | |
4848 | if (argc >= 10) | |
4849 | aDispStr = TCollection_AsciiString (argv[9]); | |
4850 | ||
4851 | Aspect_TypeOfDisplayText aTextType = Aspect_TODT_NORMAL; | |
4852 | if (aDispStr.IsEqual ("subtitle")) | |
4853 | aTextType = Aspect_TODT_SUBTITLE; | |
4854 | else if (aDispStr.IsEqual ("decal")) | |
4855 | aTextType = Aspect_TODT_DEKALE; | |
4856 | else if (aDispStr.IsEqual ("blend")) | |
4857 | aTextType = Aspect_TODT_BLEND; | |
a6eb515f | 4858 | else if (aDispStr.IsEqual ("dimension")) |
4859 | aTextType = Aspect_TODT_DIMENSION; | |
25289ec1 | 4860 | |
4861 | // subtitle color | |
4862 | Quantity_Parameter aSubRed = 1.0; | |
4863 | Quantity_Parameter aSubGreen = 1.0; | |
4864 | Quantity_Parameter aSubBlue = 1.0; | |
4865 | if (argc == 13) | |
4866 | { | |
91322f44 | 4867 | aSubRed = Draw::Atof (argv[10])/255.; |
4868 | aSubGreen = Draw::Atof (argv[11])/255.; | |
4869 | aSubBlue = Draw::Atof (argv[12])/255.; | |
25289ec1 | 4870 | } |
4871 | ||
4872 | // check fo current overlay | |
4873 | Handle(Visual3d_Layer) anOverlay = aView->Viewer()->Viewer()->OverLayer (); | |
4874 | if (anOverlay.IsNull ()) | |
4875 | { | |
4876 | Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (aView); | |
4877 | anOverlay = aMgr->Overlay (); | |
4878 | aView->SetLayerMgr (aMgr); | |
4879 | } | |
4880 | ||
4fe56619 | 4881 | Quantity_Color aTextColor (aColorRed, aColorGreen, |
25289ec1 | 4882 | aColorBlue, Quantity_TOC_RGB); |
4fe56619 | 4883 | Quantity_Color aSubtColor (aSubRed, aSubGreen, |
25289ec1 | 4884 | aSubBlue, Quantity_TOC_RGB); |
4885 | ||
4886 | // add text item | |
4887 | Handle(V3d_TextItem) anItem = new V3d_TextItem (aText, aPosX, aPosY, | |
4888 | aHeight, aFontName, aTextColor, aSubtColor, aTextType, anOverlay); | |
4889 | ||
4890 | // update view | |
4891 | aView->MustBeResized(); | |
4892 | aView->Redraw(); | |
4893 | ||
4894 | return 0; | |
4895 | } | |
4896 | ||
2bd4c032 | 4897 | //============================================================================== |
4898 | //function : VGrid | |
4899 | //purpose : | |
4900 | //============================================================================== | |
4901 | ||
35e08fe8 | 4902 | static int VGrid (Draw_Interpretor& /*theDI*/, |
2bd4c032 | 4903 | Standard_Integer theArgNb, |
4904 | const char** theArgVec) | |
4905 | { | |
4906 | // get the active view | |
4907 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
4908 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
4909 | if (aView.IsNull() || aViewer.IsNull()) | |
4910 | { | |
4911 | std::cerr << "No active view. Please call vinit.\n"; | |
4912 | return 1; | |
4913 | } | |
4914 | ||
4915 | Aspect_GridType aType = aViewer->GridType(); | |
4916 | Aspect_GridDrawMode aMode = aViewer->GridDrawMode(); | |
4917 | ||
4918 | Standard_Integer anIter = 1; | |
4919 | for (; anIter < theArgNb; ++anIter) | |
4920 | { | |
4921 | const char* aValue = theArgVec[anIter]; | |
4922 | if (*aValue == 'r') | |
4923 | { | |
4924 | aType = Aspect_GT_Rectangular; | |
4925 | } | |
4926 | else if (*aValue == 'c') | |
4927 | { | |
4928 | aType = Aspect_GT_Circular; | |
4929 | } | |
4930 | else if (*aValue == 'l') | |
4931 | { | |
4932 | aMode = Aspect_GDM_Lines; | |
4933 | } | |
4934 | else if (*aValue == 'p') | |
4935 | { | |
4936 | aMode = Aspect_GDM_Points; | |
4937 | } | |
4938 | else if (strcmp (aValue, "off" ) == 0) | |
4939 | { | |
4940 | aViewer->DeactivateGrid(); | |
4941 | return 0; | |
4942 | } | |
4943 | else | |
4944 | { | |
4945 | break; | |
4946 | } | |
4947 | } | |
4948 | ||
4949 | Standard_Integer aTail = (theArgNb - anIter); | |
4950 | if (aTail == 0) | |
4951 | { | |
4952 | aViewer->ActivateGrid (aType, aMode); | |
4953 | return 0; | |
4954 | } | |
4955 | else if (aTail != 2 && aTail != 5) | |
4956 | { | |
4957 | std::cerr << "Incorrect arguments number! Usage:\n" | |
4958 | << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n"; | |
4959 | return 1; | |
4960 | } | |
4961 | ||
4962 | Quantity_Length anOriginX, anOriginY; | |
4963 | Quantity_PlaneAngle aRotAngle; | |
4964 | if (aType == Aspect_GT_Rectangular) | |
4965 | { | |
4966 | Quantity_Length aRStepX, aRStepY; | |
4967 | aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle); | |
4968 | ||
91322f44 | 4969 | anOriginX = Draw::Atof (theArgVec[anIter++]); |
4970 | anOriginY = Draw::Atof (theArgVec[anIter++]); | |
2bd4c032 | 4971 | if (aTail == 5) |
4972 | { | |
91322f44 | 4973 | aRStepX = Draw::Atof (theArgVec[anIter++]); |
4974 | aRStepY = Draw::Atof (theArgVec[anIter++]); | |
4975 | aRotAngle = Draw::Atof (theArgVec[anIter++]); | |
2bd4c032 | 4976 | } |
4977 | aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle); | |
4978 | aViewer->ActivateGrid (aType, aMode); | |
4979 | } | |
4980 | else if (aType == Aspect_GT_Circular) | |
4981 | { | |
4982 | Quantity_Length aRadiusStep; | |
4983 | Standard_Integer aDivisionNumber; | |
4984 | aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle); | |
4985 | ||
91322f44 | 4986 | anOriginX = Draw::Atof (theArgVec[anIter++]); |
4987 | anOriginY = Draw::Atof (theArgVec[anIter++]); | |
2bd4c032 | 4988 | if (aTail == 5) |
4989 | { | |
91322f44 | 4990 | aRadiusStep = Draw::Atof (theArgVec[anIter++]); |
4991 | aDivisionNumber = Draw::Atoi (theArgVec[anIter++]); | |
4992 | aRotAngle = Draw::Atof (theArgVec[anIter++]); | |
2bd4c032 | 4993 | } |
4994 | ||
4995 | aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle); | |
4996 | aViewer->ActivateGrid (aType, aMode); | |
4997 | } | |
4998 | ||
4999 | return 0; | |
5000 | } | |
5001 | ||
c40b7d58 | 5002 | //============================================================================== |
5003 | //function : VPriviledgedPlane | |
5004 | //purpose : | |
5005 | //============================================================================== | |
5006 | ||
5007 | static int VPriviledgedPlane (Draw_Interpretor& theDI, | |
5008 | Standard_Integer theArgNb, | |
5009 | const char** theArgVec) | |
5010 | { | |
5011 | if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10) | |
5012 | { | |
5013 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
5014 | theDI.PrintHelp (theArgVec[0]); | |
5015 | return 1; | |
5016 | } | |
5017 | ||
5018 | // get the active viewer | |
5019 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
5020 | if (aViewer.IsNull()) | |
5021 | { | |
5022 | std::cerr << "Error: no active viewer. Please call vinit.\n"; | |
5023 | return 1; | |
5024 | } | |
5025 | ||
5026 | if (theArgNb == 1) | |
5027 | { | |
5028 | gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane(); | |
5029 | const gp_Pnt& anOrig = aPriviledgedPlane.Location(); | |
5030 | const gp_Dir& aNorm = aPriviledgedPlane.Direction(); | |
5031 | const gp_Dir& aXDir = aPriviledgedPlane.XDirection(); | |
5032 | theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " " | |
5033 | << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " " | |
5034 | << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n"; | |
5035 | return 0; | |
5036 | } | |
5037 | ||
5038 | Standard_Integer anArgIdx = 1; | |
5039 | Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]); | |
5040 | Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]); | |
5041 | Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]); | |
5042 | Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]); | |
5043 | Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]); | |
5044 | Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]); | |
5045 | ||
5046 | gp_Ax3 aPriviledgedPlane; | |
5047 | gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ); | |
5048 | gp_Dir aNorm (aNormX, aNormY, aNormZ); | |
5049 | if (theArgNb > 7) | |
5050 | { | |
5051 | Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]); | |
5052 | Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]); | |
5053 | Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]); | |
5054 | gp_Dir aXDir (aXDirX, aXDirY, aXDirZ); | |
5055 | aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir); | |
5056 | } | |
5057 | else | |
5058 | { | |
5059 | aPriviledgedPlane = gp_Ax3 (anOrig, aNorm); | |
5060 | } | |
5061 | ||
5062 | aViewer->SetPrivilegedPlane (aPriviledgedPlane); | |
5063 | ||
5064 | return 0; | |
5065 | } | |
5066 | ||
f25b82d6 | 5067 | //============================================================================== |
5068 | //function : VConvert | |
5069 | //purpose : | |
5070 | //============================================================================== | |
5071 | ||
5072 | static int VConvert (Draw_Interpretor& theDI, | |
5073 | Standard_Integer theArgNb, | |
5074 | const char** theArgVec) | |
5075 | { | |
5076 | // get the active view | |
5077 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5078 | if (aView.IsNull()) | |
5079 | { | |
c40b7d58 | 5080 | std::cerr << "Error: no active view. Please call vinit.\n"; |
f25b82d6 | 5081 | return 1; |
5082 | } | |
5083 | ||
5084 | enum { Model, Ray, View, Window, Grid } aMode = Model; | |
5085 | ||
5086 | // access coordinate arguments | |
5087 | TColStd_SequenceOfReal aCoord; | |
5088 | Standard_Integer anArgIdx = 1; | |
5089 | for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx) | |
5090 | { | |
5091 | TCollection_AsciiString anArg (theArgVec[anArgIdx]); | |
5092 | if (!anArg.IsRealValue()) | |
5093 | { | |
5094 | break; | |
5095 | } | |
5096 | aCoord.Append (anArg.RealValue()); | |
5097 | } | |
5098 | ||
5099 | // non-numeric argument too early | |
5100 | if (aCoord.IsEmpty()) | |
5101 | { | |
5102 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
5103 | theDI.PrintHelp (theArgVec[0]); | |
5104 | return 1; | |
5105 | } | |
5106 | ||
5107 | // collect all other arguments and options | |
5108 | for (; anArgIdx < theArgNb; ++anArgIdx) | |
5109 | { | |
5110 | TCollection_AsciiString anArg (theArgVec[anArgIdx]); | |
5111 | anArg.LowerCase(); | |
5112 | if (anArg == "window") aMode = Window; | |
5113 | else if (anArg == "view") aMode = View; | |
5114 | else if (anArg == "grid") aMode = Grid; | |
5115 | else if (anArg == "ray") aMode = Ray; | |
5116 | else | |
5117 | { | |
5118 | std::cerr << "Error: wrong argument " << anArg << "! See usage:\n"; | |
5119 | theDI.PrintHelp (theArgVec[0]); | |
5120 | return 1; | |
5121 | } | |
5122 | } | |
5123 | ||
5124 | // complete input checks | |
5125 | if ((aCoord.Length() == 1 && theArgNb > 3) || | |
5126 | (aCoord.Length() == 2 && theArgNb > 4) || | |
5127 | (aCoord.Length() == 3 && theArgNb > 5)) | |
5128 | { | |
5129 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
5130 | theDI.PrintHelp (theArgVec[0]); | |
5131 | return 1; | |
5132 | } | |
5133 | ||
5134 | Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; | |
5135 | Standard_Integer aXYp[2] = {0, 0}; | |
5136 | ||
5137 | // convert one-dimensional coordinate | |
5138 | if (aCoord.Length() == 1) | |
5139 | { | |
5140 | switch (aMode) | |
5141 | { | |
5142 | case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer) aCoord (1)); return 0; | |
5143 | case Window : theDI << "Window Vp: " << aView->Convert ((Quantity_Length) aCoord (1)); return 0; | |
5144 | default: | |
5145 | std::cerr << "Error: wrong arguments! See usage:\n"; | |
5146 | theDI.PrintHelp (theArgVec[0]); | |
5147 | return 1; | |
5148 | } | |
5149 | } | |
5150 | ||
5151 | // convert 2D coordinates from projection or view reference space | |
5152 | if (aCoord.Length() == 2) | |
5153 | { | |
5154 | switch (aMode) | |
5155 | { | |
5156 | case Model : | |
5157 | aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]); | |
5158 | theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n"; | |
5159 | return 0; | |
5160 | ||
5161 | case View : | |
5162 | aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]); | |
5163 | theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n"; | |
5164 | return 0; | |
5165 | ||
5166 | case Window : | |
5167 | aView->Convert ((V3d_Coordinate) aCoord (1), (V3d_Coordinate) aCoord (2), aXYp[0], aXYp[1]); | |
5168 | theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n"; | |
5169 | return 0; | |
5170 | ||
5171 | case Grid : | |
5172 | aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]); | |
5173 | aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]); | |
5174 | theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n"; | |
5175 | return 0; | |
5176 | ||
5177 | case Ray : | |
5178 | aView->ConvertWithProj ((Standard_Integer) aCoord (1), | |
5179 | (Standard_Integer) aCoord (2), | |
5180 | aXYZ[0], aXYZ[1], aXYZ[2], | |
5181 | aXYZ[3], aXYZ[4], aXYZ[5]); | |
5182 | theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n"; | |
5183 | return 0; | |
5184 | ||
5185 | default: | |
5186 | std::cerr << "Error: wrong arguments! See usage:\n"; | |
5187 | theDI.PrintHelp (theArgVec[0]); | |
5188 | return 1; | |
5189 | } | |
5190 | } | |
5191 | ||
5192 | // convert 3D coordinates from view reference space | |
5193 | else if (aCoord.Length() == 3) | |
5194 | { | |
5195 | switch (aMode) | |
5196 | { | |
5197 | case Window : | |
5198 | aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]); | |
5199 | theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n"; | |
5200 | return 0; | |
5201 | ||
5202 | case Grid : | |
5203 | aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]); | |
5204 | theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n"; | |
5205 | return 0; | |
5206 | ||
5207 | default: | |
5208 | std::cerr << "Error: wrong arguments! See usage:\n"; | |
5209 | theDI.PrintHelp (theArgVec[0]); | |
5210 | return 1; | |
5211 | } | |
5212 | } | |
5213 | ||
5214 | return 0; | |
5215 | } | |
5216 | ||
208e6839 | 5217 | //============================================================================== |
5218 | //function : VFps | |
5219 | //purpose : | |
5220 | //============================================================================== | |
5221 | ||
5222 | static int VFps (Draw_Interpretor& theDI, | |
5223 | Standard_Integer theArgNb, | |
5224 | const char** theArgVec) | |
5225 | { | |
5226 | // get the active view | |
5227 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5228 | if (aView.IsNull()) | |
5229 | { | |
5230 | std::cerr << "No active view. Please call vinit.\n"; | |
5231 | return 1; | |
5232 | } | |
5233 | ||
91322f44 | 5234 | Standard_Integer aFramesNb = (theArgNb > 1) ? Draw::Atoi(theArgVec[1]) : 100; |
208e6839 | 5235 | if (aFramesNb <= 0) |
5236 | { | |
5237 | std::cerr << "Incorrect arguments!\n"; | |
5238 | return 1; | |
5239 | } | |
5240 | ||
5241 | // the time is meaningless for first call | |
5242 | // due to async OpenGl rendering | |
5243 | aView->Redraw(); | |
5244 | ||
5245 | // redraw view in loop to estimate average values | |
5246 | OSD_Timer aTimer; | |
5247 | aTimer.Start(); | |
5248 | for (Standard_Integer anInter = 0; anInter < aFramesNb; ++anInter) | |
5249 | { | |
5250 | aView->Redraw(); | |
5251 | } | |
5252 | aTimer.Stop(); | |
5253 | Standard_Real aCpu; | |
5254 | const Standard_Real aTime = aTimer.ElapsedTime(); | |
5255 | aTimer.OSD_Chronometer::Show (aCpu); | |
5256 | ||
5257 | const Standard_Real aFpsAver = Standard_Real(aFramesNb) / aTime; | |
5258 | const Standard_Real aCpuAver = aCpu / Standard_Real(aFramesNb); | |
5259 | ||
5260 | // return statistics | |
5261 | theDI << "FPS: " << aFpsAver << "\n" | |
5262 | << "CPU: " << (1000.0 * aCpuAver) << " msec\n"; | |
5263 | ||
5264 | return 0; | |
5265 | } | |
5266 | ||
58655684 | 5267 | //============================================================================== |
5268 | //function : VGlDebug | |
5269 | //purpose : | |
5270 | //============================================================================== | |
5271 | ||
5272 | static int VGlDebug (Draw_Interpretor& theDI, | |
5273 | Standard_Integer theArgNb, | |
5274 | const char** theArgVec) | |
5275 | { | |
aaf512f1 | 5276 | Handle(OpenGl_GraphicDriver) aDriver; |
5277 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5278 | if (!aView.IsNull()) | |
5279 | { | |
5280 | aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver()); | |
5281 | } | |
c87535af | 5282 | OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps; |
5283 | OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL; | |
5284 | ||
58655684 | 5285 | if (theArgNb < 2) |
5286 | { | |
c87535af | 5287 | TCollection_AsciiString aDebActive, aSyncActive; |
5288 | if (aCaps == NULL) | |
58655684 | 5289 | { |
c87535af | 5290 | aCaps = aDefCaps; |
5291 | } | |
5292 | else | |
5293 | { | |
5294 | Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS), | |
5295 | "GL_ARB_debug_output"); | |
5296 | aDebActive = isActive ? " (active)" : " (inactive)"; | |
5297 | if (isActive) | |
5298 | { | |
5299 | // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB | |
5300 | aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)"; | |
5301 | } | |
58655684 | 5302 | } |
5303 | ||
c87535af | 5304 | theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n" |
5305 | << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n" | |
5306 | << "glslWarn:" << (aCaps->glslWarnings ? "1" : "0") << "\n" | |
5307 | << "extraMsg:" << (aCaps->suppressExtraMsg ? "0" : "1") << "\n"; | |
58655684 | 5308 | return 0; |
5309 | } | |
5310 | ||
c87535af | 5311 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
aaf512f1 | 5312 | { |
c87535af | 5313 | Standard_CString anArg = theArgVec[anArgIter]; |
5314 | TCollection_AsciiString anArgCase (anArg); | |
5315 | anArgCase.LowerCase(); | |
5316 | Standard_Boolean toEnableDebug = Standard_True; | |
5317 | if (anArgCase == "-glsl" | |
5318 | || anArgCase == "-glslwarn" | |
5319 | || anArgCase == "-glslwarns" | |
5320 | || anArgCase == "-glslwarnings") | |
5321 | { | |
5322 | Standard_Boolean toShowWarns = Standard_True; | |
5323 | if (++anArgIter < theArgNb | |
5324 | && !parseOnOff (theArgVec[anArgIter], toShowWarns)) | |
5325 | { | |
5326 | --anArgIter; | |
5327 | } | |
5328 | aDefCaps->glslWarnings = toShowWarns; | |
5329 | if (aCaps != NULL) | |
5330 | { | |
5331 | aCaps->glslWarnings = toShowWarns; | |
5332 | } | |
5333 | } | |
5334 | else if (anArgCase == "-extra" | |
5335 | || anArgCase == "-extramsg" | |
5336 | || anArgCase == "-extramessages") | |
5337 | { | |
5338 | Standard_Boolean toShow = Standard_True; | |
5339 | if (++anArgIter < theArgNb | |
5340 | && !parseOnOff (theArgVec[anArgIter], toShow)) | |
5341 | { | |
5342 | --anArgIter; | |
5343 | } | |
5344 | aDefCaps->suppressExtraMsg = !toShow; | |
5345 | if (aCaps != NULL) | |
5346 | { | |
5347 | aCaps->suppressExtraMsg = !toShow; | |
5348 | } | |
5349 | } | |
5350 | else if (anArgCase == "-noextra" | |
5351 | || anArgCase == "-noextramsg" | |
5352 | || anArgCase == "-noextramessages") | |
5353 | { | |
5354 | Standard_Boolean toSuppress = Standard_True; | |
5355 | if (++anArgIter < theArgNb | |
5356 | && !parseOnOff (theArgVec[anArgIter], toSuppress)) | |
5357 | { | |
5358 | --anArgIter; | |
5359 | } | |
5360 | aDefCaps->suppressExtraMsg = toSuppress; | |
5361 | if (aCaps != NULL) | |
5362 | { | |
5363 | aCaps->suppressExtraMsg = toSuppress; | |
5364 | } | |
5365 | } | |
5366 | else if (anArgCase == "-sync") | |
5367 | { | |
5368 | Standard_Boolean toSync = Standard_True; | |
5369 | if (++anArgIter < theArgNb | |
5370 | && !parseOnOff (theArgVec[anArgIter], toSync)) | |
5371 | { | |
5372 | --anArgIter; | |
5373 | } | |
5374 | aDefCaps->contextSyncDebug = toSync; | |
5375 | if (toSync) | |
5376 | { | |
5377 | aDefCaps->contextDebug = Standard_True; | |
5378 | } | |
5379 | } | |
5380 | else if (anArgCase == "-debug") | |
5381 | { | |
5382 | if (++anArgIter < theArgNb | |
5383 | && !parseOnOff (theArgVec[anArgIter], toEnableDebug)) | |
5384 | { | |
5385 | --anArgIter; | |
5386 | } | |
5387 | aDefCaps->contextDebug = toEnableDebug; | |
5388 | } | |
5389 | else if (parseOnOff (anArg, toEnableDebug) | |
5390 | && (anArgIter + 1 == theArgNb)) | |
5391 | { | |
5392 | // simple alias to turn on almost everything | |
5393 | aDefCaps->contextDebug = toEnableDebug; | |
5394 | aDefCaps->contextSyncDebug = toEnableDebug; | |
5395 | aDefCaps->glslWarnings = toEnableDebug; | |
5396 | } | |
5397 | else | |
5398 | { | |
5399 | std::cout << "Error: wrong syntax at '" << anArg << "'\n"; | |
5400 | return 1; | |
5401 | } | |
aaf512f1 | 5402 | } |
5403 | ||
58655684 | 5404 | return 0; |
5405 | } | |
208e6839 | 5406 | |
5407 | //============================================================================== | |
5408 | //function : VVbo | |
5409 | //purpose : | |
5410 | //============================================================================== | |
5411 | ||
58655684 | 5412 | static int VVbo (Draw_Interpretor& theDI, |
208e6839 | 5413 | Standard_Integer theArgNb, |
5414 | const char** theArgVec) | |
5415 | { | |
58655684 | 5416 | const Standard_Boolean toSet = (theArgNb > 1); |
5417 | const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1; | |
5418 | if (toSet) | |
208e6839 | 5419 | { |
58655684 | 5420 | ViewerTest_myDefaultCaps.vboDisable = toUseVbo; |
208e6839 | 5421 | } |
5422 | ||
58655684 | 5423 | // get the context |
5424 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); | |
5425 | if (aContextAIS.IsNull()) | |
208e6839 | 5426 | { |
58655684 | 5427 | if (!toSet) |
5428 | { | |
5429 | std::cerr << "No active view!\n"; | |
5430 | } | |
208e6839 | 5431 | return 1; |
5432 | } | |
58655684 | 5433 | Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver()); |
5434 | if (!aDriver.IsNull()) | |
208e6839 | 5435 | { |
58655684 | 5436 | if (!toSet) |
5437 | { | |
5438 | theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n"; | |
5439 | } | |
5440 | else | |
5441 | { | |
5442 | aDriver->ChangeOptions().vboDisable = toUseVbo; | |
5443 | } | |
208e6839 | 5444 | } |
5445 | ||
208e6839 | 5446 | return 0; |
5447 | } | |
5448 | ||
a577aaab | 5449 | //============================================================================== |
5450 | //function : VCaps | |
5451 | //purpose : | |
5452 | //============================================================================== | |
5453 | ||
5454 | static int VCaps (Draw_Interpretor& theDI, | |
5455 | Standard_Integer theArgNb, | |
5456 | const char** theArgVec) | |
5457 | { | |
5458 | OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps; | |
5459 | Handle(OpenGl_GraphicDriver) aDriver; | |
8625ef7e | 5460 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
5461 | if (!aContext.IsNull()) | |
a577aaab | 5462 | { |
8625ef7e | 5463 | aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver()); |
a577aaab | 5464 | aCaps = &aDriver->ChangeOptions(); |
5465 | } | |
5466 | ||
5467 | if (theArgNb < 2) | |
5468 | { | |
5469 | theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n"; | |
5470 | theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n"; | |
abe46077 | 5471 | theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n"; |
8625ef7e | 5472 | theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n"; |
f978241f | 5473 | theDI << "VSync: " << aCaps->swapInterval << "\n"; |
4e1523ef | 5474 | theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n"; |
f978241f | 5475 | theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n"; |
a577aaab | 5476 | return 0; |
5477 | } | |
5478 | ||
8625ef7e | 5479 | ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView()); |
a577aaab | 5480 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
5481 | { | |
8625ef7e | 5482 | Standard_CString anArg = theArgVec[anArgIter]; |
5483 | TCollection_AsciiString anArgCase (anArg); | |
5484 | anArgCase.LowerCase(); | |
5485 | if (anUpdateTool.parseRedrawMode (anArg)) | |
5486 | { | |
5487 | continue; | |
5488 | } | |
f978241f | 5489 | else if (anArgCase == "-vsync" |
5490 | || anArgCase == "-swapinterval") | |
5491 | { | |
5492 | Standard_Boolean toEnable = Standard_True; | |
5493 | if (++anArgIter < theArgNb | |
5494 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5495 | { | |
5496 | --anArgIter; | |
5497 | } | |
5498 | aCaps->swapInterval = toEnable; | |
5499 | } | |
8625ef7e | 5500 | else if (anArgCase == "-ffp") |
5501 | { | |
5502 | Standard_Boolean toEnable = Standard_True; | |
5503 | if (++anArgIter < theArgNb | |
5504 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5505 | { | |
5506 | --anArgIter; | |
5507 | } | |
5508 | aCaps->ffpEnable = toEnable; | |
5509 | } | |
5510 | else if (anArgCase == "-vbo") | |
a577aaab | 5511 | { |
8625ef7e | 5512 | Standard_Boolean toEnable = Standard_True; |
5513 | if (++anArgIter < theArgNb | |
5514 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5515 | { | |
5516 | --anArgIter; | |
5517 | } | |
5518 | aCaps->vboDisable = !toEnable; | |
a577aaab | 5519 | } |
8625ef7e | 5520 | else if (anArgCase == "-sprite" |
5521 | || anArgCase == "-sprites") | |
a577aaab | 5522 | { |
8625ef7e | 5523 | Standard_Boolean toEnable = Standard_True; |
5524 | if (++anArgIter < theArgNb | |
5525 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5526 | { | |
5527 | --anArgIter; | |
5528 | } | |
5529 | aCaps->pntSpritesDisable = !toEnable; | |
a577aaab | 5530 | } |
8625ef7e | 5531 | else if (anArgCase == "-softmode") |
abe46077 | 5532 | { |
8625ef7e | 5533 | Standard_Boolean toEnable = Standard_True; |
5534 | if (++anArgIter < theArgNb | |
5535 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5536 | { | |
5537 | --anArgIter; | |
5538 | } | |
5539 | aCaps->contextNoAccel = toEnable; | |
5540 | } | |
5541 | else if (anArgCase == "-accel" | |
5542 | || anArgCase == "-acceleration") | |
5543 | { | |
5544 | Standard_Boolean toEnable = Standard_True; | |
5545 | if (++anArgIter < theArgNb | |
5546 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5547 | { | |
5548 | --anArgIter; | |
5549 | } | |
5550 | aCaps->contextNoAccel = !toEnable; | |
abe46077 | 5551 | } |
4e1523ef | 5552 | else if (anArgCase == "-compat" |
5553 | || anArgCase == "-compatprofile" | |
5554 | || anArgCase == "-compatible" | |
5555 | || anArgCase == "-compatibleprofile") | |
5556 | { | |
5557 | Standard_Boolean toEnable = Standard_True; | |
5558 | if (++anArgIter < theArgNb | |
5559 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5560 | { | |
5561 | --anArgIter; | |
5562 | } | |
5563 | aCaps->contextCompatible = toEnable; | |
5564 | if (!aCaps->contextCompatible) | |
5565 | { | |
5566 | aCaps->ffpEnable = Standard_False; | |
5567 | } | |
5568 | } | |
5569 | else if (anArgCase == "-core" | |
5570 | || anArgCase == "-coreprofile") | |
5571 | { | |
5572 | Standard_Boolean toEnable = Standard_True; | |
5573 | if (++anArgIter < theArgNb | |
5574 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5575 | { | |
5576 | --anArgIter; | |
5577 | } | |
5578 | aCaps->contextCompatible = !toEnable; | |
5579 | if (!aCaps->contextCompatible) | |
5580 | { | |
5581 | aCaps->ffpEnable = Standard_False; | |
5582 | } | |
5583 | } | |
f978241f | 5584 | else if (anArgCase == "-stereo" |
5585 | || anArgCase == "-quadbuffer") | |
5586 | { | |
5587 | Standard_Boolean toEnable = Standard_True; | |
5588 | if (++anArgIter < theArgNb | |
5589 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
5590 | { | |
5591 | --anArgIter; | |
5592 | } | |
5593 | aCaps->contextStereo = toEnable; | |
5594 | } | |
a577aaab | 5595 | else |
5596 | { | |
8625ef7e | 5597 | std::cout << "Error: unknown argument '" << anArg << "'\n"; |
5598 | return 1; | |
a577aaab | 5599 | } |
5600 | } | |
5601 | if (aCaps != &ViewerTest_myDefaultCaps) | |
5602 | { | |
5603 | ViewerTest_myDefaultCaps = *aCaps; | |
5604 | } | |
5605 | return 0; | |
5606 | } | |
5607 | ||
f0430952 | 5608 | //============================================================================== |
5609 | //function : VMemGpu | |
5610 | //purpose : | |
5611 | //============================================================================== | |
5612 | ||
5613 | static int VMemGpu (Draw_Interpretor& theDI, | |
5614 | Standard_Integer theArgNb, | |
5615 | const char** theArgVec) | |
5616 | { | |
5617 | // get the context | |
5618 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); | |
5619 | if (aContextAIS.IsNull()) | |
5620 | { | |
5621 | std::cerr << "No active view. Please call vinit.\n"; | |
5622 | return 1; | |
5623 | } | |
5624 | ||
dc3fe572 | 5625 | Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver(); |
f0430952 | 5626 | if (aDriver.IsNull()) |
5627 | { | |
5628 | std::cerr << "Graphic driver not available.\n"; | |
5629 | return 1; | |
5630 | } | |
5631 | ||
5632 | Standard_Size aFreeBytes = 0; | |
5633 | TCollection_AsciiString anInfo; | |
5634 | if (!aDriver->MemoryInfo (aFreeBytes, anInfo)) | |
5635 | { | |
5636 | std::cerr << "Information not available.\n"; | |
5637 | return 1; | |
5638 | } | |
5639 | ||
5640 | if (theArgNb > 1 && *theArgVec[1] == 'f') | |
5641 | { | |
5642 | theDI << Standard_Real (aFreeBytes); | |
5643 | } | |
5644 | else | |
5645 | { | |
5646 | theDI << anInfo; | |
5647 | } | |
5648 | ||
5649 | return 0; | |
5650 | } | |
5651 | ||
85e096c3 | 5652 | // ============================================================================== |
5653 | // function : VReadPixel | |
5654 | // purpose : | |
5655 | // ============================================================================== | |
5656 | static int VReadPixel (Draw_Interpretor& theDI, | |
5657 | Standard_Integer theArgNb, | |
5658 | const char** theArgVec) | |
5659 | { | |
5660 | // get the active view | |
5661 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5662 | if (aView.IsNull()) | |
5663 | { | |
5664 | std::cerr << "No active view. Please call vinit.\n"; | |
5665 | return 1; | |
5666 | } | |
5667 | else if (theArgNb < 3) | |
5668 | { | |
5669 | std::cerr << "Usage : " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]\n"; | |
5670 | return 1; | |
5671 | } | |
5672 | ||
692613e5 | 5673 | Image_PixMap::ImgFormat aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; |
5674 | Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA; | |
5675 | ||
85e096c3 | 5676 | Standard_Integer aWidth, aHeight; |
5677 | aView->Window()->Size (aWidth, aHeight); | |
91322f44 | 5678 | const Standard_Integer anX = Draw::Atoi (theArgVec[1]); |
5679 | const Standard_Integer anY = Draw::Atoi (theArgVec[2]); | |
85e096c3 | 5680 | if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight) |
5681 | { | |
5682 | std::cerr << "Pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")\n"; | |
5683 | return 1; | |
5684 | } | |
5685 | ||
5686 | Standard_Boolean toShowName = Standard_False; | |
5687 | Standard_Boolean toShowHls = Standard_False; | |
5688 | for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter) | |
5689 | { | |
29cb310a | 5690 | const char* aParam = theArgVec[anIter]; |
5691 | if ( strcasecmp( aParam, "rgb" ) == 0 ) | |
85e096c3 | 5692 | { |
692613e5 | 5693 | aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; |
5694 | aBufferType = Graphic3d_BT_RGB; | |
85e096c3 | 5695 | } |
29cb310a | 5696 | else if ( strcasecmp( aParam, "hls" ) == 0 ) |
85e096c3 | 5697 | { |
692613e5 | 5698 | aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; |
5699 | aBufferType = Graphic3d_BT_RGB; | |
85e096c3 | 5700 | toShowHls = Standard_True; |
5701 | } | |
29cb310a | 5702 | else if ( strcasecmp( aParam, "rgbf" ) == 0 ) |
85e096c3 | 5703 | { |
692613e5 | 5704 | aFormat = Image_PixMap::ImgRGBF; |
5705 | aBufferType = Graphic3d_BT_RGB; | |
85e096c3 | 5706 | } |
29cb310a | 5707 | else if ( strcasecmp( aParam, "rgba" ) == 0 ) |
85e096c3 | 5708 | { |
692613e5 | 5709 | aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; |
5710 | aBufferType = Graphic3d_BT_RGBA; | |
85e096c3 | 5711 | } |
29cb310a | 5712 | else if ( strcasecmp( aParam, "rgbaf" ) == 0 ) |
85e096c3 | 5713 | { |
692613e5 | 5714 | aFormat = Image_PixMap::ImgRGBAF; |
5715 | aBufferType = Graphic3d_BT_RGBA; | |
85e096c3 | 5716 | } |
29cb310a | 5717 | else if ( strcasecmp( aParam, "depth" ) == 0 ) |
85e096c3 | 5718 | { |
692613e5 | 5719 | aFormat = Image_PixMap::ImgGrayF; |
5720 | aBufferType = Graphic3d_BT_Depth; | |
85e096c3 | 5721 | } |
29cb310a | 5722 | else if ( strcasecmp( aParam, "name" ) == 0 ) |
85e096c3 | 5723 | { |
5724 | toShowName = Standard_True; | |
5725 | } | |
5726 | } | |
5727 | ||
692613e5 | 5728 | Image_PixMap anImage; |
5729 | if (!anImage.InitTrash (aFormat, aWidth, aHeight)) | |
5730 | { | |
5731 | std::cerr << "Image allocation failed\n"; | |
5732 | return 1; | |
5733 | } | |
5734 | else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType)) | |
85e096c3 | 5735 | { |
5736 | std::cerr << "Image dump failed\n"; | |
5737 | return 1; | |
5738 | } | |
5739 | ||
5740 | Quantity_Parameter anAlpha; | |
692613e5 | 5741 | Quantity_Color aColor = anImage.PixelColor (anX, anY, anAlpha); |
85e096c3 | 5742 | if (toShowName) |
5743 | { | |
692613e5 | 5744 | if (aBufferType == Graphic3d_BT_RGBA) |
85e096c3 | 5745 | { |
64c759f8 | 5746 | theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha; |
85e096c3 | 5747 | } |
5748 | else | |
5749 | { | |
64c759f8 | 5750 | theDI << Quantity_Color::StringName (aColor.Name()); |
85e096c3 | 5751 | } |
5752 | } | |
5753 | else | |
5754 | { | |
5755 | switch (aBufferType) | |
5756 | { | |
5757 | default: | |
692613e5 | 5758 | case Graphic3d_BT_RGB: |
85e096c3 | 5759 | { |
5760 | if (toShowHls) | |
5761 | { | |
64c759f8 | 5762 | theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation(); |
85e096c3 | 5763 | } |
5764 | else | |
5765 | { | |
64c759f8 | 5766 | theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue(); |
85e096c3 | 5767 | } |
5768 | break; | |
5769 | } | |
692613e5 | 5770 | case Graphic3d_BT_RGBA: |
85e096c3 | 5771 | { |
64c759f8 | 5772 | theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha; |
85e096c3 | 5773 | break; |
5774 | } | |
692613e5 | 5775 | case Graphic3d_BT_Depth: |
85e096c3 | 5776 | { |
64c759f8 | 5777 | theDI << aColor.Red(); |
85e096c3 | 5778 | break; |
5779 | } | |
5780 | } | |
5781 | } | |
5782 | ||
5783 | return 0; | |
5784 | } | |
5785 | ||
692613e5 | 5786 | //============================================================================== |
5787 | //function : VDiffImage | |
5788 | //purpose : The draw-command compares two images. | |
5789 | //============================================================================== | |
5790 | ||
5791 | static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
5792 | { | |
5793 | if (theArgNb < 6) | |
5794 | { | |
5795 | theDI << "Not enough arguments.\n"; | |
5796 | return 1; | |
5797 | } | |
5798 | ||
5799 | // image file names | |
5800 | const char* anImgPathRef = theArgVec[1]; | |
5801 | const char* anImgPathNew = theArgVec[2]; | |
5802 | ||
5803 | // get string tolerance and check its validity | |
91322f44 | 5804 | Standard_Real aTolColor = Draw::Atof (theArgVec[3]); |
692613e5 | 5805 | if (aTolColor < 0.0) |
5806 | aTolColor = 0.0; | |
5807 | if (aTolColor > 1.0) | |
5808 | aTolColor = 1.0; | |
5809 | ||
91322f44 | 5810 | Standard_Boolean toBlackWhite = (Draw::Atoi (theArgVec[4]) == 1); |
5811 | Standard_Boolean isBorderFilterOn = (Draw::Atoi (theArgVec[5]) == 1); | |
692613e5 | 5812 | |
5813 | // image file of difference | |
5814 | const char* aDiffImagePath = (theArgNb >= 7) ? theArgVec[6] : NULL; | |
5815 | ||
5816 | // compare the images | |
5817 | Image_Diff aComparer; | |
5818 | if (!aComparer.Init (anImgPathRef, anImgPathNew, toBlackWhite)) | |
5819 | { | |
5820 | return 1; | |
5821 | } | |
5822 | ||
5823 | aComparer.SetColorTolerance (aTolColor); | |
5824 | aComparer.SetBorderFilterOn (isBorderFilterOn); | |
5825 | Standard_Integer aDiffColorsNb = aComparer.Compare(); | |
5826 | theDI << aDiffColorsNb << "\n"; | |
5827 | ||
5828 | // save image of difference | |
936f43da | 5829 | if (aDiffColorsNb >0 && aDiffImagePath != NULL) |
692613e5 | 5830 | { |
5831 | aComparer.SaveDiffImage (aDiffImagePath); | |
5832 | } | |
5833 | ||
5834 | return 0; | |
5835 | } | |
5836 | ||
4754e164 | 5837 | //======================================================================= |
5838 | //function : VSelect | |
5839 | //purpose : Emulates different types of selection by mouse: | |
5840 | // 1) single click selection | |
5841 | // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2) | |
5842 | // 3) selection with polygon having corners at | |
dc3fe572 | 5843 | // pixel positions (x1,y1),...,(xn,yn) |
4754e164 | 5844 | // 4) any of these selections with shift button pressed |
5845 | //======================================================================= | |
5846 | static Standard_Integer VSelect (Draw_Interpretor& di, | |
5847 | Standard_Integer argc, | |
5848 | const char ** argv) | |
5849 | { | |
dc3fe572 | 5850 | if(argc < 3) |
4754e164 | 5851 | { |
5852 | di << "Usage : " << argv[0] << " x1 y1 [x2 y2 [... xn yn]] [shift_selection = 1|0]" << "\n"; | |
5853 | return 1; | |
5854 | } | |
5855 | ||
5856 | Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext(); | |
dc3fe572 | 5857 | if(myAIScontext.IsNull()) |
4754e164 | 5858 | { |
5859 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
5860 | return 1; | |
5861 | } | |
2157d6ac | 5862 | |
5863 | const Standard_Boolean isShiftSelection = (argc > 3 && !(argc % 2) && (atoi (argv[argc - 1]) == 1)); | |
5864 | Standard_Integer aCoordsNb = isShiftSelection ? argc - 2 : argc - 1; | |
5865 | TCollection_AsciiString anArg; | |
5866 | anArg = isShiftSelection ? argv[argc - 3] : argv[argc - 2]; | |
5867 | anArg.LowerCase(); | |
5868 | if (anArg == "-allowoverlap") | |
5869 | { | |
5870 | Standard_Boolean isValidated = isShiftSelection ? argc == 8 | |
5871 | : argc == 7; | |
5872 | if (!isValidated) | |
5873 | { | |
5874 | di << "Wrong number of arguments! -allowoverlap key is applied only for rectangle selection"; | |
5875 | return 1; | |
5876 | } | |
5877 | ||
5878 | Standard_Integer isToAllow = isShiftSelection ? Draw::Atoi(argv[argc - 2]) : Draw::Atoi(argv[argc - 1]); | |
5879 | myAIScontext->MainSelector()->AllowOverlapDetection((Standard_Boolean)isToAllow); | |
5880 | aCoordsNb -= 2; | |
5881 | } | |
5882 | ||
4754e164 | 5883 | Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager(); |
5884 | aCurrentEventManager->MoveTo(atoi(argv[1]),atoi(argv[2])); | |
2157d6ac | 5885 | if(aCoordsNb == 2) |
4754e164 | 5886 | { |
5887 | if(isShiftSelection) | |
5888 | aCurrentEventManager->ShiftSelect(); | |
5889 | else | |
5890 | aCurrentEventManager->Select(); | |
5891 | } | |
2157d6ac | 5892 | else if(aCoordsNb == 4) |
4754e164 | 5893 | { |
5894 | if(isShiftSelection) | |
2157d6ac | 5895 | aCurrentEventManager->ShiftSelect (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False); |
4754e164 | 5896 | else |
2157d6ac | 5897 | aCurrentEventManager->Select (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False); |
4754e164 | 5898 | } |
5899 | else | |
5900 | { | |
2157d6ac | 5901 | TColgp_Array1OfPnt2d aPolyline (1,aCoordsNb / 2); |
4754e164 | 5902 | |
2157d6ac | 5903 | for(Standard_Integer i=1;i<=aCoordsNb / 2;++i) |
4754e164 | 5904 | aPolyline.SetValue(i,gp_Pnt2d(atoi(argv[2*i-1]),atoi(argv[2*i]))); |
5905 | ||
5906 | if(isShiftSelection) | |
5907 | aCurrentEventManager->ShiftSelect(aPolyline); | |
5908 | else | |
5909 | aCurrentEventManager->Select(aPolyline); | |
5910 | } | |
5911 | return 0; | |
5912 | } | |
5913 | ||
5914 | //======================================================================= | |
5915 | //function : VMoveTo | |
dc3fe572 | 5916 | //purpose : Emulates cursor movement to defined pixel position |
4754e164 | 5917 | //======================================================================= |
5918 | static Standard_Integer VMoveTo (Draw_Interpretor& di, | |
5919 | Standard_Integer argc, | |
5920 | const char ** argv) | |
5921 | { | |
dc3fe572 | 5922 | if(argc != 3) |
4754e164 | 5923 | { |
5924 | di << "Usage : " << argv[0] << " x y" << "\n"; | |
5925 | return 1; | |
5926 | } | |
5927 | ||
5928 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
dc3fe572 | 5929 | if(aContext.IsNull()) |
4754e164 | 5930 | { |
5931 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
5932 | return 1; | |
5933 | } | |
5934 | ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2])); | |
5935 | return 0; | |
5936 | } | |
5937 | ||
197ac94e | 5938 | //================================================================================================= |
4754e164 | 5939 | //function : VViewParams |
dc3fe572 | 5940 | //purpose : Gets or sets AIS View characteristics |
197ac94e | 5941 | //================================================================================================= |
5942 | static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
4754e164 | 5943 | { |
197ac94e | 5944 | Handle(V3d_View) anAISView = ViewerTest::CurrentView(); |
5945 | if (anAISView.IsNull()) | |
4754e164 | 5946 | { |
197ac94e | 5947 | std::cout << theArgVec[0] << ": please initialize or activate view.\n"; |
4754e164 | 5948 | return 1; |
5949 | } | |
197ac94e | 5950 | |
5951 | if (theArgsNb == 1) | |
4754e164 | 5952 | { |
197ac94e | 5953 | // print all of the available view parameters |
5954 | Quantity_Factor anAISViewScale = anAISView->Scale(); | |
5955 | ||
4754e164 | 5956 | Standard_Real anAISViewProjX = 0.0; |
5957 | Standard_Real anAISViewProjY = 0.0; | |
5958 | Standard_Real anAISViewProjZ = 0.0; | |
197ac94e | 5959 | anAISView->Proj (anAISViewProjX, anAISViewProjY, anAISViewProjZ); |
5960 | ||
4754e164 | 5961 | Standard_Real anAISViewUpX = 0.0; |
5962 | Standard_Real anAISViewUpY = 0.0; | |
5963 | Standard_Real anAISViewUpZ = 0.0; | |
197ac94e | 5964 | anAISView->Up (anAISViewUpX, anAISViewUpY, anAISViewUpZ); |
5965 | ||
4754e164 | 5966 | Standard_Real anAISViewAtX = 0.0; |
5967 | Standard_Real anAISViewAtY = 0.0; | |
5968 | Standard_Real anAISViewAtZ = 0.0; | |
197ac94e | 5969 | anAISView->At (anAISViewAtX, anAISViewAtY, anAISViewAtZ); |
5970 | ||
5971 | Standard_Real anAISViewEyeX = 0.0; | |
5972 | Standard_Real anAISViewEyeY = 0.0; | |
5973 | Standard_Real anAISViewEyeZ = 0.0; | |
5974 | anAISView->Eye (anAISViewEyeX, anAISViewEyeY, anAISViewEyeZ); | |
5975 | ||
5976 | theDi << "Scale of current view: " << anAISViewScale << "\n"; | |
5977 | theDi << "Proj on X : " << anAISViewProjX << "; on Y: " << anAISViewProjY << "; on Z: " << anAISViewProjZ << "\n"; | |
5978 | theDi << "Up on X : " << anAISViewUpX << "; on Y: " << anAISViewUpY << "; on Z: " << anAISViewUpZ << "\n"; | |
5979 | theDi << "At on X : " << anAISViewAtX << "; on Y: " << anAISViewAtY << "; on Z: " << anAISViewAtZ << "\n"; | |
5980 | theDi << "Eye on X : " << anAISViewEyeX << "; on Y: " << anAISViewEyeY << "; on Z: " << anAISViewEyeZ << "\n"; | |
5981 | return 0; | |
4754e164 | 5982 | } |
197ac94e | 5983 | |
5984 | // ------------------------- | |
5985 | // Parse options and values | |
5986 | // ------------------------- | |
5987 | ||
900f7229 | 5988 | NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfKeysByValues; |
197ac94e | 5989 | TCollection_AsciiString aParseKey; |
5990 | for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) | |
5991 | { | |
5992 | TCollection_AsciiString anArg (theArgVec [anArgIt]); | |
5993 | ||
5994 | if (anArg.Value (1) == '-' && !anArg.IsRealValue()) | |
5995 | { | |
5996 | aParseKey = anArg; | |
5997 | aParseKey.Remove (1); | |
5998 | aParseKey.UpperCase(); | |
900f7229 | 5999 | aMapOfKeysByValues.Bind (aParseKey, new TColStd_HSequenceOfAsciiString); |
197ac94e | 6000 | continue; |
6001 | } | |
6002 | ||
3dfe95cd | 6003 | if (aParseKey.IsEmpty()) |
6004 | { | |
6005 | std::cout << theArgVec[0] << ": values should be passed with key.\n"; | |
6006 | std::cout << "Type help for more information.\n"; | |
6007 | return 1; | |
6008 | } | |
6009 | ||
900f7229 | 6010 | aMapOfKeysByValues(aParseKey)->Append (anArg); |
197ac94e | 6011 | } |
6012 | ||
6013 | // --------------------------------------------- | |
6014 | // Change or print parameters, order plays role | |
6015 | // --------------------------------------------- | |
6016 | ||
6017 | // Check arguments for validity | |
900f7229 | 6018 | NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfKeysByValues); |
197ac94e | 6019 | for (; aMapIt.More(); aMapIt.Next()) |
4754e164 | 6020 | { |
197ac94e | 6021 | const TCollection_AsciiString& aKey = aMapIt.Key(); |
900f7229 | 6022 | const Handle(TColStd_HSequenceOfAsciiString)& aValues = aMapIt.Value(); |
6023 | ||
6024 | if (!(aKey.IsEqual ("SCALE") && (aValues->Length() == 1 || aValues->IsEmpty())) | |
6025 | && !(aKey.IsEqual ("SIZE") && (aValues->Length() == 1 || aValues->IsEmpty())) | |
6026 | && !(aKey.IsEqual ("EYE") && (aValues->Length() == 3 || aValues->IsEmpty())) | |
6027 | && !(aKey.IsEqual ("AT") && (aValues->Length() == 3 || aValues->IsEmpty())) | |
6028 | && !(aKey.IsEqual ("UP") && (aValues->Length() == 3 || aValues->IsEmpty())) | |
6029 | && !(aKey.IsEqual ("PROJ") && (aValues->Length() == 3 || aValues->IsEmpty())) | |
6030 | && !(aKey.IsEqual ("CENTER") && aValues->Length() == 2)) | |
197ac94e | 6031 | { |
6032 | TCollection_AsciiString aLowerKey; | |
6033 | aLowerKey = "-"; | |
6034 | aLowerKey += aKey; | |
6035 | aLowerKey.LowerCase(); | |
6036 | std::cout << theArgVec[0] << ": " << aLowerKey << " is unknown option, or number of arguments is invalid.\n"; | |
6037 | std::cout << "Type help for more information.\n"; | |
6038 | return 1; | |
6039 | } | |
4754e164 | 6040 | } |
197ac94e | 6041 | |
900f7229 | 6042 | Handle(TColStd_HSequenceOfAsciiString) aValues; |
197ac94e | 6043 | |
6044 | // Change view parameters in proper order | |
6045 | if (aMapOfKeysByValues.Find ("SCALE", aValues)) | |
6046 | { | |
900f7229 | 6047 | if (aValues->IsEmpty()) |
197ac94e | 6048 | { |
6049 | theDi << "Scale: " << anAISView->Scale() << "\n"; | |
6050 | } | |
6051 | else | |
6052 | { | |
900f7229 | 6053 | anAISView->SetScale (aValues->Value(1).RealValue()); |
197ac94e | 6054 | } |
6055 | } | |
3dfe95cd | 6056 | if (aMapOfKeysByValues.Find ("SIZE", aValues)) |
6057 | { | |
900f7229 | 6058 | if (aValues->IsEmpty()) |
3dfe95cd | 6059 | { |
6060 | Standard_Real aSizeX = 0.0; | |
6061 | Standard_Real aSizeY = 0.0; | |
6062 | anAISView->Size (aSizeX, aSizeY); | |
6063 | theDi << "Size X: " << aSizeX << " Y: " << aSizeY << "\n"; | |
6064 | } | |
6065 | else | |
6066 | { | |
900f7229 | 6067 | anAISView->SetSize (aValues->Value(1).RealValue()); |
3dfe95cd | 6068 | } |
6069 | } | |
197ac94e | 6070 | if (aMapOfKeysByValues.Find ("EYE", aValues)) |
6071 | { | |
900f7229 | 6072 | if (aValues->IsEmpty()) |
197ac94e | 6073 | { |
6074 | Standard_Real anEyeX = 0.0; | |
6075 | Standard_Real anEyeY = 0.0; | |
6076 | Standard_Real anEyeZ = 0.0; | |
6077 | anAISView->Eye (anEyeX, anEyeY, anEyeZ); | |
6078 | theDi << "Eye X: " << anEyeX << " Y: " << anEyeY << " Z: " << anEyeZ << "\n"; | |
6079 | } | |
6080 | else | |
6081 | { | |
900f7229 | 6082 | anAISView->SetEye (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue()); |
197ac94e | 6083 | } |
6084 | } | |
6085 | if (aMapOfKeysByValues.Find ("AT", aValues)) | |
6086 | { | |
900f7229 | 6087 | if (aValues->IsEmpty()) |
197ac94e | 6088 | { |
6089 | Standard_Real anAtX = 0.0; | |
6090 | Standard_Real anAtY = 0.0; | |
6091 | Standard_Real anAtZ = 0.0; | |
6092 | anAISView->At (anAtX, anAtY, anAtZ); | |
6093 | theDi << "At X: " << anAtX << " Y: " << anAtY << " Z: " << anAtZ << "\n"; | |
6094 | } | |
6095 | else | |
6096 | { | |
900f7229 | 6097 | anAISView->SetAt (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue()); |
197ac94e | 6098 | } |
6099 | } | |
6100 | if (aMapOfKeysByValues.Find ("PROJ", aValues)) | |
6101 | { | |
900f7229 | 6102 | if (aValues->IsEmpty()) |
197ac94e | 6103 | { |
6104 | Standard_Real aProjX = 0.0; | |
6105 | Standard_Real aProjY = 0.0; | |
6106 | Standard_Real aProjZ = 0.0; | |
6107 | anAISView->Proj (aProjX, aProjY, aProjZ); | |
6108 | theDi << "Proj X: " << aProjX << " Y: " << aProjY << " Z: " << aProjZ << "\n"; | |
6109 | } | |
6110 | else | |
6111 | { | |
900f7229 | 6112 | anAISView->SetProj (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue()); |
197ac94e | 6113 | } |
6114 | } | |
6115 | if (aMapOfKeysByValues.Find ("UP", aValues)) | |
6116 | { | |
900f7229 | 6117 | if (aValues->IsEmpty()) |
197ac94e | 6118 | { |
6119 | Standard_Real anUpX = 0.0; | |
6120 | Standard_Real anUpY = 0.0; | |
6121 | Standard_Real anUpZ = 0.0; | |
6122 | anAISView->Up (anUpX, anUpY, anUpZ); | |
6123 | theDi << "Up X: " << anUpX << " Y: " << anUpY << " Z: " << anUpZ << "\n"; | |
6124 | } | |
6125 | else | |
6126 | { | |
900f7229 | 6127 | anAISView->SetUp (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue()); |
197ac94e | 6128 | } |
6129 | } | |
6130 | if (aMapOfKeysByValues.Find ("CENTER", aValues)) | |
6131 | { | |
900f7229 | 6132 | anAISView->SetCenter (aValues->Value(1).IntegerValue(), aValues->Value(2).IntegerValue()); |
197ac94e | 6133 | } |
6134 | ||
4754e164 | 6135 | return 0; |
6136 | } | |
6137 | ||
6138 | //======================================================================= | |
6139 | //function : VChangeSelected | |
dc3fe572 | 6140 | //purpose : Adds the shape to selection or remove one from it |
4754e164 | 6141 | //======================================================================= |
6142 | static Standard_Integer VChangeSelected (Draw_Interpretor& di, | |
6143 | Standard_Integer argc, | |
6144 | const char ** argv) | |
6145 | { | |
6146 | if(argc != 2) | |
6147 | { | |
6148 | di<<"Usage : " << argv[0] << " shape \n"; | |
6149 | return 1; | |
6150 | } | |
6151 | //get AIS_Shape: | |
6152 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6153 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); | |
6154 | TCollection_AsciiString aName(argv[1]); | |
6155 | Handle(AIS_InteractiveObject) anAISObject; | |
6156 | ||
6157 | if(!aMap.IsBound2(aName)) | |
6158 | { | |
6159 | di<<"Use 'vdisplay' before"; | |
6160 | return 1; | |
6161 | } | |
6162 | else | |
6163 | { | |
6164 | anAISObject = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName)); | |
6165 | if(anAISObject.IsNull()){ | |
6166 | di<<"No interactive object \n"; | |
6167 | return 1; | |
6168 | } | |
6169 | ||
6170 | if(aContext->HasOpenedContext()) | |
6171 | { | |
6172 | aContext->AddOrRemoveSelected(anAISObject); | |
6173 | } | |
dc3fe572 | 6174 | else |
4754e164 | 6175 | { |
6176 | aContext->AddOrRemoveCurrentObject(anAISObject); | |
6177 | } | |
6178 | } | |
6179 | return 0; | |
6180 | } | |
6181 | ||
6182 | //======================================================================= | |
6183 | //function : VZClipping | |
dc3fe572 | 6184 | //purpose : Gets or sets ZClipping mode, width and depth |
4754e164 | 6185 | //======================================================================= |
6186 | static Standard_Integer VZClipping (Draw_Interpretor& di, | |
6187 | Standard_Integer argc, | |
6188 | const char ** argv) | |
6189 | { | |
dc3fe572 | 6190 | if(argc>4) |
4754e164 | 6191 | { |
6192 | di << "Usage : " << argv[0] << " [mode] [depth width]" << "\n" | |
6193 | <<"mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n"; | |
6194 | return -1; | |
6195 | } | |
6196 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
dc3fe572 | 6197 | if(aContext.IsNull()) |
4754e164 | 6198 | { |
6199 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6200 | return 1; | |
6201 | } | |
6202 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
1d47d8d0 | 6203 | V3d_TypeOfZclipping aZClippingMode = V3d_OFF; |
4754e164 | 6204 | if(argc==1) |
6205 | { | |
6206 | TCollection_AsciiString aZClippingModeString; | |
6207 | Quantity_Length aDepth, aWidth; | |
6208 | aZClippingMode = aView->ZClipping(aDepth, aWidth); | |
6209 | switch (aZClippingMode) | |
6210 | { | |
6211 | case V3d_OFF: | |
6212 | aZClippingModeString.Copy("OFF"); | |
6213 | break; | |
6214 | case V3d_BACK: | |
6215 | aZClippingModeString.Copy("BACK"); | |
6216 | break; | |
6217 | case V3d_FRONT: | |
6218 | aZClippingModeString.Copy("FRONT"); | |
6219 | break; | |
6220 | case V3d_SLICE: | |
6221 | aZClippingModeString.Copy("SLICE"); | |
6222 | break; | |
6223 | default: | |
6224 | aZClippingModeString.Copy(TCollection_AsciiString(aZClippingMode)); | |
6225 | break; | |
6226 | } | |
6227 | di << "ZClippingMode = " << aZClippingModeString.ToCString() << "\n" | |
6228 | << "ZClipping depth = " << aDepth << "\n" | |
6229 | << "ZClipping width = " << aWidth << "\n"; | |
6230 | } | |
6231 | else | |
6232 | { | |
6233 | if(argc !=3) | |
6234 | { | |
6235 | Standard_Integer aStatus = 0; | |
6236 | if ( strcmp (argv [1], "OFF") == 0 ) { | |
6237 | aStatus = 1; | |
6238 | aZClippingMode = V3d_OFF; | |
6239 | } | |
6240 | if ( strcmp (argv [1], "BACK") == 0 ) { | |
6241 | aStatus = 1; | |
6242 | aZClippingMode = V3d_BACK; | |
6243 | } | |
6244 | if ( strcmp (argv [1], "FRONT") == 0 ) { | |
6245 | aStatus = 1; | |
6246 | aZClippingMode = V3d_FRONT; | |
6247 | } | |
6248 | if ( strcmp (argv [1], "SLICE") == 0 ) { | |
6249 | aStatus = 1; | |
6250 | aZClippingMode = V3d_SLICE; | |
6251 | } | |
6252 | if (aStatus != 1) | |
6253 | { | |
6254 | di << "Bad mode; Usage : " << argv[0] << " [mode] [depth width]" << "\n" | |
6255 | << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n"; | |
6256 | return 1; | |
dc3fe572 | 6257 | } |
4754e164 | 6258 | aView->SetZClippingType(aZClippingMode); |
6259 | } | |
6260 | if(argc >2) | |
6261 | { | |
6262 | Quantity_Length aDepth = 0., aWidth = 1.; | |
6263 | if(argc == 3) | |
6264 | { | |
6b62b2da | 6265 | aDepth = Draw::Atof (argv[1]); |
6266 | aWidth = Draw::Atof (argv[2]); | |
4754e164 | 6267 | } |
6268 | else if(argc == 4) | |
6269 | { | |
6b62b2da | 6270 | aDepth = Draw::Atof (argv[2]); |
6271 | aWidth = Draw::Atof (argv[3]); | |
4754e164 | 6272 | } |
dc3fe572 | 6273 | |
4754e164 | 6274 | if(aDepth<0. || aDepth>1.) |
6275 | { | |
6276 | di << "Bad depth; Usage : " << argv[0] << " [mode] [depth width]" << "\n" | |
6277 | << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n"; | |
6278 | return 1; | |
6279 | } | |
6280 | if(aWidth<0. || aWidth>1.) | |
6281 | { | |
6282 | di << "Bad width; Usage : " << argv[0] << " [mode] [depth width]" << "\n" | |
6283 | << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n"; | |
6284 | return 1; | |
6285 | } | |
6286 | ||
6287 | aView->SetZClippingDepth(aDepth); | |
6288 | aView->SetZClippingWidth(aWidth); | |
6289 | } | |
6290 | aView->Redraw(); | |
6291 | } | |
6292 | return 0; | |
6293 | } | |
6294 | ||
6295 | //======================================================================= | |
6296 | //function : VNbSelected | |
dc3fe572 | 6297 | //purpose : Returns number of selected objects |
4754e164 | 6298 | //======================================================================= |
6299 | static Standard_Integer VNbSelected (Draw_Interpretor& di, | |
6300 | Standard_Integer argc, | |
6301 | const char ** argv) | |
6302 | { | |
6303 | if(argc != 1) | |
6304 | { | |
6305 | di << "Usage : " << argv[0] << "\n"; | |
6306 | return 1; | |
6307 | } | |
6308 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6309 | if(aContext.IsNull()) | |
6310 | { | |
6311 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6312 | return 1; | |
6313 | } | |
6314 | di << aContext->NbSelected() << "\n"; | |
6315 | return 0; | |
6316 | } | |
6317 | ||
6318 | //======================================================================= | |
6319 | //function : VAntialiasing | |
dc3fe572 | 6320 | //purpose : Switches altialiasing on or off |
4754e164 | 6321 | //======================================================================= |
6322 | static Standard_Integer VAntialiasing (Draw_Interpretor& di, | |
6323 | Standard_Integer argc, | |
6324 | const char ** argv) | |
6325 | { | |
6326 | if(argc > 2) | |
6327 | { | |
6328 | di << "Usage : " << argv[0] << " [1|0]" << "\n"; | |
6329 | return 1; | |
6330 | } | |
6331 | ||
6332 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6333 | if(aContext.IsNull()) | |
6334 | { | |
6335 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6336 | return 1; | |
6337 | } | |
6338 | ||
6339 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6340 | ||
6341 | if((argc == 2) && (atof(argv[1]) == 0)) | |
6342 | aView->SetAntialiasingOff(); | |
6343 | else | |
6344 | aView->SetAntialiasingOn(); | |
6345 | aView->Update(); | |
6346 | return 0; | |
6347 | } | |
6348 | ||
6349 | //======================================================================= | |
6350 | //function : VPurgeDisplay | |
dc3fe572 | 6351 | //purpose : Switches altialiasing on or off |
4754e164 | 6352 | //======================================================================= |
6353 | static Standard_Integer VPurgeDisplay (Draw_Interpretor& di, | |
6354 | Standard_Integer argc, | |
6355 | const char ** argv) | |
6356 | { | |
eb4320f2 | 6357 | if (argc > 1) |
4754e164 | 6358 | { |
eb4320f2 | 6359 | di << "Usage : " << argv[0] << "\n"; |
4754e164 | 6360 | return 1; |
6361 | } | |
4754e164 | 6362 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
6363 | if (aContext.IsNull()) | |
6364 | { | |
6365 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6366 | return 1; | |
6367 | } | |
6368 | aContext->CloseAllContexts(Standard_False); | |
eb4320f2 | 6369 | di << aContext->PurgeDisplay() << "\n"; |
4754e164 | 6370 | return 0; |
6371 | } | |
6372 | ||
6373 | //======================================================================= | |
6374 | //function : VSetViewSize | |
6375 | //purpose : | |
6376 | //======================================================================= | |
6377 | static Standard_Integer VSetViewSize (Draw_Interpretor& di, | |
6378 | Standard_Integer argc, | |
6379 | const char ** argv) | |
6380 | { | |
6381 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6382 | if(aContext.IsNull()) | |
6383 | { | |
6384 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6385 | return 1; | |
6386 | } | |
6387 | if(argc != 2) | |
6388 | { | |
6389 | di<<"Usage : " << argv[0] << " Size\n"; | |
6390 | return 1; | |
6391 | } | |
6b62b2da | 6392 | Standard_Real aSize = Draw::Atof (argv[1]); |
4754e164 | 6393 | if (aSize <= 0.) |
6394 | { | |
6395 | di<<"Bad Size value : " << aSize << "\n"; | |
6396 | return 1; | |
6397 | } | |
6398 | ||
6399 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6400 | aView->SetSize(aSize); | |
6401 | return 0; | |
6402 | } | |
6403 | ||
6404 | //======================================================================= | |
6405 | //function : VMoveView | |
6406 | //purpose : | |
6407 | //======================================================================= | |
6408 | static Standard_Integer VMoveView (Draw_Interpretor& di, | |
6409 | Standard_Integer argc, | |
6410 | const char ** argv) | |
6411 | { | |
6412 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6413 | if(aContext.IsNull()) | |
6414 | { | |
6415 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6416 | return 1; | |
6417 | } | |
6418 | if(argc < 4 || argc > 5) | |
6419 | { | |
6420 | di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n"; | |
6421 | return 1; | |
6422 | } | |
6b62b2da | 6423 | Standard_Real Dx = Draw::Atof (argv[1]); |
6424 | Standard_Real Dy = Draw::Atof (argv[2]); | |
6425 | Standard_Real Dz = Draw::Atof (argv[3]); | |
4754e164 | 6426 | Standard_Boolean aStart = Standard_True; |
6427 | if (argc == 5) | |
6428 | { | |
6b62b2da | 6429 | aStart = (Draw::Atoi (argv[4]) > 0); |
4754e164 | 6430 | } |
6431 | ||
6432 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6433 | aView->Move(Dx,Dy,Dz,aStart); | |
6434 | return 0; | |
6435 | } | |
6436 | ||
6437 | //======================================================================= | |
6438 | //function : VTranslateView | |
6439 | //purpose : | |
6440 | //======================================================================= | |
6441 | static Standard_Integer VTranslateView (Draw_Interpretor& di, | |
6442 | Standard_Integer argc, | |
6443 | const char ** argv) | |
6444 | { | |
6445 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6446 | if(aContext.IsNull()) | |
6447 | { | |
6448 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6449 | return 1; | |
6450 | } | |
6451 | if(argc < 4 || argc > 5) | |
6452 | { | |
6453 | di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n"; | |
6454 | return 1; | |
6455 | } | |
6b62b2da | 6456 | Standard_Real Dx = Draw::Atof (argv[1]); |
6457 | Standard_Real Dy = Draw::Atof (argv[2]); | |
6458 | Standard_Real Dz = Draw::Atof (argv[3]); | |
4754e164 | 6459 | Standard_Boolean aStart = Standard_True; |
dc3fe572 | 6460 | if (argc == 5) |
4754e164 | 6461 | { |
6b62b2da | 6462 | aStart = (Draw::Atoi (argv[4]) > 0); |
4754e164 | 6463 | } |
6464 | ||
6465 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6466 | aView->Translate(Dx,Dy,Dz,aStart); | |
6467 | return 0; | |
6468 | } | |
6469 | ||
6470 | //======================================================================= | |
6471 | //function : VTurnView | |
6472 | //purpose : | |
6473 | //======================================================================= | |
6474 | static Standard_Integer VTurnView (Draw_Interpretor& di, | |
6475 | Standard_Integer argc, | |
6476 | const char ** argv) | |
6477 | { | |
6478 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
6479 | if(aContext.IsNull()) { | |
6480 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
6481 | return 1; | |
6482 | } | |
6483 | if(argc < 4 || argc > 5){ | |
6484 | di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n"; | |
6485 | return 1; | |
6486 | } | |
6b62b2da | 6487 | Standard_Real Ax = Draw::Atof (argv[1]); |
6488 | Standard_Real Ay = Draw::Atof (argv[2]); | |
6489 | Standard_Real Az = Draw::Atof (argv[3]); | |
4754e164 | 6490 | Standard_Boolean aStart = Standard_True; |
dc3fe572 | 6491 | if (argc == 5) |
4754e164 | 6492 | { |
6b62b2da | 6493 | aStart = (Draw::Atoi (argv[4]) > 0); |
4754e164 | 6494 | } |
6495 | ||
6496 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6497 | aView->Turn(Ax,Ay,Az,aStart); | |
6498 | return 0; | |
6499 | } | |
6500 | ||
269294d6 | 6501 | //============================================================================== |
6502 | //function : VTextureEnv | |
6503 | //purpose : ENables or disables environment mapping | |
6504 | //============================================================================== | |
6505 | class OCC_TextureEnv : public Graphic3d_TextureEnv | |
6506 | { | |
6507 | public: | |
6508 | OCC_TextureEnv(const Standard_CString FileName); | |
6509 | OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName); | |
6510 | void SetTextureParameters(const Standard_Boolean theRepeatFlag, | |
6511 | const Standard_Boolean theModulateFlag, | |
6512 | const Graphic3d_TypeOfTextureFilter theFilter, | |
6513 | const Standard_ShortReal theXScale, | |
6514 | const Standard_ShortReal theYScale, | |
6515 | const Standard_ShortReal theXShift, | |
6516 | const Standard_ShortReal theYShift, | |
6517 | const Standard_ShortReal theAngle); | |
ec357c5c | 6518 | DEFINE_STANDARD_RTTI(OCC_TextureEnv, Graphic3d_TextureEnv); |
269294d6 | 6519 | }; |
6520 | DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv); | |
ec357c5c | 6521 | |
6522 | ||
6523 | ||
269294d6 | 6524 | |
6525 | OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName) | |
6526 | : Graphic3d_TextureEnv(theFileName) | |
6527 | { | |
6528 | } | |
6529 | ||
6530 | OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId) | |
6531 | : Graphic3d_TextureEnv(theTexId) | |
6532 | { | |
6533 | } | |
6534 | ||
6535 | void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag, | |
6536 | const Standard_Boolean theModulateFlag, | |
6537 | const Graphic3d_TypeOfTextureFilter theFilter, | |
6538 | const Standard_ShortReal theXScale, | |
6539 | const Standard_ShortReal theYScale, | |
6540 | const Standard_ShortReal theXShift, | |
6541 | const Standard_ShortReal theYShift, | |
6542 | const Standard_ShortReal theAngle) | |
6543 | { | |
6544 | myParams->SetRepeat (theRepeatFlag); | |
6545 | myParams->SetModulate (theModulateFlag); | |
6546 | myParams->SetFilter (theFilter); | |
6547 | myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale)); | |
6548 | myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift)); | |
6549 | myParams->SetRotation (theAngle); | |
6550 | } | |
6551 | ||
35e08fe8 | 6552 | static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec) |
269294d6 | 6553 | { |
6554 | // get the active view | |
6555 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6556 | if (aView.IsNull()) | |
6557 | { | |
6558 | std::cerr << "No active view. Please call vinit.\n"; | |
6559 | return 1; | |
6560 | } | |
6561 | ||
6562 | // Checking the input arguments | |
6563 | Standard_Boolean anEnableFlag = Standard_False; | |
6564 | Standard_Boolean isOk = theArgNb >= 2; | |
6565 | if (isOk) | |
6566 | { | |
6567 | TCollection_AsciiString anEnableOpt(theArgVec[1]); | |
6568 | anEnableFlag = anEnableOpt.IsEqual("on"); | |
6569 | isOk = anEnableFlag || anEnableOpt.IsEqual("off"); | |
6570 | } | |
6571 | if (anEnableFlag) | |
6572 | { | |
6573 | isOk = (theArgNb == 3 || theArgNb == 11); | |
6574 | if (isOk) | |
6575 | { | |
6576 | TCollection_AsciiString aTextureOpt(theArgVec[2]); | |
6577 | isOk = (!aTextureOpt.IsIntegerValue() || | |
6578 | (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN)); | |
6579 | ||
6580 | if (isOk && theArgNb == 11) | |
6581 | { | |
6582 | TCollection_AsciiString aRepeatOpt (theArgVec[3]), | |
6583 | aModulateOpt(theArgVec[4]), | |
6584 | aFilterOpt (theArgVec[5]), | |
6585 | aSScaleOpt (theArgVec[6]), | |
6586 | aTScaleOpt (theArgVec[7]), | |
6587 | aSTransOpt (theArgVec[8]), | |
6588 | aTTransOpt (theArgVec[9]), | |
6589 | anAngleOpt (theArgVec[10]); | |
6590 | isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) && | |
6591 | (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) && | |
6592 | (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) && | |
6593 | aSScaleOpt.IsRealValue() && aTScaleOpt.IsRealValue() && | |
6594 | aSTransOpt.IsRealValue() && aTTransOpt.IsRealValue() && | |
6595 | anAngleOpt.IsRealValue()); | |
6596 | } | |
6597 | } | |
6598 | } | |
6599 | ||
6600 | if (!isOk) | |
6601 | { | |
6602 | std::cerr << "Usage :" << std::endl; | |
6603 | std::cerr << theArgVec[0] << " off" << std::endl; | |
6604 | std::cerr << theArgVec[0] << " on {index_of_std_texture(0..7)|texture_file_name} [{clamp|repeat} {decal|modulate} {nearest|bilinear|trilinear} scale_s scale_t translation_s translation_t rotation_degrees]" << std::endl; | |
6605 | return 1; | |
6606 | } | |
6607 | ||
6608 | if (anEnableFlag) | |
6609 | { | |
6610 | TCollection_AsciiString aTextureOpt(theArgVec[2]); | |
6611 | Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ? | |
6612 | new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) : | |
6613 | new OCC_TextureEnv(theArgVec[2]); | |
6614 | ||
6615 | if (theArgNb == 11) | |
6616 | { | |
6617 | TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]); | |
6618 | aTexEnv->SetTextureParameters( | |
6619 | aRepeatOpt. IsEqual("repeat"), | |
6620 | aModulateOpt.IsEqual("modulate"), | |
6621 | aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST : | |
6622 | aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR : | |
6623 | Graphic3d_TOTF_TRILINEAR, | |
6624 | (Standard_ShortReal)Draw::Atof(theArgVec[6]), | |
6625 | (Standard_ShortReal)Draw::Atof(theArgVec[7]), | |
6626 | (Standard_ShortReal)Draw::Atof(theArgVec[8]), | |
6627 | (Standard_ShortReal)Draw::Atof(theArgVec[9]), | |
6628 | (Standard_ShortReal)Draw::Atof(theArgVec[10]) | |
6629 | ); | |
6630 | } | |
6631 | aView->SetTextureEnv(aTexEnv); | |
6632 | aView->SetSurfaceDetail(V3d_TEX_ENVIRONMENT); | |
6633 | } | |
6634 | else // Disabling environment mapping | |
6635 | { | |
6636 | aView->SetSurfaceDetail(V3d_TEX_NONE); | |
6637 | Handle(Graphic3d_TextureEnv) aTexture; | |
6638 | aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data | |
6639 | } | |
6640 | ||
6641 | aView->Redraw(); | |
6642 | return 0; | |
6643 | } | |
6644 | ||
4269bd1b | 6645 | //=============================================================================================== |
6646 | //function : VClipPlane | |
6647 | //purpose : | |
6648 | //=============================================================================================== | |
6649 | static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
6650 | { | |
6651 | // use short-cut for created clip planes map of created (or "registered by name") clip planes | |
6652 | typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes; | |
6653 | static MapOfPlanes aRegPlanes; | |
6654 | ||
6655 | if (theArgsNb < 2) | |
6656 | { | |
6657 | theDi << theArgVec[0] << ": command argument is required. Type help for more information.\n"; | |
6658 | return 1; | |
6659 | } | |
6660 | ||
6661 | TCollection_AsciiString aCommand (theArgVec[1]); | |
6662 | ||
6663 | // print maximum number of planes for current viewer | |
6664 | if (aCommand == "maxplanes") | |
6665 | { | |
6666 | if (theArgsNb < 3) | |
6667 | { | |
6668 | theDi << theArgVec[0] << ": view name is required. Type help for more information.\n"; | |
6669 | return 1; | |
6670 | } | |
6671 | ||
6672 | TCollection_AsciiString aViewName (theArgVec[2]); | |
6673 | ||
6674 | if (!ViewerTest_myViews.IsBound1 (aViewName)) | |
6675 | { | |
6676 | theDi << theArgVec[0] << ": view is not found.\n"; | |
6677 | return 1; | |
6678 | } | |
6679 | ||
6680 | const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName); | |
6681 | ||
6682 | theDi << theArgVec[0] << ": " | |
6683 | << aView->Viewer()->Driver()->InquirePlaneLimit() | |
6684 | << " plane slots provided by driver." | |
6685 | << " Note that 2 more planes might be used (reserved for z-clipping).\n"; | |
6686 | ||
6687 | return 0; | |
6688 | } | |
6689 | ||
6690 | // create / delete plane instance | |
6691 | if (aCommand == "create" || aCommand == "delete" || aCommand == "clone") | |
6692 | { | |
6693 | if (theArgsNb < 3) | |
6694 | { | |
6695 | theDi << theArgVec[0] << ": plane name is required. Type help for more information.\n"; | |
6696 | return 1; | |
6697 | } | |
6698 | ||
6699 | Standard_Boolean toCreate = (aCommand == "create"); | |
6700 | Standard_Boolean toClone = (aCommand == "clone"); | |
6701 | TCollection_AsciiString aPlane (theArgVec[2]); | |
6702 | ||
6703 | if (toCreate) | |
6704 | { | |
6705 | if (aRegPlanes.IsBound (aPlane)) | |
6706 | { | |
6707 | theDi << theArgVec[0] << ": plane name is in use.\n"; | |
6708 | return 1; | |
6709 | } | |
6710 | ||
6711 | aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane()); | |
6712 | } | |
6713 | else if (toClone) // toClone | |
6714 | { | |
6715 | if (!aRegPlanes.IsBound (aPlane)) | |
6716 | { | |
6717 | theDi << theArgVec[0] << ": no such plane.\n"; | |
6718 | return 1; | |
6719 | } | |
6720 | ||
6721 | if (theArgsNb < 4) | |
6722 | { | |
6723 | theDi << theArgVec[0] << ": enter name for new plane. Type help for more information.\n"; | |
6724 | return 1; | |
6725 | } | |
6726 | ||
6727 | TCollection_AsciiString aClone (theArgVec[3]); | |
6728 | if (aRegPlanes.IsBound (aClone)) | |
6729 | { | |
6730 | theDi << theArgVec[0] << ": plane name is in use.\n"; | |
6731 | return 1; | |
6732 | } | |
6733 | ||
6734 | const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane); | |
6735 | ||
6736 | aRegPlanes.Bind (aClone, aClipPlane->Clone()); | |
6737 | } | |
6738 | else// toDelete | |
6739 | { | |
6740 | if (!aRegPlanes.IsBound (aPlane)) | |
6741 | { | |
6742 | theDi << theArgVec[0] << ": no such plane.\n"; | |
6743 | return 1; | |
6744 | } | |
6745 | ||
6746 | Handle(Graphic3d_ClipPlane) aClipPlane = aRegPlanes.Find (aPlane); | |
6747 | aRegPlanes.UnBind (aPlane); | |
6748 | ||
6749 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS()); | |
6750 | for (; anIObjIt.More(); anIObjIt.Next()) | |
6751 | { | |
6752 | Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anIObjIt.Key1()); | |
6753 | aPrs->RemoveClipPlane(aClipPlane); | |
6754 | } | |
6755 | ||
6756 | NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews); | |
6757 | for (; aViewIt.More(); aViewIt.Next()) | |
6758 | { | |
6759 | const Handle(V3d_View)& aView = aViewIt.Key2(); | |
6760 | aView->RemoveClipPlane(aClipPlane); | |
6761 | } | |
6762 | ||
6763 | ViewerTest::RedrawAllViews(); | |
6764 | } | |
6765 | ||
6766 | return 0; | |
6767 | } | |
6768 | ||
6769 | // set / unset plane command | |
6770 | if (aCommand == "set" || aCommand == "unset") | |
6771 | { | |
6772 | if (theArgsNb < 4) | |
6773 | { | |
6774 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6775 | return 1; | |
6776 | } | |
6777 | ||
6778 | Standard_Boolean toSet = (aCommand == "set"); | |
6779 | TCollection_AsciiString aPlane (theArgVec [2]); | |
6780 | if (!aRegPlanes.IsBound (aPlane)) | |
6781 | { | |
6782 | theDi << theArgVec[0] << ": no such plane.\n"; | |
6783 | return 1; | |
6784 | } | |
6785 | ||
6786 | const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane); | |
6787 | ||
6788 | TCollection_AsciiString aTarget (theArgVec [3]); | |
6789 | if (aTarget != "object" && aTarget != "view") | |
6790 | { | |
6791 | theDi << theArgVec[0] << ": invalid target.\n"; | |
6792 | return 1; | |
6793 | } | |
6794 | ||
6795 | if (aTarget == "object" || aTarget == "view") | |
6796 | { | |
6797 | if (theArgsNb < 5) | |
6798 | { | |
6799 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6800 | return 1; | |
6801 | } | |
6802 | ||
6803 | Standard_Boolean isObject = (aTarget == "object"); | |
6804 | ||
6805 | for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt) | |
6806 | { | |
6807 | TCollection_AsciiString anEntityName (theArgVec[anIt]); | |
6808 | if (isObject) // to object | |
6809 | { | |
6810 | if (!GetMapOfAIS().IsBound2 (anEntityName)) | |
6811 | { | |
6812 | theDi << theArgVec[0] << ": can not find IO with name " << anEntityName << ".\n"; | |
6813 | continue; | |
6814 | } | |
6815 | ||
6816 | Handle(AIS_InteractiveObject) aIObj = | |
6817 | Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anEntityName)); | |
6818 | ||
6819 | if (toSet) | |
6820 | aIObj->AddClipPlane (aClipPlane); | |
6821 | else | |
6822 | aIObj->RemoveClipPlane (aClipPlane); | |
6823 | } | |
6824 | else // to view | |
6825 | { | |
6826 | if (!ViewerTest_myViews.IsBound1 (anEntityName)) | |
6827 | { | |
6828 | theDi << theArgVec[0] << ": can not find View with name " << anEntityName << ".\n"; | |
6829 | continue; | |
6830 | } | |
6831 | ||
6832 | Handle(V3d_View) aView = ViewerTest_myViews.Find1(anEntityName); | |
6833 | if (toSet) | |
6834 | aView->AddClipPlane (aClipPlane); | |
6835 | else | |
6836 | aView->RemoveClipPlane (aClipPlane); | |
6837 | } | |
6838 | } | |
6839 | ||
6840 | ViewerTest::RedrawAllViews(); | |
6841 | } | |
6842 | ||
6843 | return 0; | |
6844 | } | |
6845 | ||
6846 | // change plane command | |
6847 | if (aCommand == "change") | |
6848 | { | |
6849 | if (theArgsNb < 4) | |
6850 | { | |
6851 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6852 | return 1; | |
6853 | } | |
6854 | ||
6855 | TCollection_AsciiString aPlane (theArgVec [2]); | |
6856 | if (!aRegPlanes.IsBound (aPlane)) | |
6857 | { | |
6858 | theDi << theArgVec[0] << ": no such plane.\n"; | |
6859 | return 1; | |
6860 | } | |
6861 | ||
6862 | const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane); | |
6863 | ||
6864 | TCollection_AsciiString aChangeArg (theArgVec [3]); | |
6865 | if (aChangeArg != "on" && aChangeArg != "off" && aChangeArg != "capping" && aChangeArg != "equation") | |
6866 | { | |
6867 | theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n"; | |
6868 | return 1; | |
6869 | } | |
6870 | ||
6871 | if (aChangeArg == "on" || aChangeArg == "off") // on / off | |
6872 | { | |
6873 | aClipPlane->SetOn (aChangeArg == "on"); | |
6874 | } | |
6875 | else if (aChangeArg == "equation") // change equation | |
6876 | { | |
6877 | if (theArgsNb < 8) | |
6878 | { | |
6879 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6880 | return 1; | |
6881 | } | |
6882 | ||
6b62b2da | 6883 | Standard_Real aCoeffA = Draw::Atof (theArgVec [4]); |
6884 | Standard_Real aCoeffB = Draw::Atof (theArgVec [5]); | |
6885 | Standard_Real aCoeffC = Draw::Atof (theArgVec [6]); | |
6886 | Standard_Real aCoeffD = Draw::Atof (theArgVec [7]); | |
4269bd1b | 6887 | aClipPlane->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD)); |
6888 | } | |
6889 | else if (aChangeArg == "capping") // change capping aspects | |
6890 | { | |
6891 | if (theArgsNb < 5) | |
6892 | { | |
6893 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6894 | return 1; | |
6895 | } | |
6896 | ||
6897 | TCollection_AsciiString aCappingArg (theArgVec [4]); | |
6898 | if (aCappingArg != "on" && aCappingArg != "off" && | |
6899 | aCappingArg != "color" && aCappingArg != "texname" && | |
6900 | aCappingArg != "texscale" && aCappingArg != "texorigin" && | |
6901 | aCappingArg != "texrotate" && aCappingArg != "hatch") | |
6902 | { | |
6903 | theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n"; | |
6904 | return 1; | |
6905 | } | |
6906 | ||
6907 | if (aCappingArg == "on" || aCappingArg == "off") // on / off capping | |
6908 | { | |
6909 | aClipPlane->SetCapping (aCappingArg == "on"); | |
6910 | } | |
6911 | else if (aCappingArg == "color") // color aspect for capping | |
6912 | { | |
6913 | if (theArgsNb < 8) | |
6914 | { | |
6915 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6916 | return 1; | |
6917 | } | |
6918 | ||
6b62b2da | 6919 | Standard_Real aRed = Draw::Atof (theArgVec [5]); |
6920 | Standard_Real aGrn = Draw::Atof (theArgVec [6]); | |
6921 | Standard_Real aBlu = Draw::Atof (theArgVec [7]); | |
4269bd1b | 6922 | |
6923 | Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial(); | |
8aeeca44 | 6924 | Quantity_Color aColor (aRed, aGrn, aBlu, Quantity_TOC_RGB); |
6925 | aMat.SetAmbientColor (aColor); | |
6926 | aMat.SetDiffuseColor (aColor); | |
4269bd1b | 6927 | aClipPlane->SetCappingMaterial (aMat); |
6928 | } | |
6929 | else if (aCappingArg == "texname") // texture name | |
6930 | { | |
6931 | if (theArgsNb < 6) | |
6932 | { | |
6933 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6934 | return 1; | |
6935 | } | |
6936 | ||
6937 | TCollection_AsciiString aTextureName (theArgVec [5]); | |
6938 | ||
6939 | Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); | |
6940 | if (!aTexture->IsDone ()) | |
6941 | { | |
6942 | aClipPlane->SetCappingTexture (NULL); | |
6943 | } | |
6944 | else | |
6945 | { | |
6946 | aTexture->EnableModulate(); | |
6947 | aTexture->EnableRepeat(); | |
6948 | aClipPlane->SetCappingTexture (aTexture); | |
6949 | } | |
6950 | } | |
6951 | else if (aCappingArg == "texscale") // texture scale | |
6952 | { | |
6953 | if (aClipPlane->CappingTexture().IsNull()) | |
6954 | { | |
6955 | theDi << theArgVec[0] << ": no texture is set.\n"; | |
6956 | return 1; | |
6957 | } | |
6958 | ||
6959 | if (theArgsNb < 7) | |
6960 | { | |
6961 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6962 | return 1; | |
6963 | } | |
6964 | ||
6965 | Standard_ShortReal aSx = (Standard_ShortReal)atof (theArgVec [5]); | |
6966 | Standard_ShortReal aSy = (Standard_ShortReal)atof (theArgVec [6]); | |
6967 | ||
6968 | aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); | |
6969 | } | |
6970 | else if (aCappingArg == "texorigin") // texture origin | |
6971 | { | |
6972 | if (aClipPlane->CappingTexture().IsNull()) | |
6973 | { | |
6974 | theDi << theArgVec[0] << ": no texture is set.\n"; | |
6975 | return 1; | |
6976 | } | |
6977 | ||
6978 | if (theArgsNb < 7) | |
6979 | { | |
6980 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
6981 | return 1; | |
6982 | } | |
6983 | ||
6984 | Standard_ShortReal aTx = (Standard_ShortReal)atof (theArgVec [5]); | |
6985 | Standard_ShortReal aTy = (Standard_ShortReal)atof (theArgVec [6]); | |
6986 | ||
6987 | aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); | |
6988 | } | |
6989 | else if (aCappingArg == "texrotate") // texture rotation | |
6990 | { | |
6991 | if (aClipPlane->CappingTexture().IsNull()) | |
6992 | { | |
6993 | theDi << theArgVec[0] << ": no texture is set.\n"; | |
6994 | return 1; | |
6995 | } | |
6996 | ||
6997 | if (theArgsNb < 6) | |
6998 | { | |
6999 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
7000 | return 1; | |
7001 | } | |
7002 | ||
7003 | Standard_ShortReal aRot = (Standard_ShortReal)atof (theArgVec[5]); | |
7004 | ||
7005 | aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot); | |
7006 | } | |
7007 | else if (aCappingArg == "hatch") // hatch style | |
7008 | { | |
7009 | if (theArgsNb < 6) | |
7010 | { | |
7011 | theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n"; | |
7012 | return 1; | |
7013 | } | |
7014 | ||
7015 | TCollection_AsciiString aHatchStr (theArgVec [5]); | |
7016 | if (aHatchStr == "on") | |
7017 | { | |
7018 | aClipPlane->SetCappingHatchOn(); | |
7019 | } | |
7020 | else if (aHatchStr == "off") | |
7021 | { | |
7022 | aClipPlane->SetCappingHatchOff(); | |
7023 | } | |
7024 | else | |
7025 | { | |
7026 | aClipPlane->SetCappingHatch ((Aspect_HatchStyle)atoi (theArgVec[5])); | |
7027 | } | |
7028 | } | |
7029 | } | |
7030 | ||
7031 | ViewerTest::RedrawAllViews(); | |
7032 | ||
7033 | return 0; | |
7034 | } | |
7035 | ||
7036 | theDi << theArgVec[0] << ": invalid command. Type help for more information.\n"; | |
7037 | return 1; | |
7038 | } | |
7039 | ||
7040 | //=============================================================================================== | |
7041 | //function : VSetTextureMode | |
7042 | //purpose : | |
7043 | //=============================================================================================== | |
7044 | static int VSetTextureMode (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
7045 | { | |
7046 | if (theArgsNb < 3) | |
7047 | { | |
7048 | theDi << theArgVec[0] << ": insufficient command arguments. Type help for more information.\n"; | |
7049 | return 1; | |
7050 | } | |
7051 | ||
7052 | TCollection_AsciiString aViewName (theArgVec[1]); | |
7053 | if (!ViewerTest_myViews.IsBound1 (aViewName)) | |
7054 | { | |
7055 | theDi << theArgVec[0] << ": view is not found.\n"; | |
7056 | return 1; | |
7057 | } | |
7058 | ||
7059 | const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName); | |
7060 | switch (atoi (theArgVec[2])) | |
7061 | { | |
7062 | case 0: aView->SetSurfaceDetail (V3d_TEX_NONE); break; | |
7063 | case 1: aView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT); break; | |
7064 | case 2: aView->SetSurfaceDetail (V3d_TEX_ALL); break; | |
7065 | default: | |
7066 | theDi << theArgVec[0] << ": invalid mode.\n"; | |
7067 | return 1; | |
7068 | } | |
7069 | ||
7070 | aView->Redraw(); | |
7071 | return 0; | |
7072 | } | |
7073 | ||
b5ac8292 | 7074 | //=============================================================================================== |
7075 | //function : VZRange | |
7076 | //purpose : | |
7077 | //=============================================================================================== | |
7078 | static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
7079 | { | |
197ac94e | 7080 | const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView(); |
7081 | ||
7082 | if (aCurrentView.IsNull()) | |
b5ac8292 | 7083 | { |
197ac94e | 7084 | std::cout << theArgVec[0] << ": Call vinit before this command, please.\n"; |
b5ac8292 | 7085 | return 1; |
7086 | } | |
7087 | ||
197ac94e | 7088 | Handle(Graphic3d_Camera) aCamera = aCurrentView->Camera(); |
b5ac8292 | 7089 | |
7090 | if (theArgsNb < 2) | |
7091 | { | |
7092 | theDi << "ZNear: " << aCamera->ZNear() << "\n"; | |
7093 | theDi << "ZFar: " << aCamera->ZFar() << "\n"; | |
7094 | return 0; | |
7095 | } | |
7096 | ||
7097 | if (theArgsNb == 3) | |
7098 | { | |
6b62b2da | 7099 | Standard_Real aNewZNear = Draw::Atof (theArgVec[1]); |
7100 | Standard_Real aNewZFar = Draw::Atof (theArgVec[2]); | |
197ac94e | 7101 | |
7102 | if (aNewZNear >= aNewZFar) | |
7103 | { | |
7104 | std::cout << theArgVec[0] << ": invalid arguments: znear should be less than zfar.\n"; | |
7105 | return 1; | |
7106 | } | |
7107 | ||
7108 | if (!aCamera->IsOrthographic() && (aNewZNear <= 0.0 || aNewZFar <= 0.0)) | |
7109 | { | |
7110 | std::cout << theArgVec[0] << ": invalid arguments: "; | |
7111 | std::cout << "znear, zfar should be positive for perspective camera.\n"; | |
7112 | return 1; | |
7113 | } | |
7114 | ||
7115 | aCamera->SetZRange (aNewZNear, aNewZFar); | |
b5ac8292 | 7116 | } |
7117 | else | |
7118 | { | |
197ac94e | 7119 | std::cout << theArgVec[0] << ": wrong command arguments. Type help for more information.\n"; |
b5ac8292 | 7120 | return 1; |
7121 | } | |
7122 | ||
197ac94e | 7123 | aCurrentView->Redraw(); |
7124 | ||
b5ac8292 | 7125 | return 0; |
7126 | } | |
7127 | ||
7128 | //=============================================================================================== | |
7129 | //function : VAutoZFit | |
7130 | //purpose : | |
7131 | //=============================================================================================== | |
7132 | static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
7133 | { | |
197ac94e | 7134 | const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView(); |
7135 | ||
7136 | if (aCurrentView.IsNull()) | |
b5ac8292 | 7137 | { |
197ac94e | 7138 | std::cout << theArgVec[0] << ": Call vinit before this command, please.\n"; |
b5ac8292 | 7139 | return 1; |
7140 | } | |
7141 | ||
6bc6a6fc | 7142 | Standard_Real aScale = aCurrentView->View()->AutoZFitScaleFactor(); |
197ac94e | 7143 | |
7144 | if (theArgsNb > 3) | |
b5ac8292 | 7145 | { |
197ac94e | 7146 | std::cout << theArgVec[0] << ": wrong command arguments. Type help for more information.\n"; |
7147 | return 1; | |
b5ac8292 | 7148 | } |
7149 | ||
197ac94e | 7150 | if (theArgsNb < 2) |
b5ac8292 | 7151 | { |
197ac94e | 7152 | theDi << "Auto z-fit mode: " << "\n" |
6bc6a6fc | 7153 | << "On: " << (aCurrentView->View()->AutoZFitMode() ? "enabled" : "disabled") << "\n" |
197ac94e | 7154 | << "Scale: " << aScale << "\n"; |
7155 | return 0; | |
b5ac8292 | 7156 | } |
197ac94e | 7157 | |
7158 | Standard_Boolean isOn = Draw::Atoi (theArgVec[1]) == 1; | |
7159 | ||
7160 | if (theArgsNb >= 3) | |
b5ac8292 | 7161 | { |
197ac94e | 7162 | aScale = Draw::Atoi (theArgVec[2]); |
b5ac8292 | 7163 | } |
7164 | ||
6bc6a6fc | 7165 | aCurrentView->View()->SetAutoZFitMode (isOn, aScale); |
7166 | aCurrentView->View()->AutoZFit(); | |
197ac94e | 7167 | aCurrentView->Redraw(); |
7168 | ||
b5ac8292 | 7169 | return 0; |
7170 | } | |
7171 | ||
6b62b2da | 7172 | //! Auxiliary function to print projection type |
7173 | inline const char* projTypeName (Graphic3d_Camera::Projection theProjType) | |
7174 | { | |
7175 | switch (theProjType) | |
7176 | { | |
7177 | case Graphic3d_Camera::Projection_Orthographic: return "orthographic"; | |
7178 | case Graphic3d_Camera::Projection_Perspective: return "perspective"; | |
7179 | case Graphic3d_Camera::Projection_Stereo: return "stereoscopic"; | |
7180 | case Graphic3d_Camera::Projection_MonoLeftEye: return "monoLeftEye"; | |
7181 | case Graphic3d_Camera::Projection_MonoRightEye: return "monoRightEye"; | |
7182 | } | |
7183 | return "UNKNOWN"; | |
7184 | } | |
7185 | ||
b5ac8292 | 7186 | //=============================================================================================== |
6b62b2da | 7187 | //function : VCamera |
b5ac8292 | 7188 | //purpose : |
7189 | //=============================================================================================== | |
6b62b2da | 7190 | static int VCamera (Draw_Interpretor& theDI, |
7191 | Standard_Integer theArgsNb, | |
7192 | const char** theArgVec) | |
b5ac8292 | 7193 | { |
6b62b2da | 7194 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
7195 | if (aView.IsNull()) | |
b5ac8292 | 7196 | { |
6b62b2da | 7197 | std::cout << "Error: no active view.\n"; |
b5ac8292 | 7198 | return 1; |
7199 | } | |
7200 | ||
6b62b2da | 7201 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); |
7202 | if (theArgsNb < 2) | |
b5ac8292 | 7203 | { |
6b62b2da | 7204 | theDI << "ProjType: " << projTypeName (aCamera->ProjectionType()) << "\n"; |
7205 | theDI << "FOVy: " << aCamera->FOVy() << "\n"; | |
7206 | theDI << "Distance: " << aCamera->Distance() << "\n"; | |
7207 | theDI << "IOD: " << aCamera->IOD() << "\n"; | |
7208 | theDI << "IODType: " << (aCamera->GetIODType() == Graphic3d_Camera::IODType_Absolute ? "absolute" : "relative") << "\n"; | |
7209 | theDI << "ZFocus: " << aCamera->ZFocus() << "\n"; | |
7210 | theDI << "ZFocusType: " << (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Absolute ? "absolute" : "relative") << "\n"; | |
7211 | return 0; | |
b5ac8292 | 7212 | } |
7213 | ||
6b62b2da | 7214 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) |
b5ac8292 | 7215 | { |
6b62b2da | 7216 | Standard_CString anArg = theArgVec[anArgIter]; |
7217 | TCollection_AsciiString anArgCase (anArg); | |
7218 | anArgCase.LowerCase(); | |
7219 | if (anArgCase == "-proj" | |
7220 | || anArgCase == "-projection" | |
7221 | || anArgCase == "-projtype" | |
7222 | || anArgCase == "-projectiontype") | |
7223 | { | |
7224 | theDI << projTypeName (aCamera->ProjectionType()) << " "; | |
7225 | } | |
7226 | else if (anArgCase == "-ortho" | |
7227 | || anArgCase == "-orthographic") | |
b5ac8292 | 7228 | { |
7229 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic); | |
6b62b2da | 7230 | } |
7231 | else if (anArgCase == "-persp" | |
7232 | || anArgCase == "-perspective" | |
7233 | || anArgCase == "-perspmono" | |
7234 | || anArgCase == "-perspectivemono" | |
7235 | || anArgCase == "-mono") | |
b5ac8292 | 7236 | { |
7237 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective); | |
7238 | } | |
6b62b2da | 7239 | else if (anArgCase == "-stereo" |
7240 | || anArgCase == "-stereoscopic" | |
7241 | || anArgCase == "-perspstereo" | |
7242 | || anArgCase == "-perspectivestereo") | |
7243 | { | |
7244 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo); | |
7245 | } | |
7246 | else if (anArgCase == "-left" | |
7247 | || anArgCase == "-lefteye" | |
7248 | || anArgCase == "-monoleft" | |
7249 | || anArgCase == "-monolefteye" | |
7250 | || anArgCase == "-perpsleft" | |
7251 | || anArgCase == "-perpslefteye") | |
b5ac8292 | 7252 | { |
7253 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye); | |
7254 | } | |
6b62b2da | 7255 | else if (anArgCase == "-right" |
7256 | || anArgCase == "-righteye" | |
7257 | || anArgCase == "-monoright" | |
7258 | || anArgCase == "-monorighteye" | |
7259 | || anArgCase == "-perpsright") | |
b5ac8292 | 7260 | { |
7261 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye); | |
7262 | } | |
6b62b2da | 7263 | else if (anArgCase == "-dist" |
7264 | || anArgCase == "-distance") | |
b5ac8292 | 7265 | { |
6b62b2da | 7266 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
7267 | if (anArgValue != NULL | |
7268 | && *anArgValue != '-') | |
7269 | { | |
7270 | ++anArgIter; | |
7271 | aCamera->SetDistance (Draw::Atof (anArgValue)); | |
7272 | continue; | |
7273 | } | |
7274 | theDI << aCamera->Distance() << " "; | |
b5ac8292 | 7275 | } |
6b62b2da | 7276 | else if (anArgCase == "-iod") |
b5ac8292 | 7277 | { |
6b62b2da | 7278 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
7279 | if (anArgValue != NULL | |
7280 | && *anArgValue != '-') | |
7281 | { | |
7282 | ++anArgIter; | |
7283 | aCamera->SetIOD (aCamera->GetIODType(), Draw::Atof (anArgValue)); | |
7284 | continue; | |
7285 | } | |
7286 | theDI << aCamera->IOD() << " "; | |
b5ac8292 | 7287 | } |
6b62b2da | 7288 | else if (anArgCase == "-iodtype") |
b5ac8292 | 7289 | { |
6b62b2da | 7290 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : ""; |
7291 | TCollection_AsciiString anValueCase (anArgValue); | |
7292 | anValueCase.LowerCase(); | |
7293 | if (anValueCase == "abs" | |
7294 | || anValueCase == "absolute") | |
7295 | { | |
7296 | ++anArgIter; | |
7297 | aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD()); | |
7298 | continue; | |
7299 | } | |
7300 | else if (anValueCase == "rel" | |
7301 | || anValueCase == "relative") | |
7302 | { | |
7303 | ++anArgIter; | |
7304 | aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD()); | |
7305 | continue; | |
7306 | } | |
7307 | else if (*anArgValue != '-') | |
7308 | { | |
7309 | std::cout << "Error: unknown IOD type '" << anArgValue << "'\n"; | |
7310 | return 1; | |
7311 | } | |
7312 | switch (aCamera->GetIODType()) | |
7313 | { | |
7314 | case Graphic3d_Camera::IODType_Absolute: theDI << "absolute "; break; | |
7315 | case Graphic3d_Camera::IODType_Relative: theDI << "relative "; break; | |
7316 | } | |
b5ac8292 | 7317 | } |
6b62b2da | 7318 | else if (anArgCase == "-zfocus") |
b5ac8292 | 7319 | { |
6b62b2da | 7320 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
7321 | if (anArgValue != NULL | |
7322 | && *anArgValue != '-') | |
7323 | { | |
7324 | ++anArgIter; | |
7325 | aCamera->SetZFocus (aCamera->ZFocusType(), Draw::Atof (anArgValue)); | |
7326 | continue; | |
7327 | } | |
7328 | theDI << aCamera->ZFocus() << " "; | |
b5ac8292 | 7329 | } |
6b62b2da | 7330 | else if (anArgCase == "-zfocustype") |
b5ac8292 | 7331 | { |
6b62b2da | 7332 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : ""; |
7333 | TCollection_AsciiString anValueCase (anArgValue); | |
7334 | anValueCase.LowerCase(); | |
7335 | if (anValueCase == "abs" | |
7336 | || anValueCase == "absolute") | |
7337 | { | |
7338 | ++anArgIter; | |
7339 | aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus()); | |
7340 | continue; | |
7341 | } | |
7342 | else if (anValueCase == "rel" | |
7343 | || anValueCase == "relative") | |
7344 | { | |
7345 | ++anArgIter; | |
7346 | aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus()); | |
7347 | continue; | |
7348 | } | |
7349 | else if (*anArgValue != '-') | |
7350 | { | |
7351 | std::cout << "Error: unknown ZFocus type '" << anArgValue << "'\n"; | |
7352 | return 1; | |
7353 | } | |
7354 | switch (aCamera->ZFocusType()) | |
7355 | { | |
7356 | case Graphic3d_Camera::FocusType_Absolute: theDI << "absolute "; break; | |
7357 | case Graphic3d_Camera::FocusType_Relative: theDI << "relative "; break; | |
7358 | } | |
7359 | } | |
7360 | else if (anArgCase == "-fov" | |
7361 | || anArgCase == "-fovy") | |
b5ac8292 | 7362 | { |
6b62b2da | 7363 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
7364 | if (anArgValue != NULL | |
7365 | && *anArgValue != '-') | |
7366 | { | |
7367 | ++anArgIter; | |
7368 | aCamera->SetFOVy (Draw::Atof (anArgValue)); | |
7369 | continue; | |
7370 | } | |
7371 | theDI << aCamera->FOVy() << " "; | |
b5ac8292 | 7372 | } |
7373 | else | |
7374 | { | |
6b62b2da | 7375 | std::cout << "Error: unknown argument '" << anArg << "'\n"; |
b5ac8292 | 7376 | return 1; |
7377 | } | |
7378 | } | |
b5ac8292 | 7379 | |
6b62b2da | 7380 | aView->View()->AutoZFit(); |
7381 | aView->Redraw(); | |
b5ac8292 | 7382 | |
7383 | return 0; | |
7384 | } | |
7385 | ||
f978241f | 7386 | //! Parse stereo output mode |
7387 | inline Standard_Boolean parseStereoMode (Standard_CString theArg, | |
7388 | Graphic3d_StereoMode& theMode) | |
7389 | { | |
7390 | TCollection_AsciiString aFlag (theArg); | |
7391 | aFlag.LowerCase(); | |
7392 | if (aFlag == "quadbuffer") | |
7393 | { | |
7394 | theMode = Graphic3d_StereoMode_QuadBuffer; | |
7395 | } | |
7396 | else if (aFlag == "anaglyph") | |
7397 | { | |
7398 | theMode = Graphic3d_StereoMode_Anaglyph; | |
7399 | } | |
7400 | else if (aFlag == "row" | |
7401 | || aFlag == "rowinterlaced") | |
7402 | { | |
7403 | theMode = Graphic3d_StereoMode_RowInterlaced; | |
7404 | } | |
7405 | else if (aFlag == "col" | |
7406 | || aFlag == "colinterlaced" | |
7407 | || aFlag == "columninterlaced") | |
7408 | { | |
7409 | theMode = Graphic3d_StereoMode_ColumnInterlaced; | |
7410 | } | |
7411 | else if (aFlag == "chess" | |
7412 | || aFlag == "chessboard") | |
7413 | { | |
7414 | theMode = Graphic3d_StereoMode_ChessBoard; | |
7415 | } | |
7416 | else if (aFlag == "sbs" | |
7417 | || aFlag == "sidebyside") | |
7418 | { | |
7419 | theMode = Graphic3d_StereoMode_SideBySide; | |
7420 | } | |
7421 | else if (aFlag == "ou" | |
7422 | || aFlag == "overunder") | |
7423 | { | |
7424 | theMode = Graphic3d_StereoMode_OverUnder; | |
7425 | } | |
7426 | else if (aFlag == "pageflip" | |
7427 | || aFlag == "softpageflip") | |
7428 | { | |
7429 | theMode = Graphic3d_StereoMode_SoftPageFlip; | |
7430 | } | |
7431 | else | |
7432 | { | |
7433 | return Standard_False; | |
7434 | } | |
7435 | return Standard_True; | |
7436 | } | |
7437 | ||
7438 | //! Parse anaglyph filter | |
7439 | inline Standard_Boolean parseAnaglyphFilter (Standard_CString theArg, | |
7440 | Graphic3d_RenderingParams::Anaglyph& theFilter) | |
7441 | { | |
7442 | TCollection_AsciiString aFlag (theArg); | |
7443 | aFlag.LowerCase(); | |
7444 | if (aFlag == "redcyansimple") | |
7445 | { | |
7446 | theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple; | |
7447 | } | |
7448 | else if (aFlag == "redcyan" | |
7449 | || aFlag == "redcyanoptimized") | |
7450 | { | |
7451 | theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized; | |
7452 | } | |
7453 | else if (aFlag == "yellowbluesimple") | |
7454 | { | |
7455 | theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple; | |
7456 | } | |
7457 | else if (aFlag == "yellowblue" | |
7458 | || aFlag == "yellowblueoptimized") | |
7459 | { | |
7460 | theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized; | |
7461 | } | |
7462 | else if (aFlag == "greenmagenta" | |
7463 | || aFlag == "greenmagentasimple") | |
7464 | { | |
7465 | theFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple; | |
7466 | } | |
7467 | else | |
7468 | { | |
7469 | return Standard_False; | |
7470 | } | |
7471 | return Standard_True; | |
7472 | } | |
7473 | ||
b5ac8292 | 7474 | //============================================================================== |
7475 | //function : VStereo | |
7476 | //purpose : | |
7477 | //============================================================================== | |
7478 | ||
7479 | static int VStereo (Draw_Interpretor& theDI, | |
7480 | Standard_Integer theArgNb, | |
7481 | const char** theArgVec) | |
7482 | { | |
f978241f | 7483 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
b5ac8292 | 7484 | if (theArgNb < 2) |
7485 | { | |
b5ac8292 | 7486 | if (aView.IsNull()) |
7487 | { | |
f978241f | 7488 | std::cout << "Error: no active viewer!\n"; |
b5ac8292 | 7489 | return 0; |
7490 | } | |
7491 | ||
7492 | Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo; | |
7493 | theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n"; | |
7494 | return 0; | |
7495 | } | |
7496 | ||
f978241f | 7497 | Handle(Graphic3d_Camera) aCamera; |
7498 | Graphic3d_RenderingParams* aParams = NULL; | |
7499 | Graphic3d_StereoMode aMode = Graphic3d_StereoMode_QuadBuffer; | |
7500 | if (!aView.IsNull()) | |
7501 | { | |
7502 | aParams = &aView->ChangeRenderingParams(); | |
7503 | aMode = aParams->StereoMode; | |
7504 | aCamera = aView->Camera(); | |
7505 | } | |
7506 | ||
7507 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); | |
7508 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
7509 | { | |
7510 | Standard_CString anArg = theArgVec[anArgIter]; | |
7511 | TCollection_AsciiString aFlag (anArg); | |
7512 | aFlag.LowerCase(); | |
7513 | if (anUpdateTool.parseRedrawMode (aFlag)) | |
7514 | { | |
7515 | continue; | |
7516 | } | |
7517 | else if (aFlag == "0" | |
7518 | || aFlag == "off") | |
7519 | { | |
7520 | if (++anArgIter < theArgNb) | |
7521 | { | |
7522 | std::cout << "Error: wrong number of arguments!\n"; | |
7523 | return 1; | |
7524 | } | |
7525 | ||
7526 | if (!aCamera.IsNull() | |
7527 | && aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo) | |
7528 | { | |
7529 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective); | |
7530 | } | |
7531 | ViewerTest_myDefaultCaps.contextStereo = Standard_False; | |
7532 | return 0; | |
7533 | } | |
7534 | else if (aFlag == "1" | |
7535 | || aFlag == "on") | |
7536 | { | |
7537 | if (++anArgIter < theArgNb) | |
7538 | { | |
7539 | std::cout << "Error: wrong number of arguments!\n"; | |
7540 | return 1; | |
7541 | } | |
7542 | ||
7543 | if (!aCamera.IsNull()) | |
7544 | { | |
7545 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo); | |
7546 | } | |
7547 | ViewerTest_myDefaultCaps.contextStereo = Standard_True; | |
7548 | return 0; | |
7549 | } | |
7550 | else if (aFlag == "-reverse" | |
7551 | || aFlag == "-reversed" | |
7552 | || aFlag == "-swap") | |
7553 | { | |
7554 | Standard_Boolean toEnable = Standard_True; | |
7555 | if (++anArgIter < theArgNb | |
7556 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
7557 | { | |
7558 | --anArgIter; | |
7559 | } | |
7560 | aParams->ToReverseStereo = toEnable; | |
7561 | } | |
7562 | else if (aFlag == "-noreverse" | |
7563 | || aFlag == "-noswap") | |
7564 | { | |
7565 | Standard_Boolean toDisable = Standard_True; | |
7566 | if (++anArgIter < theArgNb | |
7567 | && !parseOnOff (theArgVec[anArgIter], toDisable)) | |
7568 | { | |
7569 | --anArgIter; | |
7570 | } | |
7571 | aParams->ToReverseStereo = !toDisable; | |
7572 | } | |
7573 | else if (aFlag == "-mode" | |
7574 | || aFlag == "-stereomode") | |
7575 | { | |
7576 | if (++anArgIter >= theArgNb | |
7577 | || !parseStereoMode (theArgVec[anArgIter], aMode)) | |
7578 | { | |
7579 | std::cout << "Error: syntax error at '" << anArg << "'\n"; | |
7580 | return 1; | |
7581 | } | |
7582 | ||
7583 | if (aMode == Graphic3d_StereoMode_QuadBuffer) | |
7584 | { | |
7585 | ViewerTest_myDefaultCaps.contextStereo = Standard_True; | |
7586 | } | |
7587 | } | |
7588 | else if (aFlag == "-anaglyph" | |
7589 | || aFlag == "-anaglyphfilter") | |
7590 | { | |
7591 | Graphic3d_RenderingParams::Anaglyph aFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple; | |
7592 | if (++anArgIter >= theArgNb | |
7593 | || !parseAnaglyphFilter (theArgVec[anArgIter], aFilter)) | |
7594 | { | |
7595 | std::cout << "Error: syntax error at '" << anArg << "'\n"; | |
7596 | return 1; | |
7597 | } | |
7598 | ||
7599 | aMode = Graphic3d_StereoMode_Anaglyph; | |
7600 | aParams->AnaglyphFilter = aFilter; | |
7601 | } | |
7602 | else if (parseStereoMode (anArg, aMode)) // short syntax | |
7603 | { | |
7604 | if (aMode == Graphic3d_StereoMode_QuadBuffer) | |
7605 | { | |
7606 | ViewerTest_myDefaultCaps.contextStereo = Standard_True; | |
7607 | } | |
7608 | } | |
7609 | else | |
7610 | { | |
7611 | std::cout << "Error: syntax error at '" << anArg << "'\n"; | |
7612 | return 1; | |
7613 | } | |
7614 | } | |
7615 | ||
7616 | if (!aView.IsNull()) | |
7617 | { | |
7618 | aParams->StereoMode = aMode; | |
7619 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo); | |
7620 | } | |
b5ac8292 | 7621 | return 0; |
7622 | } | |
7623 | ||
392ac980 | 7624 | //=============================================================================================== |
7625 | //function : VDefaults | |
7626 | //purpose : | |
7627 | //=============================================================================================== | |
7628 | static int VDefaults (Draw_Interpretor& theDi, | |
7629 | Standard_Integer theArgsNb, | |
7630 | const char** theArgVec) | |
7631 | { | |
7632 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); | |
7633 | if (aCtx.IsNull()) | |
7634 | { | |
7635 | std::cerr << "No active viewer!\n"; | |
7636 | return 1; | |
7637 | } | |
7638 | ||
7639 | Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer(); | |
7640 | if (theArgsNb < 2) | |
7641 | { | |
7642 | if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE) | |
7643 | { | |
7644 | theDi << "DeflType: relative\n" | |
7645 | << "DeviationCoeff: " << aDefParams->DeviationCoefficient() << "\n"; | |
7646 | } | |
7647 | else | |
7648 | { | |
7649 | theDi << "DeflType: absolute\n" | |
7650 | << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n"; | |
7651 | } | |
7652 | theDi << "AngularDeflection: " << (180.0 * aDefParams->HLRAngle() / M_PI) << "\n"; | |
4c513386 | 7653 | theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n"; |
392ac980 | 7654 | return 0; |
7655 | } | |
7656 | ||
7657 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
7658 | { | |
7659 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
4c513386 | 7660 | anArg.UpperCase(); |
7661 | if (anArg == "-ABSDEFL" | |
7662 | || anArg == "-ABSOLUTEDEFLECTION" | |
7663 | || anArg == "-DEFL" | |
7664 | || anArg == "-DEFLECTION") | |
392ac980 | 7665 | { |
4c513386 | 7666 | if (++anArgIter >= theArgsNb) |
7667 | { | |
7668 | std::cout << "Error: wrong syntax at " << anArg << "\n"; | |
7669 | return 1; | |
7670 | } | |
392ac980 | 7671 | aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE); |
4c513386 | 7672 | aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter])); |
392ac980 | 7673 | } |
4c513386 | 7674 | else if (anArg == "-RELDEFL" |
7675 | || anArg == "-RELATIVEDEFLECTION" | |
7676 | || anArg == "-DEVCOEFF" | |
7677 | || anArg == "-DEVIATIONCOEFF" | |
7678 | || anArg == "-DEVIATIONCOEFFICIENT") | |
392ac980 | 7679 | { |
4c513386 | 7680 | if (++anArgIter >= theArgsNb) |
7681 | { | |
7682 | std::cout << "Error: wrong syntax at " << anArg << "\n"; | |
7683 | return 1; | |
7684 | } | |
392ac980 | 7685 | aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE); |
4c513386 | 7686 | aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter])); |
392ac980 | 7687 | } |
4c513386 | 7688 | else if (anArg == "-ANGDEFL" |
7689 | || anArg == "-ANGULARDEFL" | |
7690 | || anArg == "-ANGULARDEFLECTION") | |
392ac980 | 7691 | { |
4c513386 | 7692 | if (++anArgIter >= theArgsNb) |
7693 | { | |
7694 | std::cout << "Error: wrong syntax at " << anArg << "\n"; | |
7695 | return 1; | |
7696 | } | |
392ac980 | 7697 | // currently HLRDeviationAngle is used instead of DeviationAngle in most places |
4c513386 | 7698 | aDefParams->SetHLRAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0); |
7699 | } | |
385c43e7 | 7700 | else if (anArg == "-AUTOTR" |
7701 | || anArg == "-AUTOTRIANG" | |
7702 | || anArg == "-AUTOTRIANGULATION") | |
4c513386 | 7703 | { |
7704 | if (++anArgIter >= theArgsNb) | |
7705 | { | |
7706 | std::cout << "Error: wrong syntax at " << anArg << "\n"; | |
7707 | return 1; | |
7708 | } | |
7709 | TCollection_AsciiString aValue (theArgVec[anArgIter]); | |
7710 | aValue.LowerCase(); | |
7711 | if (aValue == "on" | |
7712 | || aValue == "1") | |
7713 | { | |
7714 | aDefParams->SetAutoTriangulation (Standard_True); | |
7715 | } | |
7716 | else if (aValue == "off" | |
7717 | || aValue == "0") | |
7718 | { | |
7719 | aDefParams->SetAutoTriangulation (Standard_False); | |
7720 | } | |
392ac980 | 7721 | } |
7722 | else | |
7723 | { | |
7724 | std::cerr << "Warning, unknown argument '" << anArg.ToCString() << "'\n"; | |
7725 | } | |
7726 | } | |
7727 | ||
7728 | return 0; | |
7729 | } | |
7730 | ||
12381341 | 7731 | //! Auxiliary method |
7732 | inline void addLight (const Handle(V3d_Light)& theLightNew, | |
7733 | const Standard_Boolean theIsGlobal) | |
7734 | { | |
7735 | if (theLightNew.IsNull()) | |
7736 | { | |
7737 | return; | |
7738 | } | |
7739 | ||
7740 | if (theIsGlobal) | |
7741 | { | |
7742 | ViewerTest::GetViewerFromContext()->SetLightOn (theLightNew); | |
7743 | } | |
7744 | else | |
7745 | { | |
7746 | ViewerTest::CurrentView()->SetLightOn (theLightNew); | |
7747 | } | |
7748 | } | |
7749 | ||
7750 | //! Auxiliary method | |
7751 | inline Standard_Integer getLightId (const TCollection_AsciiString& theArgNext) | |
7752 | { | |
7753 | TCollection_AsciiString anArgNextCase (theArgNext); | |
7754 | anArgNextCase.UpperCase(); | |
7755 | if (anArgNextCase.Length() > 5 | |
7756 | && anArgNextCase.SubString (1, 5).IsEqual ("LIGHT")) | |
7757 | { | |
7758 | return theArgNext.SubString (6, theArgNext.Length()).IntegerValue(); | |
7759 | } | |
7760 | else | |
7761 | { | |
7762 | return theArgNext.IntegerValue(); | |
7763 | } | |
7764 | } | |
7765 | ||
7766 | //=============================================================================================== | |
7767 | //function : VLight | |
7768 | //purpose : | |
7769 | //=============================================================================================== | |
7770 | static int VLight (Draw_Interpretor& theDi, | |
7771 | Standard_Integer theArgsNb, | |
7772 | const char** theArgVec) | |
7773 | { | |
7774 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7775 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
7776 | if (aView.IsNull() | |
7777 | || aViewer.IsNull()) | |
7778 | { | |
7779 | std::cerr << "No active viewer!\n"; | |
7780 | return 1; | |
7781 | } | |
7782 | ||
7783 | Standard_Real anXYZ[3]; | |
7784 | Quantity_Coefficient anAtten[2]; | |
7785 | if (theArgsNb < 2) | |
7786 | { | |
7787 | // print lights info | |
7788 | Standard_Integer aLightId = 0; | |
7789 | for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightId) | |
7790 | { | |
7791 | Handle(V3d_Light) aLight = aView->ActiveLight(); | |
7792 | const Quantity_Color aColor = aLight->Color(); | |
7793 | theDi << "Light" << aLightId << "\n"; | |
7794 | switch (aLight->Type()) | |
7795 | { | |
7796 | case V3d_AMBIENT: | |
7797 | { | |
189f85a3 | 7798 | theDi << " Type: Ambient\n"; |
7799 | theDi << " Intensity: " << aLight->Intensity() << "\n"; | |
12381341 | 7800 | break; |
7801 | } | |
7802 | case V3d_DIRECTIONAL: | |
7803 | { | |
7804 | Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLight); | |
189f85a3 | 7805 | theDi << " Type: Directional\n"; |
7806 | theDi << " Intensity: " << aLight->Intensity() << "\n"; | |
7807 | theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n"; | |
7808 | theDi << " Smoothness: " << aLight->Smoothness() << "\n"; | |
12381341 | 7809 | if (!aLightDir.IsNull()) |
7810 | { | |
7811 | aLightDir->Position (anXYZ[0], anXYZ[1], anXYZ[2]); | |
189f85a3 | 7812 | theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n"; |
12381341 | 7813 | aLightDir->Direction (anXYZ[0], anXYZ[1], anXYZ[2]); |
189f85a3 | 7814 | theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n"; |
12381341 | 7815 | } |
7816 | break; | |
7817 | } | |
7818 | case V3d_POSITIONAL: | |
7819 | { | |
7820 | Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight)::DownCast (aLight); | |
189f85a3 | 7821 | theDi << " Type: Positional\n"; |
7822 | theDi << " Intensity: " << aLight->Intensity() << "\n"; | |
7823 | theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n"; | |
7824 | theDi << " Smoothness: " << aLight->Smoothness() << "\n"; | |
12381341 | 7825 | if (!aLightPos.IsNull()) |
7826 | { | |
7827 | aLightPos->Position (anXYZ[0], anXYZ[1], anXYZ[2]); | |
189f85a3 | 7828 | theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n"; |
12381341 | 7829 | aLightPos->Attenuation (anAtten[0], anAtten[1]); |
189f85a3 | 7830 | theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n"; |
12381341 | 7831 | } |
7832 | break; | |
7833 | } | |
7834 | case V3d_SPOT: | |
7835 | { | |
7836 | Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight)::DownCast (aLight); | |
189f85a3 | 7837 | theDi << " Type: Spot\n"; |
7838 | theDi << " Intensity: " << aLight->Intensity() << "\n"; | |
7839 | theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n"; | |
12381341 | 7840 | if (!aLightSpot.IsNull()) |
7841 | { | |
7842 | aLightSpot->Position (anXYZ[0], anXYZ[1], anXYZ[2]); | |
189f85a3 | 7843 | theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n"; |
12381341 | 7844 | aLightSpot->Direction (anXYZ[0], anXYZ[1], anXYZ[2]); |
189f85a3 | 7845 | theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n"; |
12381341 | 7846 | aLightSpot->Attenuation (anAtten[0], anAtten[1]); |
189f85a3 | 7847 | theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n"; |
7848 | theDi << " Angle: " << (aLightSpot->Angle() * 180.0 / M_PI) << "\n"; | |
7849 | theDi << " Exponent: " << aLightSpot->Concentration() << "\n"; | |
12381341 | 7850 | } |
7851 | break; | |
7852 | } | |
7853 | default: | |
7854 | { | |
189f85a3 | 7855 | theDi << " Type: UNKNOWN\n"; |
12381341 | 7856 | break; |
7857 | } | |
7858 | } | |
7859 | theDi << " Color: " << aColor.Red() << ", " << aColor.Green() << ", " << aColor.Blue() << "\n"; | |
7860 | } | |
7861 | } | |
7862 | ||
7863 | Handle(V3d_Light) aLightNew; | |
7864 | Handle(V3d_Light) aLightOld; | |
7865 | Standard_Boolean isGlobal = Standard_True; | |
7866 | Standard_Boolean toCreate = Standard_False; | |
7867 | for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) | |
7868 | { | |
7869 | Handle(V3d_Light) aLightCurr = aLightNew.IsNull() ? aLightOld : aLightNew; | |
7870 | Handle(V3d_AmbientLight) aLightAmb = Handle(V3d_AmbientLight) ::DownCast (aLightCurr); | |
7871 | Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLightCurr); | |
7872 | Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight) ::DownCast (aLightCurr); | |
7873 | Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight) ::DownCast (aLightCurr); | |
7874 | ||
7875 | TCollection_AsciiString aName, aValue; | |
7876 | const TCollection_AsciiString anArg (theArgVec[anArgIt]); | |
7877 | TCollection_AsciiString anArgCase (anArg); | |
7878 | anArgCase.UpperCase(); | |
7879 | if (anArgCase.IsEqual ("NEW") | |
7880 | || anArgCase.IsEqual ("ADD") | |
7881 | || anArgCase.IsEqual ("CREATE")) | |
7882 | { | |
7883 | toCreate = Standard_True; | |
7884 | } | |
7885 | else if (anArgCase.IsEqual ("GLOB") | |
7886 | || anArgCase.IsEqual ("GLOBAL")) | |
7887 | { | |
7888 | isGlobal = Standard_True; | |
7889 | } | |
7890 | else if (anArgCase.IsEqual ("LOC") | |
7891 | || anArgCase.IsEqual ("LOCAL")) | |
7892 | { | |
7893 | isGlobal = Standard_False; | |
7894 | } | |
4fe9ad57 | 7895 | else if (anArgCase.IsEqual ("DEF") |
7896 | || anArgCase.IsEqual ("DEFAULTS")) | |
7897 | { | |
7898 | toCreate = Standard_False; | |
7899 | aViewer->SetDefaultLights(); | |
7900 | } | |
7901 | else if (anArgCase.IsEqual ("CLR") | |
7902 | || anArgCase.IsEqual ("CLEAR")) | |
7903 | { | |
7904 | toCreate = Standard_False; | |
7905 | aView->InitActiveLights(); | |
7906 | while (aView->MoreActiveLights()) | |
7907 | { | |
7908 | aViewer->DelLight (aView->ActiveLight()); | |
7909 | aView->InitActiveLights(); | |
7910 | } | |
7911 | } | |
12381341 | 7912 | else if (anArgCase.IsEqual ("AMB") |
7913 | || anArgCase.IsEqual ("AMBIENT") | |
7914 | || anArgCase.IsEqual ("AMBLIGHT")) | |
7915 | { | |
7916 | addLight (aLightNew, isGlobal); | |
7917 | if (!toCreate) | |
7918 | { | |
7919 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
7920 | return 1; | |
7921 | } | |
7922 | toCreate = Standard_False; | |
7923 | aLightNew = new V3d_AmbientLight (aViewer); | |
7924 | } | |
7925 | else if (anArgCase.IsEqual ("DIRECTIONAL") | |
7926 | || anArgCase.IsEqual ("DIRLIGHT")) | |
7927 | { | |
7928 | addLight (aLightNew, isGlobal); | |
7929 | if (!toCreate) | |
7930 | { | |
7931 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
7932 | return 1; | |
7933 | } | |
7934 | toCreate = Standard_False; | |
7935 | aLightNew = new V3d_DirectionalLight (aViewer); | |
7936 | } | |
7937 | else if (anArgCase.IsEqual ("SPOT") | |
7938 | || anArgCase.IsEqual ("SPOTLIGHT")) | |
7939 | { | |
7940 | addLight (aLightNew, isGlobal); | |
7941 | if (!toCreate) | |
7942 | { | |
7943 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
7944 | return 1; | |
7945 | } | |
7946 | toCreate = Standard_False; | |
7947 | aLightNew = new V3d_SpotLight (aViewer, 0.0, 0.0, 0.0); | |
7948 | } | |
7949 | else if (anArgCase.IsEqual ("POSLIGHT") | |
7950 | || anArgCase.IsEqual ("POSITIONAL")) | |
7951 | { | |
7952 | addLight (aLightNew, isGlobal); | |
7953 | if (!toCreate) | |
7954 | { | |
7955 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
7956 | return 1; | |
7957 | } | |
7958 | toCreate = Standard_False; | |
7959 | aLightNew = new V3d_PositionalLight (aViewer, 0.0, 0.0, 0.0); | |
7960 | } | |
7961 | else if (anArgCase.IsEqual ("CHANGE")) | |
7962 | { | |
7963 | addLight (aLightNew, isGlobal); | |
7964 | aLightNew.Nullify(); | |
7965 | if (++anArgIt >= theArgsNb) | |
7966 | { | |
7967 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
7968 | return 1; | |
7969 | } | |
7970 | ||
7971 | const Standard_Integer aLightId = getLightId (theArgVec[anArgIt]); | |
7972 | Standard_Integer aLightIt = 0; | |
7973 | for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightIt) | |
7974 | { | |
7975 | if (aLightIt == aLightId) | |
7976 | { | |
7977 | aLightOld = aView->ActiveLight(); | |
7978 | break; | |
7979 | } | |
7980 | } | |
7981 | ||
7982 | if (aLightOld.IsNull()) | |
7983 | { | |
7984 | std::cerr << "Light " << theArgVec[anArgIt] << " is undefined!\n"; | |
7985 | return 1; | |
7986 | } | |
7987 | } | |
7988 | else if (anArgCase.IsEqual ("DEL") | |
7989 | || anArgCase.IsEqual ("DELETE")) | |
7990 | { | |
7991 | Handle(V3d_Light) aLightDel; | |
7992 | if (++anArgIt >= theArgsNb) | |
7993 | { | |
7994 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
7995 | return 1; | |
7996 | } | |
7997 | ||
7998 | const TCollection_AsciiString anArgNext (theArgVec[anArgIt]); | |
7999 | const Standard_Integer aLightDelId = getLightId (theArgVec[anArgIt]); | |
8000 | Standard_Integer aLightIt = 0; | |
8001 | for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightIt) | |
8002 | { | |
8003 | aLightDel = aView->ActiveLight(); | |
8004 | if (aLightIt == aLightDelId) | |
8005 | { | |
8006 | break; | |
8007 | } | |
8008 | } | |
8009 | if (!aLightDel.IsNull()) | |
8010 | { | |
8011 | aViewer->DelLight (aLightDel); | |
8012 | } | |
8013 | } | |
8014 | else if (anArgCase.IsEqual ("COLOR") | |
8015 | || anArgCase.IsEqual ("COLOUR")) | |
8016 | { | |
8017 | if (++anArgIt >= theArgsNb) | |
8018 | { | |
8019 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8020 | return 1; | |
8021 | } | |
8022 | ||
8023 | TCollection_AsciiString anArgNext (theArgVec[anArgIt]); | |
8024 | anArgNext.UpperCase(); | |
8025 | const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString()); | |
8026 | if (!aLightCurr.IsNull()) | |
8027 | { | |
8028 | aLightCurr->SetColor (aColor); | |
8029 | } | |
8030 | } | |
8031 | else if (anArgCase.IsEqual ("POS") | |
8032 | || anArgCase.IsEqual ("POSITION")) | |
8033 | { | |
8034 | if ((anArgIt + 3) >= theArgsNb) | |
8035 | { | |
8036 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8037 | return 1; | |
8038 | } | |
8039 | ||
8040 | anXYZ[0] = Atof (theArgVec[++anArgIt]); | |
8041 | anXYZ[1] = Atof (theArgVec[++anArgIt]); | |
8042 | anXYZ[2] = Atof (theArgVec[++anArgIt]); | |
8043 | if (!aLightDir.IsNull()) | |
8044 | { | |
8045 | aLightDir->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]); | |
8046 | } | |
8047 | else if (!aLightPos.IsNull()) | |
8048 | { | |
8049 | aLightPos->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]); | |
8050 | } | |
8051 | else if (!aLightSpot.IsNull()) | |
8052 | { | |
8053 | aLightSpot->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]); | |
8054 | } | |
8055 | else | |
8056 | { | |
8057 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8058 | return 1; | |
8059 | } | |
8060 | } | |
8061 | else if (anArgCase.IsEqual ("DIR") | |
8062 | || anArgCase.IsEqual ("DIRECTION")) | |
8063 | { | |
8064 | if ((anArgIt + 3) >= theArgsNb) | |
8065 | { | |
8066 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8067 | return 1; | |
8068 | } | |
8069 | ||
8070 | anXYZ[0] = Atof (theArgVec[++anArgIt]); | |
8071 | anXYZ[1] = Atof (theArgVec[++anArgIt]); | |
8072 | anXYZ[2] = Atof (theArgVec[++anArgIt]); | |
8073 | if (!aLightDir.IsNull()) | |
8074 | { | |
8075 | aLightDir->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]); | |
8076 | } | |
8077 | else if (!aLightSpot.IsNull()) | |
8078 | { | |
8079 | aLightSpot->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]); | |
8080 | } | |
8081 | else | |
8082 | { | |
8083 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8084 | return 1; | |
8085 | } | |
8086 | } | |
189f85a3 | 8087 | else if (anArgCase.IsEqual ("SM") |
8088 | || anArgCase.IsEqual ("SMOOTHNESS")) | |
8089 | { | |
8090 | if (++anArgIt >= theArgsNb) | |
8091 | { | |
8092 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8093 | return 1; | |
8094 | } | |
8095 | ||
8096 | Standard_Real aSmoothness = Atof (theArgVec[anArgIt]); | |
8097 | ||
8098 | if (fabs (aSmoothness) < Precision::Confusion()) | |
8099 | { | |
8100 | aLightCurr->SetIntensity (1.f); | |
8101 | } | |
8102 | else if (fabs (aLightCurr->Smoothness()) < Precision::Confusion()) | |
8103 | { | |
8104 | aLightCurr->SetIntensity ((aSmoothness * aSmoothness) / 3.f); | |
8105 | } | |
8106 | else | |
8107 | { | |
8108 | Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightCurr->Smoothness()); | |
8109 | aLightCurr->SetIntensity (aLightCurr->Intensity() / (aSmoothnessRatio * aSmoothnessRatio)); | |
8110 | } | |
8111 | ||
8112 | if (!aLightPos.IsNull()) | |
8113 | { | |
8114 | aLightPos->SetSmoothRadius (aSmoothness); | |
8115 | } | |
8116 | else if (!aLightDir.IsNull()) | |
8117 | { | |
8118 | aLightDir->SetSmoothAngle (aSmoothness); | |
8119 | } | |
8120 | } | |
8121 | else if (anArgCase.IsEqual ("INT") | |
8122 | || anArgCase.IsEqual ("INTENSITY")) | |
8123 | { | |
8124 | if (++anArgIt >= theArgsNb) | |
8125 | { | |
8126 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8127 | return 1; | |
8128 | } | |
8129 | ||
8130 | Standard_Real aIntensity = Atof (theArgVec[anArgIt]); | |
8131 | ||
8132 | if (!aLightCurr.IsNull()) | |
8133 | { | |
8134 | aLightCurr->SetIntensity (aIntensity); | |
8135 | } | |
8136 | } | |
4fe9ad57 | 8137 | else if (anArgCase.IsEqual ("ANG") |
8138 | || anArgCase.IsEqual ("ANGLE")) | |
8139 | { | |
8140 | if (++anArgIt >= theArgsNb) | |
8141 | { | |
8142 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8143 | return 1; | |
8144 | } | |
8145 | ||
8146 | Standard_Real anAngle = Atof (theArgVec[anArgIt]); | |
8147 | ||
8148 | if (!aLightSpot.IsNull()) | |
8149 | { | |
8150 | aLightSpot->SetAngle (anAngle / 180.0 * M_PI); | |
8151 | } | |
8152 | } | |
12381341 | 8153 | else if (anArgCase.IsEqual ("CONSTATTEN") |
8154 | || anArgCase.IsEqual ("CONSTATTENUATION")) | |
8155 | { | |
8156 | if (++anArgIt >= theArgsNb) | |
8157 | { | |
8158 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8159 | return 1; | |
8160 | } | |
8161 | ||
8162 | if (!aLightPos.IsNull()) | |
8163 | { | |
8164 | aLightPos->Attenuation (anAtten[0], anAtten[1]); | |
8165 | anAtten[0] = Atof (theArgVec[anArgIt]); | |
8166 | aLightPos->SetAttenuation (anAtten[0], anAtten[1]); | |
8167 | } | |
8168 | else if (!aLightSpot.IsNull()) | |
8169 | { | |
8170 | aLightSpot->Attenuation (anAtten[0], anAtten[1]); | |
8171 | anAtten[0] = Atof (theArgVec[anArgIt]); | |
8172 | aLightSpot->SetAttenuation (anAtten[0], anAtten[1]); | |
8173 | } | |
8174 | else | |
8175 | { | |
8176 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8177 | return 1; | |
8178 | } | |
8179 | } | |
8180 | else if (anArgCase.IsEqual ("LINATTEN") | |
8181 | || anArgCase.IsEqual ("LINEARATTEN") | |
8182 | || anArgCase.IsEqual ("LINEARATTENUATION")) | |
8183 | { | |
8184 | if (++anArgIt >= theArgsNb) | |
8185 | { | |
8186 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8187 | return 1; | |
8188 | } | |
8189 | ||
8190 | if (!aLightPos.IsNull()) | |
8191 | { | |
8192 | aLightPos->Attenuation (anAtten[0], anAtten[1]); | |
8193 | anAtten[1] = Atof (theArgVec[anArgIt]); | |
8194 | aLightPos->SetAttenuation (anAtten[0], anAtten[1]); | |
8195 | } | |
8196 | else if (!aLightSpot.IsNull()) | |
8197 | { | |
8198 | aLightSpot->Attenuation (anAtten[0], anAtten[1]); | |
8199 | anAtten[1] = Atof (theArgVec[anArgIt]); | |
8200 | aLightSpot->SetAttenuation (anAtten[0], anAtten[1]); | |
8201 | } | |
8202 | else | |
8203 | { | |
8204 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8205 | return 1; | |
8206 | } | |
8207 | } | |
8208 | else if (anArgCase.IsEqual ("EXP") | |
8209 | || anArgCase.IsEqual ("EXPONENT") | |
8210 | || anArgCase.IsEqual ("SPOTEXP") | |
8211 | || anArgCase.IsEqual ("SPOTEXPONENT")) | |
8212 | { | |
8213 | if (++anArgIt >= theArgsNb) | |
8214 | { | |
8215 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8216 | return 1; | |
8217 | } | |
8218 | ||
8219 | if (!aLightSpot.IsNull()) | |
8220 | { | |
8221 | aLightSpot->SetConcentration (Atof (theArgVec[anArgIt])); | |
8222 | } | |
8223 | else | |
8224 | { | |
8225 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8226 | return 1; | |
8227 | } | |
8228 | } | |
8229 | else if (anArgCase.IsEqual ("HEAD") | |
8230 | || anArgCase.IsEqual ("HEADLIGHT")) | |
8231 | { | |
8232 | if (++anArgIt >= theArgsNb) | |
8233 | { | |
8234 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8235 | return 1; | |
8236 | } | |
8237 | ||
8238 | if (aLightAmb.IsNull() | |
8239 | && !aLightCurr.IsNull()) | |
8240 | { | |
8241 | aLightCurr->SetHeadlight (Draw::Atoi (theArgVec[anArgIt]) != 0); | |
8242 | } | |
8243 | else | |
8244 | { | |
8245 | std::cerr << "Wrong syntax at argument '" << anArg << "'!\n"; | |
8246 | return 1; | |
8247 | } | |
8248 | } | |
8249 | else | |
8250 | { | |
8251 | std::cerr << "Warning: unknown argument '" << anArg << "'\n"; | |
8252 | } | |
8253 | } | |
8254 | ||
8255 | addLight (aLightNew, isGlobal); | |
8256 | aViewer->UpdateLights(); | |
8257 | ||
8258 | return 0; | |
8259 | } | |
8260 | ||
e276548b | 8261 | //======================================================================= |
bc8c79bb | 8262 | //function : VRenderParams |
8263 | //purpose : Enables/disables rendering features | |
e276548b | 8264 | //======================================================================= |
8265 | ||
bc8c79bb | 8266 | static Standard_Integer VRenderParams (Draw_Interpretor& theDI, |
8267 | Standard_Integer theArgNb, | |
8268 | const char** theArgVec) | |
e276548b | 8269 | { |
7ae4a307 | 8270 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
8271 | if (aView.IsNull()) | |
e276548b | 8272 | { |
bc8c79bb | 8273 | std::cerr << "Error: no active viewer!\n"; |
e276548b | 8274 | return 1; |
8275 | } | |
bc8c79bb | 8276 | |
8277 | Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams(); | |
6b62b2da | 8278 | TCollection_AsciiString aCmdName (theArgVec[0]); |
8279 | aCmdName.LowerCase(); | |
8280 | if (aCmdName == "vraytrace") | |
8281 | { | |
8282 | if (theArgNb == 1) | |
8283 | { | |
8284 | theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "on" : "off") << " "; | |
8285 | return 0; | |
8286 | } | |
8287 | else if (theArgNb == 2) | |
8288 | { | |
8289 | TCollection_AsciiString aValue (theArgVec[1]); | |
8290 | aValue.LowerCase(); | |
8291 | if (aValue == "on" | |
8292 | || aValue == "1") | |
8293 | { | |
8294 | aParams.Method = Graphic3d_RM_RAYTRACING; | |
8295 | aView->Redraw(); | |
8296 | return 0; | |
8297 | } | |
8298 | else if (aValue == "off" | |
8299 | || aValue == "0") | |
8300 | { | |
8301 | aParams.Method = Graphic3d_RM_RASTERIZATION; | |
8302 | aView->Redraw(); | |
8303 | return 0; | |
8304 | } | |
8305 | else | |
8306 | { | |
8307 | std::cout << "Error: unknown argument '" << theArgVec[1] << "'\n"; | |
8308 | return 1; | |
8309 | } | |
8310 | } | |
8311 | else | |
8312 | { | |
8313 | std::cout << "Error: wrong number of arguments\n"; | |
8314 | return 1; | |
8315 | } | |
8316 | } | |
bc8c79bb | 8317 | |
8318 | if (theArgNb < 2) | |
e276548b | 8319 | { |
bc8c79bb | 8320 | theDI << "renderMode: "; |
8321 | switch (aParams.Method) | |
8322 | { | |
8323 | case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break; | |
8324 | case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break; | |
8325 | } | |
8326 | theDI << "\n"; | |
189f85a3 | 8327 | theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n"; |
8328 | theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n"; | |
8329 | theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n"; | |
8330 | theDI << "rayDepth: " << aParams.RaytracingDepth << "\n"; | |
8331 | theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n"; | |
8332 | theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n"; | |
8625ef7e | 8333 | theDI << "shadingModel: "; |
8334 | switch (aView->ShadingModel()) | |
8335 | { | |
8336 | case V3d_COLOR: theDI << "color"; break; | |
8337 | case V3d_FLAT: theDI << "flat"; break; | |
8338 | case V3d_GOURAUD: theDI << "gouraud"; break; | |
8339 | case V3d_PHONG: theDI << "phong"; break; | |
8340 | } | |
8341 | theDI << "\n"; | |
bc8c79bb | 8342 | return 0; |
e276548b | 8343 | } |
8344 | ||
bc8c79bb | 8345 | Standard_Boolean toPrint = Standard_False; |
8625ef7e | 8346 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
e276548b | 8347 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
8348 | { | |
bc8c79bb | 8349 | Standard_CString anArg (theArgVec[anArgIter]); |
8350 | TCollection_AsciiString aFlag (anArg); | |
8351 | aFlag.LowerCase(); | |
8625ef7e | 8352 | if (anUpdateTool.parseRedrawMode (aFlag)) |
8353 | { | |
8354 | continue; | |
8355 | } | |
8356 | else if (aFlag == "-echo" | |
8357 | || aFlag == "-print") | |
e276548b | 8358 | { |
bc8c79bb | 8359 | toPrint = Standard_True; |
8625ef7e | 8360 | anUpdateTool.Invalidate(); |
e276548b | 8361 | } |
bc8c79bb | 8362 | else if (aFlag == "-mode" |
8363 | || aFlag == "-rendermode" | |
8364 | || aFlag == "-render_mode") | |
e276548b | 8365 | { |
bc8c79bb | 8366 | if (toPrint) |
8367 | { | |
8368 | switch (aParams.Method) | |
8369 | { | |
8370 | case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break; | |
8371 | case Graphic3d_RM_RAYTRACING: theDI << "ray-tracing "; break; | |
8372 | } | |
8373 | continue; | |
8374 | } | |
e276548b | 8375 | else |
bc8c79bb | 8376 | { |
8377 | std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n"; | |
8378 | return 1; | |
8379 | } | |
8380 | } | |
8381 | else if (aFlag == "-ray" | |
8382 | || aFlag == "-raytrace") | |
8383 | { | |
8384 | if (toPrint) | |
8385 | { | |
8386 | theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "true" : "false") << " "; | |
8387 | continue; | |
8388 | } | |
8389 | ||
8390 | aParams.Method = Graphic3d_RM_RAYTRACING; | |
e276548b | 8391 | } |
bc8c79bb | 8392 | else if (aFlag == "-rast" |
8393 | || aFlag == "-raster" | |
8394 | || aFlag == "-rasterization") | |
e276548b | 8395 | { |
bc8c79bb | 8396 | if (toPrint) |
8397 | { | |
8398 | theDI << (aParams.Method == Graphic3d_RM_RASTERIZATION ? "true" : "false") << " "; | |
8399 | continue; | |
8400 | } | |
8401 | ||
8402 | aParams.Method = Graphic3d_RM_RASTERIZATION; | |
8403 | } | |
8404 | else if (aFlag == "-raydepth" | |
8405 | || aFlag == "-ray_depth") | |
8406 | { | |
8407 | if (toPrint) | |
8408 | { | |
8409 | theDI << aParams.RaytracingDepth << " "; | |
8410 | continue; | |
8411 | } | |
8412 | else if (++anArgIter >= theArgNb) | |
8413 | { | |
8414 | std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n"; | |
8415 | return 1; | |
8416 | } | |
8417 | ||
8418 | const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]); | |
189f85a3 | 8419 | |
8420 | // We allow RaytracingDepth be more than 10 in case of GI enabled | |
8421 | if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled)) | |
bc8c79bb | 8422 | { |
8423 | std::cerr << "Error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]\n"; | |
8424 | return 1; | |
8425 | } | |
e276548b | 8426 | else |
bc8c79bb | 8427 | { |
8428 | aParams.RaytracingDepth = aDepth; | |
8429 | } | |
8430 | } | |
8431 | else if (aFlag == "-shad" | |
8432 | || aFlag == "-shadows") | |
8433 | { | |
8434 | if (toPrint) | |
8435 | { | |
8436 | theDI << (aParams.IsShadowEnabled ? "on" : "off") << " "; | |
8437 | continue; | |
8438 | } | |
8439 | ||
8440 | Standard_Boolean toEnable = Standard_True; | |
8441 | if (++anArgIter < theArgNb | |
8442 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
8443 | { | |
8444 | --anArgIter; | |
8445 | } | |
8446 | aParams.IsShadowEnabled = toEnable; | |
8447 | } | |
8448 | else if (aFlag == "-refl" | |
8449 | || aFlag == "-reflections") | |
8450 | { | |
8451 | if (toPrint) | |
8452 | { | |
8453 | theDI << (aParams.IsReflectionEnabled ? "on" : "off") << " "; | |
8454 | continue; | |
8455 | } | |
8456 | ||
8457 | Standard_Boolean toEnable = Standard_True; | |
8458 | if (++anArgIter < theArgNb | |
8459 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
8460 | { | |
8461 | --anArgIter; | |
8462 | } | |
8463 | aParams.IsReflectionEnabled = toEnable; | |
8464 | } | |
8465 | else if (aFlag == "-fsaa") | |
8466 | { | |
8467 | if (toPrint) | |
8468 | { | |
8469 | theDI << (aParams.IsAntialiasingEnabled ? "on" : "off") << " "; | |
8470 | continue; | |
8471 | } | |
8472 | ||
8473 | Standard_Boolean toEnable = Standard_True; | |
8474 | if (++anArgIter < theArgNb | |
8475 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
8476 | { | |
8477 | --anArgIter; | |
8478 | } | |
8479 | aParams.IsAntialiasingEnabled = toEnable; | |
8480 | } | |
8481 | else if (aFlag == "-gleam") | |
8482 | { | |
8483 | if (toPrint) | |
8484 | { | |
8485 | theDI << (aParams.IsTransparentShadowEnabled ? "on" : "off") << " "; | |
8486 | continue; | |
8487 | } | |
8488 | ||
8489 | Standard_Boolean toEnable = Standard_True; | |
8490 | if (++anArgIter < theArgNb | |
8491 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
8492 | { | |
8493 | --anArgIter; | |
8494 | } | |
8495 | aParams.IsTransparentShadowEnabled = toEnable; | |
e276548b | 8496 | } |
189f85a3 | 8497 | else if (aFlag == "-gi") |
8498 | { | |
8499 | if (toPrint) | |
8500 | { | |
8501 | theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " "; | |
8502 | continue; | |
8503 | } | |
8504 | ||
8505 | Standard_Boolean toEnable = Standard_True; | |
8506 | if (++anArgIter < theArgNb | |
8507 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
8508 | { | |
8509 | --anArgIter; | |
8510 | } | |
8511 | aParams.IsGlobalIlluminationEnabled = toEnable; | |
8512 | if (!toEnable) | |
8513 | { | |
8514 | aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10); | |
8515 | } | |
8516 | } | |
8517 | else if (aFlag == "-env") | |
8518 | { | |
8519 | if (toPrint) | |
8520 | { | |
8521 | theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " "; | |
8522 | continue; | |
8523 | } | |
8524 | ||
8525 | Standard_Boolean toEnable = Standard_True; | |
8526 | if (++anArgIter < theArgNb | |
8527 | && !parseOnOff (theArgVec[anArgIter], toEnable)) | |
8528 | { | |
8529 | --anArgIter; | |
8530 | } | |
8531 | aParams.UseEnvironmentMapBackground = toEnable; | |
8532 | } | |
8625ef7e | 8533 | else if (aFlag == "-shademodel" |
8534 | || aFlag == "-shadingmodel" | |
8535 | || aFlag == "-shading") | |
8536 | { | |
8537 | if (toPrint) | |
8538 | { | |
8539 | switch (aView->ShadingModel()) | |
8540 | { | |
8541 | case V3d_COLOR: theDI << "color "; break; | |
8542 | case V3d_FLAT: theDI << "flat "; break; | |
8543 | case V3d_GOURAUD: theDI << "gouraud "; break; | |
8544 | case V3d_PHONG: theDI << "phong "; break; | |
8545 | } | |
8546 | continue; | |
8547 | } | |
8548 | ||
8549 | if (++anArgIter >= theArgNb) | |
8550 | { | |
8551 | std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n"; | |
8552 | } | |
8553 | ||
8554 | TCollection_AsciiString aMode (theArgVec[anArgIter]); | |
8555 | aMode.LowerCase(); | |
8556 | if (aMode == "color" | |
8557 | || aMode == "none") | |
8558 | { | |
8559 | aView->SetShadingModel (V3d_COLOR); | |
8560 | } | |
8561 | else if (aMode == "flat" | |
8562 | || aMode == "facet") | |
8563 | { | |
8564 | aView->SetShadingModel (V3d_FLAT); | |
8565 | } | |
8566 | else if (aMode == "gouraud" | |
8567 | || aMode == "vertex" | |
8568 | || aMode == "vert") | |
8569 | { | |
8570 | aView->SetShadingModel (V3d_GOURAUD); | |
8571 | } | |
8572 | else if (aMode == "phong" | |
8573 | || aMode == "fragment" | |
8574 | || aMode == "frag" | |
8575 | || aMode == "pixel") | |
8576 | { | |
8577 | aView->SetShadingModel (V3d_PHONG); | |
8578 | } | |
8579 | else | |
8580 | { | |
8581 | std::cout << "Error: unknown shading model '" << aMode << "'\n"; | |
8582 | return 1; | |
8583 | } | |
8584 | } | |
e276548b | 8585 | else |
8586 | { | |
bc8c79bb | 8587 | std::cout << "Error: wrong syntax, unknown flag '" << anArg << "'\n"; |
8588 | return 1; | |
e276548b | 8589 | } |
8590 | } | |
189f85a3 | 8591 | |
8592 | return 0; | |
8593 | } | |
8594 | ||
8595 | //======================================================================= | |
8596 | //function : VProgressiveMode | |
8597 | //purpose : | |
8598 | //======================================================================= | |
8599 | #if defined(_WIN32) | |
8600 | static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/, | |
8601 | Standard_Integer /*theNbArgs*/, | |
8602 | const char** /*theArgs*/) | |
8603 | { | |
8604 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
8605 | if (aView.IsNull()) | |
8606 | { | |
8607 | std::cerr << "Error: no active viewer!\n"; | |
8608 | return 1; | |
8609 | } | |
8610 | ||
8611 | std::cout << "Press Enter or Escape key to exit progressive rendering mode" << std::endl; | |
8612 | ||
8613 | for (;;) | |
8614 | { | |
8615 | aView->Redraw(); | |
8616 | ||
8617 | Standard_Boolean toExit = Standard_False; | |
8618 | ||
8619 | MSG aMsg; | |
8620 | while (PeekMessage (&aMsg, NULL, NULL, NULL, PM_REMOVE)) | |
8621 | { | |
8622 | if (aMsg.message == WM_KEYDOWN && (aMsg.wParam == 0x0d || aMsg.wParam == 0x1b)) | |
8623 | { | |
8624 | toExit = Standard_True; | |
8625 | } | |
8626 | ||
8627 | TranslateMessage (&aMsg); | |
8628 | DispatchMessage (&aMsg); | |
8629 | } | |
8630 | ||
8631 | if (toExit) | |
8632 | { | |
8633 | break; | |
8634 | } | |
8635 | } | |
8636 | ||
e276548b | 8637 | return 0; |
8638 | } | |
189f85a3 | 8639 | #endif |
e276548b | 8640 | |
b7cd4ba7 | 8641 | //======================================================================= |
8642 | //function : VFrustumCulling | |
8643 | //purpose : enables/disables view volume's culling. | |
8644 | //======================================================================= | |
8645 | static int VFrustumCulling (Draw_Interpretor& theDI, | |
8646 | Standard_Integer theArgNb, | |
8647 | const char** theArgVec) | |
8648 | { | |
8649 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
8650 | if (aView.IsNull()) | |
8651 | { | |
8652 | std::cout << theArgVec[0] << " Error: Use 'vinit' command before\n"; | |
8653 | return 1; | |
8654 | } | |
8655 | ||
8656 | if (theArgNb < 2) | |
8657 | { | |
8658 | theDI << (aView->IsCullingEnabled() ? "on" : "off"); | |
8659 | return 0; | |
8660 | } | |
8661 | else if (theArgNb != 2) | |
8662 | { | |
8663 | std::cout << theArgVec[0] << " Syntax error: Specify the mode\n"; | |
8664 | return 1; | |
8665 | } | |
8666 | ||
8667 | TCollection_AsciiString aModeStr (theArgVec[1]); | |
8668 | aModeStr.LowerCase(); | |
8669 | Standard_Boolean toEnable = 0; | |
8670 | if (aModeStr == "on") | |
8671 | { | |
8672 | toEnable = 1; | |
8673 | } | |
8674 | else if (aModeStr == "off") | |
8675 | { | |
8676 | toEnable = 0; | |
8677 | } | |
8678 | else | |
8679 | { | |
8680 | toEnable = Draw::Atoi (theArgVec[1]) != 0; | |
8681 | } | |
8682 | ||
8683 | aView->SetFrustumCulling (toEnable); | |
8684 | aView->Redraw(); | |
8685 | return 0; | |
8686 | } | |
8687 | ||
c398b00e | 8688 | //======================================================================= |
8689 | //function : VHighlightSelected | |
8690 | //purpose : | |
8691 | //======================================================================= | |
8692 | static int VHighlightSelected (Draw_Interpretor& theDI, | |
8693 | Standard_Integer theArgNb, | |
8694 | const char** theArgVec) | |
8695 | { | |
8696 | if (ViewerTest::GetAISContext().IsNull()) | |
8697 | { | |
8698 | std::cout << theArgVec[0] << " error : Context is not created. Please call vinit before.\n"; | |
8699 | return 1; | |
8700 | } | |
8701 | ||
8702 | const Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
8703 | ||
8704 | if (theArgNb < 2) | |
8705 | { | |
8706 | theDI << (aContext->ToHilightSelected() ? "on" : "off"); | |
8707 | return 0; | |
8708 | } | |
8709 | ||
8710 | if (theArgNb != 2) | |
8711 | { | |
8712 | std::cout << theArgVec[0] << " error : wrong number of parameters." | |
8713 | << "Type 'help" << theArgVec[0] << "' for more information."; | |
8714 | return 1; | |
8715 | } | |
8716 | ||
8717 | // Parse parameter | |
8718 | TCollection_AsciiString aMode (theArgVec[1]); | |
8719 | aMode.LowerCase(); | |
8720 | Standard_Boolean toEnable = Standard_False; | |
8721 | if (aMode.IsEqual ("on")) | |
8722 | { | |
8723 | toEnable = Standard_True; | |
8724 | } | |
8725 | else if (aMode.IsEqual ("off")) | |
8726 | { | |
8727 | toEnable = Standard_False; | |
8728 | } | |
8729 | else | |
8730 | { | |
8731 | toEnable = Draw::Atoi (theArgVec[1]) != 0; | |
8732 | } | |
8733 | ||
8734 | if (toEnable != aContext->ToHilightSelected()) | |
8735 | { | |
8736 | aContext->SetToHilightSelected (toEnable); | |
8737 | ||
8738 | // Move cursor to null position and back to process updating of detection | |
8739 | // and highlighting of selected object immediatly. | |
8740 | Standard_Integer aPixX = 0; | |
8741 | Standard_Integer aPixY = 0; | |
8742 | const Handle(ViewerTest_EventManager)& anEventManager = ViewerTest::CurrentEventManager(); | |
8743 | ||
8744 | anEventManager->GetCurrentPosition (aPixX, aPixY); | |
8745 | anEventManager->MoveTo (0, 0); | |
8746 | anEventManager->MoveTo (aPixX, aPixY); | |
8747 | } | |
8748 | ||
8749 | return 0; | |
8750 | } | |
8751 | ||
0717ddc1 | 8752 | //======================================================================= |
8753 | //function : VXRotate | |
8754 | //purpose : | |
8755 | //======================================================================= | |
8756 | static Standard_Integer VXRotate (Draw_Interpretor& di, | |
8757 | Standard_Integer argc, | |
8758 | const char ** argv) | |
8759 | { | |
8760 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
8761 | if (aContext.IsNull()) | |
8762 | { | |
8763 | di << argv[0] << "ERROR : use 'vinit' command before " << "\n"; | |
8764 | return 1; | |
8765 | } | |
8766 | ||
8767 | if (argc != 3) | |
8768 | { | |
8769 | di << "ERROR : Usage : " << argv[0] << " name angle" << "\n"; | |
8770 | return 1; | |
8771 | } | |
8772 | ||
8773 | TCollection_AsciiString aName (argv[1]); | |
8774 | Standard_Real anAngle = Draw::Atof (argv[2]); | |
8775 | ||
8776 | // find object | |
8777 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); | |
8778 | Handle(AIS_InteractiveObject) anIObj; | |
8779 | if (!aMap.IsBound2 (aName) ) | |
8780 | { | |
8781 | di << "Use 'vdisplay' before" << "\n"; | |
8782 | return 1; | |
8783 | } | |
8784 | else | |
8785 | { | |
8786 | anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName)); | |
8787 | ||
8788 | gp_Trsf aTransform; | |
8789 | aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle); | |
8790 | aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart()); | |
8791 | ||
8792 | aContext->SetLocation (anIObj, aTransform); | |
8793 | aContext->UpdateCurrentViewer(); | |
8794 | } | |
8795 | ||
8796 | return 0; | |
8797 | } | |
8798 | ||
7fd59977 | 8799 | //======================================================================= |
8800 | //function : ViewerCommands | |
8801 | //purpose : | |
8802 | //======================================================================= | |
8803 | ||
8804 | void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) | |
8805 | { | |
8806 | ||
8807 | const char *group = "ZeViewer"; | |
18d715bd | 8808 | theCommands.Add("vinit", |
8809 | #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
8810 | "[name=view_name] [display=display_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n" | |
8811 | #else | |
8812 | "[name=view_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n" | |
8813 | #endif | |
8814 | " - Creates new View window with specified name view_name.\n" | |
8815 | "By default the new view is created in the viewer and in" | |
8816 | " graphic driver shared with active view.\n" | |
8817 | " - name = {driverName/viewerName/viewName | viewerName/viewName | viewName}.\n" | |
8818 | "If driverName isn't specified the driver will be shared with active view.\n" | |
8819 | "If viewerName isn't specified the viewer will be shared with active view.\n" | |
8820 | #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) | |
8821 | " - display = HostName.DisplayNumber[:ScreenNumber] : if specified" | |
8822 | "is used in creation of graphic driver\n" | |
8823 | #endif | |
8824 | " - l, t: pixel position of left top corner of the window\n" | |
8825 | " - w,h: width and heigth of window respectively.\n" | |
8826 | "Additional commands for operations with views: vclose, vactivate, vviewlist.\n", | |
7fd59977 | 8827 | __FILE__,VInit,group); |
18d715bd | 8828 | theCommands.Add("vclose" , |
d0cc1cb7 | 8829 | "[view_id [keep_context=0|1]]\n" |
18d715bd | 8830 | "or vclose ALL - to remove all created views\n" |
8831 | " - removes view(viewer window) defined by its view_id.\n" | |
8832 | " - keep_context: by default 0; if 1 and the last view is deleted" | |
8833 | " the current context is not removed.", | |
8834 | __FILE__,VClose,group); | |
8835 | theCommands.Add("vactivate" , | |
8836 | "view_id" | |
8837 | " - activates view(viewer window) defined by its view_id", | |
8838 | __FILE__,VActivate,group); | |
8839 | theCommands.Add("vviewlist", | |
8840 | "vviewlist [format={tree, long}]" | |
8841 | " - prints current list of views per viewer and graphic_driver ID shared between viewers" | |
8842 | " - format: format of result output, if tree the output is a tree view;" | |
8843 | "otherwise it's a list of full view names. By default format = tree", | |
8844 | __FILE__,VViewList,group); | |
7fd59977 | 8845 | theCommands.Add("vhelp" , |
8846 | "vhelp : display help on the viewer commands", | |
8847 | __FILE__,VHelp,group); | |
8848 | theCommands.Add("vtop" , | |
44b8f2d6 | 8849 | "vtop or <T> : Top view" , |
7fd59977 | 8850 | __FILE__,VTop,group); |
44b8f2d6 | 8851 | theCommands.Add("vbottom" , |
8852 | "vbottom : Bottom view" , | |
8853 | __FILE__,VBottom,group); | |
8854 | theCommands.Add("vleft" , | |
8855 | "vleft : Left view" , | |
8856 | __FILE__,VLeft,group); | |
8857 | theCommands.Add("vright" , | |
8858 | "vright : Right view" , | |
8859 | __FILE__,VRight,group); | |
7fd59977 | 8860 | theCommands.Add("vaxo" , |
8861 | " vaxo or <A> : Axonometric view ", | |
8862 | __FILE__,VAxo,group); | |
44b8f2d6 | 8863 | theCommands.Add("vfront" , |
8864 | "vfront : Front view" , | |
8865 | __FILE__,VFront,group); | |
8866 | theCommands.Add("vback" , | |
8867 | "vback : Back view" , | |
8868 | __FILE__,VBack,group); | |
7fd59977 | 8869 | theCommands.Add("vpick" , |
8870 | "vpick : vpick X Y Z [shape subshape] ( all variables as string )", | |
8871 | VPick,group); | |
8872 | theCommands.Add("vfit" , | |
b586500b | 8873 | "vfit or <F> [-selected]" |
8874 | "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects", | |
7fd59977 | 8875 | __FILE__,VFit,group); |
6262a303 | 8876 | theCommands.Add ("vfitarea", |
8877 | "vfitarea x1 y1 x2 y2" | |
8878 | "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2" | |
8879 | "\n\t\t: Fit view to show area located between two points" | |
8880 | "\n\t\t: given in world 2D or 3D corrdinates.", | |
8881 | __FILE__, VFitArea, group); | |
197ac94e | 8882 | theCommands.Add ("vzfit", "vzfit [scale]\n" |
8883 | " Matches Z near, Z far view volume planes to the displayed objects.\n" | |
8884 | " \"scale\" - specifies factor to scale computed z range.\n", | |
8885 | __FILE__, VZFit, group); | |
7fd59977 | 8886 | theCommands.Add("vrepaint", |
8887 | "vrepaint : vrepaint, force redraw", | |
8888 | __FILE__,VRepaint,group); | |
8889 | theCommands.Add("vclear", | |
8890 | "vclear : vclear", | |
8891 | __FILE__,VClear,group); | |
8892 | theCommands.Add("vsetbg", | |
8893 | "vsetbg : vsetbg imagefile [filltype] : Load image as background", | |
8894 | __FILE__,VSetBg,group); | |
f8b2ed36 | 8895 | theCommands.Add("vsetbgmode", |
8896 | "vsetbgmode : vsetbgmode filltype : Change background image fill type", | |
8897 | __FILE__,VSetBgMode,group); | |
7fd59977 | 8898 | theCommands.Add("vsetgradientbg", |
f8b2ed36 | 8899 | "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background", |
7fd59977 | 8900 | __FILE__,VSetGradientBg,group); |
f8b2ed36 | 8901 | theCommands.Add("vsetgrbgmode", |
8902 | "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type", | |
8903 | __FILE__,VSetGradientBgMode,group); | |
8904 | theCommands.Add("vsetcolorbg", | |
8905 | "vsetcolorbg : vsetcolorbg r g b : Set background color", | |
8906 | __FILE__,VSetColorBg,group); | |
7fd59977 | 8907 | theCommands.Add("vscale", |
8908 | "vscale : vscale X Y Z", | |
8909 | __FILE__,VScale,group); | |
8910 | theCommands.Add("vzbufftrihedron", | |
536d98e2 | 8911 | "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]" |
8912 | "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]" | |
8913 | "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]" | |
8914 | "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]" | |
8915 | "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]" | |
8916 | "\n\t\t: Displays a trihedron", | |
8917 | __FILE__,VZBuffTrihedron,group); | |
7fd59977 | 8918 | theCommands.Add("vrotate", |
4af098ba | 8919 | "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]" |
8920 | "\n : Option -mouseStart starts rotation according to the mouse position" | |
8921 | "\n : Option -mouseMove continues rotation with angle computed" | |
8922 | "\n : from last and new mouse position." | |
8923 | "\n : vrotate AX AY AZ [X Y Z]", | |
7fd59977 | 8924 | __FILE__,VRotate,group); |
8925 | theCommands.Add("vzoom", | |
8926 | "vzoom : vzoom coef", | |
8927 | __FILE__,VZoom,group); | |
8928 | theCommands.Add("vpan", | |
8929 | "vpan : vpan dx dy", | |
8930 | __FILE__,VPan,group); | |
8931 | theCommands.Add("vexport", | |
5cedc27f K |
8932 | "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }" |
8933 | " : exports the view to a vector file of a given format" | |
8934 | " : notice that EMF format requires patched gl2ps", | |
7fd59977 | 8935 | __FILE__,VExport,group); |
8936 | theCommands.Add("vcolorscale", | |
71215351 | 8937 | "vcolorscale : vcolorscale [-range RangeMin = 0 RangeMax = 100 Intervals = 10 -font HeightFont = 16 -textpos " |
8938 | "Position = left -xy X = 0 Y = 0] [-noupdate|-update]: draw color scale\n" | |
8939 | "-demo/-demoversion draw a demoversion of color scale.\n" | |
8940 | "-show/display display color scale.\n" | |
8941 | "-hide/erase erase color scale.\n" | |
8942 | "Please note that -show/-hide option must be the first argument!\n" | |
8943 | "-color Index R G B: set color for indexed interval\n" | |
8944 | "-color Index ColorName: set color for indexed interval\n" | |
8945 | "-colors R G B R G B ...: set colors for all intervals\n" | |
8946 | "-colors ColorName1 ColorName2 ...: set colors for all intervals\n" | |
8947 | "-colors supports both color names and rgb values in one call\n" | |
8948 | "-label Index Text: set label for indexed interval\n" | |
8949 | "-labels Text Text Text ...: set labels for all intervals\n" | |
8950 | "-title Title [Position]: set the title for color scale with certain position. Default position = center;\n" | |
8951 | "Available text positions: left, right, center, none;\n", | |
7fd59977 | 8952 | __FILE__,VColorScale,group); |
8953 | theCommands.Add("vgraduatedtrihedron", | |
a79f67f8 | 8954 | "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n" |
8955 | "\t[-namefont Name] [-valuesfont Name]\n" | |
8956 | "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n" | |
8957 | "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]" | |
8958 | "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n" | |
8959 | "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n" | |
8960 | "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]" | |
8961 | "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n" | |
8962 | "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n" | |
8963 | "\t[-xticks Number] [-yticks Number] [-zticks Number]\n" | |
8964 | "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n" | |
536d98e2 | 8965 | "\t[-drawgrid on/off] [-drawaxes on/off]\n" |
a79f67f8 | 8966 | " - Displays or erases graduated trihedron" |
8967 | " - xname, yname, zname - names of axes, default: X, Y, Z\n" | |
8968 | " - namefont - font of axes names. Default: Arial\n" | |
8969 | " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n" | |
8970 | " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n" | |
8971 | " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n" | |
8972 | " - valuesfont - font of axes values. Default: Arial\n" | |
8973 | " - xcolor, ycolor, zcolor - color of axis and values\n" | |
8974 | " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n" | |
8975 | " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n", | |
7fd59977 | 8976 | __FILE__,VGraduatedTrihedron,group); |
7edf74fd | 8977 | theCommands.Add("vprintview" , |
b5ac8292 | 8978 | "vprintview : width height filename [algo=0] [tile_width tile_height] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile", |
7edf74fd | 8979 | __FILE__,VPrintView,group); |
59f45b7c | 8980 | theCommands.Add("vzlayer", |
c5751993 | 8981 | "vzlayer add/del/get/settings/enable/disable [id]\n" |
8982 | " add - add new z layer to viewer and print its id\n" | |
8983 | " del - del z layer by its id\n" | |
8984 | " get - print sequence of z layers in increasing order of their overlay level\n" | |
8985 | " settings - print status of z layer settings\n" | |
8986 | " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n" | |
8987 | " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n" | |
8988 | " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n" | |
8989 | "\nWhere id is the layer identificator\n" | |
8990 | "\nExamples:\n" | |
8991 | " vzlayer add\n" | |
8992 | " vzlayer enable poffset 1\n" | |
8993 | " vzlayer disable depthtest 1\n" | |
8994 | " vzlayer del 1\n", | |
59f45b7c | 8995 | __FILE__,VZLayer,group); |
25289ec1 | 8996 | theCommands.Add("voverlaytext", |
8997 | "voverlaytext : text x y [height] [font_name] [text_color: R G B] [display_type] [background_color: R G B]" | |
8998 | " : height - pixel height of the text (default=10.0)" | |
8999 | " : font_name - name of font (default=courier)" | |
9000 | " : text_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0) " | |
9001 | " : display_type = {normal/subtitle/decal/blend}, (default=normal) " | |
9002 | " : background_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0), the parameter is defined for subtitle and decal display types ", | |
9003 | __FILE__,VOverlayText,group); | |
20637bd2 | 9004 | theCommands.Add("vlayerline", |
9005 | "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]", | |
9006 | __FILE__,VLayerLine,group); | |
2bd4c032 | 9007 | theCommands.Add ("vgrid", |
9008 | "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]" | |
9009 | " : Mode - rectangular or circular" | |
9010 | " : Type - lines or points", | |
9011 | __FILE__, VGrid, group); | |
c40b7d58 | 9012 | theCommands.Add ("vpriviledgedplane", |
9013 | "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]" | |
9014 | "\n\t\t: Ox, Oy, Oz - plane origin" | |
9015 | "\n\t\t: Nx, Ny, Nz - plane normal direction" | |
9016 | "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction" | |
9017 | "\n\t\t: Sets or prints viewer's priviledged plane geometry.", | |
9018 | __FILE__, VPriviledgedPlane, group); | |
f25b82d6 | 9019 | theCommands.Add ("vconvert", |
9020 | "vconvert v [Mode={window|view}]" | |
9021 | "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]" | |
9022 | "\n\t\t: vconvert x y z [Mode={window|grid}]" | |
9023 | "\n\t\t: window - convert to window coordinates, pixels" | |
9024 | "\n\t\t: view - convert to view projection plane" | |
9025 | "\n\t\t: grid - convert to model coordinates, given on grid" | |
9026 | "\n\t\t: ray - convert projection ray to model coordiantes" | |
9027 | "\n\t\t: - vconvert v window : convert view to window;" | |
9028 | "\n\t\t: - vconvert v view : convert window to view;" | |
9029 | "\n\t\t: - vconvert x y window : convert view to window;" | |
9030 | "\n\t\t: - vconvert x y view : convert window to view;" | |
9031 | "\n\t\t: - vconvert x y : convert window to model;" | |
9032 | "\n\t\t: - vconvert x y grid : convert window to model using grid;" | |
9033 | "\n\t\t: - vconvert x y ray : convert window projection line to model;" | |
9034 | "\n\t\t: - vconvert x y z window : convert model to window;" | |
9035 | "\n\t\t: - vconvert x y z grid : convert view to model using grid;" | |
9036 | "\n\t\t: Converts the given coordinates to window/view/model space.", | |
9037 | __FILE__, VConvert, group); | |
208e6839 | 9038 | theCommands.Add ("vfps", |
9039 | "vfps [framesNb=100] : estimate average frame rate for active view", | |
9040 | __FILE__, VFps, group); | |
58655684 | 9041 | theCommands.Add ("vgldebug", |
c87535af | 9042 | "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]" |
9043 | "\n\t\t: [-extraMsg {0|1}] [{0|1}]" | |
9044 | "\n\t\t: Request debug GL context. Should be called BEFORE vinit." | |
9045 | "\n\t\t: Debug context can be requested only on Windows" | |
9046 | "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!" | |
9047 | "\n\t\t: -sync - request synchronized debug GL context" | |
9048 | "\n\t\t: -glslWarn - log GLSL compiler/linker warnings," | |
9049 | "\n\t\t: which are suppressed by default," | |
9050 | "\n\t\t: -extraMsg - log extra diagnostic messages from GL context," | |
9051 | "\n\t\t: which are suppressed by default", | |
58655684 | 9052 | __FILE__, VGlDebug, group); |
208e6839 | 9053 | theCommands.Add ("vvbo", |
58655684 | 9054 | "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects", |
208e6839 | 9055 | __FILE__, VVbo, group); |
b5ac8292 | 9056 | theCommands.Add ("vstereo", |
f978241f | 9057 | "vstereo [0|1] [-mode Mode] [-reverse {0|1}]" |
9058 | "\n\t\t: [-anaglyph Filter]" | |
9059 | "\n\t\t: Control stereo output mode. Available modes for -mode:" | |
9060 | "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo," | |
9061 | "\n\t\t: requires driver support." | |
9062 | "\n\t\t: Should be called BEFORE vinit!" | |
9063 | "\n\t\t: anaglyph - Anaglyph glasses" | |
9064 | "\n\t\t: rowInterlaced - row-interlaced display" | |
9065 | "\n\t\t: columnInterlaced - column-interlaced display" | |
9066 | "\n\t\t: chessBoard - chess-board output" | |
9067 | "\n\t\t: sideBySide - horizontal pair" | |
9068 | "\n\t\t: overUnder - vertical pair" | |
9069 | "\n\t\t: Available Anaglyph filters for -anaglyph:" | |
9070 | "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple," | |
9071 | "\n\t\t: greenMagentaSimple", | |
b5ac8292 | 9072 | __FILE__, VStereo, group); |
a577aaab | 9073 | theCommands.Add ("vcaps", |
8625ef7e | 9074 | "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]" |
4e1523ef | 9075 | "\n\t\t: [-compatibleContext {0|1}]" |
f978241f | 9076 | "\n\t\t: [-vsync {0|1}]" |
9077 | "\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]" | |
8625ef7e | 9078 | "\n\t\t: [-softMode {0|1}] [-noupdate|-update]" |
9079 | "\n\t\t: Modify particular graphic driver options:" | |
9080 | "\n\t\t: FFP - use fixed-function pipeline instead of" | |
9081 | "\n\t\t: built-in GLSL programs" | |
4e1523ef | 9082 | "\n\t\t: (requires compatible profile)" |
8625ef7e | 9083 | "\n\t\t: VBO - use Vertex Buffer Object (copy vertex" |
9084 | "\n\t\t: arrays to GPU memory)" | |
9085 | "\n\t\t: sprite - use textured sprites instead of bitmaps" | |
f978241f | 9086 | "\n\t\t: vsync - switch VSync on or off" |
4e1523ef | 9087 | "\n\t\t: Context creation options:" |
9088 | "\n\t\t: softMode - software OpenGL implementation" | |
9089 | "\n\t\t: compatibleProfile - backward-compatible profile" | |
f978241f | 9090 | "\n\t\t: quadbuffer - QuadBuffer" |
8625ef7e | 9091 | "\n\t\t: Unlike vrenderparams, these parameters control alternative" |
9092 | "\n\t\t: rendering paths producing the same visual result when" | |
9093 | "\n\t\t: possible." | |
9094 | "\n\t\t: Command is intended for testing old hardware compatibility.", | |
a577aaab | 9095 | __FILE__, VCaps, group); |
f0430952 | 9096 | theCommands.Add ("vmemgpu", |
9097 | "vmemgpu [f]: print system-dependent GPU memory information if available;" | |
9098 | " with f option returns free memory in bytes", | |
9099 | __FILE__, VMemGpu, group); | |
85e096c3 | 9100 | theCommands.Add ("vreadpixel", |
9101 | "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]" | |
9102 | " : Read pixel value for active view", | |
9103 | __FILE__, VReadPixel, group); | |
692613e5 | 9104 | theCommands.Add("diffimage", |
9105 | "diffimage : diffimage imageFile1 imageFile2 toleranceOfColor(0..1) blackWhite(1|0) borderFilter(1|0) [diffImageFile]", | |
9106 | __FILE__, VDiffImage, group); | |
4754e164 | 9107 | theCommands.Add ("vselect", |
2157d6ac | 9108 | "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n" |
4754e164 | 9109 | "- emulates different types of selection:\n" |
9110 | "- 1) single click selection\n" | |
9111 | "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n" | |
9112 | "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n" | |
2157d6ac | 9113 | "- 4) -allowoverlap determines will partially included objects be selected in rectangular selection" |
9114 | " (partial inclusion - overlap - is not allowed by default)\n" | |
9115 | "- 5) any of these selections with shift button pressed", | |
4754e164 | 9116 | __FILE__, VSelect, group); |
9117 | theCommands.Add ("vmoveto", | |
9118 | "vmoveto x y" | |
9119 | "- emulates cursor movement to pixel postion (x,y)", | |
9120 | __FILE__, VMoveTo, group); | |
197ac94e | 9121 | theCommands.Add ("vviewparams", "vviewparams usage:\n" |
9122 | "- vviewparams\n" | |
9123 | "- vviewparams [-scale [s]] [-eye [x y z]] [-at [x y z]] [-up [x y z]]\n" | |
3dfe95cd | 9124 | " [-proj [x y z]] [-center x y] [-size sx]\n" |
197ac94e | 9125 | "- Gets or sets current view parameters.\n" |
9126 | "- If called without arguments, all view parameters are printed.\n" | |
9127 | "- The options are:\n" | |
3dfe95cd | 9128 | " -scale [s] : prints or sets viewport relative scale.\n" |
197ac94e | 9129 | " -eye [x y z] : prints or sets eye location.\n" |
9130 | " -at [x y z] : prints or sets center of look.\n" | |
9131 | " -up [x y z] : prints or sets direction of up vector.\n" | |
9132 | " -proj [x y z] : prints or sets direction of look.\n" | |
3dfe95cd | 9133 | " -center x y : sets location of center of the screen in pixels.\n" |
9134 | " -size [sx] : prints viewport projection width and height sizes\n" | |
9135 | " : or changes the size of its maximum dimension.\n", | |
197ac94e | 9136 | __FILE__, VViewParams, group); |
4754e164 | 9137 | theCommands.Add("vchangeselected", |
dc3fe572 | 9138 | "vchangeselected shape" |
4754e164 | 9139 | "- adds to shape to selection or remove one from it", |
9140 | __FILE__, VChangeSelected, group); | |
9141 | theCommands.Add("vzclipping", | |
9142 | "vzclipping [mode] [depth width]\n" | |
9143 | "- mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]\n" | |
9144 | "- gets or sets ZClipping mode, width and depth", | |
9145 | __FILE__,VZClipping,group); | |
9146 | theCommands.Add ("vnbselected", | |
9147 | "vnbselected", __FILE__, VNbSelected, group); | |
6b62b2da | 9148 | theCommands.Add ("vcamera", |
9149 | "vcamera [-ortho] [-projtype]" | |
9150 | "\n\t\t: [-persp]" | |
9151 | "\n\t\t: [-fovy [Angle]] [-distance [Distance]]" | |
9152 | "\n\t\t: [-stereo] [-leftEye] [-rightEye]" | |
9153 | "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]" | |
9154 | "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]" | |
9155 | "\n\t\t: Manage camera parameters." | |
9156 | "\n\t\t: Prints current value when option called without argument." | |
9157 | "\n\t\t: Orthographic camera:" | |
9158 | "\n\t\t: -ortho activate orthographic projection" | |
9159 | "\n\t\t: Perspective camera:" | |
9160 | "\n\t\t: -persp activate perspective projection (mono)" | |
9161 | "\n\t\t: -fovy field of view in y axis, in degrees" | |
9162 | "\n\t\t: -distance distance of eye from camera center" | |
9163 | "\n\t\t: Stereoscopic camera:" | |
9164 | "\n\t\t: -stereo perspective projection (stereo)" | |
9165 | "\n\t\t: -leftEye perspective projection (left eye)" | |
9166 | "\n\t\t: -rightEye perspective projection (right eye)" | |
9167 | "\n\t\t: -iod intraocular distance value" | |
9168 | "\n\t\t: -iodType distance type, absolute or relative" | |
9169 | "\n\t\t: -zfocus stereographic focus value" | |
9170 | "\n\t\t: -zfocusType focus type, absolute or relative", | |
9171 | __FILE__, VCamera, group); | |
b5ac8292 | 9172 | theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n" |
197ac94e | 9173 | "- vautozfit [on={1|0}] [scale]\n" |
9174 | " Prints or changes parameters of automatic z-fit mode:\n" | |
9175 | " \"on\" - turns automatic z-fit on or off\n" | |
9176 | " \"scale\" - specifies factor to scale computed z range.\n", | |
9177 | __FILE__, VAutoZFit, group); | |
b5ac8292 | 9178 | theCommands.Add ("vzrange", "command to manually access znear and zfar values\n" |
9179 | " vzrange - without parameters shows current values\n" | |
9180 | " vzrange [znear] [zfar] - applies provided values to view", | |
9181 | __FILE__,VZRange, group); | |
4754e164 | 9182 | theCommands.Add("vantialiasing", |
9183 | "vantialiasing 1|0", | |
9184 | __FILE__,VAntialiasing,group); | |
9185 | theCommands.Add ("vpurgedisplay", | |
eb4320f2 | 9186 | "vpurgedisplay" |
4754e164 | 9187 | "- removes structures which don't belong to objects displayed in neutral point", |
9188 | __FILE__, VPurgeDisplay, group); | |
9189 | theCommands.Add("vsetviewsize", | |
9190 | "vsetviewsize size", | |
9191 | __FILE__,VSetViewSize,group); | |
9192 | theCommands.Add("vmoveview", | |
9193 | "vmoveview Dx Dy Dz [Start = 1|0]", | |
9194 | __FILE__,VMoveView,group); | |
9195 | theCommands.Add("vtranslateview", | |
9196 | "vtranslateview Dx Dy Dz [Start = 1|0)]", | |
9197 | __FILE__,VTranslateView,group); | |
9198 | theCommands.Add("vturnview", | |
9199 | "vturnview Ax Ay Az [Start = 1|0]", | |
9200 | __FILE__,VTurnView,group); | |
269294d6 | 9201 | theCommands.Add("vtextureenv", |
9202 | "Enables or disables environment mapping in the 3D view, loading the texture from the given standard " | |
9203 | "or user-defined file and optionally applying texture mapping parameters\n" | |
9204 | " Usage:\n" | |
9205 | " vtextureenv off - disables environment mapping\n" | |
9206 | " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n" | |
9207 | " std_texture = (0..7)\n" | |
9208 | " rep = {clamp|repeat}\n" | |
9209 | " mod = {decal|modulate}\n" | |
9210 | " flt = {nearest|bilinear|trilinear}\n" | |
9211 | " ss, st - scale factors for s and t texture coordinates\n" | |
9212 | " ts, tt - translation for s and t texture coordinates\n" | |
9213 | " rot - texture rotation angle in degrees", | |
9214 | __FILE__, VTextureEnv, group); | |
0a768f56 | 9215 | theCommands.Add("vhlr" , |
e9224045 | 9216 | "is_enabled={on|off} [show_hidden={1|0}]" |
0a768f56 | 9217 | " - Hidden line removal algorithm:" |
e9224045 | 9218 | " - is_enabled: if is on HLR algorithm is applied\n" |
9219 | " - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n", | |
0a768f56 | 9220 | __FILE__,VHLR,group); |
9221 | theCommands.Add("vhlrtype" , | |
9222 | "algo_type={algo|polyalgo} [shape_1 ... shape_n]" | |
9223 | " - Changes the type of HLR algorithm using for shapes." | |
9224 | " - algo_type: if equals to algo, exact HLR algorithm is applied;\n" | |
9225 | " if equals to polyalgo, polygonal HLR algorithm is applied." | |
9226 | "If shapes are not given HLR algoithm of given type is applied" | |
9227 | " to all shapes in the view\n", | |
9228 | __FILE__,VHLRType,group); | |
4269bd1b | 9229 | theCommands.Add("vclipplane", "vclipplane usage: \n" |
9230 | " maxplanes <view_name> - get plane limit for view.\n" | |
9231 | " create <plane_name> - create new plane.\n" | |
9232 | " delete <plane_name> - delete plane.\n" | |
9233 | " clone <source_plane> <plane_name> - clone the plane definition.\n" | |
9234 | " set/unset <plane_name> object <object list> - set/unset plane for IO.\n" | |
9235 | " set/unset <plane_name> view <view list> - set/unset plane for view.\n" | |
9236 | " change <plane_name> on/off - turn clipping on/off.\n" | |
9237 | " change <plane_name> equation <a> <b> <c> <d> - change plane equation.\n" | |
9238 | " change <plane_name> capping on/off - turn capping on/off.\n" | |
9239 | " change <plane_name> capping color <r> <g> <b> - set color.\n" | |
9240 | " change <plane name> capping texname <texture> - set texture.\n" | |
9241 | " change <plane_name> capping texscale <sx> <sy> - set tex scale.\n" | |
9242 | " change <plane_name> capping texorigin <tx> <ty> - set tex origin.\n" | |
9243 | " change <plane_name> capping texrotate <angle> - set tex rotation.\n" | |
9244 | " change <plane_name> capping hatch on/off/<id> - set hatching mask.\n" | |
9245 | " please use VSetTextureMode command to enable texture rendering in view.\n" | |
9246 | , __FILE__, VClipPlane, group); | |
9247 | theCommands.Add("vsettexturemode", "vsettexturemode view_name mode \n" | |
9248 | " mode can be:\n" | |
9249 | " 0 - no textures enabled in view.\n" | |
9250 | " 1 - only environment textures enabled.\n" | |
9251 | " 2 - all textures enabled.\n" | |
9252 | " this command sets texture details mode for the specified view.\n" | |
9253 | , __FILE__, VSetTextureMode, group); | |
392ac980 | 9254 | theCommands.Add("vdefaults", |
4c513386 | 9255 | "vdefaults [-absDefl value]" |
9256 | "\n\t\t: [-devCoeff value]" | |
9257 | "\n\t\t: [-angDefl value]" | |
9258 | "\n\t\t: [-autoTriang {off/on | 0/1}]" | |
9259 | , __FILE__, VDefaults, group); | |
12381341 | 9260 | theCommands.Add("vlight", |
816d03ee | 9261 | "tool to manage light sources, without arguments shows list of lights." |
9262 | "\n Main commands: " | |
9263 | "\n 'clear' to clear lights" | |
9264 | "\n '{def}aults' to load deafault lights" | |
9265 | "\n 'add' (or 'new') <type> to add any light source" | |
9266 | "\n where <type> is one of {amb}ient|directional|{spot}light|positional" | |
9267 | "\n 'change' <lightId> to edit light source with specified lightId" | |
9268 | "\n\n In addition to 'add' and 'change' commands you can use light parameters:" | |
9269 | "\n {pos}ition X Y Z" | |
9270 | "\n {dir}ection X Y Z (for directional light or for spotlight)" | |
9271 | "\n color colorName" | |
9272 | "\n {head}light 0|1" | |
189f85a3 | 9273 | "\n {sm}oothness value" |
9274 | "\n {int}ensity value" | |
816d03ee | 9275 | "\n {constAtten}uation value" |
9276 | "\n {linearAtten}uation value" | |
9277 | "\n angle angleDeg" | |
9278 | "\n {spotexp}onent value" | |
9279 | "\n local|global" | |
9280 | "\n\n example: vlight add positional head 1 pos 0 1 1 color red" | |
9281 | "\n example: vlight change 0 direction 0 -1 0 linearAttenuation 0.2", | |
12381341 | 9282 | __FILE__, VLight, group); |
6b62b2da | 9283 | theCommands.Add("vraytrace", |
9284 | "vraytrace [0|1]" | |
189f85a3 | 9285 | "\n\t\t: Turns on/off ray-tracing renderer." |
6b62b2da | 9286 | "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'." |
9287 | "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.", | |
9288 | __FILE__, VRenderParams, group); | |
bc8c79bb | 9289 | theCommands.Add("vrenderparams", |
9290 | "\n Manages rendering parameters: " | |
8625ef7e | 9291 | "\n '-rayTrace' Enables GPU ray-tracing" |
9292 | "\n '-raster' Disables GPU ray-tracing" | |
9293 | "\n '-rayDepth 0..10' Defines maximum ray-tracing depth" | |
9294 | "\n '-shadows on|off' Enables/disables shadows rendering" | |
9295 | "\n '-reflections on|off' Enables/disables specular reflections" | |
9296 | "\n '-fsaa on|off' Enables/disables adaptive anti-aliasing" | |
9297 | "\n '-gleam on|off' Enables/disables transparency shadow effects" | |
189f85a3 | 9298 | "\n '-gi on|off' Enables/disables global illumination effects" |
9299 | "\n '-env on|off' Enables/disables environment map background" | |
8625ef7e | 9300 | "\n '-shadingModel model' Controls shading model from enumeration" |
9301 | "\n color, flat, gouraud, phong" | |
9302 | "\n Unlike vcaps, these parameters dramatically change visual properties." | |
9303 | "\n Command is intended to control presentation quality depending on" | |
9304 | "\n hardware capabilities and performance.", | |
bc8c79bb | 9305 | __FILE__, VRenderParams, group); |
b7cd4ba7 | 9306 | theCommands.Add("vfrustumculling", |
9307 | "vfrustumculling [toEnable]: enables/disables objects clipping", | |
9308 | __FILE__,VFrustumCulling,group); | |
c398b00e | 9309 | theCommands.Add("vhighlightselected", |
9310 | "vhighlightselected [0|1] or vhighlightselected [on|off]: enables/disables highlighting of selected objects.\n" | |
9311 | "Without arguments it shows if highlighting of selected objects is enabled now.", | |
9312 | __FILE__,VHighlightSelected,group); | |
49e1a5c7 | 9313 | theCommands.Add ("vplace", |
9314 | "vplace dx dy" | |
9315 | "\n\t\t: Places the point (in pixels) at the center of the window", | |
9316 | __FILE__, VPlace, group); | |
0717ddc1 | 9317 | theCommands.Add("vxrotate", |
9318 | "vxrotate", | |
9319 | __FILE__,VXRotate,group); | |
9320 | ||
189f85a3 | 9321 | #if defined(_WIN32) |
9322 | theCommands.Add("vprogressive", | |
9323 | "vprogressive", | |
9324 | __FILE__, VProgressiveMode, group); | |
9325 | #endif | |
7fd59977 | 9326 | } |