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>
18 #include <AIS_Shape.hxx>
19 #include <AIS_InteractiveObject.hxx>
20 #include <AIS_ListOfInteractive.hxx>
21 #include <AIS_ListIteratorOfListOfInteractive.hxx>
23 #include <Graphic3d_AspectMarker3d.hxx>
24 #include <Graphic3d_ExportFormat.hxx>
25 #include <Graphic3d_NameOfTextureEnv.hxx>
26 #include <Graphic3d_GraduatedTrihedron.hxx>
27 #include <Graphic3d_TextureEnv.hxx>
28 #include <Graphic3d_TextureParams.hxx>
29 #include <Graphic3d_TypeOfTextureFilter.hxx>
30 #include <Graphic3d_AspectFillArea3d.hxx>
31 #include <ViewerTest.hxx>
32 #include <ViewerTest_AutoUpdater.hxx>
33 #include <ViewerTest_EventManager.hxx>
34 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
35 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
36 #include <Visual3d_View.hxx>
37 #include <Visual3d_ViewManager.hxx>
38 #include <V3d_AmbientLight.hxx>
39 #include <V3d_ColorScale.hxx>
40 #include <V3d_DirectionalLight.hxx>
41 #include <V3d_LayerMgr.hxx>
42 #include <V3d_LayerMgrPointer.hxx>
43 #include <V3d_PositionalLight.hxx>
44 #include <V3d_SpotLight.hxx>
45 #include <NCollection_DoubleMap.hxx>
46 #include <NCollection_List.hxx>
47 #include <NCollection_Vector.hxx>
48 #include <AIS_InteractiveContext.hxx>
49 #include <Draw_Interpretor.hxx>
51 #include <Draw_Appli.hxx>
52 #include <Aspect_PrintAlgo.hxx>
53 #include <Image_AlienPixMap.hxx>
54 #include <OpenGl_GraphicDriver.hxx>
55 #include <OSD_Timer.hxx>
56 #include <TColStd_HSequenceOfAsciiString.hxx>
57 #include <TColStd_SequenceOfInteger.hxx>
58 #include <TColStd_HSequenceOfReal.hxx>
59 #include <TColgp_Array1OfPnt2d.hxx>
60 #include <TColStd_MapOfAsciiString.hxx>
61 #include <Visual3d_LayerItem.hxx>
62 #include <Aspect_TypeOfLine.hxx>
63 #include <Image_Diff.hxx>
64 #include <Aspect_DisplayConnection.hxx>
68 #include <PrsMgr_PresentableObject.hxx>
69 #include <Graphic3d_ClipPlane.hxx>
70 #include <NCollection_DataMap.hxx>
71 #include <Graphic3d_Texture2Dmanual.hxx>
72 #include <Prs3d_ShadingAspect.hxx>
73 #include <Prs3d_Drawer.hxx>
79 #include <Visual3d_Layer.hxx>
83 #include <WNT_WClass.hxx>
84 #include <WNT_Window.hxx>
87 #define _CRT_SECURE_NO_DEPRECATE
88 #pragma warning (disable:4996)
90 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
91 #include <Cocoa_Window.hxx>
93 #include <Xw_Window.hxx>
94 #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
95 #include <X11/Xutil.h>
99 inline Standard_Boolean parseOnOff (Standard_CString theArg,
100 Standard_Boolean& theIsOn)
102 TCollection_AsciiString aFlag (theArg);
107 theIsOn = Standard_True;
108 return Standard_True;
110 else if (aFlag == "off"
113 theIsOn = Standard_False;
114 return Standard_True;
116 return Standard_False;
119 // Auxiliary definitions
120 static const char THE_KEY_DELETE = 127;
122 //==============================================================================
123 // VIEWER GLOBAL VARIABLES
124 //==============================================================================
126 Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
127 Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
129 Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
130 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
132 extern int VErase (Draw_Interpretor& theDI,
133 Standard_Integer theArgNb,
134 const char** theArgVec);
137 static Handle(WNT_Window)& VT_GetWindow() {
138 static Handle(WNT_Window) WNTWin;
141 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
142 static Handle(Cocoa_Window)& VT_GetWindow()
144 static Handle(Cocoa_Window) aWindow;
147 extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow);
148 extern void SetCocoaWindowTitle (const Handle(Cocoa_Window)& theWindow, Standard_CString theTitle);
149 extern void GetCocoaScreenResolution (Standard_Integer& theWidth, Standard_Integer& theHeight);
152 static Handle(Xw_Window)& VT_GetWindow(){
153 static Handle(Xw_Window) XWWin;
157 static void VProcessEvents(ClientData,int);
160 static Handle(Aspect_DisplayConnection)& GetDisplayConnection()
162 static Handle(Aspect_DisplayConnection) aDisplayConnection;
163 return aDisplayConnection;
166 static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
168 GetDisplayConnection() = theDisplayConnection;
171 #if defined(_WIN32) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
172 Aspect_Handle GetWindowHandle(const Handle(Aspect_Window)& theWindow)
174 Aspect_Handle aWindowHandle = (Aspect_Handle)NULL;
176 const Handle (WNT_Window) aWindow = Handle(WNT_Window)::DownCast (theWindow);
177 if (!aWindow.IsNull())
178 return aWindow->HWindow();
179 #elif (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
180 const Handle (Xw_Window) aWindow = Handle(Xw_Window)::DownCast (theWindow);
181 if (!aWindow.IsNull())
182 return aWindow->XWindow();
184 return aWindowHandle;
188 static Standard_Boolean MyHLRIsOn = Standard_False;
190 NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
191 static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts;
192 static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers;
193 static OpenGl_Caps ViewerTest_myDefaultCaps;
195 #define ZCLIPWIDTH 1.
197 static void OSWindowSetup();
199 //==============================================================================
200 // EVENT GLOBAL VARIABLES
201 //==============================================================================
203 static int Start_Rot = 0;
204 static int ZClipIsOn = 0;
205 int X_Motion = 0; // Current cursor position
207 int X_ButtonPress = 0; // Last ButtonPress position
208 int Y_ButtonPress = 0;
209 Standard_Boolean IsDragged = Standard_False;
210 Standard_Boolean DragFirst = Standard_False;
212 //==============================================================================
215 static LRESULT WINAPI ViewerWindowProc(
220 static LRESULT WINAPI AdvViewerWindowProc(
228 //==============================================================================
231 //==============================================================================
233 const Handle(MMgt_TShared)& ViewerTest::WClass()
235 static Handle(MMgt_TShared) theWClass;
237 if (theWClass.IsNull())
239 theWClass = new WNT_WClass ("GW3D_Class", AdvViewerWindowProc,
240 CS_VREDRAW | CS_HREDRAW, 0, 0,
241 ::LoadCursor (NULL, IDC_ARROW));
247 //==============================================================================
248 //function : CreateName
249 //purpose : Create numerical name for new object in theMap
250 //==============================================================================
251 template <typename ObjectType>
252 TCollection_AsciiString CreateName (const NCollection_DoubleMap <TCollection_AsciiString, ObjectType>& theObjectMap,
253 const TCollection_AsciiString& theDefaultString)
255 if (theObjectMap.IsEmpty())
256 return theDefaultString + TCollection_AsciiString(1);
258 Standard_Integer aNextKey = 1;
259 Standard_Boolean isFound = Standard_False;
262 TCollection_AsciiString aStringKey = theDefaultString + TCollection_AsciiString(aNextKey);
263 // Look for objects with default names
264 if (theObjectMap.IsBound1(aStringKey))
269 isFound = Standard_True;
272 return theDefaultString + TCollection_AsciiString(aNextKey);
275 //==============================================================================
276 //structure : ViewerTest_Names
277 //purpose : Allow to operate with full view name: driverName/viewerName/viewName
278 //==============================================================================
279 struct ViewerTest_Names
282 TCollection_AsciiString myDriverName;
283 TCollection_AsciiString myViewerName;
284 TCollection_AsciiString myViewName;
288 const TCollection_AsciiString& GetDriverName () const
292 void SetDriverName (const TCollection_AsciiString& theDriverName)
294 myDriverName = theDriverName;
296 const TCollection_AsciiString& GetViewerName () const
300 void SetViewerName (const TCollection_AsciiString& theViewerName)
302 myViewerName = theViewerName;
304 const TCollection_AsciiString& GetViewName () const
308 void SetViewName (const TCollection_AsciiString& theViewName)
310 myViewName = theViewName;
313 //===========================================================================
314 //function : Constructor for ViewerTest_Names
315 //purpose : Get view, viewer, driver names from custom string
316 //===========================================================================
318 ViewerTest_Names (const TCollection_AsciiString& theInputString)
320 TCollection_AsciiString aName(theInputString);
321 if (theInputString.IsEmpty())
323 // Get current configuration
324 if (ViewerTest_myDrivers.IsEmpty())
325 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
326 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
328 myDriverName = ViewerTest_myDrivers.Find2
329 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
331 if(ViewerTest_myContexts.IsEmpty())
333 myViewerName = CreateName <Handle(AIS_InteractiveContext)>
334 (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer"));
337 myViewerName = ViewerTest_myContexts.Find2 (ViewerTest::GetAISContext());
339 myViewName = CreateName <Handle(V3d_View)>
340 (ViewerTest_myViews, TCollection_AsciiString(myViewerName + "/View"));
344 // There is at least view name
345 Standard_Integer aParserNumber = 0;
346 for (Standard_Integer i = 0; i < 3; ++i)
348 Standard_Integer aParserPos = aName.SearchFromEnd("/");
352 aName.Split(aParserPos-1);
357 if (aParserNumber == 0)
360 if (!ViewerTest::GetAISContext().IsNull())
362 myDriverName = ViewerTest_myDrivers.Find2
363 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
364 myViewerName = ViewerTest_myContexts.Find2
365 (ViewerTest::GetAISContext());
369 // There is no opened contexts here, need to create names for viewer and driver
370 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
371 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
373 myViewerName = CreateName <Handle(AIS_InteractiveContext)>
374 (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer"));
376 myViewName = TCollection_AsciiString(myViewerName + "/" + theInputString);
378 else if (aParserNumber == 1)
380 // Here is viewerName/viewName
381 if (!ViewerTest::GetAISContext().IsNull())
382 myDriverName = ViewerTest_myDrivers.Find2
383 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
386 // There is no opened contexts here, need to create name for driver
387 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
388 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
390 myViewerName = TCollection_AsciiString(myDriverName + "/" + aName);
392 myViewName = TCollection_AsciiString(myDriverName + "/" + theInputString);
396 //Here is driverName/viewerName/viewName
397 myDriverName = TCollection_AsciiString(aName);
399 TCollection_AsciiString aViewerName(theInputString);
400 aViewerName.Split(aViewerName.SearchFromEnd("/") - 1);
401 myViewerName = TCollection_AsciiString(aViewerName);
403 myViewName = TCollection_AsciiString(theInputString);
409 //==============================================================================
410 //function : FindContextByView
411 //purpose : Find AIS_InteractiveContext by View
412 //==============================================================================
414 Handle(AIS_InteractiveContext) FindContextByView (const Handle(V3d_View)& theView)
416 Handle(AIS_InteractiveContext) anAISContext;
418 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
419 anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
421 if (anIter.Value()->CurrentViewer() == theView->Viewer())
422 return anIter.Key2();
428 //==============================================================================
429 //function : SetWindowTitle
430 //purpose : Set window title
431 //==============================================================================
433 void SetWindowTitle (const Handle(Aspect_Window)& theWindow,
434 Standard_CString theTitle)
437 SetWindowText ((HWND)Handle(WNT_Window)::DownCast(theWindow)->HWindow(),
439 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
440 SetCocoaWindowTitle (Handle(Cocoa_Window)::DownCast(theWindow), theTitle);
442 if(GetDisplayConnection()->GetDisplay())
445 Handle(Xw_Window)::DownCast(theWindow)->XWindow();
446 XStoreName (GetDisplayConnection()->GetDisplay(), aWindow , theTitle);
451 //==============================================================================
452 //function : IsWindowOverlapped
453 //purpose : Check if theWindow overlapp another view
454 //==============================================================================
456 Standard_Boolean IsWindowOverlapped (const Standard_Integer thePxLeft,
457 const Standard_Integer thePxTop,
458 const Standard_Integer thePxRight,
459 const Standard_Integer thePxBottom,
460 TCollection_AsciiString& theViewId)
462 for(NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
463 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
465 Standard_Integer aTop = 0,
469 anIter.Value()->Window()->Position(aLeft, aTop, aRight, aBottom);
470 if ((thePxLeft >= aLeft && thePxLeft <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
471 (thePxLeft >= aLeft && thePxLeft <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom) ||
472 (thePxRight >= aLeft && thePxRight <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
473 (thePxRight >= aLeft && thePxRight <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom))
475 theViewId = anIter.Key1();
476 return Standard_True;
479 return Standard_False;
482 // Workaround: to create and delete non-orthographic views outside ViewerTest
483 void ViewerTest::RemoveViewName (const TCollection_AsciiString& theName)
485 ViewerTest_myViews.UnBind1 (theName);
488 void ViewerTest::InitViewName (const TCollection_AsciiString& theName,
489 const Handle(V3d_View)& theView)
491 ViewerTest_myViews.Bind (theName, theView);
494 TCollection_AsciiString ViewerTest::GetCurrentViewName ()
496 return ViewerTest_myViews.Find2( ViewerTest::CurrentView());
498 //==============================================================================
499 //function : ViewerInit
500 //purpose : Create the window viewer and initialize all the global variable
501 //==============================================================================
503 TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft,
504 const Standard_Integer thePxTop,
505 const Standard_Integer thePxWidth,
506 const Standard_Integer thePxHeight,
507 Standard_CString theViewName,
508 Standard_CString theDisplayName)
510 // Default position and dimension of the viewer window.
511 // Note that left top corner is set to be sufficiently small to have
512 // window fit in the small screens (actual for remote desktops, see #23003).
513 // The position corresponds to the window's client area, thus some
514 // gap is added for window frame to be visible.
515 Standard_Integer aPxLeft = 20;
516 Standard_Integer aPxTop = 40;
517 Standard_Integer aPxWidth = 409;
518 Standard_Integer aPxHeight = 409;
519 Standard_Boolean toCreateViewer = Standard_False;
521 Handle(OpenGl_GraphicDriver) aGraphicDriver;
522 ViewerTest_Names aViewNames(theViewName);
523 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ()))
524 aViewNames.SetViewName (aViewNames.GetViewerName() + "/" + CreateName<Handle(V3d_View)>(ViewerTest_myViews, "View"));
531 aPxWidth = thePxWidth;
532 if (thePxHeight != 0)
533 aPxHeight = thePxHeight;
535 // Get graphic driver (create it or get from another view)
536 if (!ViewerTest_myDrivers.IsBound1 (aViewNames.GetDriverName()))
538 // Get connection string
539 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
540 TCollection_AsciiString aDisplayName(theDisplayName);
541 if (!aDisplayName.IsEmpty())
542 SetDisplayConnection (new Aspect_DisplayConnection ());
544 SetDisplayConnection (new Aspect_DisplayConnection (aDisplayName));
546 (void)theDisplayName; // avoid warning on unused argument
547 SetDisplayConnection (new Aspect_DisplayConnection ());
549 aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection());
550 aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
551 ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
552 toCreateViewer = Standard_True;
556 aGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast (ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName()));
559 //Dispose the window if input parameters are default
560 if (!ViewerTest_myViews.IsEmpty() && thePxLeft == 0 && thePxTop == 0)
562 Standard_Integer aTop = 0,
569 // Get screen resolution
570 #if defined(_WIN32) || defined(__WIN32__)
572 GetClientRect(GetDesktopWindow(), &aWindowSize);
573 aScreenHeight = aWindowSize.bottom;
574 aScreenWidth = aWindowSize.right;
575 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
576 GetCocoaScreenResolution (aScreenWidth, aScreenHeight);
578 Screen *aScreen = DefaultScreenOfDisplay(GetDisplayConnection()->GetDisplay());
579 aScreenWidth = WidthOfScreen(aScreen);
580 aScreenHeight = HeightOfScreen(aScreen);
583 TCollection_AsciiString anOverlappedViewId("");
585 while (IsWindowOverlapped (aPxLeft, aPxTop, aPxLeft + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId))
587 ViewerTest_myViews.Find1(anOverlappedViewId)->Window()->Position (aLeft, aTop, aRight, aBottom);
589 if (IsWindowOverlapped (aRight + 20, aPxTop, aRight + 20 + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId)
590 && aRight + 2*aPxWidth + 40 > aScreenWidth)
592 if (aBottom + aPxHeight + 40 > aScreenHeight)
599 aPxTop = aBottom + 40;
602 aPxLeft = aRight + 20;
607 TCollection_AsciiString aTitle("3D View - ");
608 aTitle = aTitle + aViewNames.GetViewName() + "(*)";
610 // Change name of current active window
611 if (!ViewerTest::CurrentView().IsNull())
613 TCollection_AsciiString aTitle("3D View - ");
615 + ViewerTest_myViews.Find2 (ViewerTest::CurrentView());
616 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
620 Handle(V3d_Viewer) a3DViewer;
621 // If it's the single view, we first look for empty context
622 if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty())
624 NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
625 anIter(ViewerTest_myContexts);
627 ViewerTest::SetAISContext (anIter.Value());
628 a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
630 else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))
632 ViewerTest::SetAISContext(ViewerTest_myContexts.Find1(aViewNames.GetViewerName()));
633 a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
635 else if (a3DViewer.IsNull())
637 toCreateViewer = Standard_True;
638 TCollection_ExtendedString NameOfWindow("Viewer3D");
639 a3DViewer = new V3d_Viewer(aGraphicDriver, NameOfWindow.ToExtString());
641 NameOfWindow = TCollection_ExtendedString("Collector");
643 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
647 if (ViewerTest::GetAISContext().IsNull() ||
648 !(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())))
650 Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer);
651 ViewerTest::SetAISContext (aContext);
652 ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext());
656 ViewerTest::ResetEventManager();
661 VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
662 Handle(WNT_WClass)::DownCast (WClass()),
663 Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW,
667 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
668 VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(),
670 aPxWidth, aPxHeight);
671 ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
673 VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(),
676 aPxWidth, aPxHeight);
678 VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
681 Handle(V3d_View) aView = a3DViewer->CreateView();
682 aView->SetWindow (VT_GetWindow());
684 ViewerTest::CurrentView(aView);
685 ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView);
687 // Setup for X11 or NT
690 // Set parameters for V3d_View and V3d_Viewer
691 const Handle (V3d_View) aV3dView = ViewerTest::CurrentView();
692 aV3dView->SetComputedMode(Standard_False);
693 MyHLRIsOn = aV3dView->ComputedMode();
694 aV3dView->SetZClippingDepth(0.5);
695 aV3dView->SetZClippingWidth(ZCLIPWIDTH/2.);
697 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
700 a3DViewer->SetDefaultLights();
701 a3DViewer->SetLightOn();
704 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
705 #if TCL_MAJOR_VERSION < 8
706 Tk_CreateFileHandler((void*)XConnectionNumber(GetDisplayConnection()->GetDisplay()),
707 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
709 Tk_CreateFileHandler(XConnectionNumber(GetDisplayConnection()->GetDisplay()),
710 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
714 VT_GetWindow()->Map();
716 // Set the handle of created view in the event manager
717 ViewerTest::ResetEventManager();
719 ViewerTest::CurrentView()->Redraw();
724 return aViewNames.GetViewName();
727 //==============================================================================
728 //function : RedrawAllViews
729 //purpose : Redraw all created views
730 //==============================================================================
731 void ViewerTest::RedrawAllViews()
733 NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
734 for (; aViewIt.More(); aViewIt.Next())
736 const Handle(V3d_View)& aView = aViewIt.Key2();
741 //==============================================================================
743 //purpose : Create the window viewer and initialize all the global variable
744 // Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event
745 //==============================================================================
747 static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
751 std::cerr << theArgVec[0] << ": incorrect number of command arguments.\n"
752 << "Type help for more information.\n";
756 TCollection_AsciiString aViewName, aDisplayName;
757 Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
758 TCollection_AsciiString aName, aValue;
759 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
761 const TCollection_AsciiString anArg = theArgVec[anArgIt];
762 TCollection_AsciiString anArgCase = anArg;
763 anArgCase.UpperCase();
764 if (ViewerTest::SplitParameter (anArg, aName, aValue))
767 if (aName.IsEqual ("NAME"))
771 else if (aName.IsEqual ("L")
772 || aName.IsEqual ("LEFT"))
774 aPxLeft = aValue.IntegerValue();
776 else if (aName.IsEqual ("T")
777 || aName.IsEqual ("TOP"))
779 aPxTop = aValue.IntegerValue();
781 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
782 else if (aName.IsEqual ("DISP")
783 || aName.IsEqual ("DISPLAY"))
785 aDisplayName = aValue;
788 else if (aName.IsEqual ("W")
789 || aName.IsEqual ("WIDTH"))
791 aPxWidth = aValue.IntegerValue();
793 else if (aName.IsEqual ("H")
794 || aName.IsEqual ("HEIGHT"))
796 aPxHeight = aValue.IntegerValue();
800 std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
803 else if (aViewName.IsEmpty())
809 std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
813 ViewerTest_Names aViewNames (aViewName);
814 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
816 TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName();
817 theDi.Eval (aCommand.ToCString());
821 TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
822 aViewName.ToCString(),
823 aDisplayName.ToCString());
828 //==============================================================================
830 //purpose : hidden lines removal algorithm
831 //draw args: vhlr is_enabled={on|off} [show_hidden={1|0}]
832 //==============================================================================
834 static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
836 if (ViewerTest::CurrentView().IsNull())
838 di << argv[0] << ": Call vinit before this command, please.\n";
844 di << argv[0] << ": Wrong number of command arguments.\n"
845 << "Type help " << argv[0] << " for more information.\n";
849 // Enable or disable HLR mode.
850 Standard_Boolean isHLROn =
851 (!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False;
853 if (isHLROn != MyHLRIsOn)
856 ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn);
859 // Show or hide hidden lines in HLR mode.
860 Standard_Boolean isCurrentShowHidden
861 = ViewerTest::GetAISContext()->DefaultDrawer()->DrawHiddenLine();
863 Standard_Boolean isShowHidden =
864 (argc == 3) ? (atoi(argv[2]) == 1 ? Standard_True : Standard_False)
865 : isCurrentShowHidden;
868 if (isShowHidden != isCurrentShowHidden)
872 ViewerTest::GetAISContext()->DefaultDrawer()->EnableDrawHiddenLine();
876 ViewerTest::GetAISContext()->DefaultDrawer()->DisableDrawHiddenLine();
882 AIS_ListOfInteractive aListOfShapes;
883 ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes);
885 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next())
887 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIter.Value());
892 ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False);
897 ViewerTest::CurrentView()->Update();
901 //==============================================================================
902 //function : VHLRType
903 //purpose : change type of using HLR algorithm
904 //==============================================================================
906 static int VHLRType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
908 if (ViewerTest::CurrentView().IsNull())
910 di << argv[0] << ": Call vinit before this command, please.\n";
916 di << argv[0] << ": Wrong number of command arguments.\n"
917 << "Type help " << argv[0] << " for more information.\n";
921 Prs3d_TypeOfHLR aTypeOfHLR =
922 (!strcasecmp (argv[1], "algo")) ? Prs3d_TOH_Algo : Prs3d_TOH_PolyAlgo;
926 AIS_ListOfInteractive aListOfShapes;
927 ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes);
928 ViewerTest::GetAISContext()->DefaultDrawer()->SetTypeOfHLR(aTypeOfHLR);
929 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
930 anIter.More(); anIter.Next())
932 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
935 if (aShape->TypeOfHLR() != aTypeOfHLR)
936 aShape->SetTypeOfHLR (aTypeOfHLR);
938 ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False);
940 ViewerTest::CurrentView()->Update();
945 for (Standard_Integer i = 2; i < argc; ++i)
947 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
948 TCollection_AsciiString aName (argv[i]);
950 if (!aMap.IsBound2 (aName))
952 di << argv[0] << ":" << " Wrong shape name:" << aName.ToCString() << ".\n";
955 Handle(AIS_Shape) anAISObject =
956 Handle(AIS_Shape)::DownCast (aMap.Find2(aName));
957 if (anAISObject.IsNull())
959 anAISObject->SetTypeOfHLR (aTypeOfHLR);
961 ViewerTest::GetAISContext()->Redisplay (anAISObject, Standard_False);
963 ViewerTest::CurrentView()->Update();
969 //==============================================================================
970 //function : FindViewIdByWindowHandle
971 //purpose : Find theView Id in the map of views by window handle
972 //==============================================================================
973 #if defined(_WIN32) || defined(__WIN32__) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
974 TCollection_AsciiString FindViewIdByWindowHandle(const Aspect_Handle theWindowHandle)
976 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator
977 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
979 Aspect_Handle aWindowHandle = GetWindowHandle(anIter.Value()->Window());
980 if (aWindowHandle == theWindowHandle)
981 return anIter.Key1();
983 return TCollection_AsciiString("");
987 //==============================================================================
988 //function : ActivateView
989 //purpose : Make the view active
990 //==============================================================================
992 void ActivateView (const TCollection_AsciiString& theViewName)
994 const Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
997 Handle(AIS_InteractiveContext) anAISContext = FindContextByView(aView);
998 if (!anAISContext.IsNull())
1000 if (!ViewerTest::CurrentView().IsNull())
1002 TCollection_AsciiString aTitle("3D View - ");
1003 aTitle = aTitle + ViewerTest_myViews.Find2 (ViewerTest::CurrentView());
1004 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1007 ViewerTest::CurrentView (aView);
1008 // Update degenerate mode
1009 MyHLRIsOn = ViewerTest::CurrentView()->ComputedMode();
1010 ViewerTest::SetAISContext (anAISContext);
1011 TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - ");
1012 aTitle = aTitle + theViewName + "(*)";
1013 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1014 #if defined(_WIN32) || defined(__WIN32__)
1015 VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window());
1016 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1017 VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window());
1019 VT_GetWindow() = Handle(Xw_Window)::DownCast(ViewerTest::CurrentView()->Window());
1021 SetDisplayConnection(ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
1022 ViewerTest::CurrentView()->Redraw();
1027 //==============================================================================
1028 //function : RemoveView
1030 //==============================================================================
1031 void ViewerTest::RemoveView (const Handle(V3d_View)& theView,
1032 const Standard_Boolean theToRemoveContext)
1034 if (!ViewerTest_myViews.IsBound2 (theView))
1039 const TCollection_AsciiString aViewName = ViewerTest_myViews.Find2 (theView);
1040 RemoveView (aViewName, theToRemoveContext);
1043 //==============================================================================
1044 //function : RemoveView
1045 //purpose : Close and remove view from display, clear maps if neccessary
1046 //==============================================================================
1047 void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const Standard_Boolean isContextRemoved)
1049 if (!ViewerTest_myViews.IsBound1(theViewName))
1051 cout << "Wrong view name\n";
1055 // Activate another view if it's active now
1056 if (ViewerTest_myViews.Find1(theViewName) == ViewerTest::CurrentView())
1058 if (ViewerTest_myViews.Extent() > 1)
1060 TCollection_AsciiString aNewViewName;
1061 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> :: Iterator
1062 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
1063 if (anIter.Key1() != theViewName)
1065 aNewViewName = anIter.Key1();
1068 ActivateView (aNewViewName);
1072 Handle(V3d_View) anEmptyView;
1073 #if defined(_WIN32) || defined(__WIN32__)
1074 Handle(WNT_Window) anEmptyWindow;
1075 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1076 Handle(Cocoa_Window) anEmptyWindow;
1078 Handle(Xw_Window) anEmptyWindow;
1080 VT_GetWindow() = anEmptyWindow;
1081 ViewerTest::CurrentView (anEmptyView);
1082 if (isContextRemoved)
1084 Handle(AIS_InteractiveContext) anEmptyContext;
1085 ViewerTest::SetAISContext(anEmptyContext);
1091 Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
1092 Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
1094 // Remove view resources
1095 ViewerTest_myViews.UnBind1(theViewName);
1098 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1099 XFlush (GetDisplayConnection()->GetDisplay());
1102 // Keep context opened only if the closed view is last to avoid
1103 // unused empty contexts
1104 if (!aCurrentContext.IsNull())
1106 // Check if there are more difined views in the viewer
1107 aCurrentContext->CurrentViewer()->InitDefinedViews();
1108 if ((isContextRemoved || ViewerTest_myContexts.Size() != 1) && !aCurrentContext->CurrentViewer()->MoreDefinedViews())
1110 // Remove driver if there is no viewers that use it
1111 Standard_Boolean isRemoveDriver = Standard_True;
1112 for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1113 anIter(ViewerTest_myContexts); anIter.More(); anIter.Next())
1115 if (aCurrentContext != anIter.Key2() &&
1116 aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver())
1118 isRemoveDriver = Standard_False;
1124 ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver());
1125 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1126 #if TCL_MAJOR_VERSION < 8
1127 Tk_DeleteFileHandler((void*)XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
1129 Tk_DeleteFileHandler(XConnectionNumber(aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
1134 ViewerTest_myContexts.UnBind2(aCurrentContext);
1137 cout << "3D View - " << theViewName << " was deleted.\n";
1141 //==============================================================================
1143 //purpose : Remove the view defined by its name
1144 //==============================================================================
1146 static int VClose (Draw_Interpretor& /*theDi*/,
1147 Standard_Integer theArgsNb,
1148 const char** theArgVec)
1150 NCollection_List<TCollection_AsciiString> aViewList;
1153 TCollection_AsciiString anArg (theArgVec[1]);
1155 if (anArg.IsEqual ("ALL")
1156 || anArg.IsEqual ("*"))
1158 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
1159 anIter.More(); anIter.Next())
1161 aViewList.Append (anIter.Key1());
1163 if (aViewList.IsEmpty())
1165 std::cout << "No view to close\n";
1171 ViewerTest_Names aViewName (theArgVec[1]);
1172 if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName()))
1174 std::cerr << "The view with name '" << theArgVec[1] << "' does not exist\n";
1177 aViewList.Append (aViewName.GetViewName());
1182 // close active view
1183 if (ViewerTest::CurrentView().IsNull())
1185 std::cerr << "No active view!\n";
1188 aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView()));
1191 Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1);
1192 for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList);
1193 anIter.More(); anIter.Next())
1195 ViewerTest::RemoveView (anIter.Value(), toRemoveContext);
1201 //==============================================================================
1202 //function : VActivate
1203 //purpose : Activate the view defined by its ID
1204 //==============================================================================
1206 static int VActivate (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1210 theDi << theArgVec[0] << ": wrong number of command arguments.\n"
1211 << "Usage: " << theArgVec[0] << " ViewID\n";
1216 theDi.Eval("vviewlist");
1220 TCollection_AsciiString aNameString(theArgVec[1]);
1221 if ( strcasecmp( aNameString.ToCString(), "NONE" ) == 0 )
1223 TCollection_AsciiString aTitle("3D View - ");
1224 aTitle = aTitle + ViewerTest_myViews.Find2(ViewerTest::CurrentView());
1225 SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
1226 Handle(V3d_View) anEmptyView;
1227 #if defined(_WIN32) || defined(__WIN32__)
1228 Handle(WNT_Window) anEmptyWindow;
1229 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1230 Handle(Cocoa_Window) anEmptyWindow;
1232 Handle(Xw_Window) anEmptyWindow;
1234 VT_GetWindow() = anEmptyWindow;
1235 ViewerTest::CurrentView (anEmptyView);
1236 ViewerTest::ResetEventManager();
1237 theDi << theArgVec[0] << ": all views are inactive\n";
1241 ViewerTest_Names aViewNames(aNameString);
1243 // Check if this view exists in the viewer with the driver
1244 if (!ViewerTest_myViews.IsBound1(aViewNames.GetViewName()))
1246 theDi << "Wrong view name\n";
1250 // Check if it is active already
1251 if (ViewerTest::CurrentView() == ViewerTest_myViews.Find1(aViewNames.GetViewName()))
1253 theDi << theArgVec[0] << ": the view is active already\n";
1257 ActivateView (aViewNames.GetViewName());
1261 //==============================================================================
1262 //function : VViewList
1263 //purpose : Print current list of views per viewer and graphic driver ID
1264 // shared between viewers
1265 //==============================================================================
1267 static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1271 theDi << theArgVec[0] << ": Wrong number of command arguments\n"
1272 << "Usage: " << theArgVec[0] << " name";
1275 if (ViewerTest_myContexts.Size() < 1)
1278 Standard_Boolean isTreeView =
1279 (( theArgsNb==1 ) || ( strcasecmp( theArgVec[1], "long" ) != 0 ));
1282 theDi << theArgVec[0] <<":\n";
1284 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
1285 aDriverIter(ViewerTest_myDrivers); aDriverIter.More(); aDriverIter.Next())
1288 theDi << aDriverIter.Key1() << ":\n";
1290 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1291 aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next())
1293 if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1)
1297 TCollection_AsciiString aContextName(aContextIter.Key1());
1298 theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":" << "\n";
1301 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
1302 aViewIter(ViewerTest_myViews); aViewIter.More(); aViewIter.Next())
1304 if (aViewIter.Key1().Search(aContextIter.Key1()) != -1)
1306 TCollection_AsciiString aViewName(aViewIter.Key1());
1309 if (aViewIter.Value() == ViewerTest::CurrentView())
1310 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)" << "\n";
1312 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n";
1316 theDi << aViewName << " ";
1326 //==============================================================================
1327 //function : VT_ProcessKeyPress
1328 //purpose : Handle KeyPress event from a CString
1329 //==============================================================================
1330 void VT_ProcessKeyPress (const char* buf_ret)
1332 //cout << "KeyPress" << endl;
1333 const Handle(V3d_View) aView = ViewerTest::CurrentView();
1334 // Letter in alphabetic order
1336 if (!strcasecmp (buf_ret, "A"))
1339 aView->SetProj(V3d_XposYnegZpos);
1341 else if (!strcasecmp (buf_ret, "D"))
1346 else if (!strcasecmp (buf_ret, "F"))
1348 if (ViewerTest::GetAISContext()->NbSelected() > 0)
1350 ViewerTest::GetAISContext()->FitSelected (aView);
1358 else if (!strcasecmp (buf_ret, "H"))
1361 cout << "HLR" << endl;
1362 aView->SetComputedMode (!aView->ComputedMode());
1363 MyHLRIsOn = aView->ComputedMode();
1365 else if (!strcasecmp (buf_ret, "P"))
1368 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1369 if (aContext->DefaultDrawer()->TypeOfHLR() == Prs3d_TOH_Algo)
1370 aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_PolyAlgo);
1372 aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_Algo);
1373 if (aContext->NbCurrents()==0 || aContext->NbSelected() == 0)
1375 AIS_ListOfInteractive aListOfShapes;
1376 aContext->DisplayedObjects(aListOfShapes);
1377 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
1378 anIter.More(); anIter.Next())
1380 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
1381 if (aShape.IsNull())
1383 if (aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
1384 aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
1386 aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
1387 aContext->Redisplay (aShape, Standard_False);
1392 for (aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent())
1394 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->Current());
1395 if (aShape.IsNull())
1397 if(aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
1398 aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
1400 aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
1401 aContext->Redisplay (aShape, Standard_False);
1405 aContext->UpdateCurrentViewer();
1408 else if (!strcasecmp (buf_ret, "S"))
1410 std::cout << "setup Shaded display mode" << std::endl;
1412 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1413 if(Ctx->NbCurrents()==0 ||
1414 Ctx->NbSelected()==0)
1415 Ctx->SetDisplayMode(AIS_Shaded);
1417 if(Ctx->HasOpenedContext()){
1418 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1419 Ctx->SetDisplayMode(Ctx->Interactive(),1,Standard_False);
1422 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
1423 Ctx->SetDisplayMode(Ctx->Current(),1,Standard_False);
1425 Ctx->UpdateCurrentViewer();
1428 else if (!strcasecmp (buf_ret, "U"))
1430 // Unset display mode
1431 std::cout << "reset display mode to defaults" << std::endl;
1433 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1434 if(Ctx->NbCurrents()==0 ||
1435 Ctx->NbSelected()==0)
1436 Ctx->SetDisplayMode(AIS_WireFrame);
1438 if(Ctx->HasOpenedContext()){
1439 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1440 Ctx->UnsetDisplayMode(Ctx->Interactive(),Standard_False);
1443 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
1444 Ctx->UnsetDisplayMode(Ctx->Current(),Standard_False);
1446 Ctx->UpdateCurrentViewer();
1450 else if (!strcasecmp (buf_ret, "T"))
1453 aView->SetProj(V3d_Zpos);
1455 else if (!strcasecmp (buf_ret, "B"))
1458 aView->SetProj(V3d_Zneg);
1460 else if (!strcasecmp (buf_ret, "L"))
1463 aView->SetProj(V3d_Xneg);
1465 else if (!strcasecmp (buf_ret, "R"))
1468 aView->SetProj(V3d_Xpos);
1470 else if (!strcasecmp (buf_ret, "W"))
1472 std::cout << "setup WireFrame display mode" << std::endl;
1473 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
1474 if(Ctx->NbCurrents()==0 ||
1475 Ctx->NbSelected()==0)
1476 Ctx->SetDisplayMode(AIS_WireFrame);
1478 if(Ctx->HasOpenedContext()){
1479 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
1480 Ctx->SetDisplayMode(Ctx->Interactive(),0,Standard_False);
1483 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
1484 Ctx->SetDisplayMode(Ctx->Current(),0,Standard_False);
1486 Ctx->UpdateCurrentViewer();
1489 else if (!strcasecmp (buf_ret, "Z"))
1493 cout << "ZClipping OFF" << endl;
1496 aView->SetZClippingType(V3d_OFF);
1500 cout << "ZClipping ON" << endl;
1503 aView->SetZClippingType(V3d_FRONT);
1507 else if (!strcasecmp (buf_ret, ","))
1509 ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView());
1511 else if (!strcasecmp (buf_ret, "."))
1513 ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
1515 else if (*buf_ret == THE_KEY_DELETE)
1517 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
1519 && aCtx->NbCurrents() > 0
1520 && aCtx->NbSelected() > 0)
1522 Draw_Interprete ("verase");
1528 Standard_Integer Num = Draw::Atoi(buf_ret);
1529 if(Num>=0 && Num<=7)
1530 ViewerTest::StandardModeActivation(Num);
1534 //==============================================================================
1535 //function : VT_ProcessExpose
1536 //purpose : Redraw the View on an Expose Event
1537 //==============================================================================
1538 void VT_ProcessExpose()
1540 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
1541 if (!aView3d.IsNull())
1547 //==============================================================================
1548 //function : VT_ProcessConfigure
1549 //purpose : Resize the View on an Configure Event
1550 //==============================================================================
1551 void VT_ProcessConfigure()
1553 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
1554 if (aView3d.IsNull())
1559 aView3d->MustBeResized();
1564 //==============================================================================
1565 //function : VT_ProcessButton1Press
1567 //==============================================================================
1568 Standard_Boolean VT_ProcessButton1Press (Standard_Integer ,
1569 const char** theArgVec,
1570 Standard_Boolean theToPick,
1571 Standard_Boolean theIsShift)
1575 Standard_Real X, Y, Z;
1576 ViewerTest::CurrentView()->Convert (X_Motion, Y_Motion, X, Y, Z);
1578 Draw::Set (theArgVec[1], X);
1579 Draw::Set (theArgVec[2], Y);
1580 Draw::Set (theArgVec[3], Z);
1585 ViewerTest::CurrentEventManager()->ShiftSelect();
1589 ViewerTest::CurrentEventManager()->Select();
1592 return Standard_False;
1595 //==============================================================================
1596 //function : VT_ProcessButton1Release
1597 //purpose : End selecting
1598 //==============================================================================
1599 void VT_ProcessButton1Release (Standard_Boolean theIsShift)
1603 IsDragged = Standard_False;
1604 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
1607 EM->ShiftSelect (X_ButtonPress, Y_ButtonPress,
1608 X_Motion, Y_Motion);
1612 EM->Select (X_ButtonPress, Y_ButtonPress,
1613 X_Motion, Y_Motion);
1618 //==============================================================================
1619 //function : VT_ProcessButton3Press
1620 //purpose : Start Rotation
1621 //==============================================================================
1622 void VT_ProcessButton3Press()
1627 ViewerTest::CurrentView()->SetComputedMode (Standard_False);
1629 ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress );
1632 //==============================================================================
1633 //function : VT_ProcessButton3Release
1634 //purpose : End rotation
1635 //==============================================================================
1636 void VT_ProcessButton3Release()
1643 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
1648 //==============================================================================
1649 //function : ProcessZClipMotion
1651 //==============================================================================
1653 void ProcessZClipMotion()
1655 Handle(V3d_View) a3DView = ViewerTest::CurrentView();
1656 if ( Abs(X_Motion - X_ButtonPress) > 2 ) {
1658 //Quantity_Length VDX, VDY;
1659 //a3DView->Size(VDX,VDY);
1660 //Standard_Real VDZ = a3DView->ZSize();
1661 //printf("View size (%lf,%lf,%lf)\n", VDX, VDY, VDZ);
1663 Quantity_Length aDx = a3DView->Convert(X_Motion - X_ButtonPress);
1665 // Front = Depth + width/2.
1666 Standard_Real aDepth = 0.5;
1667 Standard_Real aWidth = 0.1;
1668 a3DView->ZClipping(aDepth,aWidth);
1672 //printf("dx %lf Depth %lf Width %lf\n", dx, D, W);
1674 a3DView->SetZClippingDepth(aDepth);
1678 X_ButtonPress = X_Motion;
1679 Y_ButtonPress = Y_Motion;
1683 //==============================================================================
1684 //function : ProcessControlButton1Motion
1686 //==============================================================================
1688 #if defined(_WIN32) || ! defined(__APPLE__) || defined(MACOSX_USE_GLX)
1689 static void ProcessControlButton1Motion()
1691 ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion);
1693 X_ButtonPress = X_Motion;
1694 Y_ButtonPress = Y_Motion;
1698 //==============================================================================
1699 //function : VT_ProcessControlButton2Motion
1701 //==============================================================================
1702 void VT_ProcessControlButton2Motion()
1704 Standard_Integer aDx = X_Motion - X_ButtonPress;
1705 Standard_Integer aDy = Y_Motion - Y_ButtonPress;
1707 aDy = -aDy; // Xwindow Y axis is from top to Bottom
1709 ViewerTest::CurrentView()->Pan (aDx, aDy);
1711 X_ButtonPress = X_Motion;
1712 Y_ButtonPress = Y_Motion;
1715 //==============================================================================
1716 //function : VT_ProcessControlButton3Motion
1717 //purpose : Rotation
1718 //==============================================================================
1719 void VT_ProcessControlButton3Motion()
1723 ViewerTest::CurrentView()->Rotation (X_Motion, Y_Motion);
1727 //==============================================================================
1728 //function : VT_ProcessMotion
1730 //==============================================================================
1731 void VT_ProcessMotion()
1733 //pre-hilights detected objects at mouse position
1735 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
1736 EM->MoveTo(X_Motion, Y_Motion);
1740 void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix)
1742 Xpix = X_Motion;Ypix=Y_Motion;
1745 //==============================================================================
1746 //function : ViewProject: implements VAxo, VTop, VLeft, ...
1747 //purpose : Switches to an axonometric, top, left and other views
1748 //==============================================================================
1750 static int ViewProject(Draw_Interpretor& di, const V3d_TypeOfOrientation ori)
1752 if ( ViewerTest::CurrentView().IsNull() )
1754 di<<"Call vinit before this command, please"<<"\n";
1758 ViewerTest::CurrentView()->SetProj(ori);
1762 //==============================================================================
1764 //purpose : Switch to an Axonometric view
1765 //Draw arg : No args
1766 //==============================================================================
1768 static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** )
1770 return ViewProject(di, V3d_XposYnegZpos);
1773 //==============================================================================
1775 //purpose : Switch to a Top View
1776 //Draw arg : No args
1777 //==============================================================================
1779 static int VTop(Draw_Interpretor& di, Standard_Integer , const char** )
1781 return ViewProject(di, V3d_Zpos);
1784 //==============================================================================
1785 //function : VBottom
1786 //purpose : Switch to a Bottom View
1787 //Draw arg : No args
1788 //==============================================================================
1790 static int VBottom(Draw_Interpretor& di, Standard_Integer , const char** )
1792 return ViewProject(di, V3d_Zneg);
1795 //==============================================================================
1797 //purpose : Switch to a Left View
1798 //Draw arg : No args
1799 //==============================================================================
1801 static int VLeft(Draw_Interpretor& di, Standard_Integer , const char** )
1803 return ViewProject(di, V3d_Ypos);
1806 //==============================================================================
1808 //purpose : Switch to a Right View
1809 //Draw arg : No args
1810 //==============================================================================
1812 static int VRight(Draw_Interpretor& di, Standard_Integer , const char** )
1814 return ViewProject(di, V3d_Yneg);
1817 //==============================================================================
1819 //purpose : Switch to a Front View
1820 //Draw arg : No args
1821 //==============================================================================
1823 static int VFront(Draw_Interpretor& di, Standard_Integer , const char** )
1825 return ViewProject(di, V3d_Xpos);
1828 //==============================================================================
1830 //purpose : Switch to a Back View
1831 //Draw arg : No args
1832 //==============================================================================
1834 static int VBack(Draw_Interpretor& di, Standard_Integer , const char** )
1836 return ViewProject(di, V3d_Xneg);
1839 //==============================================================================
1841 //purpose : Dsiplay help on viewer Keyboead and mouse commands
1842 //Draw arg : No args
1843 //==============================================================================
1845 static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
1848 di << "Q : Quit the application" << "\n";
1850 di << "========================="<<"\n";
1851 di << "F : FitAll" << "\n";
1852 di << "T : TopView" << "\n";
1853 di << "B : BottomView" << "\n";
1854 di << "R : RightView" << "\n";
1855 di << "L : LeftView" << "\n";
1856 di << "A : AxonometricView" << "\n";
1857 di << "D : ResetView" << "\n";
1859 di << "========================="<<"\n";
1860 di << "S : Shading" << "\n";
1861 di << "W : Wireframe" << "\n";
1862 di << "H : HidelLineRemoval" << "\n";
1863 di << "U : Unset display mode" << "\n";
1864 di << "Delete : Remove selection from viewer" << "\n";
1866 di << "========================="<<"\n";
1867 di << "Selection mode "<<"\n";
1868 di << "0 : Shape" <<"\n";
1869 di << "1 : Vertex" <<"\n";
1870 di << "2 : Edge" <<"\n";
1871 di << "3 : Wire" <<"\n";
1872 di << "4 : Face" <<"\n";
1873 di << "5 : Shell" <<"\n";
1874 di << "6 : Solid" <<"\n";
1875 di << "7 : Compound" <<"\n";
1877 di << "========================="<<"\n";
1878 di << "Z : Switch Z clipping On/Off" << "\n";
1879 di << ", : Hilight next detected" << "\n";
1880 di << ". : Hilight previous detected" << "\n";
1887 static Standard_Boolean Ppick = 0;
1888 static Standard_Integer Pargc = 0;
1889 static const char** Pargv = NULL;
1892 static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
1897 if (!ViewerTest_myViews.IsEmpty()) {
1899 WPARAM fwKeys = wParam;
1904 // Delete view from map of views
1905 ViewerTest::RemoveView(FindViewIdByWindowHandle(hwnd));
1910 if(LOWORD(wParam) == WA_CLICKACTIVE || LOWORD(wParam) == WA_ACTIVE
1911 || ViewerTest::CurrentView().IsNull())
1913 // Activate inactive window
1914 if(GetWindowHandle(VT_GetWindow()) != hwnd)
1916 ActivateView (FindViewIdByWindowHandle(hwnd));
1923 HDC hdc = GetDC( hwnd );
1924 SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) );
1925 SetROP2( hdc, R2_NOT );
1926 Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion );
1927 ReleaseDC( hwnd, hdc );
1928 VT_ProcessButton1Release (fwKeys & MK_SHIFT);
1930 IsDragged = Standard_False;
1931 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1933 case WM_LBUTTONDOWN:
1934 if( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) )
1936 IsDragged = Standard_True;
1937 DragFirst = Standard_True;
1938 X_ButtonPress = LOWORD(lParam);
1939 Y_ButtonPress = HIWORD(lParam);
1941 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1948 HDC hdc = GetDC( hwnd );
1950 HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) );
1951 SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) );
1952 SetROP2( hdc, R2_NOT );
1955 Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion );
1957 DragFirst = Standard_False;
1958 X_Motion = LOWORD(lParam);
1959 Y_Motion = HIWORD(lParam);
1961 Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion );
1963 SelectObject( hdc, anObj );
1965 ReleaseDC( hwnd, hdc );
1968 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1972 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1976 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
1980 static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
1987 if ( !ViewerTest::CurrentView().IsNull() ) {
1992 BeginPaint(hwnd, &ps);
1993 EndPaint(hwnd, &ps);
1998 VT_ProcessConfigure();
2002 if ((wParam != VK_SHIFT) && (wParam != VK_CONTROL))
2005 c[0] = (char) wParam;
2007 if (wParam == VK_DELETE)
2009 c[0] = THE_KEY_DELETE;
2012 else if (wParam == VK_OEM_COMMA)
2017 else if (wParam == VK_OEM_PERIOD)
2021 VT_ProcessKeyPress (c);
2029 VT_ProcessButton3Release();
2032 case WM_LBUTTONDOWN:
2033 case WM_MBUTTONDOWN:
2034 case WM_RBUTTONDOWN:
2036 WPARAM fwKeys = wParam;
2040 X_ButtonPress = LOWORD(lParam);
2041 Y_ButtonPress = HIWORD(lParam);
2043 if (Msg == WM_LBUTTONDOWN)
2045 if (fwKeys & MK_CONTROL)
2047 Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT));
2051 VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT));
2054 else if (Msg == WM_RBUTTONDOWN)
2057 VT_ProcessButton3Press();
2064 //cout << "\t WM_MOUSEMOVE" << endl;
2065 WPARAM fwKeys = wParam;
2066 X_Motion = LOWORD(lParam);
2067 Y_Motion = HIWORD(lParam);
2070 fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON ) ) {
2072 X_ButtonPress = LOWORD(lParam);
2073 Y_ButtonPress = HIWORD(lParam);
2075 if ( fwKeys & MK_RBUTTON ) {
2077 VT_ProcessButton3Press();
2081 if ( fwKeys & MK_CONTROL ) {
2082 if ( fwKeys & MK_LBUTTON ) {
2083 ProcessControlButton1Motion();
2085 else if ( fwKeys & MK_MBUTTON ||
2086 ((fwKeys&MK_LBUTTON) &&
2087 (fwKeys&MK_RBUTTON) ) ){
2088 VT_ProcessControlButton2Motion();
2090 else if ( fwKeys & MK_RBUTTON ) {
2091 VT_ProcessControlButton3Motion();
2095 else if ( fwKeys & MK_SHIFT ) {
2096 if ( fwKeys & MK_MBUTTON ||
2097 ((fwKeys&MK_LBUTTON) &&
2098 (fwKeys&MK_RBUTTON) ) ) {
2099 cout << "ProcessZClipMotion()" << endl;
2100 ProcessZClipMotion();
2104 else if (GetWindowHandle (VT_GetWindow()) == hwnd)
2106 if ((fwKeys & MK_MBUTTON
2107 || ((fwKeys & MK_LBUTTON) && (fwKeys & MK_RBUTTON))))
2109 ProcessZClipMotion();
2120 return( DefWindowProc( hwnd, Msg, wParam, lParam ));
2125 return DefWindowProc( hwnd, Msg, wParam, lParam );
2131 //==============================================================================
2132 //function : ViewerMainLoop
2133 //purpose : Get a Event on the view and dispatch it
2134 //==============================================================================
2137 int ViewerMainLoop(Standard_Integer argc, const char** argv)
2139 Ppick = (argc > 0)? 1 : 0;
2147 cout << "Start picking" << endl;
2149 while ( Ppick == 1 ) {
2150 // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
2151 if (GetMessage(&msg, NULL, 0, 0) ) {
2152 TranslateMessage(&msg);
2153 DispatchMessage(&msg);
2157 cout << "Picking done" << endl;
2163 #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX)
2165 int min( int a, int b )
2173 int max( int a, int b )
2181 int ViewerMainLoop(Standard_Integer argc, const char** argv)
2184 static XEvent aReport;
2185 Standard_Boolean pick = argc > 0;
2186 Display *aDisplay = GetDisplayConnection()->GetDisplay();
2187 XNextEvent (aDisplay, &aReport);
2189 // Handle event for the chosen display connection
2190 switch (aReport.type) {
2193 if((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW))
2196 ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window));
2202 // Activate inactive view
2203 Window aWindow = GetWindowHandle(VT_GetWindow());
2204 if(aWindow != aReport.xfocus.window)
2206 ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window));
2215 case ConfigureNotify:
2217 VT_ProcessConfigure();
2226 XComposeStatus status_in_out;
2228 ret_len = XLookupString( ( XKeyEvent *)&aReport ,
2229 (char *) buf_ret , 10 ,
2230 &ks_ret , &status_in_out ) ;
2233 buf_ret[ret_len] = '\0' ;
2237 VT_ProcessKeyPress (buf_ret);
2243 X_ButtonPress = aReport.xbutton.x;
2244 Y_ButtonPress = aReport.xbutton.y;
2246 if (aReport.xbutton.button == Button1)
2248 if (aReport.xbutton.state & ControlMask)
2250 pick = VT_ProcessButton1Press (argc, argv, pick, (aReport.xbutton.state & ShiftMask));
2254 IsDragged = Standard_True;
2255 DragFirst = Standard_True;
2258 else if (aReport.xbutton.button == Button3)
2261 VT_ProcessButton3Press();
2271 Aspect_Handle aWindow = VT_GetWindow()->XWindow();
2272 GC gc = XCreateGC( aDisplay, aWindow, 0, 0 );
2273 XDrawRectangle( aDisplay, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) );
2276 Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
2277 if( aContext.IsNull() )
2279 cout << "The context is null. Please use vinit before createmesh" << endl;
2283 Standard_Boolean ShiftPressed = ( aReport.xbutton.state & ShiftMask );
2284 if( aReport.xbutton.button==1 )
2288 aContext->ShiftSelect();
2297 aContext->ShiftSelect( min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ),
2298 max( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ),
2299 ViewerTest::CurrentView());
2303 aContext->Select( min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ),
2304 max( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ),
2305 ViewerTest::CurrentView() );
2308 VT_ProcessButton3Release();
2310 IsDragged = Standard_False;
2313 VT_ProcessButton3Release();
2318 if (GetWindowHandle (VT_GetWindow()) != aReport.xmotion.window)
2324 Aspect_Handle aWindow = VT_GetWindow()->XWindow();
2325 GC gc = XCreateGC( aDisplay, aWindow, 0, 0 );
2326 XSetFunction( aDisplay, gc, GXinvert );
2329 XDrawRectangle(aDisplay, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) );
2331 X_Motion = aReport.xmotion.x;
2332 Y_Motion = aReport.xmotion.y;
2333 DragFirst = Standard_False;
2335 XDrawRectangle( aDisplay, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) );
2339 X_Motion = aReport.xmotion.x;
2340 Y_Motion = aReport.xmotion.y;
2342 // remove all the ButtonMotionMaskr
2343 while( XCheckMaskEvent( aDisplay, ButtonMotionMask, &aReport) ) ;
2345 if ( ZClipIsOn && aReport.xmotion.state & ShiftMask ) {
2346 if ( Abs(X_Motion - X_ButtonPress) > 2 ) {
2348 Quantity_Length VDX, VDY;
2350 ViewerTest::CurrentView()->Size(VDX,VDY);
2351 Standard_Real VDZ =0 ;
2352 VDZ = ViewerTest::CurrentView()->ZSize();
2354 printf("%f,%f,%f\n", VDX, VDY, VDZ);
2356 Quantity_Length dx = 0 ;
2357 dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress);
2361 dx = dx / VDX * VDZ;
2365 ViewerTest::CurrentView()->Redraw();
2369 if ( aReport.xmotion.state & ControlMask ) {
2370 if ( aReport.xmotion.state & Button1Mask ) {
2371 ProcessControlButton1Motion();
2373 else if ( aReport.xmotion.state & Button2Mask ) {
2374 VT_ProcessControlButton2Motion();
2376 else if ( aReport.xmotion.state & Button3Mask ) {
2377 VT_ProcessControlButton3Motion();
2391 //==============================================================================
2392 //function : VProcessEvents
2393 //purpose : call by Tk_CreateFileHandler() to be able to manage the
2394 // event in the Viewer window
2395 //==============================================================================
2397 static void VProcessEvents(ClientData,int)
2399 NCollection_Vector<int> anEventNumbers;
2400 // Get number of messages from every display
2401 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
2402 anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next())
2404 anEventNumbers.Append(XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()));
2406 // Handle events for every display
2407 int anEventIter = 0;
2408 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
2409 anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next(), anEventIter++)
2411 for (int i = 0; i < anEventNumbers.Value(anEventIter) &&
2412 XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()) > 0; ++i)
2414 SetDisplayConnection (anIter.Key2()->GetDisplayConnection());
2415 int anEventResult = ViewerMainLoop( 0, NULL);
2416 // If window is closed or context was not found finish current event processing loop
2422 SetDisplayConnection (ViewerTest::GetAISContext()->CurrentViewer()->Driver()->GetDisplayConnection());
2427 //==============================================================================
2428 //function : OSWindowSetup
2429 //purpose : Setup for the X11 window to be able to cath the event
2430 //==============================================================================
2433 static void OSWindowSetup()
2435 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
2438 Window window = VT_GetWindow()->XWindow();
2439 SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
2440 Display *aDisplay = GetDisplayConnection()->GetDisplay();
2441 XSynchronize(aDisplay, 1);
2443 // X11 : For keyboard on SUN
2445 wmhints.flags = InputHint;
2448 XSetWMHints( aDisplay, window, &wmhints);
2450 XSelectInput( aDisplay, window, ExposureMask | KeyPressMask |
2451 ButtonPressMask | ButtonReleaseMask |
2452 StructureNotifyMask |
2454 Button1MotionMask | Button2MotionMask |
2455 Button3MotionMask | FocusChangeMask
2457 Atom aDeleteWindowAtom = GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW);
2458 XSetWMProtocols(aDisplay, window, &aDeleteWindowAtom, 1);
2460 XSynchronize(aDisplay, 0);
2468 //==============================================================================
2471 //purpose : Fitall, no DRAW arguments
2472 //Draw arg : No args
2473 //==============================================================================
2475 static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgc, const char** theArgv)
2479 std::cout << "Wrong number of arguments! Use: vfit [-selected]" << std::endl;
2482 const Handle(V3d_View) aView = ViewerTest::CurrentView();
2486 TCollection_AsciiString anArg (theArgv[1]);
2488 if (anArg == "-selected")
2490 ViewerTest::GetAISContext()->FitSelected (aView);
2494 if (aView.IsNull() == Standard_False) {
2501 //=======================================================================
2502 //function : VFitArea
2503 //purpose : Fit view to show area located between two points
2504 // : given in world 2D or 3D coordinates.
2505 //=======================================================================
2506 static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
2508 Handle(V3d_View) aView = ViewerTest::CurrentView();
2511 std::cerr << theArgVec[0] << "Error: No active view.\n";
2516 gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0);
2517 gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0);
2521 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
2522 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
2523 aWorldPnt2.SetX (Draw::Atof (theArgVec[3]));
2524 aWorldPnt2.SetY (Draw::Atof (theArgVec[4]));
2526 else if (theArgNb == 7)
2528 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
2529 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
2530 aWorldPnt1.SetZ (Draw::Atof (theArgVec[3]));
2531 aWorldPnt2.SetX (Draw::Atof (theArgVec[4]));
2532 aWorldPnt2.SetY (Draw::Atof (theArgVec[5]));
2533 aWorldPnt2.SetZ (Draw::Atof (theArgVec[6]));
2537 std::cerr << theArgVec[0] << "Error: Invalid number of arguments.\n";
2538 theDI.PrintHelp(theArgVec[0]);
2542 // Convert model coordinates to view space
2543 Handle(Graphic3d_Camera) aCamera = aView->Camera();
2544 gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1);
2545 gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2);
2547 // Determine fit area
2548 gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y()));
2549 gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y()));
2551 Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner);
2553 if (aDiagonal < Precision::Confusion())
2555 std::cerr << theArgVec[0] << "Error: view area is too small.\n";
2559 aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y());
2563 //==============================================================================
2565 //purpose : ZFitall, no DRAW arguments
2566 //Draw arg : No args
2567 //==============================================================================
2568 static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
2570 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
2572 if (aCurrentView.IsNull())
2574 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
2580 aCurrentView->View()->ZFitAll();
2581 aCurrentView->Redraw();
2585 Standard_Real aScale = 1.0;
2589 aScale = Draw::Atoi (theArgVec[1]);
2592 aCurrentView->View()->ZFitAll (aScale);
2593 aCurrentView->Redraw();
2598 //==============================================================================
2599 //function : VRepaint
2601 //==============================================================================
2602 static int VRepaint (Draw_Interpretor& , Standard_Integer , const char** )
2604 Handle(V3d_View) V = ViewerTest::CurrentView();
2605 if ( !V.IsNull() ) V->Redraw(); return 0;
2608 //==============================================================================
2610 //purpose : Remove all the object from the viewer
2611 //Draw arg : No args
2612 //==============================================================================
2614 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
2616 Handle(V3d_View) V = ViewerTest::CurrentView();
2618 ViewerTest::Clear();
2622 //==============================================================================
2625 //==============================================================================
2627 static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2628 { if (ViewerTest::CurrentView().IsNull() ) return 1;
2631 di << argv[0] << "Invalid number of arguments" << "\n";
2635 while (ViewerMainLoop( argc, argv)) {
2641 //==============================================================================
2643 //purpose : Load image as background
2644 //==============================================================================
2646 static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2648 if (argc < 2 || argc > 3)
2650 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
2651 di << "filltype can be one of CENTERED, TILED, STRETCH, NONE" << "\n";
2655 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2656 if(AISContext.IsNull())
2658 di << "use 'vinit' command before " << argv[0] << "\n";
2662 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
2665 const char* szType = argv[2];
2666 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
2667 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
2668 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
2669 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
2672 di << "Wrong fill type : " << szType << "\n";
2673 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
2678 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2679 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
2684 //==============================================================================
2685 //function : VSetBgMode
2686 //purpose : Change background image fill type
2687 //==============================================================================
2689 static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2693 di << "Usage : " << argv[0] << " filltype : Change background image mode" << "\n";
2694 di << "filltype must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
2698 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2699 if(AISContext.IsNull())
2701 di << "use 'vinit' command before " << argv[0] << "\n";
2704 Aspect_FillMethod aFillType = Aspect_FM_NONE;
2705 const char* szType = argv[1];
2706 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
2707 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
2708 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
2709 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
2712 di << "Wrong fill type : " << szType << "\n";
2713 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
2716 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2717 V3dView->SetBgImageStyle(aFillType, Standard_True);
2721 //==============================================================================
2722 //function : VSetGradientBg
2723 //purpose : Mount gradient background
2724 //==============================================================================
2725 static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2729 di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background" << "\n";
2730 di << "R1,G1,B1,R2,G2,B2 = [0..255]" << "\n";
2731 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
2732 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
2736 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2737 if(AISContext.IsNull())
2739 di << "use 'vinit' command before " << argv[0] << "\n";
2745 Standard_Real R1 = Draw::Atof(argv[1])/255.;
2746 Standard_Real G1 = Draw::Atof(argv[2])/255.;
2747 Standard_Real B1 = Draw::Atof(argv[3])/255.;
2748 Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB);
2750 Standard_Real R2 = Draw::Atof(argv[4])/255.;
2751 Standard_Real G2 = Draw::Atof(argv[5])/255.;
2752 Standard_Real B2 = Draw::Atof(argv[6])/255.;
2754 Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB);
2755 int aType = Draw::Atoi(argv[7]);
2756 if( aType < 0 || aType > 8 )
2758 di << "Wrong fill type " << "\n";
2759 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
2760 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
2764 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
2766 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2767 V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1);
2773 //==============================================================================
2774 //function : VSetGradientBgMode
2775 //purpose : Change gradient background fill style
2776 //==============================================================================
2777 static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2781 di << "Usage : " << argv[0] << " Type : Change gradient background fill type" << "\n";
2782 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
2783 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
2787 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2788 if(AISContext.IsNull())
2790 di << "use 'vinit' command before " << argv[0] << "\n";
2795 int aType = Draw::Atoi(argv[1]);
2796 if( aType < 0 || aType > 8 )
2798 di << "Wrong fill type " << "\n";
2799 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
2800 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
2804 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
2806 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2807 V3dView->SetBgGradientStyle( aMethod, 1 );
2813 //==============================================================================
2814 //function : VSetColorBg
2815 //purpose : Set color background
2816 //==============================================================================
2817 static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2821 di << "Usage : " << argv[0] << " R G B : Set color background" << "\n";
2822 di << "R,G,B = [0..255]" << "\n";
2826 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2827 if(AISContext.IsNull())
2829 di << "use 'vinit' command before " << argv[0] << "\n";
2835 Standard_Real R = Draw::Atof(argv[1])/255.;
2836 Standard_Real G = Draw::Atof(argv[2])/255.;
2837 Standard_Real B = Draw::Atof(argv[3])/255.;
2838 Quantity_Color aColor(R,G,B,Quantity_TOC_RGB);
2840 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2841 V3dView->SetBackgroundColor( aColor );
2848 //==============================================================================
2850 //purpose : View Scaling
2851 //==============================================================================
2853 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2855 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
2856 if ( V3dView.IsNull() ) return 1;
2859 di << argv[0] << "Invalid number of arguments" << "\n";
2862 V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
2865 //==============================================================================
2866 //function : VZBuffTrihedron
2868 //==============================================================================
2870 static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
2871 Standard_Integer theArgNb,
2872 const char** theArgVec)
2874 Handle(V3d_View) aView = ViewerTest::CurrentView();
2877 std::cout << "Error: no active viewer!\n";
2881 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
2883 Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER;
2884 V3d_TypeOfVisualization aVisType = V3d_ZBUFFER;
2885 Quantity_Color aLabelsColor = Quantity_NOC_WHITE;
2886 Quantity_Color anArrowColorX = Quantity_NOC_RED;
2887 Quantity_Color anArrowColorY = Quantity_NOC_GREEN;
2888 Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1;
2889 Standard_Real aScale = 0.1;
2890 Standard_Real aSizeRatio = 0.8;
2891 Standard_Real anArrowDiam = 0.05;
2892 Standard_Integer aNbFacets = 12;
2893 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
2895 Standard_CString anArg = theArgVec[anArgIter];
2896 TCollection_AsciiString aFlag (anArg);
2898 if (anUpdateTool.parseRedrawMode (aFlag))
2902 else if (aFlag == "-on")
2906 else if (aFlag == "-off")
2908 aView->TriedronErase();
2911 else if (aFlag == "-pos"
2912 || aFlag == "-position"
2913 || aFlag == "-corner")
2915 if (++anArgIter >= theArgNb)
2917 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
2921 TCollection_AsciiString aPosName (theArgVec[anArgIter]);
2922 aPosName.LowerCase();
2923 if (aPosName == "center")
2925 aPosition = Aspect_TOTP_CENTER;
2927 else if (aPosName == "left_lower"
2928 || aPosName == "lower_left"
2929 || aPosName == "leftlower"
2930 || aPosName == "lowerleft")
2932 aPosition = Aspect_TOTP_LEFT_LOWER;
2934 else if (aPosName == "left_upper"
2935 || aPosName == "upper_left"
2936 || aPosName == "leftupper"
2937 || aPosName == "upperleft")
2939 aPosition = Aspect_TOTP_LEFT_UPPER;
2941 else if (aPosName == "right_lower"
2942 || aPosName == "lower_right"
2943 || aPosName == "rightlower"
2944 || aPosName == "lowerright")
2946 aPosition = Aspect_TOTP_RIGHT_LOWER;
2948 else if (aPosName == "right_upper"
2949 || aPosName == "upper_right"
2950 || aPosName == "rightupper"
2951 || aPosName == "upperright")
2953 aPosition = Aspect_TOTP_RIGHT_UPPER;
2957 std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'\n";
2961 else if (aFlag == "-type")
2963 if (++anArgIter >= theArgNb)
2965 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
2969 TCollection_AsciiString aTypeName (theArgVec[anArgIter]);
2970 aTypeName.LowerCase();
2971 if (aTypeName == "wireframe"
2972 || aTypeName == "wire")
2974 aVisType = V3d_WIREFRAME;
2976 else if (aTypeName == "zbuffer"
2977 || aTypeName == "shaded")
2979 aVisType = V3d_ZBUFFER;
2983 std::cerr << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'\n";
2986 else if (aFlag == "-scale")
2988 if (++anArgIter >= theArgNb)
2990 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
2994 aScale = Draw::Atof (theArgVec[anArgIter]);
2996 else if (aFlag == "-size"
2997 || aFlag == "-sizeratio")
2999 if (++anArgIter >= theArgNb)
3001 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3005 aSizeRatio = Draw::Atof (theArgVec[anArgIter]);
3007 else if (aFlag == "-arrowdiam"
3008 || aFlag == "-arrowdiameter")
3010 if (++anArgIter >= theArgNb)
3012 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3016 anArrowDiam = Draw::Atof (theArgVec[anArgIter]);
3018 else if (aFlag == "-nbfacets")
3020 if (++anArgIter >= theArgNb)
3022 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3026 aNbFacets = Draw::Atoi (theArgVec[anArgIter]);
3028 else if (aFlag == "-colorlabel"
3029 || aFlag == "-colorlabels")
3031 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3032 theArgVec + anArgIter + 1,
3036 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3039 anArgIter += aNbParsed;
3041 else if (aFlag == "-colorarrowx")
3043 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3044 theArgVec + anArgIter + 1,
3048 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3051 anArgIter += aNbParsed;
3053 else if (aFlag == "-colorarrowy")
3055 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3056 theArgVec + anArgIter + 1,
3060 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3063 anArgIter += aNbParsed;
3065 else if (aFlag == "-colorarrowz")
3067 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
3068 theArgVec + anArgIter + 1,
3072 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3075 anArgIter += aNbParsed;
3079 std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
3084 aView->ZBufferTriedronSetup (anArrowColorX.Name(), anArrowColorY.Name(), anArrowColorZ.Name(),
3085 aSizeRatio, anArrowDiam, aNbFacets);
3086 aView->TriedronDisplay (aPosition, aLabelsColor.Name(), aScale, aVisType);
3087 aView->View()->ZFitAll();
3091 //==============================================================================
3092 //function : VRotate
3093 //purpose : Camera Rotating
3094 //==============================================================================
3096 static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
3098 Handle(V3d_View) aView = ViewerTest::CurrentView();
3101 std::cout << "No active view!\n";
3105 Standard_Boolean hasFlags = Standard_False;
3106 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3108 Standard_CString anArg (theArgVec[anArgIter]);
3109 TCollection_AsciiString aFlag (anArg);
3111 if (aFlag == "-mousestart"
3112 || aFlag == "-mousefrom")
3114 hasFlags = Standard_True;
3115 if (anArgIter + 2 >= theArgNb)
3117 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3121 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
3122 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
3123 aView->StartRotation (anX, anY);
3125 else if (aFlag == "-mousemove")
3127 hasFlags = Standard_True;
3128 if (anArgIter + 2 >= theArgNb)
3130 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3134 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
3135 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
3136 aView->Rotation (anX, anY);
3138 else if (theArgNb != 4
3141 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
3150 else if (theArgNb == 4)
3152 Standard_Real anAX = Draw::Atof (theArgVec[1]);
3153 Standard_Real anAY = Draw::Atof (theArgVec[2]);
3154 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
3155 aView->Rotate (anAX, anAY, anAZ);
3158 else if (theArgNb == 7)
3160 Standard_Real anAX = Draw::Atof (theArgVec[1]);
3161 Standard_Real anAY = Draw::Atof (theArgVec[2]);
3162 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
3164 Standard_Real anX = Draw::Atof (theArgVec[4]);
3165 Standard_Real anY = Draw::Atof (theArgVec[5]);
3166 Standard_Real anZ = Draw::Atof (theArgVec[6]);
3168 aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ);
3172 std::cout << "Error: Invalid number of arguments\n";
3176 //==============================================================================
3178 //purpose : View zoom in / out (relative to current zoom)
3179 //==============================================================================
3181 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3182 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3183 if ( V3dView.IsNull() ) {
3188 Standard_Real coef = Draw::Atof(argv[1]);
3189 if ( coef <= 0.0 ) {
3190 di << argv[1] << "Invalid value" << "\n";
3193 V3dView->SetZoom( Draw::Atof(argv[1]) );
3196 di << argv[0] << " Invalid number of arguments" << "\n";
3201 //==============================================================================
3203 //purpose : View panning (in pixels)
3204 //==============================================================================
3206 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3207 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3208 if ( V3dView.IsNull() ) return 1;
3211 V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) );
3214 di << argv[0] << " Invalid number of arguments" << "\n";
3219 //==============================================================================
3221 //purpose : Place the point (in pixels) at the center of the window
3222 //==============================================================================
3223 static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs)
3225 Handle(V3d_View) aView = ViewerTest::CurrentView();
3228 std::cerr << theArgs[0] << "Error: no active view." << std::endl;
3234 std::cerr << theArgs[0] << "Error: invalid number of arguments." << std::endl;
3238 aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale());
3243 //==============================================================================
3244 //function : VExport
3245 //purpose : Export the view to a vector graphic format (PS, EMF, PDF)
3246 //==============================================================================
3248 static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3250 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3251 if (V3dView.IsNull())
3256 std::cout << "Usage: " << argv[0] << " Filename [Format]\n";
3260 Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF;
3261 TCollection_AsciiString aFormatStr;
3263 TCollection_AsciiString aFileName (argv[1]);
3264 Standard_Integer aLen = aFileName.Length();
3268 aFormatStr = TCollection_AsciiString (argv[2]);
3272 if (aFileName.Value (aLen - 2) == '.')
3274 aFormatStr = aFileName.SubString (aLen - 1, aLen);
3276 else if (aFileName.Value (aLen - 3) == '.')
3278 aFormatStr = aFileName.SubString (aLen - 2, aLen);
3282 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
3288 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
3292 aFormatStr.UpperCase();
3293 if (aFormatStr == "PS")
3294 anExpFormat = Graphic3d_EF_PostScript;
3295 else if (aFormatStr == "EPS")
3296 anExpFormat = Graphic3d_EF_EnhPostScript;
3297 else if (aFormatStr == "TEX")
3298 anExpFormat = Graphic3d_EF_TEX;
3299 else if (aFormatStr == "PDF")
3300 anExpFormat = Graphic3d_EF_PDF;
3301 else if (aFormatStr == "SVG")
3302 anExpFormat = Graphic3d_EF_SVG;
3303 else if (aFormatStr == "PGF")
3304 anExpFormat = Graphic3d_EF_PGF;
3305 else if (aFormatStr == "EMF")
3306 anExpFormat = Graphic3d_EF_EMF;
3309 std::cout << "Invalid export format '" << aFormatStr << "'\n";
3314 if (!V3dView->View()->Export (argv[1], anExpFormat))
3316 di << "Error: export of image to " << aFormatStr << " failed!\n";
3319 catch (Standard_Failure)
3321 di << "Error: export of image to " << aFormatStr << " failed";
3322 di << " (exception: " << Standard_Failure::Caught()->GetMessageString() << ")";
3327 //==============================================================================
3328 //function : VColorScale
3329 //purpose : representation color scale
3330 //==============================================================================
3332 static Standard_Boolean checkColor (const TCollection_AsciiString& theRed,
3333 const TCollection_AsciiString& theGreen,
3334 const TCollection_AsciiString& theBlue,
3335 Standard_Real& theRedValue,
3336 Standard_Real& theGreenValue,
3337 Standard_Real& theBlueValue)
3339 if (!theRed.IsRealValue()
3340 || !theGreen.IsRealValue()
3341 || !theBlue.IsRealValue())
3343 std::cout << "Error: RGB color values should be real!\n";
3344 return Standard_True;
3346 theRedValue = theRed .RealValue();
3347 theGreenValue = theGreen.RealValue();
3348 theBlueValue = theBlue .RealValue();
3349 if (theRedValue < 0.0 || theRedValue > 1.0
3350 || theGreenValue < 0.0 || theGreenValue > 1.0
3351 || theBlueValue < 0.0 || theBlueValue > 1.0)
3353 std::cout << "Error: RGB color values should be within range 0..1!\n";
3354 return Standard_True;
3356 return Standard_False;
3359 static int VColorScale (Draw_Interpretor& theDI,
3360 Standard_Integer theArgNb,
3361 const char** theArgVec)
3363 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3364 Handle(V3d_View) aView = ViewerTest::CurrentView();
3365 if (aContext.IsNull())
3367 std::cout << "Error: no active view!\n";
3371 Handle(V3d_ColorScale) aCS = Handle(V3d_ColorScale)::DownCast (aView->ColorScale());
3374 std::cout << "Error: color scale is undefined!\n";
3378 Standard_Real aMinRange = aCS->GetMin();
3379 Standard_Real aMaxRange = aCS->GetMax();
3380 Standard_Integer aNbIntervals = aCS->GetNumberOfIntervals();
3381 Standard_Integer aTextHeight = aCS->GetTextHeight();
3382 Aspect_TypeOfColorScalePosition aLabPosition = aCS->GetLabelPosition();
3383 gp_XY aPos (aCS->GetXPosition(), aCS->GetYPosition());
3385 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
3389 theDI << "Current color scale parameters:\n"
3390 << "Min range: " << aMinRange << "\n"
3391 << "Max range: " << aMaxRange << "\n"
3392 << "Number of intervals: " << aNbIntervals << "\n"
3393 << "Text height: " << aTextHeight << "\n"
3394 << "Color scale position: " << aPos.X() <<" "<< aPos.Y()<< "\n"
3395 << "Color scale title: " << aCS->GetTitle() << "\n"
3396 << "Label position: ";
3397 switch (aLabPosition)
3399 case Aspect_TOCSP_NONE:
3402 case Aspect_TOCSP_LEFT:
3405 case Aspect_TOCSP_RIGHT:
3408 case Aspect_TOCSP_CENTER:
3409 theDI << "Center\n";
3414 Standard_CString aFirstArg = theArgVec[1];
3415 TCollection_AsciiString aFlag (aFirstArg);
3417 if (aFlag == "-hide" ||
3422 std::cout << "Error: wrong syntax at argument '" << theArgVec[1] << "'!\n";
3425 if (!aView->ColorScaleIsDisplayed())
3427 std::cout << "Error: color scale is not displayed!\n";
3432 aView->ColorScaleErase();
3436 else if (aFlag == "-show" ||
3437 aFlag == "-display")
3441 std::cout << "Error: wrong syntax at argument '" << theArgVec[1] << "'!\n";
3444 aView->ColorScaleDisplay();
3448 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3450 Standard_CString anArg = theArgVec[anArgIter];
3451 TCollection_AsciiString aFlag (anArg);
3453 if (anUpdateTool.parseRedrawMode (aFlag))
3457 else if (aFlag == "-range")
3459 if (anArgIter + 3 >= theArgNb)
3461 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3465 TCollection_AsciiString anArg1 (theArgVec[++anArgIter]);
3466 TCollection_AsciiString anArg2 (theArgVec[++anArgIter]);
3467 TCollection_AsciiString anArg3 (theArgVec[++anArgIter]);
3468 if (!anArg1.IsRealValue())
3470 std::cout << "Error: the minRange value should be real!\n";
3473 else if (!anArg2.IsRealValue())
3475 std::cout << "Error: the maxRange value should be real!\n";
3478 else if (!anArg3.IsIntegerValue())
3480 std::cout << "Error: the number of intervals should be integer!\n";
3484 aMinRange = anArg1.RealValue();
3485 aMaxRange = anArg2.RealValue();
3486 aNbIntervals = anArg3.IntegerValue();
3488 else if (aFlag == "-font")
3490 if (anArgIter + 1 >= theArgNb)
3492 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3495 TCollection_AsciiString anArg (theArgVec[anArgIter + 1]);
3496 if (!anArg.IsIntegerValue())
3498 std::cout << "Error: HeightFont value should be integer!\n";
3502 aTextHeight = anArg.IntegerValue();
3505 else if (aFlag == "-textpos")
3507 if (anArgIter + 1 >= theArgNb)
3509 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3512 TCollection_AsciiString anArg (theArgVec[++anArgIter]);
3514 if (anArg == "none")
3516 aLabPosition = Aspect_TOCSP_NONE;
3518 else if (anArg == "left")
3520 aLabPosition = Aspect_TOCSP_LEFT;
3522 else if (anArg == "right")
3524 aLabPosition = Aspect_TOCSP_RIGHT;
3526 else if (anArg == "center")
3528 aLabPosition = Aspect_TOCSP_CENTER;
3532 std::cout << "Error: unknown position '" << anArg << "'!\n";
3536 else if (aFlag == "-xy")
3538 if (anArgIter + 2 >= theArgNb)
3540 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3544 TCollection_AsciiString aX (theArgVec[++anArgIter]);
3545 TCollection_AsciiString aY (theArgVec[++anArgIter]);
3546 if (!aX.IsRealValue()
3547 || !aY.IsRealValue())
3549 std::cout << "Error: coordinates should be real values!\n";
3553 aPos.SetCoord (aX.RealValue(), aY.RealValue());
3555 else if (aFlag == "-color")
3557 if (aCS->GetColorType() != Aspect_TOCSD_USER)
3559 std::cout << "Error: wrong color type! Call -colors before to set user-specified colors!\n";
3563 Quantity_NameOfColor aColorName;
3564 if (anArgIter + 4 >= theArgNb)
3566 if (anArgIter + 2 >= theArgNb)
3568 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3571 else if (!Quantity_Color::ColorFromName (theArgVec[anArgIter + 2], aColorName))
3573 std::cout << "Error: wrong color name: '" << theArgVec[anArgIter + 2] << "' !\n";
3578 TCollection_AsciiString anInd (theArgVec[anArgIter + 1]);
3579 if (!anInd.IsIntegerValue())
3581 std::cout << "Error: Index value should be integer!\n";
3585 Standard_Integer anIndex = anInd.IntegerValue();
3587 || anIndex > aNbIntervals - 1)
3589 std::cout << "Error: Index value should be within range 0..." << (aNbIntervals - 1) <<"!\n";
3593 if (Quantity_Color::ColorFromName (theArgVec[anArgIter + 2], aColorName))
3595 aCS->SetColor (Quantity_Color (aColorName), anIndex);
3596 aCS->SetColorType(Aspect_TOCSD_USER);
3601 TCollection_AsciiString aRed (theArgVec[anArgIter + 2]);
3602 TCollection_AsciiString aGreen (theArgVec[anArgIter + 3]);
3603 TCollection_AsciiString aBlue (theArgVec[anArgIter + 4]);
3604 Standard_Real aRedValue,aGreenValue, aBlueValue;
3605 if(checkColor (aRed, aGreen, aBlue, aRedValue, aGreenValue, aBlueValue))
3609 aCS->SetColor (Quantity_Color (aRedValue, aGreenValue, aBlueValue, Quantity_TOC_RGB), anIndex);
3610 aCS->SetColorType (Aspect_TOCSD_USER);
3613 else if (aFlag == "-label")
3615 if (aCS->GetColorType() != Aspect_TOCSD_USER)
3617 std::cout << "Error: wrong label type! Call -labels before to set user-specified labels!\n";
3620 else if (anArgIter + 2 >= theArgNb)
3622 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3626 Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]);
3628 || anIndex > aNbIntervals)
3630 std::cout << "Error: Index value should be within range 0..." << aNbIntervals <<"!\n";
3634 TCollection_ExtendedString aText (theArgVec[anArgIter + 2]);
3635 aCS->SetLabel (aText, anIndex);
3636 aCS->SetLabelType (Aspect_TOCSD_USER);
3639 else if (aFlag == "-colors")
3641 Aspect_SequenceOfColor aSeq;
3642 if (anArgIter + aNbIntervals + 1 > theArgNb)
3644 std::cout << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the "
3645 << aNbIntervals << " intervals\n";
3649 Standard_Integer aColorIter = anArgIter + 1;
3650 while (aColorIter < theArgNb)
3652 if (theArgVec[aColorIter][0] == '-')
3657 else if (theArgVec[aColorIter][0] >= 97
3658 && theArgVec[aColorIter][0] <= 122)
3660 Quantity_NameOfColor aColorName;
3661 if (!Quantity_Color::ColorFromName (theArgVec[aColorIter], aColorName))
3663 std::cout << "Error: wrong color name: " << theArgVec[aColorIter] << " !\n";
3666 aSeq.Append (Quantity_Color (aColorName));
3672 TCollection_AsciiString aRed (theArgVec[aColorIter]);
3673 TCollection_AsciiString aGreen (theArgVec[aColorIter + 1]);
3674 TCollection_AsciiString aBlue (theArgVec[aColorIter + 2]);
3675 Standard_Real aRedValue,aGreenValue, aBlueValue;
3676 if (checkColor (aRed, aGreen, aBlue, aRedValue, aGreenValue, aBlueValue))
3680 aSeq.Append (Quantity_Color (aRedValue, aGreenValue, aBlueValue, Quantity_TOC_RGB));
3685 if (aSeq.Length() < aNbIntervals)
3687 std::cout << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the "
3688 << aNbIntervals << " intervals\n";
3692 aCS->SetColors (aSeq);
3693 aCS->SetColorType (Aspect_TOCSD_USER);
3695 else if (aFlag == "-labels")
3697 if (anArgIter + aNbIntervals + 1 >= theArgNb)
3699 std::cout << "Error: not enough arguments! You should provide " << (aNbIntervals + 1)
3700 << " text labels for " << aNbIntervals << " intervals.\n";
3704 TColStd_SequenceOfExtendedString aSeq;
3705 for (int aLabelIter = anArgIter + 1; aLabelIter <= anArgIter + aNbIntervals + 1; aLabelIter += 1)
3707 aSeq.Append (TCollection_ExtendedString (theArgVec[aLabelIter]));
3709 aCS->SetLabels (aSeq);
3710 aCS->SetLabelType (Aspect_TOCSD_USER);
3711 anArgIter += aSeq.Length();
3713 else if (aFlag == "-title")
3715 if (anArgIter + 1 >= theArgNb)
3717 std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
3721 Standard_Boolean isTwoArgs = Standard_False;
3722 if (anArgIter + 2 < theArgNb)
3724 TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]);
3725 aSecondArg.LowerCase();
3726 if (aSecondArg == "none")
3728 aCS->SetTitlePosition (Aspect_TOCSP_NONE);
3729 isTwoArgs = Standard_True;
3731 else if (aSecondArg == "left")
3733 aCS->SetTitlePosition (Aspect_TOCSP_LEFT);
3734 isTwoArgs = Standard_True;
3736 else if (aSecondArg == "right")
3738 aCS->SetTitlePosition (Aspect_TOCSP_RIGHT);
3739 isTwoArgs = Standard_True;
3741 else if (aSecondArg == "center")
3743 aCS->SetTitlePosition (Aspect_TOCSP_CENTER);
3744 isTwoArgs = Standard_True;
3748 aCS->SetTitle (theArgVec[anArgIter + 1]);
3755 else if (aFlag == "-demoversion"
3756 || aFlag == "-demo")
3758 aPos.SetCoord (0.0, 0.0);
3763 aLabPosition = Aspect_TOCSP_RIGHT;
3764 aCS->SetColorType(Aspect_TOCSD_AUTO);
3765 aCS->SetLabelType(Aspect_TOCSD_AUTO);
3769 std::cout << "Error: wrong syntax at " << anArg << " - unknown argument!\n";
3774 aCS->SetPosition (aPos.X(), aPos.Y());
3775 aCS->SetHeight (0.95);
3776 aCS->SetTextHeight (aTextHeight);
3777 aCS->SetRange (aMinRange, aMaxRange);
3778 aCS->SetNumberOfIntervals (aNbIntervals);
3779 aCS->SetLabelPosition (aLabPosition);
3781 if (!aView->ColorScaleIsDisplayed())
3783 aView->ColorScaleDisplay();
3789 //==============================================================================
3790 //function : VGraduatedTrihedron
3791 //purpose : Displays or hides a graduated trihedron
3792 //==============================================================================
3793 static Standard_Boolean GetColor (const TCollection_AsciiString& theValue,
3794 Quantity_Color& theColor)
3796 Quantity_NameOfColor aColorName;
3797 TCollection_AsciiString aVal = theValue;
3799 if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName))
3801 return Standard_False;
3803 theColor = Quantity_Color (aColorName);
3804 return Standard_True;
3807 static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs)
3811 std::cout << theArgs[0] << " error: wrong number of parameters. Type 'help"
3812 << theArgs[0] <<"' for more information.\n";
3813 return 1; //TCL_ERROR
3816 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
3817 TCollection_AsciiString aParseKey;
3818 for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt)
3820 TCollection_AsciiString anArg (theArgs [anArgIt]);
3822 if (anArg.Value (1) == '-' && !anArg.IsRealValue())
3825 aParseKey.Remove (1);
3826 aParseKey.LowerCase();
3827 aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
3831 if (aParseKey.IsEmpty())
3836 aMapOfArgs(aParseKey)->Append (anArg);
3840 for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
3841 aMapIt.More(); aMapIt.Next())
3843 const TCollection_AsciiString& aKey = aMapIt.Key();
3844 const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
3846 // Bool key, without arguments
3847 if ((aKey.IsEqual ("on") || aKey.IsEqual ("off"))
3848 && anArgs->IsEmpty())
3854 if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname"))
3855 && anArgs->Length() == 1)
3861 if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname")
3862 || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks")
3863 || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues")
3864 || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes"))
3865 && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off")))
3870 // One string argument
3871 if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor")
3872 || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor"))
3873 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
3878 // One integer argument
3879 if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks")
3880 || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength")
3881 || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset")
3882 || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset"))
3883 && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue())
3888 // One real argument
3889 if ( aKey.IsEqual ("arrowlength")
3890 && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue()))
3895 // Two string arguments
3896 if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont"))
3897 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
3902 TCollection_AsciiString aLowerKey;
3905 aLowerKey.LowerCase();
3906 std::cout << theArgs[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n";
3907 std::cout << "Type help for more information.\n";
3911 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3912 if (anAISContext.IsNull())
3914 std::cout << theArgs[0] << ": " << " please use 'vinit' command to initialize view.\n";
3918 Standard_Boolean toDisplay = Standard_True;
3919 Quantity_Color aColor;
3920 Graphic3d_GraduatedTrihedron aTrihedronData;
3921 // Process parameters
3922 Handle(TColStd_HSequenceOfAsciiString) aValues;
3923 if (aMapOfArgs.Find ("off", aValues))
3925 toDisplay = Standard_False;
3929 if (aMapOfArgs.Find ("xname", aValues))
3931 aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1));
3933 if (aMapOfArgs.Find ("yname", aValues))
3935 aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1));
3937 if (aMapOfArgs.Find ("zname", aValues))
3939 aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1));
3941 if (aMapOfArgs.Find ("xdrawname", aValues))
3943 aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
3945 if (aMapOfArgs.Find ("ydrawname", aValues))
3947 aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
3949 if (aMapOfArgs.Find ("zdrawname", aValues))
3951 aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
3953 if (aMapOfArgs.Find ("xnameoffset", aValues))
3955 aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
3957 if (aMapOfArgs.Find ("ynameoffset", aValues))
3959 aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
3961 if (aMapOfArgs.Find ("znameoffset", aValues))
3963 aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
3967 if (aMapOfArgs.Find ("xnamecolor", aValues))
3969 if (!GetColor (aValues->Value(1), aColor))
3971 std::cout << theArgs[0] << "error: -xnamecolor wrong color name.\n";
3974 aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor);
3976 if (aMapOfArgs.Find ("ynamecolor", aValues))
3978 if (!GetColor (aValues->Value(1), aColor))
3980 std::cout << theArgs[0] << "error: -ynamecolor wrong color name.\n";
3983 aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor);
3985 if (aMapOfArgs.Find ("znamecolor", aValues))
3987 if (!GetColor (aValues->Value(1), aColor))
3989 std::cout << theArgs[0] << "error: -znamecolor wrong color name.\n";
3992 aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor);
3994 if (aMapOfArgs.Find ("xcolor", aValues))
3996 if (!GetColor (aValues->Value(1), aColor))
3998 std::cout << theArgs[0] << "error: -xcolor wrong color name.\n";
4001 aTrihedronData.ChangeXAxisAspect().SetColor (aColor);
4003 if (aMapOfArgs.Find ("ycolor", aValues))
4005 if (!GetColor (aValues->Value(1), aColor))
4007 std::cout << theArgs[0] << "error: -ycolor wrong color name.\n";
4010 aTrihedronData.ChangeYAxisAspect().SetColor (aColor);
4012 if (aMapOfArgs.Find ("zcolor", aValues))
4014 if (!GetColor (aValues->Value(1), aColor))
4016 std::cout << theArgs[0] << "error: -zcolor wrong color name.\n";
4019 aTrihedronData.ChangeZAxisAspect().SetColor (aColor);
4023 if (aMapOfArgs.Find ("xticks", aValues))
4025 aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4027 if (aMapOfArgs.Find ("yticks", aValues))
4029 aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4031 if (aMapOfArgs.Find ("zticks", aValues))
4033 aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
4035 if (aMapOfArgs.Find ("xticklength", aValues))
4037 aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4039 if (aMapOfArgs.Find ("yticklength", aValues))
4041 aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4043 if (aMapOfArgs.Find ("zticklength", aValues))
4045 aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
4047 if (aMapOfArgs.Find ("xdrawticks", aValues))
4049 aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4051 if (aMapOfArgs.Find ("ydrawticks", aValues))
4053 aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4055 if (aMapOfArgs.Find ("zdrawticks", aValues))
4057 aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
4061 if (aMapOfArgs.Find ("xdrawvalues", aValues))
4063 aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4065 if (aMapOfArgs.Find ("ydrawvalues", aValues))
4067 aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4069 if (aMapOfArgs.Find ("zdrawvalues", aValues))
4071 aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
4073 if (aMapOfArgs.Find ("xvaluesoffset", aValues))
4075 aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4077 if (aMapOfArgs.Find ("yvaluesoffset", aValues))
4079 aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4081 if (aMapOfArgs.Find ("zvaluesoffset", aValues))
4083 aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
4087 if (aMapOfArgs.Find ("arrowlength", aValues))
4089 aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue());
4093 if (aMapOfArgs.Find ("namefont", aValues))
4095 aTrihedronData.SetNamesFont (aValues->Value(1));
4097 if (aMapOfArgs.Find ("valuesfont", aValues))
4099 aTrihedronData.SetValuesFont (aValues->Value(1));
4102 if (aMapOfArgs.Find ("drawgrid", aValues))
4104 aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on"));
4106 if (aMapOfArgs.Find ("drawaxes", aValues))
4108 aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on"));
4111 // The final step: display of erase trihedron
4114 ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData);
4118 ViewerTest::CurrentView()->GraduatedTrihedronErase();
4121 ViewerTest::GetAISContext()->UpdateCurrentViewer();
4122 ViewerTest::CurrentView()->Redraw();
4127 //==============================================================================
4128 //function : VPrintView
4129 //purpose : Test printing algorithm, print the view to image file with given
4130 // width and height. Printing implemented only for WNT.
4131 //==============================================================================
4132 static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
4136 di << "Printing implemented only for wnt!\n";
4140 Handle(AIS_InteractiveContext) aContextAIS = NULL;
4141 Handle(V3d_View) aView = NULL;
4142 aContextAIS = ViewerTest::GetAISContext();
4143 if (!aContextAIS.IsNull())
4145 const Handle(V3d_Viewer)& Vwr = aContextAIS->CurrentViewer();
4146 Vwr->InitActiveViews();
4147 if(Vwr->MoreActiveViews())
4148 aView = Vwr->ActiveView();
4154 di << "Call vinit before!\n";
4159 di << "Use: " << argv[0];
4160 di << " width height filename [print algo=0] [tile_width tile_height]\n";
4161 di << "width, height of the intermediate buffer for operation\n";
4162 di << "algo : {0|1}\n";
4163 di << " 0 - stretch algorithm\n";
4164 di << " 1 - tile algorithm\n";
4165 di << "test printing algorithms into an intermediate buffer\n";
4166 di << "using specific tile size if provided\n";
4167 di << "with saving output to an image file\n";
4171 // get the input params
4172 Standard_Integer aWidth = Draw::Atoi (argv[1]);
4173 Standard_Integer aHeight = Draw::Atoi (argv[2]);
4174 Standard_Integer aMode = 0;
4175 TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]);
4177 aMode = Draw::Atoi (argv[4]);
4179 Standard_Integer aTileWidth = 0;
4180 Standard_Integer aTileHeight = 0;
4181 Standard_Boolean isTileSizeProvided = Standard_False;
4184 isTileSizeProvided = Standard_True;
4185 aTileWidth = Draw::Atoi (argv[5]);
4186 aTileHeight = Draw::Atoi (argv[6]);
4189 // check the input parameters
4190 if (aWidth <= 0 || aHeight <= 0)
4192 di << "Width and height must be positive values!\n";
4195 if (aMode != 0 && aMode != 1)
4198 // define compatible bitmap
4199 HDC anDC = CreateCompatibleDC(0);
4200 BITMAPINFO aBitmapData;
4201 memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER));
4202 aBitmapData.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
4203 aBitmapData.bmiHeader.biWidth = aWidth ;
4204 aBitmapData.bmiHeader.biHeight = aHeight;
4205 aBitmapData.bmiHeader.biPlanes = 1;
4206 aBitmapData.bmiHeader.biBitCount = 24;
4207 aBitmapData.bmiHeader.biXPelsPerMeter = 0;
4208 aBitmapData.bmiHeader.biYPelsPerMeter = 0;
4209 aBitmapData.bmiHeader.biClrUsed = 0;
4210 aBitmapData.bmiHeader.biClrImportant = 0;
4211 aBitmapData.bmiHeader.biCompression = BI_RGB;
4212 aBitmapData.bmiHeader.biSizeImage = 0;
4214 // Create Device Independent Bitmap
4215 void* aBitsOut = NULL;
4216 HBITMAP aMemoryBitmap = CreateDIBSection (anDC, &aBitmapData, DIB_RGB_COLORS,
4217 &aBitsOut, NULL, 0);
4218 HGDIOBJ anOldBitmap = SelectObject(anDC, aMemoryBitmap);
4220 Standard_Boolean isSaved = Standard_False, isPrinted = Standard_False;
4221 if (aBitsOut != NULL)
4224 isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH);
4227 if (isTileSizeProvided)
4229 Graphic3d_CView* aCView = static_cast<Graphic3d_CView*> (ViewerTest::CurrentView()->View()->CView());
4230 Graphic3d_PtrFrameBuffer anOldBuffer = static_cast<Graphic3d_PtrFrameBuffer> (aCView->ptrFBO);
4231 aCView->ptrFBO = aView->View()->FBOCreate (aTileWidth, aTileHeight);
4233 isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE);
4235 Graphic3d_PtrFrameBuffer aNewBuffer = static_cast<Graphic3d_PtrFrameBuffer> (aCView->ptrFBO);
4236 aView->View()->FBORelease (aNewBuffer);
4237 aCView->ptrFBO = anOldBuffer;
4241 isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE);
4245 // succesfully printed into an intermediate buffer
4248 Image_PixMap aWrapper;
4249 aWrapper.InitWrapper (Image_PixMap::ImgBGR, (Standard_Byte* )aBitsOut, aWidth, aHeight, aWidth * 3 + aWidth % 4);
4250 aWrapper.SetTopDown (false);
4252 Image_AlienPixMap anImageBitmap;
4253 anImageBitmap.InitCopy (aWrapper);
4254 isSaved = anImageBitmap.Save (aFileName);
4258 di << "Print operation failed due to printing errors or\n";
4259 di << "insufficient memory available\n";
4260 di << "Please, try to use smaller dimensions for this test\n";
4261 di << "command, as it allocates intermediate buffer for storing\n";
4262 di << "the result\n";
4267 di << "Can't allocate memory for intermediate buffer\n";
4268 di << "Please use smaller dimensions\n";
4273 SelectObject (anDC, anOldBitmap);
4274 DeleteObject (aMemoryBitmap);
4280 di << "Save to file operation failed. This operation may fail\n";
4281 di << "if you don't have enough available memory, then you can\n";
4282 di << "use smaller dimensions for the output file\n";
4291 //==============================================================================
4292 //function : VZLayer
4293 //purpose : Test z layer operations for v3d viewer
4294 //==============================================================================
4295 static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
4297 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
4298 if (aContextAIS.IsNull())
4300 di << "Call vinit before!\n";
4305 di << "Use: vzlayer ";
4306 di << " add/del/get/settings/enable/disable [id]\n";
4307 di << " add - add new z layer to viewer and print its id\n";
4308 di << " del - del z layer by its id\n";
4309 di << " get - print sequence of z layers in increasing order of their overlay level\n";
4310 di << " settings - print status of z layer settings\n";
4311 di << " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n";
4312 di << " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n";
4313 di << " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n";
4314 di << "\nWhere id is the layer identificator\n";
4315 di << "\nExamples:\n";
4316 di << " vzlayer add\n";
4317 di << " vzlayer enable poffset 1\n";
4318 di << " vzlayer disable depthtest 1\n";
4319 di << " vzlayer del 1\n";
4323 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
4324 if (aViewer.IsNull())
4326 di << "No active viewer!\n";
4330 // perform operation
4331 TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]);
4334 Standard_Integer aNewId;
4335 if (!aViewer->AddZLayer (aNewId))
4337 di << "Impossible to add new z layer!\n";
4341 di << "New z layer added with index: " << aNewId << "\n";
4343 else if (anOp == "del")
4347 di << "Please also provide as argument id of z layer to remove\n";
4351 Standard_Integer aDelId = Draw::Atoi (argv[2]);
4352 if (!aViewer->RemoveZLayer (aDelId))
4354 di << "Impossible to remove the z layer or invalid id!\n";
4358 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
4359 anObjIter.More(); anObjIter.Next())
4361 Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anObjIter.Key1());
4363 || aPrs->ZLayer() != aDelId)
4367 aPrs->SetZLayer (Graphic3d_ZLayerId_Default);
4370 di << "Z layer " << aDelId << " has been removed\n";
4372 else if (anOp == "get")
4374 TColStd_SequenceOfInteger anIds;
4375 aViewer->GetAllZLayers (anIds);
4376 for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++)
4378 di << anIds.Value (aSeqIdx) << " ";
4383 else if (anOp == "settings")
4387 di << "Please also provide an id\n";
4391 Standard_Integer anId = Draw::Atoi (argv[2]);
4392 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId);
4394 di << "Depth test - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthTest) ? "enabled" : "disabled") << "\n";
4395 di << "Depth write - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthWrite) ? "enabled" : "disabled") << "\n";
4396 di << "Depth buffer clearing - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthClear) ? "enabled" : "disabled") << "\n";
4397 di << "Depth offset - " << (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthOffset) ? "enabled" : "disabled") << "\n";
4400 else if (anOp == "enable")
4404 di << "Please also provide an option to enable\n";
4410 di << "Please also provide a layer id\n";
4414 TCollection_AsciiString aSubOp = TCollection_AsciiString (argv[2]);
4415 Standard_Integer anId = Draw::Atoi (argv[3]);
4416 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId);
4418 if (aSubOp == "depthtest" || aSubOp == "test")
4420 aSettings.EnableSetting (Graphic3d_ZLayerDepthTest);
4422 else if (aSubOp == "depthwrite" || aSubOp == "write")
4424 aSettings.EnableSetting (Graphic3d_ZLayerDepthWrite);
4426 else if (aSubOp == "depthclear" || aSubOp == "clear")
4428 aSettings.EnableSetting (Graphic3d_ZLayerDepthClear);
4430 else if (aSubOp == "depthoffset" || aSubOp == "offset")
4434 di << "Please also provide a factor and units values for depth offset\n";
4435 di << "Format is: vzlayer enable offset [factor] [units] [layerId]\n";
4439 Standard_ShortReal aFactor = static_cast<Standard_ShortReal> (Draw::Atof (argv[3]));
4440 Standard_ShortReal aUnits = static_cast<Standard_ShortReal> (Draw::Atof (argv[4]));
4441 anId = Draw::Atoi (argv[5]);
4442 aSettings = aViewer->ZLayerSettings (anId);
4444 aSettings.DepthOffsetFactor = aFactor;
4445 aSettings.DepthOffsetUnits = aUnits;
4447 aSettings.EnableSetting (Graphic3d_ZLayerDepthOffset);
4449 else if (aSubOp == "positiveoffset" || aSubOp == "poffset")
4451 aSettings.SetDepthOffsetPositive();
4453 else if (aSubOp == "negativeoffset" || aSubOp == "noffset")
4455 aSettings.SetDepthOffsetNegative();
4458 aViewer->SetZLayerSettings (anId, aSettings);
4460 else if (anOp == "disable")
4464 di << "Please also provide an option to disable\n";
4470 di << "Please also provide a layer id\n";
4474 TCollection_AsciiString aSubOp = TCollection_AsciiString (argv[2]);
4475 Standard_Integer anId = Draw::Atoi (argv[3]);
4476 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId);
4478 if (aSubOp == "depthtest" || aSubOp == "test")
4480 aSettings.DisableSetting (Graphic3d_ZLayerDepthTest);
4482 else if (aSubOp == "depthwrite" || aSubOp == "write")
4484 aSettings.DisableSetting (Graphic3d_ZLayerDepthWrite);
4486 else if (aSubOp == "depthclear" || aSubOp == "clear")
4488 aSettings.DisableSetting (Graphic3d_ZLayerDepthClear);
4490 else if (aSubOp == "depthoffset" || aSubOp == "offset")
4492 aSettings.DisableSetting (Graphic3d_ZLayerDepthOffset);
4495 aViewer->SetZLayerSettings (anId, aSettings);
4499 di << "Invalid operation, please use { add / del / get / settings / enable / disable}\n";
4506 DEFINE_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
4508 // this class provides a presentation of text item in v3d view under-/overlayer
4509 class V3d_TextItem : public Visual3d_LayerItem
4514 DEFINE_STANDARD_RTTI(V3d_TextItem)
4517 Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText,
4518 const Standard_Real theX1,
4519 const Standard_Real theY1,
4520 const Standard_Real theHeight,
4521 const TCollection_AsciiString& theFontName,
4522 const Quantity_Color& theColor,
4523 const Quantity_Color& theSubtitleColor,
4524 const Aspect_TypeOfDisplayText& theTypeOfDisplay,
4525 const Handle(Visual3d_Layer)& theLayer);
4528 Standard_EXPORT void RedrawLayerPrs();
4534 TCollection_AsciiString myText;
4535 Standard_Real myHeight;
4536 Handle(Visual3d_Layer) myLayer;
4537 Quantity_Color myColor;
4538 Quantity_Color mySubtitleColor;
4539 Aspect_TypeOfDisplayText myType;
4540 TCollection_AsciiString myFontName;
4543 IMPLEMENT_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
4544 IMPLEMENT_STANDARD_RTTIEXT(V3d_TextItem, Visual3d_LayerItem)
4546 // create and add to display the text item
4547 V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText,
4548 const Standard_Real theX1,
4549 const Standard_Real theY1,
4550 const Standard_Real theHeight,
4551 const TCollection_AsciiString& theFontName,
4552 const Quantity_Color& theColor,
4553 const Quantity_Color& theSubtitleColor,
4554 const Aspect_TypeOfDisplayText& theTypeOfDisplay,
4555 const Handle(Visual3d_Layer)& theLayer)
4556 : myX1 (theX1), myY1 (theY1),
4558 myHeight (theHeight),
4561 mySubtitleColor (theSubtitleColor),
4562 myType (theTypeOfDisplay),
4563 myFontName (theFontName)
4565 if (!myLayer.IsNull ())
4566 myLayer->AddLayerItem (this);
4570 void V3d_TextItem::RedrawLayerPrs ()
4572 if (myLayer.IsNull ())
4575 myLayer->SetColor (myColor);
4576 myLayer->SetTextAttributes (myFontName.ToCString (), myType, mySubtitleColor);
4577 myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight);
4580 DEFINE_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
4582 // The Visual3d_LayerItem line item for "vlayerline" command
4583 // it provides a presentation of line with user-defined
4584 // linewidth, linetype and transparency.
4585 class V3d_LineItem : public Visual3d_LayerItem
4589 DEFINE_STANDARD_RTTI(V3d_LineItem)
4592 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
4593 Standard_Real X2, Standard_Real Y2,
4594 V3d_LayerMgrPointer theLayerMgr,
4595 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
4596 Standard_Real theWidth = 0.5,
4597 Standard_Real theTransp = 1.0);
4600 Standard_EXPORT void RedrawLayerPrs();
4604 Standard_Real myX1, myY1, myX2, myY2;
4605 V3d_LayerMgrPointer myLayerMgr;
4606 Aspect_TypeOfLine myType;
4607 Standard_Real myWidth;
4608 Standard_Real myTransparency;
4611 IMPLEMENT_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
4612 IMPLEMENT_STANDARD_RTTIEXT(V3d_LineItem, Visual3d_LayerItem)
4614 // default constructor for line item
4615 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
4616 Standard_Real X2, Standard_Real Y2,
4617 V3d_LayerMgrPointer theLayerMgr,
4618 Aspect_TypeOfLine theType,
4619 Standard_Real theWidth,
4620 Standard_Real theTransp) :
4621 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), myLayerMgr(theLayerMgr),
4622 myType(theType), myWidth(theWidth), myTransparency(theTransp)
4624 if (myLayerMgr && !myLayerMgr->Overlay().IsNull())
4625 myLayerMgr->Overlay()->AddLayerItem (this);
4629 void V3d_LineItem::RedrawLayerPrs ()
4631 Handle (Visual3d_Layer) aOverlay;
4634 aOverlay = myLayerMgr->Overlay();
4636 if (!aOverlay.IsNull())
4638 Quantity_Color aColor(1.0, 0, 0, Quantity_TOC_RGB);
4639 aOverlay->SetColor(aColor);
4640 aOverlay->SetTransparency((Standard_ShortReal)myTransparency);
4641 aOverlay->SetLineAttributes((Aspect_TypeOfLine)myType, myWidth);
4642 aOverlay->BeginPolyline();
4643 aOverlay->AddVertex(myX1, myY1);
4644 aOverlay->AddVertex(myX2, myY2);
4645 aOverlay->ClosePrimitive();
4649 //=============================================================================
4650 //function : VLayerLine
4651 //purpose : Draws line in the v3d view layer with given attributes: linetype,
4652 // : linewidth, transparency coefficient
4653 //============================================================================
4654 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
4656 // get the active view
4657 Handle(V3d_View) aView = ViewerTest::CurrentView();
4660 di << "Call vinit before!\n";
4665 di << "Use: " << argv[0];
4666 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
4667 di << " linetype : { 0 | 1 | 2 | 3 } \n";
4668 di << " 0 - solid \n";
4669 di << " 1 - dashed \n";
4670 di << " 2 - dot \n";
4671 di << " 3 - dashdot\n";
4672 di << " transparency : { 0.0 - 1.0 } \n";
4673 di << " 0.0 - transparent\n";
4674 di << " 1.0 - visible \n";
4678 // get the input params
4679 Standard_Real X1 = Draw::Atof(argv[1]);
4680 Standard_Real Y1 = Draw::Atof(argv[2]);
4681 Standard_Real X2 = Draw::Atof(argv[3]);
4682 Standard_Real Y2 = Draw::Atof(argv[4]);
4684 Standard_Real aWidth = 0.5;
4685 Standard_Integer aType = 0;
4686 Standard_Real aTransparency = 1.0;
4690 aWidth = Draw::Atof(argv[5]);
4694 aType = (Standard_Integer) Draw::Atoi(argv[6]);
4699 aTransparency = Draw::Atof(argv[7]);
4700 if (aTransparency < 0 || aTransparency > 1.0)
4701 aTransparency = 1.0;
4704 // select appropriate line type
4705 Aspect_TypeOfLine aLineType;
4709 aLineType = Aspect_TOL_DASH;
4713 aLineType = Aspect_TOL_DOT;
4717 aLineType = Aspect_TOL_DOTDASH;
4721 aLineType = Aspect_TOL_SOLID;
4724 // replace layer manager
4725 Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr(aView);
4726 aView->SetLayerMgr(aMgr);
4729 Handle (V3d_LineItem) anItem = new V3d_LineItem(X1, Y1, X2, Y2,
4735 aView->MustBeResized();
4741 //=======================================================================
4742 //function : VOverlayText
4743 //purpose : Test text displaying in view overlay
4744 //=======================================================================
4745 static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char**argv)
4747 // get the active view
4748 Handle(V3d_View) aView = ViewerTest::CurrentView();
4751 di << "No active view. Please call vinit.\n";
4754 else if (argc < 4 || argc > 13)
4756 di << "Use: " << argv[0];
4757 di << " text x y [height] [font_name] [text_color: R G B] [displayType]\n";
4758 di << "[background_color: R G B]\n";
4759 di << " height - pixel height of the text (default=10.0)\n";
4760 di << " font_name - name of font (default=courier)\n";
4761 di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n";
4762 di << " display_type = {normal/subtitle/decal/blend/dimension}, (default=normal)\n";
4763 di << " background_color- R G B values used for subtitle and decal text\n";
4764 di << "(default=255.0 255.0 255.0)\n";
4768 TCollection_AsciiString aText (argv[1]);
4769 Standard_Real aPosX = Draw::Atof(argv[2]);
4770 Standard_Real aPosY = Draw::Atof(argv[3]);
4771 Standard_Real aHeight = (argc >= 5) ? Draw::Atof (argv[4]) : 10.0;
4774 TCollection_AsciiString aFontName = "Courier";
4776 aFontName = TCollection_AsciiString (argv[5]);
4779 Quantity_Parameter aColorRed = 1.0;
4780 Quantity_Parameter aColorGreen = 1.0;
4781 Quantity_Parameter aColorBlue = 1.0;
4784 aColorRed = Draw::Atof (argv[6])/255.;
4785 aColorGreen = Draw::Atof (argv[7])/255.;
4786 aColorBlue = Draw::Atof (argv[8])/255.;
4790 TCollection_AsciiString aDispStr;
4792 aDispStr = TCollection_AsciiString (argv[9]);
4794 Aspect_TypeOfDisplayText aTextType = Aspect_TODT_NORMAL;
4795 if (aDispStr.IsEqual ("subtitle"))
4796 aTextType = Aspect_TODT_SUBTITLE;
4797 else if (aDispStr.IsEqual ("decal"))
4798 aTextType = Aspect_TODT_DEKALE;
4799 else if (aDispStr.IsEqual ("blend"))
4800 aTextType = Aspect_TODT_BLEND;
4801 else if (aDispStr.IsEqual ("dimension"))
4802 aTextType = Aspect_TODT_DIMENSION;
4805 Quantity_Parameter aSubRed = 1.0;
4806 Quantity_Parameter aSubGreen = 1.0;
4807 Quantity_Parameter aSubBlue = 1.0;
4810 aSubRed = Draw::Atof (argv[10])/255.;
4811 aSubGreen = Draw::Atof (argv[11])/255.;
4812 aSubBlue = Draw::Atof (argv[12])/255.;
4815 // check fo current overlay
4816 Handle(Visual3d_Layer) anOverlay = aView->Viewer()->Viewer()->OverLayer ();
4817 if (anOverlay.IsNull ())
4819 Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (aView);
4820 anOverlay = aMgr->Overlay ();
4821 aView->SetLayerMgr (aMgr);
4824 Quantity_Color aTextColor (aColorRed, aColorGreen,
4825 aColorBlue, Quantity_TOC_RGB);
4826 Quantity_Color aSubtColor (aSubRed, aSubGreen,
4827 aSubBlue, Quantity_TOC_RGB);
4830 Handle(V3d_TextItem) anItem = new V3d_TextItem (aText, aPosX, aPosY,
4831 aHeight, aFontName, aTextColor, aSubtColor, aTextType, anOverlay);
4834 aView->MustBeResized();
4840 //==============================================================================
4843 //==============================================================================
4845 static int VGrid (Draw_Interpretor& /*theDI*/,
4846 Standard_Integer theArgNb,
4847 const char** theArgVec)
4849 // get the active view
4850 Handle(V3d_View) aView = ViewerTest::CurrentView();
4851 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
4852 if (aView.IsNull() || aViewer.IsNull())
4854 std::cerr << "No active view. Please call vinit.\n";
4858 Aspect_GridType aType = aViewer->GridType();
4859 Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
4861 Standard_Integer anIter = 1;
4862 for (; anIter < theArgNb; ++anIter)
4864 const char* aValue = theArgVec[anIter];
4867 aType = Aspect_GT_Rectangular;
4869 else if (*aValue == 'c')
4871 aType = Aspect_GT_Circular;
4873 else if (*aValue == 'l')
4875 aMode = Aspect_GDM_Lines;
4877 else if (*aValue == 'p')
4879 aMode = Aspect_GDM_Points;
4881 else if (strcmp (aValue, "off" ) == 0)
4883 aViewer->DeactivateGrid();
4892 Standard_Integer aTail = (theArgNb - anIter);
4895 aViewer->ActivateGrid (aType, aMode);
4898 else if (aTail != 2 && aTail != 5)
4900 std::cerr << "Incorrect arguments number! Usage:\n"
4901 << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n";
4905 Quantity_Length anOriginX, anOriginY;
4906 Quantity_PlaneAngle aRotAngle;
4907 if (aType == Aspect_GT_Rectangular)
4909 Quantity_Length aRStepX, aRStepY;
4910 aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
4912 anOriginX = Draw::Atof (theArgVec[anIter++]);
4913 anOriginY = Draw::Atof (theArgVec[anIter++]);
4916 aRStepX = Draw::Atof (theArgVec[anIter++]);
4917 aRStepY = Draw::Atof (theArgVec[anIter++]);
4918 aRotAngle = Draw::Atof (theArgVec[anIter++]);
4920 aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
4921 aViewer->ActivateGrid (aType, aMode);
4923 else if (aType == Aspect_GT_Circular)
4925 Quantity_Length aRadiusStep;
4926 Standard_Integer aDivisionNumber;
4927 aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
4929 anOriginX = Draw::Atof (theArgVec[anIter++]);
4930 anOriginY = Draw::Atof (theArgVec[anIter++]);
4933 aRadiusStep = Draw::Atof (theArgVec[anIter++]);
4934 aDivisionNumber = Draw::Atoi (theArgVec[anIter++]);
4935 aRotAngle = Draw::Atof (theArgVec[anIter++]);
4938 aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
4939 aViewer->ActivateGrid (aType, aMode);
4945 //==============================================================================
4946 //function : VPriviledgedPlane
4948 //==============================================================================
4950 static int VPriviledgedPlane (Draw_Interpretor& theDI,
4951 Standard_Integer theArgNb,
4952 const char** theArgVec)
4954 if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10)
4956 std::cerr << "Error: wrong number of arguments! See usage:\n";
4957 theDI.PrintHelp (theArgVec[0]);
4961 // get the active viewer
4962 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
4963 if (aViewer.IsNull())
4965 std::cerr << "Error: no active viewer. Please call vinit.\n";
4971 gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane();
4972 const gp_Pnt& anOrig = aPriviledgedPlane.Location();
4973 const gp_Dir& aNorm = aPriviledgedPlane.Direction();
4974 const gp_Dir& aXDir = aPriviledgedPlane.XDirection();
4975 theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " "
4976 << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " "
4977 << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n";
4981 Standard_Integer anArgIdx = 1;
4982 Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]);
4983 Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]);
4984 Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]);
4985 Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]);
4986 Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]);
4987 Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]);
4989 gp_Ax3 aPriviledgedPlane;
4990 gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ);
4991 gp_Dir aNorm (aNormX, aNormY, aNormZ);
4994 Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]);
4995 Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]);
4996 Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]);
4997 gp_Dir aXDir (aXDirX, aXDirY, aXDirZ);
4998 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir);
5002 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm);
5005 aViewer->SetPrivilegedPlane (aPriviledgedPlane);
5010 //==============================================================================
5011 //function : VConvert
5013 //==============================================================================
5015 static int VConvert (Draw_Interpretor& theDI,
5016 Standard_Integer theArgNb,
5017 const char** theArgVec)
5019 // get the active view
5020 Handle(V3d_View) aView = ViewerTest::CurrentView();
5023 std::cerr << "Error: no active view. Please call vinit.\n";
5027 enum { Model, Ray, View, Window, Grid } aMode = Model;
5029 // access coordinate arguments
5030 TColStd_SequenceOfReal aCoord;
5031 Standard_Integer anArgIdx = 1;
5032 for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx)
5034 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
5035 if (!anArg.IsRealValue())
5039 aCoord.Append (anArg.RealValue());
5042 // non-numeric argument too early
5043 if (aCoord.IsEmpty())
5045 std::cerr << "Error: wrong number of arguments! See usage:\n";
5046 theDI.PrintHelp (theArgVec[0]);
5050 // collect all other arguments and options
5051 for (; anArgIdx < theArgNb; ++anArgIdx)
5053 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
5055 if (anArg == "window") aMode = Window;
5056 else if (anArg == "view") aMode = View;
5057 else if (anArg == "grid") aMode = Grid;
5058 else if (anArg == "ray") aMode = Ray;
5061 std::cerr << "Error: wrong argument " << anArg << "! See usage:\n";
5062 theDI.PrintHelp (theArgVec[0]);
5067 // complete input checks
5068 if ((aCoord.Length() == 1 && theArgNb > 3) ||
5069 (aCoord.Length() == 2 && theArgNb > 4) ||
5070 (aCoord.Length() == 3 && theArgNb > 5))
5072 std::cerr << "Error: wrong number of arguments! See usage:\n";
5073 theDI.PrintHelp (theArgVec[0]);
5077 Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
5078 Standard_Integer aXYp[2] = {0, 0};
5080 // convert one-dimensional coordinate
5081 if (aCoord.Length() == 1)
5085 case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer) aCoord (1)); return 0;
5086 case Window : theDI << "Window Vp: " << aView->Convert ((Quantity_Length) aCoord (1)); return 0;
5088 std::cerr << "Error: wrong arguments! See usage:\n";
5089 theDI.PrintHelp (theArgVec[0]);
5094 // convert 2D coordinates from projection or view reference space
5095 if (aCoord.Length() == 2)
5100 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
5101 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
5105 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]);
5106 theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n";
5110 aView->Convert ((V3d_Coordinate) aCoord (1), (V3d_Coordinate) aCoord (2), aXYp[0], aXYp[1]);
5111 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
5115 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
5116 aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]);
5117 theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
5121 aView->ConvertWithProj ((Standard_Integer) aCoord (1),
5122 (Standard_Integer) aCoord (2),
5123 aXYZ[0], aXYZ[1], aXYZ[2],
5124 aXYZ[3], aXYZ[4], aXYZ[5]);
5125 theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
5129 std::cerr << "Error: wrong arguments! See usage:\n";
5130 theDI.PrintHelp (theArgVec[0]);
5135 // convert 3D coordinates from view reference space
5136 else if (aCoord.Length() == 3)
5141 aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]);
5142 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
5146 aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]);
5147 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
5151 std::cerr << "Error: wrong arguments! See usage:\n";
5152 theDI.PrintHelp (theArgVec[0]);
5160 //==============================================================================
5163 //==============================================================================
5165 static int VFps (Draw_Interpretor& theDI,
5166 Standard_Integer theArgNb,
5167 const char** theArgVec)
5169 // get the active view
5170 Handle(V3d_View) aView = ViewerTest::CurrentView();
5173 std::cerr << "No active view. Please call vinit.\n";
5177 Standard_Integer aFramesNb = (theArgNb > 1) ? Draw::Atoi(theArgVec[1]) : 100;
5180 std::cerr << "Incorrect arguments!\n";
5184 // the time is meaningless for first call
5185 // due to async OpenGl rendering
5188 // redraw view in loop to estimate average values
5191 for (Standard_Integer anInter = 0; anInter < aFramesNb; ++anInter)
5197 const Standard_Real aTime = aTimer.ElapsedTime();
5198 aTimer.OSD_Chronometer::Show (aCpu);
5200 const Standard_Real aFpsAver = Standard_Real(aFramesNb) / aTime;
5201 const Standard_Real aCpuAver = aCpu / Standard_Real(aFramesNb);
5203 // return statistics
5204 theDI << "FPS: " << aFpsAver << "\n"
5205 << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
5210 //==============================================================================
5211 //function : VGlDebug
5213 //==============================================================================
5215 static int VGlDebug (Draw_Interpretor& theDI,
5216 Standard_Integer theArgNb,
5217 const char** theArgVec)
5219 Handle(OpenGl_GraphicDriver) aDriver;
5220 Handle(V3d_View) aView = ViewerTest::CurrentView();
5221 if (!aView.IsNull())
5223 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
5225 OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps;
5226 OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
5230 TCollection_AsciiString aDebActive, aSyncActive;
5237 Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
5238 "GL_ARB_debug_output");
5239 aDebActive = isActive ? " (active)" : " (inactive)";
5242 // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
5243 aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
5247 theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n"
5248 << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n"
5249 << "glslWarn:" << (aCaps->glslWarnings ? "1" : "0") << "\n"
5250 << "extraMsg:" << (aCaps->suppressExtraMsg ? "0" : "1") << "\n";
5254 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5256 Standard_CString anArg = theArgVec[anArgIter];
5257 TCollection_AsciiString anArgCase (anArg);
5258 anArgCase.LowerCase();
5259 Standard_Boolean toEnableDebug = Standard_True;
5260 if (anArgCase == "-glsl"
5261 || anArgCase == "-glslwarn"
5262 || anArgCase == "-glslwarns"
5263 || anArgCase == "-glslwarnings")
5265 Standard_Boolean toShowWarns = Standard_True;
5266 if (++anArgIter < theArgNb
5267 && !parseOnOff (theArgVec[anArgIter], toShowWarns))
5271 aDefCaps->glslWarnings = toShowWarns;
5274 aCaps->glslWarnings = toShowWarns;
5277 else if (anArgCase == "-extra"
5278 || anArgCase == "-extramsg"
5279 || anArgCase == "-extramessages")
5281 Standard_Boolean toShow = Standard_True;
5282 if (++anArgIter < theArgNb
5283 && !parseOnOff (theArgVec[anArgIter], toShow))
5287 aDefCaps->suppressExtraMsg = !toShow;
5290 aCaps->suppressExtraMsg = !toShow;
5293 else if (anArgCase == "-noextra"
5294 || anArgCase == "-noextramsg"
5295 || anArgCase == "-noextramessages")
5297 Standard_Boolean toSuppress = Standard_True;
5298 if (++anArgIter < theArgNb
5299 && !parseOnOff (theArgVec[anArgIter], toSuppress))
5303 aDefCaps->suppressExtraMsg = toSuppress;
5306 aCaps->suppressExtraMsg = toSuppress;
5309 else if (anArgCase == "-sync")
5311 Standard_Boolean toSync = Standard_True;
5312 if (++anArgIter < theArgNb
5313 && !parseOnOff (theArgVec[anArgIter], toSync))
5317 aDefCaps->contextSyncDebug = toSync;
5320 aDefCaps->contextDebug = Standard_True;
5323 else if (anArgCase == "-debug")
5325 if (++anArgIter < theArgNb
5326 && !parseOnOff (theArgVec[anArgIter], toEnableDebug))
5330 aDefCaps->contextDebug = toEnableDebug;
5332 else if (parseOnOff (anArg, toEnableDebug)
5333 && (anArgIter + 1 == theArgNb))
5335 // simple alias to turn on almost everything
5336 aDefCaps->contextDebug = toEnableDebug;
5337 aDefCaps->contextSyncDebug = toEnableDebug;
5338 aDefCaps->glslWarnings = toEnableDebug;
5342 std::cout << "Error: wrong syntax at '" << anArg << "'\n";
5350 //==============================================================================
5353 //==============================================================================
5355 static int VVbo (Draw_Interpretor& theDI,
5356 Standard_Integer theArgNb,
5357 const char** theArgVec)
5359 const Standard_Boolean toSet = (theArgNb > 1);
5360 const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
5363 ViewerTest_myDefaultCaps.vboDisable = toUseVbo;
5367 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5368 if (aContextAIS.IsNull())
5372 std::cerr << "No active view!\n";
5376 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
5377 if (!aDriver.IsNull())
5381 theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
5385 aDriver->ChangeOptions().vboDisable = toUseVbo;
5392 //==============================================================================
5395 //==============================================================================
5397 static int VCaps (Draw_Interpretor& theDI,
5398 Standard_Integer theArgNb,
5399 const char** theArgVec)
5401 OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps;
5402 Handle(OpenGl_GraphicDriver) aDriver;
5403 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5404 if (!aContext.IsNull())
5406 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
5407 aCaps = &aDriver->ChangeOptions();
5412 theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n";
5413 theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
5414 theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
5415 theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
5416 theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
5420 ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
5421 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5423 Standard_CString anArg = theArgVec[anArgIter];
5424 TCollection_AsciiString anArgCase (anArg);
5425 anArgCase.LowerCase();
5426 if (anUpdateTool.parseRedrawMode (anArg))
5430 else if (anArgCase == "-ffp")
5432 Standard_Boolean toEnable = Standard_True;
5433 if (++anArgIter < theArgNb
5434 && !parseOnOff (theArgVec[anArgIter], toEnable))
5438 aCaps->ffpEnable = toEnable;
5440 else if (anArgCase == "-vbo")
5442 Standard_Boolean toEnable = Standard_True;
5443 if (++anArgIter < theArgNb
5444 && !parseOnOff (theArgVec[anArgIter], toEnable))
5448 aCaps->vboDisable = !toEnable;
5450 else if (anArgCase == "-sprite"
5451 || anArgCase == "-sprites")
5453 Standard_Boolean toEnable = Standard_True;
5454 if (++anArgIter < theArgNb
5455 && !parseOnOff (theArgVec[anArgIter], toEnable))
5459 aCaps->pntSpritesDisable = !toEnable;
5461 else if (anArgCase == "-softmode")
5463 Standard_Boolean toEnable = Standard_True;
5464 if (++anArgIter < theArgNb
5465 && !parseOnOff (theArgVec[anArgIter], toEnable))
5469 aCaps->contextNoAccel = toEnable;
5471 else if (anArgCase == "-accel"
5472 || anArgCase == "-acceleration")
5474 Standard_Boolean toEnable = Standard_True;
5475 if (++anArgIter < theArgNb
5476 && !parseOnOff (theArgVec[anArgIter], toEnable))
5480 aCaps->contextNoAccel = !toEnable;
5482 else if (anArgCase == "-compat"
5483 || anArgCase == "-compatprofile"
5484 || anArgCase == "-compatible"
5485 || anArgCase == "-compatibleprofile")
5487 Standard_Boolean toEnable = Standard_True;
5488 if (++anArgIter < theArgNb
5489 && !parseOnOff (theArgVec[anArgIter], toEnable))
5493 aCaps->contextCompatible = toEnable;
5494 if (!aCaps->contextCompatible)
5496 aCaps->ffpEnable = Standard_False;
5499 else if (anArgCase == "-core"
5500 || anArgCase == "-coreprofile")
5502 Standard_Boolean toEnable = Standard_True;
5503 if (++anArgIter < theArgNb
5504 && !parseOnOff (theArgVec[anArgIter], toEnable))
5508 aCaps->contextCompatible = !toEnable;
5509 if (!aCaps->contextCompatible)
5511 aCaps->ffpEnable = Standard_False;
5516 std::cout << "Error: unknown argument '" << anArg << "'\n";
5520 if (aCaps != &ViewerTest_myDefaultCaps)
5522 ViewerTest_myDefaultCaps = *aCaps;
5527 //==============================================================================
5528 //function : VMemGpu
5530 //==============================================================================
5532 static int VMemGpu (Draw_Interpretor& theDI,
5533 Standard_Integer theArgNb,
5534 const char** theArgVec)
5537 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5538 if (aContextAIS.IsNull())
5540 std::cerr << "No active view. Please call vinit.\n";
5544 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
5545 if (aDriver.IsNull())
5547 std::cerr << "Graphic driver not available.\n";
5551 Standard_Size aFreeBytes = 0;
5552 TCollection_AsciiString anInfo;
5553 if (!aDriver->MemoryInfo (aFreeBytes, anInfo))
5555 std::cerr << "Information not available.\n";
5559 if (theArgNb > 1 && *theArgVec[1] == 'f')
5561 theDI << Standard_Real (aFreeBytes);
5571 // ==============================================================================
5572 // function : VReadPixel
5574 // ==============================================================================
5575 static int VReadPixel (Draw_Interpretor& theDI,
5576 Standard_Integer theArgNb,
5577 const char** theArgVec)
5579 // get the active view
5580 Handle(V3d_View) aView = ViewerTest::CurrentView();
5583 std::cerr << "No active view. Please call vinit.\n";
5586 else if (theArgNb < 3)
5588 std::cerr << "Usage : " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]\n";
5592 Image_PixMap::ImgFormat aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA;
5593 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
5595 Standard_Integer aWidth, aHeight;
5596 aView->Window()->Size (aWidth, aHeight);
5597 const Standard_Integer anX = Draw::Atoi (theArgVec[1]);
5598 const Standard_Integer anY = Draw::Atoi (theArgVec[2]);
5599 if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight)
5601 std::cerr << "Pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")\n";
5605 Standard_Boolean toShowName = Standard_False;
5606 Standard_Boolean toShowHls = Standard_False;
5607 for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
5609 const char* aParam = theArgVec[anIter];
5610 if ( strcasecmp( aParam, "rgb" ) == 0 )
5612 aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR;
5613 aBufferType = Graphic3d_BT_RGB;
5615 else if ( strcasecmp( aParam, "hls" ) == 0 )
5617 aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR;
5618 aBufferType = Graphic3d_BT_RGB;
5619 toShowHls = Standard_True;
5621 else if ( strcasecmp( aParam, "rgbf" ) == 0 )
5623 aFormat = Image_PixMap::ImgRGBF;
5624 aBufferType = Graphic3d_BT_RGB;
5626 else if ( strcasecmp( aParam, "rgba" ) == 0 )
5628 aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA;
5629 aBufferType = Graphic3d_BT_RGBA;
5631 else if ( strcasecmp( aParam, "rgbaf" ) == 0 )
5633 aFormat = Image_PixMap::ImgRGBAF;
5634 aBufferType = Graphic3d_BT_RGBA;
5636 else if ( strcasecmp( aParam, "depth" ) == 0 )
5638 aFormat = Image_PixMap::ImgGrayF;
5639 aBufferType = Graphic3d_BT_Depth;
5641 else if ( strcasecmp( aParam, "name" ) == 0 )
5643 toShowName = Standard_True;
5647 Image_PixMap anImage;
5648 if (!anImage.InitTrash (aFormat, aWidth, aHeight))
5650 std::cerr << "Image allocation failed\n";
5653 else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType))
5655 std::cerr << "Image dump failed\n";
5659 Quantity_Parameter anAlpha;
5660 Quantity_Color aColor = anImage.PixelColor (anX, anY, anAlpha);
5663 if (aBufferType == Graphic3d_BT_RGBA)
5665 theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha;
5669 theDI << Quantity_Color::StringName (aColor.Name());
5674 switch (aBufferType)
5677 case Graphic3d_BT_RGB:
5681 theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation();
5685 theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue();
5689 case Graphic3d_BT_RGBA:
5691 theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha;
5694 case Graphic3d_BT_Depth:
5696 theDI << aColor.Red();
5705 //==============================================================================
5706 //function : VDiffImage
5707 //purpose : The draw-command compares two images.
5708 //==============================================================================
5710 static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
5714 theDI << "Not enough arguments.\n";
5719 const char* anImgPathRef = theArgVec[1];
5720 const char* anImgPathNew = theArgVec[2];
5722 // get string tolerance and check its validity
5723 Standard_Real aTolColor = Draw::Atof (theArgVec[3]);
5724 if (aTolColor < 0.0)
5726 if (aTolColor > 1.0)
5729 Standard_Boolean toBlackWhite = (Draw::Atoi (theArgVec[4]) == 1);
5730 Standard_Boolean isBorderFilterOn = (Draw::Atoi (theArgVec[5]) == 1);
5732 // image file of difference
5733 const char* aDiffImagePath = (theArgNb >= 7) ? theArgVec[6] : NULL;
5735 // compare the images
5736 Image_Diff aComparer;
5737 if (!aComparer.Init (anImgPathRef, anImgPathNew, toBlackWhite))
5742 aComparer.SetColorTolerance (aTolColor);
5743 aComparer.SetBorderFilterOn (isBorderFilterOn);
5744 Standard_Integer aDiffColorsNb = aComparer.Compare();
5745 theDI << aDiffColorsNb << "\n";
5747 // save image of difference
5748 if (aDiffColorsNb >0 && aDiffImagePath != NULL)
5750 aComparer.SaveDiffImage (aDiffImagePath);
5756 //=======================================================================
5757 //function : VSelect
5758 //purpose : Emulates different types of selection by mouse:
5759 // 1) single click selection
5760 // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)
5761 // 3) selection with polygon having corners at
5762 // pixel positions (x1,y1),...,(xn,yn)
5763 // 4) any of these selections with shift button pressed
5764 //=======================================================================
5765 static Standard_Integer VSelect (Draw_Interpretor& di,
5766 Standard_Integer argc,
5771 di << "Usage : " << argv[0] << " x1 y1 [x2 y2 [... xn yn]] [shift_selection = 1|0]" << "\n";
5775 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
5776 if(myAIScontext.IsNull())
5778 di << "use 'vinit' command before " << argv[0] << "\n";
5782 const Standard_Boolean isShiftSelection = (argc > 3 && !(argc % 2) && (atoi (argv[argc - 1]) == 1));
5783 Standard_Integer aCoordsNb = isShiftSelection ? argc - 2 : argc - 1;
5784 TCollection_AsciiString anArg;
5785 anArg = isShiftSelection ? argv[argc - 3] : argv[argc - 2];
5787 if (anArg == "-allowoverlap")
5789 Standard_Boolean isValidated = isShiftSelection ? argc == 8
5793 di << "Wrong number of arguments! -allowoverlap key is applied only for rectangle selection";
5797 Standard_Integer isToAllow = isShiftSelection ? Draw::Atoi(argv[argc - 2]) : Draw::Atoi(argv[argc - 1]);
5798 myAIScontext->MainSelector()->AllowOverlapDetection((Standard_Boolean)isToAllow);
5802 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
5803 aCurrentEventManager->MoveTo(atoi(argv[1]),atoi(argv[2]));
5806 if(isShiftSelection)
5807 aCurrentEventManager->ShiftSelect();
5809 aCurrentEventManager->Select();
5811 else if(aCoordsNb == 4)
5813 if(isShiftSelection)
5814 aCurrentEventManager->ShiftSelect (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False);
5816 aCurrentEventManager->Select (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]), atoi (argv[4]), Standard_False);
5820 TColgp_Array1OfPnt2d aPolyline (1,aCoordsNb / 2);
5822 for(Standard_Integer i=1;i<=aCoordsNb / 2;++i)
5823 aPolyline.SetValue(i,gp_Pnt2d(atoi(argv[2*i-1]),atoi(argv[2*i])));
5825 if(isShiftSelection)
5826 aCurrentEventManager->ShiftSelect(aPolyline);
5828 aCurrentEventManager->Select(aPolyline);
5833 //=======================================================================
5834 //function : VMoveTo
5835 //purpose : Emulates cursor movement to defined pixel position
5836 //=======================================================================
5837 static Standard_Integer VMoveTo (Draw_Interpretor& di,
5838 Standard_Integer argc,
5843 di << "Usage : " << argv[0] << " x y" << "\n";
5847 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5848 if(aContext.IsNull())
5850 di << "use 'vinit' command before " << argv[0] << "\n";
5853 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
5857 //=================================================================================================
5858 //function : VViewParams
5859 //purpose : Gets or sets AIS View characteristics
5860 //=================================================================================================
5861 static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
5863 Handle(V3d_View) anAISView = ViewerTest::CurrentView();
5864 if (anAISView.IsNull())
5866 std::cout << theArgVec[0] << ": please initialize or activate view.\n";
5872 // print all of the available view parameters
5873 Quantity_Factor anAISViewScale = anAISView->Scale();
5875 Standard_Real anAISViewProjX = 0.0;
5876 Standard_Real anAISViewProjY = 0.0;
5877 Standard_Real anAISViewProjZ = 0.0;
5878 anAISView->Proj (anAISViewProjX, anAISViewProjY, anAISViewProjZ);
5880 Standard_Real anAISViewUpX = 0.0;
5881 Standard_Real anAISViewUpY = 0.0;
5882 Standard_Real anAISViewUpZ = 0.0;
5883 anAISView->Up (anAISViewUpX, anAISViewUpY, anAISViewUpZ);
5885 Standard_Real anAISViewAtX = 0.0;
5886 Standard_Real anAISViewAtY = 0.0;
5887 Standard_Real anAISViewAtZ = 0.0;
5888 anAISView->At (anAISViewAtX, anAISViewAtY, anAISViewAtZ);
5890 Standard_Real anAISViewEyeX = 0.0;
5891 Standard_Real anAISViewEyeY = 0.0;
5892 Standard_Real anAISViewEyeZ = 0.0;
5893 anAISView->Eye (anAISViewEyeX, anAISViewEyeY, anAISViewEyeZ);
5895 theDi << "Scale of current view: " << anAISViewScale << "\n";
5896 theDi << "Proj on X : " << anAISViewProjX << "; on Y: " << anAISViewProjY << "; on Z: " << anAISViewProjZ << "\n";
5897 theDi << "Up on X : " << anAISViewUpX << "; on Y: " << anAISViewUpY << "; on Z: " << anAISViewUpZ << "\n";
5898 theDi << "At on X : " << anAISViewAtX << "; on Y: " << anAISViewAtY << "; on Z: " << anAISViewAtZ << "\n";
5899 theDi << "Eye on X : " << anAISViewEyeX << "; on Y: " << anAISViewEyeY << "; on Z: " << anAISViewEyeZ << "\n";
5903 // -------------------------
5904 // Parse options and values
5905 // -------------------------
5907 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfKeysByValues;
5908 TCollection_AsciiString aParseKey;
5909 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
5911 TCollection_AsciiString anArg (theArgVec [anArgIt]);
5913 if (anArg.Value (1) == '-' && !anArg.IsRealValue())
5916 aParseKey.Remove (1);
5917 aParseKey.UpperCase();
5918 aMapOfKeysByValues.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
5922 if (aParseKey.IsEmpty())
5924 std::cout << theArgVec[0] << ": values should be passed with key.\n";
5925 std::cout << "Type help for more information.\n";
5929 aMapOfKeysByValues(aParseKey)->Append (anArg);
5932 // ---------------------------------------------
5933 // Change or print parameters, order plays role
5934 // ---------------------------------------------
5936 // Check arguments for validity
5937 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfKeysByValues);
5938 for (; aMapIt.More(); aMapIt.Next())
5940 const TCollection_AsciiString& aKey = aMapIt.Key();
5941 const Handle(TColStd_HSequenceOfAsciiString)& aValues = aMapIt.Value();
5943 if (!(aKey.IsEqual ("SCALE") && (aValues->Length() == 1 || aValues->IsEmpty()))
5944 && !(aKey.IsEqual ("SIZE") && (aValues->Length() == 1 || aValues->IsEmpty()))
5945 && !(aKey.IsEqual ("EYE") && (aValues->Length() == 3 || aValues->IsEmpty()))
5946 && !(aKey.IsEqual ("AT") && (aValues->Length() == 3 || aValues->IsEmpty()))
5947 && !(aKey.IsEqual ("UP") && (aValues->Length() == 3 || aValues->IsEmpty()))
5948 && !(aKey.IsEqual ("PROJ") && (aValues->Length() == 3 || aValues->IsEmpty()))
5949 && !(aKey.IsEqual ("CENTER") && aValues->Length() == 2))
5951 TCollection_AsciiString aLowerKey;
5954 aLowerKey.LowerCase();
5955 std::cout << theArgVec[0] << ": " << aLowerKey << " is unknown option, or number of arguments is invalid.\n";
5956 std::cout << "Type help for more information.\n";
5961 Handle(TColStd_HSequenceOfAsciiString) aValues;
5963 // Change view parameters in proper order
5964 if (aMapOfKeysByValues.Find ("SCALE", aValues))
5966 if (aValues->IsEmpty())
5968 theDi << "Scale: " << anAISView->Scale() << "\n";
5972 anAISView->SetScale (aValues->Value(1).RealValue());
5975 if (aMapOfKeysByValues.Find ("SIZE", aValues))
5977 if (aValues->IsEmpty())
5979 Standard_Real aSizeX = 0.0;
5980 Standard_Real aSizeY = 0.0;
5981 anAISView->Size (aSizeX, aSizeY);
5982 theDi << "Size X: " << aSizeX << " Y: " << aSizeY << "\n";
5986 anAISView->SetSize (aValues->Value(1).RealValue());
5989 if (aMapOfKeysByValues.Find ("EYE", aValues))
5991 if (aValues->IsEmpty())
5993 Standard_Real anEyeX = 0.0;
5994 Standard_Real anEyeY = 0.0;
5995 Standard_Real anEyeZ = 0.0;
5996 anAISView->Eye (anEyeX, anEyeY, anEyeZ);
5997 theDi << "Eye X: " << anEyeX << " Y: " << anEyeY << " Z: " << anEyeZ << "\n";
6001 anAISView->SetEye (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue());
6004 if (aMapOfKeysByValues.Find ("AT", aValues))
6006 if (aValues->IsEmpty())
6008 Standard_Real anAtX = 0.0;
6009 Standard_Real anAtY = 0.0;
6010 Standard_Real anAtZ = 0.0;
6011 anAISView->At (anAtX, anAtY, anAtZ);
6012 theDi << "At X: " << anAtX << " Y: " << anAtY << " Z: " << anAtZ << "\n";
6016 anAISView->SetAt (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue());
6019 if (aMapOfKeysByValues.Find ("PROJ", aValues))
6021 if (aValues->IsEmpty())
6023 Standard_Real aProjX = 0.0;
6024 Standard_Real aProjY = 0.0;
6025 Standard_Real aProjZ = 0.0;
6026 anAISView->Proj (aProjX, aProjY, aProjZ);
6027 theDi << "Proj X: " << aProjX << " Y: " << aProjY << " Z: " << aProjZ << "\n";
6031 anAISView->SetProj (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue());
6034 if (aMapOfKeysByValues.Find ("UP", aValues))
6036 if (aValues->IsEmpty())
6038 Standard_Real anUpX = 0.0;
6039 Standard_Real anUpY = 0.0;
6040 Standard_Real anUpZ = 0.0;
6041 anAISView->Up (anUpX, anUpY, anUpZ);
6042 theDi << "Up X: " << anUpX << " Y: " << anUpY << " Z: " << anUpZ << "\n";
6046 anAISView->SetUp (aValues->Value(1).RealValue(), aValues->Value(2).RealValue(), aValues->Value(3).RealValue());
6049 if (aMapOfKeysByValues.Find ("CENTER", aValues))
6051 anAISView->SetCenter (aValues->Value(1).IntegerValue(), aValues->Value(2).IntegerValue());
6057 //=======================================================================
6058 //function : VChangeSelected
6059 //purpose : Adds the shape to selection or remove one from it
6060 //=======================================================================
6061 static Standard_Integer VChangeSelected (Draw_Interpretor& di,
6062 Standard_Integer argc,
6067 di<<"Usage : " << argv[0] << " shape \n";
6071 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6072 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
6073 TCollection_AsciiString aName(argv[1]);
6074 Handle(AIS_InteractiveObject) anAISObject;
6076 if(!aMap.IsBound2(aName))
6078 di<<"Use 'vdisplay' before";
6083 anAISObject = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
6084 if(anAISObject.IsNull()){
6085 di<<"No interactive object \n";
6089 if(aContext->HasOpenedContext())
6091 aContext->AddOrRemoveSelected(anAISObject);
6095 aContext->AddOrRemoveCurrentObject(anAISObject);
6101 //=======================================================================
6102 //function : VZClipping
6103 //purpose : Gets or sets ZClipping mode, width and depth
6104 //=======================================================================
6105 static Standard_Integer VZClipping (Draw_Interpretor& di,
6106 Standard_Integer argc,
6111 di << "Usage : " << argv[0] << " [mode] [depth width]" << "\n"
6112 <<"mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
6115 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6116 if(aContext.IsNull())
6118 di << "use 'vinit' command before " << argv[0] << "\n";
6121 Handle(V3d_View) aView = ViewerTest::CurrentView();
6122 V3d_TypeOfZclipping aZClippingMode = V3d_OFF;
6125 TCollection_AsciiString aZClippingModeString;
6126 Quantity_Length aDepth, aWidth;
6127 aZClippingMode = aView->ZClipping(aDepth, aWidth);
6128 switch (aZClippingMode)
6131 aZClippingModeString.Copy("OFF");
6134 aZClippingModeString.Copy("BACK");
6137 aZClippingModeString.Copy("FRONT");
6140 aZClippingModeString.Copy("SLICE");
6143 aZClippingModeString.Copy(TCollection_AsciiString(aZClippingMode));
6146 di << "ZClippingMode = " << aZClippingModeString.ToCString() << "\n"
6147 << "ZClipping depth = " << aDepth << "\n"
6148 << "ZClipping width = " << aWidth << "\n";
6154 Standard_Integer aStatus = 0;
6155 if ( strcmp (argv [1], "OFF") == 0 ) {
6157 aZClippingMode = V3d_OFF;
6159 if ( strcmp (argv [1], "BACK") == 0 ) {
6161 aZClippingMode = V3d_BACK;
6163 if ( strcmp (argv [1], "FRONT") == 0 ) {
6165 aZClippingMode = V3d_FRONT;
6167 if ( strcmp (argv [1], "SLICE") == 0 ) {
6169 aZClippingMode = V3d_SLICE;
6173 di << "Bad mode; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
6174 << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
6177 aView->SetZClippingType(aZClippingMode);
6181 Quantity_Length aDepth = 0., aWidth = 1.;
6184 aDepth = Draw::Atof (argv[1]);
6185 aWidth = Draw::Atof (argv[2]);
6189 aDepth = Draw::Atof (argv[2]);
6190 aWidth = Draw::Atof (argv[3]);
6193 if(aDepth<0. || aDepth>1.)
6195 di << "Bad depth; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
6196 << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
6199 if(aWidth<0. || aWidth>1.)
6201 di << "Bad width; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
6202 << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
6206 aView->SetZClippingDepth(aDepth);
6207 aView->SetZClippingWidth(aWidth);
6214 //=======================================================================
6215 //function : VNbSelected
6216 //purpose : Returns number of selected objects
6217 //=======================================================================
6218 static Standard_Integer VNbSelected (Draw_Interpretor& di,
6219 Standard_Integer argc,
6224 di << "Usage : " << argv[0] << "\n";
6227 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6228 if(aContext.IsNull())
6230 di << "use 'vinit' command before " << argv[0] << "\n";
6233 di << aContext->NbSelected() << "\n";
6237 //=======================================================================
6238 //function : VAntialiasing
6239 //purpose : Switches altialiasing on or off
6240 //=======================================================================
6241 static Standard_Integer VAntialiasing (Draw_Interpretor& di,
6242 Standard_Integer argc,
6247 di << "Usage : " << argv[0] << " [1|0]" << "\n";
6251 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6252 if(aContext.IsNull())
6254 di << "use 'vinit' command before " << argv[0] << "\n";
6258 Handle(V3d_View) aView = ViewerTest::CurrentView();
6260 if((argc == 2) && (atof(argv[1]) == 0))
6261 aView->SetAntialiasingOff();
6263 aView->SetAntialiasingOn();
6268 //=======================================================================
6269 //function : VPurgeDisplay
6270 //purpose : Switches altialiasing on or off
6271 //=======================================================================
6272 static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
6273 Standard_Integer argc,
6278 di << "Usage : " << argv[0] << "\n";
6281 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6282 if (aContext.IsNull())
6284 di << "use 'vinit' command before " << argv[0] << "\n";
6287 aContext->CloseAllContexts(Standard_False);
6288 di << aContext->PurgeDisplay() << "\n";
6292 //=======================================================================
6293 //function : VSetViewSize
6295 //=======================================================================
6296 static Standard_Integer VSetViewSize (Draw_Interpretor& di,
6297 Standard_Integer argc,
6300 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6301 if(aContext.IsNull())
6303 di << "use 'vinit' command before " << argv[0] << "\n";
6308 di<<"Usage : " << argv[0] << " Size\n";
6311 Standard_Real aSize = Draw::Atof (argv[1]);
6314 di<<"Bad Size value : " << aSize << "\n";
6318 Handle(V3d_View) aView = ViewerTest::CurrentView();
6319 aView->SetSize(aSize);
6323 //=======================================================================
6324 //function : VMoveView
6326 //=======================================================================
6327 static Standard_Integer VMoveView (Draw_Interpretor& di,
6328 Standard_Integer argc,
6331 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6332 if(aContext.IsNull())
6334 di << "use 'vinit' command before " << argv[0] << "\n";
6337 if(argc < 4 || argc > 5)
6339 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
6342 Standard_Real Dx = Draw::Atof (argv[1]);
6343 Standard_Real Dy = Draw::Atof (argv[2]);
6344 Standard_Real Dz = Draw::Atof (argv[3]);
6345 Standard_Boolean aStart = Standard_True;
6348 aStart = (Draw::Atoi (argv[4]) > 0);
6351 Handle(V3d_View) aView = ViewerTest::CurrentView();
6352 aView->Move(Dx,Dy,Dz,aStart);
6356 //=======================================================================
6357 //function : VTranslateView
6359 //=======================================================================
6360 static Standard_Integer VTranslateView (Draw_Interpretor& di,
6361 Standard_Integer argc,
6364 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6365 if(aContext.IsNull())
6367 di << "use 'vinit' command before " << argv[0] << "\n";
6370 if(argc < 4 || argc > 5)
6372 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
6375 Standard_Real Dx = Draw::Atof (argv[1]);
6376 Standard_Real Dy = Draw::Atof (argv[2]);
6377 Standard_Real Dz = Draw::Atof (argv[3]);
6378 Standard_Boolean aStart = Standard_True;
6381 aStart = (Draw::Atoi (argv[4]) > 0);
6384 Handle(V3d_View) aView = ViewerTest::CurrentView();
6385 aView->Translate(Dx,Dy,Dz,aStart);
6389 //=======================================================================
6390 //function : VTurnView
6392 //=======================================================================
6393 static Standard_Integer VTurnView (Draw_Interpretor& di,
6394 Standard_Integer argc,
6397 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6398 if(aContext.IsNull()) {
6399 di << "use 'vinit' command before " << argv[0] << "\n";
6402 if(argc < 4 || argc > 5){
6403 di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n";
6406 Standard_Real Ax = Draw::Atof (argv[1]);
6407 Standard_Real Ay = Draw::Atof (argv[2]);
6408 Standard_Real Az = Draw::Atof (argv[3]);
6409 Standard_Boolean aStart = Standard_True;
6412 aStart = (Draw::Atoi (argv[4]) > 0);
6415 Handle(V3d_View) aView = ViewerTest::CurrentView();
6416 aView->Turn(Ax,Ay,Az,aStart);
6420 //==============================================================================
6421 //function : VTextureEnv
6422 //purpose : ENables or disables environment mapping
6423 //==============================================================================
6424 class OCC_TextureEnv : public Graphic3d_TextureEnv
6427 OCC_TextureEnv(const Standard_CString FileName);
6428 OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName);
6429 void SetTextureParameters(const Standard_Boolean theRepeatFlag,
6430 const Standard_Boolean theModulateFlag,
6431 const Graphic3d_TypeOfTextureFilter theFilter,
6432 const Standard_ShortReal theXScale,
6433 const Standard_ShortReal theYScale,
6434 const Standard_ShortReal theXShift,
6435 const Standard_ShortReal theYShift,
6436 const Standard_ShortReal theAngle);
6437 DEFINE_STANDARD_RTTI(OCC_TextureEnv);
6439 DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv);
6440 IMPLEMENT_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv);
6441 IMPLEMENT_STANDARD_RTTIEXT(OCC_TextureEnv, Graphic3d_TextureEnv);
6443 OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName)
6444 : Graphic3d_TextureEnv(theFileName)
6448 OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId)
6449 : Graphic3d_TextureEnv(theTexId)
6453 void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag,
6454 const Standard_Boolean theModulateFlag,
6455 const Graphic3d_TypeOfTextureFilter theFilter,
6456 const Standard_ShortReal theXScale,
6457 const Standard_ShortReal theYScale,
6458 const Standard_ShortReal theXShift,
6459 const Standard_ShortReal theYShift,
6460 const Standard_ShortReal theAngle)
6462 myParams->SetRepeat (theRepeatFlag);
6463 myParams->SetModulate (theModulateFlag);
6464 myParams->SetFilter (theFilter);
6465 myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale));
6466 myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift));
6467 myParams->SetRotation (theAngle);
6470 static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec)
6472 // get the active view
6473 Handle(V3d_View) aView = ViewerTest::CurrentView();
6476 std::cerr << "No active view. Please call vinit.\n";
6480 // Checking the input arguments
6481 Standard_Boolean anEnableFlag = Standard_False;
6482 Standard_Boolean isOk = theArgNb >= 2;
6485 TCollection_AsciiString anEnableOpt(theArgVec[1]);
6486 anEnableFlag = anEnableOpt.IsEqual("on");
6487 isOk = anEnableFlag || anEnableOpt.IsEqual("off");
6491 isOk = (theArgNb == 3 || theArgNb == 11);
6494 TCollection_AsciiString aTextureOpt(theArgVec[2]);
6495 isOk = (!aTextureOpt.IsIntegerValue() ||
6496 (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN));
6498 if (isOk && theArgNb == 11)
6500 TCollection_AsciiString aRepeatOpt (theArgVec[3]),
6501 aModulateOpt(theArgVec[4]),
6502 aFilterOpt (theArgVec[5]),
6503 aSScaleOpt (theArgVec[6]),
6504 aTScaleOpt (theArgVec[7]),
6505 aSTransOpt (theArgVec[8]),
6506 aTTransOpt (theArgVec[9]),
6507 anAngleOpt (theArgVec[10]);
6508 isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) &&
6509 (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) &&
6510 (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) &&
6511 aSScaleOpt.IsRealValue() && aTScaleOpt.IsRealValue() &&
6512 aSTransOpt.IsRealValue() && aTTransOpt.IsRealValue() &&
6513 anAngleOpt.IsRealValue());
6520 std::cerr << "Usage :" << std::endl;
6521 std::cerr << theArgVec[0] << " off" << std::endl;
6522 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;
6528 TCollection_AsciiString aTextureOpt(theArgVec[2]);
6529 Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ?
6530 new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) :
6531 new OCC_TextureEnv(theArgVec[2]);
6535 TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]);
6536 aTexEnv->SetTextureParameters(
6537 aRepeatOpt. IsEqual("repeat"),
6538 aModulateOpt.IsEqual("modulate"),
6539 aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST :
6540 aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR :
6541 Graphic3d_TOTF_TRILINEAR,
6542 (Standard_ShortReal)Draw::Atof(theArgVec[6]),
6543 (Standard_ShortReal)Draw::Atof(theArgVec[7]),
6544 (Standard_ShortReal)Draw::Atof(theArgVec[8]),
6545 (Standard_ShortReal)Draw::Atof(theArgVec[9]),
6546 (Standard_ShortReal)Draw::Atof(theArgVec[10])
6549 aView->SetTextureEnv(aTexEnv);
6550 aView->SetSurfaceDetail(V3d_TEX_ENVIRONMENT);
6552 else // Disabling environment mapping
6554 aView->SetSurfaceDetail(V3d_TEX_NONE);
6555 Handle(Graphic3d_TextureEnv) aTexture;
6556 aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data
6563 //===============================================================================================
6564 //function : VClipPlane
6566 //===============================================================================================
6567 static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
6569 // use short-cut for created clip planes map of created (or "registered by name") clip planes
6570 typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
6571 static MapOfPlanes aRegPlanes;
6575 theDi << theArgVec[0] << ": command argument is required. Type help for more information.\n";
6579 TCollection_AsciiString aCommand (theArgVec[1]);
6581 // print maximum number of planes for current viewer
6582 if (aCommand == "maxplanes")
6586 theDi << theArgVec[0] << ": view name is required. Type help for more information.\n";
6590 TCollection_AsciiString aViewName (theArgVec[2]);
6592 if (!ViewerTest_myViews.IsBound1 (aViewName))
6594 theDi << theArgVec[0] << ": view is not found.\n";
6598 const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName);
6600 theDi << theArgVec[0] << ": "
6601 << aView->Viewer()->Driver()->InquirePlaneLimit()
6602 << " plane slots provided by driver."
6603 << " Note that 2 more planes might be used (reserved for z-clipping).\n";
6608 // create / delete plane instance
6609 if (aCommand == "create" || aCommand == "delete" || aCommand == "clone")
6613 theDi << theArgVec[0] << ": plane name is required. Type help for more information.\n";
6617 Standard_Boolean toCreate = (aCommand == "create");
6618 Standard_Boolean toClone = (aCommand == "clone");
6619 TCollection_AsciiString aPlane (theArgVec[2]);
6623 if (aRegPlanes.IsBound (aPlane))
6625 theDi << theArgVec[0] << ": plane name is in use.\n";
6629 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
6631 else if (toClone) // toClone
6633 if (!aRegPlanes.IsBound (aPlane))
6635 theDi << theArgVec[0] << ": no such plane.\n";
6641 theDi << theArgVec[0] << ": enter name for new plane. Type help for more information.\n";
6645 TCollection_AsciiString aClone (theArgVec[3]);
6646 if (aRegPlanes.IsBound (aClone))
6648 theDi << theArgVec[0] << ": plane name is in use.\n";
6652 const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
6654 aRegPlanes.Bind (aClone, aClipPlane->Clone());
6658 if (!aRegPlanes.IsBound (aPlane))
6660 theDi << theArgVec[0] << ": no such plane.\n";
6664 Handle(Graphic3d_ClipPlane) aClipPlane = aRegPlanes.Find (aPlane);
6665 aRegPlanes.UnBind (aPlane);
6667 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
6668 for (; anIObjIt.More(); anIObjIt.Next())
6670 Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anIObjIt.Key1());
6671 aPrs->RemoveClipPlane(aClipPlane);
6674 NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
6675 for (; aViewIt.More(); aViewIt.Next())
6677 const Handle(V3d_View)& aView = aViewIt.Key2();
6678 aView->RemoveClipPlane(aClipPlane);
6681 ViewerTest::RedrawAllViews();
6687 // set / unset plane command
6688 if (aCommand == "set" || aCommand == "unset")
6692 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6696 Standard_Boolean toSet = (aCommand == "set");
6697 TCollection_AsciiString aPlane (theArgVec [2]);
6698 if (!aRegPlanes.IsBound (aPlane))
6700 theDi << theArgVec[0] << ": no such plane.\n";
6704 const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
6706 TCollection_AsciiString aTarget (theArgVec [3]);
6707 if (aTarget != "object" && aTarget != "view")
6709 theDi << theArgVec[0] << ": invalid target.\n";
6713 if (aTarget == "object" || aTarget == "view")
6717 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6721 Standard_Boolean isObject = (aTarget == "object");
6723 for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
6725 TCollection_AsciiString anEntityName (theArgVec[anIt]);
6726 if (isObject) // to object
6728 if (!GetMapOfAIS().IsBound2 (anEntityName))
6730 theDi << theArgVec[0] << ": can not find IO with name " << anEntityName << ".\n";
6734 Handle(AIS_InteractiveObject) aIObj =
6735 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anEntityName));
6738 aIObj->AddClipPlane (aClipPlane);
6740 aIObj->RemoveClipPlane (aClipPlane);
6744 if (!ViewerTest_myViews.IsBound1 (anEntityName))
6746 theDi << theArgVec[0] << ": can not find View with name " << anEntityName << ".\n";
6750 Handle(V3d_View) aView = ViewerTest_myViews.Find1(anEntityName);
6752 aView->AddClipPlane (aClipPlane);
6754 aView->RemoveClipPlane (aClipPlane);
6758 ViewerTest::RedrawAllViews();
6764 // change plane command
6765 if (aCommand == "change")
6769 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6773 TCollection_AsciiString aPlane (theArgVec [2]);
6774 if (!aRegPlanes.IsBound (aPlane))
6776 theDi << theArgVec[0] << ": no such plane.\n";
6780 const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
6782 TCollection_AsciiString aChangeArg (theArgVec [3]);
6783 if (aChangeArg != "on" && aChangeArg != "off" && aChangeArg != "capping" && aChangeArg != "equation")
6785 theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n";
6789 if (aChangeArg == "on" || aChangeArg == "off") // on / off
6791 aClipPlane->SetOn (aChangeArg == "on");
6793 else if (aChangeArg == "equation") // change equation
6797 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6801 Standard_Real aCoeffA = Draw::Atof (theArgVec [4]);
6802 Standard_Real aCoeffB = Draw::Atof (theArgVec [5]);
6803 Standard_Real aCoeffC = Draw::Atof (theArgVec [6]);
6804 Standard_Real aCoeffD = Draw::Atof (theArgVec [7]);
6805 aClipPlane->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD));
6807 else if (aChangeArg == "capping") // change capping aspects
6811 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6815 TCollection_AsciiString aCappingArg (theArgVec [4]);
6816 if (aCappingArg != "on" && aCappingArg != "off" &&
6817 aCappingArg != "color" && aCappingArg != "texname" &&
6818 aCappingArg != "texscale" && aCappingArg != "texorigin" &&
6819 aCappingArg != "texrotate" && aCappingArg != "hatch")
6821 theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n";
6825 if (aCappingArg == "on" || aCappingArg == "off") // on / off capping
6827 aClipPlane->SetCapping (aCappingArg == "on");
6829 else if (aCappingArg == "color") // color aspect for capping
6833 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6837 Standard_Real aRed = Draw::Atof (theArgVec [5]);
6838 Standard_Real aGrn = Draw::Atof (theArgVec [6]);
6839 Standard_Real aBlu = Draw::Atof (theArgVec [7]);
6841 Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
6842 Quantity_Color aColor (aRed, aGrn, aBlu, Quantity_TOC_RGB);
6843 aMat.SetAmbientColor (aColor);
6844 aMat.SetDiffuseColor (aColor);
6845 aClipPlane->SetCappingMaterial (aMat);
6847 else if (aCappingArg == "texname") // texture name
6851 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6855 TCollection_AsciiString aTextureName (theArgVec [5]);
6857 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
6858 if (!aTexture->IsDone ())
6860 aClipPlane->SetCappingTexture (NULL);
6864 aTexture->EnableModulate();
6865 aTexture->EnableRepeat();
6866 aClipPlane->SetCappingTexture (aTexture);
6869 else if (aCappingArg == "texscale") // texture scale
6871 if (aClipPlane->CappingTexture().IsNull())
6873 theDi << theArgVec[0] << ": no texture is set.\n";
6879 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6883 Standard_ShortReal aSx = (Standard_ShortReal)atof (theArgVec [5]);
6884 Standard_ShortReal aSy = (Standard_ShortReal)atof (theArgVec [6]);
6886 aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
6888 else if (aCappingArg == "texorigin") // texture origin
6890 if (aClipPlane->CappingTexture().IsNull())
6892 theDi << theArgVec[0] << ": no texture is set.\n";
6898 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6902 Standard_ShortReal aTx = (Standard_ShortReal)atof (theArgVec [5]);
6903 Standard_ShortReal aTy = (Standard_ShortReal)atof (theArgVec [6]);
6905 aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
6907 else if (aCappingArg == "texrotate") // texture rotation
6909 if (aClipPlane->CappingTexture().IsNull())
6911 theDi << theArgVec[0] << ": no texture is set.\n";
6917 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6921 Standard_ShortReal aRot = (Standard_ShortReal)atof (theArgVec[5]);
6923 aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
6925 else if (aCappingArg == "hatch") // hatch style
6929 theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
6933 TCollection_AsciiString aHatchStr (theArgVec [5]);
6934 if (aHatchStr == "on")
6936 aClipPlane->SetCappingHatchOn();
6938 else if (aHatchStr == "off")
6940 aClipPlane->SetCappingHatchOff();
6944 aClipPlane->SetCappingHatch ((Aspect_HatchStyle)atoi (theArgVec[5]));
6949 ViewerTest::RedrawAllViews();
6954 theDi << theArgVec[0] << ": invalid command. Type help for more information.\n";
6958 //===============================================================================================
6959 //function : VSetTextureMode
6961 //===============================================================================================
6962 static int VSetTextureMode (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
6966 theDi << theArgVec[0] << ": insufficient command arguments. Type help for more information.\n";
6970 TCollection_AsciiString aViewName (theArgVec[1]);
6971 if (!ViewerTest_myViews.IsBound1 (aViewName))
6973 theDi << theArgVec[0] << ": view is not found.\n";
6977 const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName);
6978 switch (atoi (theArgVec[2]))
6980 case 0: aView->SetSurfaceDetail (V3d_TEX_NONE); break;
6981 case 1: aView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT); break;
6982 case 2: aView->SetSurfaceDetail (V3d_TEX_ALL); break;
6984 theDi << theArgVec[0] << ": invalid mode.\n";
6992 //===============================================================================================
6993 //function : VZRange
6995 //===============================================================================================
6996 static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
6998 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
7000 if (aCurrentView.IsNull())
7002 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
7006 Handle(Graphic3d_Camera) aCamera = aCurrentView->Camera();
7010 theDi << "ZNear: " << aCamera->ZNear() << "\n";
7011 theDi << "ZFar: " << aCamera->ZFar() << "\n";
7017 Standard_Real aNewZNear = Draw::Atof (theArgVec[1]);
7018 Standard_Real aNewZFar = Draw::Atof (theArgVec[2]);
7020 if (aNewZNear >= aNewZFar)
7022 std::cout << theArgVec[0] << ": invalid arguments: znear should be less than zfar.\n";
7026 if (!aCamera->IsOrthographic() && (aNewZNear <= 0.0 || aNewZFar <= 0.0))
7028 std::cout << theArgVec[0] << ": invalid arguments: ";
7029 std::cout << "znear, zfar should be positive for perspective camera.\n";
7033 aCamera->SetZRange (aNewZNear, aNewZFar);
7037 std::cout << theArgVec[0] << ": wrong command arguments. Type help for more information.\n";
7041 aCurrentView->Redraw();
7046 //===============================================================================================
7047 //function : VAutoZFit
7049 //===============================================================================================
7050 static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
7052 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
7054 if (aCurrentView.IsNull())
7056 std::cout << theArgVec[0] << ": Call vinit before this command, please.\n";
7060 Standard_Real aScale = aCurrentView->View()->AutoZFitScaleFactor();
7064 std::cout << theArgVec[0] << ": wrong command arguments. Type help for more information.\n";
7070 theDi << "Auto z-fit mode: " << "\n"
7071 << "On: " << (aCurrentView->View()->AutoZFitMode() ? "enabled" : "disabled") << "\n"
7072 << "Scale: " << aScale << "\n";
7076 Standard_Boolean isOn = Draw::Atoi (theArgVec[1]) == 1;
7080 aScale = Draw::Atoi (theArgVec[2]);
7083 aCurrentView->View()->SetAutoZFitMode (isOn, aScale);
7084 aCurrentView->View()->AutoZFit();
7085 aCurrentView->Redraw();
7090 //! Auxiliary function to print projection type
7091 inline const char* projTypeName (Graphic3d_Camera::Projection theProjType)
7093 switch (theProjType)
7095 case Graphic3d_Camera::Projection_Orthographic: return "orthographic";
7096 case Graphic3d_Camera::Projection_Perspective: return "perspective";
7097 case Graphic3d_Camera::Projection_Stereo: return "stereoscopic";
7098 case Graphic3d_Camera::Projection_MonoLeftEye: return "monoLeftEye";
7099 case Graphic3d_Camera::Projection_MonoRightEye: return "monoRightEye";
7104 //===============================================================================================
7105 //function : VCamera
7107 //===============================================================================================
7108 static int VCamera (Draw_Interpretor& theDI,
7109 Standard_Integer theArgsNb,
7110 const char** theArgVec)
7112 Handle(V3d_View) aView = ViewerTest::CurrentView();
7115 std::cout << "Error: no active view.\n";
7119 Handle(Graphic3d_Camera) aCamera = aView->Camera();
7122 theDI << "ProjType: " << projTypeName (aCamera->ProjectionType()) << "\n";
7123 theDI << "FOVy: " << aCamera->FOVy() << "\n";
7124 theDI << "Distance: " << aCamera->Distance() << "\n";
7125 theDI << "IOD: " << aCamera->IOD() << "\n";
7126 theDI << "IODType: " << (aCamera->GetIODType() == Graphic3d_Camera::IODType_Absolute ? "absolute" : "relative") << "\n";
7127 theDI << "ZFocus: " << aCamera->ZFocus() << "\n";
7128 theDI << "ZFocusType: " << (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Absolute ? "absolute" : "relative") << "\n";
7132 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
7134 Standard_CString anArg = theArgVec[anArgIter];
7135 TCollection_AsciiString anArgCase (anArg);
7136 anArgCase.LowerCase();
7137 if (anArgCase == "-proj"
7138 || anArgCase == "-projection"
7139 || anArgCase == "-projtype"
7140 || anArgCase == "-projectiontype")
7142 theDI << projTypeName (aCamera->ProjectionType()) << " ";
7144 else if (anArgCase == "-ortho"
7145 || anArgCase == "-orthographic")
7147 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
7149 else if (anArgCase == "-persp"
7150 || anArgCase == "-perspective"
7151 || anArgCase == "-perspmono"
7152 || anArgCase == "-perspectivemono"
7153 || anArgCase == "-mono")
7155 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
7157 else if (anArgCase == "-stereo"
7158 || anArgCase == "-stereoscopic"
7159 || anArgCase == "-perspstereo"
7160 || anArgCase == "-perspectivestereo")
7162 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
7164 else if (anArgCase == "-left"
7165 || anArgCase == "-lefteye"
7166 || anArgCase == "-monoleft"
7167 || anArgCase == "-monolefteye"
7168 || anArgCase == "-perpsleft"
7169 || anArgCase == "-perpslefteye")
7171 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
7173 else if (anArgCase == "-right"
7174 || anArgCase == "-righteye"
7175 || anArgCase == "-monoright"
7176 || anArgCase == "-monorighteye"
7177 || anArgCase == "-perpsright")
7179 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
7181 else if (anArgCase == "-dist"
7182 || anArgCase == "-distance")
7184 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
7185 if (anArgValue != NULL
7186 && *anArgValue != '-')
7189 aCamera->SetDistance (Draw::Atof (anArgValue));
7192 theDI << aCamera->Distance() << " ";
7194 else if (anArgCase == "-iod")
7196 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
7197 if (anArgValue != NULL
7198 && *anArgValue != '-')
7201 aCamera->SetIOD (aCamera->GetIODType(), Draw::Atof (anArgValue));
7204 theDI << aCamera->IOD() << " ";
7206 else if (anArgCase == "-iodtype")
7208 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
7209 TCollection_AsciiString anValueCase (anArgValue);
7210 anValueCase.LowerCase();
7211 if (anValueCase == "abs"
7212 || anValueCase == "absolute")
7215 aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD());
7218 else if (anValueCase == "rel"
7219 || anValueCase == "relative")
7222 aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD());
7225 else if (*anArgValue != '-')
7227 std::cout << "Error: unknown IOD type '" << anArgValue << "'\n";
7230 switch (aCamera->GetIODType())
7232 case Graphic3d_Camera::IODType_Absolute: theDI << "absolute "; break;
7233 case Graphic3d_Camera::IODType_Relative: theDI << "relative "; break;
7236 else if (anArgCase == "-zfocus")
7238 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
7239 if (anArgValue != NULL
7240 && *anArgValue != '-')
7243 aCamera->SetZFocus (aCamera->ZFocusType(), Draw::Atof (anArgValue));
7246 theDI << aCamera->ZFocus() << " ";
7248 else if (anArgCase == "-zfocustype")
7250 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
7251 TCollection_AsciiString anValueCase (anArgValue);
7252 anValueCase.LowerCase();
7253 if (anValueCase == "abs"
7254 || anValueCase == "absolute")
7257 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus());
7260 else if (anValueCase == "rel"
7261 || anValueCase == "relative")
7264 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus());
7267 else if (*anArgValue != '-')
7269 std::cout << "Error: unknown ZFocus type '" << anArgValue << "'\n";
7272 switch (aCamera->ZFocusType())
7274 case Graphic3d_Camera::FocusType_Absolute: theDI << "absolute "; break;
7275 case Graphic3d_Camera::FocusType_Relative: theDI << "relative "; break;
7278 else if (anArgCase == "-fov"
7279 || anArgCase == "-fovy")
7281 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
7282 if (anArgValue != NULL
7283 && *anArgValue != '-')
7286 aCamera->SetFOVy (Draw::Atof (anArgValue));
7289 theDI << aCamera->FOVy() << " ";
7293 std::cout << "Error: unknown argument '" << anArg << "'\n";
7298 aView->View()->AutoZFit();
7304 //==============================================================================
7305 //function : VStereo
7307 //==============================================================================
7309 static int VStereo (Draw_Interpretor& theDI,
7310 Standard_Integer theArgNb,
7311 const char** theArgVec)
7315 Handle(V3d_View) aView = ViewerTest::CurrentView();
7318 std::cerr << "No active view. Please call vinit.\n";
7322 Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
7323 theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
7327 ViewerTest_myDefaultCaps.contextStereo = Draw::Atoi (theArgVec[1]) != 0;
7331 //===============================================================================================
7332 //function : VDefaults
7334 //===============================================================================================
7335 static int VDefaults (Draw_Interpretor& theDi,
7336 Standard_Integer theArgsNb,
7337 const char** theArgVec)
7339 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
7342 std::cerr << "No active viewer!\n";
7346 Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer();
7349 if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE)
7351 theDi << "DeflType: relative\n"
7352 << "DeviationCoeff: " << aDefParams->DeviationCoefficient() << "\n";
7356 theDi << "DeflType: absolute\n"
7357 << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n";
7359 theDi << "AngularDeflection: " << (180.0 * aDefParams->HLRAngle() / M_PI) << "\n";
7360 theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n";
7364 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
7366 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7368 if (anArg == "-ABSDEFL"
7369 || anArg == "-ABSOLUTEDEFLECTION"
7371 || anArg == "-DEFLECTION")
7373 if (++anArgIter >= theArgsNb)
7375 std::cout << "Error: wrong syntax at " << anArg << "\n";
7378 aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
7379 aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter]));
7381 else if (anArg == "-RELDEFL"
7382 || anArg == "-RELATIVEDEFLECTION"
7383 || anArg == "-DEVCOEFF"
7384 || anArg == "-DEVIATIONCOEFF"
7385 || anArg == "-DEVIATIONCOEFFICIENT")
7387 if (++anArgIter >= theArgsNb)
7389 std::cout << "Error: wrong syntax at " << anArg << "\n";
7392 aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
7393 aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter]));
7395 else if (anArg == "-ANGDEFL"
7396 || anArg == "-ANGULARDEFL"
7397 || anArg == "-ANGULARDEFLECTION")
7399 if (++anArgIter >= theArgsNb)
7401 std::cout << "Error: wrong syntax at " << anArg << "\n";
7404 // currently HLRDeviationAngle is used instead of DeviationAngle in most places
7405 aDefParams->SetHLRAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0);
7407 else if (anArg == "-AUTOTR"
7408 || anArg == "-AUTOTRIANG"
7409 || anArg == "-AUTOTRIANGULATION")
7411 if (++anArgIter >= theArgsNb)
7413 std::cout << "Error: wrong syntax at " << anArg << "\n";
7416 TCollection_AsciiString aValue (theArgVec[anArgIter]);
7421 aDefParams->SetAutoTriangulation (Standard_True);
7423 else if (aValue == "off"
7426 aDefParams->SetAutoTriangulation (Standard_False);
7431 std::cerr << "Warning, unknown argument '" << anArg.ToCString() << "'\n";
7438 //! Auxiliary method
7439 inline void addLight (const Handle(V3d_Light)& theLightNew,
7440 const Standard_Boolean theIsGlobal)
7442 if (theLightNew.IsNull())
7449 ViewerTest::GetViewerFromContext()->SetLightOn (theLightNew);
7453 ViewerTest::CurrentView()->SetLightOn (theLightNew);
7457 //! Auxiliary method
7458 inline Standard_Integer getLightId (const TCollection_AsciiString& theArgNext)
7460 TCollection_AsciiString anArgNextCase (theArgNext);
7461 anArgNextCase.UpperCase();
7462 if (anArgNextCase.Length() > 5
7463 && anArgNextCase.SubString (1, 5).IsEqual ("LIGHT"))
7465 return theArgNext.SubString (6, theArgNext.Length()).IntegerValue();
7469 return theArgNext.IntegerValue();
7473 //===============================================================================================
7476 //===============================================================================================
7477 static int VLight (Draw_Interpretor& theDi,
7478 Standard_Integer theArgsNb,
7479 const char** theArgVec)
7481 Handle(V3d_View) aView = ViewerTest::CurrentView();
7482 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
7484 || aViewer.IsNull())
7486 std::cerr << "No active viewer!\n";
7490 Standard_Real anXYZ[3];
7491 Quantity_Coefficient anAtten[2];
7494 // print lights info
7495 Standard_Integer aLightId = 0;
7496 for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightId)
7498 Handle(V3d_Light) aLight = aView->ActiveLight();
7499 const Quantity_Color aColor = aLight->Color();
7500 theDi << "Light" << aLightId << "\n";
7501 switch (aLight->Type())
7505 theDi << " Type: Ambient\n";
7506 theDi << " Intensity: " << aLight->Intensity() << "\n";
7509 case V3d_DIRECTIONAL:
7511 Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLight);
7512 theDi << " Type: Directional\n";
7513 theDi << " Intensity: " << aLight->Intensity() << "\n";
7514 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
7515 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
7516 if (!aLightDir.IsNull())
7518 aLightDir->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
7519 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
7520 aLightDir->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
7521 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
7525 case V3d_POSITIONAL:
7527 Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight)::DownCast (aLight);
7528 theDi << " Type: Positional\n";
7529 theDi << " Intensity: " << aLight->Intensity() << "\n";
7530 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
7531 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
7532 if (!aLightPos.IsNull())
7534 aLightPos->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
7535 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
7536 aLightPos->Attenuation (anAtten[0], anAtten[1]);
7537 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
7543 Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight)::DownCast (aLight);
7544 theDi << " Type: Spot\n";
7545 theDi << " Intensity: " << aLight->Intensity() << "\n";
7546 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
7547 if (!aLightSpot.IsNull())
7549 aLightSpot->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
7550 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
7551 aLightSpot->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
7552 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
7553 aLightSpot->Attenuation (anAtten[0], anAtten[1]);
7554 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
7555 theDi << " Angle: " << (aLightSpot->Angle() * 180.0 / M_PI) << "\n";
7556 theDi << " Exponent: " << aLightSpot->Concentration() << "\n";
7562 theDi << " Type: UNKNOWN\n";
7566 theDi << " Color: " << aColor.Red() << ", " << aColor.Green() << ", " << aColor.Blue() << "\n";
7570 Handle(V3d_Light) aLightNew;
7571 Handle(V3d_Light) aLightOld;
7572 Standard_Boolean isGlobal = Standard_True;
7573 Standard_Boolean toCreate = Standard_False;
7574 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
7576 Handle(V3d_Light) aLightCurr = aLightNew.IsNull() ? aLightOld : aLightNew;
7577 Handle(V3d_AmbientLight) aLightAmb = Handle(V3d_AmbientLight) ::DownCast (aLightCurr);
7578 Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLightCurr);
7579 Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight) ::DownCast (aLightCurr);
7580 Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight) ::DownCast (aLightCurr);
7582 TCollection_AsciiString aName, aValue;
7583 const TCollection_AsciiString anArg (theArgVec[anArgIt]);
7584 TCollection_AsciiString anArgCase (anArg);
7585 anArgCase.UpperCase();
7586 if (anArgCase.IsEqual ("NEW")
7587 || anArgCase.IsEqual ("ADD")
7588 || anArgCase.IsEqual ("CREATE"))
7590 toCreate = Standard_True;
7592 else if (anArgCase.IsEqual ("GLOB")
7593 || anArgCase.IsEqual ("GLOBAL"))
7595 isGlobal = Standard_True;
7597 else if (anArgCase.IsEqual ("LOC")
7598 || anArgCase.IsEqual ("LOCAL"))
7600 isGlobal = Standard_False;
7602 else if (anArgCase.IsEqual ("DEF")
7603 || anArgCase.IsEqual ("DEFAULTS"))
7605 toCreate = Standard_False;
7606 aViewer->SetDefaultLights();
7608 else if (anArgCase.IsEqual ("CLR")
7609 || anArgCase.IsEqual ("CLEAR"))
7611 toCreate = Standard_False;
7612 aView->InitActiveLights();
7613 while (aView->MoreActiveLights())
7615 aViewer->DelLight (aView->ActiveLight());
7616 aView->InitActiveLights();
7619 else if (anArgCase.IsEqual ("AMB")
7620 || anArgCase.IsEqual ("AMBIENT")
7621 || anArgCase.IsEqual ("AMBLIGHT"))
7623 addLight (aLightNew, isGlobal);
7626 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7629 toCreate = Standard_False;
7630 aLightNew = new V3d_AmbientLight (aViewer);
7632 else if (anArgCase.IsEqual ("DIRECTIONAL")
7633 || anArgCase.IsEqual ("DIRLIGHT"))
7635 addLight (aLightNew, isGlobal);
7638 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7641 toCreate = Standard_False;
7642 aLightNew = new V3d_DirectionalLight (aViewer);
7644 else if (anArgCase.IsEqual ("SPOT")
7645 || anArgCase.IsEqual ("SPOTLIGHT"))
7647 addLight (aLightNew, isGlobal);
7650 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7653 toCreate = Standard_False;
7654 aLightNew = new V3d_SpotLight (aViewer, 0.0, 0.0, 0.0);
7656 else if (anArgCase.IsEqual ("POSLIGHT")
7657 || anArgCase.IsEqual ("POSITIONAL"))
7659 addLight (aLightNew, isGlobal);
7662 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7665 toCreate = Standard_False;
7666 aLightNew = new V3d_PositionalLight (aViewer, 0.0, 0.0, 0.0);
7668 else if (anArgCase.IsEqual ("CHANGE"))
7670 addLight (aLightNew, isGlobal);
7671 aLightNew.Nullify();
7672 if (++anArgIt >= theArgsNb)
7674 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7678 const Standard_Integer aLightId = getLightId (theArgVec[anArgIt]);
7679 Standard_Integer aLightIt = 0;
7680 for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightIt)
7682 if (aLightIt == aLightId)
7684 aLightOld = aView->ActiveLight();
7689 if (aLightOld.IsNull())
7691 std::cerr << "Light " << theArgVec[anArgIt] << " is undefined!\n";
7695 else if (anArgCase.IsEqual ("DEL")
7696 || anArgCase.IsEqual ("DELETE"))
7698 Handle(V3d_Light) aLightDel;
7699 if (++anArgIt >= theArgsNb)
7701 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7705 const TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
7706 const Standard_Integer aLightDelId = getLightId (theArgVec[anArgIt]);
7707 Standard_Integer aLightIt = 0;
7708 for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightIt)
7710 aLightDel = aView->ActiveLight();
7711 if (aLightIt == aLightDelId)
7716 if (!aLightDel.IsNull())
7718 aViewer->DelLight (aLightDel);
7721 else if (anArgCase.IsEqual ("COLOR")
7722 || anArgCase.IsEqual ("COLOUR"))
7724 if (++anArgIt >= theArgsNb)
7726 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7730 TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
7731 anArgNext.UpperCase();
7732 const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString());
7733 if (!aLightCurr.IsNull())
7735 aLightCurr->SetColor (aColor);
7738 else if (anArgCase.IsEqual ("POS")
7739 || anArgCase.IsEqual ("POSITION"))
7741 if ((anArgIt + 3) >= theArgsNb)
7743 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7747 anXYZ[0] = Atof (theArgVec[++anArgIt]);
7748 anXYZ[1] = Atof (theArgVec[++anArgIt]);
7749 anXYZ[2] = Atof (theArgVec[++anArgIt]);
7750 if (!aLightDir.IsNull())
7752 aLightDir->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
7754 else if (!aLightPos.IsNull())
7756 aLightPos->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
7758 else if (!aLightSpot.IsNull())
7760 aLightSpot->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
7764 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7768 else if (anArgCase.IsEqual ("DIR")
7769 || anArgCase.IsEqual ("DIRECTION"))
7771 if ((anArgIt + 3) >= theArgsNb)
7773 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7777 anXYZ[0] = Atof (theArgVec[++anArgIt]);
7778 anXYZ[1] = Atof (theArgVec[++anArgIt]);
7779 anXYZ[2] = Atof (theArgVec[++anArgIt]);
7780 if (!aLightDir.IsNull())
7782 aLightDir->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
7784 else if (!aLightSpot.IsNull())
7786 aLightSpot->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
7790 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7794 else if (anArgCase.IsEqual ("SM")
7795 || anArgCase.IsEqual ("SMOOTHNESS"))
7797 if (++anArgIt >= theArgsNb)
7799 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7803 Standard_Real aSmoothness = Atof (theArgVec[anArgIt]);
7805 if (fabs (aSmoothness) < Precision::Confusion())
7807 aLightCurr->SetIntensity (1.f);
7809 else if (fabs (aLightCurr->Smoothness()) < Precision::Confusion())
7811 aLightCurr->SetIntensity ((aSmoothness * aSmoothness) / 3.f);
7815 Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightCurr->Smoothness());
7816 aLightCurr->SetIntensity (aLightCurr->Intensity() / (aSmoothnessRatio * aSmoothnessRatio));
7819 if (!aLightPos.IsNull())
7821 aLightPos->SetSmoothRadius (aSmoothness);
7823 else if (!aLightDir.IsNull())
7825 aLightDir->SetSmoothAngle (aSmoothness);
7828 else if (anArgCase.IsEqual ("INT")
7829 || anArgCase.IsEqual ("INTENSITY"))
7831 if (++anArgIt >= theArgsNb)
7833 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7837 Standard_Real aIntensity = Atof (theArgVec[anArgIt]);
7839 if (!aLightCurr.IsNull())
7841 aLightCurr->SetIntensity (aIntensity);
7844 else if (anArgCase.IsEqual ("ANG")
7845 || anArgCase.IsEqual ("ANGLE"))
7847 if (++anArgIt >= theArgsNb)
7849 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7853 Standard_Real anAngle = Atof (theArgVec[anArgIt]);
7855 if (!aLightSpot.IsNull())
7857 aLightSpot->SetAngle (anAngle / 180.0 * M_PI);
7860 else if (anArgCase.IsEqual ("CONSTATTEN")
7861 || anArgCase.IsEqual ("CONSTATTENUATION"))
7863 if (++anArgIt >= theArgsNb)
7865 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7869 if (!aLightPos.IsNull())
7871 aLightPos->Attenuation (anAtten[0], anAtten[1]);
7872 anAtten[0] = Atof (theArgVec[anArgIt]);
7873 aLightPos->SetAttenuation (anAtten[0], anAtten[1]);
7875 else if (!aLightSpot.IsNull())
7877 aLightSpot->Attenuation (anAtten[0], anAtten[1]);
7878 anAtten[0] = Atof (theArgVec[anArgIt]);
7879 aLightSpot->SetAttenuation (anAtten[0], anAtten[1]);
7883 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7887 else if (anArgCase.IsEqual ("LINATTEN")
7888 || anArgCase.IsEqual ("LINEARATTEN")
7889 || anArgCase.IsEqual ("LINEARATTENUATION"))
7891 if (++anArgIt >= theArgsNb)
7893 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7897 if (!aLightPos.IsNull())
7899 aLightPos->Attenuation (anAtten[0], anAtten[1]);
7900 anAtten[1] = Atof (theArgVec[anArgIt]);
7901 aLightPos->SetAttenuation (anAtten[0], anAtten[1]);
7903 else if (!aLightSpot.IsNull())
7905 aLightSpot->Attenuation (anAtten[0], anAtten[1]);
7906 anAtten[1] = Atof (theArgVec[anArgIt]);
7907 aLightSpot->SetAttenuation (anAtten[0], anAtten[1]);
7911 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7915 else if (anArgCase.IsEqual ("EXP")
7916 || anArgCase.IsEqual ("EXPONENT")
7917 || anArgCase.IsEqual ("SPOTEXP")
7918 || anArgCase.IsEqual ("SPOTEXPONENT"))
7920 if (++anArgIt >= theArgsNb)
7922 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7926 if (!aLightSpot.IsNull())
7928 aLightSpot->SetConcentration (Atof (theArgVec[anArgIt]));
7932 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7936 else if (anArgCase.IsEqual ("HEAD")
7937 || anArgCase.IsEqual ("HEADLIGHT"))
7939 if (++anArgIt >= theArgsNb)
7941 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7945 if (aLightAmb.IsNull()
7946 && !aLightCurr.IsNull())
7948 aLightCurr->SetHeadlight (Draw::Atoi (theArgVec[anArgIt]) != 0);
7952 std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
7958 std::cerr << "Warning: unknown argument '" << anArg << "'\n";
7962 addLight (aLightNew, isGlobal);
7963 aViewer->UpdateLights();
7968 //=======================================================================
7969 //function : VRenderParams
7970 //purpose : Enables/disables rendering features
7971 //=======================================================================
7973 static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
7974 Standard_Integer theArgNb,
7975 const char** theArgVec)
7977 Handle(V3d_View) aView = ViewerTest::CurrentView();
7980 std::cerr << "Error: no active viewer!\n";
7984 Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
7985 TCollection_AsciiString aCmdName (theArgVec[0]);
7986 aCmdName.LowerCase();
7987 if (aCmdName == "vraytrace")
7991 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "on" : "off") << " ";
7994 else if (theArgNb == 2)
7996 TCollection_AsciiString aValue (theArgVec[1]);
8001 aParams.Method = Graphic3d_RM_RAYTRACING;
8005 else if (aValue == "off"
8008 aParams.Method = Graphic3d_RM_RASTERIZATION;
8014 std::cout << "Error: unknown argument '" << theArgVec[1] << "'\n";
8020 std::cout << "Error: wrong number of arguments\n";
8027 theDI << "renderMode: ";
8028 switch (aParams.Method)
8030 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
8031 case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break;
8034 theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n";
8035 theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n";
8036 theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
8037 theDI << "rayDepth: " << aParams.RaytracingDepth << "\n";
8038 theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
8039 theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
8040 theDI << "shadingModel: ";
8041 switch (aView->ShadingModel())
8043 case V3d_COLOR: theDI << "color"; break;
8044 case V3d_FLAT: theDI << "flat"; break;
8045 case V3d_GOURAUD: theDI << "gouraud"; break;
8046 case V3d_PHONG: theDI << "phong"; break;
8052 Standard_Boolean toPrint = Standard_False;
8053 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
8054 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
8056 Standard_CString anArg (theArgVec[anArgIter]);
8057 TCollection_AsciiString aFlag (anArg);
8059 if (anUpdateTool.parseRedrawMode (aFlag))
8063 else if (aFlag == "-echo"
8064 || aFlag == "-print")
8066 toPrint = Standard_True;
8067 anUpdateTool.Invalidate();
8069 else if (aFlag == "-mode"
8070 || aFlag == "-rendermode"
8071 || aFlag == "-render_mode")
8075 switch (aParams.Method)
8077 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
8078 case Graphic3d_RM_RAYTRACING: theDI << "ray-tracing "; break;
8084 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
8088 else if (aFlag == "-ray"
8089 || aFlag == "-raytrace")
8093 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "true" : "false") << " ";
8097 aParams.Method = Graphic3d_RM_RAYTRACING;
8099 else if (aFlag == "-rast"
8100 || aFlag == "-raster"
8101 || aFlag == "-rasterization")
8105 theDI << (aParams.Method == Graphic3d_RM_RASTERIZATION ? "true" : "false") << " ";
8109 aParams.Method = Graphic3d_RM_RASTERIZATION;
8111 else if (aFlag == "-raydepth"
8112 || aFlag == "-ray_depth")
8116 theDI << aParams.RaytracingDepth << " ";
8119 else if (++anArgIter >= theArgNb)
8121 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
8125 const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]);
8127 // We allow RaytracingDepth be more than 10 in case of GI enabled
8128 if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled))
8130 std::cerr << "Error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]\n";
8135 aParams.RaytracingDepth = aDepth;
8138 else if (aFlag == "-shad"
8139 || aFlag == "-shadows")
8143 theDI << (aParams.IsShadowEnabled ? "on" : "off") << " ";
8147 Standard_Boolean toEnable = Standard_True;
8148 if (++anArgIter < theArgNb
8149 && !parseOnOff (theArgVec[anArgIter], toEnable))
8153 aParams.IsShadowEnabled = toEnable;
8155 else if (aFlag == "-refl"
8156 || aFlag == "-reflections")
8160 theDI << (aParams.IsReflectionEnabled ? "on" : "off") << " ";
8164 Standard_Boolean toEnable = Standard_True;
8165 if (++anArgIter < theArgNb
8166 && !parseOnOff (theArgVec[anArgIter], toEnable))
8170 aParams.IsReflectionEnabled = toEnable;
8172 else if (aFlag == "-fsaa")
8176 theDI << (aParams.IsAntialiasingEnabled ? "on" : "off") << " ";
8180 Standard_Boolean toEnable = Standard_True;
8181 if (++anArgIter < theArgNb
8182 && !parseOnOff (theArgVec[anArgIter], toEnable))
8186 aParams.IsAntialiasingEnabled = toEnable;
8188 else if (aFlag == "-gleam")
8192 theDI << (aParams.IsTransparentShadowEnabled ? "on" : "off") << " ";
8196 Standard_Boolean toEnable = Standard_True;
8197 if (++anArgIter < theArgNb
8198 && !parseOnOff (theArgVec[anArgIter], toEnable))
8202 aParams.IsTransparentShadowEnabled = toEnable;
8204 else if (aFlag == "-gi")
8208 theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " ";
8212 Standard_Boolean toEnable = Standard_True;
8213 if (++anArgIter < theArgNb
8214 && !parseOnOff (theArgVec[anArgIter], toEnable))
8218 aParams.IsGlobalIlluminationEnabled = toEnable;
8221 aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
8224 else if (aFlag == "-env")
8228 theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " ";
8232 Standard_Boolean toEnable = Standard_True;
8233 if (++anArgIter < theArgNb
8234 && !parseOnOff (theArgVec[anArgIter], toEnable))
8238 aParams.UseEnvironmentMapBackground = toEnable;
8240 else if (aFlag == "-shademodel"
8241 || aFlag == "-shadingmodel"
8242 || aFlag == "-shading")
8246 switch (aView->ShadingModel())
8248 case V3d_COLOR: theDI << "color "; break;
8249 case V3d_FLAT: theDI << "flat "; break;
8250 case V3d_GOURAUD: theDI << "gouraud "; break;
8251 case V3d_PHONG: theDI << "phong "; break;
8256 if (++anArgIter >= theArgNb)
8258 std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
8261 TCollection_AsciiString aMode (theArgVec[anArgIter]);
8263 if (aMode == "color"
8266 aView->SetShadingModel (V3d_COLOR);
8268 else if (aMode == "flat"
8269 || aMode == "facet")
8271 aView->SetShadingModel (V3d_FLAT);
8273 else if (aMode == "gouraud"
8274 || aMode == "vertex"
8277 aView->SetShadingModel (V3d_GOURAUD);
8279 else if (aMode == "phong"
8280 || aMode == "fragment"
8282 || aMode == "pixel")
8284 aView->SetShadingModel (V3d_PHONG);
8288 std::cout << "Error: unknown shading model '" << aMode << "'\n";
8294 std::cout << "Error: wrong syntax, unknown flag '" << anArg << "'\n";
8302 //=======================================================================
8303 //function : VProgressiveMode
8305 //=======================================================================
8307 static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/,
8308 Standard_Integer /*theNbArgs*/,
8309 const char** /*theArgs*/)
8311 Handle(V3d_View) aView = ViewerTest::CurrentView();
8314 std::cerr << "Error: no active viewer!\n";
8318 std::cout << "Press Enter or Escape key to exit progressive rendering mode" << std::endl;
8324 Standard_Boolean toExit = Standard_False;
8327 while (PeekMessage (&aMsg, NULL, NULL, NULL, PM_REMOVE))
8329 if (aMsg.message == WM_KEYDOWN && (aMsg.wParam == 0x0d || aMsg.wParam == 0x1b))
8331 toExit = Standard_True;
8334 TranslateMessage (&aMsg);
8335 DispatchMessage (&aMsg);
8348 //=======================================================================
8349 //function : VFrustumCulling
8350 //purpose : enables/disables view volume's culling.
8351 //=======================================================================
8352 static int VFrustumCulling (Draw_Interpretor& theDI,
8353 Standard_Integer theArgNb,
8354 const char** theArgVec)
8356 Handle(V3d_View) aView = ViewerTest::CurrentView();
8359 std::cout << theArgVec[0] << " Error: Use 'vinit' command before\n";
8365 theDI << (aView->IsCullingEnabled() ? "on" : "off");
8368 else if (theArgNb != 2)
8370 std::cout << theArgVec[0] << " Syntax error: Specify the mode\n";
8374 TCollection_AsciiString aModeStr (theArgVec[1]);
8375 aModeStr.LowerCase();
8376 Standard_Boolean toEnable = 0;
8377 if (aModeStr == "on")
8381 else if (aModeStr == "off")
8387 toEnable = Draw::Atoi (theArgVec[1]) != 0;
8390 aView->SetFrustumCulling (toEnable);
8395 //=======================================================================
8396 //function : VHighlightSelected
8398 //=======================================================================
8399 static int VHighlightSelected (Draw_Interpretor& theDI,
8400 Standard_Integer theArgNb,
8401 const char** theArgVec)
8403 if (ViewerTest::GetAISContext().IsNull())
8405 std::cout << theArgVec[0] << " error : Context is not created. Please call vinit before.\n";
8409 const Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8413 theDI << (aContext->ToHilightSelected() ? "on" : "off");
8419 std::cout << theArgVec[0] << " error : wrong number of parameters."
8420 << "Type 'help" << theArgVec[0] << "' for more information.";
8425 TCollection_AsciiString aMode (theArgVec[1]);
8427 Standard_Boolean toEnable = Standard_False;
8428 if (aMode.IsEqual ("on"))
8430 toEnable = Standard_True;
8432 else if (aMode.IsEqual ("off"))
8434 toEnable = Standard_False;
8438 toEnable = Draw::Atoi (theArgVec[1]) != 0;
8441 if (toEnable != aContext->ToHilightSelected())
8443 aContext->SetToHilightSelected (toEnable);
8445 // Move cursor to null position and back to process updating of detection
8446 // and highlighting of selected object immediatly.
8447 Standard_Integer aPixX = 0;
8448 Standard_Integer aPixY = 0;
8449 const Handle(ViewerTest_EventManager)& anEventManager = ViewerTest::CurrentEventManager();
8451 anEventManager->GetCurrentPosition (aPixX, aPixY);
8452 anEventManager->MoveTo (0, 0);
8453 anEventManager->MoveTo (aPixX, aPixY);
8459 //=======================================================================
8460 //function : VXRotate
8462 //=======================================================================
8463 static Standard_Integer VXRotate (Draw_Interpretor& di,
8464 Standard_Integer argc,
8467 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8468 if (aContext.IsNull())
8470 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
8476 di << "ERROR : Usage : " << argv[0] << " name angle" << "\n";
8480 TCollection_AsciiString aName (argv[1]);
8481 Standard_Real anAngle = Draw::Atof (argv[2]);
8484 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
8485 Handle(AIS_InteractiveObject) anIObj;
8486 if (!aMap.IsBound2 (aName) )
8488 di << "Use 'vdisplay' before" << "\n";
8493 anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
8496 aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle);
8497 aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart());
8499 aContext->SetLocation (anIObj, aTransform);
8500 aContext->UpdateCurrentViewer();
8506 //=======================================================================
8507 //function : ViewerCommands
8509 //=======================================================================
8511 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
8514 const char *group = "ZeViewer";
8515 theCommands.Add("vinit",
8516 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
8517 "[name=view_name] [display=display_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n"
8519 "[name=view_name] [l=leftPx t=topPx] [w=widthPx h=heightPx]\n"
8521 " - Creates new View window with specified name view_name.\n"
8522 "By default the new view is created in the viewer and in"
8523 " graphic driver shared with active view.\n"
8524 " - name = {driverName/viewerName/viewName | viewerName/viewName | viewName}.\n"
8525 "If driverName isn't specified the driver will be shared with active view.\n"
8526 "If viewerName isn't specified the viewer will be shared with active view.\n"
8527 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
8528 " - display = HostName.DisplayNumber[:ScreenNumber] : if specified"
8529 "is used in creation of graphic driver\n"
8531 " - l, t: pixel position of left top corner of the window\n"
8532 " - w,h: width and heigth of window respectively.\n"
8533 "Additional commands for operations with views: vclose, vactivate, vviewlist.\n",
8534 __FILE__,VInit,group);
8535 theCommands.Add("vclose" ,
8536 "[view_id [keep_context=0|1]]\n"
8537 "or vclose ALL - to remove all created views\n"
8538 " - removes view(viewer window) defined by its view_id.\n"
8539 " - keep_context: by default 0; if 1 and the last view is deleted"
8540 " the current context is not removed.",
8541 __FILE__,VClose,group);
8542 theCommands.Add("vactivate" ,
8544 " - activates view(viewer window) defined by its view_id",
8545 __FILE__,VActivate,group);
8546 theCommands.Add("vviewlist",
8547 "vviewlist [format={tree, long}]"
8548 " - prints current list of views per viewer and graphic_driver ID shared between viewers"
8549 " - format: format of result output, if tree the output is a tree view;"
8550 "otherwise it's a list of full view names. By default format = tree",
8551 __FILE__,VViewList,group);
8552 theCommands.Add("vhelp" ,
8553 "vhelp : display help on the viewer commands",
8554 __FILE__,VHelp,group);
8555 theCommands.Add("vtop" ,
8556 "vtop or <T> : Top view" ,
8557 __FILE__,VTop,group);
8558 theCommands.Add("vbottom" ,
8559 "vbottom : Bottom view" ,
8560 __FILE__,VBottom,group);
8561 theCommands.Add("vleft" ,
8562 "vleft : Left view" ,
8563 __FILE__,VLeft,group);
8564 theCommands.Add("vright" ,
8565 "vright : Right view" ,
8566 __FILE__,VRight,group);
8567 theCommands.Add("vaxo" ,
8568 " vaxo or <A> : Axonometric view ",
8569 __FILE__,VAxo,group);
8570 theCommands.Add("vfront" ,
8571 "vfront : Front view" ,
8572 __FILE__,VFront,group);
8573 theCommands.Add("vback" ,
8574 "vback : Back view" ,
8575 __FILE__,VBack,group);
8576 theCommands.Add("vpick" ,
8577 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
8579 theCommands.Add("vfit" ,
8580 "vfit or <F> [-selected]"
8581 "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects",
8582 __FILE__,VFit,group);
8583 theCommands.Add ("vfitarea",
8584 "vfitarea x1 y1 x2 y2"
8585 "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2"
8586 "\n\t\t: Fit view to show area located between two points"
8587 "\n\t\t: given in world 2D or 3D corrdinates.",
8588 __FILE__, VFitArea, group);
8589 theCommands.Add ("vzfit", "vzfit [scale]\n"
8590 " Matches Z near, Z far view volume planes to the displayed objects.\n"
8591 " \"scale\" - specifies factor to scale computed z range.\n",
8592 __FILE__, VZFit, group);
8593 theCommands.Add("vrepaint",
8594 "vrepaint : vrepaint, force redraw",
8595 __FILE__,VRepaint,group);
8596 theCommands.Add("vclear",
8598 __FILE__,VClear,group);
8599 theCommands.Add("vsetbg",
8600 "vsetbg : vsetbg imagefile [filltype] : Load image as background",
8601 __FILE__,VSetBg,group);
8602 theCommands.Add("vsetbgmode",
8603 "vsetbgmode : vsetbgmode filltype : Change background image fill type",
8604 __FILE__,VSetBgMode,group);
8605 theCommands.Add("vsetgradientbg",
8606 "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background",
8607 __FILE__,VSetGradientBg,group);
8608 theCommands.Add("vsetgrbgmode",
8609 "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type",
8610 __FILE__,VSetGradientBgMode,group);
8611 theCommands.Add("vsetcolorbg",
8612 "vsetcolorbg : vsetcolorbg r g b : Set background color",
8613 __FILE__,VSetColorBg,group);
8614 theCommands.Add("vscale",
8615 "vscale : vscale X Y Z",
8616 __FILE__,VScale,group);
8617 theCommands.Add("vzbufftrihedron",
8618 "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]"
8619 "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]"
8620 "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]"
8621 "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]"
8622 "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]"
8623 "\n\t\t: Displays a trihedron",
8624 __FILE__,VZBuffTrihedron,group);
8625 theCommands.Add("vrotate",
8626 "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]"
8627 "\n : Option -mouseStart starts rotation according to the mouse position"
8628 "\n : Option -mouseMove continues rotation with angle computed"
8629 "\n : from last and new mouse position."
8630 "\n : vrotate AX AY AZ [X Y Z]",
8631 __FILE__,VRotate,group);
8632 theCommands.Add("vzoom",
8633 "vzoom : vzoom coef",
8634 __FILE__,VZoom,group);
8635 theCommands.Add("vpan",
8636 "vpan : vpan dx dy",
8637 __FILE__,VPan,group);
8638 theCommands.Add("vexport",
8639 "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }"
8640 " : exports the view to a vector file of a given format"
8641 " : notice that EMF format requires patched gl2ps",
8642 __FILE__,VExport,group);
8643 theCommands.Add("vcolorscale",
8644 "vcolorscale : vcolorscale [-range RangeMin = 0 RangeMax = 100 Intervals = 10 -font HeightFont = 16 -textpos "
8645 "Position = left -xy X = 0 Y = 0] [-noupdate|-update]: draw color scale\n"
8646 "-demo/-demoversion draw a demoversion of color scale.\n"
8647 "-show/display display color scale.\n"
8648 "-hide/erase erase color scale.\n"
8649 "Please note that -show/-hide option must be the first argument!\n"
8650 "-color Index R G B: set color for indexed interval\n"
8651 "-color Index ColorName: set color for indexed interval\n"
8652 "-colors R G B R G B ...: set colors for all intervals\n"
8653 "-colors ColorName1 ColorName2 ...: set colors for all intervals\n"
8654 "-colors supports both color names and rgb values in one call\n"
8655 "-label Index Text: set label for indexed interval\n"
8656 "-labels Text Text Text ...: set labels for all intervals\n"
8657 "-title Title [Position]: set the title for color scale with certain position. Default position = center;\n"
8658 "Available text positions: left, right, center, none;\n",
8659 __FILE__,VColorScale,group);
8660 theCommands.Add("vgraduatedtrihedron",
8661 "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n"
8662 "\t[-namefont Name] [-valuesfont Name]\n"
8663 "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n"
8664 "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]"
8665 "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n"
8666 "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n"
8667 "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]"
8668 "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n"
8669 "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n"
8670 "\t[-xticks Number] [-yticks Number] [-zticks Number]\n"
8671 "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n"
8672 "\t[-drawgrid on/off] [-drawaxes on/off]\n"
8673 " - Displays or erases graduated trihedron"
8674 " - xname, yname, zname - names of axes, default: X, Y, Z\n"
8675 " - namefont - font of axes names. Default: Arial\n"
8676 " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n"
8677 " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n"
8678 " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n"
8679 " - valuesfont - font of axes values. Default: Arial\n"
8680 " - xcolor, ycolor, zcolor - color of axis and values\n"
8681 " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n"
8682 " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n",
8683 __FILE__,VGraduatedTrihedron,group);
8684 theCommands.Add("vprintview" ,
8685 "vprintview : width height filename [algo=0] [tile_width tile_height] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
8686 __FILE__,VPrintView,group);
8687 theCommands.Add("vzlayer",
8688 "vzlayer add/del/get/settings/enable/disable [id]\n"
8689 " add - add new z layer to viewer and print its id\n"
8690 " del - del z layer by its id\n"
8691 " get - print sequence of z layers in increasing order of their overlay level\n"
8692 " settings - print status of z layer settings\n"
8693 " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n"
8694 " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n"
8695 " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n"
8696 "\nWhere id is the layer identificator\n"
8699 " vzlayer enable poffset 1\n"
8700 " vzlayer disable depthtest 1\n"
8702 __FILE__,VZLayer,group);
8703 theCommands.Add("voverlaytext",
8704 "voverlaytext : text x y [height] [font_name] [text_color: R G B] [display_type] [background_color: R G B]"
8705 " : height - pixel height of the text (default=10.0)"
8706 " : font_name - name of font (default=courier)"
8707 " : text_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0) "
8708 " : display_type = {normal/subtitle/decal/blend}, (default=normal) "
8709 " : background_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0), the parameter is defined for subtitle and decal display types ",
8710 __FILE__,VOverlayText,group);
8711 theCommands.Add("vlayerline",
8712 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
8713 __FILE__,VLayerLine,group);
8714 theCommands.Add ("vgrid",
8715 "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]"
8716 " : Mode - rectangular or circular"
8717 " : Type - lines or points",
8718 __FILE__, VGrid, group);
8719 theCommands.Add ("vpriviledgedplane",
8720 "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]"
8721 "\n\t\t: Ox, Oy, Oz - plane origin"
8722 "\n\t\t: Nx, Ny, Nz - plane normal direction"
8723 "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction"
8724 "\n\t\t: Sets or prints viewer's priviledged plane geometry.",
8725 __FILE__, VPriviledgedPlane, group);
8726 theCommands.Add ("vconvert",
8727 "vconvert v [Mode={window|view}]"
8728 "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]"
8729 "\n\t\t: vconvert x y z [Mode={window|grid}]"
8730 "\n\t\t: window - convert to window coordinates, pixels"
8731 "\n\t\t: view - convert to view projection plane"
8732 "\n\t\t: grid - convert to model coordinates, given on grid"
8733 "\n\t\t: ray - convert projection ray to model coordiantes"
8734 "\n\t\t: - vconvert v window : convert view to window;"
8735 "\n\t\t: - vconvert v view : convert window to view;"
8736 "\n\t\t: - vconvert x y window : convert view to window;"
8737 "\n\t\t: - vconvert x y view : convert window to view;"
8738 "\n\t\t: - vconvert x y : convert window to model;"
8739 "\n\t\t: - vconvert x y grid : convert window to model using grid;"
8740 "\n\t\t: - vconvert x y ray : convert window projection line to model;"
8741 "\n\t\t: - vconvert x y z window : convert model to window;"
8742 "\n\t\t: - vconvert x y z grid : convert view to model using grid;"
8743 "\n\t\t: Converts the given coordinates to window/view/model space.",
8744 __FILE__, VConvert, group);
8745 theCommands.Add ("vfps",
8746 "vfps [framesNb=100] : estimate average frame rate for active view",
8747 __FILE__, VFps, group);
8748 theCommands.Add ("vgldebug",
8749 "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
8750 "\n\t\t: [-extraMsg {0|1}] [{0|1}]"
8751 "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
8752 "\n\t\t: Debug context can be requested only on Windows"
8753 "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
8754 "\n\t\t: -sync - request synchronized debug GL context"
8755 "\n\t\t: -glslWarn - log GLSL compiler/linker warnings,"
8756 "\n\t\t: which are suppressed by default,"
8757 "\n\t\t: -extraMsg - log extra diagnostic messages from GL context,"
8758 "\n\t\t: which are suppressed by default",
8759 __FILE__, VGlDebug, group);
8760 theCommands.Add ("vvbo",
8761 "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
8762 __FILE__, VVbo, group);
8763 theCommands.Add ("vstereo",
8764 "\nvstereo [{0|1}] : turn stereo usage On/Off; affects only newly displayed objects",
8765 __FILE__, VStereo, group);
8766 theCommands.Add ("vcaps",
8767 "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
8768 "\n\t\t: [-compatibleContext {0|1}]"
8769 "\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
8770 "\n\t\t: Modify particular graphic driver options:"
8771 "\n\t\t: FFP - use fixed-function pipeline instead of"
8772 "\n\t\t: built-in GLSL programs"
8773 "\n\t\t: (requires compatible profile)"
8774 "\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
8775 "\n\t\t: arrays to GPU memory)"
8776 "\n\t\t: sprite - use textured sprites instead of bitmaps"
8777 "\n\t\t: Context creation options:"
8778 "\n\t\t: softMode - software OpenGL implementation"
8779 "\n\t\t: compatibleProfile - backward-compatible profile"
8780 "\n\t\t: Unlike vrenderparams, these parameters control alternative"
8781 "\n\t\t: rendering paths producing the same visual result when"
8783 "\n\t\t: Command is intended for testing old hardware compatibility.",
8784 __FILE__, VCaps, group);
8785 theCommands.Add ("vmemgpu",
8786 "vmemgpu [f]: print system-dependent GPU memory information if available;"
8787 " with f option returns free memory in bytes",
8788 __FILE__, VMemGpu, group);
8789 theCommands.Add ("vreadpixel",
8790 "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]"
8791 " : Read pixel value for active view",
8792 __FILE__, VReadPixel, group);
8793 theCommands.Add("diffimage",
8794 "diffimage : diffimage imageFile1 imageFile2 toleranceOfColor(0..1) blackWhite(1|0) borderFilter(1|0) [diffImageFile]",
8795 __FILE__, VDiffImage, group);
8796 theCommands.Add ("vselect",
8797 "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
8798 "- emulates different types of selection:\n"
8799 "- 1) single click selection\n"
8800 "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
8801 "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
8802 "- 4) -allowoverlap determines will partially included objects be selected in rectangular selection"
8803 " (partial inclusion - overlap - is not allowed by default)\n"
8804 "- 5) any of these selections with shift button pressed",
8805 __FILE__, VSelect, group);
8806 theCommands.Add ("vmoveto",
8808 "- emulates cursor movement to pixel postion (x,y)",
8809 __FILE__, VMoveTo, group);
8810 theCommands.Add ("vviewparams", "vviewparams usage:\n"
8812 "- vviewparams [-scale [s]] [-eye [x y z]] [-at [x y z]] [-up [x y z]]\n"
8813 " [-proj [x y z]] [-center x y] [-size sx]\n"
8814 "- Gets or sets current view parameters.\n"
8815 "- If called without arguments, all view parameters are printed.\n"
8816 "- The options are:\n"
8817 " -scale [s] : prints or sets viewport relative scale.\n"
8818 " -eye [x y z] : prints or sets eye location.\n"
8819 " -at [x y z] : prints or sets center of look.\n"
8820 " -up [x y z] : prints or sets direction of up vector.\n"
8821 " -proj [x y z] : prints or sets direction of look.\n"
8822 " -center x y : sets location of center of the screen in pixels.\n"
8823 " -size [sx] : prints viewport projection width and height sizes\n"
8824 " : or changes the size of its maximum dimension.\n",
8825 __FILE__, VViewParams, group);
8826 theCommands.Add("vchangeselected",
8827 "vchangeselected shape"
8828 "- adds to shape to selection or remove one from it",
8829 __FILE__, VChangeSelected, group);
8830 theCommands.Add("vzclipping",
8831 "vzclipping [mode] [depth width]\n"
8832 "- mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]\n"
8833 "- gets or sets ZClipping mode, width and depth",
8834 __FILE__,VZClipping,group);
8835 theCommands.Add ("vnbselected",
8836 "vnbselected", __FILE__, VNbSelected, group);
8837 theCommands.Add ("vcamera",
8838 "vcamera [-ortho] [-projtype]"
8840 "\n\t\t: [-fovy [Angle]] [-distance [Distance]]"
8841 "\n\t\t: [-stereo] [-leftEye] [-rightEye]"
8842 "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]"
8843 "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]"
8844 "\n\t\t: Manage camera parameters."
8845 "\n\t\t: Prints current value when option called without argument."
8846 "\n\t\t: Orthographic camera:"
8847 "\n\t\t: -ortho activate orthographic projection"
8848 "\n\t\t: Perspective camera:"
8849 "\n\t\t: -persp activate perspective projection (mono)"
8850 "\n\t\t: -fovy field of view in y axis, in degrees"
8851 "\n\t\t: -distance distance of eye from camera center"
8852 "\n\t\t: Stereoscopic camera:"
8853 "\n\t\t: -stereo perspective projection (stereo)"
8854 "\n\t\t: -leftEye perspective projection (left eye)"
8855 "\n\t\t: -rightEye perspective projection (right eye)"
8856 "\n\t\t: -iod intraocular distance value"
8857 "\n\t\t: -iodType distance type, absolute or relative"
8858 "\n\t\t: -zfocus stereographic focus value"
8859 "\n\t\t: -zfocusType focus type, absolute or relative",
8860 __FILE__, VCamera, group);
8861 theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n"
8862 "- vautozfit [on={1|0}] [scale]\n"
8863 " Prints or changes parameters of automatic z-fit mode:\n"
8864 " \"on\" - turns automatic z-fit on or off\n"
8865 " \"scale\" - specifies factor to scale computed z range.\n",
8866 __FILE__, VAutoZFit, group);
8867 theCommands.Add ("vzrange", "command to manually access znear and zfar values\n"
8868 " vzrange - without parameters shows current values\n"
8869 " vzrange [znear] [zfar] - applies provided values to view",
8870 __FILE__,VZRange, group);
8871 theCommands.Add("vantialiasing",
8872 "vantialiasing 1|0",
8873 __FILE__,VAntialiasing,group);
8874 theCommands.Add ("vpurgedisplay",
8876 "- removes structures which don't belong to objects displayed in neutral point",
8877 __FILE__, VPurgeDisplay, group);
8878 theCommands.Add("vsetviewsize",
8879 "vsetviewsize size",
8880 __FILE__,VSetViewSize,group);
8881 theCommands.Add("vmoveview",
8882 "vmoveview Dx Dy Dz [Start = 1|0]",
8883 __FILE__,VMoveView,group);
8884 theCommands.Add("vtranslateview",
8885 "vtranslateview Dx Dy Dz [Start = 1|0)]",
8886 __FILE__,VTranslateView,group);
8887 theCommands.Add("vturnview",
8888 "vturnview Ax Ay Az [Start = 1|0]",
8889 __FILE__,VTurnView,group);
8890 theCommands.Add("vtextureenv",
8891 "Enables or disables environment mapping in the 3D view, loading the texture from the given standard "
8892 "or user-defined file and optionally applying texture mapping parameters\n"
8894 " vtextureenv off - disables environment mapping\n"
8895 " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n"
8896 " std_texture = (0..7)\n"
8897 " rep = {clamp|repeat}\n"
8898 " mod = {decal|modulate}\n"
8899 " flt = {nearest|bilinear|trilinear}\n"
8900 " ss, st - scale factors for s and t texture coordinates\n"
8901 " ts, tt - translation for s and t texture coordinates\n"
8902 " rot - texture rotation angle in degrees",
8903 __FILE__, VTextureEnv, group);
8904 theCommands.Add("vhlr" ,
8905 "is_enabled={on|off} [show_hidden={1|0}]"
8906 " - Hidden line removal algorithm:"
8907 " - is_enabled: if is on HLR algorithm is applied\n"
8908 " - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n",
8909 __FILE__,VHLR,group);
8910 theCommands.Add("vhlrtype" ,
8911 "algo_type={algo|polyalgo} [shape_1 ... shape_n]"
8912 " - Changes the type of HLR algorithm using for shapes."
8913 " - algo_type: if equals to algo, exact HLR algorithm is applied;\n"
8914 " if equals to polyalgo, polygonal HLR algorithm is applied."
8915 "If shapes are not given HLR algoithm of given type is applied"
8916 " to all shapes in the view\n",
8917 __FILE__,VHLRType,group);
8918 theCommands.Add("vclipplane", "vclipplane usage: \n"
8919 " maxplanes <view_name> - get plane limit for view.\n"
8920 " create <plane_name> - create new plane.\n"
8921 " delete <plane_name> - delete plane.\n"
8922 " clone <source_plane> <plane_name> - clone the plane definition.\n"
8923 " set/unset <plane_name> object <object list> - set/unset plane for IO.\n"
8924 " set/unset <plane_name> view <view list> - set/unset plane for view.\n"
8925 " change <plane_name> on/off - turn clipping on/off.\n"
8926 " change <plane_name> equation <a> <b> <c> <d> - change plane equation.\n"
8927 " change <plane_name> capping on/off - turn capping on/off.\n"
8928 " change <plane_name> capping color <r> <g> <b> - set color.\n"
8929 " change <plane name> capping texname <texture> - set texture.\n"
8930 " change <plane_name> capping texscale <sx> <sy> - set tex scale.\n"
8931 " change <plane_name> capping texorigin <tx> <ty> - set tex origin.\n"
8932 " change <plane_name> capping texrotate <angle> - set tex rotation.\n"
8933 " change <plane_name> capping hatch on/off/<id> - set hatching mask.\n"
8934 " please use VSetTextureMode command to enable texture rendering in view.\n"
8935 , __FILE__, VClipPlane, group);
8936 theCommands.Add("vsettexturemode", "vsettexturemode view_name mode \n"
8938 " 0 - no textures enabled in view.\n"
8939 " 1 - only environment textures enabled.\n"
8940 " 2 - all textures enabled.\n"
8941 " this command sets texture details mode for the specified view.\n"
8942 , __FILE__, VSetTextureMode, group);
8943 theCommands.Add("vdefaults",
8944 "vdefaults [-absDefl value]"
8945 "\n\t\t: [-devCoeff value]"
8946 "\n\t\t: [-angDefl value]"
8947 "\n\t\t: [-autoTriang {off/on | 0/1}]"
8948 , __FILE__, VDefaults, group);
8949 theCommands.Add("vlight",
8950 "tool to manage light sources, without arguments shows list of lights."
8951 "\n Main commands: "
8952 "\n 'clear' to clear lights"
8953 "\n '{def}aults' to load deafault lights"
8954 "\n 'add' (or 'new') <type> to add any light source"
8955 "\n where <type> is one of {amb}ient|directional|{spot}light|positional"
8956 "\n 'change' <lightId> to edit light source with specified lightId"
8957 "\n\n In addition to 'add' and 'change' commands you can use light parameters:"
8958 "\n {pos}ition X Y Z"
8959 "\n {dir}ection X Y Z (for directional light or for spotlight)"
8960 "\n color colorName"
8961 "\n {head}light 0|1"
8962 "\n {sm}oothness value"
8963 "\n {int}ensity value"
8964 "\n {constAtten}uation value"
8965 "\n {linearAtten}uation value"
8967 "\n {spotexp}onent value"
8969 "\n\n example: vlight add positional head 1 pos 0 1 1 color red"
8970 "\n example: vlight change 0 direction 0 -1 0 linearAttenuation 0.2",
8971 __FILE__, VLight, group);
8972 theCommands.Add("vraytrace",
8974 "\n\t\t: Turns on/off ray-tracing renderer."
8975 "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'."
8976 "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.",
8977 __FILE__, VRenderParams, group);
8978 theCommands.Add("vrenderparams",
8979 "\n Manages rendering parameters: "
8980 "\n '-rayTrace' Enables GPU ray-tracing"
8981 "\n '-raster' Disables GPU ray-tracing"
8982 "\n '-rayDepth 0..10' Defines maximum ray-tracing depth"
8983 "\n '-shadows on|off' Enables/disables shadows rendering"
8984 "\n '-reflections on|off' Enables/disables specular reflections"
8985 "\n '-fsaa on|off' Enables/disables adaptive anti-aliasing"
8986 "\n '-gleam on|off' Enables/disables transparency shadow effects"
8987 "\n '-gi on|off' Enables/disables global illumination effects"
8988 "\n '-env on|off' Enables/disables environment map background"
8989 "\n '-shadingModel model' Controls shading model from enumeration"
8990 "\n color, flat, gouraud, phong"
8991 "\n Unlike vcaps, these parameters dramatically change visual properties."
8992 "\n Command is intended to control presentation quality depending on"
8993 "\n hardware capabilities and performance.",
8994 __FILE__, VRenderParams, group);
8995 theCommands.Add("vfrustumculling",
8996 "vfrustumculling [toEnable]: enables/disables objects clipping",
8997 __FILE__,VFrustumCulling,group);
8998 theCommands.Add("vhighlightselected",
8999 "vhighlightselected [0|1] or vhighlightselected [on|off]: enables/disables highlighting of selected objects.\n"
9000 "Without arguments it shows if highlighting of selected objects is enabled now.",
9001 __FILE__,VHighlightSelected,group);
9002 theCommands.Add ("vplace",
9004 "\n\t\t: Places the point (in pixels) at the center of the window",
9005 __FILE__, VPlace, group);
9006 theCommands.Add("vxrotate",
9008 __FILE__,VXRotate,group);
9011 theCommands.Add("vprogressive",
9013 __FILE__, VProgressiveMode, group);