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);
1125 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1126 XFlush (GetDisplayConnection()->GetDisplay());
1129 // Keep context opened only if the closed view is last to avoid
1130 // unused empty contexts
1131 if (!aCurrentContext.IsNull())
1133 // Check if there are more difined views in the viewer
1134 aCurrentContext->CurrentViewer()->InitDefinedViews();
1135 if ((isContextRemoved || ViewerTest_myContexts.Size() != 1) && !aCurrentContext->CurrentViewer()->MoreDefinedViews())
1137 // Remove driver if there is no viewers that use it
1138 Standard_Boolean isRemoveDriver = Standard_True;
1139 for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1140 anIter(ViewerTest_myContexts); anIter.More(); anIter.Next())
1142 if (aCurrentContext != anIter.Key2() &&
1143 aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver())
1145 isRemoveDriver = Standard_False;
1150 aCurrentContext->RemoveAll (Standard_False);
1153 ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver());
1154 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1155 #if TCL_MAJOR_VERSION < 8
1156 Tk_DeleteFileHandler((void*)XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
1158 Tk_DeleteFileHandler(XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
1163 ViewerTest_myContexts.UnBind2(aCurrentContext);
1166 cout << "3D View - " << theViewName << " was deleted.\n";
1170 //==============================================================================
1172 //purpose : Remove the view defined by its name
1173 //==============================================================================
1175 static int VClose (Draw_Interpretor& /*theDi*/,
1176 Standard_Integer theArgsNb,
1177 const char** theArgVec)
1179 NCollection_List<TCollection_AsciiString> aViewList;
1182 TCollection_AsciiString anArg (theArgVec[1]);
1184 if (anArg.IsEqual ("ALL")
1185 || anArg.IsEqual ("*"))
1187 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
1188 anIter.More(); anIter.Next())
1190 aViewList.Append (anIter.Key1());
1192 if (aViewList.IsEmpty())
1194 std::cout << "No view to close\n";
1200 ViewerTest_Names aViewName (theArgVec[1]);
1201 if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName()))
1203 std::cerr << "The view with name '" << theArgVec[1] << "' does not exist\n";
1206 aViewList.Append (aViewName.GetViewName());
1211 // close active view
1212 if (ViewerTest::CurrentView().IsNull())
1214 std::cerr << "No active view!\n";
1217 aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView()));
1220 Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1);
1221 for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList);
1222 anIter.More(); anIter.Next())
1224 ViewerTest::RemoveView (anIter.Value(), toRemoveContext);
1230 //==============================================================================
1231 //function : VActivate
1232 //purpose : Activate the view defined by its ID
1233 //==============================================================================
1235 static int VActivate (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1239 theDi << theArgVec[0] << ": wrong number of command arguments.\n"
1240 << "Usage: " << theArgVec[0] << " ViewID\n";
1245 theDi.Eval("vviewlist");
1249 TCollection_AsciiString aNameString(theArgVec[1]);
1250 if ( strcasecmp( aNameString.ToCString(), "NONE" ) == 0 )
1252 TCollection_AsciiString aTitle("3D View - ");
1253 aTitle = aTitle + ViewerTest_myViews.Find2(ViewerTest::CurrentView());
1254 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1255 Handle(V3d_View) anEmptyView;
1256 #if defined(_WIN32) || defined(__WIN32__)
1257 Handle(WNT_Window) anEmptyWindow;
1258 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1259 Handle(Cocoa_Window) anEmptyWindow;
1261 Handle(Xw_Window) anEmptyWindow;
1263 VT_GetWindow() = anEmptyWindow;
1264 ViewerTest::CurrentView (anEmptyView);
1265 ViewerTest::ResetEventManager();
1266 theDi << theArgVec[0] << ": all views are inactive\n";
1270 ViewerTest_Names aViewNames(aNameString);
1272 // Check if this view exists in the viewer with the driver
1273 if (!ViewerTest_myViews.IsBound1(aViewNames.GetViewName()))
1275 theDi << "Wrong view name\n";
1279 // Check if it is active already
1280 if (ViewerTest::CurrentView() == ViewerTest_myViews.Find1(aViewNames.GetViewName()))
1282 theDi << theArgVec[0] << ": the view is active already\n";
1286 ActivateView (aViewNames.GetViewName());
1290 //==============================================================================
1291 //function : VViewList
1292 //purpose : Print current list of views per viewer and graphic driver ID
1293 // shared between viewers
1294 //==============================================================================
1296 static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1300 theDi << theArgVec[0] << ": Wrong number of command arguments\n"
1301 << "Usage: " << theArgVec[0] << " name";
1304 if (ViewerTest_myContexts.Size() < 1)
1307 Standard_Boolean isTreeView =
1308 (( theArgsNb==1 ) || ( strcasecmp( theArgVec[1], "long" ) != 0 ));
1312 theDi << theArgVec[0] <<":\n";
1315 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator aDriverIter (ViewerTest_myDrivers);
1316 aDriverIter.More(); aDriverIter.Next())
1319 theDi << aDriverIter.Key1() << ":\n";
1321 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1322 aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next())
1324 if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1)
1328 TCollection_AsciiString aContextName(aContextIter.Key1());
1329 theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":\n";
1332 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIter (ViewerTest_myViews);
1333 aViewIter.More(); aViewIter.Next())
1335 if (aViewIter.Key1().Search(aContextIter.Key1()) != -1)
1337 TCollection_AsciiString aViewName(aViewIter.Key1());
1340 if (aViewIter.Value() == ViewerTest::CurrentView())
1341 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)\n";
1343 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n";
1347 theDi << aViewName << " ";
1357 //==============================================================================
1358 //function : VT_ProcessKeyPress
1359 //purpose : Handle KeyPress event from a CString
1360 //==============================================================================
1361 void VT_ProcessKeyPress (const char* buf_ret)
1363 //cout << "KeyPress" << endl;
1364 const Handle(V3d_View) aView = ViewerTest::CurrentView();
1365 // Letter in alphabetic order
1367 if (!strcasecmp (buf_ret, "A"))
1370 aView->SetProj(V3d_XposYnegZpos);
1372 else if (!strcasecmp (buf_ret, "D"))
1377 else if (!strcasecmp (buf_ret, "F"))
1379 if (ViewerTest::GetAISContext()->NbSelected() > 0)
1381 ViewerTest::GetAISContext()->FitSelected (aView);
1389 else if (!strcasecmp (buf_ret, "H"))
1392 cout << "HLR" << endl;
1393 aView->SetComputedMode (!aView->ComputedMode());
1394 MyHLRIsOn = aView->ComputedMode();
1396 else if (!strcasecmp (buf_ret, "P"))
1399 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1400 if (aContext->DefaultDrawer()->TypeOfHLR() == Prs3d_TOH_Algo)
1401 aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_PolyAlgo);
1403 aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_Algo);
1404 if (aContext->NbSelected()==0)
1406 AIS_ListOfInteractive aListOfShapes;
1407 aContext->DisplayedObjects(aListOfShapes);
1408 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
1409 anIter.More(); anIter.Next())
1411 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
1412 if (aShape.IsNull())
1414 if (aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
1415 aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
1417 aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
1418 aContext->Redisplay (aShape, Standard_False);
1423 for (aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected())
1425 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->SelectedInteractive());
1426 if (aShape.IsNull())
1428 if(aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
1429 aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
1431 aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
1432 aContext->Redisplay (aShape, Standard_False);
1436 aContext->UpdateCurrentViewer();
1439 else if (!strcasecmp (buf_ret, "S"))
1441 std::cout << "setup Shaded display mode" << std::endl;
1443 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1444 if(Ctx->NbSelected()==0)
1445 Ctx->SetDisplayMode (AIS_Shaded, Standard_True);
1447 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1448 Ctx->SetDisplayMode(Ctx->SelectedInteractive(),1,Standard_False);
1449 Ctx->UpdateCurrentViewer();
1452 else if (!strcasecmp (buf_ret, "U"))
1454 // Unset display mode
1455 std::cout << "reset display mode to defaults" << std::endl;
1457 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1458 if(Ctx->NbSelected()==0)
1459 Ctx->SetDisplayMode (AIS_WireFrame, Standard_True);
1461 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1462 Ctx->UnsetDisplayMode(Ctx->SelectedInteractive(),Standard_False);
1463 Ctx->UpdateCurrentViewer();
1467 else if (!strcasecmp (buf_ret, "T"))
1470 aView->SetProj(V3d_Zpos);
1472 else if (!strcasecmp (buf_ret, "B"))
1475 aView->SetProj(V3d_Zneg);
1477 else if (!strcasecmp (buf_ret, "L"))
1480 aView->SetProj(V3d_Xneg);
1482 else if (!strcasecmp (buf_ret, "R"))
1485 aView->SetProj(V3d_Xpos);
1487 else if (!strcasecmp (buf_ret, "W"))
1489 std::cout << "setup WireFrame display mode" << std::endl;
1490 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1491 if(Ctx->NbSelected()==0)
1492 Ctx->SetDisplayMode (AIS_WireFrame, Standard_True);
1494 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1495 Ctx->SetDisplayMode(Ctx->SelectedInteractive(),0,Standard_False);
1496 Ctx->UpdateCurrentViewer();
1499 else if (!strcasecmp (buf_ret, ","))
1501 ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView());
1503 else if (!strcasecmp (buf_ret, "."))
1505 ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
1507 else if (!strcasecmp (buf_ret, "/"))
1509 Handle(Graphic3d_Camera) aCamera = aView->Camera();
1510 if (aCamera->IsStereo())
1512 aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() - 0.01);
1516 else if (!strcasecmp (buf_ret, "*"))
1518 Handle(Graphic3d_Camera) aCamera = aView->Camera();
1519 if (aCamera->IsStereo())
1521 aCamera->SetIOD (aCamera->GetIODType(), aCamera->IOD() + 0.01);
1525 else if (*buf_ret == THE_KEY_DELETE)
1527 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
1529 && aCtx->NbSelected() > 0)
1531 Draw_Interprete ("verase");
1537 Standard_Integer Num = Draw::Atoi(buf_ret);
1538 if(Num>=0 && Num<=7)
1539 ViewerTest::StandardModeActivation(Num);
1543 //==============================================================================
1544 //function : VT_ProcessExpose
1545 //purpose : Redraw the View on an Expose Event
1546 //==============================================================================
1547 void VT_ProcessExpose()
1549 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
1550 if (!aView3d.IsNull())
1556 //==============================================================================
1557 //function : VT_ProcessConfigure
1558 //purpose : Resize the View on an Configure Event
1559 //==============================================================================
1560 void VT_ProcessConfigure()
1562 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
1563 if (aView3d.IsNull())
1568 aView3d->MustBeResized();
1573 //==============================================================================
1574 //function : VT_ProcessButton1Press
1576 //==============================================================================
1577 Standard_Boolean VT_ProcessButton1Press (Standard_Integer ,
1578 const char** theArgVec,
1579 Standard_Boolean theToPick,
1580 Standard_Boolean theIsShift)
1584 TheIsAnimating = Standard_False;
1585 return Standard_False;
1590 Standard_Real X, Y, Z;
1591 ViewerTest::CurrentView()->Convert (X_Motion, Y_Motion, X, Y, Z);
1593 Draw::Set (theArgVec[1], X);
1594 Draw::Set (theArgVec[2], Y);
1595 Draw::Set (theArgVec[3], Z);
1600 ViewerTest::CurrentEventManager()->ShiftSelect();
1604 ViewerTest::CurrentEventManager()->Select();
1607 return Standard_False;
1610 //==============================================================================
1611 //function : VT_ProcessButton1Release
1612 //purpose : End selecting
1613 //==============================================================================
1614 void VT_ProcessButton1Release (Standard_Boolean theIsShift)
1618 IsDragged = Standard_False;
1619 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
1622 EM->ShiftSelect (X_ButtonPress, Y_ButtonPress,
1623 X_Motion, Y_Motion);
1627 EM->Select (X_ButtonPress, Y_ButtonPress,
1628 X_Motion, Y_Motion);
1633 //==============================================================================
1634 //function : VT_ProcessButton3Press
1635 //purpose : Start Rotation
1636 //==============================================================================
1637 void VT_ProcessButton3Press()
1642 ViewerTest::CurrentView()->SetComputedMode (Standard_False);
1644 ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress );
1647 //==============================================================================
1648 //function : VT_ProcessButton3Release
1649 //purpose : End rotation
1650 //==============================================================================
1651 void VT_ProcessButton3Release()
1658 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
1663 //==============================================================================
1664 //function : ProcessControlButton1Motion
1666 //==============================================================================
1668 #if defined(_WIN32) || ! defined(__APPLE__) || defined(MACOSX_USE_GLX)
1669 static void ProcessControlButton1Motion()
1671 ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion);
1673 X_ButtonPress = X_Motion;
1674 Y_ButtonPress = Y_Motion;
1678 //==============================================================================
1679 //function : VT_ProcessControlButton2Motion
1681 //==============================================================================
1682 void VT_ProcessControlButton2Motion()
1684 Standard_Integer aDx = X_Motion - X_ButtonPress;
1685 Standard_Integer aDy = Y_Motion - Y_ButtonPress;
1687 aDy = -aDy; // Xwindow Y axis is from top to Bottom
1689 ViewerTest::CurrentView()->Pan (aDx, aDy);
1691 X_ButtonPress = X_Motion;
1692 Y_ButtonPress = Y_Motion;
1695 //==============================================================================
1696 //function : VT_ProcessControlButton3Motion
1697 //purpose : Rotation
1698 //==============================================================================
1699 void VT_ProcessControlButton3Motion()
1703 ViewerTest::CurrentView()->Rotation (X_Motion, Y_Motion);
1707 //==============================================================================
1708 //function : VT_ProcessMotion
1710 //==============================================================================
1711 void VT_ProcessMotion()
1713 //pre-hilights detected objects at mouse position
1715 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
1716 EM->MoveTo(X_Motion, Y_Motion);
1720 void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix)
1722 Xpix = X_Motion;Ypix=Y_Motion;
1725 //==============================================================================
1726 //function : ViewProject: implements VAxo, VTop, VLeft, ...
1727 //purpose : Switches to an axonometric, top, left and other views
1728 //==============================================================================
1730 static int ViewProject(Draw_Interpretor& di, const V3d_TypeOfOrientation ori)
1732 if ( ViewerTest::CurrentView().IsNull() )
1734 di<<"Call vinit before this command, please\n";
1738 ViewerTest::CurrentView()->SetProj(ori);
1742 //==============================================================================
1744 //purpose : Switch to an Axonometric view
1745 //Draw arg : No args
1746 //==============================================================================
1748 static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** )
1750 return ViewProject(di, V3d_XposYnegZpos);
1753 //==============================================================================
1755 //purpose : Switch to a Top View
1756 //Draw arg : No args
1757 //==============================================================================
1759 static int VTop(Draw_Interpretor& di, Standard_Integer , const char** )
1761 return ViewProject(di, V3d_Zpos);
1764 //==============================================================================
1765 //function : VBottom
1766 //purpose : Switch to a Bottom View
1767 //Draw arg : No args
1768 //==============================================================================
1770 static int VBottom(Draw_Interpretor& di, Standard_Integer , const char** )
1772 return ViewProject(di, V3d_Zneg);
1775 //==============================================================================
1777 //purpose : Switch to a Left View
1778 //Draw arg : No args
1779 //==============================================================================
1781 static int VLeft(Draw_Interpretor& di, Standard_Integer , const char** )
1783 return ViewProject(di, V3d_Xneg);
1786 //==============================================================================
1788 //purpose : Switch to a Right View
1789 //Draw arg : No args
1790 //==============================================================================
1792 static int VRight(Draw_Interpretor& di, Standard_Integer , const char** )
1794 return ViewProject(di, V3d_Xpos);
1797 //==============================================================================
1799 //purpose : Switch to a Front View
1800 //Draw arg : No args
1801 //==============================================================================
1803 static int VFront(Draw_Interpretor& di, Standard_Integer , const char** )
1805 return ViewProject(di, V3d_Yneg);
1808 //==============================================================================
1810 //purpose : Switch to a Back View
1811 //Draw arg : No args
1812 //==============================================================================
1814 static int VBack(Draw_Interpretor& di, Standard_Integer , const char** )
1816 return ViewProject(di, V3d_Ypos);
1819 //==============================================================================
1821 //purpose : Dsiplay help on viewer Keyboead and mouse commands
1822 //Draw arg : No args
1823 //==============================================================================
1825 static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
1828 di << "Q : Quit the application\n";
1830 di << "=========================\n";
1831 di << "F : FitAll\n";
1832 di << "T : TopView\n";
1833 di << "B : BottomView\n";
1834 di << "R : RightView\n";
1835 di << "L : LeftView\n";
1836 di << "A : AxonometricView\n";
1837 di << "D : ResetView\n";
1839 di << "=========================\n";
1840 di << "S : Shading\n";
1841 di << "W : Wireframe\n";
1842 di << "H : HidelLineRemoval\n";
1843 di << "U : Unset display mode\n";
1844 di << "Delete : Remove selection from viewer\n";
1846 di << "=========================\n";
1847 di << "Selection mode \n";
1848 di << "0 : Shape\n";
1849 di << "1 : Vertex\n";
1853 di << "5 : Shell\n";
1854 di << "6 : Solid\n";
1855 di << "7 : Compound\n";
1857 di << "=========================\n";
1858 di << "Z : Switch Z clipping On/Off\n";
1859 di << ", : Hilight next detected\n";
1860 di << ". : Hilight previous detected\n";
1867 static Standard_Boolean Ppick = 0;
1868 static Standard_Integer Pargc = 0;
1869 static const char** Pargv = NULL;
1872 static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
1877 if (!ViewerTest_myViews.IsEmpty()) {
1879 WPARAM fwKeys = wParam;
1884 // Delete view from map of views
1885 ViewerTest::RemoveView(FindViewIdByWindowHandle(hwnd));
1890 if(LOWORD(wParam) == WA_CLICKACTIVE || LOWORD(wParam) == WA_ACTIVE
1891 || ViewerTest::CurrentView().IsNull())
1893 // Activate inactive window
1894 if(GetWindowHandle(VT_GetWindow()) != hwnd)
1896 ActivateView (FindViewIdByWindowHandle(hwnd));
1902 if (IsDragged && !DragFirst)
1904 if (!GetActiveAISManipulator().IsNull())
1906 GetActiveAISManipulator()->StopTransform();
1907 ViewerTest::GetAISContext()->ClearSelected (Standard_True);
1910 if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
1912 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
1913 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
1916 VT_ProcessButton1Release ((fwKeys & MK_SHIFT) != 0);
1918 IsDragged = Standard_False;
1919 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1922 if (IsDragged && !DragFirst)
1924 if (!GetActiveAISManipulator().IsNull())
1926 GetActiveAISManipulator()->StopTransform (Standard_False);
1927 ViewerTest::GetAISContext()->ClearSelected (Standard_True);
1929 IsDragged = Standard_False;
1931 return ViewerWindowProc (hwnd, Msg, wParam, lParam);
1933 case WM_LBUTTONDOWN:
1934 if (!GetActiveAISManipulator().IsNull())
1936 IsDragged = ( fwKeys == MK_LBUTTON );
1940 IsDragged = ( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) );
1945 DragFirst = Standard_True;
1946 X_ButtonPress = LOWORD(lParam);
1947 Y_ButtonPress = HIWORD(lParam);
1949 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1954 X_Motion = LOWORD (lParam);
1955 Y_Motion = HIWORD (lParam);
1956 if (!GetActiveAISManipulator().IsNull())
1960 GetActiveAISManipulator()->StartTransform (X_ButtonPress, Y_ButtonPress, ViewerTest::CurrentView());
1964 GetActiveAISManipulator()->Transform (X_Motion, Y_Motion, ViewerTest::CurrentView());
1965 ViewerTest::GetAISContext()->CurrentViewer()->Redraw();
1970 bool toRedraw = false;
1971 if (!DragFirst && ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
1973 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
1978 if (GetClientRect (hwnd, &aRect))
1980 int aHeight = aRect.bottom - aRect.top;
1981 GetRubberBand()->SetRectangle (X_ButtonPress, aHeight - Y_ButtonPress, X_Motion, aHeight - Y_Motion);
1982 ViewerTest::GetAISContext()->Display (GetRubberBand(), 0, -1, Standard_False, Standard_True, AIS_DS_Displayed);
1987 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
1991 DragFirst = Standard_False;
1994 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1998 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
2002 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
2006 static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
2012 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
2015 return DefWindowProcW (hwnd, Msg, wParam, lParam);
2022 BeginPaint(hwnd, &ps);
2023 EndPaint(hwnd, &ps);
2028 VT_ProcessConfigure();
2033 switch (aView->RenderingParams().StereoMode)
2035 case Graphic3d_StereoMode_RowInterlaced:
2036 case Graphic3d_StereoMode_ColumnInterlaced:
2037 case Graphic3d_StereoMode_ChessBoard:
2038 VT_ProcessConfigure(); // track window moves to reverse stereo pair
2046 if ((wParam != VK_SHIFT) && (wParam != VK_CONTROL))
2049 c[0] = (char) wParam;
2051 if (wParam == VK_DELETE)
2053 c[0] = THE_KEY_DELETE;
2056 else if (wParam == VK_OEM_COMMA)
2061 else if (wParam == VK_OEM_PERIOD)
2065 else if (wParam == VK_DIVIDE)
2070 else if (wParam == VK_MULTIPLY)
2074 VT_ProcessKeyPress (c);
2082 VT_ProcessButton3Release();
2085 case WM_LBUTTONDOWN:
2086 case WM_MBUTTONDOWN:
2087 case WM_RBUTTONDOWN:
2089 WPARAM fwKeys = wParam;
2093 X_ButtonPress = LOWORD(lParam);
2094 Y_ButtonPress = HIWORD(lParam);
2096 if (Msg == WM_LBUTTONDOWN)
2098 if ((fwKeys & MK_CONTROL) != 0)
2100 Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) != 0);
2104 VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) != 0);
2107 else if (Msg == WM_RBUTTONDOWN)
2110 VT_ProcessButton3Press();
2117 int aDelta = GET_WHEEL_DELTA_WPARAM (wParam);
2118 if (wParam & MK_CONTROL)
2120 if (aView->Camera()->IsStereo())
2122 Standard_Real aFocus = aView->Camera()->ZFocus() + (aDelta > 0 ? 0.05 : -0.05);
2126 aView->Camera()->SetZFocus (aView->Camera()->ZFocusType(), aFocus);
2133 aView->Zoom (0, 0, aDelta / 40, aDelta / 40);
2140 //cout << "\t WM_MOUSEMOVE" << endl;
2141 WPARAM fwKeys = wParam;
2142 X_Motion = LOWORD(lParam);
2143 Y_Motion = HIWORD(lParam);
2146 (fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON )) != 0 )
2149 X_ButtonPress = LOWORD(lParam);
2150 Y_ButtonPress = HIWORD(lParam);
2152 if ((fwKeys & MK_RBUTTON) != 0) {
2154 VT_ProcessButton3Press();
2158 if ((fwKeys & MK_CONTROL) != 0)
2160 if ((fwKeys & MK_LBUTTON) != 0)
2162 ProcessControlButton1Motion();
2164 else if ((fwKeys & MK_MBUTTON) != 0
2165 || ((fwKeys & MK_LBUTTON) != 0
2166 && (fwKeys & MK_RBUTTON) != 0))
2168 VT_ProcessControlButton2Motion();
2170 else if ((fwKeys & MK_RBUTTON) != 0)
2172 VT_ProcessControlButton3Motion();
2175 else if (GetWindowHandle (VT_GetWindow()) == hwnd)
2183 return DefWindowProcW (hwnd, Msg, wParam, lParam);
2188 //==============================================================================
2189 //function : ViewerMainLoop
2190 //purpose : Get a Event on the view and dispatch it
2191 //==============================================================================
2194 int ViewerMainLoop(Standard_Integer argc, const char** argv)
2196 Ppick = (argc > 0)? 1 : 0;
2204 cout << "Start picking" << endl;
2206 while ( Ppick == 1 ) {
2207 // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
2208 if (GetMessageW (&msg, NULL, 0, 0))
2210 TranslateMessage (&msg);
2211 DispatchMessageW (&msg);
2215 cout << "Picking done" << endl;
2221 #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX)
2223 int min( int a, int b )
2231 int max( int a, int b )
2239 int ViewerMainLoop(Standard_Integer argc, const char** argv)
2242 static XEvent aReport;
2243 Standard_Boolean pick = argc > 0;
2244 Display *aDisplay = GetDisplayConnection()->GetDisplay();
2245 XNextEvent (aDisplay, &aReport);
2247 // Handle event for the chosen display connection
2248 switch (aReport.type) {
2251 if((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW))
2254 ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window));
2260 // Activate inactive view
2261 Window aWindow = GetWindowHandle(VT_GetWindow());
2262 if(aWindow != aReport.xfocus.window)
2264 ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window));
2273 case ConfigureNotify:
2275 VT_ProcessConfigure();
2284 XComposeStatus status_in_out;
2286 ret_len = XLookupString( ( XKeyEvent *)&aReport ,
2287 (char *) buf_ret , 10 ,
2288 &ks_ret , &status_in_out ) ;
2291 buf_ret[ret_len] = '\0' ;
2295 VT_ProcessKeyPress (buf_ret);
2301 X_ButtonPress = aReport.xbutton.x;
2302 Y_ButtonPress = aReport.xbutton.y;
2304 if (aReport.xbutton.button == Button1)
2306 if (aReport.xbutton.state & ControlMask)
2308 pick = VT_ProcessButton1Press (argc, argv, pick, (aReport.xbutton.state & ShiftMask));
2312 IsDragged = Standard_True;
2313 DragFirst = Standard_True;
2316 else if (aReport.xbutton.button == Button3)
2319 VT_ProcessButton3Press();
2329 if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
2331 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
2332 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
2336 Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
2337 if( aContext.IsNull() )
2339 cout << "The context is null. Please use vinit before createmesh" << endl;
2343 Standard_Boolean ShiftPressed = ( aReport.xbutton.state & ShiftMask );
2344 if( aReport.xbutton.button==1 )
2348 aContext->ShiftSelect (Standard_True);
2352 aContext->Select (Standard_True);
2357 aContext->ShiftSelect(Min(X_ButtonPress, X_Motion), Min(Y_ButtonPress, Y_Motion),
2358 Max(X_ButtonPress, X_Motion), Max(Y_ButtonPress, Y_Motion),
2359 ViewerTest::CurrentView(), Standard_True);
2363 aContext->Select(Min(X_ButtonPress, X_Motion), Min(Y_ButtonPress, Y_Motion),
2364 Max(X_ButtonPress, X_Motion), Max(Y_ButtonPress, Y_Motion),
2365 ViewerTest::CurrentView(), Standard_True);
2368 VT_ProcessButton3Release();
2370 IsDragged = Standard_False;
2373 VT_ProcessButton3Release();
2378 if (GetWindowHandle (VT_GetWindow()) != aReport.xmotion.window)
2386 if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
2388 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
2392 X_Motion = aReport.xmotion.x;
2393 Y_Motion = aReport.xmotion.y;
2394 DragFirst = Standard_False;
2396 Window aWindow = GetWindowHandle(VT_GetWindow());
2399 unsigned int aWidth, aHeight, aBorderWidth, aDepth;
2400 XGetGeometry (aDisplay, aWindow, &aRoot, &anX, &anY, &aWidth, &aHeight, &aBorderWidth, &aDepth);
2401 GetRubberBand()->SetRectangle (X_ButtonPress, aHeight - Y_ButtonPress, X_Motion, aHeight - Y_Motion);
2402 ViewerTest::GetAISContext()->Display (GetRubberBand(), 0, -1, Standard_False, Standard_True, AIS_DS_Displayed);
2403 ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
2407 X_Motion = aReport.xmotion.x;
2408 Y_Motion = aReport.xmotion.y;
2410 // remove all the ButtonMotionMaskr
2411 while( XCheckMaskEvent( aDisplay, ButtonMotionMask, &aReport) ) ;
2413 if ( aReport.xmotion.state & ControlMask ) {
2414 if ( aReport.xmotion.state & Button1Mask ) {
2415 ProcessControlButton1Motion();
2417 else if ( aReport.xmotion.state & Button2Mask ) {
2418 VT_ProcessControlButton2Motion();
2420 else if ( aReport.xmotion.state & Button3Mask ) {
2421 VT_ProcessControlButton3Motion();
2435 //==============================================================================
2436 //function : VProcessEvents
2437 //purpose : call by Tk_CreateFileHandler() to be able to manage the
2438 // event in the Viewer window
2439 //==============================================================================
2441 static void VProcessEvents(ClientData,int)
2443 NCollection_Vector<int> anEventNumbers;
2444 // Get number of messages from every display
2445 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
2446 anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next())
2448 anEventNumbers.Append(XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()));
2450 // Handle events for every display
2451 int anEventIter = 0;
2452 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
2453 anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next(), anEventIter++)
2455 for (int i = 0; i < anEventNumbers.Value(anEventIter) &&
2456 XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()) > 0; ++i)
2458 SetDisplayConnection (anIter.Key2()->GetDisplayConnection());
2459 int anEventResult = ViewerMainLoop( 0, NULL);
2460 // If window is closed or context was not found finish current event processing loop
2466 SetDisplayConnection (ViewerTest::GetAISContext()->CurrentViewer()->Driver()->GetDisplayConnection());
2471 //==============================================================================
2472 //function : OSWindowSetup
2473 //purpose : Setup for the X11 window to be able to cath the event
2474 //==============================================================================
2477 static void OSWindowSetup()
2479 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
2482 Window window = VT_GetWindow()->XWindow();
2483 SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
2484 Display *aDisplay = GetDisplayConnection()->GetDisplay();
2485 XSynchronize(aDisplay, 1);
2487 // X11 : For keyboard on SUN
2489 wmhints.flags = InputHint;
2492 XSetWMHints( aDisplay, window, &wmhints);
2494 XSelectInput( aDisplay, window, ExposureMask | KeyPressMask |
2495 ButtonPressMask | ButtonReleaseMask |
2496 StructureNotifyMask |
2498 Button1MotionMask | Button2MotionMask |
2499 Button3MotionMask | FocusChangeMask
2501 Atom aDeleteWindowAtom = GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW);
2502 XSetWMProtocols(aDisplay, window, &aDeleteWindowAtom, 1);
2504 XSynchronize(aDisplay, 0);
2512 //==============================================================================
2515 //==============================================================================
2517 static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgv)
2519 const Handle(V3d_View) aView = ViewerTest::CurrentView();
2522 std::cout << "Error: no active viewer!\n";
2526 Standard_Boolean toFit = Standard_True;
2527 ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
2528 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
2530 TCollection_AsciiString anArg (theArgv[anArgIter]);
2532 if (anUpdateTool.parseRedrawMode (anArg))
2536 else if (anArg == "-selected")
2538 ViewerTest::GetAISContext()->FitSelected (aView, 0.01, Standard_False);
2539 toFit = Standard_False;
2543 std::cout << "Syntax error at '" << anArg << "'\n";
2549 aView->FitAll (0.01, Standard_False);
2554 //=======================================================================
2555 //function : VFitArea
2556 //purpose : Fit view to show area located between two points
2557 // : given in world 2D or 3D coordinates.
2558 //=======================================================================
2559 static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
2561 Handle(V3d_View) aView = ViewerTest::CurrentView();
2564 std::cerr << theArgVec[0] << "Error: No active view.\n";
2569 gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0);
2570 gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0);
2574 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
2575 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
2576 aWorldPnt2.SetX (Draw::Atof (theArgVec[3]));
2577 aWorldPnt2.SetY (Draw::Atof (theArgVec[4]));
2579 else if (theArgNb == 7)
2581 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
2582 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
2583 aWorldPnt1.SetZ (Draw::Atof (theArgVec[3]));
2584 aWorldPnt2.SetX (Draw::Atof (theArgVec[4]));
2585 aWorldPnt2.SetY (Draw::Atof (theArgVec[5]));
2586 aWorldPnt2.SetZ (Draw::Atof (theArgVec[6]));
2590 std::cerr << theArgVec[0] << "Error: Invalid number of arguments.\n";
2591 theDI.PrintHelp(theArgVec[0]);
2595 // Convert model coordinates to view space
2596 Handle(Graphic3d_Camera) aCamera = aView->Camera();
2597 gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1);
2598 gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2);
2600 // Determine fit area
2601 gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y()));
2602 gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y()));
2604 Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner);
2606 if (aDiagonal < Precision::Confusion())
2608 std::cerr << theArgVec[0] << "Error: view area is too small.\n";
2612 aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y());
2616 //==============================================================================
2618 //purpose : ZFitall, no DRAW arguments
2619 //Draw arg : No args
2620 //==============================================================================
2621 static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
2623 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
2625 if (aCurrentView.IsNull())
2627 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
2633 aCurrentView->ZFitAll();
2634 aCurrentView->Redraw();
2638 Standard_Real aScale = 1.0;
2642 aScale = Draw::Atoi (theArgVec[1]);
2645 aCurrentView->ZFitAll (aScale);
2646 aCurrentView->Redraw();
2651 //==============================================================================
2652 //function : VRepaint
2654 //==============================================================================
2655 static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgVec)
2657 Handle(V3d_View) aView = ViewerTest::CurrentView();
2660 std::cout << "Error: no active viewer!\n";
2664 Standard_Boolean isImmediateUpdate = Standard_False;
2665 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
2667 TCollection_AsciiString anArg (theArgVec[anArgIter]);
2669 if (anArg == "-immediate")
2671 isImmediateUpdate = Standard_True;
2672 if (anArgIter + 1 < theArgNb
2673 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate))
2680 std::cout << "Syntax error at '" << anArg << "'\n";
2684 if (isImmediateUpdate)
2686 aView->RedrawImmediate();
2695 //==============================================================================
2697 //purpose : Remove all the object from the viewer
2698 //Draw arg : No args
2699 //==============================================================================
2701 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
2703 Handle(V3d_View) V = ViewerTest::CurrentView();
2705 ViewerTest::Clear();
2709 //==============================================================================
2712 //==============================================================================
2714 static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2715 { if (ViewerTest::CurrentView().IsNull() ) return 1;
2718 di << argv[0] << "Invalid number of arguments\n";
2722 while (ViewerMainLoop( argc, argv)) {
2728 //==============================================================================
2730 //purpose : Load image as background
2731 //==============================================================================
2733 static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2735 if (argc < 2 || argc > 3)
2737 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n";
2738 di << "filltype can be one of CENTERED, TILED, STRETCH, NONE\n";
2742 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2743 if(AISContext.IsNull())
2745 di << "use 'vinit' command before " << argv[0] << "\n";
2749 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
2752 const char* szType = argv[2];
2753 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
2754 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
2755 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
2756 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
2759 di << "Wrong fill type : " << szType << "\n";
2760 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
2765 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2766 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
2771 //==============================================================================
2772 //function : VSetBgMode
2773 //purpose : Change background image fill type
2774 //==============================================================================
2776 static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2780 di << "Usage : " << argv[0] << " filltype : Change background image mode\n";
2781 di << "filltype must be one of CENTERED, TILED, STRETCH, NONE\n";
2785 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2786 if(AISContext.IsNull())
2788 di << "use 'vinit' command before " << argv[0] << "\n";
2791 Aspect_FillMethod aFillType = Aspect_FM_NONE;
2792 const char* szType = argv[1];
2793 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
2794 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
2795 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
2796 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
2799 di << "Wrong fill type : " << szType << "\n";
2800 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
2803 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2804 V3dView->SetBgImageStyle(aFillType, Standard_True);
2808 //==============================================================================
2809 //function : VSetGradientBg
2810 //purpose : Mount gradient background
2811 //==============================================================================
2812 static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2816 di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background\n";
2817 di << "R1,G1,B1,R2,G2,B2 = [0..255]\n";
2818 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2819 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2823 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2824 if(AISContext.IsNull())
2826 di << "use 'vinit' command before " << argv[0] << "\n";
2832 Standard_Real R1 = Draw::Atof(argv[1])/255.;
2833 Standard_Real G1 = Draw::Atof(argv[2])/255.;
2834 Standard_Real B1 = Draw::Atof(argv[3])/255.;
2835 Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB);
2837 Standard_Real R2 = Draw::Atof(argv[4])/255.;
2838 Standard_Real G2 = Draw::Atof(argv[5])/255.;
2839 Standard_Real B2 = Draw::Atof(argv[6])/255.;
2841 Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB);
2842 int aType = Draw::Atoi(argv[7]);
2843 if( aType < 0 || aType > 8 )
2845 di << "Wrong fill type \n";
2846 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2847 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2851 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
2853 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2854 V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1);
2860 //==============================================================================
2861 //function : VSetGradientBgMode
2862 //purpose : Change gradient background fill style
2863 //==============================================================================
2864 static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2868 di << "Usage : " << argv[0] << " Type : Change gradient background fill type\n";
2869 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2870 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2874 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2875 if(AISContext.IsNull())
2877 di << "use 'vinit' command before " << argv[0] << "\n";
2882 int aType = Draw::Atoi(argv[1]);
2883 if( aType < 0 || aType > 8 )
2885 di << "Wrong fill type \n";
2886 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
2887 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
2891 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
2893 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2894 V3dView->SetBgGradientStyle( aMethod, 1 );
2900 //==============================================================================
2901 //function : VSetColorBg
2902 //purpose : Set color background
2903 //==============================================================================
2904 static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2908 di << "Usage : " << argv[0] << " R G B : Set color background\n";
2909 di << "R,G,B = [0..255]\n";
2913 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2914 if(AISContext.IsNull())
2916 di << "use 'vinit' command before " << argv[0] << "\n";
2922 Standard_Real R = Draw::Atof(argv[1])/255.;
2923 Standard_Real G = Draw::Atof(argv[2])/255.;
2924 Standard_Real B = Draw::Atof(argv[3])/255.;
2925 Quantity_Color aColor(R,G,B,Quantity_TOC_RGB);
2927 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2928 V3dView->SetBackgroundColor( aColor );
2935 //==============================================================================
2936 //function : VSetDefaultBg
2937 //purpose : Set default viewer background fill color
2938 //==============================================================================
2939 static int VSetDefaultBg (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
2944 std::cout << "Error: wrong syntax! See usage:\n";
2945 theDI.PrintHelp (theArgVec[0]);
2949 ViewerTest_DefaultBackground.FillMethod =
2950 theArgNb == 4 ? Aspect_GFM_NONE
2951 : (Aspect_GradientFillMethod) Draw::Atoi (theArgVec[7]);
2955 Standard_Real R = Draw::Atof (theArgVec[1]) / 255.;
2956 Standard_Real G = Draw::Atof (theArgVec[2]) / 255.;
2957 Standard_Real B = Draw::Atof (theArgVec[3]) / 255.;
2958 ViewerTest_DefaultBackground.FlatColor.SetValues (R, G, B, Quantity_TOC_RGB);
2962 Standard_Real R1 = Draw::Atof (theArgVec[1]) / 255.;
2963 Standard_Real G1 = Draw::Atof (theArgVec[2]) / 255.;
2964 Standard_Real B1 = Draw::Atof (theArgVec[3]) / 255.;
2965 ViewerTest_DefaultBackground.GradientColor1.SetValues (R1, G1, B1, Quantity_TOC_RGB);
2967 Standard_Real R2 = Draw::Atof (theArgVec[4]) / 255.;
2968 Standard_Real G2 = Draw::Atof (theArgVec[5]) / 255.;
2969 Standard_Real B2 = Draw::Atof (theArgVec[6]) / 255.;
2970 ViewerTest_DefaultBackground.GradientColor2.SetValues (R2, G2, B2, Quantity_TOC_RGB);
2973 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
2974 anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
2976 const Handle(V3d_Viewer)& aViewer = anIter.Value()->CurrentViewer();
2977 aViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
2978 aViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
2979 ViewerTest_DefaultBackground.GradientColor2,
2980 ViewerTest_DefaultBackground.FillMethod);
2986 //==============================================================================
2988 //purpose : View Scaling
2989 //==============================================================================
2991 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2993 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2994 if ( V3dView.IsNull() ) return 1;
2997 di << argv[0] << "Invalid number of arguments\n";
3000 V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
3003 //==============================================================================
3004 //function : VZBuffTrihedron
3006 //==============================================================================
3008 static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
3009 Standard_Integer theArgNb,
3010 const char** theArgVec)
3012 Handle(V3d_View) aView = ViewerTest::CurrentView();
3015 std::cout << "Error: no active viewer!\n";
3019 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
3021 Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER;
3022 V3d_TypeOfVisualization aVisType = V3d_ZBUFFER;
3023 Quantity_Color aLabelsColor = Quantity_NOC_WHITE;
3024 Quantity_Color anArrowColorX = Quantity_NOC_RED;
3025 Quantity_Color anArrowColorY = Quantity_NOC_GREEN;
3026 Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1;
3027 Standard_Real aScale = 0.1;
3028 Standard_Real aSizeRatio = 0.8;
3029 Standard_Real anArrowDiam = 0.05;
3030 Standard_Integer aNbFacets = 12;
3031 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3033 Standard_CString anArg = theArgVec[anArgIter];
3034 TCollection_AsciiString aFlag (anArg);
3036 if (anUpdateTool.parseRedrawMode (aFlag))
3040 else if (aFlag == "-on")
3044 else if (aFlag == "-off")
3046 aView->TriedronErase();
3049 else if (aFlag == "-pos"
3050 || aFlag == "-position"
3051 || aFlag == "-corner")
3053 if (++anArgIter >= theArgNb)
3055 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3059 TCollection_AsciiString aPosName (theArgVec[anArgIter]);
3060 aPosName.LowerCase();
3061 if (aPosName == "center")
3063 aPosition = Aspect_TOTP_CENTER;
3065 else if (aPosName == "left_lower"
3066 || aPosName == "lower_left"
3067 || aPosName == "leftlower"
3068 || aPosName == "lowerleft")
3070 aPosition = Aspect_TOTP_LEFT_LOWER;
3072 else if (aPosName == "left_upper"
3073 || aPosName == "upper_left"
3074 || aPosName == "leftupper"
3075 || aPosName == "upperleft")
3077 aPosition = Aspect_TOTP_LEFT_UPPER;
3079 else if (aPosName == "right_lower"
3080 || aPosName == "lower_right"
3081 || aPosName == "rightlower"
3082 || aPosName == "lowerright")
3084 aPosition = Aspect_TOTP_RIGHT_LOWER;
3086 else if (aPosName == "right_upper"
3087 || aPosName == "upper_right"
3088 || aPosName == "rightupper"
3089 || aPosName == "upperright")
3091 aPosition = Aspect_TOTP_RIGHT_UPPER;
3095 std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'\n";
3099 else if (aFlag == "-type")
3101 if (++anArgIter >= theArgNb)
3103 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3107 TCollection_AsciiString aTypeName (theArgVec[anArgIter]);
3108 aTypeName.LowerCase();
3109 if (aTypeName == "wireframe"
3110 || aTypeName == "wire")
3112 aVisType = V3d_WIREFRAME;
3114 else if (aTypeName == "zbuffer"
3115 || aTypeName == "shaded")
3117 aVisType = V3d_ZBUFFER;
3121 std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'\n";
3124 else if (aFlag == "-scale")
3126 if (++anArgIter >= theArgNb)
3128 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3132 aScale = Draw::Atof (theArgVec[anArgIter]);
3134 else if (aFlag == "-size"
3135 || aFlag == "-sizeratio")
3137 if (++anArgIter >= theArgNb)
3139 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3143 aSizeRatio = Draw::Atof (theArgVec[anArgIter]);
3145 else if (aFlag == "-arrowdiam"
3146 || aFlag == "-arrowdiameter")
3148 if (++anArgIter >= theArgNb)
3150 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3154 anArrowDiam = Draw::Atof (theArgVec[anArgIter]);
3156 else if (aFlag == "-nbfacets")
3158 if (++anArgIter >= theArgNb)
3160 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3164 aNbFacets = Draw::Atoi (theArgVec[anArgIter]);
3166 else if (aFlag == "-colorlabel"
3167 || aFlag == "-colorlabels")
3169 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3170 theArgVec + anArgIter + 1,
3174 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3177 anArgIter += aNbParsed;
3179 else if (aFlag == "-colorarrowx")
3181 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3182 theArgVec + anArgIter + 1,
3186 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3189 anArgIter += aNbParsed;
3191 else if (aFlag == "-colorarrowy")
3193 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3194 theArgVec + anArgIter + 1,
3198 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3201 anArgIter += aNbParsed;
3203 else if (aFlag == "-colorarrowz")
3205 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3206 theArgVec + anArgIter + 1,
3210 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3213 anArgIter += aNbParsed;
3217 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3222 aView->ZBufferTriedronSetup (anArrowColorX.Name(), anArrowColorY.Name(), anArrowColorZ.Name(),
3223 aSizeRatio, anArrowDiam, aNbFacets);
3224 aView->TriedronDisplay (aPosition, aLabelsColor.Name(), aScale, aVisType);
3229 //==============================================================================
3230 //function : VRotate
3231 //purpose : Camera Rotating
3232 //==============================================================================
3234 static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
3236 Handle(V3d_View) aView = ViewerTest::CurrentView();
3239 std::cout << "No active view!\n";
3243 Standard_Boolean hasFlags = Standard_False;
3244 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3246 Standard_CString anArg (theArgVec[anArgIter]);
3247 TCollection_AsciiString aFlag (anArg);
3249 if (aFlag == "-mousestart"
3250 || aFlag == "-mousefrom")
3252 hasFlags = Standard_True;
3253 if (anArgIter + 2 >= theArgNb)
3255 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3259 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
3260 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
3261 aView->StartRotation (anX, anY);
3263 else if (aFlag == "-mousemove")
3265 hasFlags = Standard_True;
3266 if (anArgIter + 2 >= theArgNb)
3268 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3272 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
3273 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
3274 aView->Rotation (anX, anY);
3276 else if (theArgNb != 4
3279 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3288 else if (theArgNb == 4)
3290 Standard_Real anAX = Draw::Atof (theArgVec[1]);
3291 Standard_Real anAY = Draw::Atof (theArgVec[2]);
3292 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
3293 aView->Rotate (anAX, anAY, anAZ);
3296 else if (theArgNb == 7)
3298 Standard_Real anAX = Draw::Atof (theArgVec[1]);
3299 Standard_Real anAY = Draw::Atof (theArgVec[2]);
3300 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
3302 Standard_Real anX = Draw::Atof (theArgVec[4]);
3303 Standard_Real anY = Draw::Atof (theArgVec[5]);
3304 Standard_Real anZ = Draw::Atof (theArgVec[6]);
3306 aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ);
3310 std::cout << "Error: Invalid number of arguments\n";
3314 //==============================================================================
3316 //purpose : View zoom in / out (relative to current zoom)
3317 //==============================================================================
3319 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3320 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3321 if ( V3dView.IsNull() ) {
3326 Standard_Real coef = Draw::Atof(argv[1]);
3327 if ( coef <= 0.0 ) {
3328 di << argv[1] << "Invalid value\n";
3331 V3dView->SetZoom( Draw::Atof(argv[1]) );
3334 di << argv[0] << " Invalid number of arguments\n";
3339 //==============================================================================
3341 //purpose : View panning (in pixels)
3342 //==============================================================================
3344 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3345 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3346 if ( V3dView.IsNull() ) return 1;
3349 V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) );
3352 di << argv[0] << " Invalid number of arguments\n";
3357 //==============================================================================
3359 //purpose : Place the point (in pixels) at the center of the window
3360 //==============================================================================
3361 static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs)
3363 Handle(V3d_View) aView = ViewerTest::CurrentView();
3366 std::cerr << theArgs[0] << "Error: no active view." << std::endl;
3372 std::cerr << theArgs[0] << "Error: invalid number of arguments." << std::endl;
3376 aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale());
3381 //==============================================================================
3382 //function : VExport
3383 //purpose : Export the view to a vector graphic format (PS, EMF, PDF)
3384 //==============================================================================
3386 static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3388 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3389 if (V3dView.IsNull())
3394 std::cout << "Usage: " << argv[0] << " Filename [Format]\n";
3398 Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF;
3399 TCollection_AsciiString aFormatStr;
3401 TCollection_AsciiString aFileName (argv[1]);
3402 Standard_Integer aLen = aFileName.Length();
3406 aFormatStr = TCollection_AsciiString (argv[2]);
3410 if (aFileName.Value (aLen - 2) == '.')
3412 aFormatStr = aFileName.ToCString() + aLen - 2;
3414 else if (aFileName.Value (aLen - 3) == '.')
3416 aFormatStr = aFileName.ToCString() + aLen - 3;
3420 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
3426 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
3430 aFormatStr.UpperCase();
3431 if (aFormatStr == "PS")
3432 anExpFormat = Graphic3d_EF_PostScript;
3433 else if (aFormatStr == "EPS")
3434 anExpFormat = Graphic3d_EF_EnhPostScript;
3435 else if (aFormatStr == "TEX")
3436 anExpFormat = Graphic3d_EF_TEX;
3437 else if (aFormatStr == "PDF")
3438 anExpFormat = Graphic3d_EF_PDF;
3439 else if (aFormatStr == "SVG")
3440 anExpFormat = Graphic3d_EF_SVG;
3441 else if (aFormatStr == "PGF")
3442 anExpFormat = Graphic3d_EF_PGF;
3443 else if (aFormatStr == "EMF")
3444 anExpFormat = Graphic3d_EF_EMF;
3447 std::cout << "Invalid export format '" << aFormatStr << "'\n";
3451 Standard_DISABLE_DEPRECATION_WARNINGS
3454 if (!V3dView->Export (argv[1], anExpFormat))
3456 di << "Error: export of image to " << aFormatStr << " failed!\n";
3459 catch (Standard_Failure const& anException)
3461 di << "Error: export of image to " << aFormatStr << " failed";
3462 di << " (exception: " << anException.GetMessageString() << ")";
3464 Standard_ENABLE_DEPRECATION_WARNINGS
3468 static int VColorScale (Draw_Interpretor& theDI,
3469 Standard_Integer theArgNb,
3470 const char** theArgVec)
3472 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3473 Handle(V3d_View) aView = ViewerTest::CurrentView();
3474 if (aContext.IsNull())
3476 std::cout << "Error: no active view!\n";
3481 std::cout << "Error: wrong syntax at command '" << theArgVec[0] << "'!\n";
3485 Handle(AIS_ColorScale) aColorScale;
3486 if (GetMapOfAIS().IsBound2 (theArgVec[1]))
3488 // find existing object
3489 aColorScale = Handle(AIS_ColorScale)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
3490 if (aColorScale.IsNull())
3492 std::cout << "Error: object '" << theArgVec[1] << "'is already defined and is not a color scale!\n";
3499 if (aColorScale.IsNull())
3501 std::cout << "Syntax error: colorscale with a given name does not exist.\n";
3505 theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n"
3506 << "Min range: " << aColorScale->GetMin() << "\n"
3507 << "Max range: " << aColorScale->GetMax() << "\n"
3508 << "Number of intervals: " << aColorScale->GetNumberOfIntervals() << "\n"
3509 << "Text height: " << aColorScale->GetTextHeight() << "\n"
3510 << "Color scale position: " << aColorScale->GetXPosition() << " " << aColorScale->GetYPosition() << "\n"
3511 << "Color scale title: " << aColorScale->GetTitle() << "\n"
3512 << "Label position: ";
3513 switch (aColorScale->GetLabelPosition())
3515 case Aspect_TOCSP_NONE:
3518 case Aspect_TOCSP_LEFT:
3521 case Aspect_TOCSP_RIGHT:
3524 case Aspect_TOCSP_CENTER:
3525 theDI << "Center\n";
3531 if (aColorScale.IsNull())
3533 aColorScale = new AIS_ColorScale();
3534 aColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
3535 aContext->SetTransformPersistence (aColorScale, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
3538 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
3539 for (Standard_Integer anArgIter = 2; anArgIter < theArgNb; ++anArgIter)
3541 Standard_CString anArg = theArgVec[anArgIter];
3542 TCollection_AsciiString aFlag (anArg);
3544 if (anUpdateTool.parseRedrawMode (aFlag))
3548 else if (aFlag == "-range")
3550 if (anArgIter + 3 >= theArgNb)
3552 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3556 const TCollection_AsciiString aRangeMin (theArgVec[++anArgIter]);
3557 const TCollection_AsciiString aRangeMax (theArgVec[++anArgIter]);
3558 const TCollection_AsciiString aNbIntervals (theArgVec[++anArgIter]);
3559 if (!aRangeMin.IsRealValue()
3560 || !aRangeMax.IsRealValue())
3562 std::cout << "Error: the range values should be real!\n";
3565 else if (!aNbIntervals.IsIntegerValue())
3567 std::cout << "Error: the number of intervals should be integer!\n";
3571 aColorScale->SetRange (aRangeMin.RealValue(), aRangeMax.RealValue());
3572 aColorScale->SetNumberOfIntervals (aNbIntervals.IntegerValue());
3574 else if (aFlag == "-font")
3576 if (anArgIter + 1 >= theArgNb)
3578 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3581 TCollection_AsciiString aFontArg(theArgVec[anArgIter + 1]);
3582 if (!aFontArg.IsIntegerValue())
3584 std::cout << "Error: HeightFont value should be integer!\n";
3588 aColorScale->SetTextHeight (aFontArg.IntegerValue());
3591 else if (aFlag == "-textpos")
3593 if (anArgIter + 1 >= theArgNb)
3595 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3599 TCollection_AsciiString aTextPosArg(theArgVec[++anArgIter]);
3600 aTextPosArg.LowerCase();
3601 Aspect_TypeOfColorScalePosition aLabPosition = Aspect_TOCSP_NONE;
3602 if (aTextPosArg == "none")
3604 aLabPosition = Aspect_TOCSP_NONE;
3606 else if (aTextPosArg == "left")
3608 aLabPosition = Aspect_TOCSP_LEFT;
3610 else if (aTextPosArg == "right")
3612 aLabPosition = Aspect_TOCSP_RIGHT;
3614 else if (aTextPosArg == "center")
3616 aLabPosition = Aspect_TOCSP_CENTER;
3620 std::cout << "Error: unknown position '" << aTextPosArg << "'!\n";
3623 aColorScale->SetLabelPosition (aLabPosition);
3625 else if (aFlag == "-logarithmic"
3628 if (anArgIter + 1 >= theArgNb)
3630 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3634 Standard_Boolean IsLog;
3635 if (!ViewerTest::ParseOnOff(theArgVec[++anArgIter], IsLog))
3637 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3640 aColorScale->SetLogarithmic (IsLog);
3642 else if (aFlag == "-huerange"
3645 if (anArgIter + 2 >= theArgNb)
3647 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3651 const Standard_Real aHueMin = Draw::Atof (theArgVec[++anArgIter]);
3652 const Standard_Real aHueMax = Draw::Atof (theArgVec[++anArgIter]);
3653 aColorScale->SetHueRange (aHueMin, aHueMax);
3655 else if (aFlag == "-colorrange")
3657 Quantity_Color aColorMin, aColorMax;
3658 Standard_Integer aNbParsed1 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3659 theArgVec + (anArgIter + 1),
3661 anArgIter += aNbParsed1;
3662 Standard_Integer aNbParsed2 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3663 theArgVec + (anArgIter + 1),
3665 anArgIter += aNbParsed2;
3669 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3673 aColorScale->SetColorRange (aColorMin, aColorMax);
3675 else if (aFlag == "-reversed"
3676 || aFlag == "-inverted"
3677 || aFlag == "-topdown"
3678 || aFlag == "-bottomup")
3680 Standard_Boolean toEnable = Standard_True;
3681 if (anArgIter + 1 < theArgNb
3682 && ViewerTest::ParseOnOff(theArgVec[anArgIter + 1], toEnable))
3686 aColorScale->SetReversed ((aFlag == "-topdown") ? !toEnable : toEnable);
3688 else if (aFlag == "-smooth"
3689 || aFlag == "-smoothtransition")
3691 Standard_Boolean toEnable = Standard_True;
3692 if (anArgIter + 1 < theArgNb
3693 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
3697 aColorScale->SetSmoothTransition (toEnable);
3699 else if (aFlag == "-xy")
3701 if (anArgIter + 2 >= theArgNb)
3703 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3707 const TCollection_AsciiString anX (theArgVec[++anArgIter]);
3708 const TCollection_AsciiString anY (theArgVec[++anArgIter]);
3709 if (!anX.IsIntegerValue()
3710 || !anY.IsIntegerValue())
3712 std::cout << "Error: coordinates should be integer values!\n";
3716 aColorScale->SetPosition (anX.IntegerValue(), anY.IntegerValue());
3718 else if (aFlag == "-width"
3720 || aFlag == "-breadth")
3722 if (anArgIter + 1 >= theArgNb)
3724 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3728 const TCollection_AsciiString aBreadth (theArgVec[++anArgIter]);
3729 if (!aBreadth.IsIntegerValue())
3731 std::cout << "Error: a width should be an integer value!\n";
3734 aColorScale->SetBreadth (aBreadth.IntegerValue());
3736 else if (aFlag == "-height"
3739 if (anArgIter + 1 >= theArgNb)
3741 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3745 const TCollection_AsciiString aHeight (theArgVec[++anArgIter]);
3746 if (!aHeight.IsIntegerValue())
3748 std::cout << "Error: a width should be an integer value!\n";
3751 aColorScale->SetHeight (aHeight.IntegerValue());
3753 else if (aFlag == "-color")
3755 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
3757 std::cout << "Error: wrong color type! Call -colors before to set user-specified colors!\n";
3760 else if (anArgIter + 2 >= theArgNb)
3762 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3766 const TCollection_AsciiString anInd (theArgVec[++anArgIter]);
3767 if (!anInd.IsIntegerValue())
3769 std::cout << "Error: Index value should be integer!\n";
3772 const Standard_Integer anIndex = anInd.IntegerValue();
3773 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals())
3775 std::cout << "Error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals() <<"!\n";
3779 Quantity_Color aColor;
3780 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3781 theArgVec + (anArgIter + 1),
3785 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3788 aColorScale->SetIntervalColor (aColor, anIndex);
3789 aColorScale->SetColorType (Aspect_TOCSD_USER);
3790 anArgIter += aNbParsed;
3792 else if (aFlag == "-label")
3794 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
3796 std::cout << "Error: wrong label type! Call -labels before to set user-specified labels!\n";
3799 else if (anArgIter + 2 >= theArgNb)
3801 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3805 Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]);
3806 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals() + 1)
3808 std::cout << "Error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals() + 1 <<"!\n";
3812 TCollection_ExtendedString aText (theArgVec[anArgIter + 2]);
3813 aColorScale->SetLabel (aText, anIndex);
3814 aColorScale->SetLabelType (Aspect_TOCSD_USER);
3817 else if (aFlag == "-labelat"
3818 || aFlag == "-labat"
3819 || aFlag == "-labelatborder"
3820 || aFlag == "-labatborder"
3821 || aFlag == "-labelatcenter"
3822 || aFlag == "-labatcenter")
3824 Standard_Boolean toEnable = Standard_True;
3825 if (aFlag == "-labelat"
3826 || aFlag == "-labat")
3828 Standard_Integer aLabAtBorder = -1;
3829 if (++anArgIter >= theArgNb)
3831 TCollection_AsciiString anAtBorder (theArgVec[anArgIter]);
3832 anAtBorder.LowerCase();
3833 if (anAtBorder == "border")
3837 else if (anAtBorder == "center")
3842 if (aLabAtBorder == -1)
3844 std::cout << "Syntax error at argument '" << anArg << "'!\n";
3847 toEnable = (aLabAtBorder == 1);
3849 else if (anArgIter + 1 < theArgNb
3850 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
3854 aColorScale->SetLabelAtBorder (aFlag == "-labelatcenter"
3855 || aFlag == "-labatcenter"
3859 else if (aFlag == "-colors")
3861 Aspect_SequenceOfColor aSeq;
3864 Quantity_Color aColor;
3865 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
3866 theArgVec + (anArgIter + 1),
3872 anArgIter += aNbParsed;
3873 aSeq.Append (aColor);
3875 if (aSeq.Length() != aColorScale->GetNumberOfIntervals())
3877 std::cout << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the "
3878 << aColorScale->GetNumberOfIntervals() << " intervals\n";
3882 aColorScale->SetColors (aSeq);
3883 aColorScale->SetColorType (Aspect_TOCSD_USER);
3885 else if (aFlag == "-labels"
3886 || aFlag == "-freelabels")
3888 if (anArgIter + 1 >= theArgNb)
3890 std::cout << "Syntax error at argument '" << anArg << "'!\n";
3894 Standard_Integer aNbLabels = aColorScale->IsLabelAtBorder()
3895 ? aColorScale->GetNumberOfIntervals() + 1
3896 : aColorScale->GetNumberOfIntervals();
3897 if (aFlag == "-freelabels")
3900 aNbLabels = Draw::Atoi (theArgVec[anArgIter]);
3902 if (anArgIter + aNbLabels >= theArgNb)
3904 std::cout << "Error: not enough arguments! " << aNbLabels << " text labels are expected.\n";
3908 TColStd_SequenceOfExtendedString aSeq;
3909 for (Standard_Integer aLabelIter = 0; aLabelIter < aNbLabels; ++aLabelIter)
3911 aSeq.Append (TCollection_ExtendedString (theArgVec[++anArgIter]));
3913 aColorScale->SetLabels (aSeq);
3914 aColorScale->SetLabelType (Aspect_TOCSD_USER);
3916 else if (aFlag == "-title")
3918 if (anArgIter + 1 >= theArgNb)
3920 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3924 Standard_Boolean isTwoArgs = Standard_False;
3925 if (anArgIter + 2 < theArgNb)
3927 TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]);
3928 aSecondArg.LowerCase();
3929 Standard_DISABLE_DEPRECATION_WARNINGS
3930 if (aSecondArg == "none")
3932 aColorScale->SetTitlePosition (Aspect_TOCSP_NONE);
3933 isTwoArgs = Standard_True;
3935 else if (aSecondArg == "left")
3937 aColorScale->SetTitlePosition (Aspect_TOCSP_LEFT);
3938 isTwoArgs = Standard_True;
3940 else if (aSecondArg == "right")
3942 aColorScale->SetTitlePosition (Aspect_TOCSP_RIGHT);
3943 isTwoArgs = Standard_True;
3945 else if (aSecondArg == "center")
3947 aColorScale->SetTitlePosition (Aspect_TOCSP_CENTER);
3948 isTwoArgs = Standard_True;
3950 Standard_ENABLE_DEPRECATION_WARNINGS
3953 aColorScale->SetTitle (theArgVec[anArgIter + 1]);
3960 else if (aFlag == "-demoversion"
3961 || aFlag == "-demo")
3963 aColorScale->SetPosition (0, 0);
3964 aColorScale->SetTextHeight (16);
3965 aColorScale->SetRange (0.0, 100.0);
3966 aColorScale->SetNumberOfIntervals (10);
3967 aColorScale->SetBreadth (0);
3968 aColorScale->SetHeight (0);
3969 aColorScale->SetLabelPosition (Aspect_TOCSP_RIGHT);
3970 aColorScale->SetColorType (Aspect_TOCSD_AUTO);
3971 aColorScale->SetLabelType (Aspect_TOCSD_AUTO);
3973 else if (aFlag == "-findcolor")
3975 if (anArgIter + 1 >= theArgNb)
3977 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3981 TCollection_AsciiString anArg1 (theArgVec[++anArgIter]);
3983 if (!anArg1.IsRealValue())
3985 std::cout << "Error: the value should be real!\n";
3989 Quantity_Color aColor;
3990 aColorScale->FindColor (anArg1.RealValue(), aColor);
3991 theDI << Quantity_Color::StringName (aColor.Name());
3996 std::cout << "Error: wrong syntax at " << anArg << " - unknown argument!\n";
4001 Standard_Integer aWinWidth = 0, aWinHeight = 0;
4002 aView->Window()->Size (aWinWidth, aWinHeight);
4003 if (aColorScale->GetBreadth() == 0)
4005 aColorScale->SetBreadth (aWinWidth);
4007 if (aColorScale->GetHeight() == 0)
4009 aColorScale->SetHeight (aWinHeight);
4011 aColorScale->SetToUpdate();
4012 ViewerTest::Display (theArgVec[1], aColorScale, Standard_False, Standard_True);
4016 //==============================================================================
4017 //function : VGraduatedTrihedron
4018 //purpose : Displays or hides a graduated trihedron
4019 //==============================================================================
4020 static Standard_Boolean GetColor (const TCollection_AsciiString& theValue,
4021 Quantity_Color& theColor)
4023 Quantity_NameOfColor aColorName;
4024 TCollection_AsciiString aVal = theValue;
4026 if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName))
4028 return Standard_False;
4030 theColor = Quantity_Color (aColorName);
4031 return Standard_True;
4034 static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs)
4038 std::cout << theArgs[0] << " error: wrong number of parameters. Type 'help"
4039 << theArgs[0] <<"' for more information.\n";
4040 return 1; //TCL_ERROR
4043 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
4044 TCollection_AsciiString aParseKey;
4045 for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt)
4047 TCollection_AsciiString anArg (theArgs [anArgIt]);
4049 if (anArg.Value (1) == '-' && !anArg.IsRealValue())
4052 aParseKey.Remove (1);
4053 aParseKey.LowerCase();
4054 aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
4058 if (aParseKey.IsEmpty())
4063 aMapOfArgs(aParseKey)->Append (anArg);
4067 for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
4068 aMapIt.More(); aMapIt.Next())
4070 const TCollection_AsciiString& aKey = aMapIt.Key();
4071 const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
4073 // Bool key, without arguments
4074 if ((aKey.IsEqual ("on") || aKey.IsEqual ("off"))
4075 && anArgs->IsEmpty())
4081 if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname"))
4082 && anArgs->Length() == 1)
4088 if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname")
4089 || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks")
4090 || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues")
4091 || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes"))
4092 && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off")))
4097 // One string argument
4098 if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor")
4099 || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor"))
4100 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4105 // One integer argument
4106 if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks")
4107 || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength")
4108 || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset")
4109 || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset"))
4110 && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue())
4115 // One real argument
4116 if ( aKey.IsEqual ("arrowlength")
4117 && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue()))
4122 // Two string arguments
4123 if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont"))
4124 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4129 TCollection_AsciiString aLowerKey;
4132 aLowerKey.LowerCase();
4133 std::cout << theArgs[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n";
4134 std::cout << "Type help for more information.\n";
4138 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
4139 if (anAISContext.IsNull())
4141 std::cout << theArgs[0] << ": please use 'vinit' command to initialize view.\n";
4145 Standard_Boolean toDisplay = Standard_True;
4146 Quantity_Color aColor;
4147 Graphic3d_GraduatedTrihedron aTrihedronData;
4148 // Process parameters
4149 Handle(TColStd_HSequenceOfAsciiString) aValues;
4150 if (aMapOfArgs.Find ("off", aValues))
4152 toDisplay = Standard_False;
4156 if (aMapOfArgs.Find ("xname", aValues))
4158 aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1));
4160 if (aMapOfArgs.Find ("yname", aValues))
4162 aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1));
4164 if (aMapOfArgs.Find ("zname", aValues))
4166 aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1));
4168 if (aMapOfArgs.Find ("xdrawname", aValues))
4170 aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
4172 if (aMapOfArgs.Find ("ydrawname", aValues))
4174 aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
4176 if (aMapOfArgs.Find ("zdrawname", aValues))
4178 aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
4180 if (aMapOfArgs.Find ("xnameoffset", aValues))
4182 aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
4184 if (aMapOfArgs.Find ("ynameoffset", aValues))
4186 aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
4188 if (aMapOfArgs.Find ("znameoffset", aValues))
4190 aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
4194 if (aMapOfArgs.Find ("xnamecolor", aValues))
4196 if (!GetColor (aValues->Value(1), aColor))
4198 std::cout << theArgs[0] << "error: -xnamecolor wrong color name.\n";
4201 aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor);
4203 if (aMapOfArgs.Find ("ynamecolor", aValues))
4205 if (!GetColor (aValues->Value(1), aColor))
4207 std::cout << theArgs[0] << "error: -ynamecolor wrong color name.\n";
4210 aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor);
4212 if (aMapOfArgs.Find ("znamecolor", aValues))
4214 if (!GetColor (aValues->Value(1), aColor))
4216 std::cout << theArgs[0] << "error: -znamecolor wrong color name.\n";
4219 aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor);
4221 if (aMapOfArgs.Find ("xcolor", aValues))
4223 if (!GetColor (aValues->Value(1), aColor))
4225 std::cout << theArgs[0] << "error: -xcolor wrong color name.\n";
4228 aTrihedronData.ChangeXAxisAspect().SetColor (aColor);
4230 if (aMapOfArgs.Find ("ycolor", aValues))
4232 if (!GetColor (aValues->Value(1), aColor))
4234 std::cout << theArgs[0] << "error: -ycolor wrong color name.\n";
4237 aTrihedronData.ChangeYAxisAspect().SetColor (aColor);
4239 if (aMapOfArgs.Find ("zcolor", aValues))
4241 if (!GetColor (aValues->Value(1), aColor))
4243 std::cout << theArgs[0] << "error: -zcolor wrong color name.\n";
4246 aTrihedronData.ChangeZAxisAspect().SetColor (aColor);
4250 if (aMapOfArgs.Find ("xticks", aValues))
4252 aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4254 if (aMapOfArgs.Find ("yticks", aValues))
4256 aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4258 if (aMapOfArgs.Find ("zticks", aValues))
4260 aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4262 if (aMapOfArgs.Find ("xticklength", aValues))
4264 aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4266 if (aMapOfArgs.Find ("yticklength", aValues))
4268 aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4270 if (aMapOfArgs.Find ("zticklength", aValues))
4272 aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4274 if (aMapOfArgs.Find ("xdrawticks", aValues))
4276 aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4278 if (aMapOfArgs.Find ("ydrawticks", aValues))
4280 aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4282 if (aMapOfArgs.Find ("zdrawticks", aValues))
4284 aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4288 if (aMapOfArgs.Find ("xdrawvalues", aValues))
4290 aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4292 if (aMapOfArgs.Find ("ydrawvalues", aValues))
4294 aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4296 if (aMapOfArgs.Find ("zdrawvalues", aValues))
4298 aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4300 if (aMapOfArgs.Find ("xvaluesoffset", aValues))
4302 aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4304 if (aMapOfArgs.Find ("yvaluesoffset", aValues))
4306 aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4308 if (aMapOfArgs.Find ("zvaluesoffset", aValues))
4310 aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4314 if (aMapOfArgs.Find ("arrowlength", aValues))
4316 aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue());
4320 if (aMapOfArgs.Find ("namefont", aValues))
4322 aTrihedronData.SetNamesFont (aValues->Value(1));
4324 if (aMapOfArgs.Find ("valuesfont", aValues))
4326 aTrihedronData.SetValuesFont (aValues->Value(1));
4329 if (aMapOfArgs.Find ("drawgrid", aValues))
4331 aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on"));
4333 if (aMapOfArgs.Find ("drawaxes", aValues))
4335 aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on"));
4338 // The final step: display of erase trihedron
4341 ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData);
4345 ViewerTest::CurrentView()->GraduatedTrihedronErase();
4348 ViewerTest::GetAISContext()->UpdateCurrentViewer();
4349 ViewerTest::CurrentView()->Redraw();
4354 //==============================================================================
4357 //==============================================================================
4358 static int VTile (Draw_Interpretor& theDI,
4359 Standard_Integer theArgNb,
4360 const char** theArgVec)
4362 Handle(V3d_View) aView = ViewerTest::CurrentView();
4365 std::cerr << "Error: no active viewer.\n";
4369 Graphic3d_CameraTile aTile = aView->Camera()->Tile();
4372 theDI << "Total size: " << aTile.TotalSize.x() << " " << aTile.TotalSize.y() << "\n"
4373 << "Tile size: " << aTile.TileSize.x() << " " << aTile.TileSize.y() << "\n"
4374 << "Lower left: " << aTile.Offset.x() << " " << aTile.Offset.y() << "\n";
4378 aView->Window()->Size (aTile.TileSize.x(), aTile.TileSize.y());
4379 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
4381 TCollection_AsciiString anArg (theArgVec[anArgIter]);
4383 if (anArg == "-lowerleft"
4384 || anArg == "-upperleft")
4386 if (anArgIter + 3 < theArgNb)
4388 std::cerr << "Syntax error at '" << theArgVec[anArgIter] << "'.\n";
4391 aTile.IsTopDown = (anArg == "-upperleft") == Standard_True;
4392 aTile.Offset.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
4393 aTile.Offset.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
4395 else if (anArg == "-total"
4396 || anArg == "-totalsize"
4397 || anArg == "-viewsize")
4399 if (anArgIter + 3 < theArgNb)
4401 std::cerr << "Syntax error at '" << theArgVec[anArgIter] << "'.\n";
4404 aTile.TotalSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
4405 aTile.TotalSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
4406 if (aTile.TotalSize.x() < 1
4407 || aTile.TotalSize.y() < 1)
4409 std::cerr << "Error: total size is incorrect.\n";
4413 else if (anArg == "-tilesize")
4415 if (anArgIter + 3 < theArgNb)
4417 std::cerr << "Syntax error at '" << theArgVec[anArgIter] << "'.\n";
4421 aTile.TileSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
4422 aTile.TileSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
4423 if (aTile.TileSize.x() < 1
4424 || aTile.TileSize.y() < 1)
4426 std::cerr << "Error: tile size is incorrect.\n";
4430 else if (anArg == "-unset")
4432 aView->Camera()->SetTile (Graphic3d_CameraTile());
4438 if (aTile.TileSize.x() < 1
4439 || aTile.TileSize.y() < 1)
4441 std::cerr << "Error: tile size is undefined.\n";
4444 else if (aTile.TotalSize.x() < 1
4445 || aTile.TotalSize.y() < 1)
4447 std::cerr << "Error: total size is undefined.\n";
4451 aView->Camera()->SetTile (aTile);
4456 //! Format ZLayer ID.
4457 inline const char* formZLayerId (const Standard_Integer theLayerId)
4461 case Graphic3d_ZLayerId_UNKNOWN: return "[INVALID]";
4462 case Graphic3d_ZLayerId_Default: return "[DEFAULT]";
4463 case Graphic3d_ZLayerId_Top: return "[TOP]";
4464 case Graphic3d_ZLayerId_Topmost: return "[TOPMOST]";
4465 case Graphic3d_ZLayerId_TopOSD: return "[OVERLAY]";
4466 case Graphic3d_ZLayerId_BotOSD: return "[UNDERLAY]";
4471 //! Print the ZLayer information.
4472 inline void printZLayerInfo (Draw_Interpretor& theDI,
4473 const Graphic3d_ZLayerSettings& theLayer)
4475 if (!theLayer.Name().IsEmpty())
4477 theDI << " Name: " << theLayer.Name() << "\n";
4479 if (theLayer.IsImmediate())
4481 theDI << " Immediate: TRUE\n";
4483 theDI << " Origin: " << theLayer.Origin().X() << " " << theLayer.Origin().Y() << " " << theLayer.Origin().Z() << "\n";
4484 theDI << " Depth test: " << (theLayer.ToEnableDepthTest() ? "enabled" : "disabled") << "\n";
4485 theDI << " Depth write: " << (theLayer.ToEnableDepthWrite() ? "enabled" : "disabled") << "\n";
4486 theDI << " Depth buffer clearing: " << (theLayer.ToClearDepth() ? "enabled" : "disabled") << "\n";
4487 if (theLayer.PolygonOffset().Mode != Aspect_POM_None)
4489 theDI << " Depth offset: " << theLayer.PolygonOffset().Factor << " " << theLayer.PolygonOffset().Units << "\n";
4493 //==============================================================================
4494 //function : VZLayer
4495 //purpose : Test z layer operations for v3d viewer
4496 //==============================================================================
4497 static int VZLayer (Draw_Interpretor& theDI,
4498 Standard_Integer theArgNb,
4499 const char** theArgVec)
4501 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
4502 if (aContextAIS.IsNull())
4504 std::cout << "No active viewer!\n";
4508 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
4511 TColStd_SequenceOfInteger aLayers;
4512 aViewer->GetAllZLayers (aLayers);
4513 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
4515 theDI << "ZLayer " << aLayeriter.Value() << " " << formZLayerId (aLayeriter.Value()) << "\n";
4516 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
4517 printZLayerInfo (theDI, aSettings);
4522 Standard_Integer anArgIter = 1;
4523 Standard_Integer aLayerId = Graphic3d_ZLayerId_UNKNOWN;
4524 ViewerTest_AutoUpdater anUpdateTool (aContextAIS, ViewerTest::CurrentView());
4525 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
4530 TCollection_AsciiString aFirstArg (theArgVec[anArgIter]);
4531 if (aFirstArg.IsIntegerValue())
4534 aLayerId = aFirstArg.IntegerValue();
4538 aFirstArg.LowerCase();
4539 if (aFirstArg == "default"
4540 || aFirstArg == "def")
4542 aLayerId = Graphic3d_ZLayerId_Default;
4545 else if (aFirstArg == "top")
4547 aLayerId = Graphic3d_ZLayerId_Top;
4550 else if (aFirstArg == "topmost")
4552 aLayerId = Graphic3d_ZLayerId_Topmost;
4555 else if (aFirstArg == "overlay"
4556 || aFirstArg == "toposd")
4558 aLayerId = Graphic3d_ZLayerId_TopOSD;
4561 else if (aFirstArg == "underlay"
4562 || aFirstArg == "botosd")
4564 aLayerId = Graphic3d_ZLayerId_BotOSD;
4569 TColStd_SequenceOfInteger aLayers;
4570 aViewer->GetAllZLayers (aLayers);
4571 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
4573 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
4574 if (TCollection_AsciiString::IsSameString (aSettings.Name(), aFirstArg, Standard_False))
4576 aLayerId = aLayeriter.Value();
4584 for (; anArgIter < theArgNb; ++anArgIter)
4586 // perform operation
4587 TCollection_AsciiString anArg (theArgVec[anArgIter]);
4589 if (anUpdateTool.parseRedrawMode (anArg))
4593 else if (anArg == "-add"
4596 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
4597 if (!aViewer->AddZLayer (aLayerId))
4599 std::cout << "Error: can not add a new z layer!\n";
4605 else if (anArg == "-del"
4606 || anArg == "-delete"
4609 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4611 if (++anArgIter >= theArgNb)
4613 std::cout << "Syntax error: id of z layer to remove is missing\n";
4617 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
4620 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN
4621 || aLayerId == Graphic3d_ZLayerId_Default
4622 || aLayerId == Graphic3d_ZLayerId_Top
4623 || aLayerId == Graphic3d_ZLayerId_Topmost
4624 || aLayerId == Graphic3d_ZLayerId_TopOSD
4625 || aLayerId == Graphic3d_ZLayerId_BotOSD)
4627 std::cout << "Syntax error: standard Z layer can not be removed\n";
4631 // move all object displayed in removing layer to default layer
4632 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
4633 anObjIter.More(); anObjIter.Next())
4635 Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anObjIter.Key1());
4637 || aPrs->ZLayer() != aLayerId)
4641 aPrs->SetZLayer (Graphic3d_ZLayerId_Default);
4644 if (!aViewer->RemoveZLayer (aLayerId))
4646 std::cout << "Z layer can not be removed!\n";
4650 theDI << aLayerId << " ";
4653 else if (anArg == "-get"
4656 TColStd_SequenceOfInteger aLayers;
4657 aViewer->GetAllZLayers (aLayers);
4658 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
4660 theDI << aLayeriter.Value() << " ";
4665 else if (anArg == "-name")
4667 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4669 std::cout << "Syntax error: id of Z layer is missing\n";
4673 if (++anArgIter >= theArgNb)
4675 std::cout << "Syntax error: name is missing\n";
4679 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4680 aSettings.SetName (theArgVec[anArgIter]);
4681 aViewer->SetZLayerSettings (aLayerId, aSettings);
4683 else if (anArg == "-origin")
4685 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4687 std::cout << "Syntax error: id of Z layer is missing\n";
4691 if (anArgIter + 2 >= theArgNb)
4693 std::cout << "Syntax error: origin coordinates are missing\n";
4697 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4699 anOrigin.SetX (Draw::Atof (theArgVec[anArgIter + 1]));
4700 anOrigin.SetY (Draw::Atof (theArgVec[anArgIter + 2]));
4701 anOrigin.SetZ (0.0);
4702 if (anArgIter + 3 < theArgNb)
4704 anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter + 3]));
4711 aSettings.SetOrigin (anOrigin);
4712 aViewer->SetZLayerSettings (aLayerId, aSettings);
4714 else if (anArg == "-settings"
4715 || anArg == "settings")
4717 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4719 if (++anArgIter >= theArgNb)
4721 std::cout << "Syntax error: id of Z layer is missing\n";
4725 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
4728 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4729 printZLayerInfo (theDI, aSettings);
4731 else if (anArg == "-enable"
4732 || anArg == "enable"
4733 || anArg == "-disable"
4734 || anArg == "disable")
4736 const Standard_Boolean toEnable = anArg == "-enable"
4737 || anArg == "enable";
4738 if (++anArgIter >= theArgNb)
4740 std::cout << "Syntax error: option name is missing\n";
4744 TCollection_AsciiString aSubOp (theArgVec[anArgIter]);
4746 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
4748 if (++anArgIter >= theArgNb)
4750 std::cout << "Syntax error: id of Z layer is missing\n";
4754 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
4757 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
4758 if (aSubOp == "depthtest"
4759 || aSubOp == "test")
4761 aSettings.SetEnableDepthTest (toEnable);
4763 else if (aSubOp == "depthwrite"
4764 || aSubOp == "write")
4766 aSettings.SetEnableDepthWrite (toEnable);
4768 else if (aSubOp == "depthclear"
4769 || aSubOp == "clear")
4771 aSettings.SetClearDepth (toEnable);
4773 else if (aSubOp == "depthoffset"
4774 || aSubOp == "offset")
4776 Graphic3d_PolygonOffset aParams;
4777 aParams.Mode = toEnable ? Aspect_POM_Fill : Aspect_POM_None;
4780 if (anArgIter + 2 >= theArgNb)
4782 std::cout << "Syntax error: factor and units values for depth offset are missing\n";
4786 aParams.Factor = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
4787 aParams.Units = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
4789 aSettings.SetPolygonOffset (aParams);
4791 else if (aSubOp == "positiveoffset"
4792 || aSubOp == "poffset")
4796 aSettings.SetDepthOffsetPositive();
4800 aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
4803 else if (aSubOp == "negativeoffset"
4804 || aSubOp == "noffset")
4808 aSettings.SetDepthOffsetNegative();
4812 aSettings.SetPolygonOffset(Graphic3d_PolygonOffset());
4815 else if (aSubOp == "textureenv")
4817 aSettings.SetEnvironmentTexture (toEnable);
4820 aViewer->SetZLayerSettings (aLayerId, aSettings);
4824 std::cout << "Syntax error: unknown option " << theArgVec[anArgIter] << "\n";
4832 // The interactive presentation of 2d layer item
4833 // for "vlayerline" command it provides a presentation of
4834 // line with user-defined linewidth, linetype and transparency.
4835 class V3d_LineItem : public AIS_InteractiveObject
4839 DEFINE_STANDARD_RTTI_INLINE(V3d_LineItem,AIS_InteractiveObject)
4842 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
4843 Standard_Real X2, Standard_Real Y2,
4844 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
4845 Standard_Real theWidth = 0.5,
4846 Standard_Real theTransp = 1.0);
4850 void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
4851 const Handle(Prs3d_Presentation)& thePresentation,
4852 const Standard_Integer theMode) Standard_OVERRIDE;
4854 void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
4855 const Standard_Integer /*aMode*/) Standard_OVERRIDE
4860 Standard_Real myX1, myY1, myX2, myY2;
4861 Aspect_TypeOfLine myType;
4862 Standard_Real myWidth;
4865 // default constructor for line item
4866 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
4867 Standard_Real X2, Standard_Real Y2,
4868 Aspect_TypeOfLine theType,
4869 Standard_Real theWidth,
4870 Standard_Real theTransp) :
4871 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2),
4872 myType(theType), myWidth(theWidth)
4874 SetTransparency (1-theTransp);
4878 void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
4879 const Handle(Prs3d_Presentation)& thePresentation,
4880 const Standard_Integer /*theMode*/)
4882 thePresentation->Clear();
4883 Quantity_Color aColor (1.0, 0, 0, Quantity_TOC_RGB);
4884 Standard_Integer aWidth, aHeight;
4885 ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
4886 Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
4887 Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
4888 aPrim->AddVertex(myX1, aHeight-myY1, 0.);
4889 aPrim->AddVertex(myX2, aHeight-myY2, 0.);
4890 Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (aColor, (Aspect_TypeOfLine)myType, myWidth);
4891 aGroup->SetPrimitivesAspect (anAspect->Aspect());
4892 aGroup->AddPrimitiveArray (aPrim);
4895 //=============================================================================
4896 //function : VLayerLine
4897 //purpose : Draws line in the v3d view layer with given attributes: linetype,
4898 // : linewidth, transparency coefficient
4899 //============================================================================
4900 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
4902 // get the active view
4903 Handle(V3d_View) aView = ViewerTest::CurrentView();
4906 di << "Call vinit before!\n";
4911 di << "Use: " << argv[0];
4912 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
4913 di << " linetype : { 0 | 1 | 2 | 3 } \n";
4914 di << " 0 - solid \n";
4915 di << " 1 - dashed \n";
4916 di << " 2 - dot \n";
4917 di << " 3 - dashdot\n";
4918 di << " transparency : { 0.0 - 1.0 } \n";
4919 di << " 0.0 - transparent\n";
4920 di << " 1.0 - visible \n";
4924 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4925 // get the input params
4926 Standard_Real X1 = Draw::Atof(argv[1]);
4927 Standard_Real Y1 = Draw::Atof(argv[2]);
4928 Standard_Real X2 = Draw::Atof(argv[3]);
4929 Standard_Real Y2 = Draw::Atof(argv[4]);
4931 Standard_Real aWidth = 0.5;
4932 Standard_Real aTransparency = 1.0;
4936 aWidth = Draw::Atof(argv[5]);
4938 // select appropriate line type
4939 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
4941 && !ViewerTest::ParseLineType (argv[6], aLineType))
4943 std::cout << "Syntax error: unknown line type '" << argv[6] << "'\n";
4950 aTransparency = Draw::Atof(argv[7]);
4951 if (aTransparency < 0 || aTransparency > 1.0)
4952 aTransparency = 1.0;
4955 static Handle (V3d_LineItem) aLine;
4956 if (!aLine.IsNull())
4958 aContext->Erase (aLine, Standard_False);
4960 aLine = new V3d_LineItem (X1, Y1, X2, Y2,
4964 aContext->SetTransformPersistence (aLine, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
4965 aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD);
4966 aLine->SetToUpdate();
4967 aContext->Display (aLine, Standard_True);
4973 //==============================================================================
4976 //==============================================================================
4978 static int VGrid (Draw_Interpretor& /*theDI*/,
4979 Standard_Integer theArgNb,
4980 const char** theArgVec)
4982 // get the active view
4983 Handle(V3d_View) aView = ViewerTest::CurrentView();
4984 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
4985 if (aView.IsNull() || aViewer.IsNull())
4987 std::cerr << "No active view. Please call vinit.\n";
4991 Aspect_GridType aType = aViewer->GridType();
4992 Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
4993 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
4994 Standard_Integer anIter = 1;
4995 for (; anIter < theArgNb; ++anIter)
4997 const char* aValue = theArgVec[anIter];
4998 if (anUpdateTool.parseRedrawMode (aValue))
5002 else if (*aValue == 'r')
5004 aType = Aspect_GT_Rectangular;
5006 else if (*aValue == 'c')
5008 aType = Aspect_GT_Circular;
5010 else if (*aValue == 'l')
5012 aMode = Aspect_GDM_Lines;
5014 else if (*aValue == 'p')
5016 aMode = Aspect_GDM_Points;
5018 else if (strcmp (aValue, "off" ) == 0)
5020 aViewer->DeactivateGrid();
5029 Standard_Integer aTail = (theArgNb - anIter);
5032 aViewer->ActivateGrid (aType, aMode);
5035 else if (aTail != 2 && aTail != 5)
5037 std::cerr << "Incorrect arguments number! Usage:\n"
5038 << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n";
5042 Standard_Real anOriginX, anOriginY, aRotAngle;
5043 if (aType == Aspect_GT_Rectangular)
5045 Standard_Real aRStepX, aRStepY;
5046 aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
5048 anOriginX = Draw::Atof (theArgVec[anIter++]);
5049 anOriginY = Draw::Atof (theArgVec[anIter++]);
5052 aRStepX = Draw::Atof (theArgVec[anIter++]);
5053 aRStepY = Draw::Atof (theArgVec[anIter++]);
5054 aRotAngle = Draw::Atof (theArgVec[anIter++]);
5056 aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
5057 aViewer->ActivateGrid (aType, aMode);
5059 else if (aType == Aspect_GT_Circular)
5061 Standard_Real aRadiusStep;
5062 Standard_Integer aDivisionNumber;
5063 aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
5065 anOriginX = Draw::Atof (theArgVec[anIter++]);
5066 anOriginY = Draw::Atof (theArgVec[anIter++]);
5069 aRadiusStep = Draw::Atof (theArgVec[anIter++]);
5070 aDivisionNumber = Draw::Atoi (theArgVec[anIter++]);
5071 aRotAngle = Draw::Atof (theArgVec[anIter++]);
5074 aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
5075 aViewer->ActivateGrid (aType, aMode);
5081 //==============================================================================
5082 //function : VPriviledgedPlane
5084 //==============================================================================
5086 static int VPriviledgedPlane (Draw_Interpretor& theDI,
5087 Standard_Integer theArgNb,
5088 const char** theArgVec)
5090 if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10)
5092 std::cerr << "Error: wrong number of arguments! See usage:\n";
5093 theDI.PrintHelp (theArgVec[0]);
5097 // get the active viewer
5098 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
5099 if (aViewer.IsNull())
5101 std::cerr << "Error: no active viewer. Please call vinit.\n";
5107 gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane();
5108 const gp_Pnt& anOrig = aPriviledgedPlane.Location();
5109 const gp_Dir& aNorm = aPriviledgedPlane.Direction();
5110 const gp_Dir& aXDir = aPriviledgedPlane.XDirection();
5111 theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " "
5112 << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " "
5113 << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n";
5117 Standard_Integer anArgIdx = 1;
5118 Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]);
5119 Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]);
5120 Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]);
5121 Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]);
5122 Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]);
5123 Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]);
5125 gp_Ax3 aPriviledgedPlane;
5126 gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ);
5127 gp_Dir aNorm (aNormX, aNormY, aNormZ);
5130 Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]);
5131 Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]);
5132 Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]);
5133 gp_Dir aXDir (aXDirX, aXDirY, aXDirZ);
5134 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir);
5138 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm);
5141 aViewer->SetPrivilegedPlane (aPriviledgedPlane);
5146 //==============================================================================
5147 //function : VConvert
5149 //==============================================================================
5151 static int VConvert (Draw_Interpretor& theDI,
5152 Standard_Integer theArgNb,
5153 const char** theArgVec)
5155 // get the active view
5156 Handle(V3d_View) aView = ViewerTest::CurrentView();
5159 std::cerr << "Error: no active view. Please call vinit.\n";
5163 enum { Model, Ray, View, Window, Grid } aMode = Model;
5165 // access coordinate arguments
5166 TColStd_SequenceOfReal aCoord;
5167 Standard_Integer anArgIdx = 1;
5168 for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx)
5170 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
5171 if (!anArg.IsRealValue())
5175 aCoord.Append (anArg.RealValue());
5178 // non-numeric argument too early
5179 if (aCoord.IsEmpty())
5181 std::cerr << "Error: wrong number of arguments! See usage:\n";
5182 theDI.PrintHelp (theArgVec[0]);
5186 // collect all other arguments and options
5187 for (; anArgIdx < theArgNb; ++anArgIdx)
5189 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
5191 if (anArg == "window") aMode = Window;
5192 else if (anArg == "view") aMode = View;
5193 else if (anArg == "grid") aMode = Grid;
5194 else if (anArg == "ray") aMode = Ray;
5197 std::cerr << "Error: wrong argument " << anArg << "! See usage:\n";
5198 theDI.PrintHelp (theArgVec[0]);
5203 // complete input checks
5204 if ((aCoord.Length() == 1 && theArgNb > 3) ||
5205 (aCoord.Length() == 2 && theArgNb > 4) ||
5206 (aCoord.Length() == 3 && theArgNb > 5))
5208 std::cerr << "Error: wrong number of arguments! See usage:\n";
5209 theDI.PrintHelp (theArgVec[0]);
5213 Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
5214 Standard_Integer aXYp[2] = {0, 0};
5216 // convert one-dimensional coordinate
5217 if (aCoord.Length() == 1)
5221 case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer)aCoord (1)); return 0;
5222 case Window : theDI << "Window Vp: " << aView->Convert (aCoord (1)); return 0;
5224 std::cerr << "Error: wrong arguments! See usage:\n";
5225 theDI.PrintHelp (theArgVec[0]);
5230 // convert 2D coordinates from projection or view reference space
5231 if (aCoord.Length() == 2)
5236 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
5237 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
5241 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]);
5242 theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n";
5246 aView->Convert (aCoord (1), aCoord (2), aXYp[0], aXYp[1]);
5247 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
5251 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
5252 aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]);
5253 theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
5257 aView->ConvertWithProj ((Standard_Integer) aCoord (1),
5258 (Standard_Integer) aCoord (2),
5259 aXYZ[0], aXYZ[1], aXYZ[2],
5260 aXYZ[3], aXYZ[4], aXYZ[5]);
5261 theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
5265 std::cerr << "Error: wrong arguments! See usage:\n";
5266 theDI.PrintHelp (theArgVec[0]);
5271 // convert 3D coordinates from view reference space
5272 else if (aCoord.Length() == 3)
5277 aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]);
5278 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
5282 aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]);
5283 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
5287 std::cerr << "Error: wrong arguments! See usage:\n";
5288 theDI.PrintHelp (theArgVec[0]);
5296 //==============================================================================
5299 //==============================================================================
5301 static int VFps (Draw_Interpretor& theDI,
5302 Standard_Integer theArgNb,
5303 const char** theArgVec)
5305 // get the active view
5306 Handle(V3d_View) aView = ViewerTest::CurrentView();
5309 std::cerr << "No active view. Please call vinit.\n";
5313 Standard_Integer aFramesNb = (theArgNb > 1) ? Draw::Atoi(theArgVec[1]) : 100;
5316 std::cerr << "Incorrect arguments!\n";
5320 // the time is meaningless for first call
5321 // due to async OpenGl rendering
5324 // redraw view in loop to estimate average values
5327 for (Standard_Integer anInter = 0; anInter < aFramesNb; ++anInter)
5333 const Standard_Real aTime = aTimer.ElapsedTime();
5334 aTimer.OSD_Chronometer::Show (aCpu);
5336 const Standard_Real aFpsAver = Standard_Real(aFramesNb) / aTime;
5337 const Standard_Real aCpuAver = aCpu / Standard_Real(aFramesNb);
5339 // return statistics
5340 theDI << "FPS: " << aFpsAver << "\n"
5341 << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
5343 // compute additional statistics in ray-tracing mode
5344 Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
5346 if (aParams.Method == Graphic3d_RM_RAYTRACING)
5348 Standard_Integer aSizeX;
5349 Standard_Integer aSizeY;
5351 aView->Window()->Size (aSizeX, aSizeY);
5353 // 1 shadow ray and 1 secondary ray pew each bounce
5354 const Standard_Real aMRays = aSizeX * aSizeY * aFpsAver * aParams.RaytracingDepth * 2 / 1.0e6f;
5356 theDI << "MRays/sec (upper bound): " << aMRays << "\n";
5362 //==============================================================================
5363 //function : VGlDebug
5365 //==============================================================================
5367 static int VGlDebug (Draw_Interpretor& theDI,
5368 Standard_Integer theArgNb,
5369 const char** theArgVec)
5371 Handle(OpenGl_GraphicDriver) aDriver;
5372 Handle(V3d_View) aView = ViewerTest::CurrentView();
5373 if (!aView.IsNull())
5375 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
5377 OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps;
5378 OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
5382 TCollection_AsciiString aDebActive, aSyncActive;
5389 Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
5390 "GL_ARB_debug_output");
5391 aDebActive = isActive ? " (active)" : " (inactive)";
5394 // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
5395 aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
5399 theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n"
5400 << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n"
5401 << "glslWarn:" << (aCaps->glslWarnings ? "1" : "0") << "\n"
5402 << "extraMsg:" << (aCaps->suppressExtraMsg ? "0" : "1") << "\n";
5406 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5408 Standard_CString anArg = theArgVec[anArgIter];
5409 TCollection_AsciiString anArgCase (anArg);
5410 anArgCase.LowerCase();
5411 Standard_Boolean toEnableDebug = Standard_True;
5412 if (anArgCase == "-glsl"
5413 || anArgCase == "-glslwarn"
5414 || anArgCase == "-glslwarns"
5415 || anArgCase == "-glslwarnings")
5417 Standard_Boolean toShowWarns = Standard_True;
5418 if (++anArgIter < theArgNb
5419 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShowWarns))
5423 aDefCaps->glslWarnings = toShowWarns;
5426 aCaps->glslWarnings = toShowWarns;
5429 else if (anArgCase == "-extra"
5430 || anArgCase == "-extramsg"
5431 || anArgCase == "-extramessages")
5433 Standard_Boolean toShow = Standard_True;
5434 if (++anArgIter < theArgNb
5435 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShow))
5439 aDefCaps->suppressExtraMsg = !toShow;
5442 aCaps->suppressExtraMsg = !toShow;
5445 else if (anArgCase == "-noextra"
5446 || anArgCase == "-noextramsg"
5447 || anArgCase == "-noextramessages")
5449 Standard_Boolean toSuppress = Standard_True;
5450 if (++anArgIter < theArgNb
5451 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSuppress))
5455 aDefCaps->suppressExtraMsg = toSuppress;
5458 aCaps->suppressExtraMsg = toSuppress;
5461 else if (anArgCase == "-sync")
5463 Standard_Boolean toSync = Standard_True;
5464 if (++anArgIter < theArgNb
5465 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSync))
5469 aDefCaps->contextSyncDebug = toSync;
5472 aDefCaps->contextDebug = Standard_True;
5475 else if (anArgCase == "-debug")
5477 if (++anArgIter < theArgNb
5478 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
5482 aDefCaps->contextDebug = toEnableDebug;
5484 else if (ViewerTest::ParseOnOff (anArg, toEnableDebug)
5485 && (anArgIter + 1 == theArgNb))
5487 // simple alias to turn on almost everything
5488 aDefCaps->contextDebug = toEnableDebug;
5489 aDefCaps->contextSyncDebug = toEnableDebug;
5490 aDefCaps->glslWarnings = toEnableDebug;
5494 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
5502 //==============================================================================
5505 //==============================================================================
5507 static int VVbo (Draw_Interpretor& theDI,
5508 Standard_Integer theArgNb,
5509 const char** theArgVec)
5511 const Standard_Boolean toSet = (theArgNb > 1);
5512 const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
5515 ViewerTest_myDefaultCaps.vboDisable = toUseVbo;
5519 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5520 if (aContextAIS.IsNull())
5524 std::cerr << "No active view!\n";
5528 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
5529 if (!aDriver.IsNull())
5533 theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
5537 aDriver->ChangeOptions().vboDisable = toUseVbo;
5544 //==============================================================================
5547 //==============================================================================
5549 static int VCaps (Draw_Interpretor& theDI,
5550 Standard_Integer theArgNb,
5551 const char** theArgVec)
5553 OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps;
5554 Handle(OpenGl_GraphicDriver) aDriver;
5555 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5556 if (!aContext.IsNull())
5558 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
5559 aCaps = &aDriver->ChangeOptions();
5564 theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n";
5565 theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
5566 theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
5567 theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
5568 theDI << "VSync: " << aCaps->swapInterval << "\n";
5569 theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
5570 theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
5571 theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
5575 ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
5576 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5578 Standard_CString anArg = theArgVec[anArgIter];
5579 TCollection_AsciiString anArgCase (anArg);
5580 anArgCase.LowerCase();
5581 if (anUpdateTool.parseRedrawMode (anArg))
5585 else if (anArgCase == "-vsync"
5586 || anArgCase == "-swapinterval")
5588 Standard_Boolean toEnable = Standard_True;
5589 if (++anArgIter < theArgNb
5590 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5594 aCaps->swapInterval = toEnable;
5596 else if (anArgCase == "-ffp")
5598 Standard_Boolean toEnable = Standard_True;
5599 if (++anArgIter < theArgNb
5600 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5604 aCaps->ffpEnable = toEnable;
5606 else if (anArgCase == "-vbo")
5608 Standard_Boolean toEnable = Standard_True;
5609 if (++anArgIter < theArgNb
5610 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5614 aCaps->vboDisable = !toEnable;
5616 else if (anArgCase == "-sprite"
5617 || anArgCase == "-sprites")
5619 Standard_Boolean toEnable = Standard_True;
5620 if (++anArgIter < theArgNb
5621 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5625 aCaps->pntSpritesDisable = !toEnable;
5627 else if (anArgCase == "-softmode")
5629 Standard_Boolean toEnable = Standard_True;
5630 if (++anArgIter < theArgNb
5631 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5635 aCaps->contextNoAccel = toEnable;
5637 else if (anArgCase == "-winbuffer"
5638 || anArgCase == "-windowbuffer"
5639 || anArgCase == "-usewinbuffer"
5640 || anArgCase == "-usewindowbuffer"
5641 || anArgCase == "-usesystembuffer")
5643 Standard_Boolean toEnable = Standard_True;
5644 if (++anArgIter < theArgNb
5645 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5649 aCaps->useSystemBuffer = toEnable;
5651 else if (anArgCase == "-accel"
5652 || anArgCase == "-acceleration")
5654 Standard_Boolean toEnable = Standard_True;
5655 if (++anArgIter < theArgNb
5656 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5660 aCaps->contextNoAccel = !toEnable;
5662 else if (anArgCase == "-compat"
5663 || anArgCase == "-compatprofile"
5664 || anArgCase == "-compatible"
5665 || anArgCase == "-compatibleprofile")
5667 Standard_Boolean toEnable = Standard_True;
5668 if (++anArgIter < theArgNb
5669 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5673 aCaps->contextCompatible = toEnable;
5674 if (!aCaps->contextCompatible)
5676 aCaps->ffpEnable = Standard_False;
5679 else if (anArgCase == "-core"
5680 || anArgCase == "-coreprofile")
5682 Standard_Boolean toEnable = Standard_True;
5683 if (++anArgIter < theArgNb
5684 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5688 aCaps->contextCompatible = !toEnable;
5689 if (!aCaps->contextCompatible)
5691 aCaps->ffpEnable = Standard_False;
5694 else if (anArgCase == "-stereo"
5695 || anArgCase == "-quadbuffer")
5697 Standard_Boolean toEnable = Standard_True;
5698 if (++anArgIter < theArgNb
5699 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
5703 aCaps->contextStereo = toEnable;
5707 std::cout << "Error: unknown argument '" << anArg << "'\n";
5711 if (aCaps != &ViewerTest_myDefaultCaps)
5713 ViewerTest_myDefaultCaps = *aCaps;
5718 //==============================================================================
5719 //function : VMemGpu
5721 //==============================================================================
5723 static int VMemGpu (Draw_Interpretor& theDI,
5724 Standard_Integer theArgNb,
5725 const char** theArgVec)
5728 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5729 if (aContextAIS.IsNull())
5731 std::cerr << "No active view. Please call vinit.\n";
5735 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
5736 if (aDriver.IsNull())
5738 std::cerr << "Graphic driver not available.\n";
5742 Standard_Size aFreeBytes = 0;
5743 TCollection_AsciiString anInfo;
5744 if (!aDriver->MemoryInfo (aFreeBytes, anInfo))
5746 std::cerr << "Information not available.\n";
5750 if (theArgNb > 1 && *theArgVec[1] == 'f')
5752 theDI << Standard_Real (aFreeBytes);
5762 // ==============================================================================
5763 // function : VReadPixel
5765 // ==============================================================================
5766 static int VReadPixel (Draw_Interpretor& theDI,
5767 Standard_Integer theArgNb,
5768 const char** theArgVec)
5770 // get the active view
5771 Handle(V3d_View) aView = ViewerTest::CurrentView();
5774 std::cerr << "No active view. Please call vinit.\n";
5777 else if (theArgNb < 3)
5779 std::cerr << "Usage : " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]\n";
5783 Image_Format aFormat = Image_Format_RGBA;
5784 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
5786 Standard_Integer aWidth, aHeight;
5787 aView->Window()->Size (aWidth, aHeight);
5788 const Standard_Integer anX = Draw::Atoi (theArgVec[1]);
5789 const Standard_Integer anY = Draw::Atoi (theArgVec[2]);
5790 if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight)
5792 std::cerr << "Pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")\n";
5796 Standard_Boolean toShowName = Standard_False;
5797 Standard_Boolean toShowHls = Standard_False;
5798 for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
5800 TCollection_AsciiString aParam (theArgVec[anIter]);
5802 if (aParam == "rgb")
5804 aFormat = Image_Format_RGB;
5805 aBufferType = Graphic3d_BT_RGB;
5807 else if (aParam == "hls")
5809 aFormat = Image_Format_RGB;
5810 aBufferType = Graphic3d_BT_RGB;
5811 toShowHls = Standard_True;
5813 else if (aParam == "rgbf")
5815 aFormat = Image_Format_RGBF;
5816 aBufferType = Graphic3d_BT_RGB;
5818 else if (aParam == "rgba")
5820 aFormat = Image_Format_RGBA;
5821 aBufferType = Graphic3d_BT_RGBA;
5823 else if (aParam == "rgbaf")
5825 aFormat = Image_Format_RGBAF;
5826 aBufferType = Graphic3d_BT_RGBA;
5828 else if (aParam == "depth")
5830 aFormat = Image_Format_GrayF;
5831 aBufferType = Graphic3d_BT_Depth;
5833 else if (aParam == "name")
5835 toShowName = Standard_True;
5839 Image_PixMap anImage;
5840 if (!anImage.InitTrash (aFormat, aWidth, aHeight))
5842 std::cerr << "Image allocation failed\n";
5845 else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType))
5847 std::cerr << "Image dump failed\n";
5851 Standard_Real anAlpha;
5852 Quantity_Color aColor = anImage.PixelColor (anX, anY, anAlpha);
5855 if (aBufferType == Graphic3d_BT_RGBA)
5857 theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha;
5861 theDI << Quantity_Color::StringName (aColor.Name());
5866 switch (aBufferType)
5869 case Graphic3d_BT_RGB:
5873 theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation();
5877 theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue();
5881 case Graphic3d_BT_RGBA:
5883 theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha;
5886 case Graphic3d_BT_Depth:
5888 theDI << aColor.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 == "-exposure")
9653 if (++anArgIter >= theArgNb)
9655 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9659 TCollection_AsciiString anExposure (theArgVec[anArgIter]);
9660 if (anExposure.IsRealValue())
9662 aView->ChangeRenderingParams().Exposure = static_cast<float> (anExposure.RealValue());
9666 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9670 else if (aFlag == "-whitepoint")
9672 if (++anArgIter >= theArgNb)
9674 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9678 TCollection_AsciiString aWhitePoint (theArgVec[anArgIter]);
9679 if (aWhitePoint.IsRealValue())
9681 aView->ChangeRenderingParams().WhitePoint = static_cast<float> (aWhitePoint.RealValue());
9685 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9689 else if (aFlag == "-tonemapping")
9691 if (++anArgIter >= theArgNb)
9693 std::cout << "Error: wrong syntax at argument '" << anArg << "'\n";
9697 TCollection_AsciiString aMode (theArgVec[anArgIter]);
9700 if (aMode == "disabled")
9702 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Disabled;
9704 else if (aMode == "filmic")
9706 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Filmic;
9710 std::cout << "Error: wrong syntax at argument'" << anArg << "'.\n";
9716 std::cout << "Error: wrong syntax, unknown flag '" << anArg << "'\n";
9724 //=======================================================================
9725 //function : VProgressiveMode
9727 //=======================================================================
9729 static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/,
9730 Standard_Integer /*theNbArgs*/,
9731 const char** /*theArgs*/)
9733 Handle(V3d_View) aView = ViewerTest::CurrentView();
9736 std::cerr << "Error: no active viewer!\n";
9740 std::cout << "Press Enter or Escape key to exit progressive rendering mode" << std::endl;
9746 Standard_Boolean toExit = Standard_False;
9749 while (PeekMessageW (&aMsg, NULL, 0, 0, PM_REMOVE))
9751 if (aMsg.message == WM_KEYDOWN && (aMsg.wParam == 0x0d || aMsg.wParam == 0x1b))
9753 toExit = Standard_True;
9756 TranslateMessage (&aMsg);
9757 DispatchMessageW (&aMsg);
9770 //=======================================================================
9771 //function : VFrustumCulling
9772 //purpose : enables/disables view volume's culling.
9773 //=======================================================================
9774 static int VFrustumCulling (Draw_Interpretor& theDI,
9775 Standard_Integer theArgNb,
9776 const char** theArgVec)
9778 Handle(V3d_View) aView = ViewerTest::CurrentView();
9781 std::cout << theArgVec[0] << " Error: Use 'vinit' command before\n";
9787 theDI << (aView->IsCullingEnabled() ? "on" : "off");
9790 else if (theArgNb != 2)
9792 std::cout << theArgVec[0] << " Syntax error: Specify the mode\n";
9796 TCollection_AsciiString aModeStr (theArgVec[1]);
9797 aModeStr.LowerCase();
9798 Standard_Boolean toEnable = 0;
9799 if (aModeStr == "on")
9803 else if (aModeStr == "off")
9809 toEnable = Draw::Atoi (theArgVec[1]) != 0;
9812 aView->SetFrustumCulling (toEnable);
9817 //=======================================================================
9818 //function : VHighlightSelected
9820 //=======================================================================
9821 static int VHighlightSelected (Draw_Interpretor& theDI,
9822 Standard_Integer theArgNb,
9823 const char** theArgVec)
9825 if (ViewerTest::GetAISContext().IsNull())
9827 std::cout << theArgVec[0] << " error : Context is not created. Please call vinit before.\n";
9831 const Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
9835 theDI << (aContext->ToHilightSelected() ? "on" : "off");
9841 std::cout << theArgVec[0] << " error : wrong number of parameters."
9842 << "Type 'help" << theArgVec[0] << "' for more information.";
9847 TCollection_AsciiString aMode (theArgVec[1]);
9849 Standard_Boolean toEnable = Standard_False;
9850 if (aMode.IsEqual ("on"))
9852 toEnable = Standard_True;
9854 else if (aMode.IsEqual ("off"))
9856 toEnable = Standard_False;
9860 toEnable = Draw::Atoi (theArgVec[1]) != 0;
9863 if (toEnable != aContext->ToHilightSelected())
9865 aContext->SetToHilightSelected (toEnable);
9867 // Move cursor to null position and back to process updating of detection
9868 // and highlighting of selected object immediatly.
9869 Standard_Integer aPixX = 0;
9870 Standard_Integer aPixY = 0;
9871 const Handle(ViewerTest_EventManager)& anEventManager = ViewerTest::CurrentEventManager();
9873 anEventManager->GetCurrentPosition (aPixX, aPixY);
9874 anEventManager->MoveTo (0, 0);
9875 anEventManager->MoveTo (aPixX, aPixY);
9881 //=======================================================================
9882 //function : VXRotate
9884 //=======================================================================
9885 static Standard_Integer VXRotate (Draw_Interpretor& di,
9886 Standard_Integer argc,
9889 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
9890 if (aContext.IsNull())
9892 di << argv[0] << "ERROR : use 'vinit' command before \n";
9898 di << "ERROR : Usage : " << argv[0] << " name angle\n";
9902 TCollection_AsciiString aName (argv[1]);
9903 Standard_Real anAngle = Draw::Atof (argv[2]);
9906 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
9907 Handle(AIS_InteractiveObject) anIObj;
9908 if (!aMap.IsBound2 (aName) )
9910 di << "Use 'vdisplay' before\n";
9915 anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
9918 aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle);
9919 aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart());
9921 aContext->SetLocation (anIObj, aTransform);
9922 aContext->UpdateCurrentViewer();
9928 //===============================================================================================
9929 //class : ViewerTest_AISManipulator
9930 //purpose : Proxy class maintaining automated registry map to enlist existing AIS_Manipulator instances
9931 //===============================================================================================
9932 DEFINE_STANDARD_HANDLE (ViewerTest_AISManipulator, AIS_Manipulator)
9934 class ViewerTest_AISManipulator : public AIS_Manipulator
9938 ViewerTest_AISManipulator() : AIS_Manipulator()
9940 GetMapOfAISManipulators().Add (this);
9943 virtual ~ViewerTest_AISManipulator()
9945 GetMapOfAISManipulators().Remove (this);
9948 DEFINE_STANDARD_RTTIEXT(ViewerTest_AISManipulator, AIS_Manipulator)
9951 IMPLEMENT_STANDARD_HANDLE (ViewerTest_AISManipulator, AIS_Manipulator)
9952 IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_AISManipulator, AIS_Manipulator)
9954 //===============================================================================================
9955 //function : VManipulator
9957 //===============================================================================================
9958 static int VManipulator (Draw_Interpretor& theDi,
9959 Standard_Integer theArgsNb,
9960 const char** theArgVec)
9962 Handle(V3d_View) aView = ViewerTest::CurrentView();
9963 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
9964 ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_False);
9966 || aViewer.IsNull())
9968 std::cerr << "No active viewer!\n";
9972 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
9973 Standard_Integer anArgIter = 1;
9974 for (; anArgIter < theArgsNb; ++anArgIter)
9976 anUpdateTool.parseRedrawMode (theArgVec[anArgIter]);
9979 ViewerTest_CmdParser aCmd;
9980 aCmd.AddDescription ("Manages manipulator for interactive objects:");
9981 aCmd.AddOption ("attach", "... object - attach manipulator to an object");
9982 aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
9983 aCmd.AddOption ("adjustSize", "... {0|1} - adjust size when attaching ");
9984 aCmd.AddOption ("enableModes", "... {0|1} - enable modes when attaching ");
9985 aCmd.AddOption ("detach", "... - detach manipulator");
9987 aCmd.AddOption ("startTransform", "... mouse_x mouse_y - invoke start transformation");
9988 aCmd.AddOption ("transform", "... mouse_x mouse_y - invoke transformation");
9989 aCmd.AddOption ("stopTransform", "... [abort] - invoke stop transformation");
9991 aCmd.AddOption ("move", "... x y z - move object");
9992 aCmd.AddOption ("rotate", "... x y z dx dy dz angle - rotate object");
9993 aCmd.AddOption ("scale", "... factor - scale object");
9995 aCmd.AddOption ("autoActivate", "... {0|1} - set activation on detection");
9996 aCmd.AddOption ("followTranslation", "... {0|1} - set following translation transform");
9997 aCmd.AddOption ("followRotation", "... {0|1} - set following rotation transform");
9998 aCmd.AddOption ("gap", "... value - set gap between sub-parts");
9999 aCmd.AddOption ("part", "... axis mode {0|1} - set visual part");
10000 aCmd.AddOption ("pos", "... x y z [nx ny nz [xx xy xz]] - set position of manipulator");
10001 aCmd.AddOption ("size", "... size - set size of manipulator");
10002 aCmd.AddOption ("zoomable", "... {0|1} - set zoom persistence");
10004 aCmd.Parse (theArgsNb, theArgVec);
10006 if (aCmd.HasOption ("help"))
10008 theDi.PrintHelp (theArgVec[0]);
10012 ViewerTest_DoubleMapOfInteractiveAndName& aMapAIS = GetMapOfAIS();
10014 TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
10016 if (aName.IsEmpty())
10018 std::cerr << theArgVec[0] << " error: please specify AIS manipulator's name as the first argument.\n";
10022 // ----------------------------------
10023 // detach existing manipulator object
10024 // ----------------------------------
10026 if (aCmd.HasOption ("detach"))
10028 if (!aMapAIS.IsBound2 (aName))
10030 std::cerr << theArgVec[0] << " error: could not find \"" << aName << "\" AIS object.\n";
10034 Handle(AIS_Manipulator) aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
10035 if (aManipulator.IsNull())
10037 std::cerr << theArgVec[0] << " error: \"" << aName << "\" is not an AIS manipulator.\n";
10041 aManipulator->Detach();
10042 aMapAIS.UnBind2 (aName);
10043 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_True);
10048 // -----------------------------------------------
10049 // find or create manipulator if it does not exist
10050 // -----------------------------------------------
10052 Handle(AIS_Manipulator) aManipulator;
10053 if (!aMapAIS.IsBound2 (aName))
10055 std::cout << theArgVec[0] << ": AIS object \"" << aName << "\" has been created.\n";
10057 aManipulator = new ViewerTest_AISManipulator();
10058 aMapAIS.Bind (aManipulator, aName);
10062 aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
10063 if (aManipulator.IsNull())
10065 std::cerr << theArgVec[0] << " error: \"" << aName << "\" is not an AIS manipulator.\n";
10070 // -----------------------------------------
10071 // change properties of manipulator instance
10072 // -----------------------------------------
10074 if (aCmd.HasOption ("autoActivate", 1, Standard_True))
10076 aManipulator->SetModeActivationOnDetection (aCmd.ArgBool ("autoActivate"));
10078 if (aCmd.HasOption ("followTranslation", 1, Standard_True))
10080 aManipulator->ChangeTransformBehavior().SetFollowTranslation (aCmd.ArgBool ("followTranslation"));
10082 if (aCmd.HasOption ("followRotation", 1, Standard_True))
10084 aManipulator->ChangeTransformBehavior().SetFollowRotation (aCmd.ArgBool ("followRotation"));
10086 if (aCmd.HasOption ("gap", 1, Standard_True))
10088 aManipulator->SetGap (aCmd.ArgFloat ("gap"));
10090 if (aCmd.HasOption ("part", 3, Standard_True))
10092 Standard_Integer anAxis = aCmd.ArgInt ("part", 0);
10093 Standard_Integer aMode = aCmd.ArgInt ("part", 1);
10094 Standard_Boolean aOnOff = aCmd.ArgBool ("part", 2);
10095 if (aMode < 1 || aMode > 3)
10097 std::cerr << theArgVec[0] << " error: mode value should be in range [1, 3].\n";
10101 aManipulator->SetPart (anAxis, static_cast<AIS_ManipulatorMode> (aMode), aOnOff);
10103 if (aCmd.HasOption ("pos", 3, Standard_True))
10105 gp_Pnt aLocation = aCmd.ArgPnt ("pos", 0);
10106 gp_Dir aVDir = aCmd.HasOption ("pos", 6) ? gp_Dir (aCmd.ArgVec ("pos", 3)) : aManipulator->Position().Direction();
10107 gp_Dir aXDir = aCmd.HasOption ("pos", 9) ? gp_Dir (aCmd.ArgVec ("pos", 6)) : aManipulator->Position().XDirection();
10109 aManipulator->SetPosition (gp_Ax2 (aLocation, aVDir, aXDir));
10111 if (aCmd.HasOption ("size", 1, Standard_True))
10113 aManipulator->SetSize (aCmd.ArgFloat ("size"));
10115 if (aCmd.HasOption ("zoomable", 1, Standard_True))
10117 aManipulator->SetZoomPersistence (!aCmd.ArgBool ("zoomable"));
10119 if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator))
10121 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_False);
10122 ViewerTest::GetAISContext()->Display (aManipulator, Standard_False);
10126 // ---------------------------------------------------
10127 // attach, detach or access manipulator from an object
10128 // ---------------------------------------------------
10130 if (aCmd.HasOption ("attach"))
10132 // Find an object and attach manipulator to it
10133 if (!aCmd.HasOption ("attach", 1, Standard_True))
10138 TCollection_AsciiString anObjName (aCmd.Arg ("attach", 0).c_str());
10139 if (!aMapAIS.IsBound2 (anObjName))
10141 std::cerr << theArgVec[0] << " error: AIS object \"" << anObjName << "\" does not exist.\n";
10145 Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (aMapAIS.Find2 (anObjName));
10146 ViewerTest_MapOfAISManipulators::Iterator anIt (GetMapOfAISManipulators());
10147 for (; anIt.More(); anIt.Next())
10149 if (anIt.Value()->IsAttached()
10150 && anIt.Value()->Object() == anObject)
10152 std::cerr << theArgVec[0] << " error: AIS object \"" << anObjName << "\" already has manipulator.\n";
10157 AIS_Manipulator::OptionsForAttach anOptions;
10158 if (aCmd.HasOption ("adjustPosition", 1, Standard_True))
10160 anOptions.SetAdjustPosition (aCmd.ArgBool ("adjustPosition"));
10162 if (aCmd.HasOption ("adjustSize", 1, Standard_True))
10164 anOptions.SetAdjustSize (aCmd.ArgBool ("adjustSize"));
10166 if (aCmd.HasOption ("enableModes", 1, Standard_True))
10168 anOptions.SetEnableModes (aCmd.ArgBool ("enableModes"));
10171 aManipulator->Attach (anObject, anOptions);
10174 // --------------------------------------
10175 // apply transformation using manipulator
10176 // --------------------------------------
10178 if (aCmd.HasOption ("startTransform", 2, Standard_True))
10180 aManipulator->StartTransform (aCmd.ArgInt ("startTransform", 0), aCmd.ArgInt ("startTransform", 1), ViewerTest::CurrentView());
10182 if (aCmd.HasOption ("transform", 2, Standard_True))
10184 aManipulator->Transform (aCmd.ArgInt ("transform", 0), aCmd.ArgInt ("transform", 1), ViewerTest::CurrentView());
10186 if (aCmd.HasOption ("stopTransform"))
10188 Standard_Boolean toApply = !aCmd.HasOption ("stopTransform", 1) || (aCmd.Arg ("stopTransform", 0) != "abort");
10190 aManipulator->StopTransform (toApply);
10194 if (aCmd.HasOption ("move", 3, Standard_True))
10196 aT.SetTranslationPart (aCmd.ArgVec ("move"));
10198 if (aCmd.HasOption ("rotate", 7, Standard_True))
10200 aT.SetRotation (gp_Ax1 (aCmd.ArgPnt ("rotate", 0), aCmd.ArgVec ("rotate", 3)), aCmd.ArgDouble ("rotate", 6));
10202 if (aCmd.HasOption ("scale", 1))
10204 aT.SetScale (gp_Pnt(), aCmd.ArgDouble("scale"));
10207 if (aT.Form() != gp_Identity)
10209 aManipulator->Transform (aT);
10212 ViewerTest::GetAISContext()->Redisplay (aManipulator, Standard_True);
10217 //===============================================================================================
10218 //function : VSelectionProperties
10220 //===============================================================================================
10221 static int VSelectionProperties (Draw_Interpretor& theDi,
10222 Standard_Integer theArgsNb,
10223 const char** theArgVec)
10225 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
10228 std::cerr << "No active viewer!\n";
10232 Standard_Boolean toPrint = theArgsNb == 1;
10233 Standard_Boolean toRedraw = Standard_False;
10234 Standard_Integer anArgIter = 1;
10235 Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None;
10236 if (anArgIter < theArgsNb)
10238 TCollection_AsciiString anArgFirst (theArgVec[anArgIter]);
10239 anArgFirst.LowerCase();
10241 if (anArgFirst == "dynhighlight"
10242 || anArgFirst == "dynhilight"
10243 || anArgFirst == "dynamichighlight"
10244 || anArgFirst == "dynamichilight")
10246 aType = Prs3d_TypeOfHighlight_Dynamic;
10248 else if (anArgFirst == "localdynhighlight"
10249 || anArgFirst == "localdynhilight"
10250 || anArgFirst == "localdynamichighlight"
10251 || anArgFirst == "localdynamichilight")
10253 aType = Prs3d_TypeOfHighlight_LocalDynamic;
10255 else if (anArgFirst == "selhighlight"
10256 || anArgFirst == "selhilight"
10257 || anArgFirst == "selectedhighlight"
10258 || anArgFirst == "selectedhilight")
10260 aType = Prs3d_TypeOfHighlight_Selected;
10262 else if (anArgFirst == "localselhighlight"
10263 || anArgFirst == "localselhilight"
10264 || anArgFirst == "localselectedhighlight"
10265 || anArgFirst == "localselectedhilight")
10267 aType = Prs3d_TypeOfHighlight_LocalSelected;
10274 for (; anArgIter < theArgsNb; ++anArgIter)
10276 TCollection_AsciiString anArg (theArgVec[anArgIter]);
10278 if (anArg == "-help")
10280 theDi.PrintHelp (theArgVec[0]);
10283 else if (anArg == "-print")
10285 toPrint = Standard_True;
10287 else if (anArg == "-autoactivate")
10289 Standard_Boolean toEnable = Standard_True;
10290 if (anArgIter + 1 < theArgsNb
10291 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
10295 aCtx->SetAutoActivateSelection (toEnable);
10297 else if (anArg == "-pickstrategy"
10298 || anArg == "-pickingstrategy")
10300 if (++anArgIter >= theArgsNb)
10302 std::cout << "Syntax error: type of highlighting is undefined\n";
10306 SelectMgr_PickingStrategy aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
10307 TCollection_AsciiString aVal (theArgVec[anArgIter]);
10309 if (aVal == "first"
10310 || aVal == "firstaccepted"
10311 || aVal == "firstacceptable")
10313 aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
10315 else if (aVal == "topmost"
10316 || aVal == "onlyTopmost")
10318 aStrategy = SelectMgr_PickingStrategy_OnlyTopmost;
10322 std::cout << "Syntax error: unknwon picking strategy '" << aVal << "'\n";
10326 aCtx->SetPickingStrategy (aStrategy);
10328 else if (anArg == "-pixtol"
10329 && anArgIter + 1 < theArgsNb)
10331 aCtx->SetPixelTolerance (Draw::Atoi (theArgVec[++anArgIter]));
10333 else if ((anArg == "-mode"
10334 || anArg == "-dispmode")
10335 && anArgIter + 1 < theArgsNb)
10337 if (aType == Prs3d_TypeOfHighlight_None)
10339 std::cout << "Syntax error: type of highlighting is undefined\n";
10343 const Standard_Integer aDispMode = Draw::Atoi (theArgVec[++anArgIter]);
10344 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10345 aStyle->SetDisplayMode (aDispMode);
10346 toRedraw = Standard_True;
10348 else if (anArg == "-layer"
10349 && anArgIter + 1 < theArgsNb)
10351 if (aType == Prs3d_TypeOfHighlight_None)
10353 std::cout << "Syntax error: type of highlighting is undefined\n";
10357 const Standard_Integer aNewLayer = Draw::Atoi (theArgVec[++anArgIter]);
10358 if (aNewLayer != Graphic3d_ZLayerId_UNKNOWN)
10360 TColStd_SequenceOfInteger aLayers;
10361 aCtx->CurrentViewer()->GetAllZLayers (aLayers);
10362 if (std::find (aLayers.begin(), aLayers.end(), aNewLayer) == aLayers.end())
10364 std::cout << "Syntax error: Layer " << aNewLayer << " is undefined\n";
10369 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10370 aStyle->SetZLayer (aNewLayer);
10371 toRedraw = Standard_True;
10373 else if (anArg == "-hicolor"
10374 || anArg == "-selcolor"
10375 || anArg == "-color")
10377 if (anArg.StartsWith ("-hi"))
10379 aType = Prs3d_TypeOfHighlight_Dynamic;
10381 else if (anArg.StartsWith ("-sel"))
10383 aType = Prs3d_TypeOfHighlight_Selected;
10385 else if (aType == Prs3d_TypeOfHighlight_None)
10387 std::cout << "Syntax error: type of highlighting is undefined\n";
10391 Quantity_Color aColor;
10392 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIter - 1,
10393 theArgVec + anArgIter + 1,
10395 if (aNbParsed == 0)
10397 std::cout << "Syntax error: need more arguments.\n";
10400 anArgIter += aNbParsed;
10402 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10403 aStyle->SetColor (aColor);
10404 toRedraw = Standard_True;
10406 else if ((anArg == "-transp"
10407 || anArg == "-transparency"
10408 || anArg == "-hitransp"
10409 || anArg == "-seltransp"
10410 || anArg == "-hitransplocal"
10411 || anArg == "-seltransplocal")
10412 && anArgIter + 1 < theArgsNb)
10414 if (anArg.StartsWith ("-hi"))
10416 aType = Prs3d_TypeOfHighlight_Dynamic;
10418 else if (anArg.StartsWith ("-sel"))
10420 aType = Prs3d_TypeOfHighlight_Selected;
10422 else if (aType == Prs3d_TypeOfHighlight_None)
10424 std::cout << "Syntax error: type of highlighting is undefined\n";
10428 const Standard_Real aTransp = Draw::Atof (theArgVec[++anArgIter]);
10429 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10430 aStyle->SetTransparency ((Standard_ShortReal )aTransp);
10431 toRedraw = Standard_True;
10433 else if ((anArg == "-mat"
10434 || anArg == "-material")
10435 && anArgIter + 1 < theArgsNb)
10437 if (aType == Prs3d_TypeOfHighlight_None)
10439 std::cout << "Syntax error: type of highlighting is undefined\n";
10443 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
10444 Graphic3d_NameOfMaterial aMatName = Graphic3d_MaterialAspect::MaterialFromName (theArgVec[anArgIter + 1]);
10445 if (aMatName != Graphic3d_NOM_DEFAULT)
10448 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
10449 *anAspect = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
10450 Graphic3d_MaterialAspect aMat (aMatName);
10451 aMat.SetColor (aStyle->Color());
10452 aMat.SetTransparency (aStyle->Transparency());
10453 anAspect->SetFrontMaterial (aMat);
10454 anAspect->SetInteriorColor (aStyle->Color());
10455 aStyle->SetBasicFillAreaAspect (anAspect);
10459 aStyle->SetBasicFillAreaAspect (Handle(Graphic3d_AspectFillArea3d)());
10461 toRedraw = Standard_True;
10465 std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
10471 const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle();
10472 const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle();
10473 theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n";
10474 theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n";
10475 theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n";
10476 theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n";
10477 theDi << "Selection transparency : " << aSelStyle->Transparency() << "\n";
10478 theDi << "Dynamic highlight transparency : " << aHiStyle->Transparency() << "\n";
10479 theDi << "Selection mode : " << aSelStyle->DisplayMode() << "\n";
10480 theDi << "Dynamic highlight mode : " << aHiStyle->DisplayMode() << "\n";
10481 theDi << "Selection layer : " << aSelStyle->ZLayer() << "\n";
10482 theDi << "Dynamic layer : " << aHiStyle->ZLayer() << "\n";
10485 if (aCtx->NbSelected() != 0 && toRedraw)
10487 aCtx->HilightSelected (Standard_True);
10493 //===============================================================================================
10494 //function : VDumpSelectionImage
10496 //===============================================================================================
10497 static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
10498 Standard_Integer theArgsNb,
10499 const char** theArgVec)
10503 std::cout << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'\n";
10507 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
10508 if (aContext.IsNull())
10510 std::cout << "Error: no active view.\n";
10514 TCollection_AsciiString aFile;
10515 StdSelect_TypeOfSelectionImage aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
10516 Image_Format anImgFormat = Image_Format_BGR;
10517 Standard_Integer aPickedIndex = 1;
10518 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
10520 TCollection_AsciiString aParam (theArgVec[anArgIter]);
10521 aParam.LowerCase();
10522 if (aParam == "-type")
10524 if (++anArgIter >= theArgsNb)
10526 std::cout << "Syntax error: wrong number parameters of flag '-depth'.\n";
10530 TCollection_AsciiString aValue (theArgVec[anArgIter]);
10531 aValue.LowerCase();
10532 if (aValue == "depth"
10533 || aValue == "normdepth"
10534 || aValue == "normalizeddepth")
10536 aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
10537 anImgFormat = Image_Format_GrayF;
10539 if (aValue == "depthinverted"
10540 || aValue == "normdepthinverted"
10541 || aValue == "normalizeddepthinverted"
10542 || aValue == "inverted")
10544 aType = StdSelect_TypeOfSelectionImage_NormalizedDepthInverted;
10545 anImgFormat = Image_Format_GrayF;
10547 else if (aValue == "unnormdepth"
10548 || aValue == "unnormalizeddepth")
10550 aType = StdSelect_TypeOfSelectionImage_UnnormalizedDepth;
10551 anImgFormat = Image_Format_GrayF;
10553 else if (aValue == "objectcolor"
10554 || aValue == "object"
10555 || aValue == "color")
10557 aType = StdSelect_TypeOfSelectionImage_ColoredDetectedObject;
10559 else if (aValue == "entitycolor"
10560 || aValue == "entity")
10562 aType = StdSelect_TypeOfSelectionImage_ColoredEntity;
10564 else if (aValue == "ownercolor"
10565 || aValue == "owner")
10567 aType = StdSelect_TypeOfSelectionImage_ColoredOwner;
10569 else if (aValue == "selectionmodecolor"
10570 || aValue == "selectionmode"
10571 || aValue == "selmodecolor"
10572 || aValue == "selmode")
10574 aType = StdSelect_TypeOfSelectionImage_ColoredSelectionMode;
10577 else if (aParam == "-picked"
10578 || aParam == "-pickeddepth"
10579 || aParam == "-pickedindex")
10581 if (++anArgIter >= theArgsNb)
10583 std::cout << "Syntax error: wrong number parameters at '" << aParam << "'.\n";
10587 aPickedIndex = Draw::Atoi (theArgVec[anArgIter]);
10589 else if (aFile.IsEmpty())
10591 aFile = theArgVec[anArgIter];
10595 std::cout << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'.\n";
10599 if (aFile.IsEmpty())
10601 std::cout << "Syntax error: image file name is missing.\n";
10605 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
10606 Standard_Integer aWidth = 0, aHeight = 0;
10607 aView->Window()->Size (aWidth, aHeight);
10609 Image_AlienPixMap aPixMap;
10610 if (!aPixMap.InitZero (anImgFormat, aWidth, aHeight))
10612 std::cout << "Error: can't allocate image.\n";
10615 if (!aContext->MainSelector()->ToPixMap (aPixMap, aView, aType, aPickedIndex))
10617 std::cout << "Error: can't generate selection image.\n";
10620 if (!aPixMap.Save (aFile))
10622 std::cout << "Error: can't save selection image.\n";
10628 //=======================================================================
10629 //function : ViewerCommands
10631 //=======================================================================
10633 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
10636 const char *group = "ZeViewer";
10637 theCommands.Add("vinit",
10638 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
10639 "[name=view_name] [display=display_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n"
10641 "[name=view_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n"
10643 " - Creates new View window with specified name view_name.\n"
10644 "By default the new view is created in the viewer and in"
10645 " graphic driver shared with active view.\n"
10646 " - name = {driverName/viewerName/viewName | viewerName/viewName | viewName}.\n"
10647 "If driverName isn't specified the driver will be shared with active view.\n"
10648 "If viewerName isn't specified the viewer will be shared with active view.\n"
10649 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
10650 " - display = HostName.DisplayNumber[:ScreenNumber] : if specified"
10651 "is used in creation of graphic driver\n"
10653 " - l, t: pixel position of left top corner of the window\n"
10654 " - w,h: width and heigth of window respectively.\n"
10655 "Additional commands for operations with views: vclose, vactivate, vviewlist.\n",
10656 __FILE__,VInit,group);
10657 theCommands.Add("vclose" ,
10658 "[view_id [keep_context=0|1]]\n"
10659 "or vclose ALL - to remove all created views\n"
10660 " - removes view(viewer window) defined by its view_id.\n"
10661 " - keep_context: by default 0; if 1 and the last view is deleted"
10662 " the current context is not removed.",
10663 __FILE__,VClose,group);
10664 theCommands.Add("vactivate" ,
10666 " - activates view(viewer window) defined by its view_id",
10667 __FILE__,VActivate,group);
10668 theCommands.Add("vviewlist",
10669 "vviewlist [format={tree, long}]"
10670 " - prints current list of views per viewer and graphic_driver ID shared between viewers"
10671 " - format: format of result output, if tree the output is a tree view;"
10672 "otherwise it's a list of full view names. By default format = tree",
10673 __FILE__,VViewList,group);
10674 theCommands.Add("vhelp" ,
10675 "vhelp : display help on the viewer commands",
10676 __FILE__,VHelp,group);
10677 theCommands.Add("vtop" ,
10678 "vtop or <T> : Top view. Orientation +X+Y" ,
10679 __FILE__,VTop,group);
10680 theCommands.Add("vbottom" ,
10681 "vbottom : Bottom view. Orientation +X-Y" ,
10682 __FILE__,VBottom,group);
10683 theCommands.Add("vleft" ,
10684 "vleft : Left view. Orientation -Y+Z" ,
10685 __FILE__,VLeft,group);
10686 theCommands.Add("vright" ,
10687 "vright : Right view. Orientation +Y+Z" ,
10688 __FILE__,VRight,group);
10689 theCommands.Add("vaxo" ,
10690 " vaxo or <A> : Axonometric view. Orientation +X-Y+Z",
10691 __FILE__,VAxo,group);
10692 theCommands.Add("vfront" ,
10693 "vfront : Front view. Orientation +X+Z" ,
10694 __FILE__,VFront,group);
10695 theCommands.Add("vback" ,
10696 "vback : Back view. Orientation -X+Z" ,
10697 __FILE__,VBack,group);
10698 theCommands.Add("vpick" ,
10699 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
10701 theCommands.Add("vfit",
10702 "vfit or <F> [-selected] [-noupdate]"
10703 "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects",
10704 __FILE__,VFit,group);
10705 theCommands.Add ("vfitarea",
10706 "vfitarea x1 y1 x2 y2"
10707 "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2"
10708 "\n\t\t: Fit view to show area located between two points"
10709 "\n\t\t: given in world 2D or 3D corrdinates.",
10710 __FILE__, VFitArea, group);
10711 theCommands.Add ("vzfit", "vzfit [scale]\n"
10712 " Matches Z near, Z far view volume planes to the displayed objects.\n"
10713 " \"scale\" - specifies factor to scale computed z range.\n",
10714 __FILE__, VZFit, group);
10715 theCommands.Add("vrepaint",
10716 "vrepaint [-immediate]"
10717 "\n\t\t: force redraw",
10718 __FILE__,VRepaint,group);
10719 theCommands.Add("vclear",
10721 "\n\t\t: remove all the object from the viewer",
10722 __FILE__,VClear,group);
10723 theCommands.Add("vsetbg",
10724 "vsetbg : vsetbg imagefile [filltype] : Load image as background",
10725 __FILE__,VSetBg,group);
10726 theCommands.Add("vsetbgmode",
10727 "vsetbgmode : vsetbgmode filltype : Change background image fill type",
10728 __FILE__,VSetBgMode,group);
10729 theCommands.Add("vsetgradientbg",
10730 "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background",
10731 __FILE__,VSetGradientBg,group);
10732 theCommands.Add("vsetgrbgmode",
10733 "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type",
10734 __FILE__,VSetGradientBgMode,group);
10735 theCommands.Add("vsetcolorbg",
10736 "vsetcolorbg : vsetcolorbg r g b : Set background color",
10737 __FILE__,VSetColorBg,group);
10738 theCommands.Add("vsetdefaultbg",
10739 "vsetdefaultbg r g b\n"
10740 "\n\t\t: vsetdefaultbg r1 g1 b1 r2 g2 b2 fillmode"
10741 "\n\t\t: Set default viewer background fill color (flat/gradient).",
10742 __FILE__,VSetDefaultBg,group);
10743 theCommands.Add("vscale",
10744 "vscale : vscale X Y Z",
10745 __FILE__,VScale,group);
10746 theCommands.Add("vzbufftrihedron",
10747 "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]"
10748 "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]"
10749 "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]"
10750 "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]"
10751 "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]"
10752 "\n\t\t: Displays a trihedron",
10753 __FILE__,VZBuffTrihedron,group);
10754 theCommands.Add("vrotate",
10755 "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]"
10756 "\n : Option -mouseStart starts rotation according to the mouse position"
10757 "\n : Option -mouseMove continues rotation with angle computed"
10758 "\n : from last and new mouse position."
10759 "\n : vrotate AX AY AZ [X Y Z]",
10760 __FILE__,VRotate,group);
10761 theCommands.Add("vzoom",
10762 "vzoom : vzoom coef",
10763 __FILE__,VZoom,group);
10764 theCommands.Add("vpan",
10765 "vpan : vpan dx dy",
10766 __FILE__,VPan,group);
10767 theCommands.Add("vexport",
10768 "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }"
10769 " : exports the view to a vector file of a given format"
10770 " : notice that EMF format requires patched gl2ps",
10771 __FILE__,VExport,group);
10772 theCommands.Add("vcolorscale",
10773 "vcolorscale name [-noupdate|-update] [-demo]"
10774 "\n\t\t: [-range RangeMin=0 RangeMax=1 NbIntervals=10]"
10775 "\n\t\t: [-font HeightFont=20]"
10776 "\n\t\t: [-logarithmic {on|off}=off] [-reversed {on|off}=off]"
10777 "\n\t\t: [-smoothTransition {on|off}=off]"
10778 "\n\t\t: [-hueRange MinAngle=230 MaxAngle=0]"
10779 "\n\t\t: [-colorRange MinColor=BLUE1 MaxColor=RED]"
10780 "\n\t\t: [-textpos {left|right|center|none}=right]"
10781 "\n\t\t: [-labelAtBorder {on|off}=on]"
10782 "\n\t\t: [-colors Color1 Color2 ...] [-color Index Color]"
10783 "\n\t\t: [-labels Label1 Label2 ...] [-label Index Label]"
10784 "\n\t\t: [-freeLabels NbOfLabels Label1 Label2 ...]"
10785 "\n\t\t: [-xy Left=0 Bottom=0]"
10786 "\n\t\t: -demo - displays a color scale with demonstratio values"
10787 "\n\t\t: -colors - set colors for all intervals"
10788 "\n\t\t: -color - set color for specific interval"
10789 "\n\t\t: -textpos - horizontal label position relative to color scale bar"
10790 "\n\t\t: -labelAtBorder - vertical label position relative to color interval;"
10791 "\n\t\t: at border means the value inbetween neighbor intervals,"
10792 "\n\t\t: at center means the center value within current interval"
10793 "\n\t\t: -labels - set labels for all intervals"
10794 "\n\t\t: -freeLabels - same as -labels but does not require"
10795 "\n\t\t: matching the number of intervals"
10796 "\n\t\t: -label - set label for specific interval"
10797 "\n\t\t: -title - set title"
10798 "\n\t\t: -reversed - setup smooth color transition between intervals"
10799 "\n\t\t: -smoothTransition - swap colorscale direction"
10800 "\n\t\t: -hueRange - set hue angles corresponding to minimum and maximum values"
10801 __FILE__, VColorScale, group);
10802 theCommands.Add("vgraduatedtrihedron",
10803 "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n"
10804 "\t[-namefont Name] [-valuesfont Name]\n"
10805 "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n"
10806 "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]"
10807 "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n"
10808 "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n"
10809 "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]"
10810 "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n"
10811 "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n"
10812 "\t[-xticks Number] [-yticks Number] [-zticks Number]\n"
10813 "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n"
10814 "\t[-drawgrid on/off] [-drawaxes on/off]\n"
10815 " - Displays or erases graduated trihedron"
10816 " - xname, yname, zname - names of axes, default: X, Y, Z\n"
10817 " - namefont - font of axes names. Default: Arial\n"
10818 " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n"
10819 " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n"
10820 " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n"
10821 " - valuesfont - font of axes values. Default: Arial\n"
10822 " - xcolor, ycolor, zcolor - color of axis and values\n"
10823 " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n"
10824 " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n",
10825 __FILE__,VGraduatedTrihedron,group);
10826 theCommands.Add("vtile" ,
10827 "vtile [-totalSize W H] [-lowerLeft X Y] [-upperLeft X Y] [-tileSize W H]"
10828 "\n\t\t: Setup view to draw a tile (a part of virtual bigger viewport)."
10829 "\n\t\t: -totalSize the size of virtual bigger viewport"
10830 "\n\t\t: -tileSize tile size (the view size will be used if omitted)"
10831 "\n\t\t: -lowerLeft tile offset as lower left corner"
10832 "\n\t\t: -upperLeft tile offset as upper left corner",
10833 __FILE__, VTile, group);
10834 theCommands.Add("vzlayer",
10835 "vzlayer [layerId]"
10836 "\n\t\t: [-add|-delete|-get|-settings]"
10837 "\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
10838 "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv}]"
10839 "\n\t\t: ZLayer list management:"
10840 "\n\t\t: -add add new z layer to viewer and print its id"
10841 "\n\t\t: -delete delete z layer"
10842 "\n\t\t: -get print sequence of z layers"
10843 "\n\t\t: -settings print status of z layer settings"
10844 "\n\t\t: -disable disables given setting"
10845 "\n\t\t: -enable enables given setting",
10846 __FILE__,VZLayer,group);
10847 theCommands.Add("vlayerline",
10848 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
10849 __FILE__,VLayerLine,group);
10850 theCommands.Add ("vgrid",
10851 "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]"
10852 " : Mode - rectangular or circular"
10853 " : Type - lines or points",
10854 __FILE__, VGrid, group);
10855 theCommands.Add ("vpriviledgedplane",
10856 "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]"
10857 "\n\t\t: Ox, Oy, Oz - plane origin"
10858 "\n\t\t: Nx, Ny, Nz - plane normal direction"
10859 "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction"
10860 "\n\t\t: Sets or prints viewer's priviledged plane geometry.",
10861 __FILE__, VPriviledgedPlane, group);
10862 theCommands.Add ("vconvert",
10863 "vconvert v [Mode={window|view}]"
10864 "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]"
10865 "\n\t\t: vconvert x y z [Mode={window|grid}]"
10866 "\n\t\t: window - convert to window coordinates, pixels"
10867 "\n\t\t: view - convert to view projection plane"
10868 "\n\t\t: grid - convert to model coordinates, given on grid"
10869 "\n\t\t: ray - convert projection ray to model coordiantes"
10870 "\n\t\t: - vconvert v window : convert view to window;"
10871 "\n\t\t: - vconvert v view : convert window to view;"
10872 "\n\t\t: - vconvert x y window : convert view to window;"
10873 "\n\t\t: - vconvert x y view : convert window to view;"
10874 "\n\t\t: - vconvert x y : convert window to model;"
10875 "\n\t\t: - vconvert x y grid : convert window to model using grid;"
10876 "\n\t\t: - vconvert x y ray : convert window projection line to model;"
10877 "\n\t\t: - vconvert x y z window : convert model to window;"
10878 "\n\t\t: - vconvert x y z grid : convert view to model using grid;"
10879 "\n\t\t: Converts the given coordinates to window/view/model space.",
10880 __FILE__, VConvert, group);
10881 theCommands.Add ("vfps",
10882 "vfps [framesNb=100] : estimate average frame rate for active view",
10883 __FILE__, VFps, group);
10884 theCommands.Add ("vgldebug",
10885 "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
10886 "\n\t\t: [-extraMsg {0|1}] [{0|1}]"
10887 "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
10888 "\n\t\t: Debug context can be requested only on Windows"
10889 "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
10890 "\n\t\t: -sync - request synchronized debug GL context"
10891 "\n\t\t: -glslWarn - log GLSL compiler/linker warnings,"
10892 "\n\t\t: which are suppressed by default,"
10893 "\n\t\t: -extraMsg - log extra diagnostic messages from GL context,"
10894 "\n\t\t: which are suppressed by default",
10895 __FILE__, VGlDebug, group);
10896 theCommands.Add ("vvbo",
10897 "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
10898 __FILE__, VVbo, group);
10899 theCommands.Add ("vstereo",
10900 "vstereo [0|1] [-mode Mode] [-reverse {0|1}]"
10901 "\n\t\t: [-anaglyph Filter]"
10902 "\n\t\t: Control stereo output mode. Available modes for -mode:"
10903 "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo,"
10904 "\n\t\t: requires driver support."
10905 "\n\t\t: Should be called BEFORE vinit!"
10906 "\n\t\t: anaglyph - Anaglyph glasses"
10907 "\n\t\t: rowInterlaced - row-interlaced display"
10908 "\n\t\t: columnInterlaced - column-interlaced display"
10909 "\n\t\t: chessBoard - chess-board output"
10910 "\n\t\t: sideBySide - horizontal pair"
10911 "\n\t\t: overUnder - vertical pair"
10912 "\n\t\t: Available Anaglyph filters for -anaglyph:"
10913 "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple,"
10914 "\n\t\t: greenMagentaSimple",
10915 __FILE__, VStereo, group);
10916 theCommands.Add ("vcaps",
10917 "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
10918 "\n\t\t: [-compatibleProfile {0|1}]"
10919 "\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
10920 "\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
10921 "\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
10922 "\n\t\t: Modify particular graphic driver options:"
10923 "\n\t\t: FFP - use fixed-function pipeline instead of"
10924 "\n\t\t: built-in GLSL programs"
10925 "\n\t\t: (requires compatible profile)"
10926 "\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
10927 "\n\t\t: arrays to GPU memory)"
10928 "\n\t\t: sprite - use textured sprites instead of bitmaps"
10929 "\n\t\t: vsync - switch VSync on or off"
10930 "\n\t\t: winBuffer - allow using window buffer for rendering"
10931 "\n\t\t: Context creation options:"
10932 "\n\t\t: softMode - software OpenGL implementation"
10933 "\n\t\t: compatibleProfile - backward-compatible profile"
10934 "\n\t\t: quadbuffer - QuadBuffer"
10935 "\n\t\t: Unlike vrenderparams, these parameters control alternative"
10936 "\n\t\t: rendering paths producing the same visual result when"
10937 "\n\t\t: possible."
10938 "\n\t\t: Command is intended for testing old hardware compatibility.",
10939 __FILE__, VCaps, group);
10940 theCommands.Add ("vmemgpu",
10941 "vmemgpu [f]: print system-dependent GPU memory information if available;"
10942 " with f option returns free memory in bytes",
10943 __FILE__, VMemGpu, group);
10944 theCommands.Add ("vreadpixel",
10945 "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]"
10946 " : Read pixel value for active view",
10947 __FILE__, VReadPixel, group);
10948 theCommands.Add("diffimage",
10949 "diffimage : diffimage imageFile1 imageFile2 toleranceOfColor(0..1) blackWhite(1|0) borderFilter(1|0) [diffImageFile]",
10950 __FILE__, VDiffImage, group);
10951 theCommands.Add ("vselect",
10952 "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
10953 "- emulates different types of selection:\n"
10954 "- 1) single click selection\n"
10955 "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
10956 "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
10957 "- 4) -allowoverlap manages overlap and inclusion detection in rectangular selection.\n"
10958 " If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined rectangle will be detected,\n"
10959 " otherwise algorithm will chose only fully included sensitives. Default behavior is to detect only full inclusion. "
10960 " (partial inclusion - overlap - is not allowed by default)\n"
10961 "- 5) any of these selections with shift button pressed",
10962 __FILE__, VSelect, group);
10963 theCommands.Add ("vmoveto",
10965 "- emulates cursor movement to pixel postion (x,y)",
10966 __FILE__, VMoveTo, group);
10967 theCommands.Add ("vviewparams",
10968 "vviewparams [-args] [-scale [s]]"
10969 "\n\t\t: [-eye [x y z]] [-at [x y z]] [-up [x y z]]"
10970 "\n\t\t: [-proj [x y z]] [-center x y] [-size sx]"
10971 "\n\t\t: Manage current view parameters or prints all"
10972 "\n\t\t: current values when called without argument."
10973 "\n\t\t: -scale [s] prints or sets viewport relative scale"
10974 "\n\t\t: -eye [x y z] prints or sets eye location"
10975 "\n\t\t: -at [x y z] prints or sets center of look"
10976 "\n\t\t: -up [x y z] prints or sets direction of up vector"
10977 "\n\t\t: -proj [x y z] prints or sets direction of look"
10978 "\n\t\t: -center x y sets location of center of the screen in pixels"
10979 "\n\t\t: -size [sx] prints viewport projection width and height sizes"
10980 "\n\t\t: or changes the size of its maximum dimension"
10981 "\n\t\t: -args prints vviewparams arguments for restoring current view",
10982 __FILE__, VViewParams, group);
10984 theCommands.Add("vanimation", "Alias for vanim",
10985 __FILE__, VAnimation, group);
10987 theCommands.Add("vanim",
10988 "List existing animations:"
10990 "\n\t\t: Animation playback:"
10991 "\n\t\t: vanim name -play|-resume [playFrom [playDuration]]"
10992 "\n\t\t: [-speed Coeff] [-freeLook] [-lockLoop]"
10993 "\n\t\t: -speed playback speed (1.0 is normal speed)"
10994 "\n\t\t: -freeLook skip camera animations"
10995 "\n\t\t: -lockLoop disable any interactions"
10997 "\n\t\t: Animation definition:"
10998 "\n\t\t: vanim Name/sub/name [-clear] [-delete]"
10999 "\n\t\t: [start TimeSec] [duration TimeSec]"
11001 "\n\t\t: Animation name defined in path-style (anim/name or anim.name)"
11002 "\n\t\t: specifies nested animations."
11003 "\n\t\t: There is no syntax to explicitly add new animation,"
11004 "\n\t\t: and all non-existing animations within the name will be"
11005 "\n\t\t: implicitly created on first use (including parents)."
11007 "\n\t\t: Each animation might define the SINGLE action (see below),"
11008 "\n\t\t: like camera transition, object transformation or custom callback."
11009 "\n\t\t: Child animations can be used for defining concurrent actions."
11011 "\n\t\t: Camera animation:"
11012 "\n\t\t: vanim name -view [-eye1 X Y Z] [-eye2 X Y Z]"
11013 "\n\t\t: [-at1 X Y Z] [-at2 X Y Z]"
11014 "\n\t\t: [-up1 X Y Z] [-up2 X Y Z]"
11015 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
11016 "\n\t\t: -eyeX camera Eye positions pair (start and end)"
11017 "\n\t\t: -atX camera Center positions pair"
11018 "\n\t\t: -upX camera Up directions pair"
11019 "\n\t\t: -scaleX camera Scale factors pair"
11020 "\n\t\t: Object animation:"
11021 "\n\t\t: vanim name -object [-loc1 X Y Z] [-loc2 X Y Z]"
11022 "\n\t\t: [-rot1 QX QY QZ QW] [-rot2 QX QY QZ QW]"
11023 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
11024 "\n\t\t: -locX object Location points pair (translation)"
11025 "\n\t\t: -rotX object Orientations pair (quaternions)"
11026 "\n\t\t: -scaleX object Scale factors pair (quaternions)"
11027 "\n\t\t: Custom callback:"
11028 "\n\t\t: vanim name -invoke \"Command Arg1 Arg2 %Pts %LocalPts %Normalized ArgN\""
11029 "\n\t\t: %Pts overall animation presentation timestamp"
11030 "\n\t\t: %LocalPts local animation timestamp"
11031 "\n\t\t: %Normalized local animation normalized value in range 0..1"
11032 __FILE__, VAnimation, group);
11034 theCommands.Add("vchangeselected",
11035 "vchangeselected shape"
11036 "- adds to shape to selection or remove one from it",
11037 __FILE__, VChangeSelected, group);
11038 theCommands.Add ("vnbselected",
11040 "\n\t\t: Returns number of selected objects", __FILE__, VNbSelected, group);
11041 theCommands.Add ("vcamera",
11042 "vcamera [-ortho] [-projtype]"
11044 "\n\t\t: [-fovy [Angle]] [-distance [Distance]]"
11045 "\n\t\t: [-stereo] [-leftEye] [-rightEye]"
11046 "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]"
11047 "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]"
11048 "\n\t\t: Manage camera parameters."
11049 "\n\t\t: Prints current value when option called without argument."
11050 "\n\t\t: Orthographic camera:"
11051 "\n\t\t: -ortho activate orthographic projection"
11052 "\n\t\t: Perspective camera:"
11053 "\n\t\t: -persp activate perspective projection (mono)"
11054 "\n\t\t: -fovy field of view in y axis, in degrees"
11055 "\n\t\t: -distance distance of eye from camera center"
11056 "\n\t\t: Stereoscopic camera:"
11057 "\n\t\t: -stereo perspective projection (stereo)"
11058 "\n\t\t: -leftEye perspective projection (left eye)"
11059 "\n\t\t: -rightEye perspective projection (right eye)"
11060 "\n\t\t: -iod intraocular distance value"
11061 "\n\t\t: -iodType distance type, absolute or relative"
11062 "\n\t\t: -zfocus stereographic focus value"
11063 "\n\t\t: -zfocusType focus type, absolute or relative",
11064 __FILE__, VCamera, group);
11065 theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n"
11066 "- vautozfit [on={1|0}] [scale]\n"
11067 " Prints or changes parameters of automatic z-fit mode:\n"
11068 " \"on\" - turns automatic z-fit on or off\n"
11069 " \"scale\" - specifies factor to scale computed z range.\n",
11070 __FILE__, VAutoZFit, group);
11071 theCommands.Add ("vzrange", "command to manually access znear and zfar values\n"
11072 " vzrange - without parameters shows current values\n"
11073 " vzrange [znear] [zfar] - applies provided values to view",
11074 __FILE__,VZRange, group);
11075 theCommands.Add ("vpurgedisplay",
11077 "- removes structures which don't belong to objects displayed in neutral point",
11078 __FILE__, VPurgeDisplay, group);
11079 theCommands.Add("vsetviewsize",
11080 "vsetviewsize size",
11081 __FILE__,VSetViewSize,group);
11082 theCommands.Add("vmoveview",
11083 "vmoveview Dx Dy Dz [Start = 1|0]",
11084 __FILE__,VMoveView,group);
11085 theCommands.Add("vtranslateview",
11086 "vtranslateview Dx Dy Dz [Start = 1|0)]",
11087 __FILE__,VTranslateView,group);
11088 theCommands.Add("vturnview",
11089 "vturnview Ax Ay Az [Start = 1|0]",
11090 __FILE__,VTurnView,group);
11091 theCommands.Add("vtextureenv",
11092 "Enables or disables environment mapping in the 3D view, loading the texture from the given standard "
11093 "or user-defined file and optionally applying texture mapping parameters\n"
11095 " vtextureenv off - disables environment mapping\n"
11096 " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n"
11097 " std_texture = (0..7)\n"
11098 " rep = {clamp|repeat}\n"
11099 " mod = {decal|modulate}\n"
11100 " flt = {nearest|bilinear|trilinear}\n"
11101 " ss, st - scale factors for s and t texture coordinates\n"
11102 " ts, tt - translation for s and t texture coordinates\n"
11103 " rot - texture rotation angle in degrees",
11104 __FILE__, VTextureEnv, group);
11105 theCommands.Add("vhlr" ,
11106 "is_enabled={on|off} [show_hidden={1|0}]"
11107 " - Hidden line removal algorithm:"
11108 " - is_enabled: if is on HLR algorithm is applied\n"
11109 " - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n",
11110 __FILE__,VHLR,group);
11111 theCommands.Add("vhlrtype" ,
11112 "algo_type={algo|polyalgo} [shape_1 ... shape_n]"
11113 " - Changes the type of HLR algorithm using for shapes."
11114 " - algo_type: if equals to algo, exact HLR algorithm is applied;\n"
11115 " if equals to polyalgo, polygonal HLR algorithm is applied."
11116 "If shapes are not given HLR algoithm of given type is applied"
11117 " to all shapes in the view\n",
11118 __FILE__,VHLRType,group);
11119 theCommands.Add("vclipplane",
11120 "vclipplane planeName [{0|1}]"
11121 "\n\t\t: [-equation A B C D]"
11122 "\n\t\t: [-set|-unset [objects|views]]"
11123 "\n\t\t: [-maxPlanes]"
11124 "\n\t\t: [-capping {0|1}]"
11125 "\n\t\t: [-color R G B] [-hatch {on|off|ID}]"
11126 "\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
11127 "\n\t\t: [-texRotate Angle]"
11128 "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
11129 "\n\t\t: [-useObjShader {0|1}]"
11130 "\n\t\t: Clipping planes management:"
11131 "\n\t\t: -maxPlanes print plane limit for view"
11132 "\n\t\t: -delete delete plane with given name"
11133 "\n\t\t: {off|on|0|1} turn clipping on/off"
11134 "\n\t\t: -set|-unset set/unset plane for Object or View list;"
11135 "\n\t\t: applied to active View when list is omitted"
11136 "\n\t\t: -equation A B C D change plane equation"
11137 "\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
11138 "\n\t\t: Capping options:"
11139 "\n\t\t: -capping {off|on|0|1} turn capping on/off"
11140 "\n\t\t: -color R G B set capping color"
11141 "\n\t\t: -texName Texture set capping texture"
11142 "\n\t\t: -texScale SX SY set capping tex scale"
11143 "\n\t\t: -texOrigin TX TY set capping tex origin"
11144 "\n\t\t: -texRotate Angle set capping tex rotation"
11145 "\n\t\t: -hatch {on|off|ID} set capping hatching mask"
11146 "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
11147 "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
11148 "\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
11149 __FILE__, VClipPlane, group);
11150 theCommands.Add("vdefaults",
11151 "vdefaults [-absDefl value]"
11152 "\n\t\t: [-devCoeff value]"
11153 "\n\t\t: [-angDefl value]"
11154 "\n\t\t: [-autoTriang {off/on | 0/1}]"
11155 , __FILE__, VDefaults, group);
11156 theCommands.Add("vlight",
11157 "tool to manage light sources, without arguments shows list of lights."
11158 "\n Main commands: "
11159 "\n 'clear' to clear lights"
11160 "\n '{def}aults' to load deafault lights"
11161 "\n 'add' (or 'new') <type> to add any light source"
11162 "\n where <type> is one of {amb}ient|directional|{spot}light|positional"
11163 "\n 'change' <lightId> to edit light source with specified lightId"
11164 "\n\n In addition to 'add' and 'change' commands you can use light parameters:"
11165 "\n {pos}ition X Y Z"
11166 "\n {dir}ection X Y Z (for directional light or for spotlight)"
11167 "\n color colorName"
11168 "\n {head}light 0|1"
11169 "\n {sm}oothness value"
11170 "\n {int}ensity value"
11171 "\n {constAtten}uation value"
11172 "\n {linearAtten}uation value"
11173 "\n angle angleDeg"
11174 "\n {spotexp}onent value"
11176 "\n\n example: vlight add positional head 1 pos 0 1 1 color red"
11177 "\n example: vlight change 0 direction 0 -1 0 linearAttenuation 0.2",
11178 __FILE__, VLight, group);
11179 theCommands.Add("vraytrace",
11181 "\n\t\t: Turns on/off ray-tracing renderer."
11182 "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'."
11183 "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.",
11184 __FILE__, VRenderParams, group);
11185 theCommands.Add("vrenderparams",
11186 "\n Manages rendering parameters: "
11187 "\n '-raster' Disables GPU ray-tracing"
11188 "\n '-msaa 0..4' Specifies number of samples for MSAA"
11189 "\n '-oit off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
11190 "\n '-rendScale value Rendering resolution scale factor"
11191 "\n '-rayTrace' Enables GPU ray-tracing"
11192 "\n '-rayDepth 0..10' Defines maximum ray-tracing depth"
11193 "\n '-shadows on|off' Enables/disables shadows rendering"
11194 "\n '-reflections on|off' Enables/disables specular reflections"
11195 "\n '-fsaa on|off' Enables/disables adaptive anti-aliasing"
11196 "\n '-gleam on|off' Enables/disables transparency shadow effects"
11197 "\n '-gi on|off' Enables/disables global illumination effects"
11198 "\n '-brng on|off' Enables/disables blocked RNG (fast coherent PT)"
11199 "\n '-env on|off' Enables/disables environment map background"
11200 "\n '-twoside on|off' Enables/disables two-sided BSDF models (PT mode)"
11201 "\n '-iss on|off' Enables/disables adaptive screen sampling (PT mode)"
11202 "\n '-issd on|off' Shows screen sampling distribution in ISS mode"
11203 "\n '-maxrad > 0.0' Value used for clamping radiance estimation (PT mode)"
11204 "\n '-nbtiles 64..1024' Specifies number of screen tiles in ISS mode"
11205 "\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
11206 "\n '-shadingModel model' Controls shading model from enumeration"
11207 "\n color, flat, gouraud, phong"
11208 "\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"
11209 "\n '-exposure value' Exposure value for tone mapping (0.0 value disables the effect)"
11210 "\n '-whitepoint value' White point value for filmic tone mapping"
11211 "\n '-tonemapping mode' Tone mapping mode (disabled, filmic)"
11212 "\n Unlike vcaps, these parameters dramatically change visual properties."
11213 "\n Command is intended to control presentation quality depending on"
11214 "\n hardware capabilities and performance.",
11215 __FILE__, VRenderParams, group);
11216 theCommands.Add("vfrustumculling",
11217 "vfrustumculling [toEnable]: enables/disables objects clipping",
11218 __FILE__,VFrustumCulling,group);
11219 theCommands.Add("vhighlightselected",
11220 "vhighlightselected [0|1] or vhighlightselected [on|off]: enables/disables highlighting of selected objects.\n"
11221 "Without arguments it shows if highlighting of selected objects is enabled now.",
11222 __FILE__,VHighlightSelected,group);
11223 theCommands.Add ("vplace",
11225 "\n\t\t: Places the point (in pixels) at the center of the window",
11226 __FILE__, VPlace, group);
11227 theCommands.Add("vxrotate",
11229 __FILE__,VXRotate,group);
11231 theCommands.Add("vmanipulator",
11232 "\n vmanipulator Name [-attach AISObject | -detach | ...]"
11233 "\n tool to create and manage AIS manipulators."
11235 "\n '-attach AISObject' attach manipulator to AISObject"
11236 "\n '-adjustPosition {0|1}' adjust position when attaching"
11237 "\n '-adjustSize {0|1}' adjust size when attaching"
11238 "\n '-enableModes {0|1}' enable modes when attaching"
11239 "\n '-detach' detach manipulator"
11240 "\n '-startTransform mouse_x mouse_y' - invoke start of transformation"
11241 "\n '-transform mouse_x mouse_y' - invoke transformation"
11242 "\n '-stopTransform [abort]' - invoke stop of transformation"
11243 "\n '-move x y z' - move attached object"
11244 "\n '-rotate x y z dx dy dz angle' - rotate attached object"
11245 "\n '-scale factor' - scale attached object"
11246 "\n '-autoActivate {0|1}' - set activation on detection"
11247 "\n '-followTranslation {0|1}' - set following translation transform"
11248 "\n '-followRotation {0|1}' - set following rotation transform"
11249 "\n '-gap value' - set gap between sub-parts"
11250 "\n '-part axis mode {0|1}' - set visual part"
11251 "\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator"
11252 "\n '-size value' - set size of manipulator"
11253 "\n '-zoomable {0|1}' - set zoom persistence",
11254 __FILE__, VManipulator, group);
11256 theCommands.Add("vselprops",
11257 "\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]"
11258 "\n Customizes selection and dynamic highlight parameters for the whole interactive context:"
11259 "\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode"
11260 "\n -pickStrategy {first|topmost} : defines picking strategy"
11261 "\n 'first' to pick first acceptable (default)"
11262 "\n 'topmost' to pick only topmost (and nothing, if topmost is rejected by filters)"
11263 "\n -pixTol value : sets up pixel tolerance"
11264 "\n -dispMode dispMode : sets display mode for highlighting"
11265 "\n -layer ZLayer : sets ZLayer for highlighting"
11266 "\n -color {name|r g b} : sets highlight color"
11267 "\n -transp value : sets transparency coefficient for highlight"
11268 "\n -material material : sets highlight material"
11269 "\n -print : prints current state of all mentioned parameters",
11270 __FILE__, VSelectionProperties, group);
11272 theCommands.Add ("vseldump",
11273 "vseldump file -type {depth|unnormDepth|object|owner|selMode|entity}=depth -pickedIndex Index=1"
11274 "\n\t\t: Generate an image based on detection results:"
11275 "\n\t\t: depth normalized depth values"
11276 "\n\t\t: unnormDepth unnormalized depth values"
11277 "\n\t\t: object color of detected object"
11278 "\n\t\t: owner color of detected owner"
11279 "\n\t\t: selMode color of selection mode"
11280 "\n\t\t: entity color of etected entity",
11281 __FILE__, VDumpSelectionImage, group);
11283 #if defined(_WIN32)
11284 theCommands.Add("vprogressive",
11286 __FILE__, VProgressiveMode, group);