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))