1 // Created on: 1998-09-01
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <OpenGl_GlCore20.hxx>
19 #include <AIS_Animation.hxx>
20 #include <AIS_AnimationCamera.hxx>
21 #include <AIS_AnimationObject.hxx>
22 #include <AIS_ColorScale.hxx>
23 #include <AIS_Manipulator.hxx>
24 #include <AIS_RubberBand.hxx>
25 #include <AIS_Shape.hxx>
26 #include <AIS_InteractiveObject.hxx>
27 #include <AIS_ListOfInteractive.hxx>
28 #include <AIS_ListIteratorOfListOfInteractive.hxx>
30 #include <Graphic3d_ArrayOfPolylines.hxx>
31 #include <Graphic3d_AspectMarker3d.hxx>
32 #include <Graphic3d_ExportFormat.hxx>
33 #include <Graphic3d_NameOfTextureEnv.hxx>
34 #include <Graphic3d_GraduatedTrihedron.hxx>
35 #include <Graphic3d_TextureEnv.hxx>
36 #include <Graphic3d_TextureParams.hxx>
37 #include <Graphic3d_TypeOfTextureFilter.hxx>
38 #include <Graphic3d_AspectFillArea3d.hxx>
39 #include <ViewerTest.hxx>
40 #include <ViewerTest_AutoUpdater.hxx>
41 #include <ViewerTest_EventManager.hxx>
42 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
43 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
44 #include <ViewerTest_CmdParser.hxx>
45 #include <V3d_AmbientLight.hxx>
46 #include <V3d_DirectionalLight.hxx>
47 #include <V3d_PositionalLight.hxx>
48 #include <V3d_SpotLight.hxx>
49 #include <NCollection_DoubleMap.hxx>
50 #include <NCollection_List.hxx>
51 #include <NCollection_Vector.hxx>
52 #include <AIS_InteractiveContext.hxx>
53 #include <Draw_Interpretor.hxx>
55 #include <Draw_Appli.hxx>
56 #include <Image_AlienPixMap.hxx>
57 #include <OpenGl_GraphicDriver.hxx>
58 #include <OSD_Timer.hxx>
59 #include <TColStd_HSequenceOfAsciiString.hxx>
60 #include <TColStd_SequenceOfInteger.hxx>
61 #include <TColStd_HSequenceOfReal.hxx>
62 #include <TColgp_Array1OfPnt2d.hxx>
63 #include <TColStd_MapOfAsciiString.hxx>
64 #include <Aspect_TypeOfLine.hxx>
65 #include <Image_Diff.hxx>
66 #include <Aspect_DisplayConnection.hxx>
70 #include <PrsMgr_PresentableObject.hxx>
71 #include <Graphic3d_ClipPlane.hxx>
72 #include <NCollection_DataMap.hxx>
73 #include <Graphic3d_Texture2Dmanual.hxx>
74 #include <Prs3d_ShadingAspect.hxx>
75 #include <Prs3d_Drawer.hxx>
76 #include <Prs3d_LineAspect.hxx>
77 #include <Prs3d_Root.hxx>
86 #include <WNT_WClass.hxx>
87 #include <WNT_Window.hxx>
88 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
89 #include <Cocoa_Window.hxx>
91 #include <Xw_Window.hxx>
92 #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
93 #include <X11/Xutil.h>
97 // Auxiliary definitions
98 static const char THE_KEY_DELETE = 127;
100 //==============================================================================
101 // VIEWER GLOBAL VARIABLES
102 //==============================================================================
104 Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
105 Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
107 Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
108 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
110 extern int VErase (Draw_Interpretor& theDI,
111 Standard_Integer theArgNb,
112 const char** theArgVec);
115 static Handle(WNT_Window)& VT_GetWindow() {
116 static Handle(WNT_Window) WNTWin;
119 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
120 static Handle(Cocoa_Window)& VT_GetWindow()
122 static Handle(Cocoa_Window) aWindow;
125 extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow);
126 extern void SetCocoaWindowTitle (const Handle(Cocoa_Window)& theWindow, Standard_CString theTitle);
127 extern void GetCocoaScreenResolution (Standard_Integer& theWidth, Standard_Integer& theHeight);
130 static Handle(Xw_Window)& VT_GetWindow(){
131 static Handle(Xw_Window) XWWin;
135 static void VProcessEvents(ClientData,int);
138 static Handle(Aspect_DisplayConnection)& GetDisplayConnection()
140 static Handle(Aspect_DisplayConnection) aDisplayConnection;
141 return aDisplayConnection;
144 static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
146 GetDisplayConnection() = theDisplayConnection;
149 #if defined(_WIN32) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
150 Aspect_Handle GetWindowHandle(const Handle(Aspect_Window)& theWindow)
152 Aspect_Handle aWindowHandle = (Aspect_Handle)NULL;
154 const Handle (WNT_Window) aWindow = Handle(WNT_Window)::DownCast (theWindow);
155 if (!aWindow.IsNull())
156 return aWindow->HWindow();
157 #elif (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
158 const Handle (Xw_Window) aWindow = Handle(Xw_Window)::DownCast (theWindow);
159 if (!aWindow.IsNull())
160 return aWindow->XWindow();
162 return aWindowHandle;
166 static Standard_Boolean MyHLRIsOn = Standard_False;
168 NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
169 static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts;
170 static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers;
171 static OpenGl_Caps ViewerTest_myDefaultCaps;
173 static void OSWindowSetup();
177 Quantity_Color FlatColor;
178 Quantity_Color GradientColor1;
179 Quantity_Color GradientColor2;
180 Aspect_GradientFillMethod FillMethod;
181 } ViewerTest_DefaultBackground = { Quantity_NOC_BLACK, Quantity_NOC_BLACK, Quantity_NOC_BLACK, Aspect_GFM_NONE };
183 //==============================================================================
184 // EVENT GLOBAL VARIABLES
185 //==============================================================================
187 static int Start_Rot = 0;
188 int X_Motion = 0; // Current cursor position
190 int X_ButtonPress = 0; // Last ButtonPress position
191 int Y_ButtonPress = 0;
192 Standard_Boolean IsDragged = Standard_False;
193 Standard_Boolean DragFirst = Standard_False;
194 Standard_Boolean TheIsAnimating = Standard_False;
197 Standard_EXPORT const Handle(AIS_RubberBand)& GetRubberBand()
199 static Handle(AIS_RubberBand) aBand;
202 aBand = new AIS_RubberBand (Quantity_NOC_LIGHTBLUE, Aspect_TOL_SOLID, Quantity_NOC_LIGHTBLUE, 0.4, 1.0);
203 aBand->SetDisplayMode (0);
208 typedef NCollection_Map<AIS_Manipulator*> ViewerTest_MapOfAISManipulators;
210 Standard_EXPORT ViewerTest_MapOfAISManipulators& GetMapOfAISManipulators()
212 static ViewerTest_MapOfAISManipulators aMap;
216 Standard_EXPORT Handle(AIS_Manipulator) GetActiveAISManipulator()
218 ViewerTest_MapOfAISManipulators::Iterator anIt (GetMapOfAISManipulators());
219 for (; anIt.More(); anIt.Next())
221 if (anIt.Value()->HasActiveMode())
229 //==============================================================================
232 static LRESULT WINAPI ViewerWindowProc(
237 static LRESULT WINAPI AdvViewerWindowProc(
245 //==============================================================================
248 //==============================================================================
250 const Handle(Standard_Transient)& ViewerTest::WClass()
252 static Handle(Standard_Transient) theWClass;
254 if (theWClass.IsNull())
256 theWClass = new WNT_WClass ("GW3D_Class", (Standard_Address )AdvViewerWindowProc,
257 CS_VREDRAW | CS_HREDRAW, 0, 0,
258 ::LoadCursorW (NULL, IDC_ARROW));
264 //==============================================================================
265 //function : CreateName
266 //purpose : Create numerical name for new object in theMap
267 //==============================================================================
268 template <typename ObjectType>
269 TCollection_AsciiString CreateName (const NCollection_DoubleMap <TCollection_AsciiString, ObjectType>& theObjectMap,
270 const TCollection_AsciiString& theDefaultString)
272 if (theObjectMap.IsEmpty())
273 return theDefaultString + TCollection_AsciiString(1);
275 Standard_Integer aNextKey = 1;
276 Standard_Boolean isFound = Standard_False;
279 TCollection_AsciiString aStringKey = theDefaultString + TCollection_AsciiString(aNextKey);
280 // Look for objects with default names
281 if (theObjectMap.IsBound1(aStringKey))
286 isFound = Standard_True;
289 return theDefaultString + TCollection_AsciiString(aNextKey);
292 //==============================================================================
293 //structure : ViewerTest_Names
294 //purpose : Allow to operate with full view name: driverName/viewerName/viewName
295 //==============================================================================
296 struct ViewerTest_Names
299 TCollection_AsciiString myDriverName;
300 TCollection_AsciiString myViewerName;
301 TCollection_AsciiString myViewName;
305 const TCollection_AsciiString& GetDriverName () const
309 void SetDriverName (const TCollection_AsciiString& theDriverName)
311 myDriverName = theDriverName;
313 const TCollection_AsciiString& GetViewerName () const
317 void SetViewerName (const TCollection_AsciiString& theViewerName)
319 myViewerName = theViewerName;
321 const TCollection_AsciiString& GetViewName () const
325 void SetViewName (const TCollection_AsciiString& theViewName)
327 myViewName = theViewName;
330 //===========================================================================
331 //function : Constructor for ViewerTest_Names
332 //purpose : Get view, viewer, driver names from custom string
333 //===========================================================================
335 ViewerTest_Names (const TCollection_AsciiString& theInputString)
337 TCollection_AsciiString aName(theInputString);
338 if (theInputString.IsEmpty())
340 // Get current configuration
341 if (ViewerTest_myDrivers.IsEmpty())
342 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
343 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
345 myDriverName = ViewerTest_myDrivers.Find2
346 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
348 if(ViewerTest_myContexts.IsEmpty())
350 myViewerName = CreateName <Handle(AIS_InteractiveContext)>
351 (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer"));
355 myViewerName = ViewerTest_myContexts.Find2 (ViewerTest::GetAISContext());
358 myViewName = CreateName <Handle(V3d_View)> (ViewerTest_myViews, TCollection_AsciiString(myViewerName + "/View"));
362 // There is at least view name
363 Standard_Integer aParserNumber = 0;
364 for (Standard_Integer i = 0; i < 3; ++i)
366 Standard_Integer aParserPos = aName.SearchFromEnd("/");
370 aName.Split(aParserPos-1);
375 if (aParserNumber == 0)
378 if (!ViewerTest::GetAISContext().IsNull())
380 myDriverName = ViewerTest_myDrivers.Find2
381 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
382 myViewerName = ViewerTest_myContexts.Find2
383 (ViewerTest::GetAISContext());
387 // There is no opened contexts here, need to create names for viewer and driver
388 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
389 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
391 myViewerName = CreateName <Handle(AIS_InteractiveContext)>
392 (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer"));
394 myViewName = TCollection_AsciiString(myViewerName + "/" + theInputString);
396 else if (aParserNumber == 1)
398 // Here is viewerName/viewName
399 if (!ViewerTest::GetAISContext().IsNull())
400 myDriverName = ViewerTest_myDrivers.Find2
401 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
404 // There is no opened contexts here, need to create name for driver
405 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
406 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
408 myViewerName = TCollection_AsciiString(myDriverName + "/" + aName);
410 myViewName = TCollection_AsciiString(myDriverName + "/" + theInputString);
414 //Here is driverName/viewerName/viewName
415 myDriverName = TCollection_AsciiString(aName);
417 TCollection_AsciiString aViewerName(theInputString);
418 aViewerName.Split(aViewerName.SearchFromEnd("/") - 1);
419 myViewerName = TCollection_AsciiString(aViewerName);
421 myViewName = TCollection_AsciiString(theInputString);
427 //==============================================================================
428 //function : FindContextByView
429 //purpose : Find AIS_InteractiveContext by View
430 //==============================================================================
432 Handle(AIS_InteractiveContext) FindContextByView (const Handle(V3d_View)& theView)
434 Handle(AIS_InteractiveContext) anAISContext;
436 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
437 anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
439 if (anIter.Value()->CurrentViewer() == theView->Viewer())
440 return anIter.Key2();
446 //==============================================================================
447 //function : SetWindowTitle
448 //purpose : Set window title
449 //==============================================================================
451 void SetWindowTitle (const Handle(Aspect_Window)& theWindow,
452 Standard_CString theTitle)
455 const TCollection_ExtendedString theTitleW (theTitle);
456 SetWindowTextW ((HWND )Handle(WNT_Window)::DownCast(theWindow)->HWindow(), theTitleW.ToWideString());
457 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
458 SetCocoaWindowTitle (Handle(Cocoa_Window)::DownCast(theWindow), theTitle);
460 if(GetDisplayConnection()->GetDisplay())
463 Handle(Xw_Window)::DownCast(theWindow)->XWindow();
464 XStoreName (GetDisplayConnection()->GetDisplay(), aWindow , theTitle);
469 //==============================================================================
470 //function : IsWindowOverlapped
471 //purpose : Check if theWindow overlapp another view
472 //==============================================================================
474 Standard_Boolean IsWindowOverlapped (const Standard_Integer thePxLeft,
475 const Standard_Integer thePxTop,
476 const Standard_Integer thePxRight,
477 const Standard_Integer thePxBottom,
478 TCollection_AsciiString& theViewId)
480 for(NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
481 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
483 Standard_Integer aTop = 0,
487 anIter.Value()->Window()->Position(aLeft, aTop, aRight, aBottom);
488 if ((thePxLeft >= aLeft && thePxLeft <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
489 (thePxLeft >= aLeft && thePxLeft <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom) ||
490 (thePxRight >= aLeft && thePxRight <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
491 (thePxRight >= aLeft && thePxRight <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom))
493 theViewId = anIter.Key1();
494 return Standard_True;
497 return Standard_False;
500 // Workaround: to create and delete non-orthographic views outside ViewerTest
501 void ViewerTest::RemoveViewName (const TCollection_AsciiString& theName)
503 ViewerTest_myViews.UnBind1 (theName);
506 void ViewerTest::InitViewName (const TCollection_AsciiString& theName,
507 const Handle(V3d_View)& theView)
509 ViewerTest_myViews.Bind (theName, theView);
512 TCollection_AsciiString ViewerTest::GetCurrentViewName ()
514 return ViewerTest_myViews.Find2( ViewerTest::CurrentView());
516 //==============================================================================
517 //function : ViewerInit
518 //purpose : Create the window viewer and initialize all the global variable
519 //==============================================================================
521 TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft,
522 const Standard_Integer thePxTop,
523 const Standard_Integer thePxWidth,
524 const Standard_Integer thePxHeight,
525 Standard_CString theViewName,
526 Standard_CString theDisplayName)
528 // Default position and dimension of the viewer window.
529 // Note that left top corner is set to be sufficiently small to have
530 // window fit in the small screens (actual for remote desktops, see #23003).
531 // The position corresponds to the window's client area, thus some
532 // gap is added for window frame to be visible.
533 Standard_Integer aPxLeft = 20;
534 Standard_Integer aPxTop = 40;
535 Standard_Integer aPxWidth = 409;
536 Standard_Integer aPxHeight = 409;
537 Standard_Boolean toCreateViewer = Standard_False;
539 Handle(OpenGl_GraphicDriver) aGraphicDriver;
540 ViewerTest_Names aViewNames(theViewName);
541 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ()))
542 aViewNames.SetViewName (aViewNames.GetViewerName() + "/" + CreateName<Handle(V3d_View)>(ViewerTest_myViews, "View"));
549 aPxWidth = thePxWidth;
550 if (thePxHeight != 0)
551 aPxHeight = thePxHeight;
553 // Get graphic driver (create it or get from another view)
554 if (!ViewerTest_myDrivers.IsBound1 (aViewNames.GetDriverName()))
556 // Get connection string
557 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
558 TCollection_AsciiString aDisplayName(theDisplayName);
559 if (!aDisplayName.IsEmpty())
560 SetDisplayConnection (new Aspect_DisplayConnection ());
562 SetDisplayConnection (new Aspect_DisplayConnection (aDisplayName));
564 (void)theDisplayName; // avoid warning on unused argument
565 SetDisplayConnection (new Aspect_DisplayConnection ());
568 if (Draw_VirtualWindows)
570 // don't waste the time waiting for VSync when window is not displayed on the screen
571 ViewerTest_myDefaultCaps.swapInterval = 0;
572 // alternatively we can disable buffer swap at all, but this might be inappropriate for testing
573 //ViewerTest_myDefaultCaps.buffersNoSwap = true;
575 aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection());
576 aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
578 ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
579 toCreateViewer = Standard_True;
583 aGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast (ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName()));
586 //Dispose the window if input parameters are default
587 if (!ViewerTest_myViews.IsEmpty() && thePxLeft == 0 && thePxTop == 0)
589 Standard_Integer aTop = 0,
596 // Get screen resolution
597 #if defined(_WIN32) || defined(__WIN32__)
599 GetClientRect(GetDesktopWindow(), &aWindowSize);
600 aScreenHeight = aWindowSize.bottom;
601 aScreenWidth = aWindowSize.right;
602 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
603 GetCocoaScreenResolution (aScreenWidth, aScreenHeight);
605 Screen *aScreen = DefaultScreenOfDisplay(GetDisplayConnection()->GetDisplay());
606 aScreenWidth = WidthOfScreen(aScreen);
607 aScreenHeight = HeightOfScreen(aScreen);
610 TCollection_AsciiString anOverlappedViewId("");
612 while (IsWindowOverlapped (aPxLeft, aPxTop, aPxLeft + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId))
614 ViewerTest_myViews.Find1(anOverlappedViewId)->Window()->Position (aLeft, aTop, aRight, aBottom);
616 if (IsWindowOverlapped (aRight + 20, aPxTop, aRight + 20 + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId)
617 && aRight + 2*aPxWidth + 40 > aScreenWidth)
619 if (aBottom + aPxHeight + 40 > aScreenHeight)
626 aPxTop = aBottom + 40;
629 aPxLeft = aRight + 20;
634 TCollection_AsciiString aTitle("3D View - ");
635 aTitle = aTitle + aViewNames.GetViewName() + "(*)";
637 // Change name of current active window
638 if (!ViewerTest::CurrentView().IsNull())
640 TCollection_AsciiString anActiveWindowTitle("3D View - ");
641 anActiveWindowTitle = anActiveWindowTitle
642 + ViewerTest_myViews.Find2 (ViewerTest::CurrentView());
643 SetWindowTitle (ViewerTest::CurrentView()->Window(), anActiveWindowTitle.ToCString());
647 Handle(V3d_Viewer) a3DViewer;
648 // If it's the single view, we first look for empty context
649 if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty())
651 NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
652 anIter(ViewerTest_myContexts);
654 ViewerTest::SetAISContext (anIter.Value());
655 a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
657 else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))
659 ViewerTest::SetAISContext(ViewerTest_myContexts.Find1(aViewNames.GetViewerName()));
660 a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
662 else if (a3DViewer.IsNull())
664 toCreateViewer = Standard_True;
665 a3DViewer = new V3d_Viewer(aGraphicDriver);
666 a3DViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
667 a3DViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
668 ViewerTest_DefaultBackground.GradientColor2,
669 ViewerTest_DefaultBackground.FillMethod);
673 if (ViewerTest::GetAISContext().IsNull() ||
674 !(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())))
676 Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer);
677 ViewerTest::SetAISContext (aContext);
678 ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext());
682 ViewerTest::ResetEventManager();
687 VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
688 Handle(WNT_WClass)::DownCast (WClass()),
689 Draw_VirtualWindows ? WS_POPUP : WS_OVERLAPPEDWINDOW,
693 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
694 VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(),
696 aPxWidth, aPxHeight);
697 ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
699 VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(),
702 aPxWidth, aPxHeight);
704 VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
707 Handle(V3d_View) aView = a3DViewer->CreateView();
708 aView->SetWindow (VT_GetWindow());
709 ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer);
711 ViewerTest::CurrentView(aView);
712 ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView);
714 // Setup for X11 or NT
717 // Set parameters for V3d_View and V3d_Viewer
718 const Handle (V3d_View) aV3dView = ViewerTest::CurrentView();
719 aV3dView->SetComputedMode(Standard_False);
720 MyHLRIsOn = aV3dView->ComputedMode();
722 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
725 a3DViewer->SetDefaultLights();
726 a3DViewer->SetLightOn();
729 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
730 #if TCL_MAJOR_VERSION < 8
731 Tk_CreateFileHandler((void*)XConnectionNumber(GetDisplayConnection()->GetDisplay()),
732 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
734 Tk_CreateFileHandler(XConnectionNumber(GetDisplayConnection()->GetDisplay()),
735 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
739 VT_GetWindow()->Map();
741 // Set the handle of created view in the event manager
742 ViewerTest::ResetEventManager();
744 ViewerTest::CurrentView()->Redraw();
749 return aViewNames.GetViewName();
752 //==============================================================================
753 //function : RedrawAllViews
754 //purpose : Redraw all created views
755 //==============================================================================
756 void ViewerTest::RedrawAllViews()
758 NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
759 for (; aViewIt.More(); aViewIt.Next())
761 const Handle(V3d_View)& aView = aViewIt.Key2();
766 //==============================================================================
768 //purpose : Create the window viewer and initialize all the global variable
769 // Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event
770 //==============================================================================
772 static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
776 std::cerr << theArgVec[0] << ": incorrect number of command arguments.\n"
777 << "Type help for more information.\n";
781 TCollection_AsciiString aViewName, aDisplayName;
782 Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
783 TCollection_AsciiString aName, aValue;
784 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
786 const TCollection_AsciiString anArg = theArgVec[anArgIt];
787 TCollection_AsciiString anArgCase = anArg;
788 anArgCase.UpperCase();
789 if (ViewerTest::SplitParameter (anArg, aName, aValue))
792 if (aName.IsEqual ("NAME"))
796 else if (aName.IsEqual ("L")
797 || aName.IsEqual ("LEFT"))
799 aPxLeft = aValue.IntegerValue();
801 else if (aName.IsEqual ("T")
802 || aName.IsEqual ("TOP"))
804 aPxTop = aValue.IntegerValue();
806 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
807 else if (aName.IsEqual ("DISP")
808 || aName.IsEqual ("DISPLAY"))
810 aDisplayName = aValue;
813 else if (aName.IsEqual ("W")
814 || aName.IsEqual ("WIDTH"))
816 aPxWidth = aValue.IntegerValue();
818 else if (aName.IsEqual ("H")
819 || aName.IsEqual ("HEIGHT"))
821 aPxHeight = aValue.IntegerValue();
825 std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
828 else if (aViewName.IsEmpty())
834 std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
838 ViewerTest_Names aViewNames (aViewName);
839 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
841 TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName();
842 theDi.Eval (aCommand.ToCString());
846 TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
847 aViewName.ToCString(),
848 aDisplayName.ToCString());
853 //==============================================================================
855 //purpose : hidden lines removal algorithm
856 //draw args: vhlr is_enabled={on|off} [show_hidden={1|0}]
857 //==============================================================================
859 static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
861 if (ViewerTest::CurrentView().IsNull())
863 di << argv[0] << ": Call vinit before this command, please.\n";
869 di << argv[0] << ": Wrong number of command arguments.\n"
870 << "Type help " << argv[0] << " for more information.\n";
874 // Enable or disable HLR mode.
875 Standard_Boolean isHLROn =
876 (!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False;
878 if (isHLROn != MyHLRIsOn)
881 ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn);
884 // Show or hide hidden lines in HLR mode.
885 Standard_Boolean isCurrentShowHidden
886 = ViewerTest::GetAISContext()->DefaultDrawer()->DrawHiddenLine();
888 Standard_Boolean isShowHidden =
889 (argc == 3) ? (atoi(argv[2]) == 1 ? Standard_True : Standard_False)
890 : isCurrentShowHidden;
893 if (isShowHidden != isCurrentShowHidden)
897 ViewerTest::GetAISContext()->DefaultDrawer()->EnableDrawHiddenLine();
901 ViewerTest::GetAISContext()->DefaultDrawer()->DisableDrawHiddenLine();
907 AIS_ListOfInteractive aListOfShapes;
908 ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes);
910 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next())
912 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIter.Value());
917 ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False);
922 ViewerTest::CurrentView()->Update();
926 //==============================================================================
927 //function : VHLRType
928 //purpose : change type of using HLR algorithm
929 //==============================================================================
931 static int VHLRType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
933 if (ViewerTest::CurrentView().IsNull())
935 di << argv[0] << ": Call vinit before this command, please.\n";
941 di << argv[0] << ": Wrong number of command arguments.\n"
942 << "Type help " << argv[0] << " for more information.\n";
946 Prs3d_TypeOfHLR aTypeOfHLR =
947 (!strcasecmp (argv[1], "algo")) ? Prs3d_TOH_Algo : Prs3d_TOH_PolyAlgo;
951 AIS_ListOfInteractive aListOfShapes;
952 ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes);
953 ViewerTest::GetAISContext()->DefaultDrawer()->SetTypeOfHLR(aTypeOfHLR);
954 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
955 anIter.More(); anIter.Next())
957 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
960 if (aShape->TypeOfHLR() != aTypeOfHLR)
961 aShape->SetTypeOfHLR (aTypeOfHLR);
963 ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False);
965 ViewerTest::CurrentView()->Update();
970 for (Standard_Integer i = 2; i < argc; ++i)
972 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
973 TCollection_AsciiString aName (argv[i]);
975 if (!aMap.IsBound2 (aName))
977 di << argv[0] << ": Wrong shape name:" << aName.ToCString() << ".\n";
980 Handle(AIS_Shape) anAISObject =
981 Handle(AIS_Shape)::DownCast (aMap.Find2(aName));
982 if (anAISObject.IsNull())
984 anAISObject->SetTypeOfHLR (aTypeOfHLR);
986 ViewerTest::GetAISContext()->Redisplay (anAISObject, Standard_False);
988 ViewerTest::CurrentView()->Update();
994 //==============================================================================
995 //function : FindViewIdByWindowHandle
996 //purpose : Find theView Id in the map of views by window handle
997 //==============================================================================
998 #if defined(_WIN32) || defined(__WIN32__) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
999 TCollection_AsciiString FindViewIdByWindowHandle(const Aspect_Handle theWindowHandle)
1001 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator
1002 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
1004 Aspect_Handle aWindowHandle = GetWindowHandle(anIter.Value()->Window());
1005 if (aWindowHandle == theWindowHandle)
1006 return anIter.Key1();
1008 return TCollection_AsciiString("");
1012 //==============================================================================
1013 //function : ActivateView
1014 //purpose : Make the view active
1015 //==============================================================================
1017 void ActivateView (const TCollection_AsciiString& theViewName)
1019 const Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
1020 if (!aView.IsNull())
1022 Handle(AIS_InteractiveContext) anAISContext = FindContextByView(aView);
1023 if (!anAISContext.IsNull())
1025 if (!ViewerTest::CurrentView().IsNull())
1027 TCollection_AsciiString aTitle("3D View - ");
1028 aTitle = aTitle + ViewerTest_myViews.Find2 (ViewerTest::CurrentView());
1029 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1032 ViewerTest::CurrentView (aView);
1033 // Update degenerate mode
1034 MyHLRIsOn = ViewerTest::CurrentView()->ComputedMode();
1035 ViewerTest::SetAISContext (anAISContext);
1036 TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - ");
1037 aTitle = aTitle + theViewName + "(*)";
1038 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1039 #if defined(_WIN32) || defined(__WIN32__)
1040 VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window());
1041 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1042 VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window());
1044 VT_GetWindow() = Handle(Xw_Window)::DownCast(ViewerTest::CurrentView()->Window());
1046 SetDisplayConnection(ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
1047 ViewerTest::CurrentView()->Redraw();
1052 //==============================================================================
1053 //function : RemoveView
1055 //==============================================================================
1056 void ViewerTest::RemoveView (const Handle(V3d_View)& theView,
1057 const Standard_Boolean theToRemoveContext)
1059 if (!ViewerTest_myViews.IsBound2 (theView))
1064 const TCollection_AsciiString aViewName = ViewerTest_myViews.Find2 (theView);
1065 RemoveView (aViewName, theToRemoveContext);
1068 //==============================================================================
1069 //function : RemoveView
1070 //purpose : Close and remove view from display, clear maps if neccessary
1071 //==============================================================================
1072 void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const Standard_Boolean isContextRemoved)
1074 if (!ViewerTest_myViews.IsBound1(theViewName))
1076 cout << "Wrong view name\n";
1080 // Activate another view if it's active now
1081 if (ViewerTest_myViews.Find1(theViewName) == ViewerTest::CurrentView())
1083 if (ViewerTest_myViews.Extent() > 1)
1085 TCollection_AsciiString aNewViewName;
1086 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
1087 anIter.More(); anIter.Next())
1089 if (anIter.Key1() != theViewName)
1091 aNewViewName = anIter.Key1();
1095 ActivateView (aNewViewName);
1099 Handle(V3d_View) anEmptyView;
1100 #if defined(_WIN32) || defined(__WIN32__)
1101 Handle(WNT_Window) anEmptyWindow;
1102 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1103 Handle(Cocoa_Window) anEmptyWindow;
1105 Handle(Xw_Window) anEmptyWindow;
1107 VT_GetWindow() = anEmptyWindow;
1108 ViewerTest::CurrentView (anEmptyView);
1109 if (isContextRemoved)
1111 Handle(AIS_InteractiveContext) anEmptyContext;
1112 ViewerTest::SetAISContext(anEmptyContext);
1118 Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
1119 Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
1121 // Remove view resources
1122 ViewerTest_myViews.UnBind1(theViewName);
1123 aView->Window()->Unmap();
1126 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1127 XFlush (GetDisplayConnection()->GetDisplay());
1130 // Keep context opened only if the closed view is last to avoid
1131 // unused empty contexts
1132 if (!aCurrentContext.IsNull())
1134 // Check if there are more difined views in the viewer
1135 aCurrentContext->CurrentViewer()->InitDefinedViews();
1136 if ((isContextRemoved || ViewerTest_myContexts.Size() != 1) && !aCurrentContext->CurrentViewer()->MoreDefinedViews())
1138 // Remove driver if there is no viewers that use it
1139 Standard_Boolean isRemoveDriver = Standard_True;
1140 for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1141 anIter(ViewerTest_myContexts); anIter.More(); anIter.Next())
1143 if (aCurrentContext != anIter.Key2() &&
1144 aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver())
1146 isRemoveDriver = Standard_False;
1151 aCurrentContext->RemoveAll (Standard_False);
1154 ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver());
1155 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1156 #if TCL_MAJOR_VERSION < 8
1157 Tk_DeleteFileHandler((void*)XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
1159 Tk_DeleteFileHandler(XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
1164 ViewerTest_myContexts.UnBind2(aCurrentContext);
1167 cout << "3D View - " << theViewName << " was deleted.\n";
1171 //==============================================================================
1173 //purpose : Remove the view defined by its name
1174 //==============================================================================
1176 static int VClose (Draw_Interpretor& /*theDi*/,
1177 Standard_Integer theArgsNb,
1178 const char** theArgVec)
1180 NCollection_List<TCollection_AsciiString> aViewList;
1183 TCollection_AsciiString anArg (theArgVec[1]);
1185 if (anArg.IsEqual ("ALL")
1186 || anArg.IsEqual ("*"))
1188 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
1189 anIter.More(); anIter.Next())
1191 aViewList.Append (anIter.Key1());
1193 if (aViewList.IsEmpty())
1195 std::cout << "No view to close\n";
1201 ViewerTest_Names aViewName (theArgVec[1]);
1202 if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName()))
1204 std::cerr << "The view with name '" << theArgVec[1] << "' does not exist\n";
1207 aViewList.Append (aViewName.GetViewName());
1212 // close active view
1213 if (ViewerTest::CurrentView().IsNull())
1215 std::cerr << "No active view!\n";
1218 aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView()));
1221 Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1);
1222 for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList);
1223 anIter.More(); anIter.Next())
1225 ViewerTest::RemoveView (anIter.Value(), toRemoveContext);
1231 //==============================================================================
1232 //function : VActivate
1233 //purpose : Activate the view defined by its ID
1234 //==============================================================================
1236 static int VActivate (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1240 theDi << theArgVec[0] << ": wrong number of command arguments.\n"
1241 << "Usage: " << theArgVec[0] << " ViewID\n";
1246 theDi.Eval("vviewlist");
1250 TCollection_AsciiString aNameString(theArgVec[1]);
1251 if ( strcasecmp( aNameString.ToCString(), "NONE" ) == 0 )
1253 TCollection_AsciiString aTitle("3D View - ");
1254 aTitle = aTitle + ViewerTest_myViews.Find2(ViewerTest::CurrentView());
1255 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1256 Handle(V3d_View) anEmptyView;
1257 #if defined(_WIN32) || defined(__WIN32__)
1258 Handle(WNT_Window) anEmptyWindow;
1259 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1260 Handle(Cocoa_Window) anEmptyWindow;
1262 Handle(Xw_Window) anEmptyWindow;
1264 VT_GetWindow() = anEmptyWindow;
1265 ViewerTest::CurrentView (anEmptyView);
1266 ViewerTest::ResetEventManager();
1267 theDi << theArgVec[0] << ": all views are inactive\n";
1271 ViewerTest_Names aViewNames(aNameString);
1273 // Check if this view exists in the viewer with the driver
1274 if (!ViewerTest_myViews.IsBound1(aViewNames.GetViewName()))
1276 theDi << "Wrong view name\n";
1280 // Check if it is active already
1281 if (ViewerTest::CurrentView() == ViewerTest_myViews.Find1(aViewNames.GetViewName()))
1283 theDi << theArgVec[0] << ": the view is active already\n";
1287 ActivateView (aViewNames.GetViewName());
1291 //==============================================================================
1292 //function : VViewList
1293 //purpose : Print current list of views per viewer and graphic driver ID
1294 // shared between viewers
1295 //==============================================================================
1297 static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1301 theDi << theArgVec[0] << ": Wrong number of command arguments\n"
1302 << "Usage: " << theArgVec[0] << " name";
1305 if (ViewerTest_myContexts.Size() < 1)
1308 Standard_Boolean isTreeView =
1309 (( theArgsNb==1 ) || ( strcasecmp( theArgVec[1], "long" ) != 0 ));
1313 theDi << theArgVec[0] <<":\n";
1316 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator aDriverIter (ViewerTest_myDrivers);
1317 aDriverIter.More(); aDriverIter.Next())
1320 theDi << aDriverIter.Key1() << ":\n";
1322 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1323 aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next())
1325 if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1)
1329 TCollection_AsciiString aContextName(aContextIter.Key1());
1330 theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":\n";
1333 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIter (ViewerTest_myViews);
1334 aViewIter.More(); aViewIter.Next())
1336 if (aViewIter.Key1().Search(aContextIter.Key1()) != -1)
1338 TCollection_AsciiString aViewName(aViewIter.Key1());
1341 if (aViewIter.Value() == ViewerTest::CurrentView())
1342 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)\n";
1344 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n";
1348 theDi << aViewName << " ";
1358 //==============================================================================
1359 //function : VT_ProcessKeyPress
1360 //purpose : Handle KeyPress event from a CString
1361 //==============================================================================
1362 void VT_ProcessKeyPress (const char* buf_ret)
1364 //cout << "KeyPress" << endl;
1365 const Handle(V3d_View) aView = ViewerTest::CurrentView();
1366 // Letter in alphabetic order
1368 if (!strcasecmp (buf_ret, "A"))
1371 aView->SetProj(V3d_XposYnegZpos);
1373 else if (!strcasecmp (buf_ret, "D"))
1378 else if (!strcasecmp (buf_ret, "F"))
1380 if (ViewerTest::GetAISContext()->NbSelected() > 0)
1382 ViewerTest::GetAISContext()->FitSelected (aView);
1390 else if (!strcasecmp (buf_ret, "H"))
1393 cout << "HLR" << endl;
1394 aView->SetComputedMode (!aView->ComputedMode());
1395 MyHLRIsOn = aView->ComputedMode();
1397 else if (!strcasecmp (buf_ret, "P"))
1400 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1401 if (aContext->DefaultDrawer()->TypeOfHLR() == Prs3d_TOH_Algo)
1402 aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_PolyAlgo);
1404 aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_Algo);
1405 if (aContext->NbSelected()==0)
1407 AIS_ListOfInteractive aListOfShapes;
1408 aContext->DisplayedObjects(aListOfShapes);
1409 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
1410 anIter.More(); anIter.Next())
1412 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
1413 if (aShape.IsNull())
1415 if (aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
1416 aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
1418 aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
1419 aContext->Redisplay (aShape, Standard_False);
1424 for (aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected())
1426 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->SelectedInteractive());
1427 if (aShape.IsNull())
1429 if(aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
1430 aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
1432 aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
1433 aContext->Redisplay (aShape, Standard_False);
1437 aContext->UpdateCurrentViewer();
1440 else if (!strcasecmp (buf_ret, "S"))
1442 std::cout << "setup Shaded display mode" << std::endl;
1444 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1445 if(Ctx->NbSelected()==0)
1446 Ctx->SetDisplayMode (AIS_Shaded, Standard_True);
1448 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1449 Ctx->SetDisplayMode(Ctx->SelectedInteractive(),1,Standard_False);
1450 Ctx->UpdateCurrentViewer();
1453 else if (!strcasecmp (buf_ret, "U"))
1455 // Unset display mode
1456 std::cout << "reset display mode to defaults" << std::endl;
1458 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1459 if(Ctx->NbSelected()==0)
1460 Ctx->SetDisplayMode (AIS_WireFrame, Standard_True);
1462 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1463 Ctx->UnsetDisplayMode(Ctx->SelectedInteractive(),Standard_False);
1464 Ctx->UpdateCurrentViewer();
1468 else if (!strcasecmp (buf_ret, "T"))
1471 aView->SetProj(V3d_Zpos);
1473 else if (!strcasecmp (buf_ret, "B"))
1476 aView->SetProj(V3d_Zneg);
1478 else if (!strcasecmp (buf_ret, "L"))
1481 aView->SetProj(V3d_Xneg);
1483 else if (!strcasecmp (buf_ret, "R"))
1486 aView->SetProj(V3d_Xpos);
1488 else if (!strcasecmp (buf_ret, "W"))
1490 std::cout << "setup WireFrame display mode" << std::endl;
1491 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1492 if(Ctx->NbSelected()==0)
1493 Ctx->SetDisplayMode (AIS_WireFrame, Standard_True);
1495 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1496 Ctx->SetDisplayMode(Ctx->SelectedInteractive(),0,Standard_False);
1497 Ctx->UpdateCurrentViewer();
1500 else if (!strcasecmp (buf_ret, ","))
1502 ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView());
1504 else if (!strcasecmp (buf_ret, "."))
1506 ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
1508 else if (!strcasecmp (buf_ret, "/"))
1510 Handle(Graphic3d_Camera) aCamera = aView->Camera();
1511 if (aCamera->IsStereo())
1513 aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() - 0.01);
1517 else if (!strcasecmp (buf_ret, "*"))
1519 Handle(Graphic3d_Camera) aCamera = aView->Camera();
1520 if (aCamera->IsStereo())
1522 aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() + 0.01);
1526 else if (*buf_ret == THE_KEY_DELETE)
1528 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
1530 && aCtx->NbSelected() > 0)
1532 Draw_Interprete ("verase");
1538 Standard_Integer Num = Draw::Atoi(buf_ret);
1539 if(Num>=0 && Num<=7)
1540 ViewerTest::StandardModeActivation(Num);
1544 //==============================================================================
1545 //function : VT_ProcessExpose
1546 //purpose : Redraw the View on an Expose Event
1547 //==============================================================================
1548 void VT_ProcessExpose()
1550 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
1551 if (!aView3d.IsNull())
1557 //==============================================================================
1558 //function : VT_ProcessConfigure
1559 //purpose : Resize the View on an Configure Event
1560 //==============================================================================
1561 void VT_ProcessConfigure()
1563 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
1564 if (aView3d.IsNull())
1569 aView3d->MustBeResized();
1574 //==============================================================================
1575 //function : VT_ProcessButton1Press
1577 //==============================================================================
1578 Standard_Boolean VT_ProcessButton1Press (Standard_Integer ,
1579 const char** theArgVec,
1580 Standard_Boolean theToPick,
1581 Standard_Boolean theIsShift)
1585 TheIsAnimating = Standard_False;
1586 return Standard_False;
1591 Standard_Real X, Y, Z;
1592 ViewerTest::CurrentView()->Convert (X_Motion, Y_Motion, X, Y, Z);
1594 Draw::Set (theArgVec[1], X);
1595 Draw::Set (theArgVec[2], Y);
1596 Draw::Set (theArgVec[3], Z);
1601 ViewerTest::CurrentEventManager()->ShiftSelect();
1605 ViewerTest::CurrentEventManager()->Select();
1608 return Standard_False;
1611 //==============================================================================
1612 //function : VT_ProcessButton1Release
1613 //purpose : End selecting
1614 //==============================================================================
1615 void VT_ProcessButton1Release (Standard_Boolean theIsShift)
1619 IsDragged = Standard_False;
1620 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
1623 EM->ShiftSelect (X_ButtonPress, Y_ButtonPress,
1624 X_Motion, Y_Motion);
1628 EM->Select (X_ButtonPress, Y_ButtonPress,
1629 X_Motion, Y_Motion);
1634 //==============================================================================
1635 //function : VT_ProcessButton3Press
1636 //purpose : Start Rotation
1637 //==============================================================================
1638 void VT_ProcessButton3Press()
1643 ViewerTest::CurrentView()->SetComputedMode (Standard_False);
1645 ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress );
1648 //==============================================================================
1649 //function : VT_ProcessButton3Release
1650 //purpose : End rotation
1651 //==============================================================================
1652 void VT_ProcessButton3Release()
1659 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
1664 //==============================================================================
1665 //function : ProcessControlButton1Motion
1667 //==============================================================================
1669 #if defined(_WIN32) || ! defined(__APPLE__) || defined(MACOSX_USE_GLX)
1670 static void ProcessControlButton1Motion()
1672 ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion);
1674 X_ButtonPress = X_Motion;
1675 Y_ButtonPress = Y_Motion;
1679 //==============================================================================
1680 //function : VT_ProcessControlButton2Motion
1682 //==============================================================================
1683 void VT_ProcessControlButton2Motion()
1685 Standard_Integer aDx = X_Motion - X_ButtonPress;
1686 Standard_Integer aDy = Y_Motion - Y_ButtonPress;
1688 aDy = -aDy; // Xwindow Y axis is from top to Bottom
1690 ViewerTest::CurrentView()->Pan (aDx, aDy);
1692 X_ButtonPress = X_Motion;
1693 Y_ButtonPress = Y_Motion;
1696 //==============================================================================
1697 //function : VT_ProcessControlButton3Motion
1698 //purpose : Rotation
1699 //==============================================================================
1700 void VT_ProcessControlButton3Motion()
1704 ViewerTest::CurrentView()->Rotation (X_Motion, Y_Motion);
1708 //==============================================================================
1709 //function : VT_ProcessMotion
1711 //==============================================================================
1712 void VT_ProcessMotion()
1714 //pre-hilights detected objects at mouse position
1716 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
1717 EM->MoveTo(X_Motion, Y_Motion);
1721 void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix)
1723 Xpix = X_Motion;Ypix=Y_Motion;
1726 //==============================================================================
1727 //function : ViewProject: implements VAxo, VTop, VLeft, ...
1728 //purpose : Switches to an axonometric, top, left and other views
1729 //==============================================================================
1731 static int ViewProject(Draw_Interpretor& di, const V3d_TypeOfOrientation ori)
1733 if ( ViewerTest::CurrentView().IsNull() )
1735 di<<"Call vinit before this command, please\n";
1739 ViewerTest::CurrentView()->SetProj(ori);
1743 //==============================================================================
1745 //purpose : Switch to an Axonometric view
1746 //Draw arg : No args
1747 //==============================================================================
1749 static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** )
1751 return ViewProject(di, V3d_XposYnegZpos);
1754 //==============================================================================
1756 //purpose : Switch to a Top View
1757 //Draw arg : No args
1758 //==============================================================================
1760 static int VTop(Draw_Interpretor& di, Standard_Integer , const char** )
1762 return ViewProject(di, V3d_Zpos);
1765 //==============================================================================
1766 //function : VBottom
1767 //purpose : Switch to a Bottom View
1768 //Draw arg : No args
1769 //==============================================================================
1771 static int VBottom(Draw_Interpretor& di, Standard_Integer , const char** )
1773 return ViewProject(di, V3d_Zneg);
1776 //==============================================================================
1778 //purpose : Switch to a Left View
1779 //Draw arg : No args
1780 //==============================================================================
1782 static int VLeft(Draw_Interpretor& di, Standard_Integer , const char** )
1784 return ViewProject(di, V3d_Xneg);
1787 //==============================================================================
1789 //purpose : Switch to a Right View
1790 //Draw arg : No args
1791 //==============================================================================
1793 static int VRight(Draw_Interpretor& di, Standard_Integer , const char** )
1795 return ViewProject(di, V3d_Xpos);
1798 //==============================================================================
1800 //purpose : Switch to a Front View
1801 //Draw arg : No args
1802 //==============================================================================
1804 static int VFront(Draw_Interpretor& di, Standard_Integer , const char** )
1806 return ViewProject(di, V3d_Yneg);
1809 //==============================================================================
1811 //purpose : Switch to a Back View
1812 //Draw arg : No args
1813 //==============================================================================
1815 static int VBack(Draw_Interpretor& di, Standard_Integer , const char** )
1817 return ViewProject(di, V3d_Ypos);
1820 //==============================================================================
1822 //purpose : Dsiplay help on viewer Keyboead and mouse commands
1823 //Draw arg : No args
1824 //==============================================================================
1826 static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
1829 di << "Q : Quit the application\n";
1831 di << "=========================\n";
1832 di << "F : FitAll\n";
1833 di << "T : TopView\n";
1834 di << "B : BottomView\n";
1835 di << "R : RightView\n";
1836 di << "L : LeftView\n";
1837 di << "A : AxonometricView\n";
1838 di << "D : ResetView\n";
1840 di << "=========================\n";
1841 di << "S : Shading\n";
1842 di << "W : Wireframe\n";
1843 di << "H : HidelLineRemoval\n";
1844 di << "U : Unset display mode\n";
1845 di << "Delete : Remove selection from viewer\n";
1847 di << "=========================\n";
1848 di << "Selection mode \n";
1849 di << "0 : Shape\n";
1850 di << "1 : Vertex\n";
1854 di << "5 : Shell\n";
1855 di << "6 : Solid\n";
1856 di << "7 : Compound\n";
1858 di << "=========================\n";
1859 di << "Z : Switch Z clipping On/Off\n";
1860 di << ", : Hilight next detected\n";
1861 di << ". : Hilight previous detected\n";
1868 static Standard_Boolean Ppick = 0;
1869 static Standard_Integer Pargc = 0;
1870 static const char** Pargv = NULL;
1873 static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
1878 if (!ViewerTest_myViews.IsEmpty()) {
1880 WPARAM fwKeys = wParam;
1885 // Delete view from map of views
1886 ViewerTest::RemoveView(FindViewIdByWindowHandle(hwnd));
1891 if(LOWORD(wParam) == WA_CLICKACTIVE || LOWORD(wParam) == WA_ACTIVE
1892 || ViewerTest::CurrentView().IsNull())
1894 // Activate inactive window
1895 if(GetWindowHandle(VT_GetWindow()) != hwnd)
1897 ActivateView (FindViewIdByWindowHandle(hwnd));
1903 if (IsDragged && !DragFirst)
1905 if (!GetActiveAISManipulator().IsNull())
1907 GetActiveAISManipulator()->StopTransform();
1908 ViewerTest::GetAISContext()->ClearSelected (Standard_True);
1911 if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
1913 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
1914 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
1917 VT_ProcessButton1Release ((fwKeys & MK_SHIFT) != 0);
1919 IsDragged = Standard_False;
1920 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1923 if (IsDragged && !DragFirst)
1925 if (!GetActiveAISManipulator().IsNull())
1927 GetActiveAISManipulator()->StopTransform (Standard_False);
1928 ViewerTest::GetAISContext()->ClearSelected (Standard_True);
1930 IsDragged = Standard_False;
1932 return ViewerWindowProc (hwnd, Msg, wParam, lParam);
1934 case WM_LBUTTONDOWN:
1935 if (!GetActiveAISManipulator().IsNull())
1937 IsDragged = ( fwKeys == MK_LBUTTON );
1941 IsDragged = ( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) );
1946 DragFirst = Standard_True;
1947 X_ButtonPress = LOWORD(lParam);
1948 Y_ButtonPress = HIWORD(lParam);
1950 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1955 X_Motion = LOWORD (lParam);
1956 Y_Motion = HIWORD (lParam);
1957 if (!GetActiveAISManipulator().IsNull())
1961 GetActiveAISManipulator()->StartTransform (X_ButtonPress, Y_ButtonPress, ViewerTest::CurrentView());
1965 GetActiveAISManipulator()->Transform (X_Motion, Y_Motion, ViewerTest::CurrentView());
1966 ViewerTest::GetAISContext()->CurrentViewer()->Redraw();
1971 bool toRedraw = false;
1972 if (!DragFirst && ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
1974 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
1979 if (GetClientRect (hwnd, &aRect))
1981 int aHeight = aRect.bottom - aRect.top;
1982 GetRubberBand()->SetRectangle (X_ButtonPress, aHeight - Y_ButtonPress, X_Motion, aHeight - Y_Motion);
1983 ViewerTest::GetAISContext()->Display (GetRubberBand(), 0, -1, Standard_False, Standard_True, AIS_DS_Displayed);
1988 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
1992 DragFirst = Standard_False;
1995 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1999 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
2003 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
2007 static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
2013 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
2016 return DefWindowProcW (hwnd, Msg, wParam, lParam);
2023 BeginPaint(hwnd, &ps);
2024 EndPaint(hwnd, &ps);
2029 VT_ProcessConfigure();
2034 switch (aView->RenderingParams().StereoMode)
2036 case Graphic3d_StereoMode_RowInterlaced:
2037 case Graphic3d_StereoMode_ColumnInterlaced:
2038 case Graphic3d_StereoMode_ChessBoard:
2039 VT_ProcessConfigure(); // track window moves to reverse stereo pair
2047 if ((wParam != VK_SHIFT) && (wParam != VK_CONTROL))
2050 c[0] = (char) wParam;
2052 if (wParam == VK_DELETE)
2054 c[0] = THE_KEY_DELETE;
2057 else if (wParam == VK_OEM_COMMA)
2062 else if (wParam == VK_OEM_PERIOD)
2066 else if (wParam == VK_DIVIDE)
2071 else if (wParam == VK_MULTIPLY)
2075 VT_ProcessKeyPress (c);
2083 VT_ProcessButton3Release();
2086 case WM_LBUTTONDOWN:
2087 case WM_MBUTTONDOWN:
2088 case WM_RBUTTONDOWN:
2090 WPARAM fwKeys = wParam;
2094 X_ButtonPress = LOWORD(lParam);
2095 Y_ButtonPress = HIWORD(lParam);
2097 if (Msg == WM_LBUTTONDOWN)
2099 if ((fwKeys & MK_CONTROL) != 0)
2101 Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) != 0);
2105 VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) != 0);
2108 else if (Msg == WM_RBUTTONDOWN)
2111 VT_ProcessButton3Press();
2118 int aDelta = GET_WHEEL_DELTA_WPARAM (wParam);
2119 if (wParam & MK_CONTROL)
2121 if (aView->Camera()->IsStereo())
2123 Standard_Real aFocus = aView->Camera()->ZFocus() + (aDelta > 0 ? 0.05 : -0.05);
2127 aView->Camera()->SetZFocus (aView->Camera()->ZFocusType(), aFocus);
2134 aView->Zoom (0, 0, aDelta / 40, aDelta / 40);
2141 //cout << "\t WM_MOUSEMOVE" << endl;
2142 WPARAM fwKeys = wParam;
2143 X_Motion = LOWORD(lParam);
2144 Y_Motion = HIWORD(lParam);
2147 (fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON )) != 0 )
2150 X_ButtonPress = LOWORD(lParam);
2151 Y_ButtonPress = HIWORD(lParam);
2153 if ((fwKeys & MK_RBUTTON) != 0) {
2155 VT_ProcessButton3Press();
2159 if ((fwKeys & MK_CONTROL) != 0)
2161 if ((fwKeys & MK_LBUTTON) != 0)
2163 ProcessControlButton1Motion();
2165 else if ((fwKeys & MK_MBUTTON) != 0
2166 || ((fwKeys & MK_LBUTTON) != 0
2167 && (fwKeys & MK_RBUTTON) != 0))
2169 VT_ProcessControlButton2Motion();
2171 else if ((fwKeys & MK_RBUTTON) != 0)
2173 VT_ProcessControlButton3Motion();
2176 else if (GetWindowHandle (VT_GetWindow()) == hwnd)
2184 return DefWindowProcW (hwnd, Msg, wParam, lParam);
2189 //==============================================================================
2190 //function : ViewerMainLoop
2191 //purpose : Get a Event on the view and dispatch it
2192 //==============================================================================
2195 int ViewerMainLoop(Standard_Integer argc, const char** argv)
2197 Ppick = (argc > 0)? 1 : 0;
2205 cout << "Start picking" << endl;
2207 while ( Ppick == 1 ) {
2208 // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
2209 if (GetMessageW (&msg, NULL, 0, 0))
2211 TranslateMessage (&msg);
2212 DispatchMessageW (&msg);
2216 cout << "Picking done" << endl;
2222 #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX)
2224 int min( int a, int b )
2232 int max( int a, int b )
2240 int ViewerMainLoop(Standard_Integer argc, const char** argv)
2243 static XEvent aReport;
2244 Standard_Boolean pick = argc > 0;
2245 Display *aDisplay = GetDisplayConnection()->GetDisplay();
2246 XNextEvent (aDisplay, &aReport);
2248 // Handle event for the chosen display connection
2249 switch (aReport.type) {
2252 if((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW))
2255 ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window));
2261 // Activate inactive view
2262 Window aWindow = GetWindowHandle(VT_GetWindow());
2263 if(aWindow != aReport.xfocus.window)
2265 ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window));
2274 case ConfigureNotify:
2276 VT_ProcessConfigure();
2285 XComposeStatus status_in_out;
2287 ret_len = XLookupString( ( XKeyEvent *)&aReport ,
2288 (char *) buf_ret , 10 ,
2289 &ks_ret , &status_in_out ) ;
2292 buf_ret[ret_len] = '\0' ;
2296 VT_ProcessKeyPress (buf_ret);
2302 X_ButtonPress = aReport.xbutton.x;
2303 Y_ButtonPress = aReport.xbutton.y;
2305 if (aReport.xbutton.button == Button1)
2307 if (aReport.xbutton.state & ControlMask)
2309 pick = VT_ProcessButton1Press (argc, argv, pick, (aReport.xbutton.state & ShiftMask));
2313 IsDragged = Standard_True;
2314 DragFirst = Standard_True;
2317 else if (aReport.xbutton.button == Button3)
2320 VT_ProcessButton3Press();
2330 if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
2332 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
2333 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
2337 Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
2338 if( aContext.IsNull() )
2340 cout << "The context is null. Please use vinit before createmesh" << endl;
2344 Standard_Boolean ShiftPressed = ( aReport.xbutton.state & ShiftMask );
2345 if( aReport.xbutton.button==1 )
2349 aContext->ShiftSelect (Standard_True);
2353 aContext->Select (Standard_True);
2358 aContext->ShiftSelect(Min(X_ButtonPress, X_Motion), Min(Y_ButtonPress, Y_Motion),
2359 Max(X_ButtonPress, X_Motion), Max(Y_ButtonPress, Y_Motion),
2360 ViewerTest::CurrentView(), Standard_True);
2364 aContext->Select(Min(X_ButtonPress, X_Motion), Min(Y_ButtonPress, Y_Motion),
2365 Max(X_ButtonPress, X_Motion), Max(Y_ButtonPress, Y_Motion),
2366 ViewerTest::CurrentView(), Standard_True);
2369 VT_ProcessButton3Release();
2371 IsDragged = Standard_False;
2374 VT_ProcessButton3Release();
2379 if (GetWindowHandle (VT_GetWindow()) != aReport.xmotion.window)
2387 if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
2389 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
2393 X_Motion = aReport.xmotion.x;
2394 Y_Motion = aReport.xmotion.y;
2395 DragFirst = Standard_False;
2397 Window aWindow = GetWindowHandle(VT_GetWindow());
2400 unsigned int aWidth, aHeight, aBorderWidth, aDepth;
2401 XGetGeometry (aDisplay, aWindow, &aRoot, &anX, &anY, &aWidth, &aHeight, &aBorderWidth, &aDepth);
2402 GetRubberBand()->SetRectangle (X_ButtonPress, aHeight - Y_ButtonPress, X_Motion, aHeight - Y_Motion);
2403 ViewerTest::GetAISContext()->Display (GetRubberBand(), 0, -1, Standard_False, Standard_True, AIS_DS_Displayed);
2404 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
2408 X_Motion = aReport.xmotion.x;
2409 Y_Motion = aReport.xmotion.y;
2411 // remove all the ButtonMotionMaskr
2412 while( XCheckMaskEvent( aDisplay, ButtonMotionMask, &aReport) ) ;
2414 if ( aReport.xmotion.state & ControlMask ) {
2415 if ( aReport.xmotion.state & Button1Mask ) {
2416 ProcessControlButton1Motion();
2418 else if ( aReport.xmotion.state & Button2Mask ) {
2419 VT_ProcessControlButton2Motion();
2421 else if ( aReport.xmotion.state & Button3Mask ) {
2422 VT_ProcessControlButton3Motion();
2436 //==============================================================================
2437 //function : VProcessEvents
2438 //purpose : call by Tk_CreateFileHandler() to be able to manage the
2439 // event in the Viewer window
2440 //==============================================================================
2442 static void VProcessEvents(ClientData,int)
2444 NCollection_Vector<int> anEventNumbers;
2445 // Get number of messages from every display
2446 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
2447 anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next())
2449 anEventNumbers.Append(XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()));
2451 // Handle events for every display
2452 int anEventIter = 0;
2453 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
2454 anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next(), anEventIter++)
2456 for (int i = 0; i < anEventNumbers.Value(anEventIter) &&
2457 XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()) > 0; ++i)
2459 SetDisplayConnection (anIter.Key2()->GetDisplayConnection());
2460 int anEventResult = ViewerMainLoop( 0, NULL);
2461 // If window is closed or context was not found finish current event processing loop
2467 SetDisplayConnection (ViewerTest::GetAISContext()->CurrentViewer()->Driver()->GetDisplayConnection());
2472 //==============================================================================
2473 //function : OSWindowSetup
2474 //purpose : Setup for the X11 window to be able to cath the event
2475 //==============================================================================
2478 static void OSWindowSetup()
2480 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
2483 Window window = VT_GetWindow()->XWindow();
2484 SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
2485 Display *aDisplay = GetDisplayConnection()->GetDisplay();
2486 XSynchronize(aDisplay, 1);
2488 // X11 : For keyboard on SUN
2490 wmhints.flags = InputHint;
2493 XSetWMHints( aDisplay, window, &wmhints);
2495 XSelectInput( aDisplay, window, ExposureMask | KeyPressMask |
2496 ButtonPressMask | ButtonReleaseMask |
2497 StructureNotifyMask |
2499 Button1MotionMask | Button2MotionMask |
2500 Button3MotionMask | FocusChangeMask
2502 Atom aDeleteWindowAtom = GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW);
2503 XSetWMProtocols(aDisplay, window, &aDeleteWindowAtom, 1);
2505 XSynchronize(aDisplay, 0);
2513 //==============================================================================
2516 //==============================================================================
2518 static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgv)
2520 const Handle(V3d_View) aView = ViewerTest::CurrentView();
2523 std::cout << "Error: no active viewer!\n";
2527 Standard_Boolean toFit = Standard_True;
2528 ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
2529 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
2531 TCollection_AsciiString anArg (theArgv[anArgIter]);
2533 if (anUpdateTool.parseRedrawMode (anArg))
2537 else if (anArg == "-selected")
2539 ViewerTest::GetAISContext()->FitSelected (aView, 0.01, Standard_False);
2540 toFit = Standard_False;
2544 std::cout << "Syntax error at '" << anArg << "'\n";
2550 aView->FitAll (0.01, Standard_False);
2555 //=======================================================================
2556 //function : VFitArea
2557 //purpose : Fit view to show area located between two points
2558 // : given in world 2D or 3D coordinates.
2559 //=======================================================================
2560 static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
2562 Handle(V3d_View) aView = ViewerTest::CurrentView();
2565 std::cerr << theArgVec[0] << "Error: No active view.\n";
2570 gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0);
2571 gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0);
2575 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
2576 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
2577 aWorldPnt2.SetX (Draw::Atof (theArgVec[3]));
2578 aWorldPnt2.SetY (Draw::Atof (theArgVec[4]));
2580 else if (theArgNb == 7)
2582 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
2583 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
2584 aWorldPnt1.SetZ (Draw::Atof (theArgVec[3]));
2585 aWorldPnt2.SetX (Draw::Atof (theArgVec[4]));
2586 aWorldPnt2.SetY (Draw::Atof (theArgVec[5]));
2587 aWorldPnt2.SetZ (Draw::Atof (theArgVec[6]));
2591 std::cerr << theArgVec[0] << "Error: Invalid number of arguments.\n";
2592 theDI.PrintHelp(theArgVec[0]);
2596 // Convert model coordinates to view space
2597 Handle(Graphic3d_Camera) aCamera = aView->Camera();
2598 gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1);
2599 gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2);
2601 // Determine fit area
2602 gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y()));
2603 gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y()));
2605 Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner);
2607 if (aDiagonal < Precision::Confusion())
2609 std::cerr << theArgVec[0] << "Error: view area is too small.\n";
2613 aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y());
2617 //==============================================================================
2619 //purpose : ZFitall, no DRAW arguments
2620 //Draw arg : No args
2621 //==============================================================================
2622 static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
2624 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
2626 if (aCurrentView.IsNull())
2628 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
2634 aCurrentView->ZFitAll();
2635 aCurrentView->Redraw();
2639 Standard_Real aScale = 1.0;
2643 aScale = Draw::Atoi (theArgVec[1]);
2646 aCurrentView->ZFitAll (aScale);
2647 aCurrentView->Redraw();
2652 //==============================================================================
2653 //function : VRepaint
2655 //==============================================================================
2656 static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgVec)
2658 Handle(V3d_View) aView = ViewerTest::CurrentView();
2661 std::cout << "Error: no active viewer!\n";
2665 Standard_Boolean isImmediateUpdate = Standard_False;
2666 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
2668 TCollection_AsciiString anArg (theArgVec[anArgIter]);
2670 if (anArg == "-immediate")
2672 isImmediateUpdate = Standard_True;
2673 if (anArgIter + 1 < theArgNb
2674 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate))
2681 std::cout << "Syntax error at '" << anArg << "'\n";
2685 if (isImmediateUpdate)
2687 aView->RedrawImmediate();
2696 //==============================================================================
2698 //purpose : Remove all the object from the viewer
2699 //Draw arg : No args
2700 //==============================================================================
2702 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
2704 Handle(V3d_View) V = ViewerTest::CurrentView();
2706 ViewerTest::Clear();
2710 //==============================================================================
2713 //==============================================================================
2715 static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2716 { if (ViewerTest::CurrentView().IsNull() ) return 1;
2719 di << argv[0] << "Invalid number of arguments\n";
2723 while (ViewerMainLoop( argc, argv)) {
2729 //==============================================================================
2731 //purpose : Load image as background
2732 //==============================================================================
2734 static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2736 if (argc < 2 || argc > 3)
2738 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n";
2739 di << "filltype can be one of CENTERED, TILED, STRETCH, NONE\n";
2743 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2744 if(AISContext.IsNull())
2746 di << "use 'vinit' command before " << argv[0] << "\n";
2750 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
2753 const char* szType = argv[2];
2754 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
2755 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
2756 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
2757 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
2760 di << "Wrong fill type : " << szType << "\n";
2761 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
2766 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2767 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
2772 //==============================================================================
2773 //function : VSetBgMode
2774 //purpose : Change background image fill type
2775 //==============================================================================
2777 static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2781 di << "Usage : " << argv[0] << " filltype : Change background image mode\n";
2782 di << "filltype must be one of CENTERED, TILED, STRETCH, NONE\n";
2786 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2787 if(AISContext.IsNull())
2789 di << "use 'vinit' command before " << argv[0] << "\n";
2792 Aspect_FillMethod aFillType = Aspect_FM_NONE;
2793 const char* szType = argv[1];
2794 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
2795 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
2796 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
2797 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
2800 di << "Wrong fill type : " << szType << "\n";
2801 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
2804 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2805 V3dView->SetBgImageStyle(aFillType, Standard_True);
2809 //==============================================================================
2810 //function : VSetGradientBg
2811 //purpose : Mount gradient background
2812 //==============================================================================
2813 static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2817 di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background\n";
2818 di << "R1,G1,B1,R2,G2,B2 = [0..255]\n";
2819 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2820 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2824 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2825 if(AISContext.IsNull())
2827 di << "use 'vinit' command before " << argv[0] << "\n";
2833 Standard_Real R1 = Draw::Atof(argv[1])/255.;
2834 Standard_Real G1 = Draw::Atof(argv[2])/255.;
2835 Standard_Real B1 = Draw::Atof(argv[3])/255.;
2836 Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB);
2838 Standard_Real R2 = Draw::Atof(argv[4])/255.;
2839 Standard_Real G2 = Draw::Atof(argv[5])/255.;
2840 Standard_Real B2 = Draw::Atof(argv[6])/255.;
2842 Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB);
2843 int aType = Draw::Atoi(argv[7]);
2844 if( aType < 0 || aType > 8 )
2846 di << "Wrong fill type \n";
2847 di << "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";
2852 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
2854 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2855 V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1);
2861 //==============================================================================
2862 //function : VSetGradientBgMode
2863 //purpose : Change gradient background fill style
2864 //==============================================================================
2865 static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2869 di << "Usage : " << argv[0] << " Type : Change gradient background fill type\n";
2870 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2871 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2875 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2876 if(AISContext.IsNull())
2878 di << "use 'vinit' command before " << argv[0] << "\n";
2883 int aType = Draw::Atoi(argv[1]);
2884 if( aType < 0 || aType > 8 )
2886 di << "Wrong fill type \n";
2887 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2888 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2892 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
2894 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2895 V3dView->SetBgGradientStyle( aMethod, 1 );
2901 //==============================================================================
2902 //function : VSetColorBg
2903 //purpose : Set color background
2904 //==============================================================================
2905 static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2909 di << "Usage : " << argv[0] << " R G B : Set color background\n";
2910 di << "R,G,B = [0..255]\n";
2914 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2915 if(AISContext.IsNull())
2917 di << "use 'vinit' command before " << argv[0] << "\n";
2923 Standard_Real R = Draw::Atof(argv[1])/255.;
2924 Standard_Real G = Draw::Atof(argv[2])/255.;
2925 Standard_Real B = Draw::Atof(argv[3])/255.;
2926 Quantity_Color aColor(R,G,B,Quantity_TOC_RGB);
2928 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2929 V3dView->SetBackgroundColor( aColor );
2936 //==============================================================================
2937 //function : VSetDefaultBg
2938 //purpose : Set default viewer background fill color
2939 //==============================================================================
2940 static int VSetDefaultBg (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
2945 std::cout << "Error: wrong syntax! See usage:\n";
2946 theDI.PrintHelp (theArgVec[0]);
2950 ViewerTest_DefaultBackground.FillMethod =
2951 theArgNb == 4 ? Aspect_GFM_NONE
2952 : (Aspect_GradientFillMethod) Draw::Atoi (theArgVec[7]);
2956 Standard_Real R = Draw::Atof (theArgVec[1]) / 255.;
2957 Standard_Real G = Draw::Atof (theArgVec[2]) / 255.;
2958 Standard_Real B = Draw::Atof (theArgVec[3]) / 255.;
2959 ViewerTest_DefaultBackground.FlatColor.SetValues (R, G, B, Quantity_TOC_RGB);
2963 Standard_Real R1 = Draw::Atof (theArgVec[1]) / 255.;
2964 Standard_Real G1 = Draw::Atof (theArgVec[2]) / 255.;
2965 Standard_Real B1 = Draw::Atof (theArgVec[3]) / 255.;
2966 ViewerTest_DefaultBackground.GradientColor1.SetValues (R1, G1, B1, Quantity_TOC_RGB);
2968 Standard_Real R2 = Draw::Atof (theArgVec[4]) / 255.;
2969 Standard_Real G2 = Draw::Atof (theArgVec[5]) / 255.;
2970 Standard_Real B2 = Draw::Atof (theArgVec[6]) / 255.;
2971 ViewerTest_DefaultBackground.GradientColor2.SetValues (R2, G2, B2, Quantity_TOC_RGB);
2974 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
2975 anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
2977 const Handle(V3d_Viewer)& aViewer = anIter.Value()->CurrentViewer();
2978 aViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
2979 aViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
2980 ViewerTest_DefaultBackground.GradientColor2,
2981 ViewerTest_DefaultBackground.FillMethod);
2987 //==============================================================================
2989 //purpose : View Scaling
2990 //==============================================================================
2992 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2994 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2995 if ( V3dView.IsNull() ) return 1;
2998 di << argv[0] << "Invalid number of arguments\n";
3001 V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
3004 //==============================================================================
3005 //function : VZBuffTrihedron
3007 //==============================================================================
3009 static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
3010 Standard_Integer theArgNb,
3011 const char** theArgVec)
3013 Handle(V3d_View) aView = ViewerTest::CurrentView();
3016 std::cout << "Error: no active viewer!\n";
3020 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
3022 Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER;
3023 V3d_TypeOfVisualization aVisType = V3d_ZBUFFER;
3024 Quantity_Color aLabelsColor = Quantity_NOC_WHITE;
3025 Quantity_Color anArrowColorX = Quantity_NOC_RED;
3026 Quantity_Color anArrowColorY = Quantity_NOC_GREEN;
3027 Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1;
3028 Standard_Real aScale = 0.1;
3029 Standard_Real aSizeRatio = 0.8;
3030 Standard_Real anArrowDiam = 0.05;
3031 Standard_Integer aNbFacets = 12;
3032 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3034 Standard_CString anArg = theArgVec[anArgIter];
3035 TCollection_AsciiString aFlag (anArg);
3037 if (anUpdateTool.parseRedrawMode (aFlag))
3041 else if (aFlag == "-on")
3045 else if (aFlag == "-off")
3047 aView->TriedronErase();
3050 else if (aFlag == "-pos"
3051 || aFlag == "-position"
3052 || aFlag == "-corner")
3054 if (++anArgIter >= theArgNb)
3056 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3060 TCollection_AsciiString aPosName (theArgVec[anArgIter]);
3061 aPosName.LowerCase();
3062 if (aPosName == "center")
3064 aPosition = Aspect_TOTP_CENTER;
3066 else if (aPosName == "left_lower"
3067 || aPosName == "lower_left"
3068 || aPosName == "leftlower"
3069 || aPosName == "lowerleft")
3071 aPosition = Aspect_TOTP_LEFT_LOWER;
3073 else if (aPosName == "left_upper"
3074 || aPosName == "upper_left"
3075 || aPosName == "leftupper"
3076 || aPosName == "upperleft")
3078 aPosition = Aspect_TOTP_LEFT_UPPER;
3080 else if (aPosName == "right_lower"
3081 || aPosName == "lower_right"
3082 || aPosName == "rightlower"
3083 || aPosName == "lowerright")
3085 aPosition = Aspect_TOTP_RIGHT_LOWER;
3087 else if (aPosName == "right_upper"
3088 || aPosName == "upper_right"
3089 || aPosName == "rightupper"
3090 || aPosName == "upperright")
3092 aPosition = Aspect_TOTP_RIGHT_UPPER;
3096 std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'\n";
3100 else if (aFlag == "-type")
3102 if (++anArgIter >= theArgNb)
3104 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3108 TCollection_AsciiString aTypeName (theArgVec[anArgIter]);
3109 aTypeName.LowerCase();
3110 if (aTypeName == "wireframe"
3111 || aTypeName == "wire")
3113 aVisType = V3d_WIREFRAME;
3115 else if (aTypeName == "zbuffer"
3116 || aTypeName == "shaded")
3118 aVisType = V3d_ZBUFFER;
3122 std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'\n";
3125 else if (aFlag == "-scale")
3127 if (++anArgIter >= theArgNb)
3129 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3133 aScale = Draw::Atof (theArgVec[anArgIter]);
3135 else if (aFlag == "-size"
3136 || aFlag == "-sizeratio")
3138 if (++anArgIter >= theArgNb)
3140 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3144 aSizeRatio = Draw::Atof (theArgVec[anArgIter]);
3146 else if (aFlag == "-arrowdiam"
3147 || aFlag == "-arrowdiameter")
3149 if (++anArgIter >= theArgNb)
3151 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3155 anArrowDiam = Draw::Atof (theArgVec[anArgIter]);
3157 else if (aFlag == "-nbfacets")
3159 if (++anArgIter >= theArgNb)
3161 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3165 aNbFacets = Draw::Atoi (theArgVec[anArgIter]);
3167 else if (aFlag == "-colorlabel"
3168 || aFlag == "-colorlabels")
3170 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3171 theArgVec + anArgIter + 1,
3175 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3178 anArgIter += aNbParsed;
3180 else if (aFlag == "-colorarrowx")
3182 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3183 theArgVec + anArgIter + 1,
3187 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3190 anArgIter += aNbParsed;
3192 else if (aFlag == "-colorarrowy")
3194 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3195 theArgVec + anArgIter + 1,
3199 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3202 anArgIter += aNbParsed;
3204 else if (aFlag == "-colorarrowz")
3206 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3207 theArgVec + anArgIter + 1,
3211 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3214 anArgIter += aNbParsed;
3218 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3223 aView->ZBufferTriedronSetup (anArrowColorX.Name(), anArrowColorY.Name(), anArrowColorZ.Name(),
3224 aSizeRatio, anArrowDiam, aNbFacets);
3225 aView->TriedronDisplay (aPosition, aLabelsColor.Name(), aScale, aVisType);
3230 //==============================================================================
3231 //function : VRotate
3232 //purpose : Camera Rotating
3233 //==============================================================================
3235 static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
3237 Handle(V3d_View) aView = ViewerTest::CurrentView();
3240 std::cout << "No active view!\n";
3244 Standard_Boolean hasFlags = Standard_False;
3245 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3247 Standard_CString anArg (theArgVec[anArgIter]);
3248 TCollection_AsciiString aFlag (anArg);
3250 if (aFlag == "-mousestart"
3251 || aFlag == "-mousefrom")
3253 hasFlags = Standard_True;
3254 if (anArgIter + 2 >= theArgNb)
3256 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3260 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
3261 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
3262 aView->StartRotation (anX, anY);
3264 else if (aFlag == "-mousemove")
3266 hasFlags = Standard_True;
3267 if (anArgIter + 2 >= theArgNb)
3269 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3273 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
3274 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
3275 aView->Rotation (anX, anY);
3277 else if (theArgNb != 4
3280 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3289 else if (theArgNb == 4)
3291 Standard_Real anAX = Draw::Atof (theArgVec[1]);
3292 Standard_Real anAY = Draw::Atof (theArgVec[2]);
3293 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
3294 aView->Rotate (anAX, anAY, anAZ);
3297 else if (theArgNb == 7)
3299 Standard_Real anAX = Draw::Atof (theArgVec[1]);
3300 Standard_Real anAY = Draw::Atof (theArgVec[2]);
3301 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
3303 Standard_Real anX = Draw::Atof (theArgVec[4]);
3304 Standard_Real anY = Draw::Atof (theArgVec[5]);
3305 Standard_Real anZ = Draw::Atof (theArgVec[6]);
3307 aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ);
3311 std::cout << "Error: Invalid number of arguments\n";
3315 //==============================================================================
3317 //purpose : View zoom in / out (relative to current zoom)
3318 //==============================================================================
3320 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3321 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3322 if ( V3dView.IsNull() ) {
3327 Standard_Real coef = Draw::Atof(argv[1]);
3328 if ( coef <= 0.0 ) {
3329 di << argv[1] << "Invalid value\n";
3332 V3dView->SetZoom( Draw::Atof(argv[1]) );
3335 di << argv[0] << " Invalid number of arguments\n";
3340 //==============================================================================
3342 //purpose : View panning (in pixels)
3343 //==============================================================================
3345 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3346 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3347 if ( V3dView.IsNull() ) return 1;
3350 V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) );
3353 di << argv[0] << " Invalid number of arguments\n";
3358 //==============================================================================
3360 //purpose : Place the point (in pixels) at the center of the window
3361 //==============================================================================
3362 static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs)
3364 Handle(V3d_View) aView = ViewerTest::CurrentView();
3367 std::cerr << theArgs[0] << "Error: no active view." << std::endl;
3373 std::cerr << theArgs[0] << "Error: invalid number of arguments." << std::endl;
3377 aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale());
3382 //==============================================================================
3383 //function : VExport
3384 //purpose : Export the view to a vector graphic format (PS, EMF, PDF)
3385 //==============================================================================
3387 static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3389 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3390 if (V3dView.IsNull())
3395 std::cout << "Usage: " << argv[0] << " Filename [Format]\n";
3399 Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF;
3400 TCollection_AsciiString aFormatStr;
3402 TCollection_AsciiString aFileName (argv[1]);
3403 Standard_Integer aLen = aFileName.Length();
3407 aFormatStr = TCollection_AsciiString (argv[2]);
3411 if (aFileName.Value (aLen - 2) == '.')
3413 aFormatStr = aFileName.ToCString() + aLen - 2;
3415 else if (aFileName.Value (aLen - 3) == '.')
3417 aFormatStr = aFileName.ToCString() + aLen - 3;
3421 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
3427 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
3431 aFormatStr.UpperCase();
3432 if (aFormatStr == "PS")
3433 anExpFormat = Graphic3d_EF_PostScript;
3434 else if (aFormatStr == "EPS")
3435 anExpFormat = Graphic3d_EF_EnhPostScript;
3436 else if (aFormatStr == "TEX")
3437 anExpFormat = Graphic3d_EF_TEX;
3438 else if (aFormatStr == "PDF")
3439 anExpFormat = Graphic3d_EF_PDF;
3440 else if (aFormatStr == "SVG")
3441 anExpFormat = Graphic3d_EF_SVG;
3442 else if (aFormatStr == "PGF")
3443 anExpFormat = Graphic3d_EF_PGF;
3444 else if (aFormatStr == "EMF")
3445 anExpFormat = Graphic3d_EF_EMF;
3448 std::cout << "Invalid export format '" << aFormatStr << "'\n";
3452 Standard_DISABLE_DEPRECATION_WARNINGS
3455 if (!V3dView->Export (argv[1], anExpFormat))
3457 di << "Error: export of image to " << aFormatStr << " failed!\n";
3460 catch (Standard_Failure const& anException)
3462 di << "Error: export of image to " << aFormatStr << " failed";
3463 di << " (exception: " << anException.GetMessageString() << ")";
3465 Standard_ENABLE_DEPRECATION_WARNINGS
3469 static int VColorScale (Draw_Interpretor& theDI,
3470 Standard_Integer theArgNb,
3471 const char** theArgVec)
3473 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3474 Handle(V3d_View) aView = ViewerTest::CurrentView();
3475 if (aContext.IsNull())
3477 std::cout << "Error: no active view!\n";
3482 std::cout << "Error: wrong syntax at command '" << theArgVec[0] << "'!\n";
3486 Handle(AIS_ColorScale) aColorScale;
3487 if (GetMapOfAIS().IsBound2 (theArgVec[1]))
3489 // find existing object
3490 aColorScale = Handle(AIS_ColorScale)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
3491 if (aColorScale.IsNull())
3493 std::cout << "Error: object '" << theArgVec[1] << "'is already defined and is not a color scale!\n";
3500 if (aColorScale.IsNull())
3502 std::cout << "Syntax error: colorscale with a given name does not exist.\n";
3506 theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n"
3507 << "Min range: " << aColorScale->GetMin() << "\n"
3508 << "Max range: " << aColorScale->GetMax() << "\n"
3509 << "Number of intervals: " << aColorScale->GetNumberOfIntervals() << "\n"
3510 << "Text height: " << aColorScale->GetTextHeight() << "\n"
3511 << "Color scale position: " << aColorScale->GetXPosition() << " " << aColorScale->GetYPosition() << "\n"
3512 << "Color scale title: " << aColorScale->GetTitle() << "\n"
3513 << "Label position: ";
3514 switch (aColorScale->GetLabelPosition())
3516 case Aspect_TOCSP_NONE:
3519 case Aspect_TOCSP_LEFT:
3522 case Aspect_TOCSP_RIGHT:
3525 case Aspect_TOCSP_CENTER:
3526 theDI << "Center\n";
3532 if (aColorScale.IsNull())
3534 aColorScale = new AIS_ColorScale();
3535 aColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
3536 aContext->SetTransformPersistence (aColorScale, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
3539 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
3540 for (Standard_Integer anArgIter = 2; anArgIter < theArgNb; ++anArgIter)
3542 Standard_CString anArg = theArgVec[anArgIter];
3543 TCollection_AsciiString aFlag (anArg);
3545 if (anUpdateTool.parseRedrawMode (aFlag))
3549 else if (aFlag == "-range")
3551 if (anArgIter + 3 >= theArgNb)
3553 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3557 const TCollection_AsciiString aRangeMin (theArgVec[++anArgIter]);
3558 const TCollection_AsciiString aRangeMax (theArgVec[++anArgIter]);
3559 const TCollection_AsciiString aNbIntervals (theArgVec[++anArgIter]);
3560 if (!aRangeMin.IsRealValue()
3561 || !aRangeMax.IsRealValue())
3563 std::cout << "Error: the range values should be real!\n";
3566 else if (!aNbIntervals.IsIntegerValue())
3568 std::cout << "Error: the number of intervals should be integer!\n";
3572 aColorScale->SetRange (aRangeMin.RealValue(), aRangeMax.RealValue());
3573 aColorScale->SetNumberOfIntervals (aNbIntervals.IntegerValue());
3575 else if (aFlag == "-font")
3577 if (anArgIter + 1 >= theArgNb)
3579 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3582 TCollection_AsciiString aFontArg(theArgVec[anArgIter + 1]);
3583 if (!aFontArg.IsIntegerValue())
3585 std::cout << "Error: HeightFont value should be integer!\n";
3589 aColorScale->SetTextHeight (aFontArg.IntegerValue());
3592 else if (aFlag == "-textpos")
3594 if (anArgIter + 1 >= theArgNb)
3596 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3600 TCollection_AsciiString aTextPosArg(theArgVec[++anArgIter]);
3601 aTextPosArg.LowerCase();
3602 Aspect_TypeOfColorScalePosition aLabPosition = Aspect_TOCSP_NONE;
3603 if (aTextPosArg == "none")
3605 aLabPosition = Aspect_TOCSP_NONE;
3607 else if (aTextPosArg == "left")
3609 aLabPosition = Aspect_TOCSP_LEFT;
3611 else if (aTextPosArg == "right")
3613 aLabPosition = Aspect_TOCSP_RIGHT;
3615 else if (aTextPosArg == "center")
3617 aLabPosition = Aspect_TOCSP_CENTER;
3621 std::cout << "Error: unknown position '" << aTextPosArg << "'!\n";
3624 aColorScale->SetLabelPosition (aLabPosition);
3626 else if (aFlag == "-logarithmic"
3629 if (anArgIter + 1 >= theArgNb)
3631 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3635 Standard_Boolean IsLog;
3636 if (!ViewerTest::ParseOnOff(theArgVec[++anArgIter], IsLog))
3638 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3641 aColorScale->SetLogarithmic (IsLog);
3643 else if (aFlag == "-huerange"
3646 if (anArgIter + 2 >= theArgNb)
3648 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3652 const Standard_Real aHueMin = Draw::Atof (theArgVec[++anArgIter]);
3653 const Standard_Real aHueMax = Draw::Atof (theArgVec[++anArgIter]);
3654 aColorScale->SetHueRange (aHueMin, aHueMax);
3656 else if (aFlag == "-colorrange")
3658 Quantity_Color aColorMin, aColorMax;
3659 Standard_Integer aNbParsed1 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3660 theArgVec + (anArgIter + 1),
3662 anArgIter += aNbParsed1;
3663 Standard_Integer aNbParsed2 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3664 theArgVec + (anArgIter + 1),
3666 anArgIter += aNbParsed2;
3670 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3674 aColorScale->SetColorRange (aColorMin, aColorMax);
3676 else if (aFlag == "-reversed"
3677 || aFlag == "-inverted"
3678 || aFlag == "-topdown"
3679 || aFlag == "-bottomup")
3681 Standard_Boolean toEnable = Standard_True;
3682 if (anArgIter + 1 < theArgNb
3683 && ViewerTest::ParseOnOff(theArgVec[anArgIter + 1], toEnable))
3687 aColorScale->SetReversed ((aFlag == "-topdown") ? !toEnable : toEnable);
3689 else if (aFlag == "-smooth"
3690 || aFlag == "-smoothtransition")
3692 Standard_Boolean toEnable = Standard_True;
3693 if (anArgIter + 1 < theArgNb
3694 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
3698 aColorScale->SetSmoothTransition (toEnable);
3700 else if (aFlag == "-xy")
3702 if (anArgIter + 2 >= theArgNb)
3704 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3708 const TCollection_AsciiString anX (theArgVec[++anArgIter]);
3709 const TCollection_AsciiString anY (theArgVec[++anArgIter]);
3710 if (!anX.IsIntegerValue()
3711 || !anY.IsIntegerValue())
3713 std::cout << "Error: coordinates should be integer values!\n";
3717 aColorScale->SetPosition (anX.IntegerValue(), anY.IntegerValue());
3719 else if (aFlag == "-width"
3721 || aFlag == "-breadth")
3723 if (anArgIter + 1 >= theArgNb)
3725 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3729 const TCollection_AsciiString aBreadth (theArgVec[++anArgIter]);
3730 if (!aBreadth.IsIntegerValue())
3732 std::cout << "Error: a width should be an integer value!\n";
3735 aColorScale->SetBreadth (aBreadth.IntegerValue());
3737 else if (aFlag == "-height"
3740 if (anArgIter + 1 >= theArgNb)
3742 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3746 const TCollection_AsciiString aHeight (theArgVec[++anArgIter]);
3747 if (!aHeight.IsIntegerValue())
3749 std::cout << "Error: a width should be an integer value!\n";
3752 aColorScale->SetHeight (aHeight.IntegerValue());
3754 else if (aFlag == "-color")
3756 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
3758 std::cout << "Error: wrong color type! Call -colors before to set user-specified colors!\n";
3761 else if (anArgIter + 2 >= theArgNb)
3763 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3767 const TCollection_AsciiString anInd (theArgVec[++anArgIter]);
3768 if (!anInd.IsIntegerValue())
3770 std::cout << "Error: Index value should be integer!\n";
3773 const Standard_Integer anIndex = anInd.IntegerValue();
3774 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals())
3776 std::cout << "Error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals() <<"!\n";
3780 Quantity_Color aColor;
3781 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3782 theArgVec + (anArgIter + 1),
3786 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3789 aColorScale->SetIntervalColor (aColor, anIndex);
3790 aColorScale->SetColorType (Aspect_TOCSD_USER);
3791 anArgIter += aNbParsed;
3793 else if (aFlag == "-label")
3795 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
3797 std::cout << "Error: wrong label type! Call -labels before to set user-specified labels!\n";
3800 else if (anArgIter + 2 >= theArgNb)
3802 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3806 Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]);
3807 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals() + 1)
3809 std::cout << "Error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals() + 1 <<"!\n";
3813 TCollection_ExtendedString aText (theArgVec[anArgIter + 2]);
3814 aColorScale->SetLabel (aText, anIndex);
3815 aColorScale->SetLabelType (Aspect_TOCSD_USER);
3818 else if (aFlag == "-labelat"
3819 || aFlag == "-labat"
3820 || aFlag == "-labelatborder"
3821 || aFlag == "-labatborder"
3822 || aFlag == "-labelatcenter"
3823 || aFlag == "-labatcenter")
3825 Standard_Boolean toEnable = Standard_True;
3826 if (aFlag == "-labelat"
3827 || aFlag == "-labat")
3829 Standard_Integer aLabAtBorder = -1;
3830 if (++anArgIter >= theArgNb)
3832 TCollection_AsciiString anAtBorder (theArgVec[anArgIter]);
3833 anAtBorder.LowerCase();
3834 if (anAtBorder == "border")
3838 else if (anAtBorder == "center")
3843 if (aLabAtBorder == -1)
3845 std::cout << "Syntax error at argument '" << anArg << "'!\n";
3848 toEnable = (aLabAtBorder == 1);
3850 else if (anArgIter + 1 < theArgNb
3851 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
3855 aColorScale->SetLabelAtBorder (aFlag == "-labelatcenter"
3856 || aFlag == "-labatcenter"
3860 else if (aFlag == "-colors")
3862 Aspect_SequenceOfColor aSeq;
3865 Quantity_Color aColor;
3866 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3867 theArgVec + (anArgIter + 1),
3873 anArgIter += aNbParsed;
3874 aSeq.Append (aColor);
3876 if (aSeq.Length() != aColorScale->GetNumberOfIntervals())
3878 std::cout << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the "
3879 << aColorScale->GetNumberOfIntervals() << " intervals\n";
3883 aColorScale->SetColors (aSeq);
3884 aColorScale->SetColorType (Aspect_TOCSD_USER);
3886 else if (aFlag == "-labels"
3887 || aFlag == "-freelabels")
3889 if (anArgIter + 1 >= theArgNb)
3891 std::cout << "Syntax error at argument '" << anArg << "'!\n";
3895 Standard_Integer aNbLabels = aColorScale->IsLabelAtBorder()
3896 ? aColorScale->GetNumberOfIntervals() + 1
3897 : aColorScale->GetNumberOfIntervals();
3898 if (aFlag == "-freelabels")
3901 aNbLabels = Draw::Atoi (theArgVec[anArgIter]);
3903 if (anArgIter + aNbLabels >= theArgNb)
3905 std::cout << "Error: not enough arguments! " << aNbLabels << " text labels are expected.\n";
3909 TColStd_SequenceOfExtendedString aSeq;
3910 for (Standard_Integer aLabelIter = 0; aLabelIter < aNbLabels; ++aLabelIter)
3912 aSeq.Append (TCollection_ExtendedString (theArgVec[++anArgIter]));
3914 aColorScale->SetLabels (aSeq);
3915 aColorScale->SetLabelType (Aspect_TOCSD_USER);
3917 else if (aFlag == "-title")
3919 if (anArgIter + 1 >= theArgNb)
3921 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3925 Standard_Boolean isTwoArgs = Standard_False;
3926 if (anArgIter + 2 < theArgNb)
3928 TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]);
3929 aSecondArg.LowerCase();
3930 Standard_DISABLE_DEPRECATION_WARNINGS
3931 if (aSecondArg == "none")
3933 aColorScale->SetTitlePosition (Aspect_TOCSP_NONE);
3934 isTwoArgs = Standard_True;
3936 else if (aSecondArg == "left")
3938 aColorScale->SetTitlePosition (Aspect_TOCSP_LEFT);
3939 isTwoArgs = Standard_True;
3941 else if (aSecondArg == "right")
3943 aColorScale->SetTitlePosition (Aspect_TOCSP_RIGHT);
3944 isTwoArgs = Standard_True;
3946 else if (aSecondArg == "center")
3948 aColorScale->SetTitlePosition (Aspect_TOCSP_CENTER);
3949 isTwoArgs = Standard_True;
3951 Standard_ENABLE_DEPRECATION_WARNINGS
3954 aColorScale->SetTitle (theArgVec[anArgIter + 1]);
3961 else if (aFlag == "-demoversion"
3962 || aFlag == "-demo")
3964 aColorScale->SetPosition (0, 0);
3965 aColorScale->SetTextHeight (16);
3966 aColorScale->SetRange (0.0, 100.0);
3967 aColorScale->SetNumberOfIntervals (10);
3968 aColorScale->SetBreadth (0);
3969 aColorScale->SetHeight (0);
3970 aColorScale->SetLabelPosition (Aspect_TOCSP_RIGHT);
3971 aColorScale->SetColorType (Aspect_TOCSD_AUTO);
3972 aColorScale->SetLabelType (Aspect_TOCSD_AUTO);
3974 else if (aFlag == "-findcolor")
3976 if (anArgIter + 1 >= theArgNb)
3978 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3982 TCollection_AsciiString anArg1 (theArgVec[++anArgIter]);
3984 if (!anArg1.IsRealValue())
3986 std::cout << "Error: the value should be real!\n";
3990 Quantity_Color aColor;
3991 aColorScale->FindColor (anArg1.RealValue(), aColor);
3992 theDI << Quantity_Color::StringName (aColor.Name());
3997 std::cout << "Error: wrong syntax at " << anArg << " - unknown argument!\n";
4002 Standard_Integer aWinWidth = 0, aWinHeight = 0;
4003 aView->Window()->Size (aWinWidth, aWinHeight);
4004 if (aColorScale->GetBreadth() == 0)
4006 aColorScale->SetBreadth (aWinWidth);
4008 if (aColorScale->GetHeight() == 0)
4010 aColorScale->SetHeight (aWinHeight);
4012 aColorScale->SetToUpdate();
4013 ViewerTest::Display (theArgVec[1], aColorScale, Standard_False, Standard_True);
4017 //==============================================================================
4018 //function : VGraduatedTrihedron
4019 //purpose : Displays or hides a graduated trihedron
4020 //==============================================================================
4021 static Standard_Boolean GetColor (const TCollection_AsciiString& theValue,
4022 Quantity_Color& theColor)
4024 Quantity_NameOfColor aColorName;
4025 TCollection_AsciiString aVal = theValue;
4027 if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName))
4029 return Standard_False;
4031 theColor = Quantity_Color (aColorName);
4032 return Standard_True;
4035 static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs)
4039 std::cout << theArgs[0] << " error: wrong number of parameters. Type 'help"
4040 << theArgs[0] <<"' for more information.\n";
4041 return 1; //TCL_ERROR
4044 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
4045 TCollection_AsciiString aParseKey;
4046 for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt)
4048 TCollection_AsciiString anArg (theArgs [anArgIt]);
4050 if (anArg.Value (1) == '-' && !anArg.IsRealValue())
4053 aParseKey.Remove (1);
4054 aParseKey.LowerCase();
4055 aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
4059 if (aParseKey.IsEmpty())
4064 aMapOfArgs(aParseKey)->Append (anArg);
4068 for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
4069 aMapIt.More(); aMapIt.Next())
4071 const TCollection_AsciiString& aKey = aMapIt.Key();
4072 const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
4074 // Bool key, without arguments
4075 if ((aKey.IsEqual ("on") || aKey.IsEqual ("off"))
4076 && anArgs->IsEmpty())
4082 if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname"))
4083 && anArgs->Length() == 1)
4089 if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname")
4090 || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks")
4091 || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues")
4092 || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes"))
4093 && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off")))
4098 // One string argument
4099 if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor")
4100 || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor"))
4101 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4106 // One integer argument
4107 if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks")
4108 || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength")
4109 || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset")
4110 || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset"))
4111 && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue())
4116 // One real argument
4117 if ( aKey.IsEqual ("arrowlength")
4118 && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue()))
4123 // Two string arguments
4124 if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont"))
4125 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4130 TCollection_AsciiString aLowerKey;
4133 aLowerKey.LowerCase();
4134 std::cout << theArgs[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n";
4135 std::cout << "Type help for more information.\n";
4139 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
4140 if (anAISContext.IsNull())
4142 std::cout << theArgs[0] << ": please use 'vinit' command to initialize view.\n";
4146 Standard_Boolean toDisplay = Standard_True;
4147 Quantity_Color aColor;
4148 Graphic3d_GraduatedTrihedron aTrihedronData;
4149 // Process parameters
4150 Handle(TColStd_HSequenceOfAsciiString) aValues;
4151 if (aMapOfArgs.Find ("off", aValues))
4153 toDisplay = Standard_False;
4157 if (aMapOfArgs.Find ("xname", aValues))
4159 aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1));
4161 if (aMapOfArgs.Find ("yname", aValues))
4163 aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1));
4165 if (aMapOfArgs.Find ("zname", aValues))
4167 aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1));
4169 if (aMapOfArgs.Find ("xdrawname", aValues))
4171 aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
4173 if (aMapOfArgs.Find ("ydrawname", aValues))
4175 aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
4177 if (aMapOfArgs.Find ("zdrawname", aValues))
4179 aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
4181 if (aMapOfArgs.Find ("xnameoffset", aValues))
4183 aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
4185 if (aMapOfArgs.Find ("ynameoffset", aValues))
4187 aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
4189 if (aMapOfArgs.Find ("znameoffset", aValues))
4191 aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
4195 if (aMapOfArgs.Find ("xnamecolor", aValues))
4197 if (!GetColor (aValues->Value(1), aColor))
4199 std::cout << theArgs[0] << "error: -xnamecolor wrong color name.\n";
4202 aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor);
4204 if (aMapOfArgs.Find ("ynamecolor", aValues))
4206 if (!GetColor (aValues->Value(1), aColor))
4208 std::cout << theArgs[0] << "error: -ynamecolor wrong color name.\n";
4211 aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor);
4213 if (aMapOfArgs.Find ("znamecolor", aValues))
4215 if (!GetColor (aValues->Value(1), aColor))
4217 std::cout << theArgs[0] << "error: -znamecolor wrong color name.\n";
4220 aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor);
4222 if (aMapOfArgs.Find ("xcolor", aValues))
4224 if (!GetColor (aValues->Value(1), aColor))
4226 std::cout << theArgs[0] << "error: -xcolor wrong color name.\n";
4229 aTrihedronData.ChangeXAxisAspect().SetColor (aColor);
4231 if (aMapOfArgs.Find ("ycolor", aValues))
4233 if (!GetColor (aValues->Value(1), aColor))
4235 std::cout << theArgs[0] << "error: -ycolor wrong color name.\n";
4238 aTrihedronData.ChangeYAxisAspect().SetColor (aColor);
4240 if (aMapOfArgs.Find ("zcolor", aValues))
4242 if (!GetColor (aValues->Value(1), aColor))
4244 std::cout << theArgs[0] << "error: -zcolor wrong color name.\n";
4247 aTrihedronData.ChangeZAxisAspect().SetColor (aColor);
4251 if (aMapOfArgs.Find ("xticks", aValues))
4253 aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4255 if (aMapOfArgs.Find ("yticks", aValues))
4257 aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4259 if (aMapOfArgs.Find ("zticks", aValues))
4261 aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4263 if (aMapOfArgs.Find ("xticklength", aValues))
4265 aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4267 if (aMapOfArgs.Find ("yticklength", aValues))
4269 aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4271 if (aMapOfArgs.Find ("zticklength", aValues))
4273 aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4275 if (aMapOfArgs.Find ("xdrawticks", aValues))
4277 aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4279 if (aMapOfArgs.Find ("ydrawticks", aValues))
4281 aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4283 if (aMapOfArgs.Find ("zdrawticks", aValues))
4285 aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4289 if (aMapOfArgs.Find ("xdrawvalues", aValues))
4291 aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4293 if (aMapOfArgs.Find ("ydrawvalues", aValues))
4295 aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4297 if (aMapOfArgs.Find ("zdrawvalues", aValues))
4299 aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4301 if (aMapOfArgs.Find ("xvaluesoffset", aValues))
4303 aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4305 if (aMapOfArgs.Find ("yvaluesoffset", aValues))
4307 aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4309 if (aMapOfArgs.Find ("zvaluesoffset", aValues))
4311 aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4315 if (aMapOfArgs.Find ("arrowlength", aValues))
4317 aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue());
4321 if (aMapOfArgs.Find ("namefont", aValues))
4323 aTrihedronData.SetNamesFont (aValues->Value(1));
4325 if (aMapOfArgs.Find ("valuesfont", aValues))
4327 aTrihedronData.SetValuesFont (aValues->Value(1));
4330 if (aMapOfArgs.Find ("drawgrid", aValues))
4332 aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on"));
4334 if (aMapOfArgs.Find ("drawaxes", aValues))
4336 aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on"));
4339 // The final step: display of erase trihedron
4342 ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData);
4346 ViewerTest::CurrentView()->GraduatedTrihedronErase();
4349 ViewerTest::GetAISContext()->UpdateCurrentViewer();
4350 ViewerTest::CurrentView()->Redraw();
4355 //==============================================================================
4358 //==============================================================================
4359 static int VTile (Draw_Interpretor& theDI,
4360 Standard_Integer theArgNb,
4361 const char** theArgVec)
4363 Handle(V3d_View) aView = ViewerTest::CurrentView();
4366 std::cerr << "Error: no active viewer.\n";
4370 Graphic3d_CameraTile aTile = aView->Camera()->Tile();
4373 theDI << "Total size: " << aTile.TotalSize.x() << " " << aTile.TotalSize.y() << "\n"
4374 << "Tile size: " << aTile.TileSize.x() << " " << aTile.TileSize.y() << "\n"
4375 << "Lower left: " << aTile.Offset.x() << " " << aTile.Offset.y() << "\n";
4379 aView->Window()->Size (aTile.TileSize.x(), aTile.TileSize.y());
4380 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
4382 TCollection_AsciiString anArg (theArgVec[anArgIter]);
4384 if (anArg == "-lowerleft"
4385 || anArg == "-upperleft")
4387 if (anArgIter + 3 < theArgNb)
4389 std::cerr << "Syntax error at '" << theArgVec[anArgIter] << "'.\n";
4392 aTile.IsTopDown = (anArg == "-upperleft") == Standard_True;
4393 aTile.Offset.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
4394 aTile.Offset.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
4396 else if (anArg == "-total"
4397 || anArg == "-totalsize"
4398 || anArg == "-viewsize")
4400 if (anArgIter + 3 < theArgNb)
4402 std::cerr << "Syntax error at '" << theArgVec[anArgIter] << "'.\n";
4405 aTile.TotalSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
4406 aTile.TotalSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
4407 if (aTile.TotalSize.x() < 1
4408 || aTile.TotalSize.y() < 1)
4410 std::cerr << "Error: total size is incorrect.\n";
4414 else if (anArg == "-tilesize")
4416 if (anArgIter + 3 < theArgNb)
4418 std::cerr << "Syntax error at '" << theArgVec[anArgIter] << "'.\n";
4422 aTile.TileSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
4423 aTile.TileSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
4424 if (aTile.TileSize.x() < 1
4425 || aTile.TileSize.y() < 1)
4427 std::cerr << "Error: tile size is incorrect.\n";
4431 else if (anArg == "-unset")
4433 aView->Camera()->SetTile (Graphic3d_CameraTile());
4439 if (aTile.TileSize.x() < 1
4440 || aTile.TileSize.y() < 1)
4442 std::cerr << "Error: tile size is undefined.\n";
4445 else if (aTile.TotalSize.x() < 1
4446 || aTile.TotalSize.y() < 1)
4448 std::cerr << "Error: total size is undefined.\n";
4452 aView->Camera()->SetTile (aTile);
4457 //! Format ZLayer ID.
4458 inline const char* formZLayerId (const Standard_Integer theLayerId)
4462 case Graphic3d_ZLayerId_UNKNOWN: return "[INVALID]";
4463 case Graphic3d_ZLayerId_Default: return "[DEFAULT]";
4464 case Graphic3d_ZLayerId_Top: return "[TOP]";
4465 case Graphic3d_ZLayerId_Topmost: return "[TOPMOST]";
4466 case Graphic3d_ZLayerId_TopOSD: return "[OVERLAY]";
4467 case Graphic3d_ZLayerId_BotOSD: return "[UNDERLAY]";
4472 //! Print the ZLayer information.
4473 inline void printZLayerInfo (Draw_Interpretor& theDI,
4474 const Graphic3d_ZLayerSettings& theLayer)
4476 if (!theLayer.Name().IsEmpty())
4478 theDI << " Name: " << theLayer.Name() << "\n";
4480 if (theLayer.IsImmediate())
4482 theDI << " Immediate: TRUE\n";
4484 theDI << " Origin: " << theLayer.Origin().X() << " " << theLayer.Origin().Y() << " " << theLayer.Origin().Z() << "\n";
4485 theDI << " Depth test: " << (theLayer.ToEnableDepthTest() ? "enabled" : "disabled") << "\n";
4486 theDI << " Depth write: " << (theLayer.ToEnableDepthWrite() ? "enabled" : "disabled") << "\n";
4487 theDI << " Depth buffer clearing: " << (theLayer.ToClearDepth() ? "enabled" : "disabled") << "\n";
4488 if (theLayer.PolygonOffset().Mode != Aspect_POM_None)
4490 theDI << " Depth offset: " << theLayer.PolygonOffset().Factor << " " << theLayer.PolygonOffset().Units << "\n";
4494 //==============================================================================
4495 //function : VZLayer
4496 //purpose : Test z layer operations for v3d viewer
4497 //==============================================================================
4498 static int VZLayer (Draw_Interpretor& theDI,
4499 Standard_Integer theArgNb,
4500 const char** theArgVec)
4502 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
4503 if (aContextAIS.IsNull())
4505 std::cout << "No active viewer!\n";
4509 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
4512 TColStd_SequenceOfInteger aLayers;
4513 aViewer->GetAllZLayers (aLayers);
4514 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
4516 theDI << "ZLayer " << aLayeriter.Value() << " " << formZLayerId (aLayeriter.Value()) << "\n";
4517 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
4518 printZLayerInfo (theDI, aSettings);
4523 Standard_Integer anArgIter = 1;
4524 Standard_Integer aLayerId = Graphic3d_ZLayerId_UNKNOWN;
4525 ViewerTest_AutoUpdater anUpdateTool (aContextAIS, ViewerTest::CurrentView());
4526 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
4531 TCollection_AsciiString aFirstArg (theArgVec[anArgIter]);
4532 if (aFirstArg.IsIntegerValue())
4535 aLayerId = aFirstArg.IntegerValue();
4539 aFirstArg.LowerCase();
4540 if (aFirstArg == "default"
4541 || aFirstArg == "def")
4543 aLayerId = Graphic3d_ZLayerId_Default;
4546 else if (aFirstArg == "top")
4548 aLayerId = Graphic3d_ZLayerId_Top;
4551 else if (aFirstArg == "topmost")
4553 aLayerId = Graphic3d_ZLayerId_Topmost;
4556 else if (aFirstArg == "overlay"
4557 || aFirstArg == "toposd")
4559 aLayerId = Graphic3d_ZLayerId_TopOSD;
4562 else if (aFirstArg == "underlay"
4563 || aFirstArg == "botosd")
4565 aLayerId = Graphic3d_ZLayerId_BotOSD;
4570 TColStd_SequenceOfInteger aLayers;
4571 aViewer->GetAllZLayers (aLayers);
4572 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
4574 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
4575 if (TCollection_AsciiString::IsSameString (aSettings.Name(), aFirstArg, Standard_False))
4577 aLayerId = aLayeriter.Value();
4585 for (; anArgIter < theArgNb; ++anArgIter)
4587 // perform operation
4588 TCollection_AsciiString anArg (theArgVec[anArgIter]);
4590 if (anUpdateTool.parseRedrawMode (anArg))
4594 else if (anArg == "-add"
4597 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
4598 if (!aViewer->AddZLayer (aLayerId))
4600 std::cout << "Error: can not add a new z layer!\n";
4606 else if (anArg == "-del"
4607 || anArg == "-delete"
4610 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4612 if (++anArgIter >= theArgNb)
4614 std::cout << "Syntax error: id of z layer to remove is missing\n";
4618 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
4621 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN
4622 || aLayerId == Graphic3d_ZLayerId_Default
4623 || aLayerId == Graphic3d_ZLayerId_Top
4624 || aLayerId == Graphic3d_ZLayerId_Topmost
4625 || aLayerId == Graphic3d_ZLayerId_TopOSD
4626 || aLayerId == Graphic3d_ZLayerId_BotOSD)
4628 std::cout << "Syntax error: standard Z layer can not be removed\n";
4632 // move all object displayed in removing layer to default layer
4633 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
4634 anObjIter.More(); anObjIter.Next())
4636 Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anObjIter.Key1());
4638 || aPrs->ZLayer() != aLayerId)
4642 aPrs->SetZLayer (Graphic3d_ZLayerId_Default);
4645 if (!aViewer->RemoveZLayer (aLayerId))
4647 std::cout << "Z layer can not be removed!\n";
4651 theDI << aLayerId << " ";
4654 else if (anArg == "-get"
4657 TColStd_SequenceOfInteger aLayers;
4658 aViewer->GetAllZLayers (aLayers);
4659 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
4661 theDI << aLayeriter.Value() << " ";
4666 else if (anArg == "-name")
4668 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4670 std::cout << "Syntax error: id of Z layer is missing\n";
4674 if (++anArgIter >= theArgNb)
4676 std::cout << "Syntax error: name is missing\n";
4680 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4681 aSettings.SetName (theArgVec[anArgIter]);
4682 aViewer->SetZLayerSettings (aLayerId, aSettings);
4684 else if (anArg == "-origin")
4686 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4688 std::cout << "Syntax error: id of Z layer is missing\n";
4692 if (anArgIter + 2 >= theArgNb)
4694 std::cout << "Syntax error: origin coordinates are missing\n";
4698 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4700 anOrigin.SetX (Draw::Atof (theArgVec[anArgIter + 1]));
4701 anOrigin.SetY (Draw::Atof (theArgVec[anArgIter + 2]));
4702 anOrigin.SetZ (0.0);
4703 if (anArgIter + 3 < theArgNb)
4705 anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter + 3]));
4712 aSettings.SetOrigin (anOrigin);
4713 aViewer->SetZLayerSettings (aLayerId, aSettings);
4715 else if (anArg == "-settings"
4716 || anArg == "settings")
4718 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4720 if (++anArgIter >= theArgNb)
4722 std::cout << "Syntax error: id of Z layer is missing\n";
4726 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
4729 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4730 printZLayerInfo (theDI, aSettings);
4732 else if (anArg == "-enable"
4733 || anArg == "enable"
4734 || anArg == "-disable"
4735 || anArg == "disable")
4737 const Standard_Boolean toEnable = anArg == "-enable"
4738 || anArg == "enable";
4739 if (++anArgIter >= theArgNb)
4741 std::cout << "Syntax error: option name is missing\n";
4745 TCollection_AsciiString aSubOp (theArgVec[anArgIter]);
4747 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4749 if (++anArgIter >= theArgNb)
4751 std::cout << "Syntax error: id of Z layer is missing\n";
4755 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
4758 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4759 if (aSubOp == "depthtest"
4760 || aSubOp == "test")
4762 aSettings.SetEnableDepthTest (toEnable);
4764 else if (aSubOp == "depthwrite"
4765 || aSubOp == "write")
4767 aSettings.SetEnableDepthWrite (toEnable);
4769 else if (aSubOp == "depthclear"
4770 || aSubOp == "clear")
4772 aSettings.SetClearDepth (toEnable);
4774 else if (aSubOp == "depthoffset"
4775 || aSubOp == "offset")
4777 Graphic3d_PolygonOffset aParams;
4778 aParams.Mode = toEnable ? Aspect_POM_Fill : Aspect_POM_None;
4781 if (anArgIter + 2 >= theArgNb)
4783 std::cout << "Syntax error: factor and units values for depth offset are missing\n";
4787 aParams.Factor = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
4788 aParams.Units = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
4790 aSettings.SetPolygonOffset (aParams);
4792 else if (aSubOp == "positiveoffset"
4793 || aSubOp == "poffset")
4797 aSettings.SetDepthOffsetPositive();
4801 aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
4804 else if (aSubOp == "negativeoffset"
4805 || aSubOp == "noffset")
4809 aSettings.SetDepthOffsetNegative();
4813 aSettings.SetPolygonOffset(Graphic3d_PolygonOffset());
4816 else if (aSubOp == "textureenv")
4818 aSettings.SetEnvironmentTexture (toEnable);
4821 aViewer->SetZLayerSettings (aLayerId, aSettings);
4825 std::cout << "Syntax error: unknown option " << theArgVec[anArgIter] << "\n";
4833 // The interactive presentation of 2d layer item
4834 // for "vlayerline" command it provides a presentation of
4835 // line with user-defined linewidth, linetype and transparency.
4836 class V3d_LineItem : public AIS_InteractiveObject
4840 DEFINE_STANDARD_RTTI_INLINE(V3d_LineItem,AIS_InteractiveObject)
4843 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
4844 Standard_Real X2, Standard_Real Y2,
4845 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
4846 Standard_Real theWidth = 0.5,
4847 Standard_Real theTransp = 1.0);
4851 void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
4852 const Handle(Prs3d_Presentation)& thePresentation,
4853 const Standard_Integer theMode) Standard_OVERRIDE;
4855 void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
4856 const Standard_Integer /*aMode*/) Standard_OVERRIDE
4861 Standard_Real myX1, myY1, myX2, myY2;
4862 Aspect_TypeOfLine myType;
4863 Standard_Real myWidth;
4866 // default constructor for line item
4867 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
4868 Standard_Real X2, Standard_Real Y2,
4869 Aspect_TypeOfLine theType,
4870 Standard_Real theWidth,
4871 Standard_Real theTransp) :
4872 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2),
4873 myType(theType), myWidth(theWidth)
4875 SetTransparency (1-theTransp);
4879 void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
4880 const Handle(Prs3d_Presentation)& thePresentation,
4881 const Standard_Integer /*theMode*/)
4883 thePresentation->Clear();
4884 Quantity_Color aColor (1.0, 0, 0, Quantity_TOC_RGB);
4885 Standard_Integer aWidth, aHeight;
4886 ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
4887 Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
4888 Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
4889 aPrim->AddVertex(myX1, aHeight-myY1, 0.);
4890 aPrim->AddVertex(myX2, aHeight-myY2, 0.);
4891 Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (aColor, (Aspect_TypeOfLine)myType, myWidth);
4892 aGroup->SetPrimitivesAspect (anAspect->Aspect());
4893 aGroup->AddPrimitiveArray (aPrim);
4896 //=============================================================================
4897 //function : VLayerLine
4898 //purpose : Draws line in the v3d view layer with given attributes: linetype,
4899 // : linewidth, transparency coefficient
4900 //============================================================================
4901 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
4903 // get the active view
4904 Handle(V3d_View) aView = ViewerTest::CurrentView();
4907 di << "Call vinit before!\n";
4912 di << "Use: " << argv[0];
4913 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
4914 di << " linetype : { 0 | 1 | 2 | 3 } \n";
4915 di << " 0 - solid \n";
4916 di << " 1 - dashed \n";
4917 di << " 2 - dot \n";
4918 di << " 3 - dashdot\n";
4919 di << " transparency : { 0.0 - 1.0 } \n";
4920 di << " 0.0 - transparent\n";
4921 di << " 1.0 - visible \n";
4925 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4926 // get the input params
4927 Standard_Real X1 = Draw::Atof(argv[1]);
4928 Standard_Real Y1 = Draw::Atof(argv[2]);
4929 Standard_Real X2 = Draw::Atof(argv[3]);
4930 Standard_Real Y2 = Draw::Atof(argv[4]);
4932 Standard_Real aWidth = 0.5;
4933 Standard_Real aTransparency = 1.0;
4937 aWidth = Draw::Atof(argv[5]);
4939 // select appropriate line type
4940 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
4942 && !ViewerTest::ParseLineType (argv[6], aLineType))
4944 std::cout << "Syntax error: unknown line type '" << argv[6] << "'\n";
4951 aTransparency = Draw::Atof(argv[7]);
4952 if (aTransparency < 0 || aTransparency > 1.0)
4953 aTransparency = 1.0;
4956 static Handle (V3d_LineItem) aLine;
4957 if (!aLine.IsNull())
4959 aContext->Erase (aLine, Standard_False);
4961 aLine = new V3d_LineItem (X1, Y1, X2, Y2,
4965 aContext->SetTransformPersistence (aLine, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
4966 aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD);
4967 aLine->SetToUpdate();
4968 aContext->Display (aLine, Standard_True);
4974 //==============================================================================
4977 //==============================================================================
4979 static int VGrid (Draw_Interpretor& /*theDI*/,
4980 Standard_Integer theArgNb,
4981 const char** theArgVec)
4983 // get the active view
4984 Handle(V3d_View) aView = ViewerTest::CurrentView();
4985 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
4986 if (aView.IsNull() || aViewer.IsNull())
4988 std::cerr << "No active view. Please call vinit.\n";
4992 Aspect_GridType aType = aViewer->GridType();
4993 Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
4994 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
4995 Standard_Integer anIter = 1;
4996 for (; anIter < theArgNb; ++anIter)
4998 const char* aValue = theArgVec[anIter];
4999 if (anUpdateTool.parseRedrawMode (aValue))
5003 else if (*aValue == 'r')
5005 aType = Aspect_GT_Rectangular;
5007 else if (*aValue == 'c')
5009 aType = Aspect_GT_Circular;
5011 else if (*aValue == 'l')
5013 aMode = Aspect_GDM_Lines;
5015 else if (*aValue == 'p')
5017 aMode = Aspect_GDM_Points;
5019 else if (strcmp (aValue, "off" ) == 0)
5021 aViewer->DeactivateGrid();
5030 Standard_Integer aTail = (theArgNb - anIter);
5033 aViewer->ActivateGrid (aType, aMode);
5036 else if (aTail != 2 && aTail != 5)
5038 std::cerr << "Incorrect arguments number! Usage:\n"
5039 << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n";
5043 Standard_Real anOriginX, anOriginY, aRotAngle;
5044 if (aType == Aspect_GT_Rectangular)
5046 Standard_Real aRStepX, aRStepY;
5047 aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
5049 anOriginX = Draw::Atof (theArgVec[anIter++]);
5050 anOriginY = Draw::Atof (theArgVec[anIter++]);
5053 aRStepX = Draw::Atof (theArgVec[anIter++]);
5054 aRStepY = Draw::Atof (theArgVec[anIter++]);
5055 aRotAngle = Draw::Atof (theArgVec[anIter++]);
5057 aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
5058 aViewer->ActivateGrid (aType, aMode);
5060 else if (aType == Aspect_GT_Circular)
5062 Standard_Real aRadiusStep;
5063 Standard_Integer aDivisionNumber;
5064 aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
5066 anOriginX = Draw::Atof (theArgVec[anIter++]);
5067 anOriginY = Draw::Atof (theArgVec[anIter++]);
5070 aRadiusStep = Draw::Atof (theArgVec[anIter++]);
5071 aDivisionNumber = Draw::Atoi (theArgVec[anIter++]);
5072 aRotAngle = Draw::Atof (theArgVec[anIter++]);
5075 aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
5076 aViewer->ActivateGrid (aType, aMode);
5082 //==============================================================================
5083 //function : VPriviledgedPlane
5085 //==============================================================================
5087 static int VPriviledgedPlane (Draw_Interpretor& theDI,
5088 Standard_Integer theArgNb,
5089 const char** theArgVec)
5091 if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10)
5093 std::cerr << "Error: wrong number of arguments! See usage:\n";
5094 theDI.PrintHelp (theArgVec[0]);
5098 // get the active viewer
5099 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
5100 if (aViewer.IsNull())
5102 std::cerr << "Error: no active viewer. Please call vinit.\n";
5108 gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane();
5109 const gp_Pnt& anOrig = aPriviledgedPlane.Location();
5110 const gp_Dir& aNorm = aPriviledgedPlane.Direction();
5111 const gp_Dir& aXDir = aPriviledgedPlane.XDirection();
5112 theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " "
5113 << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " "
5114 << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n";
5118 Standard_Integer anArgIdx = 1;
5119 Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]);
5120 Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]);
5121 Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]);
5122 Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]);
5123 Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]);
5124 Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]);
5126 gp_Ax3 aPriviledgedPlane;
5127 gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ);
5128 gp_Dir aNorm (aNormX, aNormY, aNormZ);
5131 Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]);
5132 Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]);
5133 Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]);
5134 gp_Dir aXDir (aXDirX, aXDirY, aXDirZ);
5135 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir);
5139 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm);
5142 aViewer->SetPrivilegedPlane (aPriviledgedPlane);
5147 //==============================================================================
5148 //function : VConvert
5150 //==============================================================================
5152 static int VConvert (Draw_Interpretor& theDI,
5153 Standard_Integer theArgNb,
5154 const char** theArgVec)
5156 // get the active view
5157 Handle(V3d_View) aView = ViewerTest::CurrentView();
5160 std::cerr << "Error: no active view. Please call vinit.\n";
5164 enum { Model, Ray, View, Window, Grid } aMode = Model;
5166 // access coordinate arguments
5167 TColStd_SequenceOfReal aCoord;
5168 Standard_Integer anArgIdx = 1;
5169 for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx)
5171 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
5172 if (!anArg.IsRealValue())
5176 aCoord.Append (anArg.RealValue());
5179 // non-numeric argument too early
5180 if (aCoord.IsEmpty())
5182 std::cerr << "Error: wrong number of arguments! See usage:\n";
5183 theDI.PrintHelp (theArgVec[0]);
5187 // collect all other arguments and options
5188 for (; anArgIdx < theArgNb; ++anArgIdx)
5190 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
5192 if (anArg == "window") aMode = Window;
5193 else if (anArg == "view") aMode = View;
5194 else if (anArg == "grid") aMode = Grid;
5195 else if (anArg == "ray") aMode = Ray;
5198 std::cerr << "Error: wrong argument " << anArg << "! See usage:\n";
5199 theDI.PrintHelp (theArgVec[0]);
5204 // complete input checks
5205 if ((aCoord.Length() == 1 && theArgNb > 3) ||
5206 (aCoord.Length() == 2 && theArgNb > 4) ||
5207 (aCoord.Length() == 3 && theArgNb > 5))
5209 std::cerr << "Error: wrong number of arguments! See usage:\n";
5210 theDI.PrintHelp (theArgVec[0]);
5214 Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
5215 Standard_Integer aXYp[2] = {0, 0};
5217 // convert one-dimensional coordinate
5218 if (aCoord.Length() == 1)
5222 case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer)aCoord (1)); return 0;
5223 case Window : theDI << "Window Vp: " << aView->Convert (aCoord (1)); return 0;
5225 std::cerr << "Error: wrong arguments! See usage:\n";
5226 theDI.PrintHelp (theArgVec[0]);
5231 // convert 2D coordinates from projection or view reference space
5232 if (aCoord.Length() == 2)
5237 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
5238 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
5242 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]);
5243 theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n";
5247 aView->Convert (aCoord (1), aCoord (2), aXYp[0], aXYp[1]);
5248 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
5252 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
5253 aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]);
5254 theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
5258 aView->ConvertWithProj ((Standard_Integer) aCoord (1),
5259 (Standard_Integer) aCoord (2),
5260 aXYZ[0], aXYZ[1], aXYZ[2],
5261 aXYZ[3], aXYZ[4], aXYZ[5]);
5262 theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
5266 std::cerr << "Error: wrong arguments! See usage:\n";
5267 theDI.PrintHelp (theArgVec[0]);
5272 // convert 3D coordinates from view reference space
5273 else if (aCoord.Length() == 3)
5278 aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]);
5279 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
5283 aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]);
5284 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
5288 std::cerr << "Error: wrong arguments! See usage:\n";
5289 theDI.PrintHelp (theArgVec[0]);
5297 //==============================================================================
5300 //==============================================================================
5302 static int VFps (Draw_Interpretor& theDI,
5303 Standard_Integer theArgNb,
5304 const char** theArgVec)
5306 // get the active view
5307 Handle(V3d_View) aView = ViewerTest::CurrentView();
5310 std::cerr << "No active view. Please call vinit.\n";
5314 Standard_Integer aFramesNb = (theArgNb > 1) ? Draw::Atoi(theArgVec[1]) : 100;
5317 std::cerr << "Incorrect arguments!\n";
5321 // the time is meaningless for first call
5322 // due to async OpenGl rendering
5325 // redraw view in loop to estimate average values
5328 for (Standard_Integer anInter = 0; anInter < aFramesNb; ++anInter)
5334 const Standard_Real aTime = aTimer.ElapsedTime();
5335 aTimer.OSD_Chronometer::Show (aCpu);
5337 const Standard_Real aFpsAver = Standard_Real(aFramesNb) / aTime;
5338 const Standard_Real aCpuAver = aCpu / Standard_Real(aFramesNb);
5340 // return statistics
5341 theDI << "FPS: " << aFpsAver << "\n"
5342 << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
5344 // compute additional statistics in ray-tracing mode
5345 Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
5347 if (aParams.Method == Graphic3d_RM_RAYTRACING)
5349 Standard_Integer aSizeX;
5350 Standard_Integer aSizeY;
5352 aView->Window()->Size (aSizeX, aSizeY);
5354 // 1 shadow ray and 1 secondary ray pew each bounce
5355 const Standard_Real aMRays = aSizeX * aSizeY * aFpsAver * aParams.RaytracingDepth * 2 / 1.0e6f;
5357 theDI << "MRays/sec (upper bound): " << aMRays << "\n";
5363 //==============================================================================
5364 //function : VGlDebug
5366 //==============================================================================
5368 static int VGlDebug (Draw_Interpretor& theDI,
5369 Standard_Integer theArgNb,
5370 const char** theArgVec)
5372 Handle(OpenGl_GraphicDriver) aDriver;
5373 Handle(V3d_View) aView = ViewerTest::CurrentView();
5374 if (!aView.IsNull())
5376 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
5378 OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps;
5379 OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
5383 TCollection_AsciiString aDebActive, aSyncActive;
5390 Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
5391 "GL_ARB_debug_output");
5392 aDebActive = isActive ? " (active)" : " (inactive)";
5395 // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
5396 aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
5400 theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n"
5401 << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n"
5402 << "glslWarn:" << (aCaps->glslWarnings ? "1" : "0") << "\n"
5403 << "extraMsg:" << (aCaps->suppressExtraMsg ? "0" : "1") << "\n";
5407 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5409 Standard_CString anArg = theArgVec[anArgIter];
5410 TCollection_AsciiString anArgCase (anArg);
5411 anArgCase.LowerCase();
5412 Standard_Boolean toEnableDebug = Standard_True;
5413 if (anArgCase == "-glsl"
5414 || anArgCase == "-glslwarn"
5415 || anArgCase == "-glslwarns"
5416 || anArgCase == "-glslwarnings")
5418 Standard_Boolean toShowWarns = Standard_True;
5419 if (++anArgIter < theArgNb
5420 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShowWarns))
5424 aDefCaps->glslWarnings = toShowWarns;
5427 aCaps->glslWarnings = toShowWarns;
5430 else if (anArgCase == "-extra"
5431 || anArgCase == "-extramsg"
5432 || anArgCase == "-extramessages")
5434 Standard_Boolean toShow = Standard_True;
5435 if (++anArgIter < theArgNb
5436 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShow))
5440 aDefCaps->suppressExtraMsg = !toShow;
5443 aCaps->suppressExtraMsg = !toShow;
5446 else if (anArgCase == "-noextra"
5447 || anArgCase == "-noextramsg"
5448 || anArgCase == "-noextramessages")
5450 Standard_Boolean toSuppress = Standard_True;
5451 if (++anArgIter < theArgNb
5452 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSuppress))
5456 aDefCaps->suppressExtraMsg = toSuppress;
5459 aCaps->suppressExtraMsg = toSuppress;
5462 else if (anArgCase == "-sync")
5464 Standard_Boolean toSync = Standard_True;
5465 if (++anArgIter < theArgNb
5466 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSync))
5470 aDefCaps->contextSyncDebug = toSync;
5473 aDefCaps->contextDebug = Standard_True;
5476 else if (anArgCase == "-debug")
5478 if (++anArgIter < theArgNb
5479 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
5483 aDefCaps->contextDebug = toEnableDebug;
5485 else if (ViewerTest::ParseOnOff (anArg, toEnableDebug)
5486 && (anArgIter + 1 == theArgNb))
5488 // simple alias to turn on almost everything
5489 aDefCaps->contextDebug = toEnableDebug;
5490 aDefCaps->contextSyncDebug = toEnableDebug;
5491 aDefCaps->glslWarnings = toEnableDebug;
5495 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
5503 //==============================================================================
5506 //==============================================================================
5508 static int VVbo (Draw_Interpretor& theDI,
5509 Standard_Integer theArgNb,
5510 const char** theArgVec)
5512 const Standard_Boolean toSet = (theArgNb > 1);
5513 const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
5516 ViewerTest_myDefaultCaps.vboDisable = toUseVbo;
5520 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5521 if (aContextAIS.IsNull())
5525 std::cerr << "No active view!\n";
5529 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
5530 if (!aDriver.IsNull())
5534 theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
5538 aDriver->ChangeOptions().vboDisable = toUseVbo;
5545 //==============================================================================
5548 //==============================================================================
5550 static int VCaps (Draw_Interpretor& theDI,
5551 Standard_Integer theArgNb,
5552 const char** theArgVec)
5554 OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps;
5555 Handle(OpenGl_GraphicDriver) aDriver;
5556 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5557 if (!aContext.IsNull())
5559 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
5560 aCaps = &aDriver->ChangeOptions();
5565 theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n";
5566 theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
5567 theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
5568 theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
5569 theDI << "VSync: " << aCaps->swapInterval << "\n";
5570 theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
5571 theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
5572 theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
5576 ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
5577 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5579 Standard_CString anArg = theArgVec[anArgIter];
5580 TCollection_AsciiString anArgCase (anArg);
5581 anArgCase.LowerCase();
5582 if (anUpdateTool.parseRedrawMode (anArg))
5586 else if (anArgCase == "-vsync"
5587 || anArgCase == "-swapinterval")
5589 Standard_Boolean toEnable = Standard_True;
5590 if (++anArgIter < theArgNb
5591 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5595 aCaps->swapInterval = toEnable;
5597 else if (anArgCase == "-ffp")
5599 Standard_Boolean toEnable = Standard_True;
5600 if (++anArgIter < theArgNb
5601 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5605 aCaps->ffpEnable = toEnable;
5607 else if (anArgCase == "-vbo")
5609 Standard_Boolean toEnable = Standard_True;
5610 if (++anArgIter < theArgNb
5611 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5615 aCaps->vboDisable = !toEnable;
5617 else if (anArgCase == "-sprite"
5618 || anArgCase == "-sprites")
5620 Standard_Boolean toEnable = Standard_True;
5621 if (++anArgIter < theArgNb
5622 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5626 aCaps->pntSpritesDisable = !toEnable;
5628 else if (anArgCase == "-softmode")
5630 Standard_Boolean toEnable = Standard_True;
5631 if (++anArgIter < theArgNb
5632 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5636 aCaps->contextNoAccel = toEnable;
5638 else if (anArgCase == "-winbuffer"
5639 || anArgCase == "-windowbuffer"
5640 || anArgCase == "-usewinbuffer"
5641 || anArgCase == "-usewindowbuffer"
5642 || anArgCase == "-usesystembuffer")
5644 Standard_Boolean toEnable = Standard_True;
5645 if (++anArgIter < theArgNb
5646 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5650 aCaps->useSystemBuffer = toEnable;
5652 else if (anArgCase == "-accel"
5653 || anArgCase == "-acceleration")
5655 Standard_Boolean toEnable = Standard_True;
5656 if (++anArgIter < theArgNb
5657 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5661 aCaps->contextNoAccel = !toEnable;
5663 else if (anArgCase == "-compat"
5664 || anArgCase == "-compatprofile"
5665 || anArgCase == "-compatible"
5666 || anArgCase == "-compatibleprofile")
5668 Standard_Boolean toEnable = Standard_True;
5669 if (++anArgIter < theArgNb
5670 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5674 aCaps->contextCompatible = toEnable;
5675 if (!aCaps->contextCompatible)
5677 aCaps->ffpEnable = Standard_False;
5680 else if (anArgCase == "-core"
5681 || anArgCase == "-coreprofile")
5683 Standard_Boolean toEnable = Standard_True;
5684 if (++anArgIter < theArgNb
5685 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5689 aCaps->contextCompatible = !toEnable;
5690 if (!aCaps->contextCompatible)
5692 aCaps->ffpEnable = Standard_False;
5695 else if (anArgCase == "-stereo"
5696 || anArgCase == "-quadbuffer")
5698 Standard_Boolean toEnable = Standard_True;
5699 if (++anArgIter < theArgNb
5700 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5704 aCaps->contextStereo = toEnable;
5708 std::cout << "Error: unknown argument '" << anArg << "'\n";
5712 if (aCaps != &ViewerTest_myDefaultCaps)
5714 ViewerTest_myDefaultCaps = *aCaps;
5719 //==============================================================================
5720 //function : VMemGpu
5722 //==============================================================================
5724 static int VMemGpu (Draw_Interpretor& theDI,
5725 Standard_Integer theArgNb,
5726 const char** theArgVec)
5729 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5730 if (aContextAIS.IsNull())
5732 std::cerr << "No active view. Please call vinit.\n";
5736 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
5737 if (aDriver.IsNull())
5739 std::cerr << "Graphic driver not available.\n";
5743 Standard_Size aFreeBytes = 0;
5744 TCollection_AsciiString anInfo;
5745 if (!aDriver->MemoryInfo (aFreeBytes, anInfo))
5747 std::cerr << "Information not available.\n";
5751 if (theArgNb > 1 && *theArgVec[1] == 'f')
5753 theDI << Standard_Real (aFreeBytes);
5763 // ==============================================================================
5764 // function : VReadPixel
5766 // ==============================================================================
5767 static int VReadPixel (Draw_Interpretor& theDI,
5768 Standard_Integer theArgNb,
5769 const char** theArgVec)
5771 // get the active view
5772 Handle(V3d_View) aView = ViewerTest::CurrentView();
5775 std::cerr << "No active view. Please call vinit.\n";
5778 else if (theArgNb < 3)
5780 std::cerr << "Usage : " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]\n";
5784 Image_Format aFormat = Image_Format_RGBA;
5785 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
5787 Standard_Integer aWidth, aHeight;
5788 aView->Window()->Size (aWidth, aHeight);
5789 const Standard_Integer anX = Draw::Atoi (theArgVec[1]);
5790 const Standard_Integer anY = Draw::Atoi (theArgVec[2]);
5791 if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight)
5793 std::cerr << "Pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")\n";
5797 Standard_Boolean toShowName = Standard_False;
5798 Standard_Boolean toShowHls = Standard_False;
5799 for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
5801 TCollection_AsciiString aParam (theArgVec[anIter]);
5803 if (aParam == "rgb")
5805 aFormat = Image_Format_RGB;
5806 aBufferType = Graphic3d_BT_RGB;
5808 else if (aParam == "hls")
5810 aFormat = Image_Format_RGB;
5811 aBufferType = Graphic3d_BT_RGB;
5812 toShowHls = Standard_True;
5814 else if (aParam == "rgbf")
5816 aFormat = Image_Format_RGBF;
5817 aBufferType = Graphic3d_BT_RGB;
5819 else if (aParam == "rgba")
5821 aFormat = Image_Format_RGBA;
5822 aBufferType = Graphic3d_BT_RGBA;
5824 else if (aParam == "rgbaf")
5826 aFormat = Image_Format_RGBAF;
5827 aBufferType = Graphic3d_BT_RGBA;
5829 else if (aParam == "depth")
5831 aFormat = Image_Format_GrayF;
5832 aBufferType = Graphic3d_BT_Depth;
5834 else if (aParam == "name")
5836 toShowName = Standard_True;
5840 Image_PixMap anImage;
5841 if (!anImage.InitTrash (aFormat, aWidth, aHeight))
5843 std::cerr << "Image allocation failed\n";
5846 else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType))
5848 std::cerr << "Image dump failed\n";
5852 Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY);
5855 if (aBufferType == Graphic3d_BT_RGBA)
5857 theDI << Quantity_Color::StringName (aColor.GetRGB().Name()) << " " << aColor.Alpha();
5861 theDI << Quantity_Color::StringName (aColor.GetRGB().Name());
5866 switch (aBufferType)
5869 case Graphic3d_BT_RGB:
5873 theDI << aColor.GetRGB().Hue() << " " << aColor.GetRGB().Light() << " " << aColor.GetRGB().Saturation();
5877 theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue();
5881 case Graphic3d_BT_RGBA:
5883 theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue() << " " << aColor.Alpha();
5886 case Graphic3d_BT_Depth:
5888 theDI << aColor.GetRGB().Red();
5897 //==============================================================================
5898 //function : VDiffImage
5899 //purpose : The draw-command compares two images.
5900 //==============================================================================
5902 static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
5906 theDI << "Not enough arguments.\n";
5911 const char* anImgPathRef = theArgVec[1];
5912 const char* anImgPathNew = theArgVec[2];
5914 // get string tolerance and check its validity
5915 Standard_Real aTolColor = Draw::Atof (theArgVec[3]);
5916 if (aTolColor < 0.0)
5918 if (aTolColor > 1.0)
5921 Standard_Boolean toBlackWhite = (Draw::Atoi (theArgVec[4]) == 1);
5922 Standard_Boolean isBorderFilterOn = (Draw::Atoi (theArgVec[5]) == 1);
5924 // image file of difference
5925 const char* aDiffImagePath = (theArgNb >= 7) ? theArgVec[6] : NULL;
5927 // compare the images
5928 Image_Diff aComparer;
5929 if (!aComparer.Init (anImgPathRef, anImgPathNew, toBlackWhite))
5934 aComparer.SetColorTolerance (aTolColor);
5935 aComparer.SetBorderFilterOn (isBorderFilterOn);
5936 Standard_Integer aDiffColorsNb = aComparer.Compare();
5937 theDI << aDiffColorsNb << "\n";
5939 // save image of difference
5940 if (aDiffColorsNb >0 && aDiffImagePath != NULL)
5942 aComparer.SaveDiffImage (aDiffImagePath);
5948 //=======================================================================
5949 //function : VSelect
5950 //purpose : Emulates different types of selection by mouse:
5951 // 1) single click selection
5952 // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)
5953 // 3) selection with polygon having corners at
5954 // pixel positions (x1,y1),...,(xn,yn)
5955 // 4) any of these selections with shift button pressed
5956 //=======================================================================
5957 static Standard_Integer VSelect (Draw_Interpretor& di,
5958 Standard_Integer argc,
5963 di << "Usage : " << argv[0] << " x1 y1 [x2 y2 [... xn yn]] [shift_selection = 1|0]\n";
5967 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
5968 if(myAIScontext.IsNull())
5970 di << "use 'vinit' command before " << argv[0] << "\n";
5974 const Standard_Boolean isShiftSelection = (argc > 3 && !(argc % 2) && (atoi (argv[argc - 1]) == 1));
5975 Standard_Integer aCoordsNb = isShiftSelection ? argc - 2 : argc - 1;
5976 TCollection_AsciiString anArg;
5977 anArg = isShiftSelection ? argv[argc - 3] : argv[argc - 2];
5979 if (anArg == "-allowoverlap")
5981 Standard_Boolean isValidated = isShiftSelection ? argc == 8
5985 di << "Wrong number of arguments! -allowoverlap key is applied only for rectangle selection";
5989 Standard_Integer isToAllow = isShiftSelection ? Draw::Atoi(argv[argc - 2]) : Draw::Atoi(argv[argc - 1]);
5990 myAIScontext->MainSelector()->AllowOverlapDetection (isToAllow != 0);
5994 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
5995 aCurrentEventManager->MoveTo(atoi(argv[1]),atoi(argv[2]));
5998 if(isShiftSelection)
5999 aCurrentEventManager->ShiftSelect();
6001 aCurrentEventManager->Select();
6003 else if(aCoordsNb == 4)
6005 if(isShiftSelection)
6006 aCurrentEventManager->ShiftSelect (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False);
6008 aCurrentEventManager->Select (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False);
6012 TColgp_Array1OfPnt2d aPolyline (1,aCoordsNb / 2);
6014 for(Standard_Integer i=1;i<=aCoordsNb / 2;++i)
6015 aPolyline.SetValue(i,gp_Pnt2d(atoi(argv[2*i-1]),atoi(argv[2*i])));
6017 if(isShiftSelection)
6018 aCurrentEventManager->ShiftSelect(aPolyline);
6020 aCurrentEventManager->Select(aPolyline);
6025 //=======================================================================
6026 //function : VMoveTo
6027 //purpose : Emulates cursor movement to defined pixel position
6028 //=======================================================================
6029 static Standard_Integer VMoveTo (Draw_Interpretor& di,
6030 Standard_Integer argc,
6035 di << "Usage : " << argv[0] << " x y\n";
6039 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6040 if(aContext.IsNull())
6042 di << "use 'vinit' command before " << argv[0] << "\n";
6045 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
6051 //! Global map storing all animations registered in ViewerTest.
6052 static NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)> ViewerTest_AnimationTimelineMap;
6054 //! The animation calling the Draw Harness command.
6055 class ViewerTest_AnimationProc : public AIS_Animation
6059 //! Main constructor.
6060 ViewerTest_AnimationProc (const TCollection_AsciiString& theAnimationName,
6061 Draw_Interpretor* theDI,
6062 const TCollection_AsciiString& theCommand)
6063 : AIS_Animation (theAnimationName),
6065 myCommand (theCommand)
6072 //! Evaluate the command.
6073 virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE
6075 TCollection_AsciiString aCmd = myCommand;
6076 replace (aCmd, "%pts", TCollection_AsciiString(theProgress.Pts));
6077 replace (aCmd, "%localpts", TCollection_AsciiString(theProgress.LocalPts));
6078 replace (aCmd, "%ptslocal", TCollection_AsciiString(theProgress.LocalPts));
6079 replace (aCmd, "%normalized", TCollection_AsciiString(theProgress.LocalNormalized));
6080 replace (aCmd, "%localnormalized", TCollection_AsciiString(theProgress.LocalNormalized));
6081 myDrawInter->Eval (aCmd.ToCString());
6084 //! Find the keyword in the command and replace it with value.
6085 //! @return the position of the keyword to pass value
6086 void replace (TCollection_AsciiString& theCmd,
6087 const TCollection_AsciiString& theKey,
6088 const TCollection_AsciiString& theVal)
6090 TCollection_AsciiString aCmd (theCmd);
6092 const Standard_Integer aPos = aCmd.Search (theKey);
6098 TCollection_AsciiString aPart1, aPart2;
6099 Standard_Integer aPart1To = aPos - 1;
6101 && aPart1To <= theCmd.Length())
6103 aPart1 = theCmd.SubString (1, aPart1To);
6106 Standard_Integer aPart2From = aPos + theKey.Length();
6108 && aPart2From <= theCmd.Length())
6110 aPart2 = theCmd.SubString (aPart2From, theCmd.Length());
6113 theCmd = aPart1 + theVal + aPart2;
6118 Draw_Interpretor* myDrawInter;
6119 TCollection_AsciiString myCommand;
6123 //! Replace the animation with the new one.
6124 static void replaceAnimation (const Handle(AIS_Animation)& theParentAnimation,
6125 Handle(AIS_Animation)& theAnimation,
6126 const Handle(AIS_Animation)& theAnimationNew)
6128 theAnimationNew->CopyFrom (theAnimation);
6129 if (!theParentAnimation.IsNull())
6131 theParentAnimation->Replace (theAnimation, theAnimationNew);
6135 ViewerTest_AnimationTimelineMap.UnBind (theAnimationNew->Name());
6136 ViewerTest_AnimationTimelineMap.Bind (theAnimationNew->Name(), theAnimationNew);
6138 theAnimation = theAnimationNew;
6141 //! Parse the point.
6142 static Standard_Boolean parseXYZ (const char** theArgVec, gp_XYZ& thePnt)
6144 const TCollection_AsciiString anXYZ[3] = { theArgVec[0], theArgVec[1], theArgVec[2] };
6145 if (!anXYZ[0].IsRealValue()
6146 || !anXYZ[1].IsRealValue()
6147 || !anXYZ[2].IsRealValue())
6149 return Standard_False;
6152 thePnt.SetCoord (anXYZ[0].RealValue(), anXYZ[1].RealValue(), anXYZ[2].RealValue());
6153 return Standard_True;
6156 //! Parse the quaternion.
6157 static Standard_Boolean parseQuaternion (const char** theArgVec, gp_Quaternion& theQRot)
6159 const TCollection_AsciiString anXYZW[4] = {theArgVec[0], theArgVec[1], theArgVec[2], theArgVec[3]};
6160 if (!anXYZW[0].IsRealValue()
6161 || !anXYZW[1].IsRealValue()
6162 || !anXYZW[2].IsRealValue()
6163 || !anXYZW[3].IsRealValue())
6165 return Standard_False;
6168 theQRot.Set (anXYZW[0].RealValue(), anXYZW[1].RealValue(), anXYZW[2].RealValue(), anXYZW[3].RealValue());
6169 return Standard_True;
6174 //=================================================================================================
6175 //function : VViewParams
6176 //purpose : Gets or sets AIS View characteristics
6177 //=================================================================================================
6178 static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
6180 Handle(V3d_View) aView = ViewerTest::CurrentView();
6183 std::cout << theArgVec[0] << ": please initialize or activate view.\n";
6187 Standard_Boolean toSetProj = Standard_False;
6188 Standard_Boolean toSetUp = Standard_False;
6189 Standard_Boolean toSetAt = Standard_False;
6190 Standard_Boolean toSetEye = Standard_False;
6191 Standard_Boolean toSetScale = Standard_False;
6192 Standard_Boolean toSetSize = Standard_False;
6193 Standard_Boolean toSetCenter2d = Standard_False;
6194 Standard_Real aViewScale = aView->Scale();
6195 Standard_Real aViewSize = 1.0;
6196 Graphic3d_Vec2i aCenter2d;
6197 gp_XYZ aViewProj, aViewUp, aViewAt, aViewEye;
6198 aView->Proj (aViewProj.ChangeCoord (1), aViewProj.ChangeCoord (2), aViewProj.ChangeCoord (3));
6199 aView->Up (aViewUp .ChangeCoord (1), aViewUp .ChangeCoord (2), aViewUp .ChangeCoord (3));
6200 aView->At (aViewAt .ChangeCoord (1), aViewAt .ChangeCoord (2), aViewAt .ChangeCoord (3));
6201 aView->Eye (aViewEye .ChangeCoord (1), aViewEye .ChangeCoord (2), aViewEye .ChangeCoord (3));
6204 // print all of the available view parameters
6208 "Proj: %12g %12g %12g\n"
6209 "Up: %12g %12g %12g\n"
6210 "At: %12g %12g %12g\n"
6211 "Eye: %12g %12g %12g\n",
6213 aViewProj.X(), aViewProj.Y(), aViewProj.Z(),
6214 aViewUp.X(), aViewUp.Y(), aViewUp.Z(),
6215 aViewAt.X(), aViewAt.Y(), aViewAt.Z(),
6216 aViewEye.X(), aViewEye.Y(), aViewEye.Z());
6221 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
6222 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
6224 TCollection_AsciiString anArg (theArgVec[anArgIter]);
6226 if (anUpdateTool.parseRedrawMode (anArg))
6230 else if (anArg == "-cmd"
6231 || anArg == "-command"
6232 || anArg == "-args")
6241 aViewProj.X(), aViewProj.Y(), aViewProj.Z(),
6242 aViewUp.X(), aViewUp.Y(), aViewUp.Z(),
6243 aViewAt.X(), aViewAt.Y(), aViewAt.Z());
6246 else if (anArg == "-scale"
6247 || anArg == "-size")
6249 if (anArgIter + 1 < theArgsNb
6250 && *theArgVec[anArgIter + 1] != '-')
6252 const TCollection_AsciiString aValueArg (theArgVec[anArgIter + 1]);
6253 if (aValueArg.IsRealValue())
6256 if (anArg == "-scale")
6258 toSetScale = Standard_True;
6259 aViewScale = aValueArg.RealValue();
6261 else if (anArg == "-size")
6263 toSetSize = Standard_True;
6264 aViewSize = aValueArg.RealValue();
6269 if (anArg == "-scale")
6271 theDi << "Scale: " << aView->Scale() << "\n";
6273 else if (anArg == "-size")
6275 Graphic3d_Vec2d aSizeXY;
6276 aView->Size (aSizeXY.x(), aSizeXY.y());
6277 theDi << "Size: " << aSizeXY.x() << " " << aSizeXY.y() << "\n";
6280 else if (anArg == "-eye"
6283 || anArg == "-proj")
6285 if (anArgIter + 3 < theArgsNb)
6288 if (parseXYZ (theArgVec + anArgIter + 1, anXYZ))
6291 if (anArg == "-eye")
6293 toSetEye = Standard_True;
6296 else if (anArg == "-at")
6298 toSetAt = Standard_True;
6301 else if (anArg == "-up")
6303 toSetUp = Standard_True;
6306 else if (anArg == "-proj")
6308 toSetProj = Standard_True;
6315 if (anArg == "-eye")
6317 theDi << "Eye: " << aViewEye.X() << " " << aViewEye.Y() << " " << aViewEye.Z() << "\n";
6319 else if (anArg == "-at")
6321 theDi << "At: " << aViewAt.X() << " " << aViewAt.Y() << " " << aViewAt.Z() << "\n";
6323 else if (anArg == "-up")
6325 theDi << "Up: " << aViewUp.X() << " " << aViewUp.Y() << " " << aViewUp.Z() << "\n";
6327 else if (anArg == "-proj")
6329 theDi << "Proj: " << aViewProj.X() << " " << aViewProj.Y() << " " << aViewProj.Z() << "\n";
6332 else if (anArg == "-center")
6334 if (anArgIter + 2 < theArgsNb)
6336 const TCollection_AsciiString anX (theArgVec[anArgIter + 1]);
6337 const TCollection_AsciiString anY (theArgVec[anArgIter + 2]);
6338 if (anX.IsIntegerValue()
6339 && anY.IsIntegerValue())
6341 toSetCenter2d = Standard_True;
6342 aCenter2d = Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue());
6348 std::cout << "Syntax error at '" << anArg << "'\n";
6353 // change view parameters in proper order
6356 aView->SetScale (aViewScale);
6360 aView->SetSize (aViewSize);
6364 aView->SetEye (aViewEye.X(), aViewEye.Y(), aViewEye.Z());
6368 aView->SetAt (aViewAt.X(), aViewAt.Y(), aViewAt.Z());
6372 aView->SetProj (aViewProj.X(), aViewProj.Y(), aViewProj.Z());
6376 aView->SetUp (aViewUp.X(), aViewUp.Y(), aViewUp.Z());
6380 aView->SetCenter (aCenter2d.x(), aCenter2d.y());
6386 //==============================================================================
6387 //function : VAnimation
6389 //==============================================================================
6390 static Standard_Integer VAnimation (Draw_Interpretor& theDI,
6391 Standard_Integer theArgNb,
6392 const char** theArgVec)
6394 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
6397 for (NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)>::Iterator
6398 anAnimIter (ViewerTest_AnimationTimelineMap); anAnimIter.More(); anAnimIter.Next())
6400 theDI << anAnimIter.Key() << " " << anAnimIter.Value()->Duration() << " sec\n";
6406 std::cout << "Error: no active view\n";
6410 Standard_Integer anArgIter = 1;
6411 TCollection_AsciiString aNameArg (theArgVec[anArgIter++]);
6412 if (aNameArg.IsEmpty())
6414 std::cout << "Syntax error: animation name is not defined.\n";
6418 TCollection_AsciiString aNameArgLower = aNameArg;
6419 aNameArgLower.LowerCase();
6420 if (aNameArgLower == "-reset"
6421 || aNameArgLower == "-clear")
6423 ViewerTest_AnimationTimelineMap.Clear();
6426 else if (aNameArg.Value (1) == '-')
6428 std::cout << "Syntax error: invalid animation name '" << aNameArg << "'.\n";
6432 const char* aNameSplitter = "/";
6433 Standard_Integer aSplitPos = aNameArg.Search (aNameSplitter);
6434 if (aSplitPos == -1)
6436 aNameSplitter = ".";
6437 aSplitPos = aNameArg.Search (aNameSplitter);
6440 // find existing or create a new animation by specified name within syntax "parent.child".
6441 Handle(AIS_Animation) aRootAnimation, aParentAnimation, anAnimation;
6442 for (; !aNameArg.IsEmpty();)
6444 TCollection_AsciiString aNameParent;
6445 if (aSplitPos != -1)
6447 if (aSplitPos == aNameArg.Length())
6449 std::cout << "Syntax error: animation name is not defined.\n";
6453 aNameParent = aNameArg.SubString ( 1, aSplitPos - 1);
6454 aNameArg = aNameArg.SubString (aSplitPos + 1, aNameArg.Length());
6456 aSplitPos = aNameArg.Search (aNameSplitter);
6460 aNameParent = aNameArg;
6464 if (anAnimation.IsNull())
6466 if (!ViewerTest_AnimationTimelineMap.Find (aNameParent, anAnimation))
6468 anAnimation = new AIS_Animation (aNameParent);
6469 ViewerTest_AnimationTimelineMap.Bind (aNameParent, anAnimation);
6471 aRootAnimation = anAnimation;
6475 aParentAnimation = anAnimation;
6476 anAnimation = aParentAnimation->Find (aNameParent);
6477 if (anAnimation.IsNull())
6479 anAnimation = new AIS_Animation (aNameParent);
6480 aParentAnimation->Add (anAnimation);
6485 if (anArgIter >= theArgNb)
6487 // just print the list of children
6488 for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anAnimIter (anAnimation->Children()); anAnimIter.More(); anAnimIter.Next())
6490 theDI << anAnimIter.Value()->Name() << " " << anAnimIter.Value()->Duration() << " sec\n";
6495 // animation parameters
6496 Standard_Boolean toPlay = Standard_False;
6497 Standard_Real aPlaySpeed = 1.0;
6498 Standard_Real aPlayStartTime = anAnimation->StartPts();
6499 Standard_Real aPlayDuration = anAnimation->Duration();
6500 Standard_Integer aFpsNum = 0;
6501 Standard_Integer aFpsDen = 1;
6502 Standard_Boolean isFreeCamera = Standard_False;
6503 Standard_Boolean isLockLoop = Standard_False;
6504 Handle(V3d_View) aView = ViewerTest::CurrentView();
6505 for (; anArgIter < theArgNb; ++anArgIter)
6507 TCollection_AsciiString anArg (theArgVec[anArgIter]);
6510 if (anArg == "-reset"
6511 || anArg == "-clear")
6513 anAnimation->Clear();
6515 else if (anArg == "-remove"
6517 || anArg == "-delete")
6519 if (!aParentAnimation.IsNull())
6521 ViewerTest_AnimationTimelineMap.UnBind (anAnimation->Name());
6525 aParentAnimation->Remove (anAnimation);
6529 else if (anArg == "-play")
6531 toPlay = Standard_True;
6532 if (++anArgIter < theArgNb)
6534 if (*theArgVec[anArgIter] == '-')
6539 aPlayStartTime = Draw::Atof (theArgVec[anArgIter]);
6541 if (++anArgIter < theArgNb)
6543 if (*theArgVec[anArgIter] == '-')
6548 aPlayDuration = Draw::Atof (theArgVec[anArgIter]);
6552 else if (anArg == "-resume")
6554 toPlay = Standard_True;
6555 aPlayStartTime = anAnimation->ElapsedTime();
6556 if (++anArgIter < theArgNb)
6558 if (*theArgVec[anArgIter] == '-')
6564 aPlayDuration = Draw::Atof (theArgVec[anArgIter]);
6567 else if (anArg == "-playspeed"
6568 || anArg == "-speed")
6570 if (++anArgIter >= theArgNb)
6572 std::cout << "Syntax error at " << anArg << ".\n";
6575 aPlaySpeed = Draw::Atof (theArgVec[anArgIter]);
6577 else if (anArg == "-lock"
6578 || anArg == "-lockloop"
6579 || anArg == "-playlockloop")
6581 isLockLoop = Standard_True;
6583 else if (anArg == "-freecamera"
6584 || anArg == "-playfreecamera"
6585 || anArg == "-freelook")
6587 isFreeCamera = Standard_True;
6589 else if (anArg == "-fps")
6591 if (++anArgIter >= theArgNb)
6593 std::cout << "Syntax error at " << anArg << ".\n";
6597 TCollection_AsciiString aFpsArg (theArgVec[anArgIter]);
6598 Standard_Integer aSplitIndex = aFpsArg.FirstLocationInSet ("/", 1, aFpsArg.Length());
6599 if (aSplitIndex == 0)
6601 aFpsNum = aFpsArg.IntegerValue();
6605 const TCollection_AsciiString aDenStr = aFpsArg.Split (aSplitIndex);
6606 aFpsArg.Split (aFpsArg.Length() - 1);
6607 const TCollection_AsciiString aNumStr = aFpsArg;
6608 aFpsNum = aNumStr.IntegerValue();
6609 aFpsDen = aDenStr.IntegerValue();
6612 std::cout << "Syntax error at " << anArg << ".\n";
6617 // animation definition options
6618 else if (anArg == "-start"
6619 || anArg == "-starttime"
6620 || anArg == "-startpts")
6622 if (++anArgIter >= theArgNb)
6624 std::cout << "Syntax error at " << anArg << ".\n";
6628 anAnimation->SetStartPts (Draw::Atof (theArgVec[anArgIter]));
6629 aRootAnimation->UpdateTotalDuration();
6631 else if (anArg == "-end"
6632 || anArg == "-endtime"
6633 || anArg == "-endpts")
6635 if (++anArgIter >= theArgNb)
6637 std::cout << "Syntax error at " << anArg << ".\n";
6641 anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]) - anAnimation->StartPts());
6642 aRootAnimation->UpdateTotalDuration();
6644 else if (anArg == "-dur"
6645 || anArg == "-duration")
6647 if (++anArgIter >= theArgNb)
6649 std::cout << "Syntax error at " << anArg << ".\n";
6653 anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]));
6654 aRootAnimation->UpdateTotalDuration();
6656 else if (anArg == "-command"
6658 || anArg == "-invoke"
6660 || anArg == "-proc")
6662 if (++anArgIter >= theArgNb)
6664 std::cout << "Syntax error at " << anArg << ".\n";
6668 Handle(ViewerTest_AnimationProc) aCmdAnimation = new ViewerTest_AnimationProc (anAnimation->Name(), &theDI, theArgVec[anArgIter]);
6669 replaceAnimation (aParentAnimation, anAnimation, aCmdAnimation);
6671 else if (anArg == "-objecttrsf"
6672 || anArg == "-objectransformation"
6673 || anArg == "-objtransformation"
6674 || anArg == "-objtrsf"
6675 || anArg == "-object"
6678 if (++anArgIter >= theArgNb)
6680 std::cout << "Syntax error at " << anArg << ".\n";
6684 TCollection_AsciiString anObjName (theArgVec[anArgIter]);
6685 const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfAIS = GetMapOfAIS();
6686 if (!aMapOfAIS.IsBound2 (anObjName))
6688 std::cout << "Syntax error: wrong object name at " << anArg << "\n";
6692 Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (aMapOfAIS.Find2 (anObjName));
6693 gp_Trsf aTrsfs [2] = { anObject->LocalTransformation(), anObject->LocalTransformation() };
6694 gp_Quaternion aRotQuats[2] = { aTrsfs[0].GetRotation(), aTrsfs[1].GetRotation() };
6695 gp_XYZ aLocPnts [2] = { aTrsfs[0].TranslationPart(), aTrsfs[1].TranslationPart() };
6696 Standard_Real aScales [2] = { aTrsfs[0].ScaleFactor(), aTrsfs[1].ScaleFactor() };
6697 Standard_Boolean isTrsfSet = Standard_False;
6698 Standard_Integer aTrsfArgIter = anArgIter + 1;
6699 for (; aTrsfArgIter < theArgNb; ++aTrsfArgIter)
6701 TCollection_AsciiString aTrsfArg (theArgVec[aTrsfArgIter]);
6702 aTrsfArg.LowerCase();
6703 const Standard_Integer anIndex = aTrsfArg.EndsWith ("1") ? 0 : 1;
6704 if (aTrsfArg.StartsWith ("-rotation")
6705 || aTrsfArg.StartsWith ("-rot"))
6707 isTrsfSet = Standard_True;
6708 if (aTrsfArgIter + 4 >= theArgNb
6709 || !parseQuaternion (theArgVec + aTrsfArgIter + 1, aRotQuats[anIndex]))
6711 std::cout << "Syntax error at " << aTrsfArg << ".\n";
6716 else if (aTrsfArg.StartsWith ("-location")
6717 || aTrsfArg.StartsWith ("-loc"))
6719 isTrsfSet = Standard_True;
6720 if (aTrsfArgIter + 3 >= theArgNb
6721 || !parseXYZ (theArgVec + aTrsfArgIter + 1, aLocPnts[anIndex]))
6723 std::cout << "Syntax error at " << aTrsfArg << ".\n";
6728 else if (aTrsfArg.StartsWith ("-scale"))
6730 isTrsfSet = Standard_True;
6731 if (++aTrsfArgIter >= theArgNb)
6733 std::cout << "Syntax error at " << aTrsfArg << ".\n";
6737 const TCollection_AsciiString aScaleStr (theArgVec[aTrsfArgIter]);
6738 if (!aScaleStr.IsRealValue())
6740 std::cout << "Syntax error at " << aTrsfArg << ".\n";
6743 aScales[anIndex] = aScaleStr.RealValue();
6747 anArgIter = aTrsfArgIter - 1;
6753 std::cout << "Syntax error at " << anArg << ".\n";
6756 else if (aTrsfArgIter >= theArgNb)
6758 anArgIter = theArgNb;
6761 aTrsfs[0].SetRotation (aRotQuats[0]);
6762 aTrsfs[1].SetRotation (aRotQuats[1]);
6763 aTrsfs[0].SetTranslationPart (aLocPnts[0]);
6764 aTrsfs[1].SetTranslationPart (aLocPnts[1]);
6765 aTrsfs[0].SetScaleFactor (aScales[0]);
6766 aTrsfs[1].SetScaleFactor (aScales[1]);
6768 Handle(AIS_AnimationObject) anObjAnimation = new AIS_AnimationObject (anAnimation->Name(), aCtx, anObject, aTrsfs[0], aTrsfs[1]);
6769 replaceAnimation (aParentAnimation, anAnimation, anObjAnimation);
6771 else if (anArg == "-viewtrsf"
6772 || anArg == "-view")
6774 Handle(AIS_AnimationCamera) aCamAnimation = Handle(AIS_AnimationCamera)::DownCast (anAnimation);
6775 if (aCamAnimation.IsNull())
6777 aCamAnimation = new AIS_AnimationCamera (anAnimation->Name(), aView);
6778 replaceAnimation (aParentAnimation, anAnimation, aCamAnimation);
6781 Handle(Graphic3d_Camera) aCams[2] =
6783 new Graphic3d_Camera (aCamAnimation->View()->Camera()),
6784 new Graphic3d_Camera (aCamAnimation->View()->Camera())
6787 Standard_Boolean isTrsfSet = Standard_False;
6788 Standard_Integer aViewArgIter = anArgIter + 1;
6789 for (; aViewArgIter < theArgNb; ++aViewArgIter)
6791 TCollection_AsciiString aViewArg (theArgVec[aViewArgIter]);
6792 aViewArg.LowerCase();
6793 const Standard_Integer anIndex = aViewArg.EndsWith("1") ? 0 : 1;
6794 if (aViewArg.StartsWith ("-scale"))
6796 isTrsfSet = Standard_True;
6797 if (++aViewArgIter >= theArgNb)
6799 std::cout << "Syntax error at " << anArg << ".\n";
6803 const TCollection_AsciiString aScaleStr (theArgVec[aViewArgIter]);
6804 if (!aScaleStr.IsRealValue())
6806 std::cout << "Syntax error at " << aViewArg << ".\n";
6809 Standard_Real aScale = aScaleStr.RealValue();
6810 aScale = aCamAnimation->View()->DefaultCamera()->Scale() / aScale;
6811 aCams[anIndex]->SetScale (aScale);
6813 else if (aViewArg.StartsWith ("-eye")
6814 || aViewArg.StartsWith ("-center")
6815 || aViewArg.StartsWith ("-at")
6816 || aViewArg.StartsWith ("-up"))
6818 isTrsfSet = Standard_True;
6820 if (aViewArgIter + 3 >= theArgNb
6821 || !parseXYZ (theArgVec + aViewArgIter + 1, anXYZ))
6823 std::cout << "Syntax error at " << aViewArg << ".\n";
6828 if (aViewArg.StartsWith ("-eye"))
6830 aCams[anIndex]->SetEye (anXYZ);
6832 else if (aViewArg.StartsWith ("-center")
6833 || aViewArg.StartsWith ("-at"))
6835 aCams[anIndex]->SetCenter (anXYZ);
6837 else if (aViewArg.StartsWith ("-up"))
6839 aCams[anIndex]->SetUp (anXYZ);
6844 anArgIter = aViewArgIter - 1;
6850 std::cout << "Syntax error at " << anArg << ".\n";
6853 else if (aViewArgIter >= theArgNb)
6855 anArgIter = theArgNb;
6858 aCamAnimation->SetCameraStart(aCams[0]);
6859 aCamAnimation->SetCameraEnd (aCams[1]);
6863 std::cout << "Syntax error at " << anArg << ".\n";
6873 // Start animation timeline and process frame updating.
6874 TheIsAnimating = Standard_True;
6875 const Standard_Boolean wasImmediateUpdate = aView->SetImmediateUpdate (Standard_False);
6876 Handle(Graphic3d_Camera) aCameraBack = new Graphic3d_Camera (aView->Camera());
6877 anAnimation->StartTimer (aPlayStartTime, aPlaySpeed, Standard_True, aPlayDuration <= 0.0);
6880 aView->Camera()->Copy (aCameraBack);
6883 const Standard_Real anUpperPts = aPlayStartTime + aPlayDuration;
6886 while (!anAnimation->IsStopped())
6888 aCameraBack->Copy (aView->Camera());
6889 const Standard_Real aPts = anAnimation->UpdateTimer();
6892 aView->Camera()->Copy (aCameraBack);
6895 if (aPts >= anUpperPts)
6897 anAnimation->Pause();
6901 if (aView->IsInvalidated())
6907 aView->RedrawImmediate();
6912 // handle user events
6913 theDI.Eval ("after 1 set waiter 1");
6914 theDI.Eval ("vwait waiter");
6916 if (!TheIsAnimating)
6918 anAnimation->Pause();
6924 if (aView->IsInvalidated())
6930 aView->RedrawImmediate();
6935 OSD_Timer aPerfTimer;
6938 // Manage frame-rated animation here
6939 Standard_Real aPts = aPlayStartTime;
6940 int64_t aNbFrames = 0;
6941 for (; aPts <= anUpperPts;)
6943 const Standard_Real aRecPts = aPlaySpeed * ((Standard_Real(aFpsDen) / Standard_Real(aFpsNum)) * Standard_Real(aNbFrames));
6944 aPts = aPlayStartTime + aRecPts;
6946 if (!anAnimation->Update (aPts))
6955 anAnimation->Stop();
6956 const Standard_Real aRecFps = Standard_Real(aNbFrames) / aPerfTimer.ElapsedTime();
6957 theDI << "Average FPS: " << aRecFps << "\n"
6958 << "Nb. Frames: " << Standard_Real(aNbFrames);
6963 aView->SetImmediateUpdate (wasImmediateUpdate);
6964 TheIsAnimating = Standard_False;
6969 //=======================================================================
6970 //function : VChangeSelected
6971 //purpose : Adds the shape to selection or remove one from it
6972 //=======================================================================
6973 static Standard_Integer VChangeSelected (Draw_Interpretor& di,
6974 Standard_Integer argc,
6979 di<<"Usage : " << argv[0] << " shape \n";
6983 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6984 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
6985 TCollection_AsciiString aName(argv[1]);
6986 Handle(AIS_InteractiveObject) anAISObject;
6988 if(!aMap.IsBound2(aName))
6990 di<<"Use 'vdisplay' before";
6995 anAISObject = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
6996 if(anAISObject.IsNull()){
6997 di<<"No interactive object \n";
7001 aContext->AddOrRemoveSelected(anAISObject, Standard_True);
7006 //=======================================================================
7007 //function : VNbSelected
7008 //purpose : Returns number of selected objects
7009 //=======================================================================
7010 static Standard_Integer VNbSelected (Draw_Interpretor& di,
7011 Standard_Integer argc,
7016 di << "Usage : " << argv[0] << "\n";
7019 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
7020 if(aContext.IsNull())
7022 di << "use 'vinit' command before " << argv[0] << "\n";
7025 di << aContext->NbSelected() << "\n";
7029 //=======================================================================
7030 //function : VPurgeDisplay
7031 //purpose : Switches altialiasing on or off
7032 //=======================================================================
7033 static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
7034 Standard_Integer argc,
7039 di << "Usage : " << argv[0] << "\n";
7042 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
7043 if (aContext.IsNull())
7045 di << "use 'vinit' command before " << argv[0] << "\n";
7049 di << aContext->PurgeDisplay() << "\n";
7053 //=======================================================================
7054 //function : VSetViewSize
7056 //=======================================================================
7057 static Standard_Integer VSetViewSize (Draw_Interpretor& di,
7058 Standard_Integer argc,
7061 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
7062 if(aContext.IsNull())
7064 di << "use 'vinit' command before " << argv[0] << "\n";
7069 di<<"Usage : " << argv[0] << " Size\n";
7072 Standard_Real aSize = Draw::Atof (argv[1]);
7075 di<<"Bad Size value : " << aSize << "\n";
7079 Handle(V3d_View) aView = ViewerTest::CurrentView();
7080 aView->SetSize(aSize);
7084 //=======================================================================
7085 //function : VMoveView
7087 //=======================================================================
7088 static Standard_Integer VMoveView (Draw_Interpretor& di,
7089 Standard_Integer argc,
7092 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
7093 if(aContext.IsNull())
7095 di << "use 'vinit' command before " << argv[0] << "\n";
7098 if(argc < 4 || argc > 5)
7100 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
7103 Standard_Real Dx = Draw::Atof (argv[1]);
7104 Standard_Real Dy = Draw::Atof (argv[2]);
7105 Standard_Real Dz = Draw::Atof (argv[3]);
7106 Standard_Boolean aStart = Standard_True;
7109 aStart = (Draw::Atoi (argv[4]) > 0);
7112 Handle(V3d_View) aView = ViewerTest::CurrentView();
7113 aView->Move(Dx,Dy,Dz,aStart);
7117 //=======================================================================
7118 //function : VTranslateView
7120 //=======================================================================
7121 static Standard_Integer VTranslateView (Draw_Interpretor& di,
7122 Standard_Integer argc,
7125 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
7126 if(aContext.IsNull())
7128 di << "use 'vinit' command before " << argv[0] << "\n";
7131 if(argc < 4 || argc > 5)
7133 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
7136 Standard_Real Dx = Draw::Atof (argv[1]);
7137 Standard_Real Dy = Draw::Atof (argv[2]);
7138 Standard_Real Dz = Draw::Atof (argv[3]);
7139 Standard_Boolean aStart = Standard_True;
7142 aStart = (Draw::Atoi (argv[4]) > 0);
7145 Handle(V3d_View) aView = ViewerTest::CurrentView();
7146 aView->Translate(Dx,Dy,Dz,aStart);
7150 //=======================================================================
7151 //function : VTurnView
7153 //=======================================================================
7154 static Standard_Integer VTurnView (Draw_Interpretor& di,
7155 Standard_Integer argc,
7158 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
7159 if(aContext.IsNull()) {
7160 di << "use 'vinit' command before " << argv[0] << "\n";
7163 if(argc < 4 || argc > 5){
7164 di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n";
7167 Standard_Real Ax = Draw::Atof (argv[1]);
7168 Standard_Real Ay = Draw::Atof (argv[2]);
7169 Standard_Real Az = Draw::Atof (argv[3]);
7170 Standard_Boolean aStart = Standard_True;
7173 aStart = (Draw::Atoi (argv[4]) > 0);
7176 Handle(V3d_View) aView = ViewerTest::CurrentView();
7177 aView->Turn(Ax,Ay,Az,aStart);
7181 //==============================================================================
7182 //function : VTextureEnv
7183 //purpose : ENables or disables environment mapping
7184 //==============================================================================
7185 class OCC_TextureEnv : public Graphic3d_TextureEnv
7188 OCC_TextureEnv(const Standard_CString FileName);
7189 OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName);
7190 void SetTextureParameters(const Standard_Boolean theRepeatFlag,
7191 const Standard_Boolean theModulateFlag,
7192 const Graphic3d_TypeOfTextureFilter theFilter,
7193 const Standard_ShortReal theXScale,
7194 const Standard_ShortReal theYScale,
7195 const Standard_ShortReal theXShift,
7196 const Standard_ShortReal theYShift,
7197 const Standard_ShortReal theAngle);
7198 DEFINE_STANDARD_RTTI_INLINE(OCC_TextureEnv,Graphic3d_TextureEnv)
7200 DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv)
7202 OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName)
7203 : Graphic3d_TextureEnv(theFileName)
7207 OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId)
7208 : Graphic3d_TextureEnv(theTexId)
7212 void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag,
7213 const Standard_Boolean theModulateFlag,
7214 const Graphic3d_TypeOfTextureFilter theFilter,
7215 const Standard_ShortReal theXScale,
7216 const Standard_ShortReal theYScale,
7217 const Standard_ShortReal theXShift,
7218 const Standard_ShortReal theYShift,
7219 const Standard_ShortReal theAngle)
7221 myParams->SetRepeat (theRepeatFlag);
7222 myParams->SetModulate (theModulateFlag);
7223 myParams->SetFilter (theFilter);
7224 myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale));
7225 myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift));
7226 myParams->SetRotation (theAngle);
7229 static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec)
7231 // get the active view
7232 Handle(V3d_View) aView = ViewerTest::CurrentView();
7235 std::cerr << "No active view. Please call vinit.\n";
7239 // Checking the input arguments
7240 Standard_Boolean anEnableFlag = Standard_False;
7241 Standard_Boolean isOk = theArgNb >= 2;
7244 TCollection_AsciiString anEnableOpt(theArgVec[1]);
7245 anEnableFlag = anEnableOpt.IsEqual("on");
7246 isOk = anEnableFlag || anEnableOpt.IsEqual("off");
7250 isOk = (theArgNb == 3 || theArgNb == 11);
7253 TCollection_AsciiString aTextureOpt(theArgVec[2]);
7254 isOk = (!aTextureOpt.IsIntegerValue() ||
7255 (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN));
7257 if (isOk && theArgNb == 11)
7259 TCollection_AsciiString aRepeatOpt (theArgVec[3]),
7260 aModulateOpt(theArgVec[4]),
7261 aFilterOpt (theArgVec[5]),
7262 aSScaleOpt (theArgVec[6]),
7263 aTScaleOpt (theArgVec[7]),
7264 aSTransOpt (theArgVec[8]),
7265 aTTransOpt (theArgVec[9]),
7266 anAngleOpt (theArgVec[10]);
7267 isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) &&
7268 (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) &&
7269 (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) &&
7270 aSScaleOpt.IsRealValue() && aTScaleOpt.IsRealValue() &&
7271 aSTransOpt.IsRealValue() && aTTransOpt.IsRealValue() &&
7272 anAngleOpt.IsRealValue());
7279 std::cerr << "Usage :" << std::endl;
7280 std::cerr << theArgVec[0] << " off" << std::endl;
7281 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;
7287 TCollection_AsciiString aTextureOpt(theArgVec[2]);
7288 Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ?
7289 new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) :
7290 new OCC_TextureEnv(theArgVec[2]);
7294 TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]);
7295 aTexEnv->SetTextureParameters(
7296 aRepeatOpt. IsEqual("repeat"),
7297 aModulateOpt.IsEqual("modulate"),
7298 aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST :
7299 aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR :
7300 Graphic3d_TOTF_TRILINEAR,
7301 (Standard_ShortReal)Draw::Atof(theArgVec[6]),
7302 (Standard_ShortReal)Draw::Atof(theArgVec[7]),
7303 (Standard_ShortReal)Draw::Atof(theArgVec[8]),
7304 (Standard_ShortReal)Draw::Atof(theArgVec[9]),
7305 (Standard_ShortReal)Draw::Atof(theArgVec[10])
7308 aView->SetTextureEnv(aTexEnv);
7310 else // Disabling environment mapping
7312 Handle(Graphic3d_TextureEnv) aTexture;
7313 aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data
7322 typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
7324 //! Remove registered clipping plane from all views and objects.
7325 static void removePlane (MapOfPlanes& theRegPlanes,
7326 const TCollection_AsciiString& theName)
7328 Handle(Graphic3d_ClipPlane) aClipPlane;
7329 if (!theRegPlanes.Find (theName, aClipPlane))
7331 std::cout << "Warning: no such plane.\n";
7335 theRegPlanes.UnBind (theName);
7336 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
7337 anIObjIt.More(); anIObjIt.Next())
7339 Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anIObjIt.Key1());
7340 aPrs->RemoveClipPlane (aClipPlane);
7343 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
7344 aViewIt.More(); aViewIt.Next())
7346 const Handle(V3d_View)& aView = aViewIt.Key2();
7347 aView->RemoveClipPlane(aClipPlane);
7350 ViewerTest::RedrawAllViews();
7354 //===============================================================================================
7355 //function : VClipPlane
7357 //===============================================================================================
7358 static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
7360 // use short-cut for created clip planes map of created (or "registered by name") clip planes
7361 static MapOfPlanes aRegPlanes;
7365 for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More(); aPlaneIter.Next())
7367 theDi << aPlaneIter.Key() << " ";
7372 TCollection_AsciiString aCommand (theArgVec[1]);
7373 aCommand.LowerCase();
7374 const Handle(V3d_View)& anActiveView = ViewerTest::CurrentView();
7375 if (anActiveView.IsNull())
7377 std::cout << "Error: no active view.\n";
7381 // print maximum number of planes for current viewer
7382 if (aCommand == "-maxplanes"
7383 || aCommand == "maxplanes")
7385 theDi << anActiveView->Viewer()->Driver()->InquirePlaneLimit()
7386 << " plane slots provided by driver.\n";
7390 // create / delete plane instance
7391 if (aCommand == "-create"
7392 || aCommand == "create"
7393 || aCommand == "-delete"
7394 || aCommand == "delete"
7395 || aCommand == "-clone"
7396 || aCommand == "clone")
7400 std::cout << "Syntax error: plane name is required.\n";
7404 Standard_Boolean toCreate = aCommand == "-create"
7405 || aCommand == "create";
7406 Standard_Boolean toClone = aCommand == "-clone"
7407 || aCommand == "clone";
7408 Standard_Boolean toDelete = aCommand == "-delete"
7409 || aCommand == "delete";
7410 TCollection_AsciiString aPlane (theArgVec[2]);
7414 if (aRegPlanes.IsBound (aPlane))
7416 std::cout << "Warning: existing plane has been overridden.\n";
7421 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
7425 else if (toClone) // toClone
7427 if (!aRegPlanes.IsBound (aPlane))
7429 std::cout << "Error: no such plane.\n";
7432 else if (theArgsNb < 4)
7434 std::cout << "Syntax error: enter name for new plane.\n";
7438 TCollection_AsciiString aClone (theArgVec[3]);
7439 if (aRegPlanes.IsBound (aClone))
7441 std::cout << "Error: plane name is in use.\n";
7445 const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
7447 aRegPlanes.Bind (aClone, aClipPlane->Clone());
7457 for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More();)
7459 aPlane = aPlaneIter.Key();
7460 removePlane (aRegPlanes, aPlane);
7461 aPlaneIter = MapOfPlanes::Iterator (aRegPlanes);
7466 removePlane (aRegPlanes, aPlane);
7472 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
7477 // set / unset plane command
7478 if (aCommand == "set"
7479 || aCommand == "unset")
7483 std::cout << "Syntax error: need more arguments.\n";
7487 // redirect to new syntax
7488 NCollection_Array1<const char*> anArgVec (1, theArgsNb - 1);
7489 anArgVec.SetValue (1, theArgVec[0]);
7490 anArgVec.SetValue (2, theArgVec[2]);
7491 anArgVec.SetValue (3, aCommand == "set" ? "-set" : "-unset");
7492 for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
7494 anArgVec.SetValue (anIt, theArgVec[anIt]);
7497 return VClipPlane (theDi, anArgVec.Length(), &anArgVec.ChangeFirst());
7500 // change plane command
7501 TCollection_AsciiString aPlaneName;
7502 Handle(Graphic3d_ClipPlane) aClipPlane;
7503 Standard_Integer anArgIter = 0;
7504 if (aCommand == "-change"
7505 || aCommand == "change")
7507 // old syntax support
7510 std::cout << "Syntax error: need more arguments.\n";
7515 aPlaneName = theArgVec[2];
7516 if (!aRegPlanes.Find (aPlaneName, aClipPlane))
7518 std::cout << "Error: no such plane '" << aPlaneName << "'.\n";
7522 else if (aRegPlanes.Find (theArgVec[1], aClipPlane))
7525 aPlaneName = theArgVec[1];
7530 aPlaneName = theArgVec[1];
7531 aClipPlane = new Graphic3d_ClipPlane();
7532 aRegPlanes.Bind (aPlaneName, aClipPlane);
7533 theDi << "Created new plane " << aPlaneName << ".\n";
7536 if (theArgsNb - anArgIter < 1)
7538 std::cout << "Syntax error: need more arguments.\n";
7542 for (; anArgIter < theArgsNb; ++anArgIter)
7544 const char** aChangeArgs = theArgVec + anArgIter;
7545 Standard_Integer aNbChangeArgs = theArgsNb - anArgIter;
7546 TCollection_AsciiString aChangeArg (aChangeArgs[0]);
7547 aChangeArg.LowerCase();
7549 Standard_Boolean toEnable = Standard_True;
7550 if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable))
7552 aClipPlane->SetOn (toEnable);
7554 else if (aChangeArg == "-equation"
7555 || aChangeArg == "equation")
7557 if (aNbChangeArgs < 5)
7559 std::cout << "Syntax error: need more arguments.\n";
7563 Standard_Real aCoeffA = Draw::Atof (aChangeArgs [1]);
7564 Standard_Real aCoeffB = Draw::Atof (aChangeArgs [2]);
7565 Standard_Real aCoeffC = Draw::Atof (aChangeArgs [3]);
7566 Standard_Real aCoeffD = Draw::Atof (aChangeArgs [4]);
7567 aClipPlane->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD));
7570 else if (aChangeArg == "-capping"
7571 || aChangeArg == "capping")
7573 if (aNbChangeArgs < 2)
7575 std::cout << "Syntax error: need more arguments.\n";
7579 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
7581 aClipPlane->SetCapping (toEnable);
7586 // just skip otherwise (old syntax)
7589 else if (aChangeArg == "-useobjectmaterial"
7590 || aChangeArg == "-useobjectmat"
7591 || aChangeArg == "-useobjmat"
7592 || aChangeArg == "-useobjmaterial")
7594 if (aNbChangeArgs < 2)
7596 std::cout << "Syntax error: need more arguments.\n";
7600 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
7602 aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
7606 else if (aChangeArg == "-useobjecttexture"
7607 || aChangeArg == "-useobjecttex"
7608 || aChangeArg == "-useobjtexture"
7609 || aChangeArg == "-useobjtex")
7611 if (aNbChangeArgs < 2)
7613 std::cout << "Syntax error: need more arguments.\n";
7617 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
7619 aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
7623 else if (aChangeArg == "-useobjectshader"
7624 || aChangeArg == "-useobjshader")
7626 if (aNbChangeArgs < 2)
7628 std::cout << "Syntax error: need more arguments.\n";
7632 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
7634 aClipPlane->SetUseObjectShader (toEnable == Standard_True);
7638 else if (aChangeArg == "-color"
7639 || aChangeArg == "color")
7641 Quantity_Color aColor;
7642 Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
7647 std::cout << "Syntax error: need more arguments.\n";
7651 Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
7652 aMat.SetAmbientColor (aColor);
7653 aMat.SetDiffuseColor (aColor);
7654 aClipPlane->SetCappingMaterial (aMat);
7655 anArgIter += aNbParsed;
7657 else if (aChangeArg == "-texname"
7658 || aChangeArg == "texname")
7660 if (aNbChangeArgs < 2)
7662 std::cout << "Syntax error: need more arguments.\n";
7666 TCollection_AsciiString aTextureName (aChangeArgs[1]);
7667 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
7668 if (!aTexture->IsDone())
7670 aClipPlane->SetCappingTexture (NULL);
7674 aTexture->EnableModulate();
7675 aTexture->EnableRepeat();
7676 aClipPlane->SetCappingTexture (aTexture);
7680 else if (aChangeArg == "-texscale"
7681 || aChangeArg == "texscale")
7683 if (aClipPlane->CappingTexture().IsNull())
7685 std::cout << "Error: no texture is set.\n";
7689 if (aNbChangeArgs < 3)
7691 std::cout << "Syntax error: need more arguments.\n";
7695 Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
7696 Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
7697 aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
7700 else if (aChangeArg == "-texorigin"
7701 || aChangeArg == "texorigin") // texture origin
7703 if (aClipPlane->CappingTexture().IsNull())
7705 std::cout << "Error: no texture is set.\n";
7709 if (aNbChangeArgs < 3)
7711 std::cout << "Syntax error: need more arguments.\n";
7715 Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
7716 Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
7718 aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
7721 else if (aChangeArg == "-texrotate"
7722 || aChangeArg == "texrotate") // texture rotation
7724 if (aClipPlane->CappingTexture().IsNull())
7726 std::cout << "Error: no texture is set.\n";
7730 if (aNbChangeArgs < 2)
7732 std::cout << "Syntax error: need more arguments.\n";
7736 Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
7737 aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
7740 else if (aChangeArg == "-hatch"
7741 || aChangeArg == "hatch")
7743 if (aNbChangeArgs < 2)
7745 std::cout << "Syntax error: need more arguments.\n";
7749 TCollection_AsciiString aHatchStr (aChangeArgs[1]);
7750 aHatchStr.LowerCase();
7751 if (aHatchStr == "on")
7753 aClipPlane->SetCappingHatchOn();
7755 else if (aHatchStr == "off")
7757 aClipPlane->SetCappingHatchOff();
7761 aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
7765 else if (aChangeArg == "-delete"
7766 || aChangeArg == "delete")
7768 removePlane (aRegPlanes, aPlaneName);
7771 else if (aChangeArg == "-set"
7772 || aChangeArg == "-unset")
7774 // set / unset plane command
7775 Standard_Boolean toSet = aChangeArg == "-set";
7776 Standard_Integer anIt = 1;
7777 for (; anIt < aNbChangeArgs; ++anIt)
7779 TCollection_AsciiString anEntityName (aChangeArgs[anIt]);
7780 if (anEntityName.IsEmpty()
7781 || anEntityName.Value (1) == '-')
7785 else if (ViewerTest_myViews.IsBound1 (anEntityName))
7787 Handle(V3d_View) aView = ViewerTest_myViews.Find1 (anEntityName);
7790 aView->AddClipPlane (aClipPlane);
7794 aView->RemoveClipPlane (aClipPlane);
7798 else if (GetMapOfAIS().IsBound2 (anEntityName))
7800 Handle(AIS_InteractiveObject) aIObj = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anEntityName));
7803 aIObj->AddClipPlane (aClipPlane);
7807 aIObj->RemoveClipPlane (aClipPlane);
7812 std::cout << "Error: object/view '" << anEntityName << "' is not found!\n";
7819 // apply to active view
7822 anActiveView->AddClipPlane (aClipPlane);
7826 anActiveView->RemoveClipPlane (aClipPlane);
7831 anArgIter = anArgIter + anIt - 1;
7836 std::cout << "Syntax error: unknown argument '" << aChangeArg << "'.\n";
7841 ViewerTest::RedrawAllViews();
7845 //===============================================================================================
7846 //function : VZRange
7848 //===============================================================================================
7849 static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
7851 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
7853 if (aCurrentView.IsNull())
7855 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
7859 Handle(Graphic3d_Camera) aCamera = aCurrentView->Camera();
7863 theDi << "ZNear: " << aCamera->ZNear() << "\n";
7864 theDi << "ZFar: " << aCamera->ZFar() << "\n";
7870 Standard_Real aNewZNear = Draw::Atof (theArgVec[1]);
7871 Standard_Real aNewZFar = Draw::Atof (theArgVec[2]);
7873 if (aNewZNear >= aNewZFar)
7875 std::cout << theArgVec[0] << ": invalid arguments: znear should be less than zfar.\n";
7879 if (!aCamera->IsOrthographic() && (aNewZNear <= 0.0 || aNewZFar <= 0.0))
7881 std::cout << theArgVec[0] << ": invalid arguments: ";
7882 std::cout << "znear, zfar should be positive for perspective camera.\n";
7886 aCamera->SetZRange (aNewZNear, aNewZFar);
7890 std::cout << theArgVec[0] << ": wrong command arguments. Type help for more information.\n";
7894 aCurrentView->Redraw();
7899 //===============================================================================================
7900 //function : VAutoZFit
7902 //===============================================================================================
7903 static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
7905 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
7907 if (aCurrentView.IsNull())
7909 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
7913 Standard_Real aScale = aCurrentView->AutoZFitScaleFactor();
7917 std::cout << theArgVec[0] << ": wrong command arguments. Type help for more information.\n";
7923 theDi << "Auto z-fit mode: \n"
7924 << "On: " << (aCurrentView->AutoZFitMode() ? "enabled" : "disabled") << "\n"
7925 << "Scale: " << aScale << "\n";
7929 Standard_Boolean isOn = Draw::Atoi (theArgVec[1]) == 1;
7933 aScale = Draw::Atoi (theArgVec[2]);
7936 aCurrentView->SetAutoZFitMode (isOn, aScale);
7937 aCurrentView->AutoZFit();
7938 aCurrentView->Redraw();
7943 //! Auxiliary function to print projection type
7944 inline const char* projTypeName (Graphic3d_Camera::Projection theProjType)
7946 switch (theProjType)
7948 case Graphic3d_Camera::Projection_Orthographic: return "orthographic";
7949 case Graphic3d_Camera::Projection_Perspective: return "perspective";
7950 case Graphic3d_Camera::Projection_Stereo: return "stereoscopic";
7951 case Graphic3d_Camera::Projection_MonoLeftEye: return "monoLeftEye";
7952 case Graphic3d_Camera::Projection_MonoRightEye: return "monoRightEye";
7957 //===============================================================================================
7958 //function : VCamera
7960 //===============================================================================================
7961 static int VCamera (Draw_Interpretor& theDI,
7962 Standard_Integer theArgsNb,
7963 const char** theArgVec)
7965 Handle(V3d_View) aView = ViewerTest::CurrentView();
7968 std::cout << "Error: no active view.\n";
7972 Handle(Graphic3d_Camera) aCamera = aView->Camera();
7975 theDI << "ProjType: " << projTypeName (aCamera->ProjectionType()) << "\n";
7976 theDI << "FOVy: " << aCamera->FOVy() << "\n";
7977 theDI << "Distance: " << aCamera->Distance() << "\n";
7978 theDI << "IOD: " << aCamera->IOD() << "\n";
7979 theDI << "IODType: " << (aCamera->GetIODType() == Graphic3d_Camera::IODType_Absolute ? "absolute" : "relative") << "\n";
7980 theDI << "ZFocus: " << aCamera->ZFocus() << "\n";
7981 theDI << "ZFocusType: " << (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Absolute ? "absolute" : "relative") << "\n";
7985 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
7987 Standard_CString anArg = theArgVec[anArgIter];
7988 TCollection_AsciiString anArgCase (anArg);
7989 anArgCase.LowerCase();
7990 if (anArgCase == "-proj"
7991 || anArgCase == "-projection"
7992 || anArgCase == "-projtype"
7993 || anArgCase == "-projectiontype")
7995 theDI << projTypeName (aCamera->ProjectionType()) << " ";
7997 else if (anArgCase == "-ortho"
7998 || anArgCase == "-orthographic")
8000 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
8002 else if (anArgCase == "-persp"
8003 || anArgCase == "-perspective"
8004 || anArgCase == "-perspmono"
8005 || anArgCase == "-perspectivemono"
8006 || anArgCase == "-mono")
8008 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
8010 else if (anArgCase == "-stereo"
8011 || anArgCase == "-stereoscopic"
8012 || anArgCase == "-perspstereo"
8013 || anArgCase == "-perspectivestereo")
8015 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
8017 else if (anArgCase == "-left"
8018 || anArgCase == "-lefteye"
8019 || anArgCase == "-monoleft"
8020 || anArgCase == "-monolefteye"
8021 || anArgCase == "-perpsleft"
8022 || anArgCase == "-perpslefteye")
8024 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
8026 else if (anArgCase == "-right"
8027 || anArgCase == "-righteye"
8028 || anArgCase == "-monoright"
8029 || anArgCase == "-monorighteye"
8030 || anArgCase == "-perpsright")
8032 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
8034 else if (anArgCase == "-dist"
8035 || anArgCase == "-distance")
8037 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
8038 if (anArgValue != NULL
8039 && *anArgValue != '-')
8042 aCamera->SetDistance (Draw::Atof (anArgValue));
8045 theDI << aCamera->Distance() << " ";
8047 else if (anArgCase == "-iod")
8049 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
8050 if (anArgValue != NULL
8051 && *anArgValue != '-')
8054 aCamera->SetIOD (aCamera->GetIODType(), Draw::Atof (anArgValue));
8057 theDI << aCamera->IOD() << " ";
8059 else if (anArgCase == "-iodtype")
8061 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
8062 TCollection_AsciiString anValueCase (anArgValue);
8063 anValueCase.LowerCase();
8064 if (anValueCase == "abs"
8065 || anValueCase == "absolute")
8068 aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD());
8071 else if (anValueCase == "rel"
8072 || anValueCase == "relative")
8075 aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD());
8078 else if (*anArgValue != '-')
8080 std::cout << "Error: unknown IOD type '" << anArgValue << "'\n";
8083 switch (aCamera->GetIODType())
8085 case Graphic3d_Camera::IODType_Absolute: theDI << "absolute "; break;
8086 case Graphic3d_Camera::IODType_Relative: theDI << "relative "; break;
8089 else if (anArgCase == "-zfocus")
8091 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
8092 if (anArgValue != NULL
8093 && *anArgValue != '-')
8096 aCamera->SetZFocus (aCamera->ZFocusType(), Draw::Atof (anArgValue));
8099 theDI << aCamera->ZFocus() << " ";
8101 else if (anArgCase == "-zfocustype")
8103 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
8104 TCollection_AsciiString anValueCase (anArgValue);
8105 anValueCase.LowerCase();
8106 if (anValueCase == "abs"
8107 || anValueCase == "absolute")
8110 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus());
8113 else if (anValueCase == "rel"
8114 || anValueCase == "relative")
8117 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus());
8120 else if (*anArgValue != '-')
8122 std::cout << "Error: unknown ZFocus type '" << anArgValue << "'\n";
8125 switch (aCamera->ZFocusType())
8127 case Graphic3d_Camera::FocusType_Absolute: theDI << "absolute "; break;
8128 case Graphic3d_Camera::FocusType_Relative: theDI << "relative "; break;
8131 else if (anArgCase == "-fov"
8132 || anArgCase == "-fovy")
8134 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
8135 if (anArgValue != NULL
8136 && *anArgValue != '-')
8139 aCamera->SetFOVy (Draw::Atof (anArgValue));
8142 theDI << aCamera->FOVy() << " ";
8146 std::cout << "Error: unknown argument '" << anArg << "'\n";
8157 //! Parse stereo output mode
8158 inline Standard_Boolean parseStereoMode (Standard_CString theArg,
8159 Graphic3d_StereoMode& theMode)
8161 TCollection_AsciiString aFlag (theArg);
8163 if (aFlag == "quadbuffer")
8165 theMode = Graphic3d_StereoMode_QuadBuffer;
8167 else if (aFlag == "anaglyph")
8169 theMode = Graphic3d_StereoMode_Anaglyph;
8171 else if (aFlag == "row"
8172 || aFlag == "rowinterlaced")
8174 theMode = Graphic3d_StereoMode_RowInterlaced;
8176 else if (aFlag == "col"
8177 || aFlag == "colinterlaced"
8178 || aFlag == "columninterlaced")
8180 theMode = Graphic3d_StereoMode_ColumnInterlaced;
8182 else if (aFlag == "chess"
8183 || aFlag == "chessboard")
8185 theMode = Graphic3d_StereoMode_ChessBoard;
8187 else if (aFlag == "sbs"
8188 || aFlag == "sidebyside")
8190 theMode = Graphic3d_StereoMode_SideBySide;
8192 else if (aFlag == "ou"
8193 || aFlag == "overunder")
8195 theMode = Graphic3d_StereoMode_OverUnder;
8197 else if (aFlag == "pageflip"
8198 || aFlag == "softpageflip")
8200 theMode = Graphic3d_StereoMode_SoftPageFlip;
8204 return Standard_False;
8206 return Standard_True;
8209 //! Parse anaglyph filter
8210 inline Standard_Boolean parseAnaglyphFilter (Standard_CString theArg,
8211 Graphic3d_RenderingParams::Anaglyph& theFilter)
8213 TCollection_AsciiString aFlag (theArg);
8215 if (aFlag == "redcyansimple")
8217 theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
8219 else if (aFlag == "redcyan"
8220 || aFlag == "redcyanoptimized")
8222 theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized;
8224 else if (aFlag == "yellowbluesimple")
8226 theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple;
8228 else if (aFlag == "yellowblue"
8229 || aFlag == "yellowblueoptimized")
8231 theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized;
8233 else if (aFlag == "greenmagenta"
8234 || aFlag == "greenmagentasimple")
8236 theFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple;
8240 return Standard_False;
8242 return Standard_True;
8245 //==============================================================================
8246 //function : VStereo
8248 //==============================================================================
8250 static int VStereo (Draw_Interpretor& theDI,
8251 Standard_Integer theArgNb,
8252 const char** theArgVec)
8254 Handle(V3d_View) aView = ViewerTest::CurrentView();
8259 std::cout << "Error: no active viewer!\n";
8263 Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
8264 theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
8267 TCollection_AsciiString aMode;
8268 switch (aView->RenderingParams().StereoMode)
8270 case Graphic3d_StereoMode_QuadBuffer : aMode = "quadBuffer"; break;
8271 case Graphic3d_StereoMode_RowInterlaced : aMode = "rowInterlaced"; break;
8272 case Graphic3d_StereoMode_ColumnInterlaced : aMode = "columnInterlaced"; break;
8273 case Graphic3d_StereoMode_ChessBoard : aMode = "chessBoard"; break;
8274 case Graphic3d_StereoMode_SideBySide : aMode = "sideBySide"; break;
8275 case Graphic3d_StereoMode_OverUnder : aMode = "overUnder"; break;
8276 case Graphic3d_StereoMode_SoftPageFlip : aMode = "softpageflip"; break;
8277 case Graphic3d_StereoMode_Anaglyph :
8279 switch (aView->RenderingParams().AnaglyphFilter)
8281 case Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple : aMode.AssignCat (" (redCyanSimple)"); break;
8282 case Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized : aMode.AssignCat (" (redCyan)"); break;
8283 case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple : aMode.AssignCat (" (yellowBlueSimple)"); break;
8284 case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized: aMode.AssignCat (" (yellowBlue)"); break;
8285 case Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple : aMode.AssignCat (" (greenMagentaSimple)"); break;
8290 theDI << "Mode " << aMode << "\n";
8295 Handle(Graphic3d_Camera) aCamera;
8296 Graphic3d_RenderingParams* aParams = NULL;
8297 Graphic3d_StereoMode aMode = Graphic3d_StereoMode_QuadBuffer;
8298 if (!aView.IsNull())
8300 aParams = &aView->ChangeRenderingParams();
8301 aMode = aParams->StereoMode;
8302 aCamera = aView->Camera();
8305 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
8306 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
8308 Standard_CString anArg = theArgVec[anArgIter];
8309 TCollection_AsciiString aFlag (anArg);
8311 if (anUpdateTool.parseRedrawMode (aFlag))
8315 else if (aFlag == "0"
8318 if (++anArgIter < theArgNb)
8320 std::cout << "Error: wrong number of arguments!\n";
8324 if (!aCamera.IsNull()
8325 && aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
8327 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
8329 ViewerTest_myDefaultCaps.contextStereo = Standard_False;
8332 else if (aFlag == "1"
8335 if (++anArgIter < theArgNb)
8337 std::cout << "Error: wrong number of arguments!\n";
8341 if (!aCamera.IsNull())
8343 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
8345 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
8348 else if (aFlag == "-reverse"
8349 || aFlag == "-reversed"
8350 || aFlag == "-swap")
8352 Standard_Boolean toEnable = Standard_True;
8353 if (++anArgIter < theArgNb
8354 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
8358 aParams->ToReverseStereo = toEnable;
8360 else if (aFlag == "-noreverse"
8361 || aFlag == "-noswap")
8363 Standard_Boolean toDisable = Standard_True;
8364 if (++anArgIter < theArgNb
8365 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
8369 aParams->ToReverseStereo = !toDisable;
8371 else if (aFlag == "-mode"
8372 || aFlag == "-stereomode")
8374 if (++anArgIter >= theArgNb
8375 || !parseStereoMode (theArgVec[anArgIter], aMode))
8377 std::cout << "Error: syntax error at '" << anArg << "'\n";
8381 if (aMode == Graphic3d_StereoMode_QuadBuffer)
8383 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
8386 else if (aFlag == "-anaglyph"
8387 || aFlag == "-anaglyphfilter")
8389 Graphic3d_RenderingParams::Anaglyph aFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
8390 if (++anArgIter >= theArgNb
8391 || !parseAnaglyphFilter (theArgVec[anArgIter], aFilter))
8393 std::cout << "Error: syntax error at '" << anArg << "'\n";
8397 aMode = Graphic3d_StereoMode_Anaglyph;
8398 aParams->AnaglyphFilter = aFilter;
8400 else if (parseStereoMode (anArg, aMode)) // short syntax
8402 if (aMode == Graphic3d_StereoMode_QuadBuffer)
8404 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
8409 std::cout << "Error: syntax error at '" << anArg << "'\n";
8414 if (!aView.IsNull())
8416 aParams->StereoMode = aMode;
8417 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
8422 //===============================================================================================
8423 //function : VDefaults
8425 //===============================================================================================
8426 static int VDefaults (Draw_Interpretor& theDi,
8427 Standard_Integer theArgsNb,
8428 const char** theArgVec)
8430 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
8433 std::cerr << "No active viewer!\n";
8437 Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer();
8440 if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE)
8442 theDi << "DeflType: relative\n"
8443 << "DeviationCoeff: " << aDefParams->DeviationCoefficient() << "\n";
8447 theDi << "DeflType: absolute\n"
8448 << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n";
8450 theDi << "AngularDeflection: " << (180.0 * aDefParams->HLRAngle() / M_PI) << "\n";
8451 theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n";
8455 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
8457 TCollection_AsciiString anArg (theArgVec[anArgIter]);
8459 if (anArg == "-ABSDEFL"
8460 || anArg == "-ABSOLUTEDEFLECTION"
8462 || anArg == "-DEFLECTION")
8464 if (++anArgIter >= theArgsNb)
8466 std::cout << "Error: wrong syntax at " << anArg << "\n";
8469 aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
8470 aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter]));
8472 else if (anArg == "-RELDEFL"
8473 || anArg == "-RELATIVEDEFLECTION"
8474 || anArg == "-DEVCOEFF"
8475 || anArg == "-DEVIATIONCOEFF"
8476 || anArg == "-DEVIATIONCOEFFICIENT")
8478 if (++anArgIter >= theArgsNb)
8480 std::cout << "Error: wrong syntax at " << anArg << "\n";
8483 aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
8484 aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter]));
8486 else if (anArg == "-ANGDEFL"
8487 || anArg == "-ANGULARDEFL"
8488 || anArg == "-ANGULARDEFLECTION")
8490 if (++anArgIter >= theArgsNb)
8492 std::cout << "Error: wrong syntax at " << anArg << "\n";
8495 // currently HLRDeviationAngle is used instead of DeviationAngle in most places
8496 aDefParams->SetHLRAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0);
8498 else if (anArg == "-AUTOTR"
8499 || anArg == "-AUTOTRIANG"
8500 || anArg == "-AUTOTRIANGULATION")
8502 if (++anArgIter >= theArgsNb)
8504 std::cout << "Error: wrong syntax at " << anArg << "\n";
8507 TCollection_AsciiString aValue (theArgVec[anArgIter]);
8512 aDefParams->SetAutoTriangulation (Standard_True);
8514 else if (aValue == "off"
8517 aDefParams->SetAutoTriangulation (Standard_False);
8522 std::cerr << "Warning, unknown argument '" << anArg.ToCString() << "'\n";
8529 //! Auxiliary method
8530 inline void addLight (const Handle(V3d_Light)& theLightNew,
8531 const Standard_Boolean theIsGlobal)
8533 if (theLightNew.IsNull())
8540 ViewerTest::GetViewerFromContext()->SetLightOn (theLightNew);
8544 ViewerTest::CurrentView()->SetLightOn (theLightNew);
8548 //! Auxiliary method
8549 inline Standard_Integer getLightId (const TCollection_AsciiString& theArgNext)
8551 TCollection_AsciiString anArgNextCase (theArgNext);
8552 anArgNextCase.UpperCase();
8553 if (anArgNextCase.Length() > 5
8554 && anArgNextCase.SubString (1, 5).IsEqual ("LIGHT"))
8556 return theArgNext.SubString (6, theArgNext.Length()).IntegerValue();
8560 return theArgNext.IntegerValue();
8564 //===============================================================================================
8567 //===============================================================================================
8568 static int VLight (Draw_Interpretor& theDi,
8569 Standard_Integer theArgsNb,
8570 const char** theArgVec)
8572 Handle(V3d_View) aView = ViewerTest::CurrentView();
8573 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
8575 || aViewer.IsNull())
8577 std::cerr << "No active viewer!\n";
8581 Standard_Real anXYZ[3] = {};
8582 Standard_Real anAtten[2] = {};
8585 // print lights info
8586 Standard_Integer aLightId = 0;
8587 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightId)
8589 Handle(V3d_Light) aLight = aLightIter.Value();
8590 const Quantity_Color aColor = aLight->Color();
8591 theDi << "Light" << aLightId << "\n";
8592 switch (aLight->Type())
8596 theDi << " Type: Ambient\n";
8597 theDi << " Intensity: " << aLight->Intensity() << "\n";
8600 case V3d_DIRECTIONAL:
8602 Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLight);
8603 theDi << " Type: Directional\n";
8604 theDi << " Intensity: " << aLight->Intensity() << "\n";
8605 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
8606 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
8607 if (!aLightDir.IsNull())
8609 aLightDir->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
8610 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
8611 aLightDir->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
8612 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
8616 case V3d_POSITIONAL:
8618 Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight)::DownCast (aLight);
8619 theDi << " Type: Positional\n";
8620 theDi << " Intensity: " << aLight->Intensity() << "\n";
8621 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
8622 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
8623 if (!aLightPos.IsNull())
8625 aLightPos->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
8626 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
8627 aLightPos->Attenuation (anAtten[0], anAtten[1]);
8628 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
8634 Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight)::DownCast (aLight);
8635 theDi << " Type: Spot\n";
8636 theDi << " Intensity: " << aLight->Intensity() << "\n";
8637 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
8638 if (!aLightSpot.IsNull())
8640 aLightSpot->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
8641 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
8642 aLightSpot->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
8643 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
8644 aLightSpot->Attenuation (anAtten[0], anAtten[1]);
8645 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
8646 theDi << " Angle: " << (aLightSpot->Angle() * 180.0 / M_PI) << "\n";
8647 theDi << " Exponent: " << aLightSpot->Concentration() << "\n";
8653 theDi << " Type: UNKNOWN\n";
8657 theDi << " Color: " << aColor.Red() << ", " << aColor.Green() << ", " << aColor.Blue() << "\n";
8661 Handle(V3d_Light) aLightNew;
8662 Handle(V3d_Light) aLightOld;
8663 Standard_Boolean isGlobal = Standard_True;
8664 Standard_Boolean toCreate = Standard_False;
8665 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
8667 Handle(V3d_Light) aLightCurr = aLightNew.IsNull() ? aLightOld : aLightNew;
8668 Handle(V3d_AmbientLight) aLightAmb = Handle(V3d_AmbientLight) ::DownCast (aLightCurr);
8669 Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLightCurr);
8670 Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight) ::DownCast (aLightCurr);
8671 Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight) ::DownCast (aLightCurr);
8673 TCollection_AsciiString aName, aValue;
8674 const TCollection_AsciiString anArg (theArgVec[anArgIt]);
8675 TCollection_AsciiString anArgCase (anArg);
8676 anArgCase.UpperCase();
8677 if (anArgCase.IsEqual ("NEW")
8678 || anArgCase.IsEqual ("ADD")
8679 || anArgCase.IsEqual ("CREATE"))
8681 toCreate = Standard_True;
8683 else if (anArgCase.IsEqual ("GLOB")
8684 || anArgCase.IsEqual ("GLOBAL"))
8686 isGlobal = Standard_True;
8688 else if (anArgCase.IsEqual ("LOC")
8689 || anArgCase.IsEqual ("LOCAL"))
8691 isGlobal = Standard_False;
8693 else if (anArgCase.IsEqual ("DEF")
8694 || anArgCase.IsEqual ("DEFAULTS"))
8696 toCreate = Standard_False;
8697 aViewer->SetDefaultLights();
8699 else if (anArgCase.IsEqual ("CLR")
8700 || anArgCase.IsEqual ("CLEAR"))
8702 toCreate = Standard_False;
8703 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More();)
8705 Handle(V3d_Light) aLight = aLightIter.Value();
8706 aViewer->DelLight (aLight);
8707 aLightIter = aView->ActiveLightIterator();
8710 else if (anArgCase.IsEqual ("AMB")
8711 || anArgCase.IsEqual ("AMBIENT")
8712 || anArgCase.IsEqual ("AMBLIGHT"))
8714 addLight (aLightNew, isGlobal);
8717 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8720 toCreate = Standard_False;
8721 aLightNew = new V3d_AmbientLight (aViewer);
8723 else if (anArgCase.IsEqual ("DIRECTIONAL")
8724 || anArgCase.IsEqual ("DIRLIGHT"))
8726 addLight (aLightNew, isGlobal);
8729 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8732 toCreate = Standard_False;
8733 aLightNew = new V3d_DirectionalLight (aViewer);
8735 else if (anArgCase.IsEqual ("SPOT")
8736 || anArgCase.IsEqual ("SPOTLIGHT"))
8738 addLight (aLightNew, isGlobal);
8741 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8744 toCreate = Standard_False;
8745 aLightNew = new V3d_SpotLight (aViewer, 0.0, 0.0, 0.0);
8747 else if (anArgCase.IsEqual ("POSLIGHT")
8748 || anArgCase.IsEqual ("POSITIONAL"))
8750 addLight (aLightNew, isGlobal);
8753 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8756 toCreate = Standard_False;
8757 aLightNew = new V3d_PositionalLight (aViewer, 0.0, 0.0, 0.0);
8759 else if (anArgCase.IsEqual ("CHANGE"))
8761 addLight (aLightNew, isGlobal);
8762 aLightNew.Nullify();
8763 if (++anArgIt >= theArgsNb)
8765 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8769 const Standard_Integer aLightId = getLightId (theArgVec[anArgIt]);
8770 Standard_Integer aLightIt = 0;
8771 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt)
8773 if (aLightIt == aLightId)
8775 aLightOld = aLightIter.Value();
8780 if (aLightOld.IsNull())
8782 std::cerr << "Light " << theArgVec[anArgIt] << " is undefined!\n";
8786 else if (anArgCase.IsEqual ("DEL")
8787 || anArgCase.IsEqual ("DELETE"))
8789 Handle(V3d_Light) aLightDel;
8790 if (++anArgIt >= theArgsNb)
8792 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8796 const TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
8797 const Standard_Integer aLightDelId = getLightId (theArgVec[anArgIt]);
8798 Standard_Integer aLightIt = 0;
8799 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt)
8801 aLightDel = aLightIter.Value();
8802 if (aLightIt == aLightDelId)
8807 if (!aLightDel.IsNull())
8809 aViewer->DelLight (aLightDel);
8812 else if (anArgCase.IsEqual ("COLOR")
8813 || anArgCase.IsEqual ("COLOUR"))
8815 if (++anArgIt >= theArgsNb)
8817 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8821 TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
8822 anArgNext.UpperCase();
8823 const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString());
8824 if (!aLightCurr.IsNull())
8826 aLightCurr->SetColor (aColor);
8829 else if (anArgCase.IsEqual ("POS")
8830 || anArgCase.IsEqual ("POSITION"))
8832 if ((anArgIt + 3) >= theArgsNb)
8834 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8838 anXYZ[0] = Atof (theArgVec[++anArgIt]);
8839 anXYZ[1] = Atof (theArgVec[++anArgIt]);
8840 anXYZ[2] = Atof (theArgVec[++anArgIt]);
8841 if (!aLightDir.IsNull())
8843 aLightDir->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
8845 else if (!aLightPos.IsNull())
8847 aLightPos->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
8849 else if (!aLightSpot.IsNull())
8851 aLightSpot->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
8855 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8859 else if (anArgCase.IsEqual ("DIR")
8860 || anArgCase.IsEqual ("DIRECTION"))
8862 if ((anArgIt + 3) >= theArgsNb)
8864 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8868 anXYZ[0] = Atof (theArgVec[++anArgIt]);
8869 anXYZ[1] = Atof (theArgVec[++anArgIt]);
8870 anXYZ[2] = Atof (theArgVec[++anArgIt]);
8871 if (!aLightDir.IsNull())
8873 aLightDir->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
8875 else if (!aLightSpot.IsNull())
8877 aLightSpot->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
8881 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8885 else if (anArgCase.IsEqual ("SM")
8886 || anArgCase.IsEqual ("SMOOTHNESS"))
8888 if (++anArgIt >= theArgsNb)
8890 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8894 Standard_Real aSmoothness = Atof (theArgVec[anArgIt]);
8896 if (fabs (aSmoothness) < Precision::Confusion())
8898 aLightCurr->SetIntensity (1.f);
8900 else if (fabs (aLightCurr->Smoothness()) < Precision::Confusion())
8902 aLightCurr->SetIntensity ((aSmoothness * aSmoothness) / 3.f);
8906 Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightCurr->Smoothness());
8907 aLightCurr->SetIntensity (aLightCurr->Intensity() / (aSmoothnessRatio * aSmoothnessRatio));
8910 if (!aLightPos.IsNull())
8912 aLightPos->SetSmoothRadius (aSmoothness);
8914 else if (!aLightDir.IsNull())
8916 aLightDir->SetSmoothAngle (aSmoothness);
8919 else if (anArgCase.IsEqual ("INT")
8920 || anArgCase.IsEqual ("INTENSITY"))
8922 if (++anArgIt >= theArgsNb)
8924 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8928 Standard_Real aIntensity = Atof (theArgVec[anArgIt]);
8930 if (!aLightCurr.IsNull())
8932 aLightCurr->SetIntensity (aIntensity);
8935 else if (anArgCase.IsEqual ("ANG")
8936 || anArgCase.IsEqual ("ANGLE"))
8938 if (++anArgIt >= theArgsNb)
8940 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8944 Standard_Real anAngle = Atof (theArgVec[anArgIt]);
8946 if (!aLightSpot.IsNull())
8948 aLightSpot->SetAngle (anAngle / 180.0 * M_PI);
8951 else if (anArgCase.IsEqual ("CONSTATTEN")
8952 || anArgCase.IsEqual ("CONSTATTENUATION"))
8954 if (++anArgIt >= theArgsNb)
8956 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8960 if (!aLightPos.IsNull())
8962 aLightPos->Attenuation (anAtten[0], anAtten[1]);
8963 anAtten[0] = Atof (theArgVec[anArgIt]);
8964 aLightPos->SetAttenuation (anAtten[0], anAtten[1]);
8966 else if (!aLightSpot.IsNull())
8968 aLightSpot->Attenuation (anAtten[0], anAtten[1]);
8969 anAtten[0] = Atof (theArgVec[anArgIt]);
8970 aLightSpot->SetAttenuation (anAtten[0], anAtten[1]);
8974 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8978 else if (anArgCase.IsEqual ("LINATTEN")
8979 || anArgCase.IsEqual ("LINEARATTEN")
8980 || anArgCase.IsEqual ("LINEARATTENUATION"))
8982 if (++anArgIt >= theArgsNb)
8984 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
8988 if (!aLightPos.IsNull())
8990 aLightPos->Attenuation (anAtten[0], anAtten[1]);
8991 anAtten[1] = Atof (theArgVec[anArgIt]);
8992 aLightPos->SetAttenuation (anAtten[0], anAtten[1]);
8994 else if (!aLightSpot.IsNull())
8996 aLightSpot->Attenuation (anAtten[0], anAtten[1]);
8997 anAtten[1] = Atof (theArgVec[anArgIt]);
8998 aLightSpot->SetAttenuation (anAtten[0], anAtten[1]);
9002 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
9006 else if (anArgCase.IsEqual ("EXP")
9007 || anArgCase.IsEqual ("EXPONENT")
9008 || anArgCase.IsEqual ("SPOTEXP")
9009 || anArgCase.IsEqual ("SPOTEXPONENT"))
9011 if (++anArgIt >= theArgsNb)
9013 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
9017 if (!aLightSpot.IsNull())
9019 aLightSpot->SetConcentration (Atof (theArgVec[anArgIt]));
9023 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
9027 else if (anArgCase.IsEqual ("HEAD")
9028 || anArgCase.IsEqual ("HEADLIGHT"))
9030 if (++anArgIt >= theArgsNb)
9032 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
9036 if (aLightAmb.IsNull()
9037 && !aLightCurr.IsNull())
9039 aLightCurr->SetHeadlight (Draw::Atoi (theArgVec[anArgIt]) != 0);
9043 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
9049 std::cerr << "Warning: unknown argument '" << anArg << "'\n";
9053 addLight (aLightNew, isGlobal);
9054 aViewer->UpdateLights();
9059 //=======================================================================
9060 //function : VRenderParams
9061 //purpose : Enables/disables rendering features
9062 //=======================================================================
9064 static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
9065 Standard_Integer theArgNb,
9066 const char** theArgVec)
9068 Handle(V3d_View) aView = ViewerTest::CurrentView();
9071 std::cerr << "Error: no active viewer!\n";
9075 Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
9076 TCollection_AsciiString aCmdName (theArgVec[0]);
9077 aCmdName.LowerCase();
9078 if (aCmdName == "vraytrace")
9082 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "on" : "off") << " ";
9085 else if (theArgNb == 2)
9087 TCollection_AsciiString aValue (theArgVec[1]);
9092 aParams.Method = Graphic3d_RM_RAYTRACING;
9096 else if (aValue == "off"
9099 aParams.Method = Graphic3d_RM_RASTERIZATION;
9105 std::cout << "Error: unknown argument '" << theArgVec[1] << "'\n";
9111 std::cout << "Error: wrong number of arguments\n";
9118 theDI << "renderMode: ";
9119 switch (aParams.Method)
9121 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
9122 case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break;
9125 theDI << "transparency: ";
9126 switch (aParams.TransparencyMethod)
9128 case Graphic3d_RTM_BLEND_UNORDERED: theDI << "Basic blended transparency with non-commuting operator "; break;
9129 case Graphic3d_RTM_BLEND_OIT: theDI << "Weighted Blended Order-Independent Transparency, depth weight factor: "
9130 << TCollection_AsciiString (aParams.OitDepthFactor); break;
9133 theDI << "msaa: " << aParams.NbMsaaSamples << "\n";
9134 theDI << "rendScale: " << aParams.RenderResolutionScale << "\n";
9135 theDI << "rayDepth: " << aParams.RaytracingDepth << "\n";
9136 theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n";
9137 theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n";
9138 theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
9139 theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
9140 theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
9141 theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n";
9142 theDI << "iss: " << (aParams.AdaptiveScreenSampling ? "on" : "off") << "\n";
9143 theDI << "iss debug: " << (aParams.ShowSamplingTiles ? "on" : "off") << "\n";
9144 theDI << "two-sided BSDF: " << (aParams.TwoSidedBsdfModels ? "on" : "off") << "\n";
9145 theDI << "max radiance: " << aParams.RadianceClampingValue << "\n";
9146 theDI << "nb tiles (iss): " << aParams.NbRayTracingTiles << "\n";
9147 theDI << "shadingModel: ";
9148 switch (aView->ShadingModel())
9150 case V3d_COLOR: theDI << "color"; break;
9151 case V3d_FLAT: theDI << "flat"; break;
9152 case V3d_GOURAUD: theDI << "gouraud"; break;
9153 case V3d_PHONG: theDI << "phong"; break;
9159 Standard_Boolean toPrint = Standard_False;
9160 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
9161 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
9163 Standard_CString anArg (theArgVec[anArgIter]);
9164 TCollection_AsciiString aFlag (anArg);
9166 if (anUpdateTool.parseRedrawMode (aFlag))
9170 else if (aFlag == "-echo"
9171 || aFlag == "-print")
9173 toPrint = Standard_True;
9174 anUpdateTool.Invalidate();
9176 else if (aFlag == "-mode"
9177 || aFlag == "-rendermode"
9178 || aFlag == "-render_mode")
9182 switch (aParams.Method)
9184 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
9185 case Graphic3d_RM_RAYTRACING: theDI << "ray-tracing "; break;
9191 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9195 else if (aFlag == "-ray"
9196 || aFlag == "-raytrace")
9200 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "true" : "false") << " ";
9204 aParams.Method = Graphic3d_RM_RAYTRACING;
9206 else if (aFlag == "-rast"
9207 || aFlag == "-raster"
9208 || aFlag == "-rasterization")
9212 theDI << (aParams.Method == Graphic3d_RM_RASTERIZATION ? "true" : "false") << " ";
9216 aParams.Method = Graphic3d_RM_RASTERIZATION;
9218 else if (aFlag == "-msaa")
9222 theDI << aParams.NbMsaaSamples << " ";
9225 else if (++anArgIter >= theArgNb)
9227 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9231 const Standard_Integer aNbSamples = Draw::Atoi (theArgVec[anArgIter]);
9234 std::cerr << "Error: invalid number of MSAA samples " << aNbSamples << ".\n";
9239 aParams.NbMsaaSamples = aNbSamples;
9242 else if (aFlag == "-oit")
9246 if (aParams.TransparencyMethod == Graphic3d_RTM_BLEND_OIT)
9248 theDI << "on, depth weight factor: " << TCollection_AsciiString (aParams.OitDepthFactor) << " ";
9252 theDI << "off" << " ";
9256 else if (++anArgIter >= theArgNb)
9258 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9262 TCollection_AsciiString aParam = theArgVec[anArgIter];
9264 if (aParam.IsRealValue())
9266 const Standard_ShortReal aWeight = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
9267 if (aWeight < 0.f || aWeight > 1.f)
9269 std::cerr << "Error: invalid value of Weighted Order-Independent Transparency depth weight factor " << aWeight << ". Should be within range [0.0; 1.0]\n";
9273 aParams.TransparencyMethod = Graphic3d_RTM_BLEND_OIT;
9274 aParams.OitDepthFactor = aWeight;
9276 else if (aParam == "off")
9278 aParams.TransparencyMethod = Graphic3d_RTM_BLEND_UNORDERED;
9282 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9286 else if (aFlag == "-rendscale"
9287 || aFlag == "-renderscale"
9288 || aFlag == "-renderresolutionscale")
9292 theDI << aParams.RenderResolutionScale << " ";
9295 else if (++anArgIter >= theArgNb)
9297 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9301 const Standard_Real aScale = Draw::Atof (theArgVec[anArgIter]);
9304 std::cerr << "Error: invalid rendering resolution scale " << aScale << ".\n";
9309 aParams.RenderResolutionScale = Standard_ShortReal(aScale);
9312 else if (aFlag == "-raydepth"
9313 || aFlag == "-ray_depth")
9317 theDI << aParams.RaytracingDepth << " ";
9320 else if (++anArgIter >= theArgNb)
9322 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9326 const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]);
9328 // We allow RaytracingDepth be more than 10 in case of GI enabled
9329 if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled))
9331 std::cerr << "Error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]\n";
9336 aParams.RaytracingDepth = aDepth;
9339 else if (aFlag == "-shad"
9340 || aFlag == "-shadows")
9344 theDI << (aParams.IsShadowEnabled ? "on" : "off") << " ";
9348 Standard_Boolean toEnable = Standard_True;
9349 if (++anArgIter < theArgNb
9350 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9354 aParams.IsShadowEnabled = toEnable;
9356 else if (aFlag == "-refl"
9357 || aFlag == "-reflections")
9361 theDI << (aParams.IsReflectionEnabled ? "on" : "off") << " ";
9365 Standard_Boolean toEnable = Standard_True;
9366 if (++anArgIter < theArgNb
9367 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9371 aParams.IsReflectionEnabled = toEnable;
9373 else if (aFlag == "-fsaa")
9377 theDI << (aParams.IsAntialiasingEnabled ? "on" : "off") << " ";
9381 Standard_Boolean toEnable = Standard_True;
9382 if (++anArgIter < theArgNb
9383 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9387 aParams.IsAntialiasingEnabled = toEnable;
9389 else if (aFlag == "-gleam")
9393 theDI << (aParams.IsTransparentShadowEnabled ? "on" : "off") << " ";
9397 Standard_Boolean toEnable = Standard_True;
9398 if (++anArgIter < theArgNb
9399 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9403 aParams.IsTransparentShadowEnabled = toEnable;
9405 else if (aFlag == "-gi")
9409 theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " ";
9413 Standard_Boolean toEnable = Standard_True;
9414 if (++anArgIter < theArgNb
9415 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9419 aParams.IsGlobalIlluminationEnabled = toEnable;
9422 aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
9425 else if (aFlag == "-blockedrng"
9426 || aFlag == "-brng")
9430 theDI << (aParams.CoherentPathTracingMode ? "on" : "off") << " ";
9434 Standard_Boolean toEnable = Standard_True;
9435 if (++anArgIter < theArgNb
9436 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9440 aParams.CoherentPathTracingMode = toEnable;
9442 else if (aFlag == "-maxrad")
9446 theDI << aParams.RadianceClampingValue << " ";
9449 else if (++anArgIter >= theArgNb)
9451 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9455 const TCollection_AsciiString aMaxRadStr = theArgVec[anArgIter];
9456 if (!aMaxRadStr.IsRealValue())
9458 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9462 const Standard_Real aMaxRadiance = aMaxRadStr.RealValue();
9463 if (aMaxRadiance <= 0.0)
9465 std::cerr << "Error: invalid radiance clamping value " << aMaxRadiance << ".\n";
9470 aParams.RadianceClampingValue = static_cast<Standard_ShortReal> (aMaxRadiance);
9473 else if (aFlag == "-iss")
9477 theDI << (aParams.AdaptiveScreenSampling ? "on" : "off") << " ";
9481 Standard_Boolean toEnable = Standard_True;
9482 if (++anArgIter < theArgNb
9483 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9487 aParams.AdaptiveScreenSampling = toEnable;
9489 else if (aFlag == "-issd")
9493 theDI << (aParams.ShowSamplingTiles ? "on" : "off") << " ";
9497 Standard_Boolean toEnable = Standard_True;
9498 if (++anArgIter < theArgNb
9499 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9503 aParams.ShowSamplingTiles = toEnable;
9505 else if (aFlag == "-nbtiles")
9509 theDI << aParams.NbRayTracingTiles << " ";
9512 else if (++anArgIter >= theArgNb)
9514 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9518 const Standard_Integer aNbTiles = Draw::Atoi (theArgVec[anArgIter]);
9522 std::cerr << "Error: invalid number of ISS tiles " << aNbTiles << ".\n";
9523 std::cerr << "Specify value in range [64, 1024].\n";
9528 aParams.NbRayTracingTiles = aNbTiles;
9531 else if (aFlag == "-env")
9535 theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " ";
9539 Standard_Boolean toEnable = Standard_True;
9540 if (++anArgIter < theArgNb
9541 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9545 aParams.UseEnvironmentMapBackground = toEnable;
9547 else if (aFlag == "-twoside")
9551 theDI << (aParams.TwoSidedBsdfModels ? "on" : "off") << " ";
9555 Standard_Boolean toEnable = Standard_True;
9556 if (++anArgIter < theArgNb
9557 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9561 aParams.TwoSidedBsdfModels = toEnable;
9563 else if (aFlag == "-shademodel"
9564 || aFlag == "-shadingmodel"
9565 || aFlag == "-shading")
9569 switch (aView->ShadingModel())
9571 case V3d_COLOR: theDI << "color "; break;
9572 case V3d_FLAT: theDI << "flat "; break;
9573 case V3d_GOURAUD: theDI << "gouraud "; break;
9574 case V3d_PHONG: theDI << "phong "; break;
9579 if (++anArgIter >= theArgNb)
9581 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9584 TCollection_AsciiString aMode (theArgVec[anArgIter]);
9586 if (aMode == "color"
9589 aView->SetShadingModel (V3d_COLOR);
9591 else if (aMode == "flat"
9592 || aMode == "facet")
9594 aView->SetShadingModel (V3d_FLAT);
9596 else if (aMode == "gouraud"
9597 || aMode == "vertex"
9600 aView->SetShadingModel (V3d_GOURAUD);
9602 else if (aMode == "phong"
9603 || aMode == "fragment"
9605 || aMode == "pixel")
9607 aView->SetShadingModel (V3d_PHONG);
9611 std::cout << "Error: unknown shading model '" << aMode << "'\n";
9615 else if (aFlag == "-resolution")
9617 if (++anArgIter >= theArgNb)
9619 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
9623 TCollection_AsciiString aResolution (theArgVec[anArgIter]);
9624 if (aResolution.IsIntegerValue())
9626 aView->ChangeRenderingParams().Resolution = static_cast<unsigned int> (Draw::Atoi (aResolution.ToCString()));
9630 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9634 else if (aFlag == "-rebuildglsl"
9635 || aFlag == "-rebuild")
9639 theDI << (aParams.RebuildRayTracingShaders ? "on" : "off") << " ";
9643 Standard_Boolean toEnable = Standard_True;
9644 if (++anArgIter < theArgNb
9645 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
9649 aParams.RebuildRayTracingShaders = toEnable;
9651 else if (aFlag == "-focal")
9653 if (++anArgIter >= theArgNb)
9655 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9659 TCollection_AsciiString aParam (theArgVec[anArgIter]);
9660 if (aParam.IsRealValue())
9662 float aFocalDist = static_cast<float> (aParam.RealValue());
9665 std::cout << "Error: parameter can't be negative at argument '" << anArg << "'.\n";
9668 aView->ChangeRenderingParams().CameraFocalPlaneDist = aFocalDist;
9672 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9676 else if (aFlag == "-aperture")
9678 if (++anArgIter >= theArgNb)
9680 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9684 TCollection_AsciiString aParam(theArgVec[anArgIter]);
9685 if (aParam.IsRealValue())
9687 float aApertureSize = static_cast<float> (aParam.RealValue());
9688 if (aApertureSize < 0)
9690 std::cout << "Error: parameter can't be negative at argument '" << anArg << "'.\n";
9693 aView->ChangeRenderingParams().CameraApertureRadius = aApertureSize;
9697 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9701 else if (aFlag == "-exposure")
9703 if (++anArgIter >= theArgNb)
9705 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9709 TCollection_AsciiString anExposure (theArgVec[anArgIter]);
9710 if (anExposure.IsRealValue())
9712 aView->ChangeRenderingParams().Exposure = static_cast<float> (anExposure.RealValue());
9716 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9720 else if (aFlag == "-whitepoint")
9722 if (++anArgIter >= theArgNb)
9724 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9728 TCollection_AsciiString aWhitePoint (theArgVec[anArgIter]);
9729 if (aWhitePoint.IsRealValue())
9731 aView->ChangeRenderingParams().WhitePoint = static_cast<float> (aWhitePoint.RealValue());
9735 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9739 else if (aFlag == "-tonemapping")
9741 if (++anArgIter >= theArgNb)
9743 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9747 TCollection_AsciiString aMode (theArgVec[anArgIter]);
9750 if (aMode == "disabled")
9752 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Disabled;
9754 else if (aMode == "filmic")
9756 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Filmic;
9760 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9766 std::cout << "Error: wrong syntax, unknown flag '" << anArg << "'\n";
9774 //=======================================================================
9775 //function : VProgressiveMode
9777 //=======================================================================
9779 static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/,
9780 Standard_Integer /*theNbArgs*/,
9781 const char** /*theArgs*/)
9783 Handle(V3d_View) aView = ViewerTest::CurrentView();
9786 std::cerr << "Error: no active viewer!\n";
9790 std::cout << "Press Enter or Escape key to exit progressive rendering mode" << std::endl;
9796 Standard_Boolean toExit = Standard_False;
9799 while (PeekMessageW (&aMsg, NULL, 0, 0, PM_REMOVE))
9801 if (aMsg.message == WM_KEYDOWN && (aMsg.wParam == 0x0d || aMsg.wParam == 0x1b))
9803 toExit = Standard_True;
9806 TranslateMessage (&aMsg);
9807 DispatchMessageW (&aMsg);
9820 //=======================================================================
9821 //function : VFrustumCulling
9822 //purpose : enables/disables view volume's culling.
9823 //=======================================================================
9824 static int VFrustumCulling (Draw_Interpretor& theDI,
9825 Standard_Integer theArgNb,
9826 const char** theArgVec)
9828 Handle(V3d_View) aView = ViewerTest::CurrentView();
9831 std::cout << theArgVec[0] << " Error: Use 'vinit' command before\n";
9837 theDI << (aView->IsCullingEnabled() ? "on" : "off");
9840 else if (theArgNb != 2)
9842 std::cout << theArgVec[0] << " Syntax error: Specify the mode\n";
9846 TCollection_AsciiString aModeStr (theArgVec[1]);
9847 aModeStr.LowerCase();
9848 Standard_Boolean toEnable = 0;
9849 if (aModeStr == "on")
9853 else if (aModeStr == "off")
9859 toEnable = Draw::Atoi (theArgVec[1]) != 0;
9862 aView->SetFrustumCulling (toEnable);
9867 //=======================================================================
9868 //function : VHighlightSelected
9870 //=======================================================================
9871 static int VHighlightSelected (Draw_Interpretor& theDI,
9872 Standard_Integer theArgNb,
9873 const char** theArgVec)
9875 if (ViewerTest::GetAISContext().IsNull())
9877 std::cout << theArgVec[0] << " error : Context is not created. Please call vinit before.\n";
9881 const Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
9885 theDI << (aContext->ToHilightSelected() ? "on" : "off");
9891 std::cout << theArgVec[0] << " error : wrong number of parameters."
9892 << "Type 'help" << theArgVec[0] << "' for more information.";
9897 TCollection_AsciiString aMode (theArgVec[1]);
9899 Standard_Boolean toEnable = Standard_False;
9900 if (aMode.IsEqual ("on"))
9902 toEnable = Standard_True;
9904 else if (aMode.IsEqual ("off"))
9906 toEnable = Standard_False;
9910 toEnable = Draw::Atoi (theArgVec[1]) != 0;
9913 if (toEnable != aContext->ToHilightSelected())
9915 aContext->SetToHilightSelected (toEnable);
9917 // Move cursor to null position and back to process updating of detection
9918 // and highlighting of selected object immediatly.
9919 Standard_Integer aPixX = 0;
9920 Standard_Integer aPixY = 0;
9921 const Handle(ViewerTest_EventManager)& anEventManager = ViewerTest::CurrentEventManager();
9923 anEventManager->GetCurrentPosition (aPixX, aPixY);
9924 anEventManager->MoveTo (0, 0);
9925 anEventManager->MoveTo (aPixX, aPixY);
9931 //=======================================================================
9932 //function : VXRotate
9934 //=======================================================================
9935 static Standard_Integer VXRotate (Draw_Interpretor& di,
9936 Standard_Integer argc,
9939 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
9940 if (aContext.IsNull())
9942 di << argv[0] << "ERROR : use 'vinit' command before \n";
9948 di << "ERROR : Usage : " << argv[0] << " name angle\n";
9952 TCollection_AsciiString aName (argv[1]);
9953 Standard_Real anAngle = Draw::Atof (argv[2]);
9956 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
9957 Handle(AIS_InteractiveObject) anIObj;
9958 if (!aMap.IsBound2 (aName) )
9960 di << "Use 'vdisplay' before\n";
9965 anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
9968 aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle);
9969 aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart());
9971 aContext->SetLocation (anIObj, aTransform);
9972 aContext->UpdateCurrentViewer();
9978 //===============================================================================================
9979 //class : ViewerTest_AISManipulator
9980 //purpose : Proxy class maintaining automated registry map to enlist existing AIS_Manipulator instances
9981 //===============================================================================================
9982 DEFINE_STANDARD_HANDLE (ViewerTest_AISManipulator, AIS_Manipulator)
9984 class ViewerTest_AISManipulator : public AIS_Manipulator
9988 ViewerTest_AISManipulator() : AIS_Manipulator()
9990 GetMapOfAISManipulators().Add (this);
9993 virtual ~ViewerTest_AISManipulator()
9995 GetMapOfAISManipulators().Remove (this);
9998 DEFINE_STANDARD_RTTIEXT(ViewerTest_AISManipulator, AIS_Manipulator)
10001 IMPLEMENT_STANDARD_HANDLE (ViewerTest_AISManipulator, AIS_Manipulator)
10002 IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_AISManipulator, AIS_Manipulator)
10004 //===============================================================================================
10005 //function : VManipulator
10007 //===============================================================================================
10008 static int VManipulator (Draw_Interpretor& theDi,
10009 Standard_Integer theArgsNb,
10010 const char** theArgVec)
10012 Handle(V3d_View) aView = ViewerTest::CurrentView();
10013 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
10014 ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_False);
10016 || aViewer.IsNull())
10018 std::cerr << "No active viewer!\n";
10022 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
10023 Standard_Integer anArgIter = 1;
10024 for (; anArgIter < theArgsNb; ++anArgIter)
10026 anUpdateTool.parseRedrawMode (theArgVec[anArgIter]);
10029 ViewerTest_CmdParser aCmd;
10030 aCmd.AddDescription ("Manages manipulator for interactive objects:");
10031 aCmd.AddOption ("attach", "... object - attach manipulator to an object");
10032 aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
10033 aCmd.AddOption ("adjustSize", "... {0|1} - adjust size when attaching ");
10034 aCmd.AddOption ("enableModes", "... {0|1} - enable modes when attaching ");
10035 aCmd.AddOption ("detach", "... - detach manipulator");
10037 aCmd.AddOption ("startTransform", "... mouse_x mouse_y - invoke start transformation");
10038 aCmd.AddOption ("transform", "... mouse_x mouse_y - invoke transformation");
10039 aCmd.AddOption ("stopTransform", "... [abort] - invoke stop transformation");
10041 aCmd.AddOption ("move", "... x y z - move object");
10042 aCmd.AddOption ("rotate", "... x y z dx dy dz angle - rotate object");
10043 aCmd.AddOption ("scale", "... factor - scale object");
10045 aCmd.AddOption ("autoActivate", "... {0|1} - set activation on detection");
10046 aCmd.AddOption ("followTranslation", "... {0|1} - set following translation transform");
10047 aCmd.AddOption ("followRotation", "... {0|1} - set following rotation transform");
10048 aCmd.AddOption ("gap", "... value - set gap between sub-parts");
10049 aCmd.AddOption ("part", "... axis mode {0|1} - set visual part");
10050 aCmd.AddOption ("pos", "... x y z [nx ny nz [xx xy xz]] - set position of manipulator");
10051 aCmd.AddOption ("size", "... size - set size of manipulator");
10052 aCmd.AddOption ("zoomable", "... {0|1} - set zoom persistence");
10054 aCmd.Parse (theArgsNb, theArgVec);
10056 if (aCmd.HasOption ("help"))
10058 theDi.PrintHelp (theArgVec[0]);
10062 ViewerTest_DoubleMapOfInteractiveAndName& aMapAIS = GetMapOfAIS();
10064 TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
10066 if (aName.IsEmpty())
10068 std::cerr << theArgVec[0] << " error: please specify AIS manipulator's name as the first argument.\n";
10072 // ----------------------------------
10073 // detach existing manipulator object
10074 // ----------------------------------
10076 if (aCmd.HasOption ("detach"))
10078 if (!aMapAIS.IsBound2 (aName))
10080 std::cerr << theArgVec[0] << " error: could not find \"" << aName << "\" AIS object.\n";
10084 Handle(AIS_Manipulator) aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
10085 if (aManipulator.IsNull())
10087 std::cerr << theArgVec[0] << " error: \"" << aName << "\" is not an AIS manipulator.\n";
10091 aManipulator->Detach();
10092 aMapAIS.UnBind2 (aName);
10093 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_True);
10098 // -----------------------------------------------
10099 // find or create manipulator if it does not exist
10100 // -----------------------------------------------
10102 Handle(AIS_Manipulator) aManipulator;
10103 if (!aMapAIS.IsBound2 (aName))
10105 std::cout << theArgVec[0] << ": AIS object \"" << aName << "\" has been created.\n";
10107 aManipulator = new ViewerTest_AISManipulator();
10108 aMapAIS.Bind (aManipulator, aName);
10112 aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
10113 if (aManipulator.IsNull())
10115 std::cerr << theArgVec[0] << " error: \"" << aName << "\" is not an AIS manipulator.\n";
10120 // -----------------------------------------
10121 // change properties of manipulator instance
10122 // -----------------------------------------
10124 if (aCmd.HasOption ("autoActivate", 1, Standard_True))
10126 aManipulator->SetModeActivationOnDetection (aCmd.ArgBool ("autoActivate"));
10128 if (aCmd.HasOption ("followTranslation", 1, Standard_True))
10130 aManipulator->ChangeTransformBehavior().SetFollowTranslation (aCmd.ArgBool ("followTranslation"));
10132 if (aCmd.HasOption ("followRotation", 1, Standard_True))
10134 aManipulator->ChangeTransformBehavior().SetFollowRotation (aCmd.ArgBool ("followRotation"));
10136 if (aCmd.HasOption ("gap", 1, Standard_True))
10138 aManipulator->SetGap (aCmd.ArgFloat ("gap"));
10140 if (aCmd.HasOption ("part", 3, Standard_True))
10142 Standard_Integer anAxis = aCmd.ArgInt ("part", 0);
10143 Standard_Integer aMode = aCmd.ArgInt ("part", 1);
10144 Standard_Boolean aOnOff = aCmd.ArgBool ("part", 2);
10145 if (aMode < 1 || aMode > 3)
10147 std::cerr << theArgVec[0] << " error: mode value should be in range [1, 3].\n";
10151 aManipulator->SetPart (anAxis, static_cast<AIS_ManipulatorMode> (aMode), aOnOff);
10153 if (aCmd.HasOption ("pos", 3, Standard_True))
10155 gp_Pnt aLocation = aCmd.ArgPnt ("pos", 0);
10156 gp_Dir aVDir = aCmd.HasOption ("pos", 6) ? gp_Dir (aCmd.ArgVec ("pos", 3)) : aManipulator->Position().Direction();
10157 gp_Dir aXDir = aCmd.HasOption ("pos", 9) ? gp_Dir (aCmd.ArgVec ("pos", 6)) : aManipulator->Position().XDirection();
10159 aManipulator->SetPosition (gp_Ax2 (aLocation, aVDir, aXDir));
10161 if (aCmd.HasOption ("size", 1, Standard_True))
10163 aManipulator->SetSize (aCmd.ArgFloat ("size"));
10165 if (aCmd.HasOption ("zoomable", 1, Standard_True))
10167 aManipulator->SetZoomPersistence (!aCmd.ArgBool ("zoomable"));
10169 if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator))
10171 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_False);
10172 ViewerTest::GetAISContext()->Display (aManipulator, Standard_False);
10176 // ---------------------------------------------------
10177 // attach, detach or access manipulator from an object
10178 // ---------------------------------------------------
10180 if (aCmd.HasOption ("attach"))
10182 // Find an object and attach manipulator to it
10183 if (!aCmd.HasOption ("attach", 1, Standard_True))
10188 TCollection_AsciiString anObjName (aCmd.Arg ("attach", 0).c_str());
10189 if (!aMapAIS.IsBound2 (anObjName))
10191 std::cerr << theArgVec[0] << " error: AIS object \"" << anObjName << "\" does not exist.\n";
10195 Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (aMapAIS.Find2 (anObjName));
10196 ViewerTest_MapOfAISManipulators::Iterator anIt (GetMapOfAISManipulators());
10197 for (; anIt.More(); anIt.Next())
10199 if (anIt.Value()->IsAttached()
10200 && anIt.Value()->Object() == anObject)
10202 std::cerr << theArgVec[0] << " error: AIS object \"" << anObjName << "\" already has manipulator.\n";
10207 AIS_Manipulator::OptionsForAttach anOptions;
10208 if (aCmd.HasOption ("adjustPosition", 1, Standard_True))
10210 anOptions.SetAdjustPosition (aCmd.ArgBool ("adjustPosition"));
10212 if (aCmd.HasOption ("adjustSize", 1, Standard_True))
10214 anOptions.SetAdjustSize (aCmd.ArgBool ("adjustSize"));
10216 if (aCmd.HasOption ("enableModes", 1, Standard_True))
10218 anOptions.SetEnableModes (aCmd.ArgBool ("enableModes"));
10221 aManipulator->Attach (anObject, anOptions);
10224 // --------------------------------------
10225 // apply transformation using manipulator
10226 // --------------------------------------
10228 if (aCmd.HasOption ("startTransform", 2, Standard_True))
10230 aManipulator->StartTransform (aCmd.ArgInt ("startTransform", 0), aCmd.ArgInt ("startTransform", 1), ViewerTest::CurrentView());
10232 if (aCmd.HasOption ("transform", 2, Standard_True))
10234 aManipulator->Transform (aCmd.ArgInt ("transform", 0), aCmd.ArgInt ("transform", 1), ViewerTest::CurrentView());
10236 if (aCmd.HasOption ("stopTransform"))
10238 Standard_Boolean toApply = !aCmd.HasOption ("stopTransform", 1) || (aCmd.Arg ("stopTransform", 0) != "abort");
10240 aManipulator->StopTransform (toApply);
10244 if (aCmd.HasOption ("move", 3, Standard_True))
10246 aT.SetTranslationPart (aCmd.ArgVec ("move"));
10248 if (aCmd.HasOption ("rotate", 7, Standard_True))
10250 aT.SetRotation (gp_Ax1 (aCmd.ArgPnt ("rotate", 0), aCmd.ArgVec ("rotate", 3)), aCmd.ArgDouble ("rotate", 6));
10252 if (aCmd.HasOption ("scale", 1))
10254 aT.SetScale (gp_Pnt(), aCmd.ArgDouble("scale"));
10257 if (aT.Form() != gp_Identity)
10259 aManipulator->Transform (aT);
10262 ViewerTest::GetAISContext()->Redisplay (aManipulator, Standard_True);
10267 //===============================================================================================
10268 //function : VSelectionProperties
10270 //===============================================================================================
10271 static int VSelectionProperties (Draw_Interpretor& theDi,
10272 Standard_Integer theArgsNb,
10273 const char** theArgVec)
10275 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
10278 std::cerr << "No active viewer!\n";
10282 Standard_Boolean toPrint = theArgsNb == 1;
10283 Standard_Boolean toRedraw = Standard_False;
10284 Standard_Integer anArgIter = 1;
10285 Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None;
10286 if (anArgIter < theArgsNb)
10288 TCollection_AsciiString anArgFirst (theArgVec[anArgIter]);
10289 anArgFirst.LowerCase();
10291 if (anArgFirst == "dynhighlight"
10292 || anArgFirst == "dynhilight"
10293 || anArgFirst == "dynamichighlight"
10294 || anArgFirst == "dynamichilight")
10296 aType = Prs3d_TypeOfHighlight_Dynamic;
10298 else if (anArgFirst == "localdynhighlight"
10299 || anArgFirst == "localdynhilight"
10300 || anArgFirst == "localdynamichighlight"
10301 || anArgFirst == "localdynamichilight")
10303 aType = Prs3d_TypeOfHighlight_LocalDynamic;
10305 else if (anArgFirst == "selhighlight"
10306 || anArgFirst == "selhilight"
10307 || anArgFirst == "selectedhighlight"
10308 || anArgFirst == "selectedhilight")
10310 aType = Prs3d_TypeOfHighlight_Selected;
10312 else if (anArgFirst == "localselhighlight"
10313 || anArgFirst == "localselhilight"
10314 || anArgFirst == "localselectedhighlight"
10315 || anArgFirst == "localselectedhilight")
10317 aType = Prs3d_TypeOfHighlight_LocalSelected;
10324 for (; anArgIter < theArgsNb; ++anArgIter)
10326 TCollection_AsciiString anArg (theArgVec[anArgIter]);
10328 if (anArg == "-help")
10330 theDi.PrintHelp (theArgVec[0]);
10333 else if (anArg == "-print")
10335 toPrint = Standard_True;
10337 else if (anArg == "-autoactivate")
10339 Standard_Boolean toEnable = Standard_True;
10340 if (anArgIter + 1 < theArgsNb
10341 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
10345 aCtx->SetAutoActivateSelection (toEnable);
10347 else if (anArg == "-pickstrategy"
10348 || anArg == "-pickingstrategy")
10350 if (++anArgIter >= theArgsNb)
10352 std::cout << "Syntax error: type of highlighting is undefined\n";
10356 SelectMgr_PickingStrategy aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
10357 TCollection_AsciiString aVal (theArgVec[anArgIter]);
10359 if (aVal == "first"
10360 || aVal == "firstaccepted"
10361 || aVal == "firstacceptable")
10363 aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
10365 else if (aVal == "topmost"
10366 || aVal == "onlyTopmost")
10368 aStrategy = SelectMgr_PickingStrategy_OnlyTopmost;
10372 std::cout << "Syntax error: unknwon picking strategy '" << aVal << "'\n";
10376 aCtx->SetPickingStrategy (aStrategy);
10378 else if (anArg == "-pixtol"
10379 && anArgIter + 1 < theArgsNb)
10381 aCtx->SetPixelTolerance (Draw::Atoi (theArgVec[++anArgIter]));
10383 else if ((anArg == "-mode"
10384 || anArg == "-dispmode")
10385 && anArgIter + 1 < theArgsNb)
10387 if (aType == Prs3d_TypeOfHighlight_None)
10389 std::cout << "Syntax error: type of highlighting is undefined\n";
10393 const Standard_Integer aDispMode = Draw::Atoi (theArgVec[++anArgIter]);
10394 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10395 aStyle->SetDisplayMode (aDispMode);
10396 toRedraw = Standard_True;
10398 else if (anArg == "-layer"
10399 && anArgIter + 1 < theArgsNb)
10401 if (aType == Prs3d_TypeOfHighlight_None)
10403 std::cout << "Syntax error: type of highlighting is undefined\n";
10407 const Standard_Integer aNewLayer = Draw::Atoi (theArgVec[++anArgIter]);
10408 if (aNewLayer != Graphic3d_ZLayerId_UNKNOWN)
10410 TColStd_SequenceOfInteger aLayers;
10411 aCtx->CurrentViewer()->GetAllZLayers (aLayers);
10412 if (std::find (aLayers.begin(), aLayers.end(), aNewLayer) == aLayers.end())
10414 std::cout << "Syntax error: Layer " << aNewLayer << " is undefined\n";
10419 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10420 aStyle->SetZLayer (aNewLayer);
10421 toRedraw = Standard_True;
10423 else if (anArg == "-hicolor"
10424 || anArg == "-selcolor"
10425 || anArg == "-color")
10427 if (anArg.StartsWith ("-hi"))
10429 aType = Prs3d_TypeOfHighlight_Dynamic;
10431 else if (anArg.StartsWith ("-sel"))
10433 aType = Prs3d_TypeOfHighlight_Selected;
10435 else if (aType == Prs3d_TypeOfHighlight_None)
10437 std::cout << "Syntax error: type of highlighting is undefined\n";
10441 Quantity_Color aColor;
10442 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIter - 1,
10443 theArgVec + anArgIter + 1,
10445 if (aNbParsed == 0)
10447 std::cout << "Syntax error: need more arguments.\n";
10450 anArgIter += aNbParsed;
10452 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10453 aStyle->SetColor (aColor);
10454 toRedraw = Standard_True;
10456 else if ((anArg == "-transp"
10457 || anArg == "-transparency"
10458 || anArg == "-hitransp"
10459 || anArg == "-seltransp"
10460 || anArg == "-hitransplocal"
10461 || anArg == "-seltransplocal")
10462 && anArgIter + 1 < theArgsNb)
10464 if (anArg.StartsWith ("-hi"))
10466 aType = Prs3d_TypeOfHighlight_Dynamic;
10468 else if (anArg.StartsWith ("-sel"))
10470 aType = Prs3d_TypeOfHighlight_Selected;
10472 else if (aType == Prs3d_TypeOfHighlight_None)
10474 std::cout << "Syntax error: type of highlighting is undefined\n";
10478 const Standard_Real aTransp = Draw::Atof (theArgVec[++anArgIter]);
10479 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10480 aStyle->SetTransparency ((Standard_ShortReal )aTransp);
10481 toRedraw = Standard_True;
10483 else if ((anArg == "-mat"
10484 || anArg == "-material")
10485 && anArgIter + 1 < theArgsNb)
10487 if (aType == Prs3d_TypeOfHighlight_None)
10489 std::cout << "Syntax error: type of highlighting is undefined\n";
10493 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10494 Graphic3d_NameOfMaterial aMatName = Graphic3d_MaterialAspect::MaterialFromName (theArgVec[anArgIter + 1]);
10495 if (aMatName != Graphic3d_NOM_DEFAULT)
10498 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
10499 *anAspect = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
10500 Graphic3d_MaterialAspect aMat (aMatName);
10501 aMat.SetColor (aStyle->Color());
10502 aMat.SetTransparency (aStyle->Transparency());
10503 anAspect->SetFrontMaterial (aMat);
10504 anAspect->SetInteriorColor (aStyle->Color());
10505 aStyle->SetBasicFillAreaAspect (anAspect);
10509 aStyle->SetBasicFillAreaAspect (Handle(Graphic3d_AspectFillArea3d)());
10511 toRedraw = Standard_True;
10515 std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
10521 const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle();
10522 const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle();
10523 theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n";
10524 theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n";
10525 theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n";
10526 theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n";
10527 theDi << "Selection transparency : " << aSelStyle->Transparency() << "\n";
10528 theDi << "Dynamic highlight transparency : " << aHiStyle->Transparency() << "\n";
10529 theDi << "Selection mode : " << aSelStyle->DisplayMode() << "\n";
10530 theDi << "Dynamic highlight mode : " << aHiStyle->DisplayMode() << "\n";
10531 theDi << "Selection layer : " << aSelStyle->ZLayer() << "\n";
10532 theDi << "Dynamic layer : " << aHiStyle->ZLayer() << "\n";
10535 if (aCtx->NbSelected() != 0 && toRedraw)
10537 aCtx->HilightSelected (Standard_True);
10543 //===============================================================================================
10544 //function : VDumpSelectionImage
10546 //===============================================================================================
10547 static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
10548 Standard_Integer theArgsNb,
10549 const char** theArgVec)
10553 std::cout << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'\n";
10557 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
10558 if (aContext.IsNull())
10560 std::cout << "Error: no active view.\n";
10564 TCollection_AsciiString aFile;
10565 StdSelect_TypeOfSelectionImage aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
10566 Image_Format anImgFormat = Image_Format_BGR;
10567 Standard_Integer aPickedIndex = 1;
10568 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
10570 TCollection_AsciiString aParam (theArgVec[anArgIter]);
10571 aParam.LowerCase();
10572 if (aParam == "-type")
10574 if (++anArgIter >= theArgsNb)
10576 std::cout << "Syntax error: wrong number parameters of flag '-depth'.\n";
10580 TCollection_AsciiString aValue (theArgVec[anArgIter]);
10581 aValue.LowerCase();
10582 if (aValue == "depth"
10583 || aValue == "normdepth"
10584 || aValue == "normalizeddepth")
10586 aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
10587 anImgFormat = Image_Format_GrayF;
10589 if (aValue == "depthinverted"
10590 || aValue == "normdepthinverted"
10591 || aValue == "normalizeddepthinverted"
10592 || aValue == "inverted")
10594 aType = StdSelect_TypeOfSelectionImage_NormalizedDepthInverted;
10595 anImgFormat = Image_Format_GrayF;
10597 else if (aValue == "unnormdepth"
10598 || aValue == "unnormalizeddepth")
10600 aType = StdSelect_TypeOfSelectionImage_UnnormalizedDepth;
10601 anImgFormat = Image_Format_GrayF;
10603 else if (aValue == "objectcolor"
10604 || aValue == "object"
10605 || aValue == "color")
10607 aType = StdSelect_TypeOfSelectionImage_ColoredDetectedObject;
10609 else if (aValue == "entitycolor"
10610 || aValue == "entity")
10612 aType = StdSelect_TypeOfSelectionImage_ColoredEntity;
10614 else if (aValue == "ownercolor"
10615 || aValue == "owner")
10617 aType = StdSelect_TypeOfSelectionImage_ColoredOwner;
10619 else if (aValue == "selectionmodecolor"
10620 || aValue == "selectionmode"
10621 || aValue == "selmodecolor"
10622 || aValue == "selmode")
10624 aType = StdSelect_TypeOfSelectionImage_ColoredSelectionMode;
10627 else if (aParam == "-picked"
10628 || aParam == "-pickeddepth"
10629 || aParam == "-pickedindex")
10631 if (++anArgIter >= theArgsNb)
10633 std::cout << "Syntax error: wrong number parameters at '" << aParam << "'.\n";
10637 aPickedIndex = Draw::Atoi (theArgVec[anArgIter]);
10639 else if (aFile.IsEmpty())
10641 aFile = theArgVec[anArgIter];
10645 std::cout << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'.\n";
10649 if (aFile.IsEmpty())
10651 std::cout << "Syntax error: image file name is missing.\n";
10655 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
10656 Standard_Integer aWidth = 0, aHeight = 0;
10657 aView->Window()->Size (aWidth, aHeight);
10659 Image_AlienPixMap aPixMap;
10660 if (!aPixMap.InitZero (anImgFormat, aWidth, aHeight))
10662 std::cout << "Error: can't allocate image.\n";
10665 if (!aContext->MainSelector()->ToPixMap (aPixMap, aView, aType, aPickedIndex))
10667 std::cout << "Error: can't generate selection image.\n";
10670 if (!aPixMap.Save (aFile))
10672 std::cout << "Error: can't save selection image.\n";
10678 //=======================================================================
10679 //function : ViewerCommands
10681 //=======================================================================
10683 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
10686 const char *group = "ZeViewer";
10687 theCommands.Add("vinit",
10688 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
10689 "[name=view_name] [display=display_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n"
10691 "[name=view_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n"
10693 " - Creates new View window with specified name view_name.\n"
10694 "By default the new view is created in the viewer and in"
10695 " graphic driver shared with active view.\n"
10696 " - name = {driverName/viewerName/viewName | viewerName/viewName | viewName}.\n"
10697 "If driverName isn't specified the driver will be shared with active view.\n"
10698 "If viewerName isn't specified the viewer will be shared with active view.\n"
10699 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
10700 " - display = HostName.DisplayNumber[:ScreenNumber] : if specified"
10701 "is used in creation of graphic driver\n"
10703 " - l, t: pixel position of left top corner of the window\n"
10704 " - w,h: width and heigth of window respectively.\n"
10705 "Additional commands for operations with views: vclose, vactivate, vviewlist.\n",
10706 __FILE__,VInit,group);
10707 theCommands.Add("vclose" ,
10708 "[view_id [keep_context=0|1]]\n"
10709 "or vclose ALL - to remove all created views\n"
10710 " - removes view(viewer window) defined by its view_id.\n"
10711 " - keep_context: by default 0; if 1 and the last view is deleted"
10712 " the current context is not removed.",
10713 __FILE__,VClose,group);
10714 theCommands.Add("vactivate" ,
10716 " - activates view(viewer window) defined by its view_id",
10717 __FILE__,VActivate,group);
10718 theCommands.Add("vviewlist",
10719 "vviewlist [format={tree, long}]"
10720 " - prints current list of views per viewer and graphic_driver ID shared between viewers"
10721 " - format: format of result output, if tree the output is a tree view;"
10722 "otherwise it's a list of full view names. By default format = tree",
10723 __FILE__,VViewList,group);
10724 theCommands.Add("vhelp" ,
10725 "vhelp : display help on the viewer commands",
10726 __FILE__,VHelp,group);
10727 theCommands.Add("vtop" ,
10728 "vtop or <T> : Top view. Orientation +X+Y" ,
10729 __FILE__,VTop,group);
10730 theCommands.Add("vbottom" ,
10731 "vbottom : Bottom view. Orientation +X-Y" ,
10732 __FILE__,VBottom,group);
10733 theCommands.Add("vleft" ,
10734 "vleft : Left view. Orientation -Y+Z" ,
10735 __FILE__,VLeft,group);
10736 theCommands.Add("vright" ,
10737 "vright : Right view. Orientation +Y+Z" ,
10738 __FILE__,VRight,group);
10739 theCommands.Add("vaxo" ,
10740 " vaxo or <A> : Axonometric view. Orientation +X-Y+Z",
10741 __FILE__,VAxo,group);
10742 theCommands.Add("vfront" ,
10743 "vfront : Front view. Orientation +X+Z" ,
10744 __FILE__,VFront,group);
10745 theCommands.Add("vback" ,
10746 "vback : Back view. Orientation -X+Z" ,
10747 __FILE__,VBack,group);
10748 theCommands.Add("vpick" ,
10749 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
10751 theCommands.Add("vfit",
10752 "vfit or <F> [-selected] [-noupdate]"
10753 "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects",
10754 __FILE__,VFit,group);
10755 theCommands.Add ("vfitarea",
10756 "vfitarea x1 y1 x2 y2"
10757 "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2"
10758 "\n\t\t: Fit view to show area located between two points"
10759 "\n\t\t: given in world 2D or 3D corrdinates.",
10760 __FILE__, VFitArea, group);
10761 theCommands.Add ("vzfit", "vzfit [scale]\n"
10762 " Matches Z near, Z far view volume planes to the displayed objects.\n"
10763 " \"scale\" - specifies factor to scale computed z range.\n",
10764 __FILE__, VZFit, group);
10765 theCommands.Add("vrepaint",
10766 "vrepaint [-immediate]"
10767 "\n\t\t: force redraw",
10768 __FILE__,VRepaint,group);
10769 theCommands.Add("vclear",
10771 "\n\t\t: remove all the object from the viewer",
10772 __FILE__,VClear,group);
10773 theCommands.Add("vsetbg",
10774 "vsetbg : vsetbg imagefile [filltype] : Load image as background",
10775 __FILE__,VSetBg,group);
10776 theCommands.Add("vsetbgmode",
10777 "vsetbgmode : vsetbgmode filltype : Change background image fill type",
10778 __FILE__,VSetBgMode,group);
10779 theCommands.Add("vsetgradientbg",
10780 "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background",
10781 __FILE__,VSetGradientBg,group);
10782 theCommands.Add("vsetgrbgmode",
10783 "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type",
10784 __FILE__,VSetGradientBgMode,group);
10785 theCommands.Add("vsetcolorbg",
10786 "vsetcolorbg : vsetcolorbg r g b : Set background color",
10787 __FILE__,VSetColorBg,group);
10788 theCommands.Add("vsetdefaultbg",
10789 "vsetdefaultbg r g b\n"
10790 "\n\t\t: vsetdefaultbg r1 g1 b1 r2 g2 b2 fillmode"
10791 "\n\t\t: Set default viewer background fill color (flat/gradient).",
10792 __FILE__,VSetDefaultBg,group);
10793 theCommands.Add("vscale",
10794 "vscale : vscale X Y Z",
10795 __FILE__,VScale,group);
10796 theCommands.Add("vzbufftrihedron",
10797 "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]"
10798 "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]"
10799 "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]"
10800 "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]"
10801 "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]"
10802 "\n\t\t: Displays a trihedron",
10803 __FILE__,VZBuffTrihedron,group);
10804 theCommands.Add("vrotate",
10805 "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]"
10806 "\n : Option -mouseStart starts rotation according to the mouse position"
10807 "\n : Option -mouseMove continues rotation with angle computed"
10808 "\n : from last and new mouse position."
10809 "\n : vrotate AX AY AZ [X Y Z]",
10810 __FILE__,VRotate,group);
10811 theCommands.Add("vzoom",
10812 "vzoom : vzoom coef",
10813 __FILE__,VZoom,group);
10814 theCommands.Add("vpan",
10815 "vpan : vpan dx dy",
10816 __FILE__,VPan,group);
10817 theCommands.Add("vexport",
10818 "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }"
10819 " : exports the view to a vector file of a given format"
10820 " : notice that EMF format requires patched gl2ps",
10821 __FILE__,VExport,group);
10822 theCommands.Add("vcolorscale",
10823 "vcolorscale name [-noupdate|-update] [-demo]"
10824 "\n\t\t: [-range RangeMin=0 RangeMax=1 NbIntervals=10]"
10825 "\n\t\t: [-font HeightFont=20]"
10826 "\n\t\t: [-logarithmic {on|off}=off] [-reversed {on|off}=off]"
10827 "\n\t\t: [-smoothTransition {on|off}=off]"
10828 "\n\t\t: [-hueRange MinAngle=230 MaxAngle=0]"
10829 "\n\t\t: [-colorRange MinColor=BLUE1 MaxColor=RED]"
10830 "\n\t\t: [-textpos {left|right|center|none}=right]"
10831 "\n\t\t: [-labelAtBorder {on|off}=on]"
10832 "\n\t\t: [-colors Color1 Color2 ...] [-color Index Color]"
10833 "\n\t\t: [-labels Label1 Label2 ...] [-label Index Label]"
10834 "\n\t\t: [-freeLabels NbOfLabels Label1 Label2 ...]"
10835 "\n\t\t: [-xy Left=0 Bottom=0]"
10836 "\n\t\t: -demo - displays a color scale with demonstratio values"
10837 "\n\t\t: -colors - set colors for all intervals"
10838 "\n\t\t: -color - set color for specific interval"
10839 "\n\t\t: -textpos - horizontal label position relative to color scale bar"
10840 "\n\t\t: -labelAtBorder - vertical label position relative to color interval;"
10841 "\n\t\t: at border means the value inbetween neighbor intervals,"
10842 "\n\t\t: at center means the center value within current interval"
10843 "\n\t\t: -labels - set labels for all intervals"
10844 "\n\t\t: -freeLabels - same as -labels but does not require"
10845 "\n\t\t: matching the number of intervals"
10846 "\n\t\t: -label - set label for specific interval"
10847 "\n\t\t: -title - set title"
10848 "\n\t\t: -reversed - setup smooth color transition between intervals"
10849 "\n\t\t: -smoothTransition - swap colorscale direction"
10850 "\n\t\t: -hueRange - set hue angles corresponding to minimum and maximum values"
10851 __FILE__, VColorScale, group);
10852 theCommands.Add("vgraduatedtrihedron",
10853 "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n"
10854 "\t[-namefont Name] [-valuesfont Name]\n"
10855 "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n"
10856 "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]"
10857 "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n"
10858 "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n"
10859 "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]"
10860 "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n"
10861 "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n"
10862 "\t[-xticks Number] [-yticks Number] [-zticks Number]\n"
10863 "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n"
10864 "\t[-drawgrid on/off] [-drawaxes on/off]\n"
10865 " - Displays or erases graduated trihedron"
10866 " - xname, yname, zname - names of axes, default: X, Y, Z\n"
10867 " - namefont - font of axes names. Default: Arial\n"
10868 " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n"
10869 " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n"
10870 " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n"
10871 " - valuesfont - font of axes values. Default: Arial\n"
10872 " - xcolor, ycolor, zcolor - color of axis and values\n"
10873 " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n"
10874 " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n",
10875 __FILE__,VGraduatedTrihedron,group);
10876 theCommands.Add("vtile" ,
10877 "vtile [-totalSize W H] [-lowerLeft X Y] [-upperLeft X Y] [-tileSize W H]"
10878 "\n\t\t: Setup view to draw a tile (a part of virtual bigger viewport)."
10879 "\n\t\t: -totalSize the size of virtual bigger viewport"
10880 "\n\t\t: -tileSize tile size (the view size will be used if omitted)"
10881 "\n\t\t: -lowerLeft tile offset as lower left corner"
10882 "\n\t\t: -upperLeft tile offset as upper left corner",
10883 __FILE__, VTile, group);
10884 theCommands.Add("vzlayer",
10885 "vzlayer [layerId]"
10886 "\n\t\t: [-add|-delete|-get|-settings]"
10887 "\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
10888 "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv}]"
10889 "\n\t\t: ZLayer list management:"
10890 "\n\t\t: -add add new z layer to viewer and print its id"
10891 "\n\t\t: -delete delete z layer"
10892 "\n\t\t: -get print sequence of z layers"
10893 "\n\t\t: -settings print status of z layer settings"
10894 "\n\t\t: -disable disables given setting"
10895 "\n\t\t: -enable enables given setting",
10896 __FILE__,VZLayer,group);
10897 theCommands.Add("vlayerline",
10898 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
10899 __FILE__,VLayerLine,group);
10900 theCommands.Add ("vgrid",
10901 "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]"
10902 " : Mode - rectangular or circular"
10903 " : Type - lines or points",
10904 __FILE__, VGrid, group);
10905 theCommands.Add ("vpriviledgedplane",
10906 "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]"
10907 "\n\t\t: Ox, Oy, Oz - plane origin"
10908 "\n\t\t: Nx, Ny, Nz - plane normal direction"
10909 "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction"
10910 "\n\t\t: Sets or prints viewer's priviledged plane geometry.",
10911 __FILE__, VPriviledgedPlane, group);
10912 theCommands.Add ("vconvert",
10913 "vconvert v [Mode={window|view}]"
10914 "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]"
10915 "\n\t\t: vconvert x y z [Mode={window|grid}]"
10916 "\n\t\t: window - convert to window coordinates, pixels"
10917 "\n\t\t: view - convert to view projection plane"
10918 "\n\t\t: grid - convert to model coordinates, given on grid"
10919 "\n\t\t: ray - convert projection ray to model coordiantes"
10920 "\n\t\t: - vconvert v window : convert view to window;"
10921 "\n\t\t: - vconvert v view : convert window to view;"
10922 "\n\t\t: - vconvert x y window : convert view to window;"
10923 "\n\t\t: - vconvert x y view : convert window to view;"
10924 "\n\t\t: - vconvert x y : convert window to model;"
10925 "\n\t\t: - vconvert x y grid : convert window to model using grid;"
10926 "\n\t\t: - vconvert x y ray : convert window projection line to model;"
10927 "\n\t\t: - vconvert x y z window : convert model to window;"
10928 "\n\t\t: - vconvert x y z grid : convert view to model using grid;"
10929 "\n\t\t: Converts the given coordinates to window/view/model space.",
10930 __FILE__, VConvert, group);
10931 theCommands.Add ("vfps",
10932 "vfps [framesNb=100] : estimate average frame rate for active view",
10933 __FILE__, VFps, group);
10934 theCommands.Add ("vgldebug",
10935 "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
10936 "\n\t\t: [-extraMsg {0|1}] [{0|1}]"
10937 "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
10938 "\n\t\t: Debug context can be requested only on Windows"
10939 "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
10940 "\n\t\t: -sync - request synchronized debug GL context"
10941 "\n\t\t: -glslWarn - log GLSL compiler/linker warnings,"
10942 "\n\t\t: which are suppressed by default,"
10943 "\n\t\t: -extraMsg - log extra diagnostic messages from GL context,"
10944 "\n\t\t: which are suppressed by default",
10945 __FILE__, VGlDebug, group);
10946 theCommands.Add ("vvbo",
10947 "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
10948 __FILE__, VVbo, group);
10949 theCommands.Add ("vstereo",
10950 "vstereo [0|1] [-mode Mode] [-reverse {0|1}]"
10951 "\n\t\t: [-anaglyph Filter]"
10952 "\n\t\t: Control stereo output mode. Available modes for -mode:"
10953 "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo,"
10954 "\n\t\t: requires driver support."
10955 "\n\t\t: Should be called BEFORE vinit!"
10956 "\n\t\t: anaglyph - Anaglyph glasses"
10957 "\n\t\t: rowInterlaced - row-interlaced display"
10958 "\n\t\t: columnInterlaced - column-interlaced display"
10959 "\n\t\t: chessBoard - chess-board output"
10960 "\n\t\t: sideBySide - horizontal pair"
10961 "\n\t\t: overUnder - vertical pair"
10962 "\n\t\t: Available Anaglyph filters for -anaglyph:"
10963 "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple,"
10964 "\n\t\t: greenMagentaSimple",
10965 __FILE__, VStereo, group);
10966 theCommands.Add ("vcaps",
10967 "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
10968 "\n\t\t: [-compatibleProfile {0|1}]"
10969 "\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
10970 "\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
10971 "\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
10972 "\n\t\t: Modify particular graphic driver options:"
10973 "\n\t\t: FFP - use fixed-function pipeline instead of"
10974 "\n\t\t: built-in GLSL programs"
10975 "\n\t\t: (requires compatible profile)"
10976 "\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
10977 "\n\t\t: arrays to GPU memory)"
10978 "\n\t\t: sprite - use textured sprites instead of bitmaps"
10979 "\n\t\t: vsync - switch VSync on or off"
10980 "\n\t\t: winBuffer - allow using window buffer for rendering"
10981 "\n\t\t: Context creation options:"
10982 "\n\t\t: softMode - software OpenGL implementation"
10983 "\n\t\t: compatibleProfile - backward-compatible profile"
10984 "\n\t\t: quadbuffer - QuadBuffer"
10985 "\n\t\t: Unlike vrenderparams, these parameters control alternative"
10986 "\n\t\t: rendering paths producing the same visual result when"
10987 "\n\t\t: possible."
10988 "\n\t\t: Command is intended for testing old hardware compatibility.",
10989 __FILE__, VCaps, group);
10990 theCommands.Add ("vmemgpu",
10991 "vmemgpu [f]: print system-dependent GPU memory information if available;"
10992 " with f option returns free memory in bytes",
10993 __FILE__, VMemGpu, group);
10994 theCommands.Add ("vreadpixel",
10995 "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]"
10996 " : Read pixel value for active view",
10997 __FILE__, VReadPixel, group);
10998 theCommands.Add("diffimage",
10999 "diffimage : diffimage imageFile1 imageFile2 toleranceOfColor(0..1) blackWhite(1|0) borderFilter(1|0) [diffImageFile]",
11000 __FILE__, VDiffImage, group);
11001 theCommands.Add ("vselect",
11002 "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
11003 "- emulates different types of selection:\n"
11004 "- 1) single click selection\n"
11005 "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
11006 "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
11007 "- 4) -allowoverlap manages overlap and inclusion detection in rectangular selection.\n"
11008 " If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined rectangle will be detected,\n"
11009 " otherwise algorithm will chose only fully included sensitives. Default behavior is to detect only full inclusion. "
11010 " (partial inclusion - overlap - is not allowed by default)\n"
11011 "- 5) any of these selections with shift button pressed",
11012 __FILE__, VSelect, group);
11013 theCommands.Add ("vmoveto",
11015 "- emulates cursor movement to pixel postion (x,y)",
11016 __FILE__, VMoveTo, group);
11017 theCommands.Add ("vviewparams",
11018 "vviewparams [-args] [-scale [s]]"
11019 "\n\t\t: [-eye [x y z]] [-at [x y z]] [-up [x y z]]"
11020 "\n\t\t: [-proj [x y z]] [-center x y] [-size sx]"
11021 "\n\t\t: Manage current view parameters or prints all"
11022 "\n\t\t: current values when called without argument."
11023 "\n\t\t: -scale [s] prints or sets viewport relative scale"
11024 "\n\t\t: -eye [x y z] prints or sets eye location"
11025 "\n\t\t: -at [x y z] prints or sets center of look"
11026 "\n\t\t: -up [x y z] prints or sets direction of up vector"
11027 "\n\t\t: -proj [x y z] prints or sets direction of look"
11028 "\n\t\t: -center x y sets location of center of the screen in pixels"
11029 "\n\t\t: -size [sx] prints viewport projection width and height sizes"
11030 "\n\t\t: or changes the size of its maximum dimension"
11031 "\n\t\t: -args prints vviewparams arguments for restoring current view",
11032 __FILE__, VViewParams, group);
11034 theCommands.Add("vanimation", "Alias for vanim",
11035 __FILE__, VAnimation, group);
11037 theCommands.Add("vanim",
11038 "List existing animations:"
11040 "\n\t\t: Animation playback:"
11041 "\n\t\t: vanim name -play|-resume [playFrom [playDuration]]"
11042 "\n\t\t: [-speed Coeff] [-freeLook] [-lockLoop]"
11043 "\n\t\t: -speed playback speed (1.0 is normal speed)"
11044 "\n\t\t: -freeLook skip camera animations"
11045 "\n\t\t: -lockLoop disable any interactions"
11047 "\n\t\t: Animation definition:"
11048 "\n\t\t: vanim Name/sub/name [-clear] [-delete]"
11049 "\n\t\t: [start TimeSec] [duration TimeSec]"
11051 "\n\t\t: Animation name defined in path-style (anim/name or anim.name)"
11052 "\n\t\t: specifies nested animations."
11053 "\n\t\t: There is no syntax to explicitly add new animation,"
11054 "\n\t\t: and all non-existing animations within the name will be"
11055 "\n\t\t: implicitly created on first use (including parents)."
11057 "\n\t\t: Each animation might define the SINGLE action (see below),"
11058 "\n\t\t: like camera transition, object transformation or custom callback."
11059 "\n\t\t: Child animations can be used for defining concurrent actions."
11061 "\n\t\t: Camera animation:"
11062 "\n\t\t: vanim name -view [-eye1 X Y Z] [-eye2 X Y Z]"
11063 "\n\t\t: [-at1 X Y Z] [-at2 X Y Z]"
11064 "\n\t\t: [-up1 X Y Z] [-up2 X Y Z]"
11065 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
11066 "\n\t\t: -eyeX camera Eye positions pair (start and end)"
11067 "\n\t\t: -atX camera Center positions pair"
11068 "\n\t\t: -upX camera Up directions pair"
11069 "\n\t\t: -scaleX camera Scale factors pair"
11070 "\n\t\t: Object animation:"
11071 "\n\t\t: vanim name -object [-loc1 X Y Z] [-loc2 X Y Z]"
11072 "\n\t\t: [-rot1 QX QY QZ QW] [-rot2 QX QY QZ QW]"
11073 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
11074 "\n\t\t: -locX object Location points pair (translation)"
11075 "\n\t\t: -rotX object Orientations pair (quaternions)"
11076 "\n\t\t: -scaleX object Scale factors pair (quaternions)"
11077 "\n\t\t: Custom callback:"
11078 "\n\t\t: vanim name -invoke \"Command Arg1 Arg2 %Pts %LocalPts %Normalized ArgN\""
11079 "\n\t\t: %Pts overall animation presentation timestamp"
11080 "\n\t\t: %LocalPts local animation timestamp"
11081 "\n\t\t: %Normalized local animation normalized value in range 0..1"
11082 __FILE__, VAnimation, group);
11084 theCommands.Add("vchangeselected",
11085 "vchangeselected shape"
11086 "- adds to shape to selection or remove one from it",
11087 __FILE__, VChangeSelected, group);
11088 theCommands.Add ("vnbselected",
11090 "\n\t\t: Returns number of selected objects", __FILE__, VNbSelected, group);
11091 theCommands.Add ("vcamera",
11092 "vcamera [-ortho] [-projtype]"
11094 "\n\t\t: [-fovy [Angle]] [-distance [Distance]]"
11095 "\n\t\t: [-stereo] [-leftEye] [-rightEye]"
11096 "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]"
11097 "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]"
11098 "\n\t\t: Manage camera parameters."
11099 "\n\t\t: Prints current value when option called without argument."
11100 "\n\t\t: Orthographic camera:"
11101 "\n\t\t: -ortho activate orthographic projection"
11102 "\n\t\t: Perspective camera:"
11103 "\n\t\t: -persp activate perspective projection (mono)"
11104 "\n\t\t: -fovy field of view in y axis, in degrees"
11105 "\n\t\t: -distance distance of eye from camera center"
11106 "\n\t\t: Stereoscopic camera:"
11107 "\n\t\t: -stereo perspective projection (stereo)"
11108 "\n\t\t: -leftEye perspective projection (left eye)"
11109 "\n\t\t: -rightEye perspective projection (right eye)"
11110 "\n\t\t: -iod intraocular distance value"
11111 "\n\t\t: -iodType distance type, absolute or relative"
11112 "\n\t\t: -zfocus stereographic focus value"
11113 "\n\t\t: -zfocusType focus type, absolute or relative",
11114 __FILE__, VCamera, group);
11115 theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n"
11116 "- vautozfit [on={1|0}] [scale]\n"
11117 " Prints or changes parameters of automatic z-fit mode:\n"
11118 " \"on\" - turns automatic z-fit on or off\n"
11119 " \"scale\" - specifies factor to scale computed z range.\n",
11120 __FILE__, VAutoZFit, group);
11121 theCommands.Add ("vzrange", "command to manually access znear and zfar values\n"
11122 " vzrange - without parameters shows current values\n"
11123 " vzrange [znear] [zfar] - applies provided values to view",
11124 __FILE__,VZRange, group);
11125 theCommands.Add ("vpurgedisplay",
11127 "- removes structures which don't belong to objects displayed in neutral point",
11128 __FILE__, VPurgeDisplay, group);
11129 theCommands.Add("vsetviewsize",
11130 "vsetviewsize size",
11131 __FILE__,VSetViewSize,group);
11132 theCommands.Add("vmoveview",
11133 "vmoveview Dx Dy Dz [Start = 1|0]",
11134 __FILE__,VMoveView,group);
11135 theCommands.Add("vtranslateview",
11136 "vtranslateview Dx Dy Dz [Start = 1|0)]",
11137 __FILE__,VTranslateView,group);
11138 theCommands.Add("vturnview",
11139 "vturnview Ax Ay Az [Start = 1|0]",
11140 __FILE__,VTurnView,group);
11141 theCommands.Add("vtextureenv",
11142 "Enables or disables environment mapping in the 3D view, loading the texture from the given standard "
11143 "or user-defined file and optionally applying texture mapping parameters\n"
11145 " vtextureenv off - disables environment mapping\n"
11146 " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n"
11147 " std_texture = (0..7)\n"
11148 " rep = {clamp|repeat}\n"
11149 " mod = {decal|modulate}\n"
11150 " flt = {nearest|bilinear|trilinear}\n"
11151 " ss, st - scale factors for s and t texture coordinates\n"
11152 " ts, tt - translation for s and t texture coordinates\n"
11153 " rot - texture rotation angle in degrees",
11154 __FILE__, VTextureEnv, group);
11155 theCommands.Add("vhlr" ,
11156 "is_enabled={on|off} [show_hidden={1|0}]"
11157 " - Hidden line removal algorithm:"
11158 " - is_enabled: if is on HLR algorithm is applied\n"
11159 " - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n",
11160 __FILE__,VHLR,group);
11161 theCommands.Add("vhlrtype" ,
11162 "algo_type={algo|polyalgo} [shape_1 ... shape_n]"
11163 " - Changes the type of HLR algorithm using for shapes."
11164 " - algo_type: if equals to algo, exact HLR algorithm is applied;\n"
11165 " if equals to polyalgo, polygonal HLR algorithm is applied."
11166 "If shapes are not given HLR algoithm of given type is applied"
11167 " to all shapes in the view\n",
11168 __FILE__,VHLRType,group);
11169 theCommands.Add("vclipplane",
11170 "vclipplane planeName [{0|1}]"
11171 "\n\t\t: [-equation A B C D]"
11172 "\n\t\t: [-set|-unset [objects|views]]"
11173 "\n\t\t: [-maxPlanes]"
11174 "\n\t\t: [-capping {0|1}]"
11175 "\n\t\t: [-color R G B] [-hatch {on|off|ID}]"
11176 "\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
11177 "\n\t\t: [-texRotate Angle]"
11178 "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
11179 "\n\t\t: [-useObjShader {0|1}]"
11180 "\n\t\t: Clipping planes management:"
11181 "\n\t\t: -maxPlanes print plane limit for view"
11182 "\n\t\t: -delete delete plane with given name"
11183 "\n\t\t: {off|on|0|1} turn clipping on/off"
11184 "\n\t\t: -set|-unset set/unset plane for Object or View list;"
11185 "\n\t\t: applied to active View when list is omitted"
11186 "\n\t\t: -equation A B C D change plane equation"
11187 "\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
11188 "\n\t\t: Capping options:"
11189 "\n\t\t: -capping {off|on|0|1} turn capping on/off"
11190 "\n\t\t: -color R G B set capping color"
11191 "\n\t\t: -texName Texture set capping texture"
11192 "\n\t\t: -texScale SX SY set capping tex scale"
11193 "\n\t\t: -texOrigin TX TY set capping tex origin"
11194 "\n\t\t: -texRotate Angle set capping tex rotation"
11195 "\n\t\t: -hatch {on|off|ID} set capping hatching mask"
11196 "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
11197 "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
11198 "\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
11199 __FILE__, VClipPlane, group);
11200 theCommands.Add("vdefaults",
11201 "vdefaults [-absDefl value]"
11202 "\n\t\t: [-devCoeff value]"
11203 "\n\t\t: [-angDefl value]"
11204 "\n\t\t: [-autoTriang {off/on | 0/1}]"
11205 , __FILE__, VDefaults, group);
11206 theCommands.Add("vlight",
11207 "tool to manage light sources, without arguments shows list of lights."
11208 "\n Main commands: "
11209 "\n 'clear' to clear lights"
11210 "\n '{def}aults' to load deafault lights"
11211 "\n 'add' (or 'new') <type> to add any light source"
11212 "\n where <type> is one of {amb}ient|directional|{spot}light|positional"
11213 "\n 'change' <lightId> to edit light source with specified lightId"
11214 "\n\n In addition to 'add' and 'change' commands you can use light parameters:"
11215 "\n {pos}ition X Y Z"
11216 "\n {dir}ection X Y Z (for directional light or for spotlight)"
11217 "\n color colorName"
11218 "\n {head}light 0|1"
11219 "\n {sm}oothness value"
11220 "\n {int}ensity value"
11221 "\n {constAtten}uation value"
11222 "\n {linearAtten}uation value"
11223 "\n angle angleDeg"
11224 "\n {spotexp}onent value"
11226 "\n\n example: vlight add positional head 1 pos 0 1 1 color red"
11227 "\n example: vlight change 0 direction 0 -1 0 linearAttenuation 0.2",
11228 __FILE__, VLight, group);
11229 theCommands.Add("vraytrace",
11231 "\n\t\t: Turns on/off ray-tracing renderer."
11232 "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'."
11233 "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.",
11234 __FILE__, VRenderParams, group);
11235 theCommands.Add("vrenderparams",
11236 "\n Manages rendering parameters: "
11237 "\n '-raster' Disables GPU ray-tracing"
11238 "\n '-msaa 0..4' Specifies number of samples for MSAA"
11239 "\n '-oit off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
11240 "\n '-rendScale value Rendering resolution scale factor"
11241 "\n '-rayTrace' Enables GPU ray-tracing"
11242 "\n '-rayDepth 0..10' Defines maximum ray-tracing depth"
11243 "\n '-shadows on|off' Enables/disables shadows rendering"
11244 "\n '-reflections on|off' Enables/disables specular reflections"
11245 "\n '-fsaa on|off' Enables/disables adaptive anti-aliasing"
11246 "\n '-gleam on|off' Enables/disables transparency shadow effects"
11247 "\n '-gi on|off' Enables/disables global illumination effects"
11248 "\n '-brng on|off' Enables/disables blocked RNG (fast coherent PT)"
11249 "\n '-env on|off' Enables/disables environment map background"
11250 "\n '-twoside on|off' Enables/disables two-sided BSDF models (PT mode)"
11251 "\n '-iss on|off' Enables/disables adaptive screen sampling (PT mode)"
11252 "\n '-issd on|off' Shows screen sampling distribution in ISS mode"
11253 "\n '-maxrad > 0.0' Value used for clamping radiance estimation (PT mode)"
11254 "\n '-nbtiles 64..1024' Specifies number of screen tiles in ISS mode"
11255 "\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
11256 "\n '-shadingModel model' Controls shading model from enumeration"
11257 "\n color, flat, gouraud, phong"
11258 "\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"
11259 "\n '-aperture >= 0.0' Aperture size of perspective camera for depth-of-field effect (0 disables DOF)"
11260 "\n '-focal >= 0.0' Focal distance of perspective camera for depth-of-field effect"
11261 "\n '-exposure value' Exposure value for tone mapping (0.0 value disables the effect)"
11262 "\n '-whitepoint value' White point value for filmic tone mapping"
11263 "\n '-tonemapping mode' Tone mapping mode (disabled, filmic)"
11264 "\n Unlike vcaps, these parameters dramatically change visual properties."
11265 "\n Command is intended to control presentation quality depending on"
11266 "\n hardware capabilities and performance.",
11267 __FILE__, VRenderParams, group);
11268 theCommands.Add("vfrustumculling",
11269 "vfrustumculling [toEnable]: enables/disables objects clipping",
11270 __FILE__,VFrustumCulling,group);
11271 theCommands.Add("vhighlightselected",
11272 "vhighlightselected [0|1] or vhighlightselected [on|off]: enables/disables highlighting of selected objects.\n"
11273 "Without arguments it shows if highlighting of selected objects is enabled now.",
11274 __FILE__,VHighlightSelected,group);
11275 theCommands.Add ("vplace",
11277 "\n\t\t: Places the point (in pixels) at the center of the window",
11278 __FILE__, VPlace, group);
11279 theCommands.Add("vxrotate",
11281 __FILE__,VXRotate,group);
11283 theCommands.Add("vmanipulator",
11284 "\n vmanipulator Name [-attach AISObject | -detach | ...]"
11285 "\n tool to create and manage AIS manipulators."
11287 "\n '-attach AISObject' attach manipulator to AISObject"
11288 "\n '-adjustPosition {0|1}' adjust position when attaching"
11289 "\n '-adjustSize {0|1}' adjust size when attaching"
11290 "\n '-enableModes {0|1}' enable modes when attaching"
11291 "\n '-detach' detach manipulator"
11292 "\n '-startTransform mouse_x mouse_y' - invoke start of transformation"
11293 "\n '-transform mouse_x mouse_y' - invoke transformation"
11294 "\n '-stopTransform [abort]' - invoke stop of transformation"
11295 "\n '-move x y z' - move attached object"
11296 "\n '-rotate x y z dx dy dz angle' - rotate attached object"
11297 "\n '-scale factor' - scale attached object"
11298 "\n '-autoActivate {0|1}' - set activation on detection"
11299 "\n '-followTranslation {0|1}' - set following translation transform"
11300 "\n '-followRotation {0|1}' - set following rotation transform"
11301 "\n '-gap value' - set gap between sub-parts"
11302 "\n '-part axis mode {0|1}' - set visual part"
11303 "\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator"
11304 "\n '-size value' - set size of manipulator"
11305 "\n '-zoomable {0|1}' - set zoom persistence",
11306 __FILE__, VManipulator, group);
11308 theCommands.Add("vselprops",
11309 "\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]"
11310 "\n Customizes selection and dynamic highlight parameters for the whole interactive context:"
11311 "\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode"
11312 "\n -pickStrategy {first|topmost} : defines picking strategy"
11313 "\n 'first' to pick first acceptable (default)"
11314 "\n 'topmost' to pick only topmost (and nothing, if topmost is rejected by filters)"
11315 "\n -pixTol value : sets up pixel tolerance"
11316 "\n -dispMode dispMode : sets display mode for highlighting"
11317 "\n -layer ZLayer : sets ZLayer for highlighting"
11318 "\n -color {name|r g b} : sets highlight color"
11319 "\n -transp value : sets transparency coefficient for highlight"
11320 "\n -material material : sets highlight material"
11321 "\n -print : prints current state of all mentioned parameters",
11322 __FILE__, VSelectionProperties, group);
11324 theCommands.Add ("vseldump",
11325 "vseldump file -type {depth|unnormDepth|object|owner|selMode|entity}=depth -pickedIndex Index=1"
11326 "\n\t\t: Generate an image based on detection results:"
11327 "\n\t\t: depth normalized depth values"
11328 "\n\t\t: unnormDepth unnormalized depth values"
11329 "\n\t\t: object color of detected object"
11330 "\n\t\t: owner color of detected owner"
11331 "\n\t\t: selMode color of selection mode"
11332 "\n\t\t: entity color of etected entity",
11333 __FILE__, VDumpSelectionImage, group);
11335 #if defined(_WIN32)
11336 theCommands.Add("vprogressive",
11338 __FILE__, VProgressiveMode, group);