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 <ViewerTest.hxx>
20 #include <AIS_AnimationCamera.hxx>
21 #include <AIS_AnimationObject.hxx>
22 #include <AIS_CameraFrustum.hxx>
23 #include <AIS_ColorScale.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <AIS_ListOfInteractive.hxx>
26 #include <AIS_ListIteratorOfListOfInteractive.hxx>
27 #include <AIS_Manipulator.hxx>
28 #include <AIS_ViewCube.hxx>
29 #include <AIS_Shape.hxx>
30 #include <Aspect_DisplayConnection.hxx>
31 #include <Aspect_Grid.hxx>
32 #include <Aspect_TypeOfLine.hxx>
34 #include <Draw_Appli.hxx>
35 #include <Draw_Interpretor.hxx>
36 #include <Draw_ProgressIndicator.hxx>
40 #include <Graphic3d_ArrayOfPolylines.hxx>
41 #include <Graphic3d_AspectFillArea3d.hxx>
42 #include <Graphic3d_AspectMarker3d.hxx>
43 #include <Graphic3d_ClipPlane.hxx>
44 #include <Graphic3d_CubeMapPacked.hxx>
45 #include <Graphic3d_CubeMapSeparate.hxx>
46 #include <Graphic3d_GraduatedTrihedron.hxx>
47 #include <Graphic3d_NameOfTextureEnv.hxx>
48 #include <Graphic3d_Texture2Dmanual.hxx>
49 #include <Graphic3d_TextureEnv.hxx>
50 #include <Graphic3d_TextureParams.hxx>
51 #include <Graphic3d_TypeOfTextureFilter.hxx>
52 #include <Image_AlienPixMap.hxx>
53 #include <Image_Diff.hxx>
54 #include <Image_VideoRecorder.hxx>
55 #include <Message_ProgressSentry.hxx>
56 #include <NCollection_DataMap.hxx>
57 #include <NCollection_List.hxx>
58 #include <NCollection_Vector.hxx>
60 #include <OSD_Timer.hxx>
61 #include <OpenGl_GraphicDriver.hxx>
62 #include <Prs3d_ShadingAspect.hxx>
63 #include <Prs3d_Drawer.hxx>
64 #include <Prs3d_LineAspect.hxx>
65 #include <Prs3d_Root.hxx>
66 #include <Prs3d_Text.hxx>
67 #include <Select3D_SensitivePrimitiveArray.hxx>
68 #include <TColStd_HSequenceOfAsciiString.hxx>
69 #include <TColStd_SequenceOfInteger.hxx>
70 #include <TColStd_HSequenceOfReal.hxx>
71 #include <TColgp_Array1OfPnt2d.hxx>
72 #include <TColStd_MapOfAsciiString.hxx>
73 #include <ViewerTest_AutoUpdater.hxx>
74 #include <ViewerTest_ContinuousRedrawer.hxx>
75 #include <ViewerTest_EventManager.hxx>
76 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
77 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
78 #include <ViewerTest_CmdParser.hxx>
79 #include <ViewerTest_V3dView.hxx>
80 #include <V3d_AmbientLight.hxx>
81 #include <V3d_DirectionalLight.hxx>
82 #include <V3d_PositionalLight.hxx>
83 #include <V3d_SpotLight.hxx>
90 #include <WNT_WClass.hxx>
91 #include <WNT_Window.hxx>
92 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
93 #include <Cocoa_Window.hxx>
95 #include <Xw_Window.hxx>
96 #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
97 #include <X11/Xutil.h>
101 //==============================================================================
102 // VIEWER GLOBAL VARIABLES
103 //==============================================================================
105 Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
106 Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
108 Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
109 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
112 static Handle(WNT_Window)& VT_GetWindow() {
113 static Handle(WNT_Window) WNTWin;
116 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
117 static Handle(Cocoa_Window)& VT_GetWindow()
119 static Handle(Cocoa_Window) aWindow;
122 extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow);
123 extern void GetCocoaScreenResolution (Standard_Integer& theWidth, Standard_Integer& theHeight);
126 static Handle(Xw_Window)& VT_GetWindow(){
127 static Handle(Xw_Window) XWWin;
131 static void VProcessEvents(ClientData,int);
134 static Handle(Aspect_DisplayConnection)& GetDisplayConnection()
136 static Handle(Aspect_DisplayConnection) aDisplayConnection;
137 return aDisplayConnection;
140 static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
142 GetDisplayConnection() = theDisplayConnection;
145 NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
146 static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts;
147 static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers;
148 static OpenGl_Caps ViewerTest_myDefaultCaps;
150 static void OSWindowSetup();
154 Quantity_Color FlatColor;
155 Quantity_Color GradientColor1;
156 Quantity_Color GradientColor2;
157 Aspect_GradientFillMethod FillMethod;
158 } ViewerTest_DefaultBackground = { Quantity_NOC_BLACK, Quantity_NOC_BLACK, Quantity_NOC_BLACK, Aspect_GFM_NONE };
160 //==============================================================================
161 // EVENT GLOBAL VARIABLES
162 //==============================================================================
164 Standard_Boolean TheIsAnimating = Standard_False;
169 //! Checks if some set is a subset of other set
170 //! @tparam TheSuperSet the type of the superset
171 //! @tparam TheSubSet the type of the subset
172 //! @param theSuperSet the superset
173 //! @param theSubSet the subset to be checked
174 //! @return true if the superset includes subset, or false otherwise
175 template <typename TheSuperSet, typename TheSubSet>
176 static bool includes (const TheSuperSet& theSuperSet, const TheSubSet& theSubSet)
178 return std::includes (theSuperSet.begin(), theSuperSet.end(), theSubSet.begin(), theSubSet.end());
181 //! A variable set of keys for command-line options.
182 //! It includes a set of mandatory keys and a set of all possible keys.
183 class CommandOptionKeyVariableSet
186 //! Default constructor
187 CommandOptionKeyVariableSet()
192 //! @param theMandatoryKeySet the set of the mandatory option keys
193 //! @param theAdditionalKeySet the set of additional options that could be omitted
194 CommandOptionKeyVariableSet (
195 const ViewerTest_CommandOptionKeySet& theMandatoryKeySet,
196 const ViewerTest_CommandOptionKeySet& theAdditionalKeySet = ViewerTest_CommandOptionKeySet())
197 : myMandatoryKeySet (theMandatoryKeySet)
199 std::set_union (theMandatoryKeySet.begin(),
200 theMandatoryKeySet.end(),
201 theAdditionalKeySet.begin(),
202 theAdditionalKeySet.end(),
203 std::inserter (myFullKeySet, myFullKeySet.begin()));
206 //! Checks if the set of option keys fits to the current variable set (it must contain all mandatory keys
207 //! and be contained in the full key set)
208 //! @param theCheckedKeySet the set of option keys to be checked
209 bool IsInSet (const ViewerTest_CommandOptionKeySet& theCheckedKeySet) const
211 return includes (theCheckedKeySet, myMandatoryKeySet) && includes (myFullKeySet, theCheckedKeySet);
215 //! A set of mandatory command-line option keys
216 ViewerTest_CommandOptionKeySet myMandatoryKeySet;
218 //! A full set of command-line option keys (includes mandatory and additional option keys)
219 ViewerTest_CommandOptionKeySet myFullKeySet;
222 //! Gets some code by its name
223 //! @tparam TheCode the type of a code to be found
224 //! @param theCodeNameMap the map from code names to codes
225 //! @param theCodeName the name of a code to be found
226 //! @param theCode the code to be found
227 //! @return true if a code is found, or false otherwise
228 template <typename TheCode>
229 static bool getSomeCodeByName (const std::map<TCollection_AsciiString, TheCode>& theCodeNameMap,
230 TCollection_AsciiString theCodeName,
233 theCodeName.LowerCase();
234 const typename std::map<TCollection_AsciiString, TheCode>::const_iterator aCodeIterator = theCodeNameMap.find (
236 if (aCodeIterator == theCodeNameMap.end())
240 theCode = aCodeIterator->second;
244 // Defines possible commands related to background changing
245 enum BackgroundCommand
247 BackgroundCommand_Main, //!< The main command that manages other commands through options
248 BackgroundCommand_Image, //!< Sets an image as a background
249 BackgroundCommand_ImageMode, //!< Changes a background image mode
250 BackgroundCommand_Gradient, //!< Sets a gradient as a background
251 BackgroundCommand_GradientMode, //!< Changes a background gradient mode
252 BackgroundCommand_Color, //!< Fills background with a specified color
253 BackgroundCommand_Default //!< Sets the background default color or gradient
256 //! Map from background command names to its codes
257 typedef std::map<TCollection_AsciiString, BackgroundCommand> BackgroundCommandNameMap;
259 //! Creates a map from background command names to its codes
260 //! @return a map from background command names to its codes
261 static BackgroundCommandNameMap createBackgroundCommandNameMap()
263 BackgroundCommandNameMap aBackgroundCommandNameMap;
264 aBackgroundCommandNameMap["vbackground"] = BackgroundCommand_Main;
265 aBackgroundCommandNameMap["vsetbg"] = BackgroundCommand_Image;
266 aBackgroundCommandNameMap["vsetbgmode"] = BackgroundCommand_ImageMode;
267 aBackgroundCommandNameMap["vsetgradientbg"] = BackgroundCommand_Gradient;
268 aBackgroundCommandNameMap["vsetgrbgmode"] = BackgroundCommand_GradientMode;
269 aBackgroundCommandNameMap["vsetcolorbg"] = BackgroundCommand_Color;
270 aBackgroundCommandNameMap["vsetdefaultbg"] = BackgroundCommand_Default;
271 return aBackgroundCommandNameMap;
274 //! Gets a background command by its name
275 //! @param theBackgroundCommandName the name of the background command
276 //! @param theBackgroundCommand the background command to be found
277 //! @return true if a background command is found, or false otherwise
278 static bool getBackgroundCommandByName (const TCollection_AsciiString& theBackgroundCommandName,
279 BackgroundCommand& theBackgroundCommand)
281 static const BackgroundCommandNameMap THE_BACKGROUND_COMMAND_NAME_MAP = createBackgroundCommandNameMap();
282 return getSomeCodeByName (THE_BACKGROUND_COMMAND_NAME_MAP, theBackgroundCommandName, theBackgroundCommand);
285 //! Map from background image fill method names to its codes
286 typedef std::map<TCollection_AsciiString, Aspect_FillMethod> BackgroundImageFillMethodNameMap;
288 //! Creates a map from background image fill method names to its codes
289 //! @return a map from background image fill method names to its codes
290 static BackgroundImageFillMethodNameMap createBackgroundImageFillMethodNameMap()
292 BackgroundImageFillMethodNameMap aBackgroundImageFillMethodNameMap;
293 aBackgroundImageFillMethodNameMap["none"] = Aspect_FM_NONE;
294 aBackgroundImageFillMethodNameMap["centered"] = Aspect_FM_CENTERED;
295 aBackgroundImageFillMethodNameMap["tiled"] = Aspect_FM_TILED;
296 aBackgroundImageFillMethodNameMap["stretch"] = Aspect_FM_STRETCH;
297 return aBackgroundImageFillMethodNameMap;
300 //! Gets a background image fill method by its name
301 //! @param theBackgroundImageFillMethodName the name of the background image fill method
302 //! @param theBackgroundImageFillMethod the background image fill method to be found
303 //! @return true if a background image fill method is found, or false otherwise
304 static bool getBackgroundImageFillMethodByName (const TCollection_AsciiString& theBackgroundImageFillMethodName,
305 Aspect_FillMethod& theBackgroundImageFillMethod)
307 static const BackgroundImageFillMethodNameMap THE_BACKGROUND_IMAGE_FILL_METHOD_NAME_MAP =
308 createBackgroundImageFillMethodNameMap();
309 return getSomeCodeByName (THE_BACKGROUND_IMAGE_FILL_METHOD_NAME_MAP,
310 theBackgroundImageFillMethodName,
311 theBackgroundImageFillMethod);
314 //! Map from background gradient fill method names to its codes
315 typedef std::map<TCollection_AsciiString, Aspect_GradientFillMethod> BackgroundGradientFillMethodNameMap;
317 //! Creates a map from background gradient fill method names to its codes
318 //! @return a map from background gradient fill method names to its codes
319 static BackgroundGradientFillMethodNameMap createBackgroundGradientFillMethodNameMap()
321 BackgroundGradientFillMethodNameMap aBackgroundGradientFillMethodNameMap;
322 aBackgroundGradientFillMethodNameMap["none"] = Aspect_GFM_NONE;
323 aBackgroundGradientFillMethodNameMap["hor"] = Aspect_GFM_HOR;
324 aBackgroundGradientFillMethodNameMap["horizontal"] = Aspect_GFM_HOR;
325 aBackgroundGradientFillMethodNameMap["ver"] = Aspect_GFM_VER;
326 aBackgroundGradientFillMethodNameMap["vertical"] = Aspect_GFM_VER;
327 aBackgroundGradientFillMethodNameMap["diag1"] = Aspect_GFM_DIAG1;
328 aBackgroundGradientFillMethodNameMap["diagonal1"] = Aspect_GFM_DIAG1;
329 aBackgroundGradientFillMethodNameMap["diag2"] = Aspect_GFM_DIAG2;
330 aBackgroundGradientFillMethodNameMap["diagonal2"] = Aspect_GFM_DIAG2;
331 aBackgroundGradientFillMethodNameMap["corner1"] = Aspect_GFM_CORNER1;
332 aBackgroundGradientFillMethodNameMap["corner2"] = Aspect_GFM_CORNER2;
333 aBackgroundGradientFillMethodNameMap["corner3"] = Aspect_GFM_CORNER3;
334 aBackgroundGradientFillMethodNameMap["corner4"] = Aspect_GFM_CORNER4;
335 return aBackgroundGradientFillMethodNameMap;
338 //! Gets a gradient fill method by its name
339 //! @param theBackgroundGradientFillMethodName the name of the gradient fill method
340 //! @param theBackgroundGradientFillMethod the gradient fill method to be found
341 //! @return true if a gradient fill method is found, or false otherwise
342 static bool getBackgroundGradientFillMethodByName (const TCollection_AsciiString& theBackgroundGradientFillMethodName,
343 Aspect_GradientFillMethod& theBackgroundGradientFillMethod)
345 static const BackgroundGradientFillMethodNameMap THE_BACKGROUND_GRADIENT_FILL_METHOD_NAME_MAP =
346 createBackgroundGradientFillMethodNameMap();
347 return getSomeCodeByName (THE_BACKGROUND_GRADIENT_FILL_METHOD_NAME_MAP,
348 theBackgroundGradientFillMethodName,
349 theBackgroundGradientFillMethod);
352 //! Changes the background in accordance with passed command line options
353 class BackgroundChanger
356 //! Constructor. Prepares the command parser
359 prepareCommandParser();
362 //! Processes the command line and changes the background
363 //! @param theDrawInterpretor the interpreter of the Draw Harness application
364 //! @param theNumberOfCommandLineArguments the number of passed command line arguments
365 //! @param theCommandLineArguments the array of command line arguments
366 bool ProcessCommandLine (Draw_Interpretor& theDrawInterpretor,
367 const Standard_Integer theNumberOfCommandLineArguments,
368 const char* const* const theCommandLineArguments)
370 const char* const aBackgroundCommandName = theCommandLineArguments[0];
371 BackgroundCommand aBackgroundCommand = BackgroundCommand_Main;
372 if (!getBackgroundCommandByName (aBackgroundCommandName, aBackgroundCommand))
376 addCommandDescription (aBackgroundCommand);
377 myCommandParser.Parse (theNumberOfCommandLineArguments, theCommandLineArguments);
378 return processCommandOptions (aBackgroundCommandName, aBackgroundCommand, theDrawInterpretor);
382 //! The type of functions that are able to set gradient background filling
383 typedef void SetGradientFunction (const Quantity_Color& /* theColor1 */,
384 const Quantity_Color& /* theColor2 */,
385 const Aspect_GradientFillMethod /* theGradientMode */);
387 //! The type of functions that are able to fill a background with a specific color
388 typedef void SetColorFunction (const Quantity_Color& /* theColor */);
390 //! the command parser used to parse command line options and its arguments
391 ViewerTest_CmdParser myCommandParser;
393 //! the option key for the command that sets an image as a background
394 ViewerTest_CommandOptionKey myImageOptionKey;
396 //! the option key for the command that sets a background image fill type
397 ViewerTest_CommandOptionKey myImageModeOptionKey;
399 //! the option key for the command that sets a gradient filling for the background
400 ViewerTest_CommandOptionKey myGradientOptionKey;
402 //! the option key for the command that sets a background gradient filling method
403 ViewerTest_CommandOptionKey myGradientModeOptionKey;
405 //! the option key for the command that fills background with a specific color
406 ViewerTest_CommandOptionKey myColorOptionKey;
408 //! the option key for the command that sets default background gradient or color
409 ViewerTest_CommandOptionKey myDefaultOptionKey;
411 //! the option key for the command that sets an environment cubemap as a background
412 ViewerTest_CommandOptionKey myCubeMapOptionKey;
414 //! the option key for the command that defines order of tiles in one image packed cubemap
415 ViewerTest_CommandOptionKey myCubeMapOrderOptionKey;
417 //! the option key for the command that sets inversion of Z axis for background cubemap
418 ViewerTest_CommandOptionKey myCubeMapInvertedZOptionKey;
420 //! the option key for the command that allows skip IBL map generation
421 ViewerTest_CommandOptionKey myCubeMapDoNotGenPBREnvOptionKey;
423 //! the variable set of options that are allowed for the old scenario (without any option passed)
424 CommandOptionKeyVariableSet myUnnamedOptionVariableSet;
426 //! the variable set of options that are allowed for setting an environment cubemap as background
427 CommandOptionKeyVariableSet myCubeMapOptionVariableSet;
429 //! the variable set of options that are allowed for setting an image as a background
430 CommandOptionKeyVariableSet myImageOptionVariableSet;
432 //! the variable set of options that are allowed for setting a background image fill type
433 CommandOptionKeyVariableSet myImageModeOptionVariableSet;
435 //! the variable set of options that are allowed for setting a gradient filling for the background
436 CommandOptionKeyVariableSet myGradientOptionVariableSet;
438 //! the variable set of options that are allowed for setting a background gradient filling method
439 CommandOptionKeyVariableSet myGradientModeOptionVariableSet;
441 //! the variable set of options that are allowed for filling a background with a specific color
442 CommandOptionKeyVariableSet myColorOptionVariableSet;
444 //! the variable set of options that are allowed for setting a default background gradient
445 CommandOptionKeyVariableSet myDefaultGradientOptionVariableSet;
447 //! the variable set of options that are allowed for setting a default background color
448 CommandOptionKeyVariableSet myDefaultColorOptionVariableSet;
450 //! the variable set of options that are allowed for printing help
451 CommandOptionKeyVariableSet myHelpOptionVariableSet;
453 //! Adds options to command parser
454 void addOptionsToCommandParser()
456 myImageOptionKey = myCommandParser.AddOption ("imageFile|image|imgFile|img",
457 "filename of image used as background");
458 myImageModeOptionKey = myCommandParser.AddOption (
459 "imageMode|imgMode", "image fill type, should be one of CENTERED, TILED, STRETCH, NONE");
460 myGradientOptionKey = myCommandParser.AddOption ("gradient|grad|gr",
461 "sets background gradient starting and ending colors");
462 myGradientModeOptionKey =
463 myCommandParser.AddOption ("gradientMode|gradMode|gradMd|grMode|grMd",
464 "gradient fill method, should be one of NONE, HOR[IZONTAL], VER[TICAL], "
465 "DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, CORNER4");
466 myColorOptionKey = myCommandParser.AddOption ("color|col", "background color");
467 myDefaultOptionKey = myCommandParser.AddOption ("default|def", "sets background default gradient or color");
469 myCubeMapOptionKey = myCommandParser.AddOption ("cubemap|cmap|cm", "background cubemap");
470 myCubeMapOrderOptionKey = myCommandParser.AddOption ("order|o", "order of sides in one image packed cubemap");
471 myCubeMapInvertedZOptionKey = myCommandParser.AddOption (
472 "invertedz|invz|iz", "whether Z axis is inverted or not during background cubemap rendering");
473 myCubeMapDoNotGenPBREnvOptionKey = myCommandParser.AddOption ("nopbrenv", "whether IBL map generation should be skipped");
476 //! Creates option sets used to determine if a passed option set is valid or not
477 void createOptionSets()
479 ViewerTest_CommandOptionKeySet anUnnamedOptionSet;
480 anUnnamedOptionSet.insert (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
481 myUnnamedOptionVariableSet = CommandOptionKeyVariableSet (anUnnamedOptionSet);
483 ViewerTest_CommandOptionKeySet aCubeMapOptionSet;
484 aCubeMapOptionSet.insert (myCubeMapOptionKey);
485 ViewerTest_CommandOptionKeySet aCubeMapAdditionalOptionKeySet;
486 aCubeMapAdditionalOptionKeySet.insert (myCubeMapInvertedZOptionKey);
487 aCubeMapAdditionalOptionKeySet.insert (myCubeMapDoNotGenPBREnvOptionKey);
488 aCubeMapAdditionalOptionKeySet.insert (myCubeMapOrderOptionKey);
489 myCubeMapOptionVariableSet = CommandOptionKeyVariableSet (aCubeMapOptionSet, aCubeMapAdditionalOptionKeySet);
491 ViewerTest_CommandOptionKeySet anImageOptionSet;
492 anImageOptionSet.insert (myImageOptionKey);
493 ViewerTest_CommandOptionKeySet anImageModeOptionSet;
494 anImageModeOptionSet.insert (myImageModeOptionKey);
495 myImageOptionVariableSet = CommandOptionKeyVariableSet (anImageOptionSet, anImageModeOptionSet);
496 myImageModeOptionVariableSet = CommandOptionKeyVariableSet (anImageModeOptionSet);
498 ViewerTest_CommandOptionKeySet aGradientOptionSet;
499 aGradientOptionSet.insert (myGradientOptionKey);
500 ViewerTest_CommandOptionKeySet aGradientModeOptionSet;
501 aGradientModeOptionSet.insert (myGradientModeOptionKey);
502 myGradientOptionVariableSet = CommandOptionKeyVariableSet (aGradientOptionSet, aGradientModeOptionSet);
503 myGradientModeOptionVariableSet = CommandOptionKeyVariableSet (aGradientModeOptionSet);
505 ViewerTest_CommandOptionKeySet aColorOptionSet;
506 aColorOptionSet.insert (myColorOptionKey);
507 myColorOptionVariableSet = CommandOptionKeyVariableSet (aColorOptionSet);
509 aGradientOptionSet.insert (myDefaultOptionKey);
510 myDefaultGradientOptionVariableSet = CommandOptionKeyVariableSet (aGradientOptionSet, aGradientModeOptionSet);
511 aColorOptionSet.insert (myDefaultOptionKey);
512 myDefaultColorOptionVariableSet = CommandOptionKeyVariableSet (aColorOptionSet);
514 ViewerTest_CommandOptionKeySet aHelpOptionSet;
515 aHelpOptionSet.insert (ViewerTest_CmdParser::THE_HELP_COMMAND_OPTION_KEY);
516 myHelpOptionVariableSet = CommandOptionKeyVariableSet (aHelpOptionSet);
519 //! Prepares the command parser. Adds options and creates option sets used to determine
520 //! if a passed option set is valid or not
521 void prepareCommandParser()
523 addOptionsToCommandParser();
527 //! Adds a command description to the command parser
528 //! @param theBackgroundCommand the key of the command which description is added to the command parser
529 void addCommandDescription (const BackgroundCommand theBackgroundCommand)
531 std::string aDescription;
532 bool isMainCommand = false;
533 switch (theBackgroundCommand)
535 case BackgroundCommand_Main:
536 aDescription = "Command: vbackground (changes background or some background settings)";
537 isMainCommand = true;
539 case BackgroundCommand_Image:
540 aDescription = "Command: vsetbg (loads image as a background)";
542 case BackgroundCommand_ImageMode:
543 aDescription = "Command: vsetbgmode (changes background fill type)";
545 case BackgroundCommand_Gradient:
546 aDescription = "Command: vsetgradientbg (mounts gradient background)";
548 case BackgroundCommand_GradientMode:
549 aDescription = "Command: vsetgradientbgmode (changes gradient background fill method)";
551 case BackgroundCommand_Color:
552 aDescription = "Command: vsetcolorbg (sets color background)";
554 case BackgroundCommand_Default:
555 aDescription = "Command: vsetdefaultbg (sets default viewer background gradient or fill color)";
562 aDescription += "\nThis command is obsolete. Use vbackground instead.";
564 myCommandParser.SetDescription (aDescription);
567 //! Check if a viewer is needed to be initialized
568 //! @param theBackgroundCommand the key of the command that changes the background
569 //! @return true if processing was successful, or false otherwise
570 bool checkViewerIsNeeded (const BackgroundCommand theBackgroundCommand) const
572 const bool isMain = (theBackgroundCommand == BackgroundCommand_Main);
573 const ViewerTest_CommandOptionKeySet aUsedOptions = myCommandParser.GetUsedOptions();
574 const bool aViewerIsNotNeeded =
575 (theBackgroundCommand == BackgroundCommand_Default)
576 || (myDefaultGradientOptionVariableSet.IsInSet (aUsedOptions) && isMain)
577 || (myDefaultColorOptionVariableSet.IsInSet (aUsedOptions) && isMain)
578 || myHelpOptionVariableSet.IsInSet (aUsedOptions);
579 return !aViewerIsNotNeeded;
582 //! Check if a viewer is initialized
583 //! @param theBackgroundCommandName the name of the command that changes the background
584 //! @param theDrawInterpretor the interpreter of the Draw Harness application
585 //! @return true if a viewer is initialized, or false otherwise
586 static bool checkViewerIsInitialized (const char* const theBackgroundCommandName,
587 Draw_Interpretor& theDrawInterpretor)
589 const Handle (AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
590 if (anAISContext.IsNull())
592 theDrawInterpretor << "Use 'vinit' command before executing '" << theBackgroundCommandName << "' command.\n";
598 //! Processes command options
599 //! @param theBackgroundCommandName the name of the command that changes the background
600 //! @param theBackgroundCommand the key of the command that changes the background
601 //! @param theDrawInterpretor the interpreter of the Draw Harness application
602 //! @return true if processing was successful, or false otherwise
603 bool processCommandOptions (const char* const theBackgroundCommandName,
604 const BackgroundCommand theBackgroundCommand,
605 Draw_Interpretor& theDrawInterpretor) const
607 if (myCommandParser.HasNoOption())
609 return printHelp (theBackgroundCommandName, theDrawInterpretor);
611 if (checkViewerIsNeeded (theBackgroundCommand)
612 && !checkViewerIsInitialized (theBackgroundCommandName, theDrawInterpretor))
616 if (myCommandParser.HasOnlyUnnamedOption())
618 return processUnnamedOption (theBackgroundCommand);
620 return processNamedOptions (theBackgroundCommandName, theBackgroundCommand, theDrawInterpretor);
623 //! Processes the unnamed option
624 //! @param theBackgroundCommand the key of the command that changes the background
625 //! @return true if processing was successful, or false otherwise
626 bool processUnnamedOption (const BackgroundCommand theBackgroundCommand) const
628 switch (theBackgroundCommand)
630 case BackgroundCommand_Main:
632 case BackgroundCommand_Image:
633 return processImageUnnamedOption();
634 case BackgroundCommand_ImageMode:
635 return processImageModeUnnamedOption();
636 case BackgroundCommand_Gradient:
637 return processGradientUnnamedOption();
638 case BackgroundCommand_GradientMode:
639 return processGradientModeUnnamedOption();
640 case BackgroundCommand_Color:
641 return processColorUnnamedOption();
642 case BackgroundCommand_Default:
643 return processDefaultUnnamedOption();
649 //! Processes the image unnamed option
650 //! @return true if processing was successful, or false otherwise
651 bool processImageUnnamedOption() const
653 const std::size_t aNumberOfImageUnnamedOptionArguments = myCommandParser.GetNumberOfOptionArguments (
654 ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
655 if ((aNumberOfImageUnnamedOptionArguments != 1) && (aNumberOfImageUnnamedOptionArguments != 2))
659 std::string anImageFileName;
660 if (!myCommandParser.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0, anImageFileName))
664 Aspect_FillMethod anImageMode = Aspect_FM_CENTERED;
665 if (aNumberOfImageUnnamedOptionArguments == 2)
667 std::string anImageModeString;
668 if (!myCommandParser.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 1, anImageModeString))
672 if (!getBackgroundImageFillMethodByName (anImageModeString.c_str(), anImageMode))
677 setImage (anImageFileName.c_str(), anImageMode);
681 //! Processes the image mode unnamed option
682 //! @return true if processing was successful, or false otherwise
683 bool processImageModeUnnamedOption() const
685 return processImageModeOptionSet (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
688 //! Processes the gradient unnamed option
689 //! @param theSetGradient the function used to set a background gradient filling
690 //! @return true if processing was successful, or false otherwise
691 bool processGradientUnnamedOption (SetGradientFunction* const theSetGradient = setGradient) const
693 const Standard_Integer aNumberOfGradientUnnamedOptionArguments = myCommandParser.GetNumberOfOptionArguments (
694 ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
695 if (aNumberOfGradientUnnamedOptionArguments < 2)
700 Standard_Integer anArgumentIndex = 0;
701 Quantity_Color aColor1;
702 if (!myCommandParser.ArgColor (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, anArgumentIndex, aColor1))
706 if (anArgumentIndex >= aNumberOfGradientUnnamedOptionArguments)
711 Quantity_Color aColor2;
712 if (!myCommandParser.ArgColor (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, anArgumentIndex, aColor2))
716 if (anArgumentIndex > aNumberOfGradientUnnamedOptionArguments)
721 Aspect_GradientFillMethod aGradientMode = Aspect_GFM_HOR;
722 if (anArgumentIndex == aNumberOfGradientUnnamedOptionArguments - 1)
724 std::string anGradientModeString;
726 if (!myCommandParser.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY,
728 anGradientModeString))
732 if (!getBackgroundGradientFillMethodByName (anGradientModeString.c_str(), aGradientMode))
738 if (anArgumentIndex != aNumberOfGradientUnnamedOptionArguments)
742 theSetGradient (aColor1, aColor2, aGradientMode);
746 //! Processes the gradient mode unnamed option
747 //! @return true if processing was successful, or false otherwise
748 bool processGradientModeUnnamedOption() const
750 return processGradientModeOptionSet (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
753 //! Processes the color unnamed option
754 //! @param theSetColor the function used to set a background color
755 //! @return true if processing was successful, or false otherwise
756 bool processColorUnnamedOption (SetColorFunction* const theSetColor = setColor) const
758 return processColorOptionSet (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, theSetColor);
761 //! Processes the default back unnamed option
762 //! @return true if processing was successful, or false otherwise
763 bool processDefaultUnnamedOption() const
765 if (processGradientUnnamedOption (setDefaultGradient))
769 return processColorUnnamedOption (setDefaultColor);
772 //! Processes named options
773 //! @param theBackgroundCommandName the name of the command that changes the background
774 //! @param theBackgroundCommand the key of the command that changes the background
775 //! @param theDrawInterpretor the interpreter of the Draw Harness application
776 //! @return true if processing was successful, or false otherwise
777 bool processNamedOptions (const char* const theBackgroundCommandName,
778 const BackgroundCommand theBackgroundCommand,
779 Draw_Interpretor& theDrawInterpretor) const
781 const bool isMain = (theBackgroundCommand == BackgroundCommand_Main);
782 const ViewerTest_CommandOptionKeySet aUsedOptions = myCommandParser.GetUsedOptions();
783 if (myCubeMapOptionVariableSet.IsInSet (aUsedOptions) && isMain)
785 return processCubeMapOptionSet();
787 if (myImageOptionVariableSet.IsInSet (aUsedOptions)
788 && (isMain || (theBackgroundCommand == BackgroundCommand_Image)))
790 return processImageOptionSet();
792 if (myImageModeOptionVariableSet.IsInSet (aUsedOptions)
793 && (isMain || (theBackgroundCommand == BackgroundCommand_ImageMode)))
795 return processImageModeOptionSet();
797 if (myGradientOptionVariableSet.IsInSet (aUsedOptions)
798 && (isMain || (theBackgroundCommand == BackgroundCommand_Gradient)))
800 return processGradientOptionSet();
802 if (myGradientModeOptionVariableSet.IsInSet (aUsedOptions)
803 && (isMain || (theBackgroundCommand == BackgroundCommand_GradientMode)))
805 return processGradientModeOptionSet();
807 if (myColorOptionVariableSet.IsInSet (aUsedOptions)
808 && (isMain || (theBackgroundCommand == BackgroundCommand_Color)))
810 return processColorOptionSet();
812 if ((myDefaultGradientOptionVariableSet.IsInSet (aUsedOptions) && isMain)
813 || (myGradientOptionVariableSet.IsInSet (aUsedOptions)
814 && (theBackgroundCommand == BackgroundCommand_Default)))
816 return processDefaultGradientOptionSet();
818 if ((myDefaultColorOptionVariableSet.IsInSet (aUsedOptions) && isMain)
819 || (myColorOptionVariableSet.IsInSet (aUsedOptions) && (theBackgroundCommand == BackgroundCommand_Default)))
821 return processDefaultColorOptionSet();
823 if (myHelpOptionVariableSet.IsInSet (aUsedOptions))
825 return processHelpOptionSet (theBackgroundCommandName, theDrawInterpretor);
830 //! Process the cubemap option set in named and unnamed case.
831 //! @return true if processing was successful, or false otherwise
832 bool processCubeMapOptionSet() const
834 NCollection_Array1<TCollection_AsciiString> aFilePaths;
836 if (!processCubeMapOptions (aFilePaths))
841 Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
843 if (myCommandParser.HasOption (myCubeMapOrderOptionKey))
845 if (!processCubeMapOrderOptions (anOrder))
851 bool aZIsInverted = false;
852 if (myCommandParser.HasOption (myCubeMapInvertedZOptionKey))
854 if (!processCubeMapInvertedZOptionSet())
861 bool aToGenPBREnv = true;
862 if (myCommandParser.HasOption (myCubeMapDoNotGenPBREnvOptionKey))
864 if (!processCubeMapDoNotGenPBREnvOptionSet())
868 aToGenPBREnv = false;
871 setCubeMap (aFilePaths, anOrder.Validated(), aZIsInverted, aToGenPBREnv);
875 //! Processes the image option set
876 //! @return true if processing was successful, or false otherwise
877 bool processImageOptionSet() const
879 std::string anImageFileName;
880 if (!processImageOption (anImageFileName))
884 Aspect_FillMethod anImageMode = Aspect_FM_CENTERED;
885 if (myCommandParser.HasOption (myImageModeOptionKey) && !processImageModeOption (anImageMode))
889 setImage (anImageFileName.c_str(), anImageMode);
893 //! Processes the image mode option set
894 //! @return true if processing was successful, or false otherwise
895 bool processImageModeOptionSet() const
897 return processImageModeOptionSet (myImageModeOptionKey);
900 //! Processes the image mode option set
901 //! @param theImageModeOptionKey the key of the option that is interpreted as an image mode option
902 //! @return true if processing was successful, or false otherwise
903 bool processImageModeOptionSet (const ViewerTest_CommandOptionKey theImageModeOptionKey) const
905 Aspect_FillMethod anImageMode = Aspect_FM_NONE;
906 if (!processImageModeOption (theImageModeOptionKey, anImageMode))
910 setImageMode (anImageMode);
914 //! Processes the gradient option set
915 //! @param theSetGradient the function used to set a background gradient filling
916 //! @return true if processing was successful, or false otherwise
917 bool processGradientOptionSet (SetGradientFunction* const theSetGradient = setGradient) const
919 Quantity_Color aColor1;
920 Quantity_Color aColor2;
921 if (!processGradientOption (aColor1, aColor2))
925 Aspect_GradientFillMethod aGradientMode = Aspect_GFM_HOR;
926 if (myCommandParser.HasOption (myGradientModeOptionKey) && !processGradientModeOption (aGradientMode))
930 theSetGradient (aColor1, aColor2, aGradientMode);
934 //! Processes the gradient mode option set
935 //! @return true if processing was successful, or false otherwise
936 bool processGradientModeOptionSet() const
938 return processGradientModeOptionSet (myGradientModeOptionKey);
941 //! Processes the gradient mode option set
942 //! @param theGradientModeOptionKey the key of the option that is interpreted as a gradient mode option
943 //! @return true if processing was successful, or false otherwise
944 bool processGradientModeOptionSet (const ViewerTest_CommandOptionKey theGradientModeOptionKey) const
946 Aspect_GradientFillMethod aGradientMode = Aspect_GFM_NONE;
947 if (!processGradientModeOption (theGradientModeOptionKey, aGradientMode))
951 setGradientMode (aGradientMode);
955 //! Processes the color option set
956 //! @param theSetColor the function used to set a background color
957 //! @return true if processing was successful, or false otherwise
958 bool processColorOptionSet (SetColorFunction* const theSetColor = setColor) const
960 return processColorOptionSet (myColorOptionKey, theSetColor);
963 //! Processes the default color option set
964 //! @return true if processing was successful, or false otherwise
965 bool processDefaultGradientOptionSet() const
967 return processGradientOptionSet (setDefaultGradient);
970 //! Processes the default gradient option set
971 //! @return true if processing was successful, or false otherwise
972 bool processDefaultColorOptionSet() const
974 return processColorOptionSet (setDefaultColor);
977 //! Processes the color option set
978 //! @param theColorOptionKey the key of the option that is interpreted as a color option
979 //! @param theSetColor the function used to set a background color
980 //! @return true if processing was successful, or false otherwise
981 bool processColorOptionSet (const ViewerTest_CommandOptionKey theColorOptionKey,
982 SetColorFunction* const theSetColor = setColor) const
984 Quantity_Color aColor;
985 if (!processColorOption (theColorOptionKey, aColor))
989 theSetColor (aColor);
993 //! Processes the help option set
994 //! @param theBackgroundCommandName the name of the command that changes the background
995 //! @param theDrawInterpretor the interpreter of the Draw Harness application
996 //! @return true if processing was successful, or false otherwise
997 bool processHelpOptionSet (const char* const theBackgroundCommandName, Draw_Interpretor& theDrawInterpretor) const
999 const Standard_Integer aNumberOfHelpOptionArguments = myCommandParser.GetNumberOfOptionArguments (
1000 ViewerTest_CmdParser::THE_HELP_COMMAND_OPTION_KEY);
1001 if (aNumberOfHelpOptionArguments != 0)
1005 return printHelp (theBackgroundCommandName, theDrawInterpretor);
1008 //! Processes the cubemap option
1009 //! @param theFilePaths the array of filenames of cubemap sides
1010 //! @return true if processing was successful, or false otherwise
1011 bool processCubeMapOptions (NCollection_Array1<TCollection_AsciiString> &theFilePaths) const
1013 const Standard_Integer aNumberOfCubeMapOptionArguments = myCommandParser.GetNumberOfOptionArguments (myCubeMapOptionKey);
1015 if (aNumberOfCubeMapOptionArguments != 1
1016 && aNumberOfCubeMapOptionArguments != 6)
1021 theFilePaths.Resize(0, aNumberOfCubeMapOptionArguments - 1, Standard_False);
1023 for (int i = 0; i < aNumberOfCubeMapOptionArguments; ++i)
1025 std::string aCubeMapFileName;
1026 if (!myCommandParser.Arg (myCubeMapOptionKey, i, aCubeMapFileName))
1030 theFilePaths[i] = aCubeMapFileName.c_str();
1036 //! Processes the inverted z cubemap option
1037 //! @return true if processing was successful, or false otherwise
1038 bool processCubeMapInvertedZOptionSet () const
1040 const Standard_Integer aNumberOfCubeMapZInversionOptionArguments =
1041 myCommandParser.GetNumberOfOptionArguments (myCubeMapInvertedZOptionKey);
1043 if (aNumberOfCubeMapZInversionOptionArguments != 0)
1051 //! Processes the option allowing to skip IBM maps generation
1052 //! @return true if processing was successful, or false otherwise
1053 bool processCubeMapDoNotGenPBREnvOptionSet() const
1055 const Standard_Integer aNumberOfCubeMapDoNotGenPBREnvOptionArguments =
1056 myCommandParser.GetNumberOfOptionArguments(myCubeMapDoNotGenPBREnvOptionKey);
1058 if (aNumberOfCubeMapDoNotGenPBREnvOptionArguments != 0)
1066 //! Processes the tiles order option
1067 //! @param theOrder the array of indexes if cubemap sides in tile grid
1068 //! @return true if processing was successful, or false otherwise
1069 bool processCubeMapOrderOptions (Graphic3d_CubeMapOrder& theOrder) const
1071 const Standard_Integer aNumberOfCubeMapOrderOptionArguments = myCommandParser.GetNumberOfOptionArguments(
1072 myCubeMapOrderOptionKey);
1074 if (aNumberOfCubeMapOrderOptionArguments != 6)
1080 for (unsigned int i = 0; i < 6; ++i)
1082 std::string anOrderItem;
1083 if (!myCommandParser.Arg (myCubeMapOrderOptionKey, i, anOrderItem))
1088 theOrder.Set (Graphic3d_CubeMapSide (i),
1089 static_cast<unsigned char> (Draw::Atoi (anOrderItem.c_str())));
1092 return theOrder.IsValid();
1095 //! Processes the image option
1096 //! @param theImageFileName the filename of the image to be used as a background
1097 //! @return true if processing was successful, or false otherwise
1098 bool processImageOption (std::string& theImageFileName) const
1100 const Standard_Integer aNumberOfImageOptionArguments = myCommandParser.GetNumberOfOptionArguments (
1102 if (aNumberOfImageOptionArguments != 1)
1106 std::string anImageFileName;
1107 if (!myCommandParser.Arg (myImageOptionKey, 0, anImageFileName))
1111 theImageFileName = anImageFileName;
1115 //! Processes the image mode option
1116 //! @param theImageMode the fill type used for a background image
1117 //! @return true if processing was successful, or false otherwise
1118 bool processImageModeOption (Aspect_FillMethod& theImageMode) const
1120 return processImageModeOption (myImageModeOptionKey, theImageMode);
1123 //! Processes the image mode option
1124 //! @param theImageModeOptionKey the key of the option that is interpreted as an image mode option
1125 //! @param theImageMode the fill type used for a background image
1126 //! @return true if processing was successful, or false otherwise
1127 bool processImageModeOption (const ViewerTest_CommandOptionKey theImageModeOptionKey,
1128 Aspect_FillMethod& theImageMode) const
1130 return processModeOption (theImageModeOptionKey, getBackgroundImageFillMethodByName, theImageMode);
1133 //! Processes the gradient option
1134 //! @param theColor1 the gradient starting color
1135 //! @param theColor2 the gradient ending color
1136 //! @return true if processing was successful, or false otherwise
1137 bool processGradientOption (Quantity_Color& theColor1, Quantity_Color& theColor2) const
1139 Standard_Integer anArgumentIndex = 0;
1140 Quantity_Color aColor1;
1141 if (!myCommandParser.ArgColor (myGradientOptionKey, anArgumentIndex, aColor1))
1145 Quantity_Color aColor2;
1146 if (!myCommandParser.ArgColor (myGradientOptionKey, anArgumentIndex, aColor2))
1150 const Standard_Integer aNumberOfGradientOptionArguments = myCommandParser.GetNumberOfOptionArguments (
1151 myGradientOptionKey);
1152 if (anArgumentIndex != aNumberOfGradientOptionArguments)
1156 theColor1 = aColor1;
1157 theColor2 = aColor2;
1161 //! Processes the gradient mode option
1162 //! @param theGradientMode the fill method used for a background gradient filling
1163 //! @return true if processing was successful, or false otherwise
1164 bool processGradientModeOption (Aspect_GradientFillMethod& theGradientMode) const
1166 return processGradientModeOption (myGradientModeOptionKey, theGradientMode);
1169 //! Processes the gradient mode option
1170 //! @param theGradientModeOptionKey the key of the option that is interpreted as a gradient mode option
1171 //! @param theGradientMode the fill method used for a background gradient filling
1172 //! @return true if processing was successful, or false otherwise
1173 bool processGradientModeOption (const ViewerTest_CommandOptionKey theGradientModeOptionKey,
1174 Aspect_GradientFillMethod& theGradientMode) const
1176 return processModeOption (theGradientModeOptionKey, getBackgroundGradientFillMethodByName, theGradientMode);
1179 //! Processes some mode option
1180 //! @tparam TheMode the type of a mode to be processed
1181 //! @param theModeOptionKey the key of the option that is interpreted as a mode option
1182 //! @param theMode a mode to be processed
1183 //! @return true if processing was successful, or false otherwise
1184 template <typename TheMode>
1185 bool processModeOption (const ViewerTest_CommandOptionKey theModeOptionKey,
1186 bool (*const theGetModeByName) (const TCollection_AsciiString& /* theModeName */,
1187 TheMode& /* theMode */),
1188 TheMode& theMode) const
1190 const Standard_Integer aNumberOfModeOptionArguments = myCommandParser.GetNumberOfOptionArguments (
1192 if (aNumberOfModeOptionArguments != 1)
1196 std::string aModeString;
1197 if (!myCommandParser.Arg (theModeOptionKey, 0, aModeString))
1201 TheMode aMode = TheMode();
1202 if (!theGetModeByName (aModeString.c_str(), aMode))
1210 //! Processes the color option
1211 //! @param theColor a color used for filling a background
1212 //! @return true if processing was successful, or false otherwise
1213 bool processColorOption (Quantity_Color& theColor) const
1215 return processColorOption (myColorOptionKey, theColor);
1218 //! Processes the color option
1219 //! @param theColorOptionKey the key of the option that is interpreted as a color option
1220 //! @param theColor a color used for filling a background
1221 //! @return true if processing was successful, or false otherwise
1222 bool processColorOption (const ViewerTest_CommandOptionKey theColorOptionKey, Quantity_Color& theColor) const
1224 Standard_Integer anArgumentIndex = 0;
1225 Quantity_Color aColor;
1226 if (!myCommandParser.ArgColor (theColorOptionKey, anArgumentIndex, aColor))
1230 const Standard_Integer aNumberOfColorOptionArguments = myCommandParser.GetNumberOfOptionArguments (
1232 if (anArgumentIndex != aNumberOfColorOptionArguments)
1240 //! Prints helping message
1241 //! @param theBackgroundCommandName the name of the command that changes the background
1242 //! @param theDrawInterpretor the interpreter of the Draw Harness application
1243 //! @return true if printing was successful, or false otherwise
1244 static bool printHelp (const char* const theBackgroundCommandName, Draw_Interpretor& theDrawInterpretor)
1246 return theDrawInterpretor.PrintHelp (theBackgroundCommandName) == TCL_OK;
1249 //! Sets the cubemap as a background
1250 //! @param theFileNames the array of filenames of packed or multifile cubemap
1251 //! @param theOrder array of cubemap sides indexes mapping them from tiles in packed cubemap
1252 static void setCubeMap (const NCollection_Array1<TCollection_AsciiString>& theFileNames,
1253 const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default(),
1254 bool theZIsInverted = false,
1255 bool theToGenPBREnv = true)
1257 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
1258 Handle(Graphic3d_CubeMap) aCubeMap;
1260 if (theFileNames.Size() == 1)
1261 aCubeMap = new Graphic3d_CubeMapPacked(theFileNames[0], theOrder);
1263 aCubeMap = new Graphic3d_CubeMapSeparate(theFileNames);
1265 aCubeMap->SetZInversion (theZIsInverted);
1267 aCubeMap->GetParams()->SetFilter(Graphic3d_TOTF_BILINEAR);
1268 aCubeMap->GetParams()->SetRepeat(Standard_False);
1269 aCubeMap->GetParams()->SetTextureUnit(Graphic3d_TextureUnit_EnvMap);
1271 aCurrentView->SetBackgroundCubeMap (aCubeMap, theToGenPBREnv, Standard_True);
1274 //! Sets the image as a background
1275 //! @param theImageFileName the filename of the image to be used as a background
1276 //! @param theImageMode the fill type used for a background image
1277 static void setImage (const Standard_CString theImageFileName, const Aspect_FillMethod theImageMode)
1279 const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
1280 aCurrentView->SetBackgroundImage (theImageFileName, theImageMode, Standard_True);
1283 //! Sets the fill type used for a background image
1284 //! @param theImageMode the fill type used for a background image
1285 static void setImageMode (const Aspect_FillMethod theImageMode)
1287 const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
1288 aCurrentView->SetBgImageStyle (theImageMode, Standard_True);
1291 //! Sets the gradient filling for a background
1292 //! @param theColor1 the gradient starting color
1293 //! @param theColor2 the gradient ending color
1294 //! @param theGradientMode the fill method used for a background gradient filling
1295 static void setGradient (const Quantity_Color& theColor1,
1296 const Quantity_Color& theColor2,
1297 const Aspect_GradientFillMethod theGradientMode)
1299 const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
1300 aCurrentView->SetBgGradientColors (theColor1, theColor2, theGradientMode, Standard_True);
1303 //! Sets the fill method used for a background gradient filling
1304 //! @param theGradientMode the fill method used for a background gradient filling
1305 static void setGradientMode (const Aspect_GradientFillMethod theGradientMode)
1307 const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
1308 aCurrentView->SetBgGradientStyle (theGradientMode, Standard_True);
1311 //! Sets the color used for filling a background
1312 //! @param theColor the color used for filling a background
1313 static void setColor (const Quantity_Color& theColor)
1315 const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
1316 aCurrentView->SetBgGradientStyle (Aspect_GFM_NONE);
1317 aCurrentView->SetBackgroundColor (theColor);
1318 aCurrentView->Update();
1321 //! Sets the gradient filling for a background in a default viewer
1322 //! @param theColor1 the gradient starting color
1323 //! @param theColor2 the gradient ending color
1324 //! @param theGradientMode the fill method used for a background gradient filling
1325 static void setDefaultGradient (const Quantity_Color& theColor1,
1326 const Quantity_Color& theColor2,
1327 const Aspect_GradientFillMethod theGradientMode)
1329 ViewerTest_DefaultBackground.GradientColor1 = theColor1;
1330 ViewerTest_DefaultBackground.GradientColor2 = theColor2;
1331 ViewerTest_DefaultBackground.FillMethod = theGradientMode;
1332 setDefaultGradient();
1335 //! Sets the color used for filling a background in a default viewer
1336 //! @param theColor the color used for filling a background
1337 static void setDefaultColor (const Quantity_Color& theColor)
1339 ViewerTest_DefaultBackground.GradientColor1 = Quantity_Color();
1340 ViewerTest_DefaultBackground.GradientColor2 = Quantity_Color();
1341 ViewerTest_DefaultBackground.FillMethod = Aspect_GFM_NONE;
1342 ViewerTest_DefaultBackground.FlatColor = theColor;
1343 setDefaultGradient();
1347 //! Sets the gradient filling for a background in a default viewer.
1348 //! Gradient settings are taken from ViewerTest_DefaultBackground structure
1349 static void setDefaultGradient()
1351 for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator
1352 anInteractiveContextIterator (ViewerTest_myContexts);
1353 anInteractiveContextIterator.More();
1354 anInteractiveContextIterator.Next())
1356 const Handle (V3d_Viewer)& aViewer = anInteractiveContextIterator.Value()->CurrentViewer();
1357 aViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
1358 ViewerTest_DefaultBackground.GradientColor2,
1359 ViewerTest_DefaultBackground.FillMethod);
1363 //! Sets the color used for filling a background in a default viewer.
1364 //! The color value is taken from ViewerTest_DefaultBackground structure
1365 static void setDefaultColor()
1367 for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator
1368 anInteractiveContextIterator (ViewerTest_myContexts);
1369 anInteractiveContextIterator.More();
1370 anInteractiveContextIterator.Next())
1372 const Handle (V3d_Viewer)& aViewer = anInteractiveContextIterator.Value()->CurrentViewer();
1373 aViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
1380 //==============================================================================
1383 static LRESULT WINAPI ViewerWindowProc(
1388 static LRESULT WINAPI AdvViewerWindowProc(
1396 //==============================================================================
1399 //==============================================================================
1401 const Handle(WNT_WClass)& ViewerTest::WClass()
1403 static Handle(WNT_WClass) theWClass;
1405 if (theWClass.IsNull())
1407 theWClass = new WNT_WClass ("GW3D_Class", (Standard_Address )AdvViewerWindowProc,
1408 CS_VREDRAW | CS_HREDRAW, 0, 0,
1409 ::LoadCursor (NULL, IDC_ARROW));
1415 //==============================================================================
1416 //function : CreateName
1417 //purpose : Create numerical name for new object in theMap
1418 //==============================================================================
1419 template <typename ObjectType>
1420 TCollection_AsciiString CreateName (const NCollection_DoubleMap <TCollection_AsciiString, ObjectType>& theObjectMap,
1421 const TCollection_AsciiString& theDefaultString)
1423 if (theObjectMap.IsEmpty())
1424 return theDefaultString + TCollection_AsciiString(1);
1426 Standard_Integer aNextKey = 1;
1427 Standard_Boolean isFound = Standard_False;
1430 TCollection_AsciiString aStringKey = theDefaultString + TCollection_AsciiString(aNextKey);
1431 // Look for objects with default names
1432 if (theObjectMap.IsBound1(aStringKey))
1437 isFound = Standard_True;
1440 return theDefaultString + TCollection_AsciiString(aNextKey);
1443 //==============================================================================
1444 //structure : ViewerTest_Names
1445 //purpose : Allow to operate with full view name: driverName/viewerName/viewName
1446 //==============================================================================
1447 struct ViewerTest_Names
1450 TCollection_AsciiString myDriverName;
1451 TCollection_AsciiString myViewerName;
1452 TCollection_AsciiString myViewName;
1456 const TCollection_AsciiString& GetDriverName () const
1458 return myDriverName;
1460 void SetDriverName (const TCollection_AsciiString& theDriverName)
1462 myDriverName = theDriverName;
1464 const TCollection_AsciiString& GetViewerName () const
1466 return myViewerName;
1468 void SetViewerName (const TCollection_AsciiString& theViewerName)
1470 myViewerName = theViewerName;
1472 const TCollection_AsciiString& GetViewName () const
1476 void SetViewName (const TCollection_AsciiString& theViewName)
1478 myViewName = theViewName;
1481 //===========================================================================
1482 //function : Constructor for ViewerTest_Names
1483 //purpose : Get view, viewer, driver names from custom string
1484 //===========================================================================
1486 ViewerTest_Names (const TCollection_AsciiString& theInputString)
1488 TCollection_AsciiString aName(theInputString);
1489 if (theInputString.IsEmpty())
1491 // Get current configuration
1492 if (ViewerTest_myDrivers.IsEmpty())
1493 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
1494 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
1496 myDriverName = ViewerTest_myDrivers.Find2
1497 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
1499 if(ViewerTest_myContexts.IsEmpty())
1501 myViewerName = CreateName <Handle(AIS_InteractiveContext)>
1502 (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer"));
1506 myViewerName = ViewerTest_myContexts.Find2 (ViewerTest::GetAISContext());
1509 myViewName = CreateName <Handle(V3d_View)> (ViewerTest_myViews, TCollection_AsciiString(myViewerName + "/View"));
1513 // There is at least view name
1514 Standard_Integer aParserNumber = 0;
1515 for (Standard_Integer i = 0; i < 3; ++i)
1517 Standard_Integer aParserPos = aName.SearchFromEnd("/");
1518 if(aParserPos != -1)
1521 aName.Split(aParserPos-1);
1526 if (aParserNumber == 0)
1529 if (!ViewerTest::GetAISContext().IsNull())
1531 myDriverName = ViewerTest_myDrivers.Find2
1532 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
1533 myViewerName = ViewerTest_myContexts.Find2
1534 (ViewerTest::GetAISContext());
1538 // There is no opened contexts here, need to create names for viewer and driver
1539 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
1540 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
1542 myViewerName = CreateName <Handle(AIS_InteractiveContext)>
1543 (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer"));
1545 myViewName = TCollection_AsciiString(myViewerName + "/" + theInputString);
1547 else if (aParserNumber == 1)
1549 // Here is viewerName/viewName
1550 if (!ViewerTest::GetAISContext().IsNull())
1551 myDriverName = ViewerTest_myDrivers.Find2
1552 (ViewerTest::GetAISContext()->CurrentViewer()->Driver());
1555 // There is no opened contexts here, need to create name for driver
1556 myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)>
1557 (ViewerTest_myDrivers, TCollection_AsciiString("Driver"));
1559 myViewerName = TCollection_AsciiString(myDriverName + "/" + aName);
1561 myViewName = TCollection_AsciiString(myDriverName + "/" + theInputString);
1565 //Here is driverName/viewerName/viewName
1566 myDriverName = TCollection_AsciiString(aName);
1568 TCollection_AsciiString aViewerName(theInputString);
1569 aViewerName.Split(aViewerName.SearchFromEnd("/") - 1);
1570 myViewerName = TCollection_AsciiString(aViewerName);
1572 myViewName = TCollection_AsciiString(theInputString);
1578 //==============================================================================
1579 //function : FindContextByView
1580 //purpose : Find AIS_InteractiveContext by View
1581 //==============================================================================
1583 Handle(AIS_InteractiveContext) FindContextByView (const Handle(V3d_View)& theView)
1585 Handle(AIS_InteractiveContext) anAISContext;
1587 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1588 anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
1590 if (anIter.Value()->CurrentViewer() == theView->Viewer())
1591 return anIter.Key2();
1593 return anAISContext;
1596 //==============================================================================
1597 //function : IsWindowOverlapped
1598 //purpose : Check if theWindow overlapp another view
1599 //==============================================================================
1601 Standard_Boolean IsWindowOverlapped (const Standard_Integer thePxLeft,
1602 const Standard_Integer thePxTop,
1603 const Standard_Integer thePxRight,
1604 const Standard_Integer thePxBottom,
1605 TCollection_AsciiString& theViewId)
1607 for(NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
1608 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
1610 Standard_Integer aTop = 0,
1614 anIter.Value()->Window()->Position(aLeft, aTop, aRight, aBottom);
1615 if ((thePxLeft >= aLeft && thePxLeft <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
1616 (thePxLeft >= aLeft && thePxLeft <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom) ||
1617 (thePxRight >= aLeft && thePxRight <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
1618 (thePxRight >= aLeft && thePxRight <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom))
1620 theViewId = anIter.Key1();
1621 return Standard_True;
1624 return Standard_False;
1627 // Workaround: to create and delete non-orthographic views outside ViewerTest
1628 void ViewerTest::RemoveViewName (const TCollection_AsciiString& theName)
1630 ViewerTest_myViews.UnBind1 (theName);
1633 void ViewerTest::InitViewName (const TCollection_AsciiString& theName,
1634 const Handle(V3d_View)& theView)
1636 ViewerTest_myViews.Bind (theName, theView);
1639 TCollection_AsciiString ViewerTest::GetCurrentViewName ()
1641 return ViewerTest_myViews.Find2( ViewerTest::CurrentView());
1644 //==============================================================================
1645 //function : ViewerInit
1646 //purpose : Create the window viewer and initialize all the global variable
1647 //==============================================================================
1649 TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft,
1650 const Standard_Integer thePxTop,
1651 const Standard_Integer thePxWidth,
1652 const Standard_Integer thePxHeight,
1653 const TCollection_AsciiString& theViewName,
1654 const TCollection_AsciiString& theDisplayName,
1655 const Handle(V3d_View)& theViewToClone)
1657 // Default position and dimension of the viewer window.
1658 // Note that left top corner is set to be sufficiently small to have
1659 // window fit in the small screens (actual for remote desktops, see #23003).
1660 // The position corresponds to the window's client area, thus some
1661 // gap is added for window frame to be visible.
1662 Standard_Integer aPxLeft = 20;
1663 Standard_Integer aPxTop = 40;
1664 Standard_Integer aPxWidth = 409;
1665 Standard_Integer aPxHeight = 409;
1666 Standard_Boolean toCreateViewer = Standard_False;
1667 if (!theViewToClone.IsNull())
1669 theViewToClone->Window()->Size (aPxWidth, aPxHeight);
1672 Handle(OpenGl_GraphicDriver) aGraphicDriver;
1673 ViewerTest_Names aViewNames(theViewName);
1674 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ()))
1675 aViewNames.SetViewName (aViewNames.GetViewerName() + "/" + CreateName<Handle(V3d_View)>(ViewerTest_myViews, "View"));
1678 aPxLeft = thePxLeft;
1681 if (thePxWidth != 0)
1682 aPxWidth = thePxWidth;
1683 if (thePxHeight != 0)
1684 aPxHeight = thePxHeight;
1686 // Get graphic driver (create it or get from another view)
1687 const bool isNewDriver = !ViewerTest_myDrivers.IsBound1 (aViewNames.GetDriverName());
1690 // Get connection string
1691 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1692 if (!theDisplayName.IsEmpty())
1694 SetDisplayConnection (new Aspect_DisplayConnection (theDisplayName));
1698 ::Display* aDispX = NULL;
1699 // create dedicated display connection instead of reusing Tk connection
1700 // so that to procede events independently through VProcessEvents()/ViewerMainLoop() callbacks
1701 /*Draw_Interpretor& aCommands = Draw::GetInterpretor();
1702 Tcl_Interp* aTclInterp = aCommands.Interp();
1703 Tk_Window aMainWindow = Tk_MainWindow (aTclInterp);
1704 aDispX = aMainWindow != NULL ? Tk_Display (aMainWindow) : NULL;*/
1705 SetDisplayConnection (new Aspect_DisplayConnection (aDispX));
1708 (void)theDisplayName; // avoid warning on unused argument
1709 SetDisplayConnection (new Aspect_DisplayConnection ());
1712 if (Draw_VirtualWindows)
1714 // don't waste the time waiting for VSync when window is not displayed on the screen
1715 ViewerTest_myDefaultCaps.swapInterval = 0;
1716 // alternatively we can disable buffer swap at all, but this might be inappropriate for testing
1717 //ViewerTest_myDefaultCaps.buffersNoSwap = true;
1719 aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection(), false);
1720 aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
1721 aGraphicDriver->InitContext();
1723 ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
1724 toCreateViewer = Standard_True;
1728 aGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast (ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName()));
1731 //Dispose the window if input parameters are default
1732 if (!ViewerTest_myViews.IsEmpty() && thePxLeft == 0 && thePxTop == 0)
1734 Standard_Integer aTop = 0,
1741 // Get screen resolution
1742 #if defined(_WIN32) || defined(__WIN32__)
1744 GetClientRect(GetDesktopWindow(), &aWindowSize);
1745 aScreenHeight = aWindowSize.bottom;
1746 aScreenWidth = aWindowSize.right;
1747 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1748 GetCocoaScreenResolution (aScreenWidth, aScreenHeight);
1750 Screen *aScreen = DefaultScreenOfDisplay(GetDisplayConnection()->GetDisplay());
1751 aScreenWidth = WidthOfScreen(aScreen);
1752 aScreenHeight = HeightOfScreen(aScreen);
1755 TCollection_AsciiString anOverlappedViewId("");
1757 while (IsWindowOverlapped (aPxLeft, aPxTop, aPxLeft + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId))
1759 ViewerTest_myViews.Find1(anOverlappedViewId)->Window()->Position (aLeft, aTop, aRight, aBottom);
1761 if (IsWindowOverlapped (aRight + 20, aPxTop, aRight + 20 + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId)
1762 && aRight + 2*aPxWidth + 40 > aScreenWidth)
1764 if (aBottom + aPxHeight + 40 > aScreenHeight)
1771 aPxTop = aBottom + 40;
1774 aPxLeft = aRight + 20;
1779 TCollection_AsciiString aTitle("3D View - ");
1780 aTitle = aTitle + aViewNames.GetViewName() + "(*)";
1782 // Change name of current active window
1783 if (const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView())
1785 aCurrentView->Window()->SetTitle (TCollection_AsciiString ("3D View - ") + ViewerTest_myViews.Find2 (aCurrentView));
1789 Handle(V3d_Viewer) a3DViewer;
1790 // If it's the single view, we first look for empty context
1791 if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty())
1793 NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
1794 anIter(ViewerTest_myContexts);
1796 ViewerTest::SetAISContext (anIter.Value());
1797 a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
1799 else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))
1801 ViewerTest::SetAISContext(ViewerTest_myContexts.Find1(aViewNames.GetViewerName()));
1802 a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
1804 else if (a3DViewer.IsNull())
1806 toCreateViewer = Standard_True;
1807 a3DViewer = new V3d_Viewer(aGraphicDriver);
1808 a3DViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
1809 a3DViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
1810 ViewerTest_DefaultBackground.GradientColor2,
1811 ViewerTest_DefaultBackground.FillMethod);
1814 // AIS context setup
1815 if (ViewerTest::GetAISContext().IsNull() ||
1816 !(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())))
1818 Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer);
1819 ViewerTest::SetAISContext (aContext);
1820 ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext());
1824 ViewerTest::ResetEventManager();
1829 VT_GetWindow() = new WNT_Window (aTitle.ToCString(), WClass(),
1830 Draw_VirtualWindows ? WS_POPUP : WS_OVERLAPPEDWINDOW,
1832 aPxWidth, aPxHeight,
1833 Quantity_NOC_BLACK);
1834 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
1835 VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(),
1837 aPxWidth, aPxHeight);
1838 ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
1840 VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(),
1843 aPxWidth, aPxHeight);
1845 VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
1848 Handle(V3d_View) aView;
1849 if (!theViewToClone.IsNull())
1851 aView = new ViewerTest_V3dView (a3DViewer, theViewToClone);
1855 aView = new ViewerTest_V3dView (a3DViewer, a3DViewer->DefaultTypeOfView());
1858 aView->SetWindow (VT_GetWindow());
1859 ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer);
1861 ViewerTest::CurrentView(aView);
1862 ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView);
1864 // Setup for X11 or NT
1867 // Set parameters for V3d_View and V3d_Viewer
1868 const Handle (V3d_View) aV3dView = ViewerTest::CurrentView();
1869 aV3dView->SetComputedMode(Standard_False);
1871 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
1874 a3DViewer->SetDefaultLights();
1875 a3DViewer->SetLightOn();
1878 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1881 ::Display* aDispX = GetDisplayConnection()->GetDisplay();
1882 Tcl_CreateFileHandler (XConnectionNumber (aDispX), TCL_READABLE, VProcessEvents, (ClientData )aDispX);
1886 VT_GetWindow()->Map();
1888 // Set the handle of created view in the event manager
1889 ViewerTest::ResetEventManager();
1891 ViewerTest::CurrentView()->Redraw();
1894 a3DViewer.Nullify();
1896 return aViewNames.GetViewName();
1899 //==============================================================================
1900 //function : RedrawAllViews
1901 //purpose : Redraw all created views
1902 //==============================================================================
1903 void ViewerTest::RedrawAllViews()
1905 NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
1906 for (; aViewIt.More(); aViewIt.Next())
1908 const Handle(V3d_View)& aView = aViewIt.Key2();
1913 //==============================================================================
1915 //purpose : Create the window viewer and initialize all the global variable
1916 // Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event
1917 //==============================================================================
1919 static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
1921 TCollection_AsciiString aViewName, aDisplayName;
1922 Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
1923 Handle(V3d_View) aCopyFrom;
1924 TCollection_AsciiString aName, aValue;
1926 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
1928 const TCollection_AsciiString anArg = theArgVec[anArgIt];
1929 TCollection_AsciiString anArgCase = anArg;
1930 anArgCase.LowerCase();
1931 if (anArgIt + 1 < theArgsNb
1932 && anArgCase == "-name")
1934 aViewName = theArgVec[++anArgIt];
1936 else if (anArgIt + 1 < theArgsNb
1937 && (anArgCase == "-left"
1938 || anArgCase == "-l"))
1940 aPxLeft = Draw::Atoi (theArgVec[++anArgIt]);
1942 else if (anArgIt + 1 < theArgsNb
1943 && (anArgCase == "-top"
1944 || anArgCase == "-t"))
1946 aPxTop = Draw::Atoi (theArgVec[++anArgIt]);
1948 else if (anArgIt + 1 < theArgsNb
1949 && (anArgCase == "-width"
1950 || anArgCase == "-w"))
1952 aPxWidth = Draw::Atoi (theArgVec[++anArgIt]);
1954 else if (anArgIt + 1 < theArgsNb
1955 && (anArgCase == "-height"
1956 || anArgCase == "-h"))
1958 aPxHeight = Draw::Atoi (theArgVec[++anArgIt]);
1960 else if (anArgCase == "-exitonclose")
1962 ViewerTest_EventManager::ToExitOnCloseView() = true;
1963 if (anArgIt + 1 < theArgsNb
1964 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToExitOnCloseView()))
1969 else if (anArgCase == "-closeonescape"
1970 || anArgCase == "-closeonesc")
1972 ViewerTest_EventManager::ToCloseViewOnEscape() = true;
1973 if (anArgIt + 1 < theArgsNb
1974 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
1979 else if (anArgCase == "-2d_mode"
1980 || anArgCase == "-2dmode"
1981 || anArgCase == "-2d")
1983 bool toEnable = true;
1984 if (anArgIt + 1 < theArgsNb
1985 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], toEnable))
1989 is2dMode = toEnable ? 1 : 0;
1991 else if (anArgIt + 1 < theArgsNb
1992 && (anArgCase == "-disp"
1993 || anArgCase == "-display"))
1995 aDisplayName = theArgVec[++anArgIt];
1997 else if (!ViewerTest::CurrentView().IsNull()
1998 && aCopyFrom.IsNull()
1999 && (anArgCase == "-copy"
2000 || anArgCase == "-clone"
2001 || anArgCase == "-cloneactive"
2002 || anArgCase == "-cloneactiveview"))
2004 aCopyFrom = ViewerTest::CurrentView();
2007 else if (ViewerTest::SplitParameter (anArg, aName, aValue))
2010 if (aName == "name")
2014 else if (aName == "l"
2017 aPxLeft = aValue.IntegerValue();
2019 else if (aName == "t"
2022 aPxTop = aValue.IntegerValue();
2024 else if (aName == "disp"
2025 || aName == "display")
2027 aDisplayName = aValue;
2029 else if (aName == "w"
2030 || aName == "width")
2032 aPxWidth = aValue.IntegerValue();
2034 else if (aName == "h"
2035 || aName == "height")
2037 aPxHeight = aValue.IntegerValue();
2041 Message::SendFail() << "Syntax error: unknown argument " << anArg;
2045 else if (aViewName.IsEmpty())
2051 Message::SendFail() << "Syntax error: unknown argument " << anArg;
2056 #if defined(_WIN32) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
2057 if (!aDisplayName.IsEmpty())
2059 aDisplayName.Clear();
2060 Message::SendWarning() << "Warning: display parameter will be ignored.\n";
2064 ViewerTest_Names aViewNames (aViewName);
2065 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
2067 TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName();
2068 theDi.Eval (aCommand.ToCString());
2071 ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1);
2076 TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
2077 aViewName, aDisplayName, aCopyFrom);
2080 ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1);
2086 //! Parse HLR algo type.
2087 static Standard_Boolean parseHlrAlgoType (const char* theName,
2088 Prs3d_TypeOfHLR& theType)
2090 TCollection_AsciiString aName (theName);
2092 if (aName == "polyalgo")
2094 theType = Prs3d_TOH_PolyAlgo;
2096 else if (aName == "algo")
2098 theType = Prs3d_TOH_Algo;
2102 return Standard_False;
2104 return Standard_True;
2107 //==============================================================================
2109 //purpose : hidden lines removal algorithm
2110 //==============================================================================
2112 static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2114 const Handle(V3d_View) aView = ViewerTest::CurrentView();
2115 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2118 Message::SendFail ("Error: no active viewer");
2122 Standard_Boolean hasHlrOnArg = Standard_False;
2123 Standard_Boolean hasShowHiddenArg = Standard_False;
2124 Standard_Boolean isHLROn = Standard_False;
2125 Standard_Boolean toShowHidden = aCtx->DefaultDrawer()->DrawHiddenLine();
2126 Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet;
2127 ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
2128 for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
2130 TCollection_AsciiString anArg (argv[anArgIter]);
2132 if (anUpdateTool.parseRedrawMode (anArg))
2136 else if (anArg == "-showhidden"
2137 && anArgIter + 1 < argc
2138 && ViewerTest::ParseOnOff (argv[anArgIter + 1], toShowHidden))
2141 hasShowHiddenArg = Standard_True;
2144 else if ((anArg == "-type"
2146 || anArg == "-algotype")
2147 && anArgIter + 1 < argc
2148 && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR))
2153 else if (!hasHlrOnArg
2154 && ViewerTest::ParseOnOff (argv[anArgIter], isHLROn))
2156 hasHlrOnArg = Standard_True;
2160 else if (!hasShowHiddenArg
2161 && ViewerTest::ParseOnOff(argv[anArgIter], toShowHidden))
2163 hasShowHiddenArg = Standard_True;
2168 Message::SendFail() << "Syntax error at '" << argv[anArgIter] << "'";
2174 di << "HLR: " << aView->ComputedMode() << "\n";
2175 di << "HiddenLine: " << aCtx->DefaultDrawer()->DrawHiddenLine() << "\n";
2177 switch (aCtx->DefaultDrawer()->TypeOfHLR())
2179 case Prs3d_TOH_NotSet: di << "NotSet\n"; break;
2180 case Prs3d_TOH_PolyAlgo: di << "PolyAlgo\n"; break;
2181 case Prs3d_TOH_Algo: di << "Algo\n"; break;
2183 anUpdateTool.Invalidate();
2187 Standard_Boolean toRecompute = Standard_False;
2188 if (aTypeOfHLR != Prs3d_TOH_NotSet
2189 && aTypeOfHLR != aCtx->DefaultDrawer()->TypeOfHLR())
2191 toRecompute = Standard_True;
2192 aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR);
2194 if (toShowHidden != aCtx->DefaultDrawer()->DrawHiddenLine())
2196 toRecompute = Standard_True;
2199 aCtx->DefaultDrawer()->EnableDrawHiddenLine();
2203 aCtx->DefaultDrawer()->DisableDrawHiddenLine();
2208 if (aView->ComputedMode() && isHLROn && toRecompute)
2210 AIS_ListOfInteractive aListOfShapes;
2211 aCtx->DisplayedObjects (aListOfShapes);
2212 for (AIS_ListIteratorOfListOfInteractive anIter (aListOfShapes); anIter.More(); anIter.Next())
2214 if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()))
2216 aCtx->Redisplay (aShape, Standard_False);
2221 aView->SetComputedMode (isHLROn);
2225 //==============================================================================
2226 //function : VHLRType
2227 //purpose : change type of using HLR algorithm
2228 //==============================================================================
2230 static int VHLRType (Draw_Interpretor& , Standard_Integer argc, const char** argv)
2232 const Handle(V3d_View) aView = ViewerTest::CurrentView();
2233 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2236 Message::SendFail ("Error: no active viewer");
2240 Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet;
2241 ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
2242 AIS_ListOfInteractive aListOfShapes;
2243 for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
2245 TCollection_AsciiString anArg (argv[anArgIter]);
2247 if (anUpdateTool.parseRedrawMode (anArg))
2251 else if ((anArg == "-type"
2253 || anArg == "-algotype")
2254 && anArgIter + 1 < argc
2255 && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR))
2261 else if (aTypeOfHLR == Prs3d_TOH_NotSet
2262 && parseHlrAlgoType (argv[anArgIter], aTypeOfHLR))
2268 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
2269 TCollection_AsciiString aName (argv[anArgIter]);
2270 if (!aMap.IsBound2 (aName))
2272 Message::SendFail() << "Syntax error: Wrong shape name '" << aName << "'";
2276 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (aMap.Find2 (aName));
2277 if (aShape.IsNull())
2279 Message::SendFail() << "Syntax error: '" << aName << "' is not a shape presentation";
2282 aListOfShapes.Append (aShape);
2286 if (aTypeOfHLR == Prs3d_TOH_NotSet)
2288 Message::SendFail ("Syntax error: wrong number of arguments");
2292 const Standard_Boolean isGlobal = aListOfShapes.IsEmpty();
2295 aCtx->DisplayedObjects (aListOfShapes);
2296 aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR);
2299 for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next())
2301 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
2302 if (aShape.IsNull())
2307 const bool toUpdateShape = aShape->TypeOfHLR() != aTypeOfHLR
2308 && aView->ComputedMode();
2310 || aShape->TypeOfHLR() != aTypeOfHLR)
2312 aShape->SetTypeOfHLR (aTypeOfHLR);
2316 aCtx->Redisplay (aShape, Standard_False);
2322 //==============================================================================
2323 //function : FindViewIdByWindowHandle
2324 //purpose : Find theView Id in the map of views by window handle
2325 //==============================================================================
2326 #if defined(_WIN32) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
2327 TCollection_AsciiString FindViewIdByWindowHandle (Aspect_Drawable theWindowHandle)
2329 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator
2330 anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
2332 Aspect_Drawable aWindowHandle = anIter.Value()->Window()->NativeHandle();
2333 if (aWindowHandle == theWindowHandle)
2334 return anIter.Key1();
2336 return TCollection_AsciiString("");
2340 //! Make the view active
2341 void ActivateView (const TCollection_AsciiString& theViewName,
2342 Standard_Boolean theToUpdate = Standard_True)
2344 const Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
2350 Handle(AIS_InteractiveContext) anAISContext = FindContextByView(aView);
2351 if (!anAISContext.IsNull())
2353 if (const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView())
2355 aCurrentView->Window()->SetTitle (TCollection_AsciiString ("3D View - ") + ViewerTest_myViews.Find2 (aCurrentView));
2358 ViewerTest::CurrentView (aView);
2359 ViewerTest::SetAISContext (anAISContext);
2360 aView->Window()->SetTitle (TCollection_AsciiString("3D View - ") + theViewName + "(*)");
2362 VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window());
2363 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
2364 VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window());
2366 VT_GetWindow() = Handle(Xw_Window)::DownCast(ViewerTest::CurrentView()->Window());
2368 SetDisplayConnection(ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
2371 ViewerTest::CurrentView()->Redraw();
2376 //==============================================================================
2377 //function : RemoveView
2379 //==============================================================================
2380 void ViewerTest::RemoveView (const Handle(V3d_View)& theView,
2381 const Standard_Boolean theToRemoveContext)
2383 if (!ViewerTest_myViews.IsBound2 (theView))
2388 const TCollection_AsciiString aViewName = ViewerTest_myViews.Find2 (theView);
2389 RemoveView (aViewName, theToRemoveContext);
2392 //==============================================================================
2393 //function : RemoveView
2394 //purpose : Close and remove view from display, clear maps if neccessary
2395 //==============================================================================
2396 void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const Standard_Boolean isContextRemoved)
2398 if (!ViewerTest_myViews.IsBound1(theViewName))
2400 Message::SendFail() << "Wrong view name";
2404 // Activate another view if it's active now
2405 if (ViewerTest_myViews.Find1(theViewName) == ViewerTest::CurrentView())
2407 if (ViewerTest_myViews.Extent() > 1)
2409 TCollection_AsciiString aNewViewName;
2410 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
2411 anIter.More(); anIter.Next())
2413 if (anIter.Key1() != theViewName)
2415 aNewViewName = anIter.Key1();
2419 ActivateView (aNewViewName);
2423 VT_GetWindow().Nullify();
2424 ViewerTest::CurrentView (Handle(V3d_View)());
2425 if (isContextRemoved)
2427 Handle(AIS_InteractiveContext) anEmptyContext;
2428 ViewerTest::SetAISContext(anEmptyContext);
2434 Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
2435 Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
2436 ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
2437 aRedrawer.Stop (aView->Window());
2439 // Remove view resources
2440 ViewerTest_myViews.UnBind1(theViewName);
2441 aView->Window()->Unmap();
2444 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
2445 XFlush (GetDisplayConnection()->GetDisplay());
2448 // Keep context opened only if the closed view is last to avoid
2449 // unused empty contexts
2450 if (!aCurrentContext.IsNull())
2452 // Check if there are more difined views in the viewer
2453 if ((isContextRemoved || ViewerTest_myContexts.Size() != 1)
2454 && aCurrentContext->CurrentViewer()->DefinedViews().IsEmpty())
2456 // Remove driver if there is no viewers that use it
2457 Standard_Boolean isRemoveDriver = Standard_True;
2458 for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
2459 anIter(ViewerTest_myContexts); anIter.More(); anIter.Next())
2461 if (aCurrentContext != anIter.Key2() &&
2462 aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver())
2464 isRemoveDriver = Standard_False;
2469 aCurrentContext->RemoveAll (Standard_False);
2472 ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver());
2473 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
2474 Tcl_DeleteFileHandler (XConnectionNumber (aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplay()));
2478 ViewerTest_myContexts.UnBind2(aCurrentContext);
2481 Message::SendInfo() << "3D View - " << theViewName << " was deleted.\n";
2482 if (ViewerTest_EventManager::ToExitOnCloseView())
2484 Draw_Interprete ("exit");
2488 //==============================================================================
2490 //purpose : Remove the view defined by its name
2491 //==============================================================================
2493 static int VClose (Draw_Interpretor& /*theDi*/,
2494 Standard_Integer theArgsNb,
2495 const char** theArgVec)
2497 NCollection_List<TCollection_AsciiString> aViewList;
2500 TCollection_AsciiString anArg (theArgVec[1]);
2502 if (anArg.IsEqual ("ALL")
2503 || anArg.IsEqual ("*"))
2505 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
2506 anIter.More(); anIter.Next())
2508 aViewList.Append (anIter.Key1());
2510 if (aViewList.IsEmpty())
2512 std::cout << "No view to close\n";
2518 ViewerTest_Names aViewName (theArgVec[1]);
2519 if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName()))
2521 Message::SendFail() << "Error: the view with name '" << theArgVec[1] << "' does not exist";
2524 aViewList.Append (aViewName.GetViewName());
2529 // close active view
2530 if (ViewerTest::CurrentView().IsNull())
2532 Message::SendFail ("Error: no active view");
2535 aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView()));
2538 Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1);
2539 for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList);
2540 anIter.More(); anIter.Next())
2542 ViewerTest::RemoveView (anIter.Value(), toRemoveContext);
2548 //==============================================================================
2549 //function : VActivate
2550 //purpose : Activate the view defined by its ID
2551 //==============================================================================
2553 static int VActivate (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
2557 theDi.Eval("vviewlist");
2561 TCollection_AsciiString aNameString;
2562 Standard_Boolean toUpdate = Standard_True;
2563 Standard_Boolean toActivate = Standard_True;
2564 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
2566 TCollection_AsciiString anArg (theArgVec[anArgIter]);
2569 && anArg == "-noupdate")
2571 toUpdate = Standard_False;
2574 && aNameString.IsEmpty()
2577 ViewerTest::CurrentView()->Window()->SetTitle (TCollection_AsciiString ("3D View - ") + ViewerTest_myViews.Find2 (ViewerTest::CurrentView()));
2578 VT_GetWindow().Nullify();
2579 ViewerTest::CurrentView (Handle(V3d_View)());
2580 ViewerTest::ResetEventManager();
2581 theDi << theArgVec[0] << ": all views are inactive\n";
2582 toActivate = Standard_False;
2585 && aNameString.IsEmpty())
2587 aNameString = theArgVec[anArgIter];
2591 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
2600 else if (aNameString.IsEmpty())
2602 Message::SendFail ("Syntax error: wrong number of arguments");
2606 // Check if this view exists in the viewer with the driver
2607 ViewerTest_Names aViewNames (aNameString);
2608 if (!ViewerTest_myViews.IsBound1(aViewNames.GetViewName()))
2610 theDi << "Syntax error: wrong view name '" << aNameString << "'\n";
2614 // Check if it is active already
2615 if (ViewerTest::CurrentView() == ViewerTest_myViews.Find1(aViewNames.GetViewName()))
2617 theDi << theArgVec[0] << ": the view is active already\n";
2621 ActivateView (aViewNames.GetViewName(), toUpdate);
2625 //==============================================================================
2626 //function : VViewList
2627 //purpose : Print current list of views per viewer and graphic driver ID
2628 // shared between viewers
2629 //==============================================================================
2631 static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
2635 theDi << theArgVec[0] << ": Wrong number of command arguments\n"
2636 << "Usage: " << theArgVec[0] << " name";
2639 if (ViewerTest_myContexts.Size() < 1)
2642 Standard_Boolean isTreeView =
2643 (( theArgsNb==1 ) || ( strcasecmp( theArgVec[1], "long" ) != 0 ));
2647 theDi << theArgVec[0] <<":\n";
2650 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator aDriverIter (ViewerTest_myDrivers);
2651 aDriverIter.More(); aDriverIter.Next())
2654 theDi << aDriverIter.Key1() << ":\n";
2656 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
2657 aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next())
2659 if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1)
2663 TCollection_AsciiString aContextName(aContextIter.Key1());
2664 theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":\n";
2667 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIter (ViewerTest_myViews);
2668 aViewIter.More(); aViewIter.Next())
2670 if (aViewIter.Key1().Search(aContextIter.Key1()) != -1)
2672 TCollection_AsciiString aViewName(aViewIter.Key1());
2675 if (aViewIter.Value() == ViewerTest::CurrentView())
2676 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)\n";
2678 theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n";
2682 theDi << aViewName << " ";
2692 //==============================================================================
2693 //function : GetMousePosition
2695 //==============================================================================
2696 void ViewerTest::GetMousePosition (Standard_Integer& theX,
2697 Standard_Integer& theY)
2699 if (Handle(ViewerTest_EventManager) aViewCtrl = ViewerTest::CurrentEventManager())
2701 theX = aViewCtrl->LastMousePosition().x();
2702 theY = aViewCtrl->LastMousePosition().y();
2706 //==============================================================================
2707 //function : VViewProj
2708 //purpose : Switch view projection
2709 //==============================================================================
2710 static int VViewProj (Draw_Interpretor& ,
2711 Standard_Integer theNbArgs,
2712 const char** theArgVec)
2714 static Standard_Boolean isYup = Standard_False;
2715 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
2718 Message::SendFail ("Error: no active viewer");
2722 TCollection_AsciiString aCmdName (theArgVec[0]);
2723 Standard_Boolean isGeneralCmd = Standard_False;
2724 if (aCmdName == "vfront")
2726 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Front : V3d_TypeOfOrientation_Zup_Front, isYup);
2728 else if (aCmdName == "vback")
2730 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Back : V3d_TypeOfOrientation_Zup_Back, isYup);
2732 else if (aCmdName == "vtop")
2734 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Top : V3d_TypeOfOrientation_Zup_Top, isYup);
2736 else if (aCmdName == "vbottom")
2738 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Bottom : V3d_TypeOfOrientation_Zup_Bottom, isYup);
2740 else if (aCmdName == "vleft")
2742 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Left : V3d_TypeOfOrientation_Zup_Left, isYup);
2744 else if (aCmdName == "vright")
2746 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Right : V3d_TypeOfOrientation_Zup_Right, isYup);
2748 else if (aCmdName == "vaxo")
2750 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_AxoRight : V3d_TypeOfOrientation_Zup_AxoRight, isYup);
2754 isGeneralCmd = Standard_True;
2755 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
2757 TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
2758 anArgCase.LowerCase();
2759 if (anArgCase == "-zup")
2761 isYup = Standard_False;
2763 else if (anArgCase == "-yup")
2765 isYup = Standard_True;
2767 else if (anArgCase == "-front"
2768 || anArgCase == "front"
2769 || anArgCase == "-f"
2770 || anArgCase == "f")
2772 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Front : V3d_TypeOfOrientation_Zup_Front, isYup);
2774 else if (anArgCase == "-back"
2775 || anArgCase == "back"
2776 || anArgCase == "-b"
2777 || anArgCase == "b")
2779 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Back : V3d_TypeOfOrientation_Zup_Back, isYup);
2781 else if (anArgCase == "-top"
2782 || anArgCase == "top"
2783 || anArgCase == "-t"
2784 || anArgCase == "t")
2786 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Top : V3d_TypeOfOrientation_Zup_Top, isYup);
2788 else if (anArgCase == "-bottom"
2789 || anArgCase == "bottom"
2790 || anArgCase == "-bot"
2791 || anArgCase == "bot"
2792 || anArgCase == "-b"
2793 || anArgCase == "b")
2795 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Bottom : V3d_TypeOfOrientation_Zup_Bottom, isYup);
2797 else if (anArgCase == "-left"
2798 || anArgCase == "left"
2799 || anArgCase == "-l"
2800 || anArgCase == "l")
2802 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Left : V3d_TypeOfOrientation_Zup_Left, isYup);
2804 else if (anArgCase == "-right"
2805 || anArgCase == "right"
2806 || anArgCase == "-r"
2807 || anArgCase == "r")
2809 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Right : V3d_TypeOfOrientation_Zup_Right, isYup);
2811 else if (anArgCase == "-axoleft"
2812 || anArgCase == "-leftaxo"
2813 || anArgCase == "axoleft"
2814 || anArgCase == "leftaxo")
2816 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_AxoLeft : V3d_TypeOfOrientation_Zup_AxoLeft, isYup);
2818 else if (anArgCase == "-axo"
2819 || anArgCase == "axo"
2820 || anArgCase == "-a"
2822 || anArgCase == "-axoright"
2823 || anArgCase == "-rightaxo"
2824 || anArgCase == "axoright"
2825 || anArgCase == "rightaxo")
2827 aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_AxoRight : V3d_TypeOfOrientation_Zup_AxoRight, isYup);
2829 else if (anArgCase == "+x")
2831 aView->SetProj (V3d_Xpos, isYup);
2833 else if (anArgCase == "-x")
2835 aView->SetProj (V3d_Xneg, isYup);
2837 else if (anArgCase == "+y")
2839 aView->SetProj (V3d_Ypos, isYup);
2841 else if (anArgCase == "-y")
2843 aView->SetProj (V3d_Yneg, isYup);
2845 else if (anArgCase == "+z")
2847 aView->SetProj (V3d_Zpos, isYup);
2849 else if (anArgCase == "-z")
2851 aView->SetProj (V3d_Zneg, isYup);
2853 else if (anArgCase == "+x+y+z")
2855 aView->SetProj (V3d_XposYposZpos, isYup);
2857 else if (anArgCase == "+x+y-z")
2859 aView->SetProj (V3d_XposYposZneg, isYup);
2861 else if (anArgCase == "+x-y+z")
2863 aView->SetProj (V3d_XposYnegZpos, isYup);
2865 else if (anArgCase == "+x-y-z")
2867 aView->SetProj (V3d_XposYnegZneg, isYup);
2869 else if (anArgCase == "-x+y+z")
2871 aView->SetProj (V3d_XnegYposZpos, isYup);
2873 else if (anArgCase == "-x+y-z")
2875 aView->SetProj (V3d_XnegYposZneg, isYup);
2877 else if (anArgCase == "-x-y+z")
2879 aView->SetProj (V3d_XnegYnegZpos, isYup);
2881 else if (anArgCase == "-x-y-z")
2883 aView->SetProj (V3d_XnegYnegZneg, isYup);
2885 else if (anArgCase == "+x+y")
2887 aView->SetProj (V3d_XposYpos, isYup);
2889 else if (anArgCase == "+x-y")
2891 aView->SetProj (V3d_XposYneg, isYup);
2893 else if (anArgCase == "-x+y")
2895 aView->SetProj (V3d_XnegYpos, isYup);
2897 else if (anArgCase == "-x-y")
2899 aView->SetProj (V3d_XnegYneg, isYup);
2901 else if (anArgCase == "+x+z")
2903 aView->SetProj (V3d_XposZpos, isYup);
2905 else if (anArgCase == "+x-z")
2907 aView->SetProj (V3d_XposZneg, isYup);
2909 else if (anArgCase == "-x+z")
2911 aView->SetProj (V3d_XnegZpos, isYup);
2913 else if (anArgCase == "-x-z")
2915 aView->SetProj (V3d_XnegZneg, isYup);
2917 else if (anArgCase == "+y+z")
2919 aView->SetProj (V3d_YposZpos, isYup);
2921 else if (anArgCase == "+y-z")
2923 aView->SetProj (V3d_YposZneg, isYup);
2925 else if (anArgCase == "-y+z")
2927 aView->SetProj (V3d_YnegZpos, isYup);
2929 else if (anArgCase == "-y-z")
2931 aView->SetProj (V3d_YnegZneg, isYup);
2933 else if (anArgIter + 1 < theNbArgs
2934 && anArgCase == "-frame"
2935 && TCollection_AsciiString (theArgVec[anArgIter + 1]).Length() == 4)
2937 TCollection_AsciiString aFrameDef (theArgVec[++anArgIter]);
2938 aFrameDef.LowerCase();
2939 gp_Dir aRight, anUp;
2940 if (aFrameDef.Value (2) == aFrameDef.Value (4))
2942 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
2946 if (aFrameDef.Value (2) == 'x')
2948 aRight = aFrameDef.Value (1) == '+' ? gp::DX() : -gp::DX();
2950 else if (aFrameDef.Value (2) == 'y')
2952 aRight = aFrameDef.Value (1) == '+' ? gp::DY() : -gp::DY();
2954 else if (aFrameDef.Value (2) == 'z')
2956 aRight = aFrameDef.Value (1) == '+' ? gp::DZ() : -gp::DZ();
2960 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
2964 if (aFrameDef.Value (4) == 'x')
2966 anUp = aFrameDef.Value (3) == '+' ? gp::DX() : -gp::DX();
2968 else if (aFrameDef.Value (4) == 'y')
2970 anUp = aFrameDef.Value (3) == '+' ? gp::DY() : -gp::DY();
2972 else if (aFrameDef.Value (4) == 'z')
2974 anUp = aFrameDef.Value (3) == '+' ? gp::DZ() : -gp::DZ();
2978 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
2982 const Handle(Graphic3d_Camera)& aCamera = aView->Camera();
2983 const gp_Pnt anOriginVCS = aCamera->ConvertWorld2View (gp::Origin());
2984 const gp_Dir aDir = anUp.Crossed (aRight);
2985 aCamera->SetCenter (gp_Pnt (0, 0, 0));
2986 aCamera->SetDirection (aDir);
2987 aCamera->SetUp (anUp);
2988 aCamera->OrthogonalizeUp();
2990 aView->Panning (anOriginVCS.X(), anOriginVCS.Y());
2995 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
3004 Message::SendFail ("Syntax error: wrong number of arguments");
3010 //==============================================================================
3012 //purpose : Dsiplay help on viewer Keyboead and mouse commands
3013 //Draw arg : No args
3014 //==============================================================================
3016 static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
3018 di << "=========================\n";
3019 di << "F : FitAll\n";
3020 di << "T : TopView\n";
3021 di << "B : BottomView\n";
3022 di << "R : RightView\n";
3023 di << "L : LeftView\n";
3024 di << "Backspace : AxonometricView\n";
3026 di << "=========================\n";
3027 di << "W, S : Fly forward/backward\n";
3028 di << "A, D : Slide left/right\n";
3029 di << "Q, E : Bank left/right\n";
3030 di << "-, + : Change flying speed\n";
3031 di << "Arrows : look left/right/up/down\n";
3032 di << "Arrows+Shift : slide left/right/up/down\n";
3034 di << "=========================\n";
3035 di << "S + Ctrl : Shading\n";
3036 di << "W + Ctrl : Wireframe\n";
3037 di << "H : HiddenLineRemoval\n";
3038 di << "U : Unset display mode\n";
3039 di << "Delete : Remove selection from viewer\n";
3041 di << "=========================\n";
3042 di << "Selection mode \n";
3043 di << "0 : Shape\n";
3044 di << "1 : Vertex\n";
3048 di << "5 : Shell\n";
3049 di << "6 : Solid\n";
3050 di << "7 : Compound\n";
3052 di << "=========================\n";
3053 di << "< : Hilight next detected\n";
3054 di << "> : Hilight previous detected\n";
3061 static LRESULT WINAPI AdvViewerWindowProc (HWND theWinHandle,
3066 if (ViewerTest_myViews.IsEmpty())
3068 return ViewerWindowProc (theWinHandle, theMsg, wParam, lParam);
3075 // Delete view from map of views
3076 ViewerTest::RemoveView (FindViewIdByWindowHandle (theWinHandle));
3081 if (LOWORD(wParam) == WA_CLICKACTIVE
3082 || LOWORD(wParam) == WA_ACTIVE
3083 || ViewerTest::CurrentView().IsNull())
3085 // Activate inactive window
3086 if (VT_GetWindow().IsNull()
3087 || (HWND )VT_GetWindow()->HWindow() != theWinHandle)
3089 ActivateView (FindViewIdByWindowHandle (theWinHandle));
3096 return ViewerWindowProc (theWinHandle, theMsg, wParam, lParam);
3102 static LRESULT WINAPI ViewerWindowProc (HWND theWinHandle,
3107 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
3110 return DefWindowProcW (theWinHandle, theMsg, wParam, lParam);
3118 BeginPaint(theWinHandle, &aPaint);
3119 EndPaint (theWinHandle, &aPaint);
3120 ViewerTest::CurrentEventManager()->ProcessExpose();
3125 ViewerTest::CurrentEventManager()->ProcessConfigure();
3132 switch (aView->RenderingParams().StereoMode)
3134 case Graphic3d_StereoMode_RowInterlaced:
3135 case Graphic3d_StereoMode_ColumnInterlaced:
3136 case Graphic3d_StereoMode_ChessBoard:
3138 // track window moves to reverse stereo pair
3139 aView->MustBeResized();
3151 const Aspect_VKey aVKey = WNT_Window::VirtualKeyFromNative ((Standard_Integer )wParam);
3152 if (aVKey != Aspect_VKey_UNKNOWN)
3154 const double aTimeStamp = ViewerTest::CurrentEventManager()->EventTime();
3155 if (theMsg == WM_KEYDOWN)
3157 ViewerTest::CurrentEventManager()->KeyDown (aVKey, aTimeStamp);
3161 ViewerTest::CurrentEventManager()->KeyUp (aVKey, aTimeStamp);
3163 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3170 case WM_LBUTTONDOWN:
3171 case WM_MBUTTONDOWN:
3172 case WM_RBUTTONDOWN:
3174 const Graphic3d_Vec2i aPos (LOWORD(lParam), HIWORD(lParam));
3175 const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (wParam);
3176 Aspect_VKeyMouse aButton = Aspect_VKeyMouse_NONE;
3180 case WM_LBUTTONDOWN:
3181 aButton = Aspect_VKeyMouse_LeftButton;
3184 case WM_MBUTTONDOWN:
3185 aButton = Aspect_VKeyMouse_MiddleButton;
3188 case WM_RBUTTONDOWN:
3189 aButton = Aspect_VKeyMouse_RightButton;
3192 if (theMsg == WM_LBUTTONDOWN
3193 || theMsg == WM_MBUTTONDOWN
3194 || theMsg == WM_RBUTTONDOWN)
3196 if (aButton == Aspect_VKeyMouse_LeftButton)
3198 TheIsAnimating = Standard_False;
3201 SetFocus (theWinHandle);
3202 SetCapture(theWinHandle);
3203 ViewerTest::CurrentEventManager()->PressMouseButton (aPos, aButton, aFlags, false);
3208 ViewerTest::CurrentEventManager()->ReleaseMouseButton (aPos, aButton, aFlags, false);
3210 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3215 const int aDelta = GET_WHEEL_DELTA_WPARAM (wParam);
3216 const Standard_Real aDeltaF = Standard_Real(aDelta) / Standard_Real(WHEEL_DELTA);
3217 const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (wParam);
3218 Graphic3d_Vec2i aPos (int(short(LOWORD(lParam))), int(short(HIWORD(lParam))));
3219 POINT aCursorPnt = { aPos.x(), aPos.y() };
3220 if (ScreenToClient (theWinHandle, &aCursorPnt))
3222 aPos.SetValues (aCursorPnt.x, aCursorPnt.y);
3225 ViewerTest::CurrentEventManager()->UpdateMouseScroll (Aspect_ScrollDelta (aPos, aDeltaF, aFlags));
3226 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3231 Graphic3d_Vec2i aPos (LOWORD(lParam), HIWORD(lParam));
3232 Aspect_VKeyMouse aButtons = WNT_Window::MouseButtonsFromEvent (wParam);
3233 Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent(wParam);
3235 // don't make a slide-show from input events - fetch the actual mouse cursor position
3237 aCursor.cbSize = sizeof(aCursor);
3238 if (::GetCursorInfo (&aCursor) != FALSE)
3240 POINT aCursorPnt = { aCursor.ptScreenPos.x, aCursor.ptScreenPos.y };
3241 if (ScreenToClient (theWinHandle, &aCursorPnt))
3243 // as we override mouse position, we need overriding also mouse state
3244 aPos.SetValues (aCursorPnt.x, aCursorPnt.y);
3245 aButtons = WNT_Window::MouseButtonsAsync();
3246 aFlags = WNT_Window::MouseKeyFlagsAsync();
3250 if (VT_GetWindow().IsNull()
3251 || (HWND )VT_GetWindow()->HWindow() != theWinHandle)
3253 // mouse move events come also for inactive windows
3257 ViewerTest::CurrentEventManager()->UpdateMousePosition (aPos, aButtons, aFlags, false);
3258 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
3263 return DefWindowProcW (theWinHandle, theMsg, wParam, lParam);
3269 //==============================================================================
3270 //function : ViewerMainLoop
3271 //purpose : Get a Event on the view and dispatch it
3272 //==============================================================================
3274 int ViewerMainLoop (Standard_Integer theNbArgs, const char** theArgVec)
3276 Handle(ViewerTest_EventManager) aViewCtrl = ViewerTest::CurrentEventManager();
3277 if (aViewCtrl.IsNull()
3283 aViewCtrl->StartPickPoint (theArgVec[1], theArgVec[2], theArgVec[3]);
3285 std::cout << "Start picking\n";
3289 while (aViewCtrl->ToPickPoint())
3291 // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
3292 if (GetMessageW (&aMsg, NULL, 0, 0))
3294 TranslateMessage (&aMsg);
3295 DispatchMessageW (&aMsg);
3299 std::cout << "Picking done\n";
3303 #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX)
3305 int min( int a, int b )
3313 int max( int a, int b )
3321 int ViewerMainLoop (Standard_Integer theNbArgs, const char** theArgVec)
3323 static XEvent aReport;
3324 const Standard_Boolean toPick = theNbArgs > 0;
3327 if (ViewerTest::CurrentEventManager().IsNull())
3331 ViewerTest::CurrentEventManager()->StartPickPoint (theArgVec[1], theArgVec[2], theArgVec[3]);
3334 Display* aDisplay = GetDisplayConnection()->GetDisplay();
3335 XNextEvent (aDisplay, &aReport);
3337 // Handle event for the chosen display connection
3338 switch (aReport.type)
3342 if ((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW))
3345 ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window));
3346 return toPick ? 0 : 1;
3352 // Activate inactive view
3353 Window aWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3354 if (aWindow != aReport.xfocus.window)
3356 ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window));
3362 Window anXWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3363 if (anXWindow == aReport.xexpose.window)
3365 ViewerTest::CurrentEventManager()->ProcessExpose();
3368 // remove all the ExposureMask and process them at once
3369 for (int aNbMaxEvents = XPending (aDisplay); aNbMaxEvents > 0; --aNbMaxEvents)
3371 if (!XCheckWindowEvent (aDisplay, anXWindow, ExposureMask, &aReport))
3379 case ConfigureNotify:
3381 // remove all the StructureNotifyMask and process them at once
3382 Window anXWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3383 for (int aNbMaxEvents = XPending (aDisplay); aNbMaxEvents > 0; --aNbMaxEvents)
3385 if (!XCheckWindowEvent (aDisplay, anXWindow, StructureNotifyMask, &aReport))
3391 if (anXWindow == aReport.xconfigure.window)
3393 ViewerTest::CurrentEventManager()->ProcessConfigure();
3400 XKeyEvent* aKeyEvent = (XKeyEvent* )&aReport;
3401 const KeySym aKeySym = XLookupKeysym (aKeyEvent, 0);
3402 const Aspect_VKey aVKey = Xw_Window::VirtualKeyFromNative (aKeySym);
3403 if (aVKey != Aspect_VKey_UNKNOWN)
3405 const double aTimeStamp = ViewerTest::CurrentEventManager()->EventTime();
3406 if (aReport.type == KeyPress)
3408 ViewerTest::CurrentEventManager()->KeyDown (aVKey, aTimeStamp);
3412 ViewerTest::CurrentEventManager()->KeyUp (aVKey, aTimeStamp);
3414 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3421 const Graphic3d_Vec2i aPos (aReport.xbutton.x, aReport.xbutton.y);
3422 Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
3423 Aspect_VKeyMouse aButton = Aspect_VKeyMouse_NONE;
3424 if (aReport.xbutton.button == Button1)
3426 aButton = Aspect_VKeyMouse_LeftButton;
3428 if (aReport.xbutton.button == Button2)
3430 aButton = Aspect_VKeyMouse_MiddleButton;
3432 if (aReport.xbutton.button == Button3)
3434 aButton = Aspect_VKeyMouse_RightButton;
3437 if (aReport.xbutton.state & ControlMask)
3439 aFlags |= Aspect_VKeyFlags_CTRL;
3441 if (aReport.xbutton.state & ShiftMask)
3443 aFlags |= Aspect_VKeyFlags_SHIFT;
3445 if (ViewerTest::CurrentEventManager()->Keys().IsKeyDown (Aspect_VKey_Alt))
3447 aFlags |= Aspect_VKeyFlags_ALT;
3450 if (aReport.xbutton.button == Button4
3451 || aReport.xbutton.button == Button5)
3453 if (aReport.type != ButtonPress)
3458 const double aDeltaF = (aReport.xbutton.button == Button4 ? 1.0 : -1.0);
3459 ViewerTest::CurrentEventManager()->UpdateMouseScroll (Aspect_ScrollDelta (aPos, aDeltaF, aFlags));
3461 else if (aReport.type == ButtonPress)
3463 if (aButton == Aspect_VKeyMouse_LeftButton)
3465 TheIsAnimating = Standard_False;
3467 ViewerTest::CurrentEventManager()->PressMouseButton (aPos, aButton, aFlags, false);
3471 ViewerTest::CurrentEventManager()->ReleaseMouseButton (aPos, aButton, aFlags, false);
3473 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3478 Window anXWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3479 if (anXWindow != aReport.xmotion.window)
3484 // remove all the ButtonMotionMask and process them at once
3485 for (int aNbMaxEvents = XPending (aDisplay); aNbMaxEvents > 0; --aNbMaxEvents)
3487 if (!XCheckWindowEvent (aDisplay, anXWindow, ButtonMotionMask | PointerMotionMask, &aReport))
3493 Graphic3d_Vec2i aPos (aReport.xmotion.x, aReport.xmotion.y);
3494 Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
3495 Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
3496 if ((aReport.xmotion.state & Button1Mask) != 0)
3498 aButtons |= Aspect_VKeyMouse_LeftButton;
3500 else if ((aReport.xmotion.state & Button2Mask) != 0)
3502 aButtons |= Aspect_VKeyMouse_MiddleButton;
3504 else if ((aReport.xmotion.state & Button3Mask) != 0)
3506 aButtons |= Aspect_VKeyMouse_RightButton;
3509 if (aReport.xmotion.state & ControlMask)
3511 aFlags |= Aspect_VKeyFlags_CTRL;
3513 if (aReport.xmotion.state & ShiftMask)
3515 aFlags |= Aspect_VKeyFlags_SHIFT;
3517 if (ViewerTest::CurrentEventManager()->Keys().IsKeyDown (Aspect_VKey_Alt))
3519 aFlags |= Aspect_VKeyFlags_ALT;
3522 ViewerTest::CurrentEventManager()->UpdateMousePosition (aPos, aButtons, aFlags, false);
3523 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3527 return (!toPick || ViewerTest::CurrentEventManager()->ToPickPoint()) ? 1 : 0;
3530 //==============================================================================
3531 //function : VProcessEvents
3532 //purpose : manage the event in the Viewer window (see Tcl_CreateFileHandler())
3533 //==============================================================================
3534 static void VProcessEvents (ClientData theDispX, int)
3536 Display* aDispX = (Display* )theDispX;
3537 Handle(Aspect_DisplayConnection) aDispConn;
3538 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
3539 aDriverIter (ViewerTest_myDrivers); aDriverIter.More(); aDriverIter.Next())
3541 const Handle(Aspect_DisplayConnection)& aDispConnTmp = aDriverIter.Key2()->GetDisplayConnection();
3542 if (aDispConnTmp->GetDisplay() == aDispX)
3544 aDispConn = aDispConnTmp;
3548 if (aDispConn.IsNull())
3550 Message::SendFail ("Error: ViewerTest is unable processing messages for unknown X Display");
3554 // process new events in queue
3555 SetDisplayConnection (aDispConn);
3557 for (int aNbEventsMax = XPending (aDispX), anEventIter (0);;)
3559 const int anEventResult = ViewerMainLoop (0, NULL);
3560 if (anEventResult == 0)
3565 aNbRemain = XPending (aDispX);
3566 if (++anEventIter >= aNbEventsMax
3573 // Listening X events through Tcl_CreateFileHandler() callback is fragile,
3574 // it is possible that new events will arrive to queue before the end of this callback
3575 // so that either this callback should go into an infinite loop (blocking processing of other events)
3576 // or to keep unprocessed events till the next queue update (which can arrive not soon).
3577 // Sending a dummy event in this case is a simple workaround (still, it is possible that new event will be queued in-between).
3581 memset (&aDummyEvent, 0, sizeof(aDummyEvent));
3582 aDummyEvent.type = ClientMessage;
3583 aDummyEvent.xclient.format = 32;
3584 XSendEvent (aDispX, InputFocus, False, 0, &aDummyEvent);
3588 if (const Handle(AIS_InteractiveContext)& anActiveCtx = ViewerTest::GetAISContext())
3590 SetDisplayConnection (anActiveCtx->CurrentViewer()->Driver()->GetDisplayConnection());
3595 //==============================================================================
3596 //function : OSWindowSetup
3597 //purpose : Setup for the X11 window to be able to cath the event
3598 //==============================================================================
3601 static void OSWindowSetup()
3603 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
3606 Window window = VT_GetWindow()->XWindow();
3607 SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
3608 Display *aDisplay = GetDisplayConnection()->GetDisplay();
3609 XSynchronize(aDisplay, 1);
3611 // X11 : For keyboard on SUN
3613 wmhints.flags = InputHint;
3616 XSetWMHints( aDisplay, window, &wmhints);
3618 XSelectInput( aDisplay, window, ExposureMask | KeyPressMask | KeyReleaseMask |
3619 ButtonPressMask | ButtonReleaseMask |
3620 StructureNotifyMask |
3622 Button1MotionMask | Button2MotionMask |
3623 Button3MotionMask | FocusChangeMask
3625 Atom aDeleteWindowAtom = GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW);
3626 XSetWMProtocols(aDisplay, window, &aDeleteWindowAtom, 1);
3628 XSynchronize(aDisplay, 0);
3636 //==============================================================================
3639 //==============================================================================
3641 static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgv)
3643 const Handle(V3d_View) aView = ViewerTest::CurrentView();
3646 Message::SendFail ("Error: no active viewer");
3650 Standard_Boolean toFit = Standard_True;
3651 ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
3652 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3654 TCollection_AsciiString anArg (theArgv[anArgIter]);
3656 if (anUpdateTool.parseRedrawMode (anArg))
3660 else if (anArg == "-selected")
3662 ViewerTest::GetAISContext()->FitSelected (aView, 0.01, Standard_False);
3663 toFit = Standard_False;
3667 Message::SendFail() << "Syntax error at '" << anArg << "'";
3673 aView->FitAll (0.01, Standard_False);
3678 //=======================================================================
3679 //function : VFitArea
3680 //purpose : Fit view to show area located between two points
3681 // : given in world 2D or 3D coordinates.
3682 //=======================================================================
3683 static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3685 Handle(V3d_View) aView = ViewerTest::CurrentView();
3688 Message::SendFail ("Error: No active viewer");
3693 gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0);
3694 gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0);
3698 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
3699 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
3700 aWorldPnt2.SetX (Draw::Atof (theArgVec[3]));
3701 aWorldPnt2.SetY (Draw::Atof (theArgVec[4]));
3703 else if (theArgNb == 7)
3705 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
3706 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
3707 aWorldPnt1.SetZ (Draw::Atof (theArgVec[3]));
3708 aWorldPnt2.SetX (Draw::Atof (theArgVec[4]));
3709 aWorldPnt2.SetY (Draw::Atof (theArgVec[5]));
3710 aWorldPnt2.SetZ (Draw::Atof (theArgVec[6]));
3714 Message::SendFail ("Syntax error: Invalid number of arguments");
3715 theDI.PrintHelp(theArgVec[0]);
3719 // Convert model coordinates to view space
3720 Handle(Graphic3d_Camera) aCamera = aView->Camera();
3721 gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1);
3722 gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2);
3724 // Determine fit area
3725 gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y()));
3726 gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y()));
3728 Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner);
3730 if (aDiagonal < Precision::Confusion())
3732 Message::SendFail ("Error: view area is too small");
3736 aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y());
3740 //==============================================================================
3742 //purpose : ZFitall, no DRAW arguments
3743 //Draw arg : No args
3744 //==============================================================================
3745 static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
3747 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
3749 if (aCurrentView.IsNull())
3751 Message::SendFail ("Error: no active viewer");
3757 aCurrentView->ZFitAll();
3758 aCurrentView->Redraw();
3762 Standard_Real aScale = 1.0;
3766 aScale = Draw::Atoi (theArgVec[1]);
3769 aCurrentView->ZFitAll (aScale);
3770 aCurrentView->Redraw();
3775 //==============================================================================
3776 //function : VRepaint
3778 //==============================================================================
3779 static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgVec)
3781 Handle(V3d_View) aView = ViewerTest::CurrentView();
3784 Message::SendFail ("Error: no active viewer");
3788 Standard_Boolean isImmediateUpdate = Standard_False;
3789 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3791 TCollection_AsciiString anArg (theArgVec[anArgIter]);
3793 if (anArg == "-immediate"
3796 isImmediateUpdate = Standard_True;
3797 if (anArgIter + 1 < theArgNb
3798 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate))
3803 else if (anArg == "-continuous"
3806 || anArg == "-framerate")
3808 Standard_Real aFps = -1.0;
3809 if (anArgIter + 1 < theArgNb
3810 && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsRealValue())
3812 aFps = Draw::Atof (theArgVec[++anArgIter]);
3815 ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
3816 if (Abs (aFps) >= 1.0)
3818 aRedrawer.Start (aView->Window(), aFps);
3827 Message::SendFail() << "Syntax error at '" << anArg << "'";
3832 if (isImmediateUpdate)
3834 aView->RedrawImmediate();
3843 //==============================================================================
3845 //purpose : Remove all the object from the viewer
3846 //Draw arg : No args
3847 //==============================================================================
3849 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
3851 Handle(V3d_View) V = ViewerTest::CurrentView();
3853 ViewerTest::Clear();
3857 //==============================================================================
3860 //==============================================================================
3862 static int VPick (Draw_Interpretor& ,
3863 Standard_Integer theNbArgs,
3864 const char** theArgVec)
3866 if (ViewerTest::CurrentView().IsNull())
3873 Message::SendFail ("Syntax error: wrong number of arguments");
3877 while (ViewerMainLoop (theNbArgs, theArgVec))
3888 //! Changes the background
3889 //! @param theDrawInterpretor the interpreter of the Draw Harness application
3890 //! @param theNumberOfCommandLineArguments the number of passed command line arguments
3891 //! @param theCommandLineArguments the array of command line arguments
3892 //! @return TCL_OK if changing was successful, or TCL_ERROR otherwise
3893 static int vbackground (Draw_Interpretor& theDrawInterpretor,
3894 const Standard_Integer theNumberOfCommandLineArguments,
3895 const char** const theCommandLineArguments)
3897 if (theNumberOfCommandLineArguments < 1)
3901 BackgroundChanger aBackgroundChanger;
3902 if (!aBackgroundChanger.ProcessCommandLine (theDrawInterpretor,
3903 theNumberOfCommandLineArguments,
3904 theCommandLineArguments))
3906 theDrawInterpretor << "Wrong command arguments.\n"
3908 << theCommandLineArguments[0] << "' for information about command options and its arguments.\n";
3916 //==============================================================================
3918 //purpose : View Scaling
3919 //==============================================================================
3921 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3923 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3924 if ( V3dView.IsNull() ) return 1;
3927 di << argv[0] << "Invalid number of arguments\n";
3930 V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
3933 //==============================================================================
3934 //function : VZBuffTrihedron
3936 //==============================================================================
3938 static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
3939 Standard_Integer theArgNb,
3940 const char** theArgVec)
3942 Handle(V3d_View) aView = ViewerTest::CurrentView();
3945 Message::SendFail ("Error: no active viewer");
3949 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
3951 Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER;
3952 V3d_TypeOfVisualization aVisType = V3d_ZBUFFER;
3953 Quantity_Color aLabelsColor = Quantity_NOC_WHITE;
3954 Quantity_Color anArrowColorX = Quantity_NOC_RED;
3955 Quantity_Color anArrowColorY = Quantity_NOC_GREEN;
3956 Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1;
3957 Standard_Real aScale = 0.1;
3958 Standard_Real aSizeRatio = 0.8;
3959 Standard_Real anArrowDiam = 0.05;
3960 Standard_Integer aNbFacets = 12;
3961 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3963 Standard_CString anArg = theArgVec[anArgIter];
3964 TCollection_AsciiString aFlag (anArg);
3966 if (anUpdateTool.parseRedrawMode (aFlag))
3970 else if (aFlag == "-on")
3974 else if (aFlag == "-off")
3976 aView->TriedronErase();
3979 else if (aFlag == "-pos"
3980 || aFlag == "-position"
3981 || aFlag == "-corner")
3983 if (++anArgIter >= theArgNb)
3985 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
3989 TCollection_AsciiString aPosName (theArgVec[anArgIter]);
3990 aPosName.LowerCase();
3991 if (aPosName == "center")
3993 aPosition = Aspect_TOTP_CENTER;
3995 else if (aPosName == "left_lower"
3996 || aPosName == "lower_left"
3997 || aPosName == "leftlower"
3998 || aPosName == "lowerleft")
4000 aPosition = Aspect_TOTP_LEFT_LOWER;
4002 else if (aPosName == "left_upper"
4003 || aPosName == "upper_left"
4004 || aPosName == "leftupper"
4005 || aPosName == "upperleft")
4007 aPosition = Aspect_TOTP_LEFT_UPPER;
4009 else if (aPosName == "right_lower"
4010 || aPosName == "lower_right"
4011 || aPosName == "rightlower"
4012 || aPosName == "lowerright")
4014 aPosition = Aspect_TOTP_RIGHT_LOWER;
4016 else if (aPosName == "right_upper"
4017 || aPosName == "upper_right"
4018 || aPosName == "rightupper"
4019 || aPosName == "upperright")
4021 aPosition = Aspect_TOTP_RIGHT_UPPER;
4025 Message::SendFail() << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'";
4029 else if (aFlag == "-type")
4031 if (++anArgIter >= theArgNb)
4033 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4037 TCollection_AsciiString aTypeName (theArgVec[anArgIter]);
4038 aTypeName.LowerCase();
4039 if (aTypeName == "wireframe"
4040 || aTypeName == "wire")
4042 aVisType = V3d_WIREFRAME;
4044 else if (aTypeName == "zbuffer"
4045 || aTypeName == "shaded")
4047 aVisType = V3d_ZBUFFER;
4051 Message::SendFail() << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'";
4054 else if (aFlag == "-scale")
4056 if (++anArgIter >= theArgNb)
4058 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4062 aScale = Draw::Atof (theArgVec[anArgIter]);
4064 else if (aFlag == "-size"
4065 || aFlag == "-sizeratio")
4067 if (++anArgIter >= theArgNb)
4069 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4073 aSizeRatio = Draw::Atof (theArgVec[anArgIter]);
4075 else if (aFlag == "-arrowdiam"
4076 || aFlag == "-arrowdiameter")
4078 if (++anArgIter >= theArgNb)
4080 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4084 anArrowDiam = Draw::Atof (theArgVec[anArgIter]);
4086 else if (aFlag == "-nbfacets")
4088 if (++anArgIter >= theArgNb)
4090 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4094 aNbFacets = Draw::Atoi (theArgVec[anArgIter]);
4096 else if (aFlag == "-colorlabel"
4097 || aFlag == "-colorlabels")
4099 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4100 theArgVec + anArgIter + 1,
4104 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4107 anArgIter += aNbParsed;
4109 else if (aFlag == "-colorarrowx")
4111 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4112 theArgVec + anArgIter + 1,
4116 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4119 anArgIter += aNbParsed;
4121 else if (aFlag == "-colorarrowy")
4123 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4124 theArgVec + anArgIter + 1,
4128 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4131 anArgIter += aNbParsed;
4133 else if (aFlag == "-colorarrowz")
4135 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4136 theArgVec + anArgIter + 1,
4140 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4143 anArgIter += aNbParsed;
4147 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4152 aView->ZBufferTriedronSetup (anArrowColorX.Name(), anArrowColorY.Name(), anArrowColorZ.Name(),
4153 aSizeRatio, anArrowDiam, aNbFacets);
4154 aView->TriedronDisplay (aPosition, aLabelsColor.Name(), aScale, aVisType);
4159 //==============================================================================
4160 //function : VRotate
4161 //purpose : Camera Rotating
4162 //==============================================================================
4164 static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
4166 Handle(V3d_View) aView = ViewerTest::CurrentView();
4169 Message::SendFail ("Error: no active viewer");
4173 Standard_Boolean hasFlags = Standard_False;
4174 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
4176 Standard_CString anArg (theArgVec[anArgIter]);
4177 TCollection_AsciiString aFlag (anArg);
4179 if (aFlag == "-mousestart"
4180 || aFlag == "-mousefrom")
4182 hasFlags = Standard_True;
4183 if (anArgIter + 2 >= theArgNb)
4185 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4189 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
4190 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
4191 aView->StartRotation (anX, anY);
4193 else if (aFlag == "-mousemove")
4195 hasFlags = Standard_True;
4196 if (anArgIter + 2 >= theArgNb)
4198 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4202 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
4203 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
4204 aView->Rotation (anX, anY);
4206 else if (theArgNb != 4
4209 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4218 else if (theArgNb == 4)
4220 Standard_Real anAX = Draw::Atof (theArgVec[1]);
4221 Standard_Real anAY = Draw::Atof (theArgVec[2]);
4222 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
4223 aView->Rotate (anAX, anAY, anAZ);
4226 else if (theArgNb == 7)
4228 Standard_Real anAX = Draw::Atof (theArgVec[1]);
4229 Standard_Real anAY = Draw::Atof (theArgVec[2]);
4230 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
4232 Standard_Real anX = Draw::Atof (theArgVec[4]);
4233 Standard_Real anY = Draw::Atof (theArgVec[5]);
4234 Standard_Real anZ = Draw::Atof (theArgVec[6]);
4236 aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ);
4240 Message::SendFail ("Error: Invalid number of arguments");
4244 //==============================================================================
4246 //purpose : View zoom in / out (relative to current zoom)
4247 //==============================================================================
4249 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
4250 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
4251 if ( V3dView.IsNull() ) {
4256 Standard_Real coef = Draw::Atof(argv[1]);
4257 if ( coef <= 0.0 ) {
4258 di << argv[1] << "Invalid value\n";
4261 V3dView->SetZoom( Draw::Atof(argv[1]) );
4264 di << argv[0] << " Invalid number of arguments\n";
4269 //==============================================================================
4271 //purpose : View panning (in pixels)
4272 //==============================================================================
4274 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
4275 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
4276 if ( V3dView.IsNull() ) return 1;
4279 V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) );
4282 di << argv[0] << " Invalid number of arguments\n";
4287 //==============================================================================
4289 //purpose : Place the point (in pixels) at the center of the window
4290 //==============================================================================
4291 static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs)
4293 Handle(V3d_View) aView = ViewerTest::CurrentView();
4296 Message::SendFail ("Error: no active viewer");
4302 Message::SendFail ("Syntax error: wrong number of arguments");
4306 aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale());
4311 static int VColorScale (Draw_Interpretor& theDI,
4312 Standard_Integer theArgNb,
4313 const char** theArgVec)
4315 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4316 Handle(V3d_View) aView = ViewerTest::CurrentView();
4317 if (aContext.IsNull())
4319 Message::SendFail ("Error: no active viewer");
4324 Message::SendFail() << "Error: wrong syntax at command '" << theArgVec[0] << "'";
4328 Handle(AIS_ColorScale) aColorScale;
4329 if (GetMapOfAIS().IsBound2 (theArgVec[1]))
4331 // find existing object
4332 aColorScale = Handle(AIS_ColorScale)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
4333 if (aColorScale.IsNull())
4335 Message::SendFail() << "Error: object '" << theArgVec[1] << "'is already defined and is not a color scale";
4342 if (aColorScale.IsNull())
4344 Message::SendFail() << "Syntax error: colorscale with a given name does not exist";
4348 theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n"
4349 << "Min range: " << aColorScale->GetMin() << "\n"
4350 << "Max range: " << aColorScale->GetMax() << "\n"
4351 << "Number of intervals: " << aColorScale->GetNumberOfIntervals() << "\n"
4352 << "Text height: " << aColorScale->GetTextHeight() << "\n"
4353 << "Color scale position: " << aColorScale->GetXPosition() << " " << aColorScale->GetYPosition() << "\n"
4354 << "Color scale title: " << aColorScale->GetTitle() << "\n"
4355 << "Label position: ";
4356 switch (aColorScale->GetLabelPosition())
4358 case Aspect_TOCSP_NONE:
4361 case Aspect_TOCSP_LEFT:
4364 case Aspect_TOCSP_RIGHT:
4367 case Aspect_TOCSP_CENTER:
4368 theDI << "Center\n";
4374 if (aColorScale.IsNull())
4376 aColorScale = new AIS_ColorScale();
4377 aColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
4378 aContext->SetTransformPersistence (aColorScale, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
4381 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
4382 for (Standard_Integer anArgIter = 2; anArgIter < theArgNb; ++anArgIter)
4384 Standard_CString anArg = theArgVec[anArgIter];
4385 TCollection_AsciiString aFlag (anArg);
4387 if (anUpdateTool.parseRedrawMode (aFlag))
4391 else if (aFlag == "-range")
4393 if (anArgIter + 3 >= theArgNb)
4395 Message::SendFail() << "Error: wrong syntax at argument '" << anArg << "'";
4399 const TCollection_AsciiString aRangeMin (theArgVec[++anArgIter]);
4400 const TCollection_AsciiString aRangeMax (theArgVec[++anArgIter]);
4401 const TCollection_AsciiString aNbIntervals (theArgVec[++anArgIter]);
4402 if (!aRangeMin.IsRealValue()
4403 || !aRangeMax.IsRealValue())
4405 Message::SendFail ("Syntax error: the range values should be real");
4408 else if (!aNbIntervals.IsIntegerValue())
4410 Message::SendFail ("Syntax error: the number of intervals should be integer");
4414 aColorScale->SetRange (aRangeMin.RealValue(), aRangeMax.RealValue());
4415 aColorScale->SetNumberOfIntervals (aNbIntervals.IntegerValue());
4417 else if (aFlag == "-font")
4419 if (anArgIter + 1 >= theArgNb)
4421 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4424 TCollection_AsciiString aFontArg(theArgVec[anArgIter + 1]);
4425 if (!aFontArg.IsIntegerValue())
4427 Message::SendFail ("Syntax error: HeightFont value should be integer");
4431 aColorScale->SetTextHeight (aFontArg.IntegerValue());
4434 else if (aFlag == "-textpos")
4436 if (anArgIter + 1 >= theArgNb)
4438 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4442 TCollection_AsciiString aTextPosArg(theArgVec[++anArgIter]);
4443 aTextPosArg.LowerCase();
4444 Aspect_TypeOfColorScalePosition aLabPosition = Aspect_TOCSP_NONE;
4445 if (aTextPosArg == "none")
4447 aLabPosition = Aspect_TOCSP_NONE;
4449 else if (aTextPosArg == "left")
4451 aLabPosition = Aspect_TOCSP_LEFT;
4453 else if (aTextPosArg == "right")
4455 aLabPosition = Aspect_TOCSP_RIGHT;
4457 else if (aTextPosArg == "center")
4459 aLabPosition = Aspect_TOCSP_CENTER;
4463 Message::SendFail() << "Syntax error: unknown position '" << aTextPosArg << "'";
4466 aColorScale->SetLabelPosition (aLabPosition);
4468 else if (aFlag == "-logarithmic"
4471 if (anArgIter + 1 >= theArgNb)
4473 Message::SendFail() << "Synta error at argument '" << anArg << "'";
4477 Standard_Boolean IsLog;
4478 if (!ViewerTest::ParseOnOff(theArgVec[++anArgIter], IsLog))
4480 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4483 aColorScale->SetLogarithmic (IsLog);
4485 else if (aFlag == "-huerange"
4488 if (anArgIter + 2 >= theArgNb)
4490 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4494 const Standard_Real aHueMin = Draw::Atof (theArgVec[++anArgIter]);
4495 const Standard_Real aHueMax = Draw::Atof (theArgVec[++anArgIter]);
4496 aColorScale->SetHueRange (aHueMin, aHueMax);
4498 else if (aFlag == "-colorrange")
4500 Quantity_Color aColorMin, aColorMax;
4501 Standard_Integer aNbParsed1 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4502 theArgVec + (anArgIter + 1),
4504 anArgIter += aNbParsed1;
4505 Standard_Integer aNbParsed2 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4506 theArgVec + (anArgIter + 1),
4508 anArgIter += aNbParsed2;
4512 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4516 aColorScale->SetColorRange (aColorMin, aColorMax);
4518 else if (aFlag == "-reversed"
4519 || aFlag == "-inverted"
4520 || aFlag == "-topdown"
4521 || aFlag == "-bottomup")
4523 Standard_Boolean toEnable = Standard_True;
4524 if (anArgIter + 1 < theArgNb
4525 && ViewerTest::ParseOnOff(theArgVec[anArgIter + 1], toEnable))
4529 aColorScale->SetReversed ((aFlag == "-topdown") ? !toEnable : toEnable);
4531 else if (aFlag == "-smooth"
4532 || aFlag == "-smoothtransition")
4534 Standard_Boolean toEnable = Standard_True;
4535 if (anArgIter + 1 < theArgNb
4536 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
4540 aColorScale->SetSmoothTransition (toEnable);
4542 else if (aFlag == "-xy")
4544 if (anArgIter + 2 >= theArgNb)
4546 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4550 const TCollection_AsciiString anX (theArgVec[++anArgIter]);
4551 const TCollection_AsciiString anY (theArgVec[++anArgIter]);
4552 if (!anX.IsIntegerValue()
4553 || !anY.IsIntegerValue())
4555 Message::SendFail ("Syntax error: coordinates should be integer values");
4559 aColorScale->SetPosition (anX.IntegerValue(), anY.IntegerValue());
4561 else if (aFlag == "-width"
4563 || aFlag == "-breadth")
4565 if (anArgIter + 1 >= theArgNb)
4567 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4571 const TCollection_AsciiString aBreadth (theArgVec[++anArgIter]);
4572 if (!aBreadth.IsIntegerValue())
4574 Message::SendFail ("Syntax error: a width should be an integer value");
4577 aColorScale->SetBreadth (aBreadth.IntegerValue());
4579 else if (aFlag == "-height"
4582 if (anArgIter + 1 >= theArgNb)
4584 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4588 const TCollection_AsciiString aHeight (theArgVec[++anArgIter]);
4589 if (!aHeight.IsIntegerValue())
4591 Message::SendFail ("Syntax error: a width should be an integer value");
4594 aColorScale->SetHeight (aHeight.IntegerValue());
4596 else if (aFlag == "-color")
4598 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
4600 Message::SendFail ("Syntax error: wrong color type. Call -colors before to set user-specified colors");
4603 else if (anArgIter + 2 >= theArgNb)
4605 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4609 const TCollection_AsciiString anInd (theArgVec[++anArgIter]);
4610 if (!anInd.IsIntegerValue())
4612 Message::SendFail ("Syntax error: Index value should be integer");
4615 const Standard_Integer anIndex = anInd.IntegerValue();
4616 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals())
4618 Message::SendFail() << "Syntax error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals();
4622 Quantity_Color aColor;
4623 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4624 theArgVec + (anArgIter + 1),
4628 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4631 aColorScale->SetIntervalColor (aColor, anIndex);
4632 aColorScale->SetColorType (Aspect_TOCSD_USER);
4633 anArgIter += aNbParsed;
4635 else if (aFlag == "-label")
4637 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
4639 Message::SendFail ("Syntax error: wrong label type. Call -labels before to set user-specified labels");
4642 else if (anArgIter + 2 >= theArgNb)
4644 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4648 Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]);
4649 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals() + 1)
4651 Message::SendFail() << "Syntax error: Index value should be within range 1.." << (aColorScale->GetNumberOfIntervals() + 1);
4655 TCollection_ExtendedString aText (theArgVec[anArgIter + 2]);
4656 aColorScale->SetLabel (aText, anIndex);
4657 aColorScale->SetLabelType (Aspect_TOCSD_USER);
4660 else if (aFlag == "-labelat"
4661 || aFlag == "-labat"
4662 || aFlag == "-labelatborder"
4663 || aFlag == "-labatborder"
4664 || aFlag == "-labelatcenter"
4665 || aFlag == "-labatcenter")
4667 Standard_Boolean toEnable = Standard_True;
4668 if (aFlag == "-labelat"
4669 || aFlag == "-labat")
4671 Standard_Integer aLabAtBorder = -1;
4672 if (++anArgIter >= theArgNb)
4674 TCollection_AsciiString anAtBorder (theArgVec[anArgIter]);
4675 anAtBorder.LowerCase();
4676 if (anAtBorder == "border")
4680 else if (anAtBorder == "center")
4685 if (aLabAtBorder == -1)
4687 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4690 toEnable = (aLabAtBorder == 1);
4692 else if (anArgIter + 1 < theArgNb
4693 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
4697 aColorScale->SetLabelAtBorder (aFlag == "-labelatcenter"
4698 || aFlag == "-labatcenter"
4702 else if (aFlag == "-colors")
4704 Aspect_SequenceOfColor aSeq;
4707 Quantity_Color aColor;
4708 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4709 theArgVec + (anArgIter + 1),
4715 anArgIter += aNbParsed;
4716 aSeq.Append (aColor);
4718 if (aSeq.Length() != aColorScale->GetNumberOfIntervals())
4720 Message::SendFail() << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the "
4721 << aColorScale->GetNumberOfIntervals() << " intervals";
4725 aColorScale->SetColors (aSeq);
4726 aColorScale->SetColorType (Aspect_TOCSD_USER);
4728 else if (aFlag == "-uniform")
4730 const Standard_Real aLightness = Draw::Atof (theArgVec[++anArgIter]);
4731 const Standard_Real aHueStart = Draw::Atof (theArgVec[++anArgIter]);
4732 const Standard_Real aHueEnd = Draw::Atof (theArgVec[++anArgIter]);
4733 aColorScale->SetUniformColors (aLightness, aHueStart, aHueEnd);
4734 aColorScale->SetColorType (Aspect_TOCSD_USER);
4736 else if (aFlag == "-labels"
4737 || aFlag == "-freelabels")
4739 if (anArgIter + 1 >= theArgNb)
4741 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4745 Standard_Integer aNbLabels = aColorScale->IsLabelAtBorder()
4746 ? aColorScale->GetNumberOfIntervals() + 1
4747 : aColorScale->GetNumberOfIntervals();
4748 if (aFlag == "-freelabels")
4751 aNbLabels = Draw::Atoi (theArgVec[anArgIter]);
4753 if (anArgIter + aNbLabels >= theArgNb)
4755 Message::SendFail() << "Syntax error: not enough arguments. " << aNbLabels << " text labels are expected";
4759 TColStd_SequenceOfExtendedString aSeq;
4760 for (Standard_Integer aLabelIter = 0; aLabelIter < aNbLabels; ++aLabelIter)
4762 aSeq.Append (TCollection_ExtendedString (theArgVec[++anArgIter]));
4764 aColorScale->SetLabels (aSeq);
4765 aColorScale->SetLabelType (Aspect_TOCSD_USER);
4767 else if (aFlag == "-title")
4769 if (anArgIter + 1 >= theArgNb)
4771 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4775 Standard_Boolean isTwoArgs = Standard_False;
4776 if (anArgIter + 2 < theArgNb)
4778 TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]);
4779 aSecondArg.LowerCase();
4780 Standard_DISABLE_DEPRECATION_WARNINGS
4781 if (aSecondArg == "none")
4783 aColorScale->SetTitlePosition (Aspect_TOCSP_NONE);
4784 isTwoArgs = Standard_True;
4786 else if (aSecondArg == "left")
4788 aColorScale->SetTitlePosition (Aspect_TOCSP_LEFT);
4789 isTwoArgs = Standard_True;
4791 else if (aSecondArg == "right")
4793 aColorScale->SetTitlePosition (Aspect_TOCSP_RIGHT);
4794 isTwoArgs = Standard_True;
4796 else if (aSecondArg == "center")
4798 aColorScale->SetTitlePosition (Aspect_TOCSP_CENTER);
4799 isTwoArgs = Standard_True;
4801 Standard_ENABLE_DEPRECATION_WARNINGS
4804 aColorScale->SetTitle (theArgVec[anArgIter + 1]);
4811 else if (aFlag == "-demoversion"
4812 || aFlag == "-demo")
4814 aColorScale->SetPosition (0, 0);
4815 aColorScale->SetTextHeight (16);
4816 aColorScale->SetRange (0.0, 100.0);
4817 aColorScale->SetNumberOfIntervals (10);
4818 aColorScale->SetBreadth (0);
4819 aColorScale->SetHeight (0);
4820 aColorScale->SetLabelPosition (Aspect_TOCSP_RIGHT);
4821 aColorScale->SetColorType (Aspect_TOCSD_AUTO);
4822 aColorScale->SetLabelType (Aspect_TOCSD_AUTO);
4824 else if (aFlag == "-findcolor")
4826 if (anArgIter + 1 >= theArgNb)
4828 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4832 TCollection_AsciiString anArg1 (theArgVec[++anArgIter]);
4834 if (!anArg1.IsRealValue())
4836 Message::SendFail ("Syntax error: the value should be real");
4840 Quantity_Color aColor;
4841 aColorScale->FindColor (anArg1.RealValue(), aColor);
4842 theDI << Quantity_Color::StringName (aColor.Name());
4847 Message::SendFail() << "Syntax error at " << anArg << " - unknown argument";
4852 Standard_Integer aWinWidth = 0, aWinHeight = 0;
4853 aView->Window()->Size (aWinWidth, aWinHeight);
4854 if (aColorScale->GetBreadth() == 0)
4856 aColorScale->SetBreadth (aWinWidth);
4858 if (aColorScale->GetHeight() == 0)
4860 aColorScale->SetHeight (aWinHeight);
4862 aColorScale->SetToUpdate();
4863 ViewerTest::Display (theArgVec[1], aColorScale, Standard_False, Standard_True);
4867 //==============================================================================
4868 //function : VGraduatedTrihedron
4869 //purpose : Displays or hides a graduated trihedron
4870 //==============================================================================
4871 static Standard_Boolean GetColor (const TCollection_AsciiString& theValue,
4872 Quantity_Color& theColor)
4874 Quantity_NameOfColor aColorName;
4875 TCollection_AsciiString aVal = theValue;
4877 if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName))
4879 return Standard_False;
4881 theColor = Quantity_Color (aColorName);
4882 return Standard_True;
4885 static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs)
4889 Message::SendFail() << "Syntax error: wrong number of parameters. Type 'help"
4890 << theArgs[0] <<"' for more information";
4894 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
4895 TCollection_AsciiString aParseKey;
4896 for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt)
4898 TCollection_AsciiString anArg (theArgs [anArgIt]);
4900 if (anArg.Value (1) == '-' && !anArg.IsRealValue())
4903 aParseKey.Remove (1);
4904 aParseKey.LowerCase();
4905 aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
4909 if (aParseKey.IsEmpty())
4914 aMapOfArgs(aParseKey)->Append (anArg);
4918 for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
4919 aMapIt.More(); aMapIt.Next())
4921 const TCollection_AsciiString& aKey = aMapIt.Key();
4922 const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
4924 // Bool key, without arguments
4925 if ((aKey.IsEqual ("on") || aKey.IsEqual ("off"))
4926 && anArgs->IsEmpty())
4932 if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname"))
4933 && anArgs->Length() == 1)
4939 if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname")
4940 || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks")
4941 || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues")
4942 || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes"))
4943 && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off")))
4948 // One string argument
4949 if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor")
4950 || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor"))
4951 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4956 // One integer argument
4957 if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks")
4958 || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength")
4959 || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset")
4960 || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset"))
4961 && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue())
4966 // One real argument
4967 if ( aKey.IsEqual ("arrowlength")
4968 && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue()))
4973 // Two string arguments
4974 if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont"))
4975 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4980 TCollection_AsciiString aLowerKey;
4983 aLowerKey.LowerCase();
4984 Message::SendFail() << "Syntax error: " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n"
4985 << "Type help for more information";
4989 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
4990 if (anAISContext.IsNull())
4992 Message::SendFail ("Error: no active viewer");
4996 Standard_Boolean toDisplay = Standard_True;
4997 Quantity_Color aColor;
4998 Graphic3d_GraduatedTrihedron aTrihedronData;
4999 // Process parameters
5000 Handle(TColStd_HSequenceOfAsciiString) aValues;
5001 if (aMapOfArgs.Find ("off", aValues))
5003 toDisplay = Standard_False;
5007 if (aMapOfArgs.Find ("xname", aValues))
5009 aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1));
5011 if (aMapOfArgs.Find ("yname", aValues))
5013 aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1));
5015 if (aMapOfArgs.Find ("zname", aValues))
5017 aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1));
5019 if (aMapOfArgs.Find ("xdrawname", aValues))
5021 aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
5023 if (aMapOfArgs.Find ("ydrawname", aValues))
5025 aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
5027 if (aMapOfArgs.Find ("zdrawname", aValues))
5029 aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
5031 if (aMapOfArgs.Find ("xnameoffset", aValues))
5033 aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
5035 if (aMapOfArgs.Find ("ynameoffset", aValues))
5037 aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
5039 if (aMapOfArgs.Find ("znameoffset", aValues))
5041 aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
5045 if (aMapOfArgs.Find ("xnamecolor", aValues))
5047 if (!GetColor (aValues->Value(1), aColor))
5049 Message::SendFail ("Syntax error: -xnamecolor wrong color name");
5052 aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor);
5054 if (aMapOfArgs.Find ("ynamecolor", aValues))
5056 if (!GetColor (aValues->Value(1), aColor))
5058 Message::SendFail ("Syntax error: -ynamecolor wrong color name");
5061 aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor);
5063 if (aMapOfArgs.Find ("znamecolor", aValues))
5065 if (!GetColor (aValues->Value(1), aColor))
5067 Message::SendFail ("Syntax error: -znamecolor wrong color name");
5070 aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor);
5072 if (aMapOfArgs.Find ("xcolor", aValues))
5074 if (!GetColor (aValues->Value(1), aColor))
5076 Message::SendFail ("Syntax error: -xcolor wrong color name");
5079 aTrihedronData.ChangeXAxisAspect().SetColor (aColor);
5081 if (aMapOfArgs.Find ("ycolor", aValues))
5083 if (!GetColor (aValues->Value(1), aColor))
5085 Message::SendFail ("Syntax error: -ycolor wrong color name");
5088 aTrihedronData.ChangeYAxisAspect().SetColor (aColor);
5090 if (aMapOfArgs.Find ("zcolor", aValues))
5092 if (!GetColor (aValues->Value(1), aColor))
5094 Message::SendFail ("Syntax error: -zcolor wrong color name");
5097 aTrihedronData.ChangeZAxisAspect().SetColor (aColor);
5101 if (aMapOfArgs.Find ("xticks", aValues))
5103 aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
5105 if (aMapOfArgs.Find ("yticks", aValues))
5107 aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
5109 if (aMapOfArgs.Find ("zticks", aValues))
5111 aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
5113 if (aMapOfArgs.Find ("xticklength", aValues))
5115 aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
5117 if (aMapOfArgs.Find ("yticklength", aValues))
5119 aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
5121 if (aMapOfArgs.Find ("zticklength", aValues))
5123 aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
5125 if (aMapOfArgs.Find ("xdrawticks", aValues))
5127 aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
5129 if (aMapOfArgs.Find ("ydrawticks", aValues))
5131 aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
5133 if (aMapOfArgs.Find ("zdrawticks", aValues))
5135 aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
5139 if (aMapOfArgs.Find ("xdrawvalues", aValues))
5141 aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
5143 if (aMapOfArgs.Find ("ydrawvalues", aValues))
5145 aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
5147 if (aMapOfArgs.Find ("zdrawvalues", aValues))
5149 aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
5151 if (aMapOfArgs.Find ("xvaluesoffset", aValues))
5153 aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
5155 if (aMapOfArgs.Find ("yvaluesoffset", aValues))
5157 aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
5159 if (aMapOfArgs.Find ("zvaluesoffset", aValues))
5161 aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
5165 if (aMapOfArgs.Find ("arrowlength", aValues))
5167 aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue());
5171 if (aMapOfArgs.Find ("namefont", aValues))
5173 aTrihedronData.SetNamesFont (aValues->Value(1));
5175 if (aMapOfArgs.Find ("valuesfont", aValues))
5177 aTrihedronData.SetValuesFont (aValues->Value(1));
5180 if (aMapOfArgs.Find ("drawgrid", aValues))
5182 aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on"));
5184 if (aMapOfArgs.Find ("drawaxes", aValues))
5186 aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on"));
5189 // The final step: display of erase trihedron
5192 ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData);
5196 ViewerTest::CurrentView()->GraduatedTrihedronErase();
5199 ViewerTest::GetAISContext()->UpdateCurrentViewer();
5200 ViewerTest::CurrentView()->Redraw();
5205 //==============================================================================
5208 //==============================================================================
5209 static int VTile (Draw_Interpretor& theDI,
5210 Standard_Integer theArgNb,
5211 const char** theArgVec)
5213 Handle(V3d_View) aView = ViewerTest::CurrentView();
5216 Message::SendFail ("Error: no active viewer");
5220 Graphic3d_CameraTile aTile = aView->Camera()->Tile();
5223 theDI << "Total size: " << aTile.TotalSize.x() << " " << aTile.TotalSize.y() << "\n"
5224 << "Tile size: " << aTile.TileSize.x() << " " << aTile.TileSize.y() << "\n"
5225 << "Lower left: " << aTile.Offset.x() << " " << aTile.Offset.y() << "\n";
5229 aView->Window()->Size (aTile.TileSize.x(), aTile.TileSize.y());
5230 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5232 TCollection_AsciiString anArg (theArgVec[anArgIter]);
5234 if (anArg == "-lowerleft"
5235 || anArg == "-upperleft")
5237 if (anArgIter + 3 < theArgNb)
5239 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
5242 aTile.IsTopDown = (anArg == "-upperleft") == Standard_True;
5243 aTile.Offset.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
5244 aTile.Offset.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
5246 else if (anArg == "-total"
5247 || anArg == "-totalsize"
5248 || anArg == "-viewsize")
5250 if (anArgIter + 3 < theArgNb)
5252 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
5255 aTile.TotalSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
5256 aTile.TotalSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
5257 if (aTile.TotalSize.x() < 1
5258 || aTile.TotalSize.y() < 1)
5260 Message::SendFail ("Error: total size is incorrect");
5264 else if (anArg == "-tilesize")
5266 if (anArgIter + 3 < theArgNb)
5268 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
5272 aTile.TileSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
5273 aTile.TileSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
5274 if (aTile.TileSize.x() < 1
5275 || aTile.TileSize.y() < 1)
5277 Message::SendFail ("Error: tile size is incorrect");
5281 else if (anArg == "-unset")
5283 aView->Camera()->SetTile (Graphic3d_CameraTile());
5289 if (aTile.TileSize.x() < 1
5290 || aTile.TileSize.y() < 1)
5292 Message::SendFail ("Error: tile size is undefined");
5295 else if (aTile.TotalSize.x() < 1
5296 || aTile.TotalSize.y() < 1)
5298 Message::SendFail ("Error: total size is undefined");
5302 aView->Camera()->SetTile (aTile);
5307 //! Format ZLayer ID.
5308 inline const char* formZLayerId (const Standard_Integer theLayerId)
5312 case Graphic3d_ZLayerId_UNKNOWN: return "[INVALID]";
5313 case Graphic3d_ZLayerId_Default: return "[DEFAULT]";
5314 case Graphic3d_ZLayerId_Top: return "[TOP]";
5315 case Graphic3d_ZLayerId_Topmost: return "[TOPMOST]";
5316 case Graphic3d_ZLayerId_TopOSD: return "[OVERLAY]";
5317 case Graphic3d_ZLayerId_BotOSD: return "[UNDERLAY]";
5322 //! Print the ZLayer information.
5323 inline void printZLayerInfo (Draw_Interpretor& theDI,
5324 const Graphic3d_ZLayerSettings& theLayer)
5326 if (!theLayer.Name().IsEmpty())
5328 theDI << " Name: " << theLayer.Name() << "\n";
5330 if (theLayer.IsImmediate())
5332 theDI << " Immediate: TRUE\n";
5334 theDI << " Origin: " << theLayer.Origin().X() << " " << theLayer.Origin().Y() << " " << theLayer.Origin().Z() << "\n";
5335 theDI << " Culling distance: " << theLayer.CullingDistance() << "\n";
5336 theDI << " Culling size: " << theLayer.CullingSize() << "\n";
5337 theDI << " Depth test: " << (theLayer.ToEnableDepthTest() ? "enabled" : "disabled") << "\n";
5338 theDI << " Depth write: " << (theLayer.ToEnableDepthWrite() ? "enabled" : "disabled") << "\n";
5339 theDI << " Depth buffer clearing: " << (theLayer.ToClearDepth() ? "enabled" : "disabled") << "\n";
5340 if (theLayer.PolygonOffset().Mode != Aspect_POM_None)
5342 theDI << " Depth offset: " << theLayer.PolygonOffset().Factor << " " << theLayer.PolygonOffset().Units << "\n";
5346 //==============================================================================
5347 //function : VZLayer
5348 //purpose : Test z layer operations for v3d viewer
5349 //==============================================================================
5350 static int VZLayer (Draw_Interpretor& theDI,
5351 Standard_Integer theArgNb,
5352 const char** theArgVec)
5354 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5355 if (aContextAIS.IsNull())
5357 Message::SendFail ("Error: no active viewer");
5361 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
5364 TColStd_SequenceOfInteger aLayers;
5365 aViewer->GetAllZLayers (aLayers);
5366 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
5368 theDI << "ZLayer " << aLayeriter.Value() << " " << formZLayerId (aLayeriter.Value()) << "\n";
5369 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
5370 printZLayerInfo (theDI, aSettings);
5375 Standard_Integer anArgIter = 1;
5376 Standard_Integer aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5377 ViewerTest_AutoUpdater anUpdateTool (aContextAIS, ViewerTest::CurrentView());
5378 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
5384 TCollection_AsciiString aFirstArg (theArgVec[anArgIter]);
5385 if (aFirstArg.IsIntegerValue())
5388 aLayerId = aFirstArg.IntegerValue();
5392 if (ViewerTest::ParseZLayerName (aFirstArg.ToCString(), aLayerId))
5399 Graphic3d_ZLayerId anOtherLayerId = Graphic3d_ZLayerId_UNKNOWN;
5400 for (; anArgIter < theArgNb; ++anArgIter)
5402 // perform operation
5403 TCollection_AsciiString anArg (theArgVec[anArgIter]);
5405 if (anUpdateTool.parseRedrawMode (anArg))
5409 else if (anArg == "-add"
5412 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5413 if (!aViewer->AddZLayer (aLayerId))
5415 Message::SendFail ("Error: can not add a new z layer");
5421 else if (anArg == "-insertbefore"
5422 && anArgIter + 1 < theArgNb
5423 && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
5426 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5427 if (!aViewer->InsertLayerBefore (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
5429 Message::SendFail ("Error: can not add a new z layer");
5435 else if (anArg == "-insertafter"
5436 && anArgIter + 1 < theArgNb
5437 && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
5440 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5441 if (!aViewer->InsertLayerAfter (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
5443 Message::SendFail ("Error: can not add a new z layer");
5449 else if (anArg == "-del"
5450 || anArg == "-delete"
5453 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5455 if (++anArgIter >= theArgNb)
5457 Message::SendFail ("Syntax error: id of z layer to remove is missing");
5461 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
5464 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN
5465 || aLayerId == Graphic3d_ZLayerId_Default
5466 || aLayerId == Graphic3d_ZLayerId_Top
5467 || aLayerId == Graphic3d_ZLayerId_Topmost
5468 || aLayerId == Graphic3d_ZLayerId_TopOSD
5469 || aLayerId == Graphic3d_ZLayerId_BotOSD)
5471 Message::SendFail ("Syntax error: standard Z layer can not be removed");
5475 // move all object displayed in removing layer to default layer
5476 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
5477 anObjIter.More(); anObjIter.Next())
5479 const Handle(AIS_InteractiveObject)& aPrs = anObjIter.Key1();
5481 || aPrs->ZLayer() != aLayerId)
5485 aPrs->SetZLayer (Graphic3d_ZLayerId_Default);
5488 if (!aViewer->RemoveZLayer (aLayerId))
5490 Message::SendFail ("Z layer can not be removed");
5494 theDI << aLayerId << " ";
5497 else if (anArg == "-get"
5500 TColStd_SequenceOfInteger aLayers;
5501 aViewer->GetAllZLayers (aLayers);
5502 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
5504 theDI << aLayeriter.Value() << " ";
5509 else if (anArg == "-name")
5511 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5513 Message::SendFail ("Syntax error: id of Z layer is missing");
5517 if (++anArgIter >= theArgNb)
5519 Message::SendFail ("Syntax error: name is missing");
5523 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5524 aSettings.SetName (theArgVec[anArgIter]);
5525 aViewer->SetZLayerSettings (aLayerId, aSettings);
5527 else if (anArg == "-origin")
5529 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5531 Message::SendFail ("Syntax error: id of Z layer is missing");
5535 if (anArgIter + 2 >= theArgNb)
5537 Message::SendFail ("Syntax error: origin coordinates are missing");
5541 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5543 anOrigin.SetX (Draw::Atof (theArgVec[anArgIter + 1]));
5544 anOrigin.SetY (Draw::Atof (theArgVec[anArgIter + 2]));
5545 anOrigin.SetZ (0.0);
5546 if (anArgIter + 3 < theArgNb)
5548 anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter + 3]));
5555 aSettings.SetOrigin (anOrigin);
5556 aViewer->SetZLayerSettings (aLayerId, aSettings);
5558 else if (aLayerId != Graphic3d_ZLayerId_UNKNOWN
5559 && anArgIter + 1 < theArgNb
5560 && (anArg == "-cullingdistance"
5561 || anArg == "-cullingdist"
5562 || anArg == "-culldistance"
5563 || anArg == "-culldist"
5564 || anArg == "-distcull"
5565 || anArg == "-distculling"
5566 || anArg == "-distanceculling"))
5568 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5569 const Standard_Real aDist = Draw::Atof (theArgVec[++anArgIter]);
5570 aSettings.SetCullingDistance (aDist);
5571 aViewer->SetZLayerSettings (aLayerId, aSettings);
5573 else if (aLayerId != Graphic3d_ZLayerId_UNKNOWN
5574 && anArgIter + 1 < theArgNb
5575 && (anArg == "-cullingsize"
5576 || anArg == "-cullsize"
5577 || anArg == "-sizecull"
5578 || anArg == "-sizeculling"))
5580 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5581 const Standard_Real aSize = Draw::Atof (theArgVec[++anArgIter]);
5582 aSettings.SetCullingSize (aSize);
5583 aViewer->SetZLayerSettings (aLayerId, aSettings);
5585 else if (anArg == "-settings"
5586 || anArg == "settings")
5588 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5590 if (++anArgIter >= theArgNb)
5592 Message::SendFail ("Syntax error: id of Z layer is missing");
5596 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
5599 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5600 printZLayerInfo (theDI, aSettings);
5602 else if (anArg == "-enable"
5603 || anArg == "enable"
5604 || anArg == "-disable"
5605 || anArg == "disable")
5607 const Standard_Boolean toEnable = anArg == "-enable"
5608 || anArg == "enable";
5609 if (++anArgIter >= theArgNb)
5611 Message::SendFail ("Syntax error: option name is missing");
5615 TCollection_AsciiString aSubOp (theArgVec[anArgIter]);
5617 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5619 if (++anArgIter >= theArgNb)
5621 Message::SendFail ("Syntax error: id of Z layer is missing");
5625 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
5628 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5629 if (aSubOp == "depthtest"
5630 || aSubOp == "test")
5632 aSettings.SetEnableDepthTest (toEnable);
5634 else if (aSubOp == "depthwrite"
5635 || aSubOp == "write")
5637 aSettings.SetEnableDepthWrite (toEnable);
5639 else if (aSubOp == "depthclear"
5640 || aSubOp == "clear")
5642 aSettings.SetClearDepth (toEnable);
5644 else if (aSubOp == "depthoffset"
5645 || aSubOp == "offset")
5647 Graphic3d_PolygonOffset aParams;
5648 aParams.Mode = toEnable ? Aspect_POM_Fill : Aspect_POM_None;
5651 if (anArgIter + 2 >= theArgNb)
5653 Message::SendFail ("Syntax error: factor and units values for depth offset are missing");
5657 aParams.Factor = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
5658 aParams.Units = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
5660 aSettings.SetPolygonOffset (aParams);
5662 else if (aSubOp == "positiveoffset"
5663 || aSubOp == "poffset")
5667 aSettings.SetDepthOffsetPositive();
5671 aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
5674 else if (aSubOp == "negativeoffset"
5675 || aSubOp == "noffset")
5679 aSettings.SetDepthOffsetNegative();
5683 aSettings.SetPolygonOffset(Graphic3d_PolygonOffset());
5686 else if (aSubOp == "textureenv")
5688 aSettings.SetEnvironmentTexture (toEnable);
5690 else if (aSubOp == "raytracing")
5692 aSettings.SetRaytracable (toEnable);
5695 aViewer->SetZLayerSettings (aLayerId, aSettings);
5699 Message::SendFail() << "Syntax error: unknown option " << theArgVec[anArgIter];
5707 // The interactive presentation of 2d layer item
5708 // for "vlayerline" command it provides a presentation of
5709 // line with user-defined linewidth, linetype and transparency.
5710 class V3d_LineItem : public AIS_InteractiveObject
5714 DEFINE_STANDARD_RTTI_INLINE(V3d_LineItem,AIS_InteractiveObject)
5717 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
5718 Standard_Real X2, Standard_Real Y2,
5719 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
5720 Standard_Real theWidth = 0.5,
5721 Standard_Real theTransp = 1.0);
5725 void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
5726 const Handle(Prs3d_Presentation)& thePresentation,
5727 const Standard_Integer theMode) Standard_OVERRIDE;
5729 void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
5730 const Standard_Integer /*aMode*/) Standard_OVERRIDE
5735 Standard_Real myX1, myY1, myX2, myY2;
5736 Aspect_TypeOfLine myType;
5737 Standard_Real myWidth;
5740 // default constructor for line item
5741 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
5742 Standard_Real X2, Standard_Real Y2,
5743 Aspect_TypeOfLine theType,
5744 Standard_Real theWidth,
5745 Standard_Real theTransp) :
5746 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2),
5747 myType(theType), myWidth(theWidth)
5749 SetTransparency (1-theTransp);
5753 void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
5754 const Handle(Prs3d_Presentation)& thePresentation,
5755 const Standard_Integer /*theMode*/)
5757 thePresentation->Clear();
5758 Quantity_Color aColor (Quantity_NOC_RED);
5759 Standard_Integer aWidth, aHeight;
5760 ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
5761 Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
5762 Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
5763 aPrim->AddVertex(myX1, aHeight-myY1, 0.);
5764 aPrim->AddVertex(myX2, aHeight-myY2, 0.);
5765 Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (aColor, (Aspect_TypeOfLine)myType, myWidth);
5766 aGroup->SetPrimitivesAspect (anAspect->Aspect());
5767 aGroup->AddPrimitiveArray (aPrim);
5770 //=============================================================================
5771 //function : VLayerLine
5772 //purpose : Draws line in the v3d view layer with given attributes: linetype,
5773 // : linewidth, transparency coefficient
5774 //============================================================================
5775 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
5777 // get the active view
5778 Handle(V3d_View) aView = ViewerTest::CurrentView();
5781 di << "Call vinit before!\n";
5786 di << "Use: " << argv[0];
5787 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
5788 di << " linetype : { 0 | 1 | 2 | 3 } \n";
5789 di << " 0 - solid \n";
5790 di << " 1 - dashed \n";
5791 di << " 2 - dot \n";
5792 di << " 3 - dashdot\n";
5793 di << " transparency : { 0.0 - 1.0 } \n";
5794 di << " 0.0 - transparent\n";
5795 di << " 1.0 - visible \n";
5799 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5800 // get the input params
5801 Standard_Real X1 = Draw::Atof(argv[1]);
5802 Standard_Real Y1 = Draw::Atof(argv[2]);
5803 Standard_Real X2 = Draw::Atof(argv[3]);
5804 Standard_Real Y2 = Draw::Atof(argv[4]);
5806 Standard_Real aWidth = 0.5;
5807 Standard_Real aTransparency = 1.0;
5811 aWidth = Draw::Atof(argv[5]);
5813 // select appropriate line type
5814 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
5816 && !ViewerTest::ParseLineType (argv[6], aLineType))
5818 Message::SendFail() << "Syntax error: unknown line type '" << argv[6] << "'";
5825 aTransparency = Draw::Atof(argv[7]);
5826 if (aTransparency < 0 || aTransparency > 1.0)
5827 aTransparency = 1.0;
5830 static Handle (V3d_LineItem) aLine;
5831 if (!aLine.IsNull())
5833 aContext->Erase (aLine, Standard_False);
5835 aLine = new V3d_LineItem (X1, Y1, X2, Y2,
5839 aContext->SetTransformPersistence (aLine, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
5840 aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD);
5841 aLine->SetToUpdate();
5842 aContext->Display (aLine, Standard_True);
5848 //==============================================================================
5851 //==============================================================================
5853 static int VGrid (Draw_Interpretor& /*theDI*/,
5854 Standard_Integer theArgNb,
5855 const char** theArgVec)
5857 Handle(V3d_View) aView = ViewerTest::CurrentView();
5858 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
5859 if (aView.IsNull() || aViewer.IsNull())
5861 Message::SendFail ("Error: no active viewer");
5865 Aspect_GridType aType = aViewer->GridType();
5866 Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
5867 Graphic3d_Vec2d aNewOriginXY, aNewStepXY, aNewSizeXY;
5868 Standard_Real aNewRotAngle = 0.0, aNewZOffset = 0.0;
5869 bool hasOrigin = false, hasStep = false, hasRotAngle = false, hasSize = false, hasZOffset = false;
5870 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
5871 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5873 TCollection_AsciiString anArg (theArgVec[anArgIter]);
5875 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
5879 else if (anArgIter + 1 < theArgNb
5880 && anArg == "-type")
5882 TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
5883 anArgNext.LowerCase();
5884 if (anArgNext == "r"
5885 || anArgNext == "rect"
5886 || anArgNext == "rectangular")
5888 aType = Aspect_GT_Rectangular;
5890 else if (anArgNext == "c"
5891 || anArgNext == "circ"
5892 || anArgNext == "circular")
5894 aType = Aspect_GT_Circular;
5898 Message::SendFail() << "Syntax error at '" << anArgNext << "'";
5902 else if (anArgIter + 1 < theArgNb
5903 && anArg == "-mode")
5905 TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
5906 anArgNext.LowerCase();
5907 if (anArgNext == "l"
5908 || anArgNext == "line"
5909 || anArgNext == "lines")
5911 aMode = Aspect_GDM_Lines;
5913 else if (anArgNext == "p"
5914 || anArgNext == "point"
5915 || anArgNext == "points")
5917 aMode = Aspect_GDM_Points;
5921 Message::SendFail() << "Syntax error at '" << anArgNext << "'";
5925 else if (anArgIter + 2 < theArgNb
5926 && (anArg == "-origin"
5927 || anArg == "-orig"))
5930 aNewOriginXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
5931 Draw::Atof (theArgVec[anArgIter + 2]));
5934 else if (anArgIter + 2 < theArgNb
5935 && anArg == "-step")
5938 aNewStepXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
5939 Draw::Atof (theArgVec[anArgIter + 2]));
5940 if (aNewStepXY.x() <= 0.0
5941 || aNewStepXY.y() <= 0.0)
5943 Message::SendFail() << "Syntax error: wrong step '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'";
5948 else if (anArgIter + 1 < theArgNb
5949 && (anArg == "-angle"
5950 || anArg == "-rotangle"
5951 || anArg == "-rotationangle"))
5954 aNewRotAngle = Draw::Atof (theArgVec[++anArgIter]);
5956 else if (anArgIter + 1 < theArgNb
5957 && (anArg == "-zoffset"
5961 aNewZOffset = Draw::Atof (theArgVec[++anArgIter]);
5963 else if (anArgIter + 1 < theArgNb
5964 && anArg == "-radius")
5968 aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter]), 0.0);
5969 if (aNewStepXY.x() <= 0.0)
5971 Message::SendFail() << "Syntax error: wrong size '" << theArgVec[anArgIter] << "'";
5975 else if (anArgIter + 2 < theArgNb
5976 && anArg == "-size")
5979 aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
5980 Draw::Atof (theArgVec[anArgIter + 2]));
5981 if (aNewStepXY.x() <= 0.0
5982 || aNewStepXY.y() <= 0.0)
5984 Message::SendFail() << "Syntax error: wrong size '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'";
5989 else if (anArg == "r"
5991 || anArg == "rectangular")
5993 aType = Aspect_GT_Rectangular;
5995 else if (anArg == "c"
5997 || anArg == "circular")
5999 aType = Aspect_GT_Circular;
6001 else if (anArg == "l"
6003 || anArg == "lines")
6005 aMode = Aspect_GDM_Lines;
6007 else if (anArg == "p"
6009 || anArg == "points")
6011 aMode = Aspect_GDM_Points;
6013 else if (anArgIter + 1 >= theArgNb
6016 aViewer->DeactivateGrid();
6021 Message::SendFail() << "Syntax error at '" << anArg << "'";
6026 if (aType == Aspect_GT_Rectangular)
6028 Graphic3d_Vec2d anOrigXY, aStepXY;
6029 Standard_Real aRotAngle = 0.0;
6030 aViewer->RectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle);
6033 anOrigXY = aNewOriginXY;
6037 aStepXY = aNewStepXY;
6041 aRotAngle = aNewRotAngle;
6043 aViewer->SetRectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle);
6044 if (hasSize || hasZOffset)
6046 Graphic3d_Vec3d aSize;
6047 aViewer->RectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z());
6050 aSize.x() = aNewSizeXY.x();
6051 aSize.y() = aNewSizeXY.y();
6055 aSize.z() = aNewZOffset;
6057 aViewer->SetRectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z());
6060 else if (aType == Aspect_GT_Circular)
6062 Graphic3d_Vec2d anOrigXY;
6063 Standard_Real aRadiusStep;
6064 Standard_Integer aDivisionNumber;
6065 Standard_Real aRotAngle = 0.0;
6066 aViewer->CircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle);
6069 anOrigXY = aNewOriginXY;
6073 aRadiusStep = aNewStepXY[0];
6074 aDivisionNumber = (int )aNewStepXY[1];
6075 if (aDivisionNumber < 1)
6077 Message::SendFail() << "Syntax error: invalid division number '" << aNewStepXY[1] << "'";
6083 aRotAngle = aNewRotAngle;
6086 aViewer->SetCircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle);
6087 if (hasSize || hasZOffset)
6089 Standard_Real aRadius = 0.0, aZOffset = 0.0;
6090 aViewer->CircularGridGraphicValues (aRadius, aZOffset);
6093 aRadius = aNewSizeXY.x();
6094 if (aNewSizeXY.y() != 0.0)
6096 Message::SendFail ("Syntax error: circular size should be specified as radius");
6102 aZOffset = aNewZOffset;
6104 aViewer->SetCircularGridGraphicValues (aRadius, aZOffset);
6107 aViewer->ActivateGrid (aType, aMode);
6111 //==============================================================================
6112 //function : VPriviledgedPlane
6114 //==============================================================================
6116 static int VPriviledgedPlane (Draw_Interpretor& theDI,
6117 Standard_Integer theArgNb,
6118 const char** theArgVec)
6120 if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10)
6122 Message::SendFail ("Error: wrong number of arguments! See usage:");
6123 theDI.PrintHelp (theArgVec[0]);
6127 // get the active viewer
6128 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
6129 if (aViewer.IsNull())
6131 Message::SendFail ("Error: no active viewer");
6137 gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane();
6138 const gp_Pnt& anOrig = aPriviledgedPlane.Location();
6139 const gp_Dir& aNorm = aPriviledgedPlane.Direction();
6140 const gp_Dir& aXDir = aPriviledgedPlane.XDirection();
6141 theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " "
6142 << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " "
6143 << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n";
6147 Standard_Integer anArgIdx = 1;
6148 Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]);
6149 Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]);
6150 Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]);
6151 Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]);
6152 Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]);
6153 Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]);
6155 gp_Ax3 aPriviledgedPlane;
6156 gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ);
6157 gp_Dir aNorm (aNormX, aNormY, aNormZ);
6160 Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]);
6161 Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]);
6162 Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]);
6163 gp_Dir aXDir (aXDirX, aXDirY, aXDirZ);
6164 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir);
6168 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm);
6171 aViewer->SetPrivilegedPlane (aPriviledgedPlane);
6176 //==============================================================================
6177 //function : VConvert
6179 //==============================================================================
6181 static int VConvert (Draw_Interpretor& theDI,
6182 Standard_Integer theArgNb,
6183 const char** theArgVec)
6185 // get the active view
6186 Handle(V3d_View) aView = ViewerTest::CurrentView();
6189 Message::SendFail ("Error: no active viewer");
6193 enum { Model, Ray, View, Window, Grid } aMode = Model;
6195 // access coordinate arguments
6196 TColStd_SequenceOfReal aCoord;
6197 Standard_Integer anArgIdx = 1;
6198 for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx)
6200 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
6201 if (!anArg.IsRealValue())
6205 aCoord.Append (anArg.RealValue());
6208 // non-numeric argument too early
6209 if (aCoord.IsEmpty())
6211 Message::SendFail ("Error: wrong number of arguments! See usage:");
6212 theDI.PrintHelp (theArgVec[0]);
6216 // collect all other arguments and options
6217 for (; anArgIdx < theArgNb; ++anArgIdx)
6219 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
6221 if (anArg == "window") aMode = Window;
6222 else if (anArg == "view") aMode = View;
6223 else if (anArg == "grid") aMode = Grid;
6224 else if (anArg == "ray") aMode = Ray;
6227 Message::SendFail() << "Error: wrong argument " << anArg << "! See usage:";
6228 theDI.PrintHelp (theArgVec[0]);
6233 // complete input checks
6234 if ((aCoord.Length() == 1 && theArgNb > 3) ||
6235 (aCoord.Length() == 2 && theArgNb > 4) ||
6236 (aCoord.Length() == 3 && theArgNb > 5))
6238 Message::SendFail ("Error: wrong number of arguments! See usage:");
6239 theDI.PrintHelp (theArgVec[0]);
6243 Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
6244 Standard_Integer aXYp[2] = {0, 0};
6246 // convert one-dimensional coordinate
6247 if (aCoord.Length() == 1)
6251 case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer)aCoord (1)); return 0;
6252 case Window : theDI << "Window Vp: " << aView->Convert (aCoord (1)); return 0;
6254 Message::SendFail ("Error: wrong arguments! See usage:");
6255 theDI.PrintHelp (theArgVec[0]);
6260 // convert 2D coordinates from projection or view reference space
6261 if (aCoord.Length() == 2)
6266 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
6267 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
6271 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]);
6272 theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n";
6276 aView->Convert (aCoord (1), aCoord (2), aXYp[0], aXYp[1]);
6277 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
6281 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
6282 aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]);
6283 theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
6287 aView->ConvertWithProj ((Standard_Integer) aCoord (1),
6288 (Standard_Integer) aCoord (2),
6289 aXYZ[0], aXYZ[1], aXYZ[2],
6290 aXYZ[3], aXYZ[4], aXYZ[5]);
6291 theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
6295 Message::SendFail ("Error: wrong arguments! See usage:");
6296 theDI.PrintHelp (theArgVec[0]);
6301 // convert 3D coordinates from view reference space
6302 else if (aCoord.Length() == 3)
6307 aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]);
6308 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
6312 aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]);
6313 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
6317 Message::SendFail ("Error: wrong arguments! See usage:");
6318 theDI.PrintHelp (theArgVec[0]);
6326 //==============================================================================
6329 //==============================================================================
6331 static int VFps (Draw_Interpretor& theDI,
6332 Standard_Integer theArgNb,
6333 const char** theArgVec)
6335 // get the active view
6336 Handle(V3d_View) aView = ViewerTest::CurrentView();
6339 Message::SendFail ("Error: no active viewer");
6343 Standard_Integer aFramesNb = -1;
6344 Standard_Real aDuration = -1.0;
6345 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6347 TCollection_AsciiString anArg (theArgVec[anArgIter]);
6350 && anArgIter + 1 < theArgNb
6351 && (anArg == "-duration"
6353 || anArg == "-time"))
6355 aDuration = Draw::Atof (theArgVec[++anArgIter]);
6357 else if (aFramesNb < 0
6358 && anArg.IsIntegerValue())
6360 aFramesNb = anArg.IntegerValue();
6363 Message::SendFail() << "Syntax error at '" << anArg << "'";
6369 Message::SendFail() << "Syntax error at '" << anArg << "'";
6373 if (aFramesNb < 0 && aDuration < 0.0)
6378 // the time is meaningless for first call
6379 // due to async OpenGl rendering
6382 // redraw view in loop to estimate average values
6385 Standard_Integer aFrameIter = 1;
6386 for (;; ++aFrameIter)
6390 && aFrameIter >= aFramesNb)
6392 && aTimer.ElapsedTime() >= aDuration))
6399 const Standard_Real aTime = aTimer.ElapsedTime();
6400 aTimer.OSD_Chronometer::Show (aCpu);
6402 const Standard_Real aFpsAver = Standard_Real(aFrameIter) / aTime;
6403 const Standard_Real aCpuAver = aCpu / Standard_Real(aFrameIter);
6405 // return statistics
6406 theDI << "FPS: " << aFpsAver << "\n"
6407 << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
6409 // compute additional statistics in ray-tracing mode
6410 const Graphic3d_RenderingParams& aParams = aView->RenderingParams();
6411 if (aParams.Method == Graphic3d_RM_RAYTRACING)
6413 Graphic3d_Vec2i aWinSize (0, 0);
6414 aView->Window()->Size (aWinSize.x(), aWinSize.y());
6416 // 1 shadow ray and 1 secondary ray pew each bounce
6417 const Standard_Real aMRays = aWinSize.x() * aWinSize.y() * aFpsAver * aParams.RaytracingDepth * 2 / 1.0e6f;
6418 theDI << "MRays/sec (upper bound): " << aMRays << "\n";
6424 //! Auxiliary function for parsing glsl dump level argument.
6425 static Standard_Boolean parseGlslSourceFlag (Standard_CString theArg,
6426 OpenGl_ShaderProgramDumpLevel& theGlslDumpLevel)
6428 TCollection_AsciiString aTypeStr (theArg);
6429 aTypeStr.LowerCase();
6430 if (aTypeStr == "off"
6433 theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
6435 else if (aTypeStr == "short")
6437 theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Short;
6439 else if (aTypeStr == "full"
6442 theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
6446 return Standard_False;
6448 return Standard_True;
6451 //==============================================================================
6452 //function : VGlDebug
6454 //==============================================================================
6456 static int VGlDebug (Draw_Interpretor& theDI,
6457 Standard_Integer theArgNb,
6458 const char** theArgVec)
6460 Handle(OpenGl_GraphicDriver) aDriver;
6461 Handle(V3d_View) aView = ViewerTest::CurrentView();
6462 if (!aView.IsNull())
6464 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
6466 OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps;
6467 OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
6471 TCollection_AsciiString aDebActive, aSyncActive;
6478 Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
6479 "GL_ARB_debug_output");
6480 aDebActive = isActive ? " (active)" : " (inactive)";
6483 // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
6484 aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
6488 TCollection_AsciiString aGlslCodeDebugStatus = TCollection_AsciiString()
6489 + "glslSourceCode: "
6490 + (aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Off
6492 : aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Short
6496 theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n"
6497 << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n"
6498 << "glslWarn: " << (aCaps->glslWarnings ? "1" : "0") << "\n"
6499 << aGlslCodeDebugStatus
6500 << "extraMsg: " << (aCaps->suppressExtraMsg ? "0" : "1") << "\n";
6504 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6506 Standard_CString anArg = theArgVec[anArgIter];
6507 TCollection_AsciiString anArgCase (anArg);
6508 anArgCase.LowerCase();
6509 Standard_Boolean toEnableDebug = Standard_True;
6510 if (anArgCase == "-glsl"
6511 || anArgCase == "-glslwarn"
6512 || anArgCase == "-glslwarns"
6513 || anArgCase == "-glslwarnings")
6515 Standard_Boolean toShowWarns = Standard_True;
6516 if (++anArgIter < theArgNb
6517 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShowWarns))
6521 aDefCaps->glslWarnings = toShowWarns;
6524 aCaps->glslWarnings = toShowWarns;
6527 else if (anArgCase == "-extra"
6528 || anArgCase == "-extramsg"
6529 || anArgCase == "-extramessages")
6531 Standard_Boolean toShow = Standard_True;
6532 if (++anArgIter < theArgNb
6533 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShow))
6537 aDefCaps->suppressExtraMsg = !toShow;
6540 aCaps->suppressExtraMsg = !toShow;
6543 else if (anArgCase == "-noextra"
6544 || anArgCase == "-noextramsg"
6545 || anArgCase == "-noextramessages")
6547 Standard_Boolean toSuppress = Standard_True;
6548 if (++anArgIter < theArgNb
6549 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSuppress))
6553 aDefCaps->suppressExtraMsg = toSuppress;
6556 aCaps->suppressExtraMsg = toSuppress;
6559 else if (anArgCase == "-sync")
6561 Standard_Boolean toSync = Standard_True;
6562 if (++anArgIter < theArgNb
6563 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSync))
6567 aDefCaps->contextSyncDebug = toSync;
6570 aDefCaps->contextDebug = Standard_True;
6573 else if (anArgCase == "-glslsourcecode"
6574 || anArgCase == "-glslcode")
6576 OpenGl_ShaderProgramDumpLevel aGslsDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
6577 if (++anArgIter < theArgNb
6578 && !parseGlslSourceFlag (theArgVec[anArgIter], aGslsDumpLevel))
6582 aDefCaps->glslDumpLevel = aGslsDumpLevel;
6585 aCaps->glslDumpLevel = aGslsDumpLevel;
6588 else if (anArgCase == "-debug")
6590 if (++anArgIter < theArgNb
6591 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
6595 aDefCaps->contextDebug = toEnableDebug;
6597 else if (ViewerTest::ParseOnOff (anArg, toEnableDebug)
6598 && (anArgIter + 1 == theArgNb))
6600 // simple alias to turn on almost everything
6601 aDefCaps->contextDebug = toEnableDebug;
6602 aDefCaps->contextSyncDebug = toEnableDebug;
6603 aDefCaps->glslWarnings = toEnableDebug;
6606 aDefCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
6608 aDefCaps->suppressExtraMsg = !toEnableDebug;
6611 aCaps->contextDebug = toEnableDebug;
6612 aCaps->contextSyncDebug = toEnableDebug;
6613 aCaps->glslWarnings = toEnableDebug;
6616 aCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
6618 aCaps->suppressExtraMsg = !toEnableDebug;
6623 Message::SendFail() << "Syntax error at '" << anArg << "'";
6631 //==============================================================================
6634 //==============================================================================
6636 static int VVbo (Draw_Interpretor& theDI,
6637 Standard_Integer theArgNb,
6638 const char** theArgVec)
6640 const Standard_Boolean toSet = (theArgNb > 1);
6641 const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
6644 ViewerTest_myDefaultCaps.vboDisable = toUseVbo;
6648 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
6649 if (aContextAIS.IsNull())
6653 Message::SendFail ("Error: no active viewer");
6657 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
6658 if (!aDriver.IsNull())
6662 theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
6666 aDriver->ChangeOptions().vboDisable = toUseVbo;
6673 //==============================================================================
6676 //==============================================================================
6678 static int VCaps (Draw_Interpretor& theDI,
6679 Standard_Integer theArgNb,
6680 const char** theArgVec)
6682 OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps;
6683 Handle(OpenGl_GraphicDriver) aDriver;
6684 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6685 if (!aContext.IsNull())
6687 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
6688 aCaps = &aDriver->ChangeOptions();
6693 theDI << "sRGB: " << (aCaps->sRGBDisable ? "0" : "1") << "\n";
6694 theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n";
6695 theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
6696 theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
6697 theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
6698 theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
6699 theDI << "VSync: " << aCaps->swapInterval << "\n";
6700 theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
6701 theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
6702 theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
6703 theDI << "NoExt:" << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
6704 theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
6705 theDI << "CompressTextures: " << (aCaps->compressedTexturesDisable ? "0" : "1") << "\n";
6709 ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
6710 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6712 Standard_CString anArg = theArgVec[anArgIter];
6713 TCollection_AsciiString anArgCase (anArg);
6714 anArgCase.LowerCase();
6715 if (anUpdateTool.parseRedrawMode (anArg))
6719 else if (anArgCase == "-vsync"
6720 || anArgCase == "-swapinterval")
6722 Standard_Boolean toEnable = Standard_True;
6723 if (++anArgIter < theArgNb
6724 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6728 aCaps->swapInterval = toEnable;
6730 else if (anArgCase == "-ffp")
6732 Standard_Boolean toEnable = Standard_True;
6733 if (++anArgIter < theArgNb
6734 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6738 aCaps->ffpEnable = toEnable;
6740 else if (anArgCase == "-polygonmode")
6742 Standard_Boolean toEnable = Standard_True;
6743 if (++anArgIter < theArgNb
6744 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6748 aCaps->usePolygonMode = toEnable;
6750 else if (anArgCase == "-srgb")
6752 Standard_Boolean toEnable = Standard_True;
6753 if (++anArgIter < theArgNb
6754 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6758 aCaps->sRGBDisable = !toEnable;
6760 else if (anArgCase == "-compressedtextures")
6762 Standard_Boolean toEnable = Standard_True;
6763 if (++anArgIter < theArgNb
6764 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6768 aCaps->compressedTexturesDisable = !toEnable;
6770 else if (anArgCase == "-vbo")
6772 Standard_Boolean toEnable = Standard_True;
6773 if (++anArgIter < theArgNb
6774 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6778 aCaps->vboDisable = !toEnable;
6780 else if (anArgCase == "-sprite"
6781 || anArgCase == "-sprites")
6783 Standard_Boolean toEnable = Standard_True;
6784 if (++anArgIter < theArgNb
6785 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6789 aCaps->pntSpritesDisable = !toEnable;
6791 else if (anArgCase == "-softmode")
6793 Standard_Boolean toEnable = Standard_True;
6794 if (++anArgIter < theArgNb
6795 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6799 aCaps->contextNoAccel = toEnable;
6801 else if (anArgCase == "-winbuffer"
6802 || anArgCase == "-windowbuffer"
6803 || anArgCase == "-usewinbuffer"
6804 || anArgCase == "-usewindowbuffer"
6805 || anArgCase == "-usesystembuffer")
6807 Standard_Boolean toEnable = Standard_True;
6808 if (++anArgIter < theArgNb
6809 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6813 aCaps->useSystemBuffer = toEnable;
6815 else if (anArgCase == "-accel"
6816 || anArgCase == "-acceleration")
6818 Standard_Boolean toEnable = Standard_True;
6819 if (++anArgIter < theArgNb
6820 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6824 aCaps->contextNoAccel = !toEnable;
6826 else if (anArgCase == "-compat"
6827 || anArgCase == "-compatprofile"
6828 || anArgCase == "-compatible"
6829 || anArgCase == "-compatibleprofile")
6831 Standard_Boolean toEnable = Standard_True;
6832 if (++anArgIter < theArgNb
6833 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6837 aCaps->contextCompatible = toEnable;
6838 if (!aCaps->contextCompatible)
6840 aCaps->ffpEnable = Standard_False;
6843 else if (anArgCase == "-core"
6844 || anArgCase == "-coreprofile")
6846 Standard_Boolean toEnable = Standard_True;
6847 if (++anArgIter < theArgNb
6848 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6852 aCaps->contextCompatible = !toEnable;
6853 if (!aCaps->contextCompatible)
6855 aCaps->ffpEnable = Standard_False;
6858 else if (anArgCase == "-stereo"
6859 || anArgCase == "-quadbuffer")
6861 Standard_Boolean toEnable = Standard_True;
6862 if (++anArgIter < theArgNb
6863 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6867 aCaps->contextStereo = toEnable;
6869 else if (anArgCase == "-noext"
6870 || anArgCase == "-noextensions"
6871 || anArgCase == "-noextension")
6873 Standard_Boolean toDisable = Standard_True;
6874 if (++anArgIter < theArgNb
6875 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
6879 aCaps->contextNoExtensions = toDisable;
6881 else if (anArgCase == "-maxversion"
6882 || anArgCase == "-upperversion"
6883 || anArgCase == "-limitversion")
6885 Standard_Integer aVer[2] = { -2, -1 };
6886 for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
6888 if (anArgIter + 1 < theArgNb)
6890 const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
6891 if (aStr.IsIntegerValue())
6893 aVer[aValIter] = aStr.IntegerValue();
6901 Message::SendFail() << "Syntax error at '" << anArgCase << "'";
6904 aCaps->contextMajorVersionUpper = aVer[0];
6905 aCaps->contextMinorVersionUpper = aVer[1];
6909 Message::SendFail() << "Error: unknown argument '" << anArg << "'";
6913 if (aCaps != &ViewerTest_myDefaultCaps)
6915 ViewerTest_myDefaultCaps = *aCaps;
6920 //==============================================================================
6921 //function : VMemGpu
6923 //==============================================================================
6925 static int VMemGpu (Draw_Interpretor& theDI,
6926 Standard_Integer theArgNb,
6927 const char** theArgVec)
6930 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
6931 if (aContextAIS.IsNull())
6933 Message::SendFail ("Error: no active viewer");
6937 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
6938 if (aDriver.IsNull())
6940 Message::SendFail ("Error: graphic driver not available");
6944 Standard_Size aFreeBytes = 0;
6945 TCollection_AsciiString anInfo;
6946 if (!aDriver->MemoryInfo (aFreeBytes, anInfo))
6948 Message::SendFail ("Error: information not available");
6952 if (theArgNb > 1 && *theArgVec[1] == 'f')
6954 theDI << Standard_Real (aFreeBytes);
6964 // ==============================================================================
6965 // function : VReadPixel
6967 // ==============================================================================
6968 static int VReadPixel (Draw_Interpretor& theDI,
6969 Standard_Integer theArgNb,
6970 const char** theArgVec)
6972 // get the active view
6973 Handle(V3d_View) aView = ViewerTest::CurrentView();
6976 Message::SendFail ("Error: no active viewer");
6979 else if (theArgNb < 3)
6981 Message::SendFail() << "Syntax error: wrong number of arguments.\n"
6982 << "Usage: " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]";
6986 Image_Format aFormat = Image_Format_RGBA;
6987 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
6989 Standard_Integer aWidth, aHeight;
6990 aView->Window()->Size (aWidth, aHeight);
6991 const Standard_Integer anX = Draw::Atoi (theArgVec[1]);
6992 const Standard_Integer anY = Draw::Atoi (theArgVec[2]);
6993 if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight)
6995 Message::SendFail() << "Error: pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")";
6999 bool toShowName = false, toShowHls = false, toShowHex = false, toShow_sRGB = false;
7000 for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
7002 TCollection_AsciiString aParam (theArgVec[anIter]);
7004 if (aParam == "-rgb"
7006 || aParam == "-srgb"
7007 || aParam == "srgb")
7009 aFormat = Image_Format_RGB;
7010 aBufferType = Graphic3d_BT_RGB;
7011 toShow_sRGB = aParam == "-srgb" || aParam == "srgb";
7013 else if (aParam == "-hls"
7016 aFormat = Image_Format_RGB;
7017 aBufferType = Graphic3d_BT_RGB;
7018 toShowHls = Standard_True;
7020 else if (aParam == "-rgbf"
7021 || aParam == "rgbf")
7023 aFormat = Image_Format_RGBF;
7024 aBufferType = Graphic3d_BT_RGB;
7026 else if (aParam == "-rgba"
7028 || aParam == "-srgba"
7029 || aParam == "srgba")
7031 aFormat = Image_Format_RGBA;
7032 aBufferType = Graphic3d_BT_RGBA;
7033 toShow_sRGB = aParam == "-srgba" || aParam == "srgba";
7035 else if (aParam == "-rgbaf"
7036 || aParam == "rgbaf")
7038 aFormat = Image_Format_RGBAF;
7039 aBufferType = Graphic3d_BT_RGBA;
7041 else if (aParam == "-depth"
7042 || aParam == "depth")
7044 aFormat = Image_Format_GrayF;
7045 aBufferType = Graphic3d_BT_Depth;
7047 else if (aParam == "-name"
7048 || aParam == "name")
7050 toShowName = Standard_True;
7052 else if (aParam == "-hex"
7055 toShowHex = Standard_True;
7059 Message::SendFail() << "Syntax error at '" << aParam << "'";
7064 Image_PixMap anImage;
7065 if (!anImage.InitTrash (aFormat, aWidth, aHeight))
7067 Message::SendFail ("Error: image allocation failed");
7070 else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType))
7072 Message::SendFail ("Error: image dump failed");
7076 // redirect possible warning messages that could have been added by ToPixMap
7077 // into the Tcl interpretor (via DefaultMessenger) to cout, so that they do not
7078 // contaminate result of the command
7079 Standard_CString aWarnLog = theDI.Result();
7080 if (aWarnLog != NULL && aWarnLog[0] != '\0')
7082 std::cout << aWarnLog << std::endl;
7086 Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY, true);
7089 if (aBufferType == Graphic3d_BT_RGBA)
7091 theDI << Quantity_Color::StringName (aColor.GetRGB().Name()) << " " << aColor.Alpha();
7095 theDI << Quantity_Color::StringName (aColor.GetRGB().Name());
7100 if (aBufferType == Graphic3d_BT_RGBA)
7102 theDI << Quantity_ColorRGBA::ColorToHex (aColor);
7106 theDI << Quantity_Color::ColorToHex (aColor.GetRGB());
7111 switch (aBufferType)
7114 case Graphic3d_BT_RGB:
7118 theDI << aColor.GetRGB().Hue() << " " << aColor.GetRGB().Light() << " " << aColor.GetRGB().Saturation();
7120 else if (toShow_sRGB)
7122 const Graphic3d_Vec4 aColor_sRGB = Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor);
7123 theDI << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b();
7127 theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue();
7131 case Graphic3d_BT_RGBA:
7133 const Graphic3d_Vec4 aVec4 = toShow_sRGB ? Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor) : (Graphic3d_Vec4 )aColor;
7134 theDI << aVec4.r() << " " << aVec4.g() << " " << aVec4.b() << " " << aVec4.a();
7137 case Graphic3d_BT_Depth:
7139 theDI << aColor.GetRGB().Red();
7148 //! Auxiliary presentation for an image plane.
7149 class ViewerTest_ImagePrs : public AIS_InteractiveObject
7152 //! Main constructor.
7153 ViewerTest_ImagePrs (const Handle(Image_PixMap)& theImage,
7154 const Standard_Real theWidth,
7155 const Standard_Real theHeight,
7156 const TCollection_AsciiString& theLabel)
7157 : myLabel (theLabel), myWidth (theWidth), myHeight(theHeight)
7161 myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
7163 myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
7164 const Handle(Graphic3d_AspectFillArea3d)& aFillAspect = myDrawer->ShadingAspect()->Aspect();
7165 Graphic3d_MaterialAspect aMat;
7166 aMat.SetMaterialType (Graphic3d_MATERIAL_PHYSIC);
7167 aMat.SetAmbientColor (Quantity_NOC_BLACK);
7168 aMat.SetDiffuseColor (Quantity_NOC_WHITE);
7169 aMat.SetSpecularColor (Quantity_NOC_BLACK);
7170 aMat.SetEmissiveColor (Quantity_NOC_BLACK);
7171 aFillAspect->SetFrontMaterial (aMat);
7172 aFillAspect->SetTextureMap (new Graphic3d_Texture2Dmanual (theImage));
7173 aFillAspect->SetTextureMapOn();
7176 Handle(Prs3d_TextAspect) aTextAspect = new Prs3d_TextAspect();
7177 aTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER);
7178 aTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
7179 myDrawer->SetTextAspect (aTextAspect);
7182 const gp_Dir aNorm (0.0, 0.0, 1.0);
7183 myTris = new Graphic3d_ArrayOfTriangles (4, 6, true, false, true);
7184 myTris->AddVertex (gp_Pnt(-myWidth * 0.5, -myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (0.0, 0.0));
7185 myTris->AddVertex (gp_Pnt( myWidth * 0.5, -myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (1.0, 0.0));
7186 myTris->AddVertex (gp_Pnt(-myWidth * 0.5, myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (0.0, 1.0));
7187 myTris->AddVertex (gp_Pnt( myWidth * 0.5, myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (1.0, 1.0));
7188 myTris->AddEdge (1);
7189 myTris->AddEdge (2);
7190 myTris->AddEdge (3);
7191 myTris->AddEdge (3);
7192 myTris->AddEdge (2);
7193 myTris->AddEdge (4);
7195 myRect = new Graphic3d_ArrayOfPolylines (4);
7196 myRect->AddVertex (myTris->Vertice (1));
7197 myRect->AddVertex (myTris->Vertice (3));
7198 myRect->AddVertex (myTris->Vertice (4));
7199 myRect->AddVertex (myTris->Vertice (2));
7203 //! Returns TRUE for accepted display modes.
7204 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0 || theMode == 1; }
7206 //! Compute presentation.
7207 virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& , const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE
7213 Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
7214 aGroup->AddPrimitiveArray (myTris);
7215 aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
7216 aGroup->AddPrimitiveArray (myRect);
7217 aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
7222 Prs3d_Text::Draw (thePrs->NewGroup(), myDrawer->TextAspect(), myLabel, gp_Pnt(0.0, 0.0, 0.0));
7223 Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
7224 aGroup->AddPrimitiveArray (myRect);
7225 aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
7231 //! Compute selection.
7232 virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, const Standard_Integer theMode) Standard_OVERRIDE
7236 Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 5);
7237 Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anEntityOwner);
7238 aSensitive->InitTriangulation (myTris->Attributes(), myTris->Indices(), TopLoc_Location());
7239 theSel->Add (aSensitive);
7244 Handle(Graphic3d_ArrayOfTriangles) myTris;
7245 Handle(Graphic3d_ArrayOfPolylines) myRect;
7246 TCollection_AsciiString myLabel;
7247 Standard_Real myWidth;
7248 Standard_Real myHeight;
7251 //==============================================================================
7252 //function : VDiffImage
7253 //purpose : The draw-command compares two images.
7254 //==============================================================================
7256 static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
7260 Message::SendFail ("Syntax error: not enough arguments");
7264 Standard_Integer anArgIter = 1;
7265 TCollection_AsciiString anImgPathRef (theArgVec[anArgIter++]);
7266 TCollection_AsciiString anImgPathNew (theArgVec[anArgIter++]);
7267 TCollection_AsciiString aDiffImagePath;
7268 Standard_Real aTolColor = -1.0;
7269 Standard_Integer toBlackWhite = -1;
7270 Standard_Integer isBorderFilterOn = -1;
7271 Standard_Boolean isOldSyntax = Standard_False;
7272 TCollection_AsciiString aViewName, aPrsNameRef, aPrsNameNew, aPrsNameDiff;
7273 for (; anArgIter < theArgNb; ++anArgIter)
7275 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7277 if (anArgIter + 1 < theArgNb
7278 && (anArg == "-toleranceofcolor"
7279 || anArg == "-tolerancecolor"
7280 || anArg == "-tolerance"
7281 || anArg == "-toler"))
7283 aTolColor = Atof (theArgVec[++anArgIter]);
7284 if (aTolColor < 0.0 || aTolColor > 1.0)
7286 Message::SendFail() << "Syntax error at '" << anArg << " " << theArgVec[anArgIter] << "'";
7290 else if (anArg == "-blackwhite")
7292 Standard_Boolean toEnable = Standard_True;
7293 if (anArgIter + 1 < theArgNb
7294 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
7298 toBlackWhite = toEnable ? 1 : 0;
7300 else if (anArg == "-borderfilter")
7302 Standard_Boolean toEnable = Standard_True;
7303 if (anArgIter + 1 < theArgNb
7304 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
7308 isBorderFilterOn = toEnable ? 1 : 0;
7310 else if (anArg == "-exitonclose")
7312 ViewerTest_EventManager::ToExitOnCloseView() = true;
7313 if (anArgIter + 1 < theArgNb
7314 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToExitOnCloseView()))
7319 else if (anArg == "-closeonescape"
7320 || anArg == "-closeonesc")
7322 ViewerTest_EventManager::ToCloseViewOnEscape() = true;
7323 if (anArgIter + 1 < theArgNb
7324 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
7329 else if (anArgIter + 3 < theArgNb
7330 && anArg == "-display")
7332 aViewName = theArgVec[++anArgIter];
7333 aPrsNameRef = theArgVec[++anArgIter];
7334 aPrsNameNew = theArgVec[++anArgIter];
7335 if (anArgIter + 1 < theArgNb
7336 && *theArgVec[anArgIter + 1] != '-')
7338 aPrsNameDiff = theArgVec[++anArgIter];
7341 else if (aTolColor < 0.0
7342 && anArg.IsRealValue())
7344 isOldSyntax = Standard_True;
7345 aTolColor = anArg.RealValue();
7346 if (aTolColor < 0.0 || aTolColor > 1.0)
7348 Message::SendFail() << "Syntax error at '" << anArg << " " << theArgVec[anArgIter] << "'";
7352 else if (isOldSyntax
7353 && toBlackWhite == -1
7354 && (anArg == "0" || anArg == "1"))
7356 toBlackWhite = anArg == "1" ? 1 : 0;
7358 else if (isOldSyntax
7359 && isBorderFilterOn == -1
7360 && (anArg == "0" || anArg == "1"))
7362 isBorderFilterOn = anArg == "1" ? 1 : 0;
7364 else if (aDiffImagePath.IsEmpty())
7366 aDiffImagePath = theArgVec[anArgIter];
7370 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
7375 Handle(Image_AlienPixMap) anImgRef = new Image_AlienPixMap();
7376 Handle(Image_AlienPixMap) anImgNew = new Image_AlienPixMap();
7377 if (!anImgRef->Load (anImgPathRef))
7379 Message::SendFail() << "Error: image file '" << anImgPathRef << "' cannot be read";
7382 if (!anImgNew->Load (anImgPathNew))
7384 Message::SendFail() << "Error: image file '" << anImgPathNew << "' cannot be read";
7388 // compare the images
7389 Image_Diff aComparer;
7390 Standard_Integer aDiffColorsNb = -1;
7391 if (aComparer.Init (anImgRef, anImgNew, toBlackWhite == 1))
7393 aComparer.SetColorTolerance (aTolColor >= 0.0 ? aTolColor : 0.0);
7394 aComparer.SetBorderFilterOn (isBorderFilterOn == 1);
7395 aDiffColorsNb = aComparer.Compare();
7396 theDI << aDiffColorsNb << "\n";
7399 // save image of difference
7400 Handle(Image_AlienPixMap) aDiff;
7401 if (aDiffColorsNb > 0
7402 && (!aDiffImagePath.IsEmpty() || !aPrsNameDiff.IsEmpty()))
7404 aDiff = new Image_AlienPixMap();
7405 if (!aDiff->InitTrash (Image_Format_Gray, anImgRef->SizeX(), anImgRef->SizeY()))
7407 Message::SendFail() << "Error: cannot allocate memory for diff image " << anImgRef->SizeX() << "x" << anImgRef->SizeY();
7410 aComparer.SaveDiffImage (*aDiff);
7411 if (!aDiffImagePath.IsEmpty()
7412 && !aDiff->Save (aDiffImagePath))
7414 Message::SendFail() << "Error: diff image file '" << aDiffImagePath << "' cannot be written";
7419 if (aViewName.IsEmpty())
7424 ViewerTest_Names aViewNames (aViewName);
7425 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
7427 TCollection_AsciiString aCommand = TCollection_AsciiString ("vclose ") + aViewNames.GetViewName();
7428 theDI.Eval (aCommand.ToCString());
7431 Standard_Integer aPxLeft = 0;
7432 Standard_Integer aPxTop = 0;
7433 Standard_Integer aWinSizeX = int(anImgRef->SizeX() * 2);
7434 Standard_Integer aWinSizeY = !aDiff.IsNull() && !aPrsNameDiff.IsEmpty()
7435 ? int(anImgRef->SizeY() * 2)
7436 : int(anImgRef->SizeY());
7437 TCollection_AsciiString aDisplayName;
7438 TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aWinSizeX, aWinSizeY,
7439 aViewName, aDisplayName);
7441 Standard_Real aRatio = anImgRef->Ratio();
7442 Standard_Real aSizeX = 1.0;
7443 Standard_Real aSizeY = aSizeX / aRatio;
7445 OSD_Path aPath (anImgPathRef);
7446 TCollection_AsciiString aLabelRef;
7447 if (!aPath.Name().IsEmpty())
7449 aLabelRef = aPath.Name() + aPath.Extension();
7451 aLabelRef += TCollection_AsciiString() + "\n" + int(anImgRef->SizeX()) + "x" + int(anImgRef->SizeY());
7453 Handle(ViewerTest_ImagePrs) anImgRefPrs = new ViewerTest_ImagePrs (anImgRef, aSizeX, aSizeY, aLabelRef);
7455 aTrsfRef.SetTranslationPart (gp_Vec (-aSizeX * 0.5, 0.0, 0.0));
7456 anImgRefPrs->SetLocalTransformation (aTrsfRef);
7457 ViewerTest::Display (aPrsNameRef, anImgRefPrs, false, true);
7460 OSD_Path aPath (anImgPathNew);
7461 TCollection_AsciiString aLabelNew;
7462 if (!aPath.Name().IsEmpty())
7464 aLabelNew = aPath.Name() + aPath.Extension();
7466 aLabelNew += TCollection_AsciiString() + "\n" + int(anImgNew->SizeX()) + "x" + int(anImgNew->SizeY());
7468 Handle(ViewerTest_ImagePrs) anImgNewPrs = new ViewerTest_ImagePrs (anImgNew, aSizeX, aSizeY, aLabelNew);
7470 aTrsfRef.SetTranslationPart (gp_Vec (aSizeX * 0.5, 0.0, 0.0));
7471 anImgNewPrs->SetLocalTransformation (aTrsfRef);
7472 ViewerTest::Display (aPrsNameNew, anImgNewPrs, false, true);
7474 Handle(ViewerTest_ImagePrs) anImgDiffPrs;
7475 if (!aDiff.IsNull())
7477 anImgDiffPrs = new ViewerTest_ImagePrs (aDiff, aSizeX, aSizeY, TCollection_AsciiString() + "Difference: " + aDiffColorsNb + " pixels");
7479 aTrsfDiff.SetTranslationPart (gp_Vec (0.0, -aSizeY, 0.0));
7480 anImgDiffPrs->SetLocalTransformation (aTrsfDiff);
7482 if (!aPrsNameDiff.IsEmpty())
7484 ViewerTest::Display (aPrsNameDiff, anImgDiffPrs, false, true);
7486 ViewerTest::CurrentView()->SetProj (V3d_Zpos);
7487 ViewerTest::CurrentView()->FitAll();
7491 //=======================================================================
7492 //function : VSelect
7493 //purpose : Emulates different types of selection by mouse:
7494 // 1) single click selection
7495 // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)
7496 // 3) selection with polygon having corners at
7497 // pixel positions (x1,y1),...,(xn,yn)
7498 // 4) any of these selections with shift button pressed
7499 //=======================================================================
7500 static Standard_Integer VSelect (Draw_Interpretor& ,
7501 Standard_Integer theNbArgs,
7502 const char** theArgVec)
7504 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
7507 Message::SendFail ("Error: no active viewer");
7511 NCollection_Sequence<Graphic3d_Vec2i> aPnts;
7512 bool isShiftSelection = false, toAllowOverlap = false;
7513 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
7515 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7517 if (anArg == "-allowoverlap")
7519 toAllowOverlap = true;
7520 if (anArgIter + 1 < theNbArgs
7521 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toAllowOverlap))
7526 else if (anArgIter + 1 < theNbArgs
7527 && anArg.IsIntegerValue()
7528 && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue())
7530 const TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
7531 aPnts.Append (Graphic3d_Vec2i (anArg.IntegerValue(), anArgNext.IntegerValue()));
7533 else if (anArgIter + 1 == theNbArgs
7534 && anArg.IsIntegerValue())
7536 isShiftSelection = anArg.IntegerValue() == 1;
7540 Message::SendFail() << "Syntax error at '" << anArg << "'";
7547 aCtx->MainSelector()->AllowOverlapDetection (toAllowOverlap);
7550 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
7551 if (aPnts.IsEmpty())
7553 if (isShiftSelection)
7555 aCtx->ShiftSelect (false);
7559 aCtx->Select (false);
7561 aCtx->CurrentViewer()->Invalidate();
7563 else if (aPnts.Length() == 2)
7566 && aPnts.First().y() < aPnts.Last().y())
7568 std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast());
7570 else if (!toAllowOverlap
7571 && aPnts.First().y() > aPnts.Last().y())
7573 std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast());
7575 aCurrentEventManager->SelectInViewer (aPnts, isShiftSelection);
7579 aCurrentEventManager->SelectInViewer (aPnts, isShiftSelection);
7581 aCurrentEventManager->FlushViewEvents (aCtx, ViewerTest::CurrentView(), true);
7585 //=======================================================================
7586 //function : VMoveTo
7587 //purpose : Emulates cursor movement to defined pixel position
7588 //=======================================================================
7589 static Standard_Integer VMoveTo (Draw_Interpretor& theDI,
7590 Standard_Integer theNbArgs,
7591 const char** theArgVec)
7593 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
7594 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
7595 if (aContext.IsNull())
7597 Message::SendFail ("Error: no active viewer");
7601 Graphic3d_Vec2i aMousePos (IntegerLast(), IntegerLast());
7602 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
7604 TCollection_AsciiString anArgStr (theArgVec[anArgIter]);
7605 anArgStr.LowerCase();
7606 if (anArgStr == "-reset"
7607 || anArgStr == "-clear")
7609 if (anArgIter + 1 < theNbArgs)
7611 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter + 1] << "'";
7615 const Standard_Boolean toEchoGrid = aContext->CurrentViewer()->Grid()->IsActive()
7616 && aContext->CurrentViewer()->GridEcho();
7619 aContext->CurrentViewer()->HideGridEcho (aView);
7621 if (aContext->ClearDetected() || toEchoGrid)
7623 aContext->CurrentViewer()->RedrawImmediate();
7627 else if (aMousePos.x() == IntegerLast()
7628 && anArgStr.IsIntegerValue())
7630 aMousePos.x() = anArgStr.IntegerValue();
7632 else if (aMousePos.y() == IntegerLast()
7633 && anArgStr.IsIntegerValue())
7635 aMousePos.y() = anArgStr.IntegerValue();
7639 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
7644 if (aMousePos.x() == IntegerLast()
7645 || aMousePos.y() == IntegerLast())
7647 Message::SendFail ("Syntax error: wrong number of arguments");
7651 ViewerTest::CurrentEventManager()->ResetPreviousMoveTo();
7652 ViewerTest::CurrentEventManager()->UpdateMousePosition (aMousePos, Aspect_VKeyMouse_NONE, Aspect_VKeyFlags_NONE, false);
7653 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
7655 gp_Pnt aTopPnt (RealLast(), RealLast(), RealLast());
7656 const Handle(SelectMgr_EntityOwner)& aDetOwner = aContext->DetectedOwner();
7657 for (Standard_Integer aDetIter = 1; aDetIter <= aContext->MainSelector()->NbPicked(); ++aDetIter)
7659 if (aContext->MainSelector()->Picked (aDetIter) == aDetOwner)
7661 aTopPnt = aContext->MainSelector()->PickedPoint (aDetIter);
7665 theDI << aTopPnt.X() << " " << aTopPnt.Y() << " " << aTopPnt.Z();
7671 //! Global map storing all animations registered in ViewerTest.
7672 static NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)> ViewerTest_AnimationTimelineMap;
7674 //! The animation calling the Draw Harness command.
7675 class ViewerTest_AnimationProc : public AIS_Animation
7679 //! Main constructor.
7680 ViewerTest_AnimationProc (const TCollection_AsciiString& theAnimationName,
7681 Draw_Interpretor* theDI,
7682 const TCollection_AsciiString& theCommand)
7683 : AIS_Animation (theAnimationName),
7685 myCommand (theCommand)
7692 //! Evaluate the command.
7693 virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE
7695 TCollection_AsciiString aCmd = myCommand;
7696 replace (aCmd, "%pts", TCollection_AsciiString(theProgress.Pts));
7697 replace (aCmd, "%localpts", TCollection_AsciiString(theProgress.LocalPts));
7698 replace (aCmd, "%ptslocal", TCollection_AsciiString(theProgress.LocalPts));
7699 replace (aCmd, "%normalized", TCollection_AsciiString(theProgress.LocalNormalized));
7700 replace (aCmd, "%localnormalized", TCollection_AsciiString(theProgress.LocalNormalized));
7701 myDrawInter->Eval (aCmd.ToCString());
7704 //! Find the keyword in the command and replace it with value.
7705 //! @return the position of the keyword to pass value
7706 void replace (TCollection_AsciiString& theCmd,
7707 const TCollection_AsciiString& theKey,
7708 const TCollection_AsciiString& theVal)
7710 TCollection_AsciiString aCmd (theCmd);
7712 const Standard_Integer aPos = aCmd.Search (theKey);
7718 TCollection_AsciiString aPart1, aPart2;
7719 Standard_Integer aPart1To = aPos - 1;
7721 && aPart1To <= theCmd.Length())
7723 aPart1 = theCmd.SubString (1, aPart1To);
7726 Standard_Integer aPart2From = aPos + theKey.Length();
7728 && aPart2From <= theCmd.Length())
7730 aPart2 = theCmd.SubString (aPart2From, theCmd.Length());
7733 theCmd = aPart1 + theVal + aPart2;
7738 Draw_Interpretor* myDrawInter;
7739 TCollection_AsciiString myCommand;
7743 //! Replace the animation with the new one.
7744 static void replaceAnimation (const Handle(AIS_Animation)& theParentAnimation,
7745 Handle(AIS_Animation)& theAnimation,
7746 const Handle(AIS_Animation)& theAnimationNew)
7748 theAnimationNew->CopyFrom (theAnimation);
7749 if (!theParentAnimation.IsNull())
7751 theParentAnimation->Replace (theAnimation, theAnimationNew);
7755 ViewerTest_AnimationTimelineMap.UnBind (theAnimationNew->Name());
7756 ViewerTest_AnimationTimelineMap.Bind (theAnimationNew->Name(), theAnimationNew);
7758 theAnimation = theAnimationNew;
7761 //! Parse the point.
7762 static Standard_Boolean parseXYZ (const char** theArgVec, gp_XYZ& thePnt)
7764 const TCollection_AsciiString anXYZ[3] = { theArgVec[0], theArgVec[1], theArgVec[2] };
7765 if (!anXYZ[0].IsRealValue()
7766 || !anXYZ[1].IsRealValue()
7767 || !anXYZ[2].IsRealValue())
7769 return Standard_False;
7772 thePnt.SetCoord (anXYZ[0].RealValue(), anXYZ[1].RealValue(), anXYZ[2].RealValue());
7773 return Standard_True;
7776 //! Parse the quaternion.
7777 static Standard_Boolean parseQuaternion (const char** theArgVec, gp_Quaternion& theQRot)
7779 const TCollection_AsciiString anXYZW[4] = {theArgVec[0], theArgVec[1], theArgVec[2], theArgVec[3]};
7780 if (!anXYZW[0].IsRealValue()
7781 || !anXYZW[1].IsRealValue()
7782 || !anXYZW[2].IsRealValue()
7783 || !anXYZW[3].IsRealValue())
7785 return Standard_False;
7788 theQRot.Set (anXYZW[0].RealValue(), anXYZW[1].RealValue(), anXYZW[2].RealValue(), anXYZW[3].RealValue());
7789 return Standard_True;
7792 //! Auxiliary class for flipping image upside-down.
7797 //! Empty constructor.
7798 ImageFlipper() : myTmp (NCollection_BaseAllocator::CommonBaseAllocator()) {}
7800 //! Perform flipping.
7801 Standard_Boolean FlipY (Image_PixMap& theImage)
7803 if (theImage.IsEmpty()
7804 || theImage.SizeX() == 0
7805 || theImage.SizeY() == 0)
7807 return Standard_False;
7810 const Standard_Size aRowSize = theImage.SizeRowBytes();
7811 if (myTmp.Size() < aRowSize
7812 && !myTmp.Allocate (aRowSize))
7814 return Standard_False;
7817 // for odd height middle row should be left as is
7818 Standard_Size aNbRowsHalf = theImage.SizeY() / 2;
7819 for (Standard_Size aRowT = 0, aRowB = theImage.SizeY() - 1; aRowT < aNbRowsHalf; ++aRowT, --aRowB)
7821 Standard_Byte* aTop = theImage.ChangeRow (aRowT);
7822 Standard_Byte* aBot = theImage.ChangeRow (aRowB);
7823 memcpy (myTmp.ChangeData(), aTop, aRowSize);
7824 memcpy (aTop, aBot, aRowSize);
7825 memcpy (aBot, myTmp.Data(), aRowSize);
7827 return Standard_True;
7831 NCollection_Buffer myTmp;
7836 //=================================================================================================
7837 //function : VViewParams
7838 //purpose : Gets or sets AIS View characteristics
7839 //=================================================================================================
7840 static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
7842 Handle(V3d_View) aView = ViewerTest::CurrentView();
7845 Message::SendFail ("Error: no active viewer");
7849 Standard_Boolean toSetProj = Standard_False;
7850 Standard_Boolean toSetUp = Standard_False;
7851 Standard_Boolean toSetAt = Standard_False;
7852 Standard_Boolean toSetEye = Standard_False;
7853 Standard_Boolean toSetScale = Standard_False;
7854 Standard_Boolean toSetSize = Standard_False;
7855 Standard_Boolean toSetCenter2d = Standard_False;
7856 Standard_Real aViewScale = aView->Scale();
7857 Standard_Real aViewSize = 1.0;
7858 Graphic3d_Vec2i aCenter2d;
7859 gp_XYZ aViewProj, aViewUp, aViewAt, aViewEye;
7860 aView->Proj (aViewProj.ChangeCoord (1), aViewProj.ChangeCoord (2), aViewProj.ChangeCoord (3));
7861 aView->Up (aViewUp .ChangeCoord (1), aViewUp .ChangeCoord (2), aViewUp .ChangeCoord (3));
7862 aView->At (aViewAt .ChangeCoord (1), aViewAt .ChangeCoord (2), aViewAt .ChangeCoord (3));
7863 aView->Eye (aViewEye .ChangeCoord (1), aViewEye .ChangeCoord (2), aViewEye .ChangeCoord (3));
7866 // print all of the available view parameters
7870 "Proj: %12g %12g %12g\n"
7871 "Up: %12g %12g %12g\n"
7872 "At: %12g %12g %12g\n"
7873 "Eye: %12g %12g %12g\n",
7875 aViewProj.X(), aViewProj.Y(), aViewProj.Z(),
7876 aViewUp.X(), aViewUp.Y(), aViewUp.Z(),
7877 aViewAt.X(), aViewAt.Y(), aViewAt.Z(),
7878 aViewEye.X(), aViewEye.Y(), aViewEye.Z());
7883 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
7884 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
7886 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7888 if (anUpdateTool.parseRedrawMode (anArg))
7892 else if (anArg == "-cmd"
7893 || anArg == "-command"
7894 || anArg == "-args")
7903 aViewProj.X(), aViewProj.Y(), aViewProj.Z(),
7904 aViewUp.X(), aViewUp.Y(), aViewUp.Z(),
7905 aViewAt.X(), aViewAt.Y(), aViewAt.Z());
7908 else if (anArg == "-scale"
7909 || anArg == "-size")
7911 if (anArgIter + 1 < theArgsNb
7912 && *theArgVec[anArgIter + 1] != '-')
7914 const TCollection_AsciiString aValueArg (theArgVec[anArgIter + 1]);
7915 if (aValueArg.IsRealValue())
7918 if (anArg == "-scale")
7920 toSetScale = Standard_True;
7921 aViewScale = aValueArg.RealValue();
7923 else if (anArg == "-size")
7925 toSetSize = Standard_True;
7926 aViewSize = aValueArg.RealValue();
7931 if (anArg == "-scale")
7933 theDi << "Scale: " << aView->Scale() << "\n";
7935 else if (anArg == "-size")
7937 Graphic3d_Vec2d aSizeXY;
7938 aView->Size (aSizeXY.x(), aSizeXY.y());
7939 theDi << "Size: " << aSizeXY.x() << " " << aSizeXY.y() << "\n";
7942 else if (anArg == "-eye"
7945 || anArg == "-proj")
7947 if (anArgIter + 3 < theArgsNb)
7950 if (parseXYZ (theArgVec + anArgIter + 1, anXYZ))
7953 if (anArg == "-eye")
7955 toSetEye = Standard_True;
7958 else if (anArg == "-at")
7960 toSetAt = Standard_True;
7963 else if (anArg == "-up")
7965 toSetUp = Standard_True;
7968 else if (anArg == "-proj")
7970 toSetProj = Standard_True;
7977 if (anArg == "-eye")
7979 theDi << "Eye: " << aViewEye.X() << " " << aViewEye.Y() << " " << aViewEye.Z() << "\n";
7981 else if (anArg == "-at")
7983 theDi << "At: " << aViewAt.X() << " " << aViewAt.Y() << " " << aViewAt.Z() << "\n";
7985 else if (anArg == "-up")
7987 theDi << "Up: " << aViewUp.X() << " " << aViewUp.Y() << " " << aViewUp.Z() << "\n";
7989 else if (anArg == "-proj")
7991 theDi << "Proj: " << aViewProj.X() << " " << aViewProj.Y() << " " << aViewProj.Z() << "\n";
7994 else if (anArg == "-center")
7996 if (anArgIter + 2 < theArgsNb)
7998 const TCollection_AsciiString anX (theArgVec[anArgIter + 1]);
7999 const TCollection_AsciiString anY (theArgVec[anArgIter + 2]);
8000 if (anX.IsIntegerValue()
8001 && anY.IsIntegerValue())
8003 toSetCenter2d = Standard_True;
8004 aCenter2d = Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue());
8010 Message::SendFail() << "Syntax error at '" << anArg << "'";
8015 // change view parameters in proper order
8018 aView->SetScale (aViewScale);
8022 aView->SetSize (aViewSize);
8026 aView->SetEye (aViewEye.X(), aViewEye.Y(), aViewEye.Z());
8030 aView->SetAt (aViewAt.X(), aViewAt.Y(), aViewAt.Z());
8034 aView->SetProj (aViewProj.X(), aViewProj.Y(), aViewProj.Z());
8038 aView->SetUp (aViewUp.X(), aViewUp.Y(), aViewUp.Z());
8042 aView->SetCenter (aCenter2d.x(), aCenter2d.y());
8048 //==============================================================================
8049 //function : V2DMode
8051 //==============================================================================
8052 static Standard_Integer V2DMode (Draw_Interpretor&, Standard_Integer theArgsNb, const char** theArgVec)
8054 bool is2dMode = true;
8055 Handle(ViewerTest_V3dView) aV3dView = Handle(ViewerTest_V3dView)::DownCast (ViewerTest::CurrentView());
8056 if (aV3dView.IsNull())
8058 Message::SendFail ("Error: no active viewer");
8061 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
8063 const TCollection_AsciiString anArg = theArgVec[anArgIt];
8064 TCollection_AsciiString anArgCase = anArg;
8065 anArgCase.LowerCase();
8066 if (anArgIt + 1 < theArgsNb
8067 && anArgCase == "-name")
8069 ViewerTest_Names aViewNames (theArgVec[++anArgIt]);
8070 TCollection_AsciiString aViewName = aViewNames.GetViewName();
8071 if (!ViewerTest_myViews.IsBound1 (aViewName))
8073 Message::SendFail() << "Syntax error: unknown view '" << theArgVec[anArgIt - 1] << "'";
8076 aV3dView = Handle(ViewerTest_V3dView)::DownCast (ViewerTest_myViews.Find1 (aViewName));
8078 else if (anArgCase == "-mode")
8080 if (anArgIt + 1 < theArgsNb
8081 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], is2dMode))
8086 else if (ViewerTest::ParseOnOff (theArgVec[anArgIt], is2dMode))
8092 Message::SendFail() << "Syntax error: unknown argument " << anArg;
8097 aV3dView->SetView2DMode (is2dMode);
8101 //==============================================================================
8102 //function : VAnimation
8104 //==============================================================================
8105 static Standard_Integer VAnimation (Draw_Interpretor& theDI,
8106 Standard_Integer theArgNb,
8107 const char** theArgVec)
8109 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
8112 for (NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)>::Iterator
8113 anAnimIter (ViewerTest_AnimationTimelineMap); anAnimIter.More(); anAnimIter.Next())
8115 theDI << anAnimIter.Key() << " " << anAnimIter.Value()->Duration() << " sec\n";
8121 Message::SendFail ("Error: no active viewer");
8125 Standard_Integer anArgIter = 1;
8126 TCollection_AsciiString aNameArg (theArgVec[anArgIter++]);
8127 if (aNameArg.IsEmpty())
8129 Message::SendFail ("Syntax error: animation name is not defined");
8133 TCollection_AsciiString aNameArgLower = aNameArg;
8134 aNameArgLower.LowerCase();
8135 if (aNameArgLower == "-reset"
8136 || aNameArgLower == "-clear")
8138 ViewerTest_AnimationTimelineMap.Clear();
8141 else if (aNameArg.Value (1) == '-')
8143 Message::SendFail() << "Syntax error: invalid animation name '" << aNameArg << "'";
8147 const char* aNameSplitter = "/";
8148 Standard_Integer aSplitPos = aNameArg.Search (aNameSplitter);
8149 if (aSplitPos == -1)
8151 aNameSplitter = ".";
8152 aSplitPos = aNameArg.Search (aNameSplitter);
8155 // find existing or create a new animation by specified name within syntax "parent.child".
8156 Handle(AIS_Animation) aRootAnimation, aParentAnimation, anAnimation;
8157 for (; !aNameArg.IsEmpty();)
8159 TCollection_AsciiString aNameParent;
8160 if (aSplitPos != -1)
8162 if (aSplitPos == aNameArg.Length())
8164 Message::SendFail ("Syntax error: animation name is not defined");
8168 aNameParent = aNameArg.SubString ( 1, aSplitPos - 1);
8169 aNameArg = aNameArg.SubString (aSplitPos + 1, aNameArg.Length());
8171 aSplitPos = aNameArg.Search (aNameSplitter);
8175 aNameParent = aNameArg;
8179 if (anAnimation.IsNull())
8181 if (!ViewerTest_AnimationTimelineMap.Find (aNameParent, anAnimation))
8183 anAnimation = new AIS_Animation (aNameParent);
8184 ViewerTest_AnimationTimelineMap.Bind (aNameParent, anAnimation);
8186 aRootAnimation = anAnimation;
8190 aParentAnimation = anAnimation;
8191 anAnimation = aParentAnimation->Find (aNameParent);
8192 if (anAnimation.IsNull())
8194 anAnimation = new AIS_Animation (aNameParent);
8195 aParentAnimation->Add (anAnimation);
8200 if (anArgIter >= theArgNb)
8202 // just print the list of children
8203 for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anAnimIter (anAnimation->Children()); anAnimIter.More(); anAnimIter.Next())
8205 theDI << anAnimIter.Value()->Name() << " " << anAnimIter.Value()->Duration() << " sec\n";
8210 // animation parameters
8211 Standard_Boolean toPlay = Standard_False;
8212 Standard_Real aPlaySpeed = 1.0;
8213 Standard_Real aPlayStartTime = anAnimation->StartPts();
8214 Standard_Real aPlayDuration = anAnimation->Duration();
8215 Standard_Boolean isFreeCamera = Standard_False;
8216 Standard_Boolean isLockLoop = Standard_False;
8218 // video recording parameters
8219 TCollection_AsciiString aRecFile;
8220 Image_VideoParams aRecParams;
8222 Handle(V3d_View) aView = ViewerTest::CurrentView();
8223 for (; anArgIter < theArgNb; ++anArgIter)
8225 TCollection_AsciiString anArg (theArgVec[anArgIter]);
8228 if (anArg == "-reset"
8229 || anArg == "-clear")
8231 anAnimation->Clear();
8233 else if (anArg == "-remove"
8235 || anArg == "-delete")
8237 if (!aParentAnimation.IsNull())
8239 ViewerTest_AnimationTimelineMap.UnBind (anAnimation->Name());
8243 aParentAnimation->Remove (anAnimation);
8247 else if (anArg == "-play")
8249 toPlay = Standard_True;
8250 if (++anArgIter < theArgNb)
8252 if (*theArgVec[anArgIter] == '-')
8257 aPlayStartTime = Draw::Atof (theArgVec[anArgIter]);
8259 if (++anArgIter < theArgNb)
8261 if (*theArgVec[anArgIter] == '-')
8266 aPlayDuration = Draw::Atof (theArgVec[anArgIter]);
8270 else if (anArg == "-resume")
8272 toPlay = Standard_True;
8273 aPlayStartTime = anAnimation->ElapsedTime();
8274 if (++anArgIter < theArgNb)
8276 if (*theArgVec[anArgIter] == '-')
8282 aPlayDuration = Draw::Atof (theArgVec[anArgIter]);
8285 else if (anArg == "-playspeed"
8286 || anArg == "-speed")
8288 if (++anArgIter >= theArgNb)
8290 Message::SendFail() << "Syntax error at " << anArg << "";
8293 aPlaySpeed = Draw::Atof (theArgVec[anArgIter]);
8295 else if (anArg == "-lock"
8296 || anArg == "-lockloop"
8297 || anArg == "-playlockloop")
8299 isLockLoop = Standard_True;
8301 else if (anArg == "-freecamera"
8302 || anArg == "-playfreecamera"
8303 || anArg == "-freelook")
8305 isFreeCamera = Standard_True;
8307 // video recodring options
8308 else if (anArg == "-rec"
8309 || anArg == "-record")
8311 if (++anArgIter >= theArgNb)
8313 Message::SendFail() << "Syntax error at " << anArg;
8317 aRecFile = theArgVec[anArgIter];
8318 if (aRecParams.FpsNum <= 0)
8320 aRecParams.FpsNum = 24;
8323 if (anArgIter + 2 < theArgNb
8324 && *theArgVec[anArgIter + 1] != '-'
8325 && *theArgVec[anArgIter + 2] != '-')
8327 TCollection_AsciiString aWidthArg (theArgVec[anArgIter + 1]);
8328 TCollection_AsciiString aHeightArg (theArgVec[anArgIter + 2]);
8329 if (aWidthArg .IsIntegerValue()
8330 && aHeightArg.IsIntegerValue())
8332 aRecParams.Width = aWidthArg .IntegerValue();
8333 aRecParams.Height = aHeightArg.IntegerValue();
8338 else if (anArg == "-fps")
8340 if (++anArgIter >= theArgNb)
8342 Message::SendFail() << "Syntax error at " << anArg;
8346 TCollection_AsciiString aFpsArg (theArgVec[anArgIter]);
8347 Standard_Integer aSplitIndex = aFpsArg.FirstLocationInSet ("/", 1, aFpsArg.Length());
8348 if (aSplitIndex == 0)
8350 aRecParams.FpsNum = aFpsArg.IntegerValue();
8354 const TCollection_AsciiString aDenStr = aFpsArg.Split (aSplitIndex);
8355 aFpsArg.Split (aFpsArg.Length() - 1);
8356 const TCollection_AsciiString aNumStr = aFpsArg;
8357 aRecParams.FpsNum = aNumStr.IntegerValue();
8358 aRecParams.FpsDen = aDenStr.IntegerValue();
8359 if (aRecParams.FpsDen < 1)
8361 Message::SendFail() << "Syntax error at " << anArg;
8366 else if (anArg == "-format")
8368 if (++anArgIter >= theArgNb)
8370 Message::SendFail() << "Syntax error at " << anArg;
8373 aRecParams.Format = theArgVec[anArgIter];
8375 else if (anArg == "-pix_fmt"
8376 || anArg == "-pixfmt"
8377 || anArg == "-pixelformat")
8379 if (++anArgIter >= theArgNb)
8381 Message::SendFail() << "Syntax error at " << anArg;
8384 aRecParams.PixelFormat = theArgVec[anArgIter];
8386 else if (anArg == "-codec"
8387 || anArg == "-vcodec"
8388 || anArg == "-videocodec")
8390 if (++anArgIter >= theArgNb)
8392 Message::SendFail() << "Syntax error at " << anArg;
8395 aRecParams.VideoCodec = theArgVec[anArgIter];
8397 else if (anArg == "-crf"
8398 || anArg == "-preset"
8401 const TCollection_AsciiString aParamName = anArg.SubString (2, anArg.Length());
8402 if (++anArgIter >= theArgNb)
8404 Message::SendFail() << "Syntax error at " << anArg;
8408 aRecParams.VideoCodecParams.Bind (aParamName, theArgVec[anArgIter]);
8410 // animation definition options
8411 else if (anArg == "-start"
8412 || anArg == "-starttime"
8413 || anArg == "-startpts")
8415 if (++anArgIter >= theArgNb)
8417 Message::SendFail() << "Syntax error at " << anArg;
8421 anAnimation->SetStartPts (Draw::Atof (theArgVec[anArgIter]));
8422 aRootAnimation->UpdateTotalDuration();
8424 else if (anArg == "-end"
8425 || anArg == "-endtime"
8426 || anArg == "-endpts")
8428 if (++anArgIter >= theArgNb)
8430 Message::SendFail() << "Syntax error at " << anArg;
8434 anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]) - anAnimation->StartPts());
8435 aRootAnimation->UpdateTotalDuration();
8437 else if (anArg == "-dur"
8438 || anArg == "-duration")
8440 if (++anArgIter >= theArgNb)
8442 Message::SendFail() << "Syntax error at " << anArg;
8446 anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]));
8447 aRootAnimation->UpdateTotalDuration();
8449 else if (anArg == "-command"
8451 || anArg == "-invoke"
8453 || anArg == "-proc")
8455 if (++anArgIter >= theArgNb)
8457 Message::SendFail() << "Syntax error at " << anArg;
8461 Handle(ViewerTest_AnimationProc) aCmdAnimation = new ViewerTest_AnimationProc (anAnimation->Name(), &theDI, theArgVec[anArgIter]);
8462 replaceAnimation (aParentAnimation, anAnimation, aCmdAnimation);
8464 else if (anArg == "-objecttrsf"
8465 || anArg == "-objectransformation"
8466 || anArg == "-objtransformation"
8467 || anArg == "-objtrsf"
8468 || anArg == "-object"
8471 if (++anArgIter >= theArgNb)
8473 Message::SendFail() << "Syntax error at " << anArg;
8477 TCollection_AsciiString anObjName (theArgVec[anArgIter]);
8478 const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfAIS = GetMapOfAIS();
8479 Handle(AIS_InteractiveObject) anObject;
8480 if (!aMapOfAIS.Find2 (anObjName, anObject))
8482 Message::SendFail() << "Syntax error: wrong object name at " << anArg;
8486 gp_Trsf aTrsfs [2] = { anObject->LocalTransformation(), anObject->LocalTransformation() };
8487 gp_Quaternion aRotQuats[2] = { aTrsfs[0].GetRotation(), aTrsfs[1].GetRotation() };
8488 gp_XYZ aLocPnts [2] = { aTrsfs[0].TranslationPart(), aTrsfs[1].TranslationPart() };
8489 Standard_Real aScales [2] = { aTrsfs[0].ScaleFactor(), aTrsfs[1].ScaleFactor() };
8490 Standard_Boolean isTrsfSet = Standard_False;
8491 Standard_Integer aTrsfArgIter = anArgIter + 1;
8492 for (; aTrsfArgIter < theArgNb; ++aTrsfArgIter)
8494 TCollection_AsciiString aTrsfArg (theArgVec[aTrsfArgIter]);
8495 aTrsfArg.LowerCase();
8496 const Standard_Integer anIndex = aTrsfArg.EndsWith ("1") ? 0 : 1;
8497 if (aTrsfArg.StartsWith ("-rotation")
8498 || aTrsfArg.StartsWith ("-rot"))
8500 isTrsfSet = Standard_True;
8501 if (aTrsfArgIter + 4 >= theArgNb
8502 || !parseQuaternion (theArgVec + aTrsfArgIter + 1, aRotQuats[anIndex]))
8504 Message::SendFail() << "Syntax error at " << aTrsfArg;
8509 else if (aTrsfArg.StartsWith ("-location")
8510 || aTrsfArg.StartsWith ("-loc"))
8512 isTrsfSet = Standard_True;
8513 if (aTrsfArgIter + 3 >= theArgNb
8514 || !parseXYZ (theArgVec + aTrsfArgIter + 1, aLocPnts[anIndex]))
8516 Message::SendFail() << "Syntax error at " << aTrsfArg;
8521 else if (aTrsfArg.StartsWith ("-scale"))
8523 isTrsfSet = Standard_True;
8524 if (++aTrsfArgIter >= theArgNb)
8526 Message::SendFail() << "Syntax error at " << aTrsfArg;
8530 const TCollection_AsciiString aScaleStr (theArgVec[aTrsfArgIter]);
8531 if (!aScaleStr.IsRealValue())
8533 Message::SendFail() << "Syntax error at " << aTrsfArg;
8536 aScales[anIndex] = aScaleStr.RealValue();
8540 anArgIter = aTrsfArgIter - 1;
8546 Message::SendFail() << "Syntax error at " << anArg;
8549 else if (aTrsfArgIter >= theArgNb)
8551 anArgIter = theArgNb;
8554 aTrsfs[0].SetRotation (aRotQuats[0]);
8555 aTrsfs[1].SetRotation (aRotQuats[1]);
8556 aTrsfs[0].SetTranslationPart (aLocPnts[0]);
8557 aTrsfs[1].SetTranslationPart (aLocPnts[1]);
8558 aTrsfs[0].SetScaleFactor (aScales[0]);
8559 aTrsfs[1].SetScaleFactor (aScales[1]);
8561 Handle(AIS_AnimationObject) anObjAnimation = new AIS_AnimationObject (anAnimation->Name(), aCtx, anObject, aTrsfs[0], aTrsfs[1]);
8562 replaceAnimation (aParentAnimation, anAnimation, anObjAnimation);
8564 else if (anArg == "-viewtrsf"
8565 || anArg == "-view")
8567 Handle(AIS_AnimationCamera) aCamAnimation = Handle(AIS_AnimationCamera)::DownCast (anAnimation);
8568 if (aCamAnimation.IsNull())
8570 aCamAnimation = new AIS_AnimationCamera (anAnimation->Name(), aView);
8571 replaceAnimation (aParentAnimation, anAnimation, aCamAnimation);
8574 Handle(Graphic3d_Camera) aCams[2] =
8576 new Graphic3d_Camera (aCamAnimation->View()->Camera()),
8577 new Graphic3d_Camera (aCamAnimation->View()->Camera())
8580 Standard_Boolean isTrsfSet = Standard_False;
8581 Standard_Integer aViewArgIter = anArgIter + 1;
8582 for (; aViewArgIter < theArgNb; ++aViewArgIter)
8584 TCollection_AsciiString aViewArg (theArgVec[aViewArgIter]);
8585 aViewArg.LowerCase();
8586 const Standard_Integer anIndex = aViewArg.EndsWith("1") ? 0 : 1;
8587 if (aViewArg.StartsWith ("-scale"))
8589 isTrsfSet = Standard_True;
8590 if (++aViewArgIter >= theArgNb)
8592 Message::SendFail() << "Syntax error at " << anArg;
8596 const TCollection_AsciiString aScaleStr (theArgVec[aViewArgIter]);
8597 if (!aScaleStr.IsRealValue())
8599 Message::SendFail() << "Syntax error at " << aViewArg;
8602 Standard_Real aScale = aScaleStr.RealValue();
8603 aScale = aCamAnimation->View()->DefaultCamera()->Scale() / aScale;
8604 aCams[anIndex]->SetScale (aScale);
8606 else if (aViewArg.StartsWith ("-eye")
8607 || aViewArg.StartsWith ("-center")
8608 || aViewArg.StartsWith ("-at")
8609 || aViewArg.StartsWith ("-up"))
8611 isTrsfSet = Standard_True;
8613 if (aViewArgIter + 3 >= theArgNb
8614 || !parseXYZ (theArgVec + aViewArgIter + 1, anXYZ))
8616 Message::SendFail() << "Syntax error at " << aViewArg;
8621 if (aViewArg.StartsWith ("-eye"))
8623 aCams[anIndex]->SetEye (anXYZ);
8625 else if (aViewArg.StartsWith ("-center")
8626 || aViewArg.StartsWith ("-at"))
8628 aCams[anIndex]->SetCenter (anXYZ);
8630 else if (aViewArg.StartsWith ("-up"))
8632 aCams[anIndex]->SetUp (anXYZ);
8637 anArgIter = aViewArgIter - 1;
8643 Message::SendFail() << "Syntax error at " << anArg;
8646 else if (aViewArgIter >= theArgNb)
8648 anArgIter = theArgNb;
8651 aCamAnimation->SetCameraStart(aCams[0]);
8652 aCamAnimation->SetCameraEnd (aCams[1]);
8656 Message::SendFail() << "Syntax error at " << anArg;
8661 if (!toPlay && aRecFile.IsEmpty())
8666 // Start animation timeline and process frame updating.
8667 TheIsAnimating = Standard_True;
8668 const Standard_Boolean wasImmediateUpdate = aView->SetImmediateUpdate (Standard_False);
8669 Handle(Graphic3d_Camera) aCameraBack = new Graphic3d_Camera (aView->Camera());
8670 anAnimation->StartTimer (aPlayStartTime, aPlaySpeed, Standard_True, aPlayDuration <= 0.0);
8673 aView->Camera()->Copy (aCameraBack);
8676 const Standard_Real anUpperPts = aPlayStartTime + aPlayDuration;
8677 if (aRecParams.FpsNum <= 0)
8679 while (!anAnimation->IsStopped())
8681 aCameraBack->Copy (aView->Camera());
8682 const Standard_Real aPts = anAnimation->UpdateTimer();
8685 aView->Camera()->Copy (aCameraBack);
8688 if (aPts >= anUpperPts)
8690 anAnimation->Pause();
8694 if (aView->IsInvalidated())
8700 aView->RedrawImmediate();
8705 // handle user events
8706 theDI.Eval ("after 1 set waiter 1");
8707 theDI.Eval ("vwait waiter");
8709 if (!TheIsAnimating)
8711 anAnimation->Pause();
8717 if (aView->IsInvalidated())
8723 aView->RedrawImmediate();
8728 OSD_Timer aPerfTimer;
8731 Handle(Image_VideoRecorder) aRecorder;
8732 ImageFlipper aFlipper;
8733 Handle(Draw_ProgressIndicator) aProgress;
8734 if (!aRecFile.IsEmpty())
8736 if (aRecParams.Width <= 0
8737 || aRecParams.Height <= 0)
8739 aView->Window()->Size (aRecParams.Width, aRecParams.Height);
8742 aRecorder = new Image_VideoRecorder();
8743 if (!aRecorder->Open (aRecFile.ToCString(), aRecParams))
8745 Message::SendFail ("Error: failed to open video file for recording");
8749 aProgress = new Draw_ProgressIndicator (theDI, 1);
8752 // Manage frame-rated animation here
8753 Standard_Real aPts = aPlayStartTime;
8754 int64_t aNbFrames = 0;
8755 Message_ProgressSentry aPSentry (aProgress, "Video recording, sec", 0, Max (1, Standard_Integer(aPlayDuration / aPlaySpeed)), 1);
8756 Standard_Integer aSecondsProgress = 0;
8757 for (; aPts <= anUpperPts && aPSentry.More();)
8759 const Standard_Real aRecPts = aPlaySpeed * ((Standard_Real(aRecParams.FpsDen) / Standard_Real(aRecParams.FpsNum)) * Standard_Real(aNbFrames));
8760 aPts = aPlayStartTime + aRecPts;
8762 if (!anAnimation->Update (aPts))
8767 if (!aRecorder.IsNull())
8769 V3d_ImageDumpOptions aDumpParams;
8770 aDumpParams.Width = aRecParams.Width;
8771 aDumpParams.Height = aRecParams.Height;
8772 aDumpParams.BufferType = Graphic3d_BT_RGBA;
8773 aDumpParams.StereoOptions = V3d_SDO_MONO;
8774 aDumpParams.ToAdjustAspect = Standard_True;
8775 if (!aView->ToPixMap (aRecorder->ChangeFrame(), aDumpParams))
8777 Message::SendFail ("Error: view dump is failed");
8780 aFlipper.FlipY (aRecorder->ChangeFrame());
8781 if (!aRecorder->PushFrame())
8791 while (aSecondsProgress < Standard_Integer(aRecPts / aPlaySpeed))
8799 anAnimation->Stop();
8800 const Standard_Real aRecFps = Standard_Real(aNbFrames) / aPerfTimer.ElapsedTime();
8801 theDI << "Average FPS: " << aRecFps << "\n"
8802 << "Nb. Frames: " << Standard_Real(aNbFrames);
8807 aView->SetImmediateUpdate (wasImmediateUpdate);
8808 TheIsAnimating = Standard_False;
8813 //=======================================================================
8814 //function : VChangeSelected
8815 //purpose : Adds the shape to selection or remove one from it
8816 //=======================================================================
8817 static Standard_Integer VChangeSelected (Draw_Interpretor& di,
8818 Standard_Integer argc,
8823 di<<"Usage : " << argv[0] << " shape \n";
8827 TCollection_AsciiString aName(argv[1]);
8828 Handle(AIS_InteractiveObject) anAISObject;
8829 if (!GetMapOfAIS().Find2 (aName, anAISObject)
8830 || anAISObject.IsNull())
8832 di<<"Use 'vdisplay' before";
8836 ViewerTest::GetAISContext()->AddOrRemoveSelected(anAISObject, Standard_True);
8840 //=======================================================================
8841 //function : VNbSelected
8842 //purpose : Returns number of selected objects
8843 //=======================================================================
8844 static Standard_Integer VNbSelected (Draw_Interpretor& di,
8845 Standard_Integer argc,
8850 di << "Usage : " << argv[0] << "\n";
8853 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8854 if(aContext.IsNull())
8856 di << "use 'vinit' command before " << argv[0] << "\n";
8859 di << aContext->NbSelected() << "\n";
8863 //=======================================================================
8864 //function : VPurgeDisplay
8865 //purpose : Switches altialiasing on or off
8866 //=======================================================================
8867 static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
8868 Standard_Integer argc,
8873 di << "Usage : " << argv[0] << "\n";
8876 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8877 if (aContext.IsNull())
8879 di << "use 'vinit' command before " << argv[0] << "\n";
8883 di << aContext->PurgeDisplay() << "\n";
8887 //=======================================================================
8888 //function : VSetViewSize
8890 //=======================================================================
8891 static Standard_Integer VSetViewSize (Draw_Interpretor& di,
8892 Standard_Integer argc,
8895 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8896 if(aContext.IsNull())
8898 di << "use 'vinit' command before " << argv[0] << "\n";
8903 di<<"Usage : " << argv[0] << " Size\n";
8906 Standard_Real aSize = Draw::Atof (argv[1]);
8909 di<<"Bad Size value : " << aSize << "\n";
8913 Handle(V3d_View) aView = ViewerTest::CurrentView();
8914 aView->SetSize(aSize);
8918 //=======================================================================
8919 //function : VMoveView
8921 //=======================================================================
8922 static Standard_Integer VMoveView (Draw_Interpretor& di,
8923 Standard_Integer argc,
8926 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8927 if(aContext.IsNull())
8929 di << "use 'vinit' command before " << argv[0] << "\n";
8932 if(argc < 4 || argc > 5)
8934 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
8937 Standard_Real Dx = Draw::Atof (argv[1]);
8938 Standard_Real Dy = Draw::Atof (argv[2]);
8939 Standard_Real Dz = Draw::Atof (argv[3]);
8940 Standard_Boolean aStart = Standard_True;
8943 aStart = (Draw::Atoi (argv[4]) > 0);
8946 Handle(V3d_View) aView = ViewerTest::CurrentView();
8947 aView->Move(Dx,Dy,Dz,aStart);
8951 //=======================================================================
8952 //function : VTranslateView
8954 //=======================================================================
8955 static Standard_Integer VTranslateView (Draw_Interpretor& di,
8956 Standard_Integer argc,
8959 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8960 if(aContext.IsNull())
8962 di << "use 'vinit' command before " << argv[0] << "\n";
8965 if(argc < 4 || argc > 5)
8967 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
8970 Standard_Real Dx = Draw::Atof (argv[1]);
8971 Standard_Real Dy = Draw::Atof (argv[2]);
8972 Standard_Real Dz = Draw::Atof (argv[3]);
8973 Standard_Boolean aStart = Standard_True;
8976 aStart = (Draw::Atoi (argv[4]) > 0);
8979 Handle(V3d_View) aView = ViewerTest::CurrentView();
8980 aView->Translate(Dx,Dy,Dz,aStart);
8984 //=======================================================================
8985 //function : VTurnView
8987 //=======================================================================
8988 static Standard_Integer VTurnView (Draw_Interpretor& di,
8989 Standard_Integer argc,
8992 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8993 if(aContext.IsNull()) {
8994 di << "use 'vinit' command before " << argv[0] << "\n";
8997 if(argc < 4 || argc > 5){
8998 di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n";
9001 Standard_Real Ax = Draw::Atof (argv[1]);
9002 Standard_Real Ay = Draw::Atof (argv[2]);
9003 Standard_Real Az = Draw::Atof (argv[3]);
9004 Standard_Boolean aStart = Standard_True;
9007 aStart = (Draw::Atoi (argv[4]) > 0);
9010 Handle(V3d_View) aView = ViewerTest::CurrentView();
9011 aView->Turn(Ax,Ay,Az,aStart);
9015 //==============================================================================
9016 //function : VTextureEnv
9017 //purpose : ENables or disables environment mapping
9018 //==============================================================================
9019 class OCC_TextureEnv : public Graphic3d_TextureEnv
9022 OCC_TextureEnv(const Standard_CString FileName);
9023 OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName);
9024 void SetTextureParameters(const Standard_Boolean theRepeatFlag,
9025 const Standard_Boolean theModulateFlag,
9026 const Graphic3d_TypeOfTextureFilter theFilter,
9027 const Standard_ShortReal theXScale,
9028 const Standard_ShortReal theYScale,
9029 const Standard_ShortReal theXShift,
9030 const Standard_ShortReal theYShift,
9031 const Standard_ShortReal theAngle);
9032 DEFINE_STANDARD_RTTI_INLINE(OCC_TextureEnv,Graphic3d_TextureEnv)
9034 DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv)
9036 OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName)
9037 : Graphic3d_TextureEnv(theFileName)
9041 OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId)
9042 : Graphic3d_TextureEnv(theTexId)
9046 void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag,
9047 const Standard_Boolean theModulateFlag,
9048 const Graphic3d_TypeOfTextureFilter theFilter,
9049 const Standard_ShortReal theXScale,
9050 const Standard_ShortReal theYScale,
9051 const Standard_ShortReal theXShift,
9052 const Standard_ShortReal theYShift,
9053 const Standard_ShortReal theAngle)
9055 myParams->SetRepeat (theRepeatFlag);
9056 myParams->SetModulate (theModulateFlag);
9057 myParams->SetFilter (theFilter);
9058 myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale));
9059 myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift));
9060 myParams->SetRotation (theAngle);
9063 static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec)
9065 // get the active view
9066 Handle(V3d_View) aView = ViewerTest::CurrentView();
9069 Message::SendFail ("Error: no active viewer");
9073 // Checking the input arguments
9074 Standard_Boolean anEnableFlag = Standard_False;
9075 Standard_Boolean isOk = theArgNb >= 2;
9078 TCollection_AsciiString anEnableOpt(theArgVec[1]);
9079 anEnableFlag = anEnableOpt.IsEqual("on");
9080 isOk = anEnableFlag || anEnableOpt.IsEqual("off");
9084 isOk = (theArgNb == 3 || theArgNb == 11);
9087 TCollection_AsciiString aTextureOpt(theArgVec[2]);
9088 isOk = (!aTextureOpt.IsIntegerValue() ||
9089 (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN));
9091 if (isOk && theArgNb == 11)
9093 TCollection_AsciiString aRepeatOpt (theArgVec[3]),
9094 aModulateOpt(theArgVec[4]),
9095 aFilterOpt (theArgVec[5]),
9096 aSScaleOpt (theArgVec[6]),
9097 aTScaleOpt (theArgVec[7]),
9098 aSTransOpt (theArgVec[8]),
9099 aTTransOpt (theArgVec[9]),
9100 anAngleOpt (theArgVec[10]);
9101 isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) &&
9102 (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) &&
9103 (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) &&
9104 aSScaleOpt.IsRealValue() && aTScaleOpt.IsRealValue() &&
9105 aSTransOpt.IsRealValue() && aTTransOpt.IsRealValue() &&
9106 anAngleOpt.IsRealValue());
9113 Message::SendFail() << "Usage:\n"
9114 << theArgVec[0] << " off\n"
9115 << theArgVec[0] << " on {index_of_std_texture(0..7)|texture_file_name} [{clamp|repeat} {decal|modulate} {nearest|bilinear|trilinear} scale_s scale_t translation_s translation_t rotation_degrees]";
9121 TCollection_AsciiString aTextureOpt(theArgVec[2]);
9122 Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ?
9123 new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) :
9124 new OCC_TextureEnv(theArgVec[2]);
9128 TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]);
9129 aTexEnv->SetTextureParameters(
9130 aRepeatOpt. IsEqual("repeat"),
9131 aModulateOpt.IsEqual("modulate"),
9132 aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST :
9133 aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR :
9134 Graphic3d_TOTF_TRILINEAR,
9135 (Standard_ShortReal)Draw::Atof(theArgVec[6]),
9136 (Standard_ShortReal)Draw::Atof(theArgVec[7]),
9137 (Standard_ShortReal)Draw::Atof(theArgVec[8]),
9138 (Standard_ShortReal)Draw::Atof(theArgVec[9]),
9139 (Standard_ShortReal)Draw::Atof(theArgVec[10])
9142 aView->SetTextureEnv(aTexEnv);
9144 else // Disabling environment mapping
9146 Handle(Graphic3d_TextureEnv) aTexture;
9147 aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data
9156 typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
9158 //! Remove registered clipping plane from all views and objects.
9159 static void removePlane (MapOfPlanes& theRegPlanes,
9160 const TCollection_AsciiString& theName)
9162 Handle(Graphic3d_ClipPlane) aClipPlane;
9163 if (!theRegPlanes.Find (theName, aClipPlane))
9165 Message::SendWarning ("Warning: no such plane");
9169 theRegPlanes.UnBind (theName);
9170 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
9171 anIObjIt.More(); anIObjIt.Next())
9173 const Handle(AIS_InteractiveObject)& aPrs = anIObjIt.Key1();
9174 aPrs->RemoveClipPlane (aClipPlane);
9177 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
9178 aViewIt.More(); aViewIt.Next())
9180 const Handle(V3d_View)& aView = aViewIt.Key2();
9181 aView->RemoveClipPlane(aClipPlane);
9184 ViewerTest::RedrawAllViews();
9188 //===============================================================================================
9189 //function : VClipPlane
9191 //===============================================================================================
9192 static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
9194 // use short-cut for created clip planes map of created (or "registered by name") clip planes
9195 static MapOfPlanes aRegPlanes;
9199 for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More(); aPlaneIter.Next())
9201 theDi << aPlaneIter.Key() << " ";
9206 TCollection_AsciiString aCommand (theArgVec[1]);
9207 aCommand.LowerCase();
9208 const Handle(V3d_View)& anActiveView = ViewerTest::CurrentView();
9209 if (anActiveView.IsNull())
9211 Message::SendFail ("Error: no active viewer");
9215 // print maximum number of planes for current viewer
9216 if (aCommand == "-maxplanes"
9217 || aCommand == "maxplanes")
9219 theDi << anActiveView->Viewer()->Driver()->InquirePlaneLimit()
9220 << " plane slots provided by driver.\n";
9224 // create / delete plane instance
9225 if (aCommand == "-create"
9226 || aCommand == "create"
9227 || aCommand == "-delete"
9228 || aCommand == "delete"
9229 || aCommand == "-clone"
9230 || aCommand == "clone")
9234 Message::SendFail ("Syntax error: plane name is required");
9238 Standard_Boolean toCreate = aCommand == "-create"
9239 || aCommand == "create";
9240 Standard_Boolean toClone = aCommand == "-clone"
9241 || aCommand == "clone";
9242 Standard_Boolean toDelete = aCommand == "-delete"
9243 || aCommand == "delete";
9244 TCollection_AsciiString aPlane (theArgVec[2]);
9248 if (aRegPlanes.IsBound (aPlane))
9250 std::cout << "Warning: existing plane has been overridden.\n";
9255 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
9259 else if (toClone) // toClone
9261 if (!aRegPlanes.IsBound (aPlane))
9263 Message::SendFail ("Error: no such plane");
9266 else if (theArgsNb < 4)
9268 Message::SendFail ("Syntax error: enter name for new plane");
9272 TCollection_AsciiString aClone (theArgVec[3]);
9273 if (aRegPlanes.IsBound (aClone))
9275 Message::SendFail ("Error: plane name is in use");
9279 const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
9281 aRegPlanes.Bind (aClone, aClipPlane->Clone());
9291 for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More();)
9293 aPlane = aPlaneIter.Key();
9294 removePlane (aRegPlanes, aPlane);
9295 aPlaneIter = MapOfPlanes::Iterator (aRegPlanes);
9300 removePlane (aRegPlanes, aPlane);
9306 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
9311 // set / unset plane command
9312 if (aCommand == "set"
9313 || aCommand == "unset")
9317 Message::SendFail ("Syntax error: need more arguments");
9321 // redirect to new syntax
9322 NCollection_Array1<const char*> anArgVec (1, theArgsNb - 1);
9323 anArgVec.SetValue (1, theArgVec[0]);
9324 anArgVec.SetValue (2, theArgVec[2]);
9325 anArgVec.SetValue (3, aCommand == "set" ? "-set" : "-unset");
9326 for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
9328 anArgVec.SetValue (anIt, theArgVec[anIt]);
9331 return VClipPlane (theDi, anArgVec.Length(), &anArgVec.ChangeFirst());
9334 // change plane command
9335 TCollection_AsciiString aPlaneName;
9336 Handle(Graphic3d_ClipPlane) aClipPlane;
9337 Standard_Integer anArgIter = 0;
9338 if (aCommand == "-change"
9339 || aCommand == "change")
9341 // old syntax support
9344 Message::SendFail ("Syntax error: need more arguments");
9349 aPlaneName = theArgVec[2];
9350 if (!aRegPlanes.Find (aPlaneName, aClipPlane))
9352 Message::SendFail() << "Error: no such plane '" << aPlaneName << "'";
9356 else if (aRegPlanes.Find (theArgVec[1], aClipPlane))
9359 aPlaneName = theArgVec[1];
9364 aPlaneName = theArgVec[1];
9365 aClipPlane = new Graphic3d_ClipPlane();
9366 aRegPlanes.Bind (aPlaneName, aClipPlane);
9367 theDi << "Created new plane " << aPlaneName << ".\n";
9370 if (theArgsNb - anArgIter < 1)
9372 Message::SendFail ("Syntax error: need more arguments");
9376 for (; anArgIter < theArgsNb; ++anArgIter)
9378 const char** aChangeArgs = theArgVec + anArgIter;
9379 Standard_Integer aNbChangeArgs = theArgsNb - anArgIter;
9380 TCollection_AsciiString aChangeArg (aChangeArgs[0]);
9381 aChangeArg.LowerCase();
9383 Standard_Boolean toEnable = Standard_True;
9384 if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable))
9386 aClipPlane->SetOn (toEnable);
9388 else if (aChangeArg.StartsWith ("-equation")
9389 || aChangeArg.StartsWith ("equation"))
9391 if (aNbChangeArgs < 5)
9393 Message::SendFail ("Syntax error: need more arguments");
9397 Standard_Integer aSubIndex = 1;
9398 Standard_Integer aPrefixLen = 8 + (aChangeArg.Value (1) == '-' ? 1 : 0);
9399 if (aPrefixLen < aChangeArg.Length())
9401 TCollection_AsciiString aSubStr = aChangeArg.SubString (aPrefixLen + 1, aChangeArg.Length());
9402 if (!aSubStr.IsIntegerValue()
9403 || aSubStr.IntegerValue() <= 0)
9405 Message::SendFail() << "Syntax error: unknown argument '" << aChangeArg << "'";
9408 aSubIndex = aSubStr.IntegerValue();
9411 Standard_Real aCoeffA = Draw::Atof (aChangeArgs[1]);
9412 Standard_Real aCoeffB = Draw::Atof (aChangeArgs[2]);
9413 Standard_Real aCoeffC = Draw::Atof (aChangeArgs[3]);
9414 Standard_Real aCoeffD = Draw::Atof (aChangeArgs[4]);
9415 Handle(Graphic3d_ClipPlane) aSubPln = aClipPlane;
9416 for (Standard_Integer aSubPlaneIter = 1; aSubPlaneIter < aSubIndex; ++aSubPlaneIter)
9418 if (aSubPln->ChainNextPlane().IsNull())
9420 aSubPln->SetChainNextPlane (new Graphic3d_ClipPlane (*aSubPln));
9422 aSubPln = aSubPln->ChainNextPlane();
9424 aSubPln->SetChainNextPlane (Handle(Graphic3d_ClipPlane)());
9425 aSubPln->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD));
9428 else if ((aChangeArg == "-boxinterior"
9429 || aChangeArg == "-boxint"
9430 || aChangeArg == "-box")
9431 && aNbChangeArgs >= 7)
9433 Graphic3d_BndBox3d aBndBox;
9434 aBndBox.Add (Graphic3d_Vec3d (Draw::Atof (aChangeArgs[1]), Draw::Atof (aChangeArgs[2]), Draw::Atof (aChangeArgs[3])));
9435 aBndBox.Add (Graphic3d_Vec3d (Draw::Atof (aChangeArgs[4]), Draw::Atof (aChangeArgs[5]), Draw::Atof (aChangeArgs[6])));
9438 Standard_Integer aNbSubPlanes = 6;
9439 const Graphic3d_Vec3d aDirArray[6] =
9441 Graphic3d_Vec3d (-1, 0, 0),
9442 Graphic3d_Vec3d ( 1, 0, 0),
9443 Graphic3d_Vec3d ( 0,-1, 0),
9444 Graphic3d_Vec3d ( 0, 1, 0),
9445 Graphic3d_Vec3d ( 0, 0,-1),
9446 Graphic3d_Vec3d ( 0, 0, 1),
9448 Handle(Graphic3d_ClipPlane) aSubPln = aClipPlane;
9449 for (Standard_Integer aSubPlaneIter = 0; aSubPlaneIter < aNbSubPlanes; ++aSubPlaneIter)
9451 const Graphic3d_Vec3d& aDir = aDirArray[aSubPlaneIter];
9452 const Standard_Real aW = -aDir.Dot ((aSubPlaneIter % 2 == 1) ? aBndBox.CornerMax() : aBndBox.CornerMin());
9453 aSubPln->SetEquation (gp_Pln (aDir.x(), aDir.y(), aDir.z(), aW));
9454 if (aSubPlaneIter + 1 == aNbSubPlanes)
9456 aSubPln->SetChainNextPlane (Handle(Graphic3d_ClipPlane)());
9460 aSubPln->SetChainNextPlane (new Graphic3d_ClipPlane (*aSubPln));
9462 aSubPln = aSubPln->ChainNextPlane();
9465 else if (aChangeArg == "-capping"
9466 || aChangeArg == "capping")
9468 if (aNbChangeArgs < 2)
9470 Message::SendFail ("Syntax error: need more arguments");
9474 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9476 aClipPlane->SetCapping (toEnable);
9481 // just skip otherwise (old syntax)
9484 else if (aChangeArg == "-useobjectmaterial"
9485 || aChangeArg == "-useobjectmat"
9486 || aChangeArg == "-useobjmat"
9487 || aChangeArg == "-useobjmaterial")
9489 if (aNbChangeArgs < 2)
9491 Message::SendFail ("Syntax error: need more arguments");
9495 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9497 aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
9501 else if (aChangeArg == "-useobjecttexture"
9502 || aChangeArg == "-useobjecttex"
9503 || aChangeArg == "-useobjtexture"
9504 || aChangeArg == "-useobjtex")
9506 if (aNbChangeArgs < 2)
9508 Message::SendFail ("Syntax error: need more arguments");
9512 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9514 aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
9518 else if (aChangeArg == "-useobjectshader"
9519 || aChangeArg == "-useobjshader")
9521 if (aNbChangeArgs < 2)
9523 Message::SendFail ("Syntax error: need more arguments");
9527 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9529 aClipPlane->SetUseObjectShader (toEnable == Standard_True);
9533 else if (aChangeArg == "-color"
9534 || aChangeArg == "color")
9536 Quantity_Color aColor;
9537 Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
9542 Message::SendFail ("Syntax error: need more arguments");
9545 aClipPlane->SetCappingColor (aColor);
9546 anArgIter += aNbParsed;
9548 else if (aNbChangeArgs >= 1
9549 && (aChangeArg == "-material"
9550 || aChangeArg == "material"))
9553 Graphic3d_NameOfMaterial aMatName;
9554 if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeArgs[1], aMatName))
9556 Message::SendFail() << "Syntax error: unknown material '" << aChangeArgs[1] << "'";
9559 aClipPlane->SetCappingMaterial (aMatName);
9561 else if ((aChangeArg == "-transparency"
9562 || aChangeArg == "-transp")
9563 && aNbChangeArgs >= 2)
9565 TCollection_AsciiString aValStr (aChangeArgs[1]);
9566 Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect();
9567 if (aValStr.IsRealValue())
9569 Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
9570 aMat.SetTransparency ((float )aValStr.RealValue());
9571 anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto);
9572 aClipPlane->SetCappingMaterial (aMat);
9576 aValStr.LowerCase();
9577 Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto;
9578 if (aValStr == "opaque")
9580 aMode = Graphic3d_AlphaMode_Opaque;
9582 else if (aValStr == "mask")
9584 aMode = Graphic3d_AlphaMode_Mask;
9586 else if (aValStr == "blend")
9588 aMode = Graphic3d_AlphaMode_Blend;
9590 else if (aValStr == "blendauto")
9592 aMode = Graphic3d_AlphaMode_BlendAuto;
9596 Message::SendFail() << "Syntax error at '" << aValStr << "'";
9599 anAspect->SetAlphaMode (aMode);
9600 aClipPlane->SetCappingAspect (anAspect);
9604 else if (aChangeArg == "-texname"
9605 || aChangeArg == "texname")
9607 if (aNbChangeArgs < 2)
9609 Message::SendFail ("Syntax error: need more arguments");
9613 TCollection_AsciiString aTextureName (aChangeArgs[1]);
9614 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
9615 if (!aTexture->IsDone())
9617 aClipPlane->SetCappingTexture (NULL);
9621 aTexture->EnableModulate();
9622 aTexture->EnableRepeat();
9623 aClipPlane->SetCappingTexture (aTexture);
9627 else if (aChangeArg == "-texscale"
9628 || aChangeArg == "texscale")
9630 if (aClipPlane->CappingTexture().IsNull())
9632 Message::SendFail ("Error: no texture is set");
9636 if (aNbChangeArgs < 3)
9638 Message::SendFail ("Syntax error: need more arguments");
9642 Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
9643 Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
9644 aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
9647 else if (aChangeArg == "-texorigin"
9648 || aChangeArg == "texorigin") // texture origin
9650 if (aClipPlane->CappingTexture().IsNull())
9652 Message::SendFail ("Error: no texture is set");
9656 if (aNbChangeArgs < 3)
9658 Message::SendFail ("Syntax error: need more arguments");
9662 Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
9663 Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
9665 aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
9668 else if (aChangeArg == "-texrotate"
9669 || aChangeArg == "texrotate") // texture rotation
9671 if (aClipPlane->CappingTexture().IsNull())
9673 Message::SendFail ("Error: no texture is set");
9677 if (aNbChangeArgs < 2)
9679 Message::SendFail ("Syntax error: need more arguments");
9683 Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
9684 aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
9687 else if (aChangeArg == "-hatch"
9688 || aChangeArg == "hatch")
9690 if (aNbChangeArgs < 2)
9692 Message::SendFail ("Syntax error: need more arguments");
9696 TCollection_AsciiString aHatchStr (aChangeArgs[1]);
9697 aHatchStr.LowerCase();
9698 if (aHatchStr == "on")
9700 aClipPlane->SetCappingHatchOn();
9702 else if (aHatchStr == "off")
9704 aClipPlane->SetCappingHatchOff();
9708 aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
9712 else if (aChangeArg == "-delete"
9713 || aChangeArg == "delete")
9715 removePlane (aRegPlanes, aPlaneName);
9718 else if (aChangeArg == "-set"
9719 || aChangeArg == "-unset"
9720 || aChangeArg == "-setoverrideglobal")
9722 // set / unset plane command
9723 const Standard_Boolean toSet = aChangeArg.StartsWith ("-set");
9724 const Standard_Boolean toOverrideGlobal = aChangeArg == "-setoverrideglobal";
9725 Standard_Integer anIt = 1;
9726 for (; anIt < aNbChangeArgs; ++anIt)
9728 TCollection_AsciiString anEntityName (aChangeArgs[anIt]);
9729 if (anEntityName.IsEmpty()
9730 || anEntityName.Value (1) == '-')
9734 else if (!toOverrideGlobal
9735 && ViewerTest_myViews.IsBound1 (anEntityName))
9737 Handle(V3d_View) aView = ViewerTest_myViews.Find1 (anEntityName);
9740 aView->AddClipPlane (aClipPlane);
9744 aView->RemoveClipPlane (aClipPlane);
9748 else if (GetMapOfAIS().IsBound2 (anEntityName))
9750 Handle(AIS_InteractiveObject) aIObj = GetMapOfAIS().Find2 (anEntityName);
9753 aIObj->AddClipPlane (aClipPlane);
9757 aIObj->RemoveClipPlane (aClipPlane);
9759 if (!aIObj->ClipPlanes().IsNull())
9761 aIObj->ClipPlanes()->SetOverrideGlobal (toOverrideGlobal);
9766 Message::SendFail() << "Error: object/view '" << anEntityName << "' is not found";
9773 // apply to active view
9776 anActiveView->AddClipPlane (aClipPlane);
9780 anActiveView->RemoveClipPlane (aClipPlane);
9785 anArgIter = anArgIter + anIt - 1;
9790 Message::SendFail() << "Syntax error: unknown argument '" << aChangeArg << "'";
9795 ViewerTest::RedrawAllViews();
9799 //===============================================================================================
9800 //function : VZRange
9802 //===============================================================================================
9803 static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
9805 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
9807 if (aCurrentView.IsNull())
9809 Message::SendFail ("Error: no active viewer");
9813 Handle(Graphic3d_Camera) aCamera = aCurrentView->Camera();
9817 theDi << "ZNear: " << aCamera->ZNear() << "\n";
9818 theDi << "ZFar: " << aCamera->ZFar() << "\n";
9824 Standard_Real aNewZNear = Draw::Atof (theArgVec[1]);
9825 Standard_Real aNewZFar = Draw::Atof (theArgVec[2]);
9827 if (aNewZNear >= aNewZFar)
9829 Message::SendFail ("Syntax error: invalid arguments: znear should be less than zfar");
9833 if (!aCamera->IsOrthographic() && (aNewZNear <= 0.0 || aNewZFar <= 0.0))
9835 Message::SendFail ("Syntax error: invalid arguments: znear, zfar should be positive for perspective camera");
9839 aCamera->SetZRange (aNewZNear, aNewZFar);
9843 Message::SendFail ("Syntax error: wrong command arguments");
9847 aCurrentView->Redraw();
9852 //===============================================================================================
9853 //function : VAutoZFit
9855 //===============================================================================================
9856 static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
9858 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
9860 if (aCurrentView.IsNull())
9862 Message::SendFail ("Error: no active viewer");
9866 Standard_Real aScale = aCurrentView->AutoZFitScaleFactor();
9870 Message::SendFail ("Syntax error: wrong command arguments");
9876 theDi << "Auto z-fit mode: \n"
9877 << "On: " << (aCurrentView->AutoZFitMode() ? "enabled" : "disabled") << "\n"
9878 << "Scale: " << aScale << "\n";
9882 Standard_Boolean isOn = Draw::Atoi (theArgVec[1]) == 1;
9886 aScale = Draw::Atoi (theArgVec[2]);
9889 aCurrentView->SetAutoZFitMode (isOn, aScale);
9890 aCurrentView->Redraw();
9894 //! Auxiliary function to print projection type
9895 inline const char* projTypeName (Graphic3d_Camera::Projection theProjType)
9897 switch (theProjType)
9899 case Graphic3d_Camera::Projection_Orthographic: return "orthographic";
9900 case Graphic3d_Camera::Projection_Perspective: return "perspective";
9901 case Graphic3d_Camera::Projection_Stereo: return "stereoscopic";
9902 case Graphic3d_Camera::Projection_MonoLeftEye: return "monoLeftEye";
9903 case Graphic3d_Camera::Projection_MonoRightEye: return "monoRightEye";
9908 //===============================================================================================
9909 //function : VCamera
9911 //===============================================================================================
9912 static int VCamera (Draw_Interpretor& theDI,
9913 Standard_Integer theArgsNb,
9914 const char** theArgVec)
9916 Handle(V3d_View) aView = ViewerTest::CurrentView();
9919 Message::SendFail ("Error: no active viewer");
9923 Handle(Graphic3d_Camera) aCamera = aView->Camera();
9926 theDI << "ProjType: " << projTypeName (aCamera->ProjectionType()) << "\n";
9927 theDI << "FOVy: " << aCamera->FOVy() << "\n";
9928 theDI << "FOVx: " << aCamera->FOVx() << "\n";
9929 theDI << "FOV2d: " << aCamera->FOV2d() << "\n";
9930 theDI << "Distance: " << aCamera->Distance() << "\n";
9931 theDI << "IOD: " << aCamera->IOD() << "\n";
9932 theDI << "IODType: " << (aCamera->GetIODType() == Graphic3d_Camera::IODType_Absolute ? "absolute" : "relative") << "\n";
9933 theDI << "ZFocus: " << aCamera->ZFocus() << "\n";
9934 theDI << "ZFocusType: " << (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Absolute ? "absolute" : "relative") << "\n";
9938 TCollection_AsciiString aPrsName;
9939 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
9941 Standard_CString anArg = theArgVec[anArgIter];
9942 TCollection_AsciiString anArgCase (anArg);
9943 anArgCase.LowerCase();
9944 if (anArgCase == "-proj"
9945 || anArgCase == "-projection"
9946 || anArgCase == "-projtype"
9947 || anArgCase == "-projectiontype")
9949 theDI << projTypeName (aCamera->ProjectionType()) << " ";
9951 else if (anArgCase == "-ortho"
9952 || anArgCase == "-orthographic")
9954 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
9956 else if (anArgCase == "-persp"
9957 || anArgCase == "-perspective"
9958 || anArgCase == "-perspmono"
9959 || anArgCase == "-perspectivemono"
9960 || anArgCase == "-mono")
9962 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
9964 else if (anArgCase == "-stereo"
9965 || anArgCase == "-stereoscopic"
9966 || anArgCase == "-perspstereo"
9967 || anArgCase == "-perspectivestereo")
9969 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
9971 else if (anArgCase == "-left"
9972 || anArgCase == "-lefteye"
9973 || anArgCase == "-monoleft"
9974 || anArgCase == "-monolefteye"
9975 || anArgCase == "-perpsleft"
9976 || anArgCase == "-perpslefteye")
9978 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
9980 else if (anArgCase == "-right"
9981 || anArgCase == "-righteye"
9982 || anArgCase == "-monoright"
9983 || anArgCase == "-monorighteye"
9984 || anArgCase == "-perpsright")
9986 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
9988 else if (anArgCase == "-dist"
9989 || anArgCase == "-distance")
9991 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
9992 if (anArgValue != NULL
9993 && *anArgValue != '-')
9996 aCamera->SetDistance (Draw::Atof (anArgValue));
9999 theDI << aCamera->Distance() << " ";
10001 else if (anArgCase == "-iod")
10003 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
10004 if (anArgValue != NULL
10005 && *anArgValue != '-')
10008 aCamera->SetIOD (aCamera->GetIODType(), Draw::Atof (anArgValue));
10011 theDI << aCamera->IOD() << " ";
10013 else if (anArgCase == "-iodtype")
10015 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
10016 TCollection_AsciiString anValueCase (anArgValue);
10017 anValueCase.LowerCase();
10018 if (anValueCase == "abs"
10019 || anValueCase == "absolute")
10022 aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD());
10025 else if (anValueCase == "rel"
10026 || anValueCase == "relative")
10029 aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD());
10032 else if (*anArgValue != '-')
10034 Message::SendFail() << "Error: unknown IOD type '" << anArgValue << "'";
10037 switch (aCamera->GetIODType())
10039 case Graphic3d_Camera::IODType_Absolute: theDI << "absolute "; break;
10040 case Graphic3d_Camera::IODType_Relative: theDI << "relative "; break;
10043 else if (anArgCase == "-zfocus")
10045 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
10046 if (anArgValue != NULL
10047 && *anArgValue != '-')
10050 aCamera->SetZFocus (aCamera->ZFocusType(), Draw::Atof (anArgValue));
10053 theDI << aCamera->ZFocus() << " ";
10055 else if (anArgCase == "-zfocustype")
10057 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
10058 TCollection_AsciiString anValueCase (anArgValue);
10059 anValueCase.LowerCase();
10060 if (anValueCase == "abs"
10061 || anValueCase == "absolute")
10064 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus());
10067 else if (anValueCase == "rel"
10068 || anValueCase == "relative")
10071 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus());
10074 else if (*anArgValue != '-')
10076 Message::SendFail() << "Error: unknown ZFocus type '" << anArgValue << "'";
10079 switch (aCamera->ZFocusType())
10081 case Graphic3d_Camera::FocusType_Absolute: theDI << "absolute "; break;
10082 case Graphic3d_Camera::FocusType_Relative: theDI << "relative "; break;
10085 else if (anArgCase == "-lockzup"
10086 || anArgCase == "-turntable")
10088 bool toLockUp = true;
10089 if (++anArgIter < theArgsNb
10090 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toLockUp))
10094 ViewerTest::CurrentEventManager()->SetLockOrbitZUp (toLockUp);
10096 else if (anArgCase == "-fov"
10097 || anArgCase == "-fovy"
10098 || anArgCase == "-fovx"
10099 || anArgCase == "-fov2d")
10101 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
10102 if (anArgValue != NULL
10103 && *anArgValue != '-')
10106 if (anArgCase == "-fov2d")
10108 aCamera->SetFOV2d (Draw::Atof (anArgValue));
10110 else if (anArgCase == "-fovx")
10112 aCamera->SetFOVy (Draw::Atof (anArgValue) / aCamera->Aspect());///
10116 aCamera->SetFOVy (Draw::Atof (anArgValue));
10120 if (anArgCase == "-fov2d")
10122 theDI << aCamera->FOV2d() << " ";
10124 else if (anArgCase == "-fovx")
10126 theDI << aCamera->FOVx() << " ";
10130 theDI << aCamera->FOVy() << " ";
10133 else if (anArgIter + 1 < theArgsNb
10134 && anArgCase == "-xrpose")
10136 TCollection_AsciiString anXRArg (theArgVec[++anArgIter]);
10137 anXRArg.LowerCase();
10138 if (anXRArg == "base")
10140 aCamera = aView->View()->BaseXRCamera();
10142 else if (anXRArg == "head")
10144 aCamera = aView->View()->PosedXRCamera();
10148 Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'";
10151 if (aCamera.IsNull())
10153 Message::SendFail() << "Error: undefined XR pose";
10156 if (aView->AutoZFitMode())
10158 const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues (false);
10159 const Bnd_Box aGraphicBox = aView->View()->MinMaxValues (true);
10160 aCamera->ZFitAll (aView->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox);
10163 else if (aPrsName.IsEmpty()
10164 && !anArgCase.StartsWith ("-"))
10170 Message::SendFail() << "Error: unknown argument '" << anArg << "'";
10175 if (aPrsName.IsEmpty()
10181 if (!aPrsName.IsEmpty())
10183 Handle(AIS_CameraFrustum) aCameraFrustum;
10184 if (GetMapOfAIS().IsBound2 (aPrsName))
10186 // find existing object
10187 aCameraFrustum = Handle(AIS_CameraFrustum)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
10188 if (aCameraFrustum.IsNull())
10190 Message::SendFail() << "Error: object '" << aPrsName << "'is already defined and is not a camera frustum";
10195 if (aCameraFrustum.IsNull())
10197 aCameraFrustum = new AIS_CameraFrustum();
10201 // not include displayed object of old camera frustum in the new one.
10202 ViewerTest::GetAISContext()->Erase (aCameraFrustum, false);
10205 aCameraFrustum->SetCameraFrustum (aCamera);
10207 ViewerTest::Display (aPrsName, aCameraFrustum);
10213 //! Parse stereo output mode
10214 inline Standard_Boolean parseStereoMode (Standard_CString theArg,
10215 Graphic3d_StereoMode& theMode)
10217 TCollection_AsciiString aFlag (theArg);
10219 if (aFlag == "quadbuffer")
10221 theMode = Graphic3d_StereoMode_QuadBuffer;
10223 else if (aFlag == "anaglyph")
10225 theMode = Graphic3d_StereoMode_Anaglyph;
10227 else if (aFlag == "row"
10228 || aFlag == "rowinterlaced")
10230 theMode = Graphic3d_StereoMode_RowInterlaced;
10232 else if (aFlag == "col"
10233 || aFlag == "colinterlaced"
10234 || aFlag == "columninterlaced")
10236 theMode = Graphic3d_StereoMode_ColumnInterlaced;
10238 else if (aFlag == "chess"
10239 || aFlag == "chessboard")
10241 theMode = Graphic3d_StereoMode_ChessBoard;
10243 else if (aFlag == "sbs"
10244 || aFlag == "sidebyside")
10246 theMode = Graphic3d_StereoMode_SideBySide;
10248 else if (aFlag == "ou"
10249 || aFlag == "overunder")
10251 theMode = Graphic3d_StereoMode_OverUnder;
10253 else if (aFlag == "pageflip"
10254 || aFlag == "softpageflip")
10256 theMode = Graphic3d_StereoMode_SoftPageFlip;
10258 else if (aFlag == "openvr"
10261 theMode = Graphic3d_StereoMode_OpenVR;
10265 return Standard_False;
10267 return Standard_True;
10270 //! Parse anaglyph filter
10271 inline Standard_Boolean parseAnaglyphFilter (Standard_CString theArg,
10272 Graphic3d_RenderingParams::Anaglyph& theFilter)
10274 TCollection_AsciiString aFlag (theArg);
10276 if (aFlag == "redcyansimple")
10278 theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
10280 else if (aFlag == "redcyan"
10281 || aFlag == "redcyanoptimized")
10283 theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized;
10285 else if (aFlag == "yellowbluesimple")
10287 theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple;
10289 else if (aFlag == "yellowblue"
10290 || aFlag == "yellowblueoptimized")
10292 theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized;
10294 else if (aFlag == "greenmagenta"
10295 || aFlag == "greenmagentasimple")
10297 theFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple;
10301 return Standard_False;
10303 return Standard_True;
10306 //==============================================================================
10307 //function : VStereo
10309 //==============================================================================
10311 static int VStereo (Draw_Interpretor& theDI,
10312 Standard_Integer theArgNb,
10313 const char** theArgVec)
10315 Handle(V3d_View) aView = ViewerTest::CurrentView();
10318 if (aView.IsNull())
10320 Message::SendFail ("Error: no active viewer");
10324 Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
10325 theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
10328 TCollection_AsciiString aMode;
10329 switch (aView->RenderingParams().StereoMode)
10331 case Graphic3d_StereoMode_QuadBuffer : aMode = "quadBuffer"; break;
10332 case Graphic3d_StereoMode_RowInterlaced : aMode = "rowInterlaced"; break;
10333 case Graphic3d_StereoMode_ColumnInterlaced : aMode = "columnInterlaced"; break;
10334 case Graphic3d_StereoMode_ChessBoard : aMode = "chessBoard"; break;
10335 case Graphic3d_StereoMode_SideBySide : aMode = "sideBySide"; break;
10336 case Graphic3d_StereoMode_OverUnder : aMode = "overUnder"; break;
10337 case Graphic3d_StereoMode_SoftPageFlip : aMode = "softpageflip"; break;
10338 case Graphic3d_StereoMode_OpenVR : aMode = "openVR"; break;
10339 case Graphic3d_StereoMode_Anaglyph :
10340 aMode = "anaglyph";
10341 switch (aView->RenderingParams().AnaglyphFilter)
10343 case Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple : aMode.AssignCat (" (redCyanSimple)"); break;
10344 case Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized : aMode.AssignCat (" (redCyan)"); break;
10345 case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple : aMode.AssignCat (" (yellowBlueSimple)"); break;
10346 case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized: aMode.AssignCat (" (yellowBlue)"); break;
10347 case Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple : aMode.AssignCat (" (greenMagentaSimple)"); break;
10352 theDI << "Mode " << aMode << "\n";
10357 Handle(Graphic3d_Camera) aCamera;
10358 Graphic3d_RenderingParams* aParams = NULL;
10359 Graphic3d_StereoMode aMode = Graphic3d_StereoMode_QuadBuffer;
10360 if (!aView.IsNull())
10362 aParams = &aView->ChangeRenderingParams();
10363 aMode = aParams->StereoMode;
10364 aCamera = aView->Camera();
10367 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
10368 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
10370 Standard_CString anArg = theArgVec[anArgIter];
10371 TCollection_AsciiString aFlag (anArg);
10373 if (anUpdateTool.parseRedrawMode (aFlag))
10377 else if (aFlag == "0"
10380 if (++anArgIter < theArgNb)
10382 Message::SendFail ("Error: wrong number of arguments");
10386 if (!aCamera.IsNull()
10387 && aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
10389 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
10391 ViewerTest_myDefaultCaps.contextStereo = Standard_False;
10394 else if (aFlag == "1"
10397 if (++anArgIter < theArgNb)
10399 Message::SendFail ("Error: wrong number of arguments");
10403 if (!aCamera.IsNull())
10405 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
10407 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
10408 if (aParams->StereoMode != Graphic3d_StereoMode_OpenVR)
10413 else if (aFlag == "-reverse"
10414 || aFlag == "-reversed"
10415 || aFlag == "-swap")
10417 Standard_Boolean toEnable = Standard_True;
10418 if (++anArgIter < theArgNb
10419 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
10423 aParams->ToReverseStereo = toEnable;
10425 else if (aFlag == "-noreverse"
10426 || aFlag == "-noswap")
10428 Standard_Boolean toDisable = Standard_True;
10429 if (++anArgIter < theArgNb
10430 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
10434 aParams->ToReverseStereo = !toDisable;
10436 else if (aFlag == "-mode"
10437 || aFlag == "-stereomode")
10439 if (++anArgIter >= theArgNb
10440 || !parseStereoMode (theArgVec[anArgIter], aMode))
10442 Message::SendFail() << "Syntax error at '" << anArg << "'";
10446 if (aMode == Graphic3d_StereoMode_QuadBuffer)
10448 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
10451 else if (aFlag == "-anaglyph"
10452 || aFlag == "-anaglyphfilter")
10454 Graphic3d_RenderingParams::Anaglyph aFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
10455 if (++anArgIter >= theArgNb
10456 || !parseAnaglyphFilter (theArgVec[anArgIter], aFilter))
10458 Message::SendFail() << "Syntax error at '" << anArg << "'";
10462 aMode = Graphic3d_StereoMode_Anaglyph;
10463 aParams->AnaglyphFilter = aFilter;
10465 else if (parseStereoMode (anArg, aMode)) // short syntax
10467 if (aMode == Graphic3d_StereoMode_QuadBuffer)
10469 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
10472 else if (anArgIter + 1 < theArgNb
10473 && aFlag == "-hmdfov2d")
10475 aParams->HmdFov2d = (float )Draw::Atof (theArgVec[++anArgIter]);
10476 if (aParams->HmdFov2d < 10.0f
10477 || aParams->HmdFov2d > 180.0f)
10479 Message::SendFail() << "Error: FOV is out of range";
10483 else if (aFlag == "-mirror"
10484 || aFlag == "-mirrorcomposer")
10486 Standard_Boolean toEnable = Standard_True;
10487 if (++anArgIter < theArgNb
10488 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
10492 aParams->ToMirrorComposer = toEnable;
10494 else if (anArgIter + 1 < theArgNb
10495 && (aFlag == "-unitfactor"
10496 || aFlag == "-unitscale"))
10498 aView->View()->SetUnitFactor (Draw::Atof (theArgVec[++anArgIter]));
10502 Message::SendFail() << "Syntax error at '" << anArg << "'";
10507 if (!aView.IsNull())
10509 aParams->StereoMode = aMode;
10510 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
10511 if (aParams->StereoMode == Graphic3d_StereoMode_OpenVR)
10513 // initiate implicit continuous rendering
10514 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
10520 //===============================================================================================
10521 //function : VDefaults
10523 //===============================================================================================
10524 static int VDefaults (Draw_Interpretor& theDi,
10525 Standard_Integer theArgsNb,
10526 const char** theArgVec)
10528 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
10531 Message::SendFail ("Error: no active viewer");
10535 Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer();
10538 if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE)
10540 theDi << "DeflType: relative\n"
10541 << "DeviationCoeff: " << aDefParams->DeviationCoefficient() << "\n";
10545 theDi << "DeflType: absolute\n"
10546 << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n";
10548 theDi << "AngularDeflection: " << (180.0 * aDefParams->DeviationAngle() / M_PI) << "\n";
10549 theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n";
10553 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
10555 TCollection_AsciiString anArg (theArgVec[anArgIter]);
10557 if (anArg == "-ABSDEFL"
10558 || anArg == "-ABSOLUTEDEFLECTION"
10559 || anArg == "-DEFL"
10560 || anArg == "-DEFLECTION")
10562 if (++anArgIter >= theArgsNb)
10564 Message::SendFail() << "Syntax error at " << anArg;
10567 aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
10568 aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter]));
10570 else if (anArg == "-RELDEFL"
10571 || anArg == "-RELATIVEDEFLECTION"
10572 || anArg == "-DEVCOEFF"
10573 || anArg == "-DEVIATIONCOEFF"
10574 || anArg == "-DEVIATIONCOEFFICIENT")
10576 if (++anArgIter >= theArgsNb)
10578 Message::SendFail() << "Syntax error at " << anArg;
10581 aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
10582 aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter]));
10584 else if (anArg == "-ANGDEFL"
10585 || anArg == "-ANGULARDEFL"
10586 || anArg == "-ANGULARDEFLECTION")
10588 if (++anArgIter >= theArgsNb)
10590 Message::SendFail() << "Syntax error at " << anArg;
10593 aDefParams->SetDeviationAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0);
10595 else if (anArg == "-AUTOTR"
10596 || anArg == "-AUTOTRIANG"
10597 || anArg == "-AUTOTRIANGULATION")
10600 bool toTurnOn = true;
10601 if (anArgIter >= theArgsNb
10602 || !ViewerTest::ParseOnOff (theArgVec[anArgIter], toTurnOn))
10604 Message::SendFail() << "Syntax error at '" << anArg << "'";
10607 aDefParams->SetAutoTriangulation (toTurnOn);
10611 Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'";
10619 //! Auxiliary method
10620 inline void addLight (const Handle(V3d_Light)& theLightNew,
10621 const Graphic3d_ZLayerId theLayer,
10622 const Standard_Boolean theIsGlobal)
10624 if (theLightNew.IsNull())
10629 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
10630 if (theLayer == Graphic3d_ZLayerId_UNKNOWN)
10632 aViewer->AddLight (theLightNew);
10635 aViewer->SetLightOn (theLightNew);
10639 ViewerTest::CurrentView()->SetLightOn (theLightNew);
10644 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (theLayer);
10645 if (aSettings.Lights().IsNull())
10647 aSettings.SetLights (new Graphic3d_LightSet());
10649 aSettings.Lights()->Add (theLightNew);
10650 aViewer->SetZLayerSettings (theLayer, aSettings);
10654 //! Auxiliary method
10655 inline Standard_Integer getLightId (const TCollection_AsciiString& theArgNext)
10657 TCollection_AsciiString anArgNextCase (theArgNext);
10658 anArgNextCase.UpperCase();
10659 if (anArgNextCase.Length() > 5
10660 && anArgNextCase.SubString (1, 5).IsEqual ("LIGHT"))
10662 return theArgNext.SubString (6, theArgNext.Length()).IntegerValue();
10666 return theArgNext.IntegerValue();
10670 //===============================================================================================
10671 //function : VLight
10673 //===============================================================================================
10674 static int VLight (Draw_Interpretor& theDi,
10675 Standard_Integer theArgsNb,
10676 const char** theArgVec)
10678 Handle(V3d_View) aView = ViewerTest::CurrentView();
10679 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
10681 || aViewer.IsNull())
10683 Message::SendFail ("Error: no active viewer");
10687 Standard_Real anXYZ[3] = {};
10688 Standard_Real anAtten[2] = {};
10691 // print lights info
10692 Standard_Integer aLightId = 0;
10693 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightId)
10695 Handle(V3d_Light) aLight = aLightIter.Value();
10696 const Quantity_Color aColor = aLight->Color();
10697 theDi << "Light #" << aLightId
10698 << (!aLight->Name().IsEmpty() ? (TCollection_AsciiString(" ") + aLight->Name()) : "")
10699 << " [" << aLight->GetId() << "]" << "\n";
10700 switch (aLight->Type())
10704 theDi << " Type: Ambient\n";
10705 theDi << " Intensity: " << aLight->Intensity() << "\n";
10708 case V3d_DIRECTIONAL:
10710 theDi << " Type: Directional\n";
10711 theDi << " Intensity: " << aLight->Intensity() << "\n";
10712 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
10713 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
10714 aLight->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
10715 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10718 case V3d_POSITIONAL:
10720 theDi << " Type: Positional\n";
10721 theDi << " Intensity: " << aLight->Intensity() << "\n";
10722 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
10723 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
10724 aLight->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
10725 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10726 aLight->Attenuation (anAtten[0], anAtten[1]);
10727 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
10728 theDi << " Range: " << aLight->Range() << "\n";
10733 theDi << " Type: Spot\n";
10734 theDi << " Intensity: " << aLight->Intensity() << "\n";
10735 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
10736 aLight->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
10737 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10738 aLight->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
10739 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10740 aLight->Attenuation (anAtten[0], anAtten[1]);
10741 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
10742 theDi << " Angle: " << (aLight->Angle() * 180.0 / M_PI) << "\n";
10743 theDi << " Exponent: " << aLight->Concentration() << "\n";
10744 theDi << " Range: " << aLight->Range() << "\n";
10749 theDi << " Type: UNKNOWN\n";
10753 theDi << " Color: " << aColor.Red() << ", " << aColor.Green() << ", " << aColor.Blue() << " [" << Quantity_Color::StringName (aColor.Name()) << "]\n";
10757 Handle(V3d_Light) aLightNew;
10758 Handle(V3d_Light) aLightOld;
10759 Graphic3d_ZLayerId aLayer = Graphic3d_ZLayerId_UNKNOWN;
10760 Standard_Boolean isGlobal = Standard_True;
10761 Standard_Boolean toCreate = Standard_False;
10762 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
10763 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
10765 Handle(V3d_Light) aLightCurr = aLightNew.IsNull() ? aLightOld : aLightNew;
10767 TCollection_AsciiString aName, aValue;
10768 const TCollection_AsciiString anArg (theArgVec[anArgIt]);
10769 TCollection_AsciiString anArgCase (anArg);
10770 anArgCase.UpperCase();
10771 if (anUpdateTool.parseRedrawMode (anArg))
10776 if (anArgCase.IsEqual ("NEW")
10777 || anArgCase.IsEqual ("ADD")
10778 || anArgCase.IsEqual ("CREATE")
10779 || anArgCase.IsEqual ("-NEW")
10780 || anArgCase.IsEqual ("-ADD")
10781 || anArgCase.IsEqual ("-CREATE"))
10783 toCreate = Standard_True;
10785 else if (anArgCase.IsEqual ("-LAYER")
10786 || anArgCase.IsEqual ("-ZLAYER"))
10788 if (++anArgIt >= theArgsNb)
10790 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10794 TCollection_AsciiString aValStr (theArgVec[anArgIt]);
10795 aValStr.LowerCase();
10796 if (aValStr == "default"
10797 || aValStr == "def")
10799 aLayer = Graphic3d_ZLayerId_Default;
10801 else if (aValStr == "top")
10803 aLayer = Graphic3d_ZLayerId_Top;
10805 else if (aValStr == "topmost")
10807 aLayer = Graphic3d_ZLayerId_Topmost;
10809 else if (aValStr == "toposd"
10810 || aValStr == "osd")
10812 aLayer = Graphic3d_ZLayerId_TopOSD;
10814 else if (aValStr == "botosd"
10815 || aValStr == "bottom")
10817 aLayer = Graphic3d_ZLayerId_BotOSD;
10819 else if (aValStr.IsIntegerValue())
10821 aLayer = Draw::Atoi (theArgVec[anArgIt]);
10825 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10829 else if (anArgCase.IsEqual ("GLOB")
10830 || anArgCase.IsEqual ("GLOBAL")
10831 || anArgCase.IsEqual ("-GLOB")
10832 || anArgCase.IsEqual ("-GLOBAL"))
10834 isGlobal = Standard_True;
10836 else if (anArgCase.IsEqual ("LOC")
10837 || anArgCase.IsEqual ("LOCAL")
10838 || anArgCase.IsEqual ("-LOC")
10839 || anArgCase.IsEqual ("-LOCAL"))
10841 isGlobal = Standard_False;
10843 else if (anArgCase.IsEqual ("DEF")
10844 || anArgCase.IsEqual ("DEFAULTS")
10845 || anArgCase.IsEqual ("-DEF")
10846 || anArgCase.IsEqual ("-DEFAULTS"))
10848 toCreate = Standard_False;
10849 aViewer->SetDefaultLights();
10851 else if (anArgCase.IsEqual ("CLR")
10852 || anArgCase.IsEqual ("CLEAR")
10853 || anArgCase.IsEqual ("-CLR")
10854 || anArgCase.IsEqual ("-CLEAR"))
10856 toCreate = Standard_False;
10858 TColStd_SequenceOfInteger aLayers;
10859 aViewer->GetAllZLayers (aLayers);
10860 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
10862 if (aLayeriter.Value() == aLayer
10863 || aLayer == Graphic3d_ZLayerId_UNKNOWN)
10865 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
10866 aSettings.SetLights (Handle(Graphic3d_LightSet)());
10867 aViewer->SetZLayerSettings (aLayeriter.Value(), aSettings);
10868 if (aLayer != Graphic3d_ZLayerId_UNKNOWN)
10875 if (aLayer == Graphic3d_ZLayerId_UNKNOWN)
10877 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More();)
10879 Handle(V3d_Light) aLight = aLightIter.Value();
10880 aViewer->DelLight (aLight);
10881 aLightIter = aView->ActiveLightIterator();
10885 else if (anArgCase.IsEqual ("AMB")
10886 || anArgCase.IsEqual ("AMBIENT")
10887 || anArgCase.IsEqual ("AMBLIGHT"))
10891 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10895 addLight (aLightNew, aLayer, isGlobal);
10896 toCreate = Standard_False;
10897 aLightNew = new V3d_AmbientLight();
10899 else if (anArgCase.IsEqual ("DIRECTIONAL")
10900 || anArgCase.IsEqual ("DIRLIGHT"))
10904 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10908 addLight (aLightNew, aLayer, isGlobal);
10909 toCreate = Standard_False;
10910 aLightNew = new V3d_DirectionalLight();
10912 else if (anArgCase.IsEqual ("SPOT")
10913 || anArgCase.IsEqual ("SPOTLIGHT"))
10917 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10921 addLight (aLightNew, aLayer, isGlobal);
10922 toCreate = Standard_False;
10923 aLightNew = new V3d_SpotLight (gp_Pnt (0.0, 0.0, 0.0));
10925 else if (anArgCase.IsEqual ("POSLIGHT")
10926 || anArgCase.IsEqual ("POSITIONAL"))
10930 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10934 addLight (aLightNew, aLayer, isGlobal);
10935 toCreate = Standard_False;
10936 aLightNew = new V3d_PositionalLight (gp_Pnt (0.0, 0.0, 0.0));
10938 else if (anArgCase.IsEqual ("CHANGE")
10939 || anArgCase.IsEqual ("-CHANGE"))
10941 if (++anArgIt >= theArgsNb)
10943 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10947 addLight (aLightNew, aLayer, isGlobal);
10948 aLightNew.Nullify();
10949 const Standard_Integer aLightId = getLightId (theArgVec[anArgIt]);
10950 Standard_Integer aLightIt = 0;
10951 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt)
10953 if (aLightIt == aLightId)
10955 aLightOld = aLightIter.Value();
10960 if (aLightOld.IsNull())
10962 Message::SendFail() << "Error: Light " << theArgVec[anArgIt] << " is undefined";
10966 else if (anArgCase.IsEqual ("DEL")
10967 || anArgCase.IsEqual ("DELETE")
10968 || anArgCase.IsEqual ("-DEL")
10969 || anArgCase.IsEqual ("-DELETE"))
10971 Handle(V3d_Light) aLightDel;
10972 if (++anArgIt >= theArgsNb)
10974 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10978 const TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
10979 const Standard_Integer aLightDelId = getLightId (theArgVec[anArgIt]);
10980 Standard_Integer aLightIt = 0;
10981 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt)
10983 aLightDel = aLightIter.Value();
10984 if (aLightIt == aLightDelId)
10989 if (aLightDel.IsNull())
10994 TColStd_SequenceOfInteger aLayers;
10995 aViewer->GetAllZLayers (aLayers);
10996 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
10998 if (aLayeriter.Value() == aLayer
10999 || aLayer == Graphic3d_ZLayerId_UNKNOWN)
11001 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
11002 if (!aSettings.Lights().IsNull())
11004 aSettings.Lights()->Remove (aLightDel);
11005 if (aSettings.Lights()->IsEmpty())
11007 aSettings.SetLights (Handle(Graphic3d_LightSet)());
11010 aViewer->SetZLayerSettings (aLayeriter.Value(), aSettings);
11011 if (aLayer != Graphic3d_ZLayerId_UNKNOWN)
11018 if (aLayer == Graphic3d_ZLayerId_UNKNOWN)
11020 aViewer->DelLight (aLightDel);
11023 else if (anArgCase.IsEqual ("COLOR")
11024 || anArgCase.IsEqual ("COLOUR")
11025 || anArgCase.IsEqual ("-COLOR")
11026 || anArgCase.IsEqual ("-COLOUR"))
11028 if (++anArgIt >= theArgsNb
11029 || aLightCurr.IsNull())
11031 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11035 TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
11036 anArgNext.UpperCase();
11037 const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString());
11038 aLightCurr->SetColor (aColor);
11040 else if (anArgCase.IsEqual ("POS")
11041 || anArgCase.IsEqual ("POSITION")
11042 || anArgCase.IsEqual ("-POS")
11043 || anArgCase.IsEqual ("-POSITION"))
11045 if ((anArgIt + 3) >= theArgsNb
11046 || aLightCurr.IsNull()
11047 || (aLightCurr->Type() != Graphic3d_TOLS_POSITIONAL
11048 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11050 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11054 anXYZ[0] = Atof (theArgVec[++anArgIt]);
11055 anXYZ[1] = Atof (theArgVec[++anArgIt]);
11056 anXYZ[2] = Atof (theArgVec[++anArgIt]);
11057 aLightCurr->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
11059 else if (anArgCase.IsEqual ("DIR")
11060 || anArgCase.IsEqual ("DIRECTION")
11061 || anArgCase.IsEqual ("-DIR")
11062 || anArgCase.IsEqual ("-DIRECTION"))
11064 if ((anArgIt + 3) >= theArgsNb
11065 || aLightCurr.IsNull()
11066 || (aLightCurr->Type() != Graphic3d_TOLS_DIRECTIONAL
11067 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11069 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11073 anXYZ[0] = Atof (theArgVec[++anArgIt]);
11074 anXYZ[1] = Atof (theArgVec[++anArgIt]);
11075 anXYZ[2] = Atof (theArgVec[++anArgIt]);
11076 aLightCurr->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
11078 else if (anArgCase.IsEqual ("SM")
11079 || anArgCase.IsEqual ("SMOOTHNESS")
11080 || anArgCase.IsEqual ("-SM")
11081 || anArgCase.IsEqual ("-SMOOTHNESS"))
11083 if (++anArgIt >= theArgsNb
11084 || aLightCurr.IsNull())
11086 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11090 Standard_ShortReal aSmoothness = (Standard_ShortReal )Atof (theArgVec[anArgIt]);
11091 if (Abs (aSmoothness) <= ShortRealEpsilon())
11093 aLightCurr->SetIntensity (1.f);
11095 else if (Abs (aLightCurr->Smoothness()) <= ShortRealEpsilon())
11097 aLightCurr->SetIntensity ((aSmoothness * aSmoothness) / 3.f);
11101 Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightCurr->Smoothness());
11102 aLightCurr->SetIntensity (aLightCurr->Intensity() / (aSmoothnessRatio * aSmoothnessRatio));
11105 if (aLightCurr->Type() == Graphic3d_TOLS_POSITIONAL)
11107 aLightCurr->SetSmoothRadius (aSmoothness);
11109 else if (aLightCurr->Type() == Graphic3d_TOLS_DIRECTIONAL)
11111 aLightCurr->SetSmoothAngle (aSmoothness);
11114 else if (anArgCase.IsEqual ("INT")
11115 || anArgCase.IsEqual ("INTENSITY")
11116 || anArgCase.IsEqual ("-INT")
11117 || anArgCase.IsEqual ("-INTENSITY"))
11119 if (++anArgIt >= theArgsNb
11120 || aLightCurr.IsNull())
11122 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11126 Standard_ShortReal aIntensity = (Standard_ShortReal )Atof (theArgVec[anArgIt]);
11127 aLightCurr->SetIntensity (aIntensity);
11129 else if (anArgCase.IsEqual ("ANG")
11130 || anArgCase.IsEqual ("ANGLE")
11131 || anArgCase.IsEqual ("-ANG")
11132 || anArgCase.IsEqual ("-ANGLE"))
11134 if (++anArgIt >= theArgsNb
11135 || aLightCurr.IsNull()
11136 || aLightCurr->Type() != Graphic3d_TOLS_SPOT)
11138 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11142 Standard_ShortReal anAngle = (Standard_ShortReal )Atof (theArgVec[anArgIt]);
11143 aLightCurr->SetAngle (Standard_ShortReal (anAngle / 180.0 * M_PI));
11145 else if (anArgCase.IsEqual ("CONSTATTEN")
11146 || anArgCase.IsEqual ("CONSTATTENUATION")
11147 || anArgCase.IsEqual ("-CONSTATTEN")
11148 || anArgCase.IsEqual ("-CONSTATTENUATION"))
11150 if (++anArgIt >= theArgsNb
11151 || aLightCurr.IsNull()
11152 || (aLightCurr->Type() != Graphic3d_TOLS_POSITIONAL
11153 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11155 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11159 aLightCurr->Attenuation (anAtten[0], anAtten[1]);
11160 anAtten[0] = Atof (theArgVec[anArgIt]);
11161 aLightCurr->SetAttenuation ((Standard_ShortReal )anAtten[0], (Standard_ShortReal )anAtten[1]);
11163 else if (anArgCase.IsEqual ("LINATTEN")
11164 || anArgCase.IsEqual ("LINEARATTEN")
11165 || anArgCase.IsEqual ("LINEARATTENUATION")
11166 || anArgCase.IsEqual ("-LINATTEN")
11167 || anArgCase.IsEqual ("-LINEARATTEN")
11168 || anArgCase.IsEqual ("-LINEARATTENUATION"))
11170 if (++anArgIt >= theArgsNb
11171 || aLightCurr.IsNull()
11172 || (aLightCurr->Type() != Graphic3d_TOLS_POSITIONAL
11173 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11175 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11179 aLightCurr->Attenuation (anAtten[0], anAtten[1]);
11180 anAtten[1] = Atof (theArgVec[anArgIt]);
11181 aLightCurr->SetAttenuation ((Standard_ShortReal )anAtten[0], (Standard_ShortReal )anAtten[1]);
11183 else if (anArgCase.IsEqual ("EXP")
11184 || anArgCase.IsEqual ("EXPONENT")
11185 || anArgCase.IsEqual ("SPOTEXP")
11186 || anArgCase.IsEqual ("SPOTEXPONENT")
11187 || anArgCase.IsEqual ("-EXP")
11188 || anArgCase.IsEqual ("-EXPONENT")
11189 || anArgCase.IsEqual ("-SPOTEXP")
11190 || anArgCase.IsEqual ("-SPOTEXPONENT"))
11192 if (++anArgIt >= theArgsNb
11193 || aLightCurr.IsNull()
11194 || aLightCurr->Type() != Graphic3d_TOLS_SPOT)
11196 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11200 aLightCurr->SetConcentration ((Standard_ShortReal )Atof (theArgVec[anArgIt]));
11202 else if (anArgCase.IsEqual("RANGE")
11203 || anArgCase.IsEqual("-RANGE"))
11205 if (++anArgIt >= theArgsNb
11206 || aLightCurr.IsNull()
11207 || aLightCurr->Type() == Graphic3d_TOLS_AMBIENT
11208 || aLightCurr->Type() == Graphic3d_TOLS_DIRECTIONAL)
11210 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11214 aLightCurr->SetRange ((Standard_ShortReal)Atof (theArgVec[anArgIt]));
11216 else if (anArgCase.IsEqual ("HEAD")
11217 || anArgCase.IsEqual ("HEADLIGHT")
11218 || anArgCase.IsEqual ("-HEAD")
11219 || anArgCase.IsEqual ("-HEADLIGHT"))
11221 if (aLightCurr.IsNull()
11222 || aLightCurr->Type() == Graphic3d_TOLS_AMBIENT)
11224 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11228 Standard_Boolean isHeadLight = Standard_True;
11229 if (anArgIt + 1 < theArgsNb
11230 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], isHeadLight))
11234 aLightCurr->SetHeadlight (isHeadLight);
11238 Message::SendFail() << "Warning: unknown argument '" << anArg << "'";
11242 addLight (aLightNew, aLayer, isGlobal);
11246 //===============================================================================================
11247 //function : VPBREnvironment
11249 //===============================================================================================
11250 static int VPBREnvironment (Draw_Interpretor&,
11251 Standard_Integer theArgsNb,
11252 const char** theArgVec)
11256 Message::SendFail ("Syntax error: 'vpbrenv' command has only one argument");
11260 Handle(V3d_View) aView = ViewerTest::CurrentView();
11261 if (aView.IsNull())
11263 Message::SendFail ("Error: no active viewer");
11267 TCollection_AsciiString anArg = TCollection_AsciiString (theArgVec[1]);
11270 if (anArg == "-generate"
11271 || anArg == "-gen")
11273 aView->GeneratePBREnvironment (Standard_True);
11275 else if (anArg == "-clear")
11277 aView->ClearPBREnvironment (Standard_True);
11281 Message::SendFail() << "Syntax error: unknown argument [" << theArgVec[1] << "] for 'vpbrenv' command";
11288 //! Read Graphic3d_RenderingParams::PerfCounters flag.
11289 static Standard_Boolean parsePerfStatsFlag (const TCollection_AsciiString& theValue,
11290 Standard_Boolean& theToReset,
11291 Graphic3d_RenderingParams::PerfCounters& theFlagsRem,
11292 Graphic3d_RenderingParams::PerfCounters& theFlagsAdd)
11294 Graphic3d_RenderingParams::PerfCounters aFlag = Graphic3d_RenderingParams::PerfCounters_NONE;
11295 TCollection_AsciiString aVal = theValue;
11296 Standard_Boolean toReverse = Standard_False;
11297 if (aVal == "none")
11299 theToReset = Standard_True;
11300 return Standard_True;
11302 else if (aVal.StartsWith ("-"))
11304 toReverse = Standard_True;
11305 aVal = aVal.SubString (2, aVal.Length());
11307 else if (aVal.StartsWith ("no"))
11309 toReverse = Standard_True;
11310 aVal = aVal.SubString (3, aVal.Length());
11312 else if (aVal.StartsWith ("+"))
11314 aVal = aVal.SubString (2, aVal.Length());
11318 theToReset = Standard_True;
11322 || aVal == "framerate") aFlag = Graphic3d_RenderingParams::PerfCounters_FrameRate;
11323 else if (aVal == "cpu") aFlag = Graphic3d_RenderingParams::PerfCounters_CPU;
11324 else if (aVal == "layers") aFlag = Graphic3d_RenderingParams::PerfCounters_Layers;
11325 else if (aVal == "structs"
11326 || aVal == "structures"
11327 || aVal == "objects") aFlag = Graphic3d_RenderingParams::PerfCounters_Structures;
11328 else if (aVal == "groups") aFlag = Graphic3d_RenderingParams::PerfCounters_Groups;
11329 else if (aVal == "arrays") aFlag = Graphic3d_RenderingParams::PerfCounters_GroupArrays;
11330 else if (aVal == "tris"
11331 || aVal == "triangles") aFlag = Graphic3d_RenderingParams::PerfCounters_Triangles;
11332 else if (aVal == "pnts"
11333 || aVal == "points") aFlag = Graphic3d_RenderingParams::PerfCounters_Points;
11334 else if (aVal == "lines") aFlag = Graphic3d_RenderingParams::PerfCounters_Lines;
11335 else if (aVal == "mem"
11336 || aVal == "gpumem"
11337 || aVal == "estimmem") aFlag = Graphic3d_RenderingParams::PerfCounters_EstimMem;
11338 else if (aVal == "skipimmediate"
11339 || aVal == "noimmediate") aFlag = Graphic3d_RenderingParams::PerfCounters_SkipImmediate;
11340 else if (aVal == "frametime"
11341 || aVal == "frametimers"
11342 || aVal == "time") aFlag = Graphic3d_RenderingParams::PerfCounters_FrameTime;
11343 else if (aVal == "basic") aFlag = Graphic3d_RenderingParams::PerfCounters_Basic;
11344 else if (aVal == "extended"
11345 || aVal == "verbose"
11346 || aVal == "extra") aFlag = Graphic3d_RenderingParams::PerfCounters_Extended;
11347 else if (aVal == "full"
11348 || aVal == "all") aFlag = Graphic3d_RenderingParams::PerfCounters_All;
11351 return Standard_False;
11356 theFlagsRem = Graphic3d_RenderingParams::PerfCounters(theFlagsRem | aFlag);
11360 theFlagsAdd = Graphic3d_RenderingParams::PerfCounters(theFlagsAdd | aFlag);
11362 return Standard_True;
11365 //! Read Graphic3d_RenderingParams::PerfCounters flags.
11366 static Standard_Boolean convertToPerfStatsFlags (const TCollection_AsciiString& theValue,
11367 Graphic3d_RenderingParams::PerfCounters& theFlags)
11369 TCollection_AsciiString aValue = theValue;
11370 Graphic3d_RenderingParams::PerfCounters aFlagsRem = Graphic3d_RenderingParams::PerfCounters_NONE;
11371 Graphic3d_RenderingParams::PerfCounters aFlagsAdd = Graphic3d_RenderingParams::PerfCounters_NONE;
11372 Standard_Boolean toReset = Standard_False;
11375 Standard_Integer aSplitPos = aValue.Search ("|");
11376 if (aSplitPos <= 0)
11378 if (!parsePerfStatsFlag (aValue, toReset, aFlagsRem, aFlagsAdd))
11380 return Standard_False;
11384 theFlags = Graphic3d_RenderingParams::PerfCounters_NONE;
11386 theFlags = Graphic3d_RenderingParams::PerfCounters(theFlags | aFlagsAdd);
11387 theFlags = Graphic3d_RenderingParams::PerfCounters(theFlags & ~aFlagsRem);
11388 return Standard_True;
11393 TCollection_AsciiString aSubValue = aValue.SubString (1, aSplitPos - 1);
11394 if (!parsePerfStatsFlag (aSubValue, toReset, aFlagsRem, aFlagsAdd))
11396 return Standard_False;
11399 aValue = aValue.SubString (aSplitPos + 1, aValue.Length());
11403 //=======================================================================
11404 //function : VRenderParams
11405 //purpose : Enables/disables rendering features
11406 //=======================================================================
11408 static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
11409 Standard_Integer theArgNb,
11410 const char** theArgVec)
11412 Handle(V3d_View) aView = ViewerTest::CurrentView();
11413 if (aView.IsNull())
11415 Message::SendFail ("Error: no active viewer");
11419 Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
11420 TCollection_AsciiString aCmdName (theArgVec[0]);
11421 aCmdName.LowerCase();
11422 if (aCmdName == "vraytrace")
11426 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "on" : "off") << " ";
11429 else if (theArgNb == 2)
11431 TCollection_AsciiString aValue (theArgVec[1]);
11432 aValue.LowerCase();
11436 aParams.Method = Graphic3d_RM_RAYTRACING;
11440 else if (aValue == "off"
11443 aParams.Method = Graphic3d_RM_RASTERIZATION;
11449 Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[1] << "'";
11455 Message::SendFail ("Syntax error: wrong number of arguments");
11462 theDI << "renderMode: ";
11463 switch (aParams.Method)
11465 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
11466 case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break;
11469 theDI << "transparency: ";
11470 switch (aParams.TransparencyMethod)
11472 case Graphic3d_RTM_BLEND_UNORDERED: theDI << "Basic blended transparency with non-commuting operator "; break;
11473 case Graphic3d_RTM_BLEND_OIT: theDI << "Weighted Blended Order-Independent Transparency, depth weight factor: "
11474 << TCollection_AsciiString (aParams.OitDepthFactor); break;
11477 theDI << "msaa: " << aParams.NbMsaaSamples << "\n";
11478 theDI << "rendScale: " << aParams.RenderResolutionScale << "\n";
11479 theDI << "rayDepth: " << aParams.RaytracingDepth << "\n";
11480 theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n";
11481 theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n";
11482 theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
11483 theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
11484 theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
11485 theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n";
11486 theDI << "iss: " << (aParams.AdaptiveScreenSampling ? "on" : "off") << "\n";
11487 theDI << "iss debug: " << (aParams.ShowSamplingTiles ? "on" : "off") << "\n";
11488 theDI << "two-sided BSDF: " << (aParams.TwoSidedBsdfModels ? "on" : "off") << "\n";
11489 theDI << "max radiance: " << aParams.RadianceClampingValue << "\n";
11490 theDI << "nb tiles (iss): " << aParams.NbRayTracingTiles << "\n";
11491 theDI << "tile size (iss):" << aParams.RayTracingTileSize << "x" << aParams.RayTracingTileSize << "\n";
11492 theDI << "shadingModel: ";
11493 switch (aView->ShadingModel())
11495 case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
11496 case Graphic3d_TOSM_UNLIT: theDI << "unlit"; break;
11497 case Graphic3d_TOSM_FACET: theDI << "flat"; break;
11498 case Graphic3d_TOSM_VERTEX: theDI << "gouraud"; break;
11499 case Graphic3d_TOSM_FRAGMENT: theDI << "phong"; break;
11500 case Graphic3d_TOSM_PBR: theDI << "pbr"; break;
11501 case Graphic3d_TOSM_PBR_FACET: theDI << "pbr_facet"; break;
11504 theDI << "perfCounters:";
11505 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_FrameRate) != 0)
11509 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_CPU) != 0)
11513 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Structures) != 0)
11515 theDI << " structs";
11517 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Groups) != 0)
11519 theDI << " groups";
11521 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_GroupArrays) != 0)
11523 theDI << " arrays";
11525 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Triangles) != 0)
11529 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Lines) != 0)
11533 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Points) != 0)
11537 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_EstimMem) != 0)
11539 theDI << " gpumem";
11541 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_FrameTime) != 0)
11543 theDI << " frameTime";
11545 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_SkipImmediate) != 0)
11547 theDI << " skipimmediate";
11549 if (aParams.CollectedStats == Graphic3d_RenderingParams::PerfCounters_NONE)
11555 theDI << "depth pre-pass: " << (aParams.ToEnableDepthPrepass ? "on" : "off") << "\n";
11556 theDI << "alpha to coverage: " << (aParams.ToEnableAlphaToCoverage ? "on" : "off") << "\n";
11557 theDI << "frustum culling: " << (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On ? "on" :
11558 aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off ? "off" :
11559 "noUpdate") << "\n";
11564 Standard_Boolean toPrint = Standard_False;
11565 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
11566 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
11568 Standard_CString anArg (theArgVec[anArgIter]);
11569 TCollection_AsciiString aFlag (anArg);
11571 if (anUpdateTool.parseRedrawMode (aFlag))
11575 else if (aFlag == "-echo"
11576 || aFlag == "-print")
11578 toPrint = Standard_True;
11579 anUpdateTool.Invalidate();
11581 else if (aFlag == "-mode"
11582 || aFlag == "-rendermode"
11583 || aFlag == "-render_mode")
11587 switch (aParams.Method)
11589 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
11590 case Graphic3d_RM_RAYTRACING: theDI << "ray-tracing "; break;
11596 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11600 else if (aFlag == "-ray"
11601 || aFlag == "-raytrace")
11605 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "true" : "false") << " ";
11609 aParams.Method = Graphic3d_RM_RAYTRACING;
11611 else if (aFlag == "-rast"
11612 || aFlag == "-raster"
11613 || aFlag == "-rasterization")
11617 theDI << (aParams.Method == Graphic3d_RM_RASTERIZATION ? "true" : "false") << " ";
11621 aParams.Method = Graphic3d_RM_RASTERIZATION;
11623 else if (aFlag == "-msaa")
11627 theDI << aParams.NbMsaaSamples << " ";
11630 else if (++anArgIter >= theArgNb)
11632 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11636 const Standard_Integer aNbSamples = Draw::Atoi (theArgVec[anArgIter]);
11637 if (aNbSamples < 0)
11639 Message::SendFail() << "Syntax error: invalid number of MSAA samples " << aNbSamples << "";
11644 aParams.NbMsaaSamples = aNbSamples;
11647 else if (aFlag == "-linefeather"
11648 || aFlag == "-edgefeather"
11649 || aFlag == "-feather")
11653 theDI << " " << aParams.LineFeather << " ";
11656 else if (++anArgIter >= theArgNb)
11658 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11662 TCollection_AsciiString aParam = theArgVec[anArgIter];
11663 const Standard_ShortReal aFeather = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
11664 if (aFeather <= 0.0f)
11666 Message::SendFail() << "Syntax error: invalid value of line width feather " << aFeather << ". Should be > 0";
11669 aParams.LineFeather = aFeather;
11671 else if (aFlag == "-oit")
11675 if (aParams.TransparencyMethod == Graphic3d_RTM_BLEND_OIT)
11677 theDI << "on, depth weight factor: " << TCollection_AsciiString (aParams.OitDepthFactor) << " ";
11681 theDI << "off" << " ";
11685 else if (++anArgIter >= theArgNb)
11687 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11691 TCollection_AsciiString aParam = theArgVec[anArgIter];
11692 aParam.LowerCase();
11693 if (aParam.IsRealValue())
11695 const Standard_ShortReal aWeight = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
11696 if (aWeight < 0.f || aWeight > 1.f)
11698 Message::SendFail() << "Syntax error: invalid value of Weighted Order-Independent Transparency depth weight factor " << aWeight << ". Should be within range [0.0; 1.0]";
11702 aParams.TransparencyMethod = Graphic3d_RTM_BLEND_OIT;
11703 aParams.OitDepthFactor = aWeight;
11705 else if (aParam == "off")
11707 aParams.TransparencyMethod = Graphic3d_RTM_BLEND_UNORDERED;
11711 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11715 else if (aFlag == "-depthprepass")
11719 theDI << (aParams.ToEnableDepthPrepass ? "on " : "off ");
11722 aParams.ToEnableDepthPrepass = Standard_True;
11723 if (anArgIter + 1 < theArgNb
11724 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableDepthPrepass))
11729 else if (aFlag == "-samplealphatocoverage"
11730 || aFlag == "-alphatocoverage")
11734 theDI << (aParams.ToEnableAlphaToCoverage ? "on " : "off ");
11737 aParams.ToEnableAlphaToCoverage = Standard_True;
11738 if (anArgIter + 1 < theArgNb
11739 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableAlphaToCoverage))
11744 else if (aFlag == "-rendscale"
11745 || aFlag == "-renderscale"
11746 || aFlag == "-renderresolutionscale")
11750 theDI << aParams.RenderResolutionScale << " ";
11753 else if (++anArgIter >= theArgNb)
11755 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11759 const Standard_Real aScale = Draw::Atof (theArgVec[anArgIter]);
11762 Message::SendFail() << "Syntax error: invalid rendering resolution scale " << aScale << "";
11767 aParams.RenderResolutionScale = Standard_ShortReal(aScale);
11770 else if (aFlag == "-raydepth"
11771 || aFlag == "-ray_depth")
11775 theDI << aParams.RaytracingDepth << " ";
11778 else if (++anArgIter >= theArgNb)
11780 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11784 const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]);
11786 // We allow RaytracingDepth be more than 10 in case of GI enabled
11787 if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled))
11789 Message::SendFail() << "Syntax error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]";
11794 aParams.RaytracingDepth = aDepth;
11797 else if (aFlag == "-shad"
11798 || aFlag == "-shadows")
11802 theDI << (aParams.IsShadowEnabled ? "on" : "off") << " ";
11806 Standard_Boolean toEnable = Standard_True;
11807 if (++anArgIter < theArgNb
11808 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11812 aParams.IsShadowEnabled = toEnable;
11814 else if (aFlag == "-refl"
11815 || aFlag == "-reflections")
11819 theDI << (aParams.IsReflectionEnabled ? "on" : "off") << " ";
11823 Standard_Boolean toEnable = Standard_True;
11824 if (++anArgIter < theArgNb
11825 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11829 aParams.IsReflectionEnabled = toEnable;
11831 else if (aFlag == "-fsaa")
11835 theDI << (aParams.IsAntialiasingEnabled ? "on" : "off") << " ";
11839 Standard_Boolean toEnable = Standard_True;
11840 if (++anArgIter < theArgNb
11841 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11845 aParams.IsAntialiasingEnabled = toEnable;
11847 else if (aFlag == "-gleam")
11851 theDI << (aParams.IsTransparentShadowEnabled ? "on" : "off") << " ";
11855 Standard_Boolean toEnable = Standard_True;
11856 if (++anArgIter < theArgNb
11857 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11861 aParams.IsTransparentShadowEnabled = toEnable;
11863 else if (aFlag == "-gi")
11867 theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " ";
11871 Standard_Boolean toEnable = Standard_True;
11872 if (++anArgIter < theArgNb
11873 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11877 aParams.IsGlobalIlluminationEnabled = toEnable;
11880 aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
11883 else if (aFlag == "-blockedrng"
11884 || aFlag == "-brng")
11888 theDI << (aParams.CoherentPathTracingMode ? "on" : "off") << " ";
11892 Standard_Boolean toEnable = Standard_True;
11893 if (++anArgIter < theArgNb
11894 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11898 aParams.CoherentPathTracingMode = toEnable;
11900 else if (aFlag == "-maxrad")
11904 theDI << aParams.RadianceClampingValue << " ";
11907 else if (++anArgIter >= theArgNb)
11909 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11913 const TCollection_AsciiString aMaxRadStr = theArgVec[anArgIter];
11914 if (!aMaxRadStr.IsRealValue())
11916 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11920 const Standard_Real aMaxRadiance = aMaxRadStr.RealValue();
11921 if (aMaxRadiance <= 0.0)
11923 Message::SendFail() << "Syntax error: invalid radiance clamping value " << aMaxRadiance;
11928 aParams.RadianceClampingValue = static_cast<Standard_ShortReal> (aMaxRadiance);
11931 else if (aFlag == "-iss")
11935 theDI << (aParams.AdaptiveScreenSampling ? "on" : "off") << " ";
11939 Standard_Boolean toEnable = Standard_True;
11940 if (++anArgIter < theArgNb
11941 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11945 aParams.AdaptiveScreenSampling = toEnable;
11947 else if (aFlag == "-issatomic")
11951 theDI << (aParams.AdaptiveScreenSamplingAtomic ? "on" : "off") << " ";
11955 Standard_Boolean toEnable = Standard_True;
11956 if (++anArgIter < theArgNb
11957 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11961 aParams.AdaptiveScreenSamplingAtomic = toEnable;
11963 else if (aFlag == "-issd")
11967 theDI << (aParams.ShowSamplingTiles ? "on" : "off") << " ";
11971 Standard_Boolean toEnable = Standard_True;
11972 if (++anArgIter < theArgNb
11973 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11977 aParams.ShowSamplingTiles = toEnable;
11979 else if (aFlag == "-tilesize")
11983 theDI << aParams.RayTracingTileSize << " ";
11986 else if (++anArgIter >= theArgNb)
11988 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11992 const Standard_Integer aTileSize = Draw::Atoi (theArgVec[anArgIter]);
11995 Message::SendFail() << "Syntax error: invalid size of ISS tile " << aTileSize;
11998 aParams.RayTracingTileSize = aTileSize;
12000 else if (aFlag == "-nbtiles")
12004 theDI << aParams.NbRayTracingTiles << " ";
12007 else if (++anArgIter >= theArgNb)
12009 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12013 const Standard_Integer aNbTiles = Draw::Atoi (theArgVec[anArgIter]);
12016 Message::SendFail() << "Syntax error: invalid number of ISS tiles " << aNbTiles;
12019 else if (aNbTiles > 0
12021 || aNbTiles > 1024))
12023 Message::SendWarning() << "Warning: suboptimal number of ISS tiles " << aNbTiles << ". Recommended range: [64, 1024].";
12025 aParams.NbRayTracingTiles = aNbTiles;
12027 else if (aFlag == "-env")
12031 theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " ";
12035 Standard_Boolean toEnable = Standard_True;
12036 if (++anArgIter < theArgNb
12037 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12041 aParams.UseEnvironmentMapBackground = toEnable;
12043 else if (aFlag == "-ignorenormalmap")
12047 theDI << (aParams.ToIgnoreNormalMapInRayTracing ? "on" : "off") << " ";
12051 Standard_Boolean toEnable = Standard_True;
12052 if (++anArgIter < theArgNb
12053 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12057 aParams.ToIgnoreNormalMapInRayTracing = toEnable;
12059 else if (aFlag == "-twoside")
12063 theDI << (aParams.TwoSidedBsdfModels ? "on" : "off") << " ";
12067 Standard_Boolean toEnable = Standard_True;
12068 if (++anArgIter < theArgNb
12069 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12073 aParams.TwoSidedBsdfModels = toEnable;
12075 else if (aFlag == "-shademodel"
12076 || aFlag == "-shadingmodel"
12077 || aFlag == "-shading")
12081 switch (aView->ShadingModel())
12083 case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
12084 case Graphic3d_TOSM_UNLIT: theDI << "unlit "; break;
12085 case Graphic3d_TOSM_FACET: theDI << "flat "; break;
12086 case Graphic3d_TOSM_VERTEX: theDI << "gouraud "; break;
12087 case Graphic3d_TOSM_FRAGMENT: theDI << "phong "; break;
12088 case Graphic3d_TOSM_PBR: theDI << "pbr"; break;
12089 case Graphic3d_TOSM_PBR_FACET: theDI << "pbr_facet"; break;
12094 if (++anArgIter >= theArgNb)
12096 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12099 Graphic3d_TypeOfShadingModel aModel = Graphic3d_TOSM_DEFAULT;
12100 if (ViewerTest::ParseShadingModel (theArgVec[anArgIter], aModel)
12101 && aModel != Graphic3d_TOSM_DEFAULT)
12103 aView->SetShadingModel (aModel);
12107 Message::SendFail() << "Syntax error: unknown shading model '" << theArgVec[anArgIter] << "'";
12111 else if (aFlag == "-pbrenvpow2size"
12112 || aFlag == "-pbrenvp2s"
12113 || aFlag == "-pep2s")
12115 if (++anArgIter >= theArgNb)
12117 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12121 const Standard_Integer aPbrEnvPow2Size = Draw::Atoi (theArgVec[anArgIter]);
12122 if (aPbrEnvPow2Size < 1)
12124 Message::SendFail ("Syntax error: 'Pow2Size' of PBR Environment has to be greater or equal 1");
12127 aParams.PbrEnvPow2Size = aPbrEnvPow2Size;
12129 else if (aFlag == "-pbrenvspecmaplevelsnumber"
12130 || aFlag == "-pbrenvspecmapnblevels"
12131 || aFlag == "-pbrenvspecmaplevels"
12132 || aFlag == "-pbrenvsmln"
12133 || aFlag == "-pesmln")
12135 if (++anArgIter >= theArgNb)
12137 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12141 const Standard_Integer aPbrEnvSpecMapNbLevels = Draw::Atoi (theArgVec[anArgIter]);
12142 if (aPbrEnvSpecMapNbLevels < 2)
12144 Message::SendFail ("Syntax error: 'SpecMapLevelsNumber' of PBR Environment has to be greater or equal 2");
12147 aParams.PbrEnvSpecMapNbLevels = aPbrEnvSpecMapNbLevels;
12149 else if (aFlag == "-pbrenvbakngdiffsamplesnumber"
12150 || aFlag == "-pbrenvbakingdiffsamples"
12151 || aFlag == "-pbrenvbdsn")
12153 if (++anArgIter >= theArgNb)
12155 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12159 const Standard_Integer aPbrEnvBakingDiffNbSamples = Draw::Atoi (theArgVec[anArgIter]);
12160 if (aPbrEnvBakingDiffNbSamples < 1)
12162 Message::SendFail ("Syntax error: 'BakingDiffSamplesNumber' of PBR Environtment has to be greater or equal 1");
12165 aParams.PbrEnvBakingDiffNbSamples = aPbrEnvBakingDiffNbSamples;
12167 else if (aFlag == "-pbrenvbakngspecsamplesnumber"
12168 || aFlag == "-pbrenvbakingspecsamples"
12169 || aFlag == "-pbrenvbssn")
12171 if (++anArgIter >= theArgNb)
12173 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12177 const Standard_Integer aPbrEnvBakingSpecNbSamples = Draw::Atoi(theArgVec[anArgIter]);
12178 if (aPbrEnvBakingSpecNbSamples < 1)
12180 Message::SendFail ("Syntax error: 'BakingSpecSamplesNumber' of PBR Environtment has to be greater or equal 1");
12183 aParams.PbrEnvBakingSpecNbSamples = aPbrEnvBakingSpecNbSamples;
12185 else if (aFlag == "-pbrenvbakingprobability"
12186 || aFlag == "-pbrenvbp")
12188 if (++anArgIter >= theArgNb)
12190 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12193 const Standard_ShortReal aPbrEnvBakingProbability = static_cast<Standard_ShortReal>(Draw::Atof (theArgVec[anArgIter]));
12194 if (aPbrEnvBakingProbability < 0.f
12195 || aPbrEnvBakingProbability > 1.f)
12197 Message::SendFail ("Syntax error: 'BakingProbability' of PBR Environtment has to be in range of [0, 1]");
12200 aParams.PbrEnvBakingProbability = aPbrEnvBakingProbability;
12202 else if (aFlag == "-resolution")
12204 if (++anArgIter >= theArgNb)
12206 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12210 TCollection_AsciiString aResolution (theArgVec[anArgIter]);
12211 if (aResolution.IsIntegerValue())
12213 aView->ChangeRenderingParams().Resolution = static_cast<unsigned int> (Draw::Atoi (aResolution.ToCString()));
12217 Message::SendFail() << "Syntax error: wrong syntax at argument'" << anArg << "'";
12221 else if (aFlag == "-rebuildglsl"
12222 || aFlag == "-rebuild")
12226 theDI << (aParams.RebuildRayTracingShaders ? "on" : "off") << " ";
12230 Standard_Boolean toEnable = Standard_True;
12231 if (++anArgIter < theArgNb
12232 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12236 aParams.RebuildRayTracingShaders = toEnable;
12238 else if (aFlag == "-focal")
12240 if (++anArgIter >= theArgNb)
12242 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12246 TCollection_AsciiString aParam (theArgVec[anArgIter]);
12247 if (aParam.IsRealValue())
12249 float aFocalDist = static_cast<float> (aParam.RealValue());
12250 if (aFocalDist < 0)
12252 Message::SendFail() << "Error: parameter can't be negative at argument '" << anArg << "'";
12255 aView->ChangeRenderingParams().CameraFocalPlaneDist = aFocalDist;
12259 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12263 else if (aFlag == "-aperture")
12265 if (++anArgIter >= theArgNb)
12267 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12271 TCollection_AsciiString aParam(theArgVec[anArgIter]);
12272 if (aParam.IsRealValue())
12274 float aApertureSize = static_cast<float> (aParam.RealValue());
12275 if (aApertureSize < 0)
12277 Message::SendFail() << "Error: parameter can't be negative at argument '" << anArg << "'";
12280 aView->ChangeRenderingParams().CameraApertureRadius = aApertureSize;
12284 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12288 else if (aFlag == "-exposure")
12290 if (++anArgIter >= theArgNb)
12292 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12296 TCollection_AsciiString anExposure (theArgVec[anArgIter]);
12297 if (anExposure.IsRealValue())
12299 aView->ChangeRenderingParams().Exposure = static_cast<float> (anExposure.RealValue());
12303 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12307 else if (aFlag == "-whitepoint")
12309 if (++anArgIter >= theArgNb)
12311 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12315 TCollection_AsciiString aWhitePoint (theArgVec[anArgIter]);
12316 if (aWhitePoint.IsRealValue())
12318 aView->ChangeRenderingParams().WhitePoint = static_cast<float> (aWhitePoint.RealValue());
12322 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12326 else if (aFlag == "-tonemapping")
12328 if (++anArgIter >= theArgNb)
12330 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12334 TCollection_AsciiString aMode (theArgVec[anArgIter]);
12337 if (aMode == "disabled")
12339 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Disabled;
12341 else if (aMode == "filmic")
12343 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Filmic;
12347 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12351 else if (aFlag == "-performancestats"
12352 || aFlag == "-performancecounters"
12353 || aFlag == "-perfstats"
12354 || aFlag == "-perfcounters"
12355 || aFlag == "-stats")
12357 if (++anArgIter >= theArgNb)
12359 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12363 TCollection_AsciiString aFlagsStr (theArgVec[anArgIter]);
12364 aFlagsStr.LowerCase();
12365 Graphic3d_RenderingParams::PerfCounters aFlags = aView->ChangeRenderingParams().CollectedStats;
12366 if (!convertToPerfStatsFlags (aFlagsStr, aFlags))
12368 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12371 aView->ChangeRenderingParams().CollectedStats = aFlags;
12372 aView->ChangeRenderingParams().ToShowStats = aFlags != Graphic3d_RenderingParams::PerfCounters_NONE;
12374 else if (aFlag == "-perfupdateinterval"
12375 || aFlag == "-statsupdateinterval")
12377 if (++anArgIter >= theArgNb)
12379 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12382 aView->ChangeRenderingParams().StatsUpdateInterval = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]);
12384 else if (aFlag == "-perfchart"
12385 || aFlag == "-statschart")
12387 if (++anArgIter >= theArgNb)
12389 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12392 aView->ChangeRenderingParams().StatsNbFrames = Draw::Atoi (theArgVec[anArgIter]);
12394 else if (aFlag == "-perfchartmax"
12395 || aFlag == "-statschartmax")
12397 if (++anArgIter >= theArgNb)
12399 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12402 aView->ChangeRenderingParams().StatsMaxChartTime = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]);
12404 else if (aFlag == "-frustumculling"
12405 || aFlag == "-culling")
12409 theDI << ((aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On) ? "on" :
12410 (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off) ? "off" :
12411 "noUpdate") << " ";
12415 Graphic3d_RenderingParams::FrustumCulling aState = Graphic3d_RenderingParams::FrustumCulling_On;
12416 if (++anArgIter < theArgNb)
12418 TCollection_AsciiString aStateStr(theArgVec[anArgIter]);
12419 aStateStr.LowerCase();
12420 bool toEnable = true;
12421 if (ViewerTest::ParseOnOff (aStateStr.ToCString(), toEnable))
12423 aState = toEnable ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off;
12425 else if (aStateStr == "noupdate"
12426 || aStateStr == "freeze")
12428 aState = Graphic3d_RenderingParams::FrustumCulling_NoUpdate;
12435 aParams.FrustumCullingState = aState;
12439 Message::SendFail() << "Syntax error: unknown flag '" << anArg << "'";
12447 //=======================================================================
12448 //function : searchInfo
12450 //=======================================================================
12451 inline TCollection_AsciiString searchInfo (const TColStd_IndexedDataMapOfStringString& theDict,
12452 const TCollection_AsciiString& theKey)
12454 for (TColStd_IndexedDataMapOfStringString::Iterator anIter (theDict); anIter.More(); anIter.Next())
12456 if (TCollection_AsciiString::IsSameString (anIter.Key(), theKey, Standard_False))
12458 return anIter.Value();
12461 return TCollection_AsciiString();
12464 //=======================================================================
12465 //function : VStatProfiler
12467 //=======================================================================
12468 static Standard_Integer VStatProfiler (Draw_Interpretor& theDI,
12469 Standard_Integer theArgNb,
12470 const char** theArgVec)
12472 Handle(V3d_View) aView = ViewerTest::CurrentView();
12473 if (aView.IsNull())
12475 Message::SendFail ("Error: no active viewer");
12479 Standard_Boolean toRedraw = Standard_True;
12480 Graphic3d_RenderingParams::PerfCounters aPrevCounters = aView->ChangeRenderingParams().CollectedStats;
12481 Standard_ShortReal aPrevUpdInterval = aView->ChangeRenderingParams().StatsUpdateInterval;
12482 Graphic3d_RenderingParams::PerfCounters aRenderParams = Graphic3d_RenderingParams::PerfCounters_NONE;
12483 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
12485 Standard_CString anArg (theArgVec[anArgIter]);
12486 TCollection_AsciiString aFlag (anArg);
12488 if (aFlag == "-noredraw")
12490 toRedraw = Standard_False;
12494 Graphic3d_RenderingParams::PerfCounters aParam = Graphic3d_RenderingParams::PerfCounters_NONE;
12495 if (aFlag == "fps") aParam = Graphic3d_RenderingParams::PerfCounters_FrameRate;
12496 else if (aFlag == "cpu") aParam = Graphic3d_RenderingParams::PerfCounters_CPU;
12497 else if (aFlag == "alllayers"
12498 || aFlag == "layers") aParam = Graphic3d_RenderingParams::PerfCounters_Layers;
12499 else if (aFlag == "allstructs"
12500 || aFlag == "allstructures"
12501 || aFlag == "structs"
12502 || aFlag == "structures") aParam = Graphic3d_RenderingParams::PerfCounters_Structures;
12503 else if (aFlag == "groups") aParam = Graphic3d_RenderingParams::PerfCounters_Groups;
12504 else if (aFlag == "allarrays"
12505 || aFlag == "fillarrays"
12506 || aFlag == "linearrays"
12507 || aFlag == "pointarrays"
12508 || aFlag == "textarrays") aParam = Graphic3d_RenderingParams::PerfCounters_GroupArrays;
12509 else if (aFlag == "triangles") aParam = Graphic3d_RenderingParams::PerfCounters_Triangles;
12510 else if (aFlag == "lines") aParam = Graphic3d_RenderingParams::PerfCounters_Lines;
12511 else if (aFlag == "points") aParam = Graphic3d_RenderingParams::PerfCounters_Points;
12512 else if (aFlag == "geommem"
12513 || aFlag == "texturemem"
12514 || aFlag == "framemem") aParam = Graphic3d_RenderingParams::PerfCounters_EstimMem;
12515 else if (aFlag == "elapsedframe"
12516 || aFlag == "cpuframeaverage"
12517 || aFlag == "cpupickingaverage"
12518 || aFlag == "cpucullingaverage"
12519 || aFlag == "cpudynaverage"
12520 || aFlag == "cpuframemax"
12521 || aFlag == "cpupickingmax"
12522 || aFlag == "cpucullingmax"
12523 || aFlag == "cpudynmax") aParam = Graphic3d_RenderingParams::PerfCounters_FrameTime;
12526 Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'";
12530 aRenderParams = Graphic3d_RenderingParams::PerfCounters (aRenderParams | aParam);
12534 if (aRenderParams != Graphic3d_RenderingParams::PerfCounters_NONE)
12536 aView->ChangeRenderingParams().CollectedStats =
12537 Graphic3d_RenderingParams::PerfCounters (aView->RenderingParams().CollectedStats | aRenderParams);
12541 aView->ChangeRenderingParams().StatsUpdateInterval = -1;
12543 aView->ChangeRenderingParams().StatsUpdateInterval = aPrevUpdInterval;
12546 TColStd_IndexedDataMapOfStringString aDict;
12547 aView->StatisticInformation (aDict);
12549 aView->ChangeRenderingParams().CollectedStats = aPrevCounters;
12551 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
12553 Standard_CString anArg(theArgVec[anArgIter]);
12554 TCollection_AsciiString aFlag(anArg);
12556 if (aFlag == "fps")
12558 theDI << searchInfo (aDict, "FPS") << " ";
12560 else if (aFlag == "cpu")
12562 theDI << searchInfo (aDict, "CPU FPS") << " ";
12564 else if (aFlag == "alllayers")
12566 theDI << searchInfo (aDict, "Layers") << " ";
12568 else if (aFlag == "layers")
12570 theDI << searchInfo (aDict, "Rendered layers") << " ";
12572 else if (aFlag == "allstructs"
12573 || aFlag == "allstructures")
12575 theDI << searchInfo (aDict, "Structs") << " ";
12577 else if (aFlag == "structs"
12578 || aFlag == "structures")
12580 TCollection_AsciiString aRend = searchInfo (aDict, "Rendered structs");
12581 if (aRend.IsEmpty()) // all structures rendered
12583 aRend = searchInfo (aDict, "Structs");
12585 theDI << aRend << " ";
12587 else if (aFlag == "groups")
12589 theDI << searchInfo (aDict, "Rendered groups") << " ";
12591 else if (aFlag == "allarrays")
12593 theDI << searchInfo (aDict, "Rendered arrays") << " ";
12595 else if (aFlag == "fillarrays")
12597 theDI << searchInfo (aDict, "Rendered [fill] arrays") << " ";
12599 else if (aFlag == "linearrays")
12601 theDI << searchInfo (aDict, "Rendered [line] arrays") << " ";
12603 else if (aFlag == "pointarrays")
12605 theDI << searchInfo (aDict, "Rendered [point] arrays") << " ";
12607 else if (aFlag == "textarrays")
12609 theDI << searchInfo (aDict, "Rendered [text] arrays") << " ";
12611 else if (aFlag == "triangles")
12613 theDI << searchInfo (aDict, "Rendered triangles") << " ";
12615 else if (aFlag == "points")
12617 theDI << searchInfo (aDict, "Rendered points") << " ";
12619 else if (aFlag == "geommem")
12621 theDI << searchInfo (aDict, "GPU Memory [geometry]") << " ";
12623 else if (aFlag == "texturemem")
12625 theDI << searchInfo (aDict, "GPU Memory [textures]") << " ";
12627 else if (aFlag == "framemem")
12629 theDI << searchInfo (aDict, "GPU Memory [frames]") << " ";
12631 else if (aFlag == "elapsedframe")
12633 theDI << searchInfo (aDict, "Elapsed Frame (average)") << " ";
12635 else if (aFlag == "cpuframe_average")
12637 theDI << searchInfo (aDict, "CPU Frame (average)") << " ";
12639 else if (aFlag == "cpupicking_average")
12641 theDI << searchInfo (aDict, "CPU Picking (average)") << " ";
12643 else if (aFlag == "cpuculling_average")
12645 theDI << searchInfo (aDict, "CPU Culling (average)") << " ";
12647 else if (aFlag == "cpudyn_average")
12649 theDI << searchInfo (aDict, "CPU Dynamics (average)") << " ";
12651 else if (aFlag == "cpuframe_max")
12653 theDI << searchInfo (aDict, "CPU Frame (max)") << " ";
12655 else if (aFlag == "cpupicking_max")
12657 theDI << searchInfo (aDict, "CPU Picking (max)") << " ";
12659 else if (aFlag == "cpuculling_max")
12661 theDI << searchInfo (aDict, "CPU Culling (max)") << " ";
12663 else if (aFlag == "cpudyn_max")
12665 theDI << searchInfo (aDict, "CPU Dynamics (max)") << " ";
12673 aView->ChangeRenderingParams().StatsUpdateInterval = -1;
12675 aView->ChangeRenderingParams().StatsUpdateInterval = aPrevUpdInterval;
12677 theDI << "Statistic info:\n" << aView->StatisticInformation();
12682 //=======================================================================
12683 //function : VXRotate
12685 //=======================================================================
12686 static Standard_Integer VXRotate (Draw_Interpretor& di,
12687 Standard_Integer argc,
12688 const char ** argv)
12690 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
12691 if (aContext.IsNull())
12693 di << argv[0] << "ERROR : use 'vinit' command before \n";
12699 di << "ERROR : Usage : " << argv[0] << " name angle\n";
12703 TCollection_AsciiString aName (argv[1]);
12704 Standard_Real anAngle = Draw::Atof (argv[2]);
12707 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
12708 Handle(AIS_InteractiveObject) anIObj;
12709 if (!aMap.Find2 (aName, anIObj))
12711 di << "Use 'vdisplay' before\n";
12715 gp_Trsf aTransform;
12716 aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle);
12717 aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart());
12719 aContext->SetLocation (anIObj, aTransform);
12720 aContext->UpdateCurrentViewer();
12724 //===============================================================================================
12725 //function : VManipulator
12727 //===============================================================================================
12728 static int VManipulator (Draw_Interpretor& theDi,
12729 Standard_Integer theArgsNb,
12730 const char** theArgVec)
12732 Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
12733 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
12734 ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_False);
12735 if (aCurrentView.IsNull()
12736 || aViewer.IsNull())
12738 Message::SendFail ("Error: no active viewer");
12742 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
12743 Standard_Integer anArgIter = 1;
12744 for (; anArgIter < theArgsNb; ++anArgIter)
12746 anUpdateTool.parseRedrawMode (theArgVec[anArgIter]);
12749 ViewerTest_CmdParser aCmd;
12750 aCmd.SetDescription ("Manages manipulator for interactive objects:");
12751 aCmd.AddOption ("attach", "... object - attach manipulator to an object");
12752 aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
12753 aCmd.AddOption ("adjustSize", "... {0|1} - adjust size when attaching ");
12754 aCmd.AddOption ("enableModes", "... {0|1} - enable modes when attaching ");
12755 aCmd.AddOption ("view", "... {active | [view name]} - define view in which manipulator will be displayed, 'all' by default");
12756 aCmd.AddOption ("detach", "... - detach manipulator");
12758 aCmd.AddOption ("startTransform", "... mouse_x mouse_y - invoke start transformation");
12759 aCmd.AddOption ("transform", "... mouse_x mouse_y - invoke transformation");
12760 aCmd.AddOption ("stopTransform", "... [abort] - invoke stop transformation");
12762 aCmd.AddOption ("move", "... x y z - move object");
12763 aCmd.AddOption ("rotate", "... x y z dx dy dz angle - rotate object");
12764 aCmd.AddOption ("scale", "... factor - scale object");
12766 aCmd.AddOption ("autoActivate", "... {0|1} - set activation on detection");
12767 aCmd.AddOption ("followTranslation", "... {0|1} - set following translation transform");
12768 aCmd.AddOption ("followRotation", "... {0|1} - set following rotation transform");
12769 aCmd.AddOption ("followDragging", "... {0|1} - set following dragging transform");
12770 aCmd.AddOption ("gap", "... value - set gap between sub-parts");
12771 aCmd.AddOption ("part", "... axis mode {0|1} - set visual part");
12772 aCmd.AddOption ("parts", "... all axes mode {0|1} - set visual part");
12773 aCmd.AddOption ("pos", "... x y z [nx ny nz [xx xy xz]] - set position of manipulator");
12774 aCmd.AddOption ("size", "... size - set size of manipulator");
12775 aCmd.AddOption ("zoomable", "... {0|1} - set zoom persistence");
12777 aCmd.Parse (theArgsNb, theArgVec);
12779 if (aCmd.HasOption ("help"))
12781 theDi.PrintHelp (theArgVec[0]);
12785 ViewerTest_DoubleMapOfInteractiveAndName& aMapAIS = GetMapOfAIS();
12787 TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str());
12789 if (aName.IsEmpty())
12791 Message::SendFail ("Syntax error: please specify AIS manipulator's name as the first argument");
12795 // ----------------------------------
12796 // detach existing manipulator object
12797 // ----------------------------------
12799 if (aCmd.HasOption ("detach"))
12801 if (!aMapAIS.IsBound2 (aName))
12803 Message::SendFail() << "Syntax error: could not find \"" << aName << "\" AIS object";
12807 Handle(AIS_Manipulator) aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
12808 if (aManipulator.IsNull())
12810 Message::SendFail() << "Syntax error: \"" << aName << "\" is not an AIS manipulator";
12814 aManipulator->Detach();
12815 aMapAIS.UnBind2 (aName);
12816 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_True);
12821 // -----------------------------------------------
12822 // find or create manipulator if it does not exist
12823 // -----------------------------------------------
12825 Handle(AIS_Manipulator) aManipulator;
12826 if (!aMapAIS.IsBound2 (aName))
12828 std::cout << theArgVec[0] << ": AIS object \"" << aName << "\" has been created.\n";
12830 aManipulator = new AIS_Manipulator();
12831 aManipulator->SetModeActivationOnDetection (true);
12832 aMapAIS.Bind (aManipulator, aName);
12836 aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
12837 if (aManipulator.IsNull())
12839 Message::SendFail() << "Syntax error: \"" << aName << "\" is not an AIS manipulator";
12844 // -----------------------------------------
12845 // change properties of manipulator instance
12846 // -----------------------------------------
12848 if (aCmd.HasOption ("autoActivate", 1, Standard_True))
12850 aManipulator->SetModeActivationOnDetection (aCmd.ArgBool ("autoActivate"));
12852 if (aCmd.HasOption ("followTranslation", 1, Standard_True))
12854 aManipulator->ChangeTransformBehavior().SetFollowTranslation (aCmd.ArgBool ("followTranslation"));
12856 if (aCmd.HasOption ("followRotation", 1, Standard_True))
12858 aManipulator->ChangeTransformBehavior().SetFollowRotation (aCmd.ArgBool ("followRotation"));
12860 if (aCmd.HasOption("followDragging", 1, Standard_True))
12862 aManipulator->ChangeTransformBehavior().SetFollowDragging(aCmd.ArgBool("followDragging"));
12864 if (aCmd.HasOption ("gap", 1, Standard_True))
12866 aManipulator->SetGap (aCmd.ArgFloat ("gap"));
12868 if (aCmd.HasOption ("part", 3, Standard_True))
12870 Standard_Integer anAxis = aCmd.ArgInt ("part", 0);
12871 Standard_Integer aMode = aCmd.ArgInt ("part", 1);
12872 Standard_Boolean aOnOff = aCmd.ArgBool ("part", 2);
12873 if (aMode < 1 || aMode > 4)
12875 Message::SendFail ("Syntax error: mode value should be in range [1, 4]");
12879 aManipulator->SetPart (anAxis, static_cast<AIS_ManipulatorMode> (aMode), aOnOff);
12881 if (aCmd.HasOption("parts", 2, Standard_True))
12883 Standard_Integer aMode = aCmd.ArgInt("parts", 0);
12884 Standard_Boolean aOnOff = aCmd.ArgBool("parts", 1);
12885 if (aMode < 1 || aMode > 4)
12887 Message::SendFail ("Syntax error: mode value should be in range [1, 4]");
12891 aManipulator->SetPart(static_cast<AIS_ManipulatorMode>(aMode), aOnOff);
12893 if (aCmd.HasOption ("pos", 3, Standard_True))
12895 gp_Pnt aLocation = aCmd.ArgPnt ("pos", 0);
12896 gp_Dir aVDir = aCmd.HasOption ("pos", 6) ? gp_Dir (aCmd.ArgVec ("pos", 3)) : aManipulator->Position().Direction();
12897 gp_Dir aXDir = aCmd.HasOption ("pos", 9) ? gp_Dir (aCmd.ArgVec ("pos", 6)) : aManipulator->Position().XDirection();
12899 aManipulator->SetPosition (gp_Ax2 (aLocation, aVDir, aXDir));
12901 if (aCmd.HasOption ("size", 1, Standard_True))
12903 aManipulator->SetSize (aCmd.ArgFloat ("size"));
12905 if (aCmd.HasOption ("zoomable", 1, Standard_True))
12907 aManipulator->SetZoomPersistence (!aCmd.ArgBool ("zoomable"));
12909 if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator))
12911 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_False);
12912 ViewerTest::GetAISContext()->Display (aManipulator, Standard_False);
12916 // ---------------------------------------------------
12917 // attach, detach or access manipulator from an object
12918 // ---------------------------------------------------
12920 if (aCmd.HasOption ("attach"))
12922 // Find an object and attach manipulator to it
12923 if (!aCmd.HasOption ("attach", 1, Standard_True))
12928 TCollection_AsciiString anObjName (aCmd.Arg ("attach", 0).c_str());
12929 Handle(AIS_InteractiveObject) anObject;
12930 if (!aMapAIS.Find2 (anObjName, anObject))
12932 Message::SendFail() << "Syntax error: AIS object \"" << anObjName << "\" does not exist";
12936 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (aMapAIS);
12937 anIter.More(); anIter.Next())
12939 Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (anIter.Key1());
12940 if (!aManip.IsNull()
12941 && aManip->IsAttached()
12942 && aManip->Object() == anObject)
12944 Message::SendFail() << "Syntax error: AIS object \"" << anObjName << "\" already has manipulator";
12949 AIS_Manipulator::OptionsForAttach anOptions;
12950 if (aCmd.HasOption ("adjustPosition", 1, Standard_True))
12952 anOptions.SetAdjustPosition (aCmd.ArgBool ("adjustPosition"));
12954 if (aCmd.HasOption ("adjustSize", 1, Standard_True))
12956 anOptions.SetAdjustSize (aCmd.ArgBool ("adjustSize"));
12958 if (aCmd.HasOption ("enableModes", 1, Standard_True))
12960 anOptions.SetEnableModes (aCmd.ArgBool ("enableModes"));
12963 aManipulator->Attach (anObject, anOptions);
12965 // Check view option
12966 if (aCmd.HasOption ("view"))
12968 if (!aCmd.HasOption ("view", 1, Standard_True))
12972 TCollection_AsciiString aViewString (aCmd.Arg ("view", 0).c_str());
12973 Handle(V3d_View) aView;
12974 if (aViewString.IsEqual ("active"))
12976 aView = ViewerTest::CurrentView();
12978 else // Check view name
12980 ViewerTest_Names aViewNames (aViewString);
12981 if (!ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
12983 Message::SendFail() << "Syntax error: wrong view name '" << aViewString << "'";
12986 aView = ViewerTest_myViews.Find1 (aViewNames.GetViewName());
12987 if (aView.IsNull())
12989 Message::SendFail() << "Syntax error: cannot find view with name '" << aViewString << "'";
12993 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
12994 anIter (ViewerTest_myViews); anIter.More(); anIter.Next())
12996 ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Value(), Standard_False);
12998 ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, aView, Standard_True);
13002 // --------------------------------------
13003 // apply transformation using manipulator
13004 // --------------------------------------
13006 if (aCmd.HasOption ("startTransform", 2, Standard_True))
13008 aManipulator->StartTransform (aCmd.ArgInt ("startTransform", 0), aCmd.ArgInt ("startTransform", 1), ViewerTest::CurrentView());
13010 if (aCmd.HasOption ("transform", 2, Standard_True))
13012 aManipulator->Transform (aCmd.ArgInt ("transform", 0), aCmd.ArgInt ("transform", 1), ViewerTest::CurrentView());
13014 if (aCmd.HasOption ("stopTransform"))
13016 Standard_Boolean toApply = !aCmd.HasOption ("stopTransform", 1) || (aCmd.Arg ("stopTransform", 0) != "abort");
13018 aManipulator->StopTransform (toApply);
13022 if (aCmd.HasOption ("move", 3, Standard_True))
13024 aT.SetTranslationPart (aCmd.ArgVec ("move"));
13026 if (aCmd.HasOption ("rotate", 7, Standard_True))
13028 aT.SetRotation (gp_Ax1 (aCmd.ArgPnt ("rotate", 0), aCmd.ArgVec ("rotate", 3)), aCmd.ArgDouble ("rotate", 6));
13030 if (aCmd.HasOption ("scale", 1))
13032 aT.SetScale (gp_Pnt(), aCmd.ArgDouble("scale"));
13035 if (aT.Form() != gp_Identity)
13037 aManipulator->Transform (aT);
13040 ViewerTest::GetAISContext()->Redisplay (aManipulator, Standard_True);
13045 //===============================================================================================
13046 //function : VSelectionProperties
13048 //===============================================================================================
13049 static int VSelectionProperties (Draw_Interpretor& theDi,
13050 Standard_Integer theArgsNb,
13051 const char** theArgVec)
13053 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
13056 Message::SendFail ("Error: no active viewer");
13060 if (TCollection_AsciiString (theArgVec[0]) == "vhighlightselected")
13062 // handle obsolete alias
13063 bool toEnable = true;
13066 theDi << (aCtx->ToHilightSelected() ? "on" : "off");
13069 else if (theArgsNb != 2
13070 || !ViewerTest::ParseOnOff (theArgVec[1], toEnable))
13072 Message::SendFail ("Syntax error: wrong number of parameters");
13075 if (toEnable != aCtx->ToHilightSelected())
13077 aCtx->ClearDetected();
13078 aCtx->SetToHilightSelected (toEnable);
13083 Standard_Boolean toPrint = theArgsNb == 1;
13084 Standard_Boolean toRedraw = Standard_False;
13085 Standard_Integer anArgIter = 1;
13086 Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None;
13087 if (anArgIter < theArgsNb)
13089 TCollection_AsciiString anArgFirst (theArgVec[anArgIter]);
13090 anArgFirst.LowerCase();
13092 if (anArgFirst == "dynhighlight"
13093 || anArgFirst == "dynhilight"
13094 || anArgFirst == "dynamichighlight"
13095 || anArgFirst == "dynamichilight")
13097 aType = Prs3d_TypeOfHighlight_Dynamic;
13099 else if (anArgFirst == "localdynhighlight"
13100 || anArgFirst == "localdynhilight"
13101 || anArgFirst == "localdynamichighlight"
13102 || anArgFirst == "localdynamichilight")
13104 aType = Prs3d_TypeOfHighlight_LocalDynamic;
13106 else if (anArgFirst == "selhighlight"
13107 || anArgFirst == "selhilight"
13108 || anArgFirst == "selectedhighlight"
13109 || anArgFirst == "selectedhilight")
13111 aType = Prs3d_TypeOfHighlight_Selected;
13113 else if (anArgFirst == "localselhighlight"
13114 || anArgFirst == "localselhilight"
13115 || anArgFirst == "localselectedhighlight"
13116 || anArgFirst == "localselectedhilight")
13118 aType = Prs3d_TypeOfHighlight_LocalSelected;
13125 for (; anArgIter < theArgsNb; ++anArgIter)
13127 TCollection_AsciiString anArg (theArgVec[anArgIter]);
13129 if (anArg == "-help")
13131 theDi.PrintHelp (theArgVec[0]);
13134 else if (anArg == "-print")
13136 toPrint = Standard_True;
13138 else if (anArg == "-autoactivate")
13140 Standard_Boolean toEnable = Standard_True;
13141 if (anArgIter + 1 < theArgsNb
13142 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
13146 aCtx->SetAutoActivateSelection (toEnable);
13148 else if (anArg == "-automatichighlight"
13149 || anArg == "-automatichilight"
13150 || anArg == "-autohighlight"
13151 || anArg == "-autohilight")
13153 Standard_Boolean toEnable = Standard_True;
13154 if (anArgIter + 1 < theArgsNb
13155 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
13159 aCtx->ClearSelected (false);
13160 aCtx->ClearDetected();
13161 aCtx->SetAutomaticHilight (toEnable);
13164 else if (anArg == "-highlightselected"
13165 || anArg == "-hilightselected")
13167 Standard_Boolean toEnable = Standard_True;
13168 if (anArgIter + 1 < theArgsNb
13169 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
13173 aCtx->ClearDetected();
13174 aCtx->SetToHilightSelected (toEnable);
13177 else if (anArg == "-pickstrategy"
13178 || anArg == "-pickingstrategy")
13180 if (++anArgIter >= theArgsNb)
13182 Message::SendFail ("Syntax error: type of highlighting is undefined");
13186 SelectMgr_PickingStrategy aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
13187 TCollection_AsciiString aVal (theArgVec[anArgIter]);
13189 if (aVal == "first"
13190 || aVal == "firstaccepted"
13191 || aVal == "firstacceptable")
13193 aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
13195 else if (aVal == "topmost"
13196 || aVal == "onlyTopmost")
13198 aStrategy = SelectMgr_PickingStrategy_OnlyTopmost;
13202 Message::SendFail() << "Syntax error: unknown picking strategy '" << aVal << "'";
13206 aCtx->SetPickingStrategy (aStrategy);
13208 else if (anArg == "-pixtol"
13209 && anArgIter + 1 < theArgsNb)
13211 aCtx->SetPixelTolerance (Draw::Atoi (theArgVec[++anArgIter]));
13213 else if ((anArg == "-mode"
13214 || anArg == "-dispmode")
13215 && anArgIter + 1 < theArgsNb)
13217 if (aType == Prs3d_TypeOfHighlight_None)
13219 Message::SendFail ("Syntax error: type of highlighting is undefined");
13223 const Standard_Integer aDispMode = Draw::Atoi (theArgVec[++anArgIter]);
13224 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13225 aStyle->SetDisplayMode (aDispMode);
13226 toRedraw = Standard_True;
13228 else if (anArg == "-layer"
13229 && anArgIter + 1 < theArgsNb)
13231 if (aType == Prs3d_TypeOfHighlight_None)
13233 Message::SendFail ("Syntax error: type of highlighting is undefined");
13238 Graphic3d_ZLayerId aNewLayer = Graphic3d_ZLayerId_UNKNOWN;
13239 if (!ViewerTest::ParseZLayer (theArgVec[anArgIter], aNewLayer))
13241 Message::SendFail() << "Syntax error at " << theArgVec[anArgIter];
13245 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13246 aStyle->SetZLayer (aNewLayer);
13247 toRedraw = Standard_True;
13249 else if (anArg == "-hicolor"
13250 || anArg == "-selcolor"
13251 || anArg == "-color")
13253 if (anArg.StartsWith ("-hi"))
13255 aType = Prs3d_TypeOfHighlight_Dynamic;
13257 else if (anArg.StartsWith ("-sel"))
13259 aType = Prs3d_TypeOfHighlight_Selected;
13261 else if (aType == Prs3d_TypeOfHighlight_None)
13263 Message::SendFail ("Syntax error: type of highlighting is undefined");
13267 Quantity_Color aColor;
13268 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIter - 1,
13269 theArgVec + anArgIter + 1,
13271 if (aNbParsed == 0)
13273 Message::SendFail ("Syntax error: need more arguments");
13276 anArgIter += aNbParsed;
13278 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13279 aStyle->SetColor (aColor);
13280 toRedraw = Standard_True;
13282 else if ((anArg == "-transp"
13283 || anArg == "-transparency"
13284 || anArg == "-hitransp"
13285 || anArg == "-seltransp"
13286 || anArg == "-hitransplocal"
13287 || anArg == "-seltransplocal")
13288 && anArgIter + 1 < theArgsNb)
13290 if (anArg.StartsWith ("-hi"))
13292 aType = Prs3d_TypeOfHighlight_Dynamic;
13294 else if (anArg.StartsWith ("-sel"))
13296 aType = Prs3d_TypeOfHighlight_Selected;
13298 else if (aType == Prs3d_TypeOfHighlight_None)
13300 Message::SendFail ("Syntax error: type of highlighting is undefined");
13304 const Standard_Real aTransp = Draw::Atof (theArgVec[++anArgIter]);
13305 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13306 aStyle->SetTransparency ((Standard_ShortReal )aTransp);
13307 toRedraw = Standard_True;
13309 else if ((anArg == "-mat"
13310 || anArg == "-material")
13311 && anArgIter + 1 < theArgsNb)
13313 if (aType == Prs3d_TypeOfHighlight_None)
13315 Message::SendFail ("Syntax error: type of highlighting is undefined");
13319 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13320 Graphic3d_NameOfMaterial aMatName = Graphic3d_MaterialAspect::MaterialFromName (theArgVec[anArgIter + 1]);
13321 if (aMatName != Graphic3d_NOM_DEFAULT)
13324 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
13325 *anAspect = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
13326 Graphic3d_MaterialAspect aMat (aMatName);
13327 aMat.SetColor (aStyle->Color());
13328 aMat.SetTransparency (aStyle->Transparency());
13329 anAspect->SetFrontMaterial (aMat);
13330 anAspect->SetInteriorColor (aStyle->Color());
13331 aStyle->SetBasicFillAreaAspect (anAspect);
13335 aStyle->SetBasicFillAreaAspect (Handle(Graphic3d_AspectFillArea3d)());
13337 toRedraw = Standard_True;
13341 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
13347 const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle();
13348 const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle();
13349 theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n";
13350 theDi << "Auto-highlight : " << (aCtx->AutomaticHilight() ? "On" : "Off") << "\n";
13351 theDi << "Highlight selected : " << (aCtx->ToHilightSelected() ? "On" : "Off") << "\n";
13352 theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n";
13353 theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n";
13354 theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n";
13355 theDi << "Selection transparency : " << aSelStyle->Transparency() << "\n";
13356 theDi << "Dynamic highlight transparency : " << aHiStyle->Transparency() << "\n";
13357 theDi << "Selection mode : " << aSelStyle->DisplayMode() << "\n";
13358 theDi << "Dynamic highlight mode : " << aHiStyle->DisplayMode() << "\n";
13359 theDi << "Selection layer : " << aSelStyle->ZLayer() << "\n";
13360 theDi << "Dynamic layer : " << aHiStyle->ZLayer() << "\n";
13363 if (aCtx->NbSelected() != 0 && toRedraw)
13365 aCtx->HilightSelected (Standard_True);
13371 //===============================================================================================
13372 //function : VDumpSelectionImage
13374 //===============================================================================================
13375 static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
13376 Standard_Integer theArgsNb,
13377 const char** theArgVec)
13381 Message::SendFail() << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'";
13385 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
13386 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
13387 if (aContext.IsNull())
13389 Message::SendFail ("Error: no active viewer");
13393 TCollection_AsciiString aFile;
13394 StdSelect_TypeOfSelectionImage aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
13395 Handle(Graphic3d_Camera) aCustomCam;
13396 Image_Format anImgFormat = Image_Format_BGR;
13397 Standard_Integer aPickedIndex = 1;
13398 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
13400 TCollection_AsciiString aParam (theArgVec[anArgIter]);
13401 aParam.LowerCase();
13402 if (aParam == "-type")
13404 if (++anArgIter >= theArgsNb)
13406 Message::SendFail ("Syntax error: wrong number parameters of flag '-depth'");
13410 TCollection_AsciiString aValue (theArgVec[anArgIter]);
13411 aValue.LowerCase();
13412 if (aValue == "depth"
13413 || aValue == "normdepth"
13414 || aValue == "normalizeddepth")
13416 aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
13417 anImgFormat = Image_Format_GrayF;
13419 if (aValue == "depthinverted"
13420 || aValue == "normdepthinverted"
13421 || aValue == "normalizeddepthinverted"
13422 || aValue == "inverted")
13424 aType = StdSelect_TypeOfSelectionImage_NormalizedDepthInverted;
13425 anImgFormat = Image_Format_GrayF;
13427 else if (aValue == "unnormdepth"
13428 || aValue == "unnormalizeddepth")
13430 aType = StdSelect_TypeOfSelectionImage_UnnormalizedDepth;
13431 anImgFormat = Image_Format_GrayF;
13433 else if (aValue == "objectcolor"
13434 || aValue == "object"
13435 || aValue == "color")
13437 aType = StdSelect_TypeOfSelectionImage_ColoredDetectedObject;
13439 else if (aValue == "entitycolor"
13440 || aValue == "entity")
13442 aType = StdSelect_TypeOfSelectionImage_ColoredEntity;
13444 else if (aValue == "ownercolor"
13445 || aValue == "owner")
13447 aType = StdSelect_TypeOfSelectionImage_ColoredOwner;
13449 else if (aValue == "selectionmodecolor"
13450 || aValue == "selectionmode"
13451 || aValue == "selmodecolor"
13452 || aValue == "selmode")
13454 aType = StdSelect_TypeOfSelectionImage_ColoredSelectionMode;
13457 else if (aParam == "-picked"
13458 || aParam == "-pickeddepth"
13459 || aParam == "-pickedindex")
13461 if (++anArgIter >= theArgsNb)
13463 Message::SendFail() << "Syntax error: wrong number parameters at '" << aParam << "'";
13467 aPickedIndex = Draw::Atoi (theArgVec[anArgIter]);
13469 else if (anArgIter + 1 < theArgsNb
13470 && aParam == "-xrpose")
13472 TCollection_AsciiString anXRArg (theArgVec[++anArgIter]);
13473 anXRArg.LowerCase();
13474 if (anXRArg == "base")
13476 aCustomCam = aView->View()->BaseXRCamera();
13478 else if (anXRArg == "head")
13480 aCustomCam = aView->View()->PosedXRCamera();
13484 Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'";
13487 if (aCustomCam.IsNull())
13489 Message::SendFail() << "Error: undefined XR pose";
13493 else if (aFile.IsEmpty())
13495 aFile = theArgVec[anArgIter];
13499 Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
13503 if (aFile.IsEmpty())
13505 Message::SendFail ("Syntax error: image file name is missing");
13509 Standard_Integer aWidth = 0, aHeight = 0;
13510 aView->Window()->Size (aWidth, aHeight);
13512 Image_AlienPixMap aPixMap;
13513 if (!aPixMap.InitZero (anImgFormat, aWidth, aHeight))
13515 Message::SendFail ("Error: can't allocate image");
13519 const bool wasImmUpdate = aView->SetImmediateUpdate (false);
13520 Handle(Graphic3d_Camera) aCamBack = aView->Camera();
13521 if (!aCustomCam.IsNull())
13523 aView->SetCamera (aCustomCam);
13525 if (!aContext->MainSelector()->ToPixMap (aPixMap, aView, aType, aPickedIndex))
13527 Message::SendFail ("Error: can't generate selection image");
13530 if (!aCustomCam.IsNull())
13532 aView->SetCamera (aCamBack);
13534 aView->SetImmediateUpdate (wasImmUpdate);
13536 if (!aPixMap.Save (aFile))
13538 Message::SendFail ("Error: can't save selection image");
13544 //===============================================================================================
13545 //function : VViewCube
13547 //===============================================================================================
13548 static int VViewCube (Draw_Interpretor& ,
13549 Standard_Integer theNbArgs,
13550 const char** theArgVec)
13552 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
13553 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
13554 if (aContext.IsNull() || aView.IsNull())
13556 Message::SendFail ("Error: no active viewer");
13559 else if (theNbArgs < 2)
13561 Message::SendFail ("Syntax error: wrong number arguments");
13565 Handle(AIS_ViewCube) aViewCube;
13566 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
13567 Quantity_Color aColorRgb;
13568 TCollection_AsciiString aName;
13569 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
13571 TCollection_AsciiString anArg (theArgVec[anArgIter]);
13573 if (anUpdateTool.parseRedrawMode (anArg))
13577 else if (aViewCube.IsNull())
13579 aName = theArgVec[anArgIter];
13580 if (aName.StartsWith ("-"))
13582 Message::SendFail ("Syntax error: object name should be specified");
13585 Handle(AIS_InteractiveObject) aPrs;
13586 GetMapOfAIS().Find2 (aName, aPrs);
13587 aViewCube = Handle(AIS_ViewCube)::DownCast (aPrs);
13588 if (aViewCube.IsNull())
13590 aViewCube = new AIS_ViewCube();
13591 aViewCube->SetBoxColor (Quantity_NOC_GRAY50);
13592 aViewCube->SetViewAnimation (ViewerTest::CurrentEventManager()->ViewAnimation());
13593 aViewCube->SetFixedAnimationLoop (false);
13596 else if (anArg == "-reset")
13598 aViewCube->ResetStyles();
13600 else if (anArg == "-color"
13601 || anArg == "-boxcolor"
13602 || anArg == "-boxsidecolor"
13603 || anArg == "-sidecolor"
13604 || anArg == "-boxedgecolor"
13605 || anArg == "-edgecolor"
13606 || anArg == "-boxcornercolor"
13607 || anArg == "-cornercolor"
13608 || anArg == "-innercolor"
13609 || anArg == "-textcolor")
13611 Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
13612 theArgVec + anArgIter + 1,
13614 if (aNbParsed == 0)
13616 Message::SendFail() << "Syntax error at '" << anArg << "'";
13619 anArgIter += aNbParsed;
13620 if (anArg == "-boxcolor")
13622 aViewCube->SetBoxColor (aColorRgb);
13624 else if (anArg == "-boxsidecolor"
13625 || anArg == "-sidecolor")
13627 aViewCube->BoxSideStyle()->SetColor (aColorRgb);
13628 aViewCube->SynchronizeAspects();
13630 else if (anArg == "-boxedgecolor"
13631 || anArg == "-edgecolor")
13633 aViewCube->BoxEdgeStyle()->SetColor (aColorRgb);
13634 aViewCube->SynchronizeAspects();
13636 else if (anArg == "-boxcornercolor"
13637 || anArg == "-cornercolor")
13639 aViewCube->BoxCornerStyle()->SetColor (aColorRgb);
13640 aViewCube->SynchronizeAspects();
13642 else if (anArg == "-innercolor")
13644 aViewCube->SetInnerColor (aColorRgb);
13646 else if (anArg == "-textcolor")
13648 aViewCube->SetTextColor (aColorRgb);
13652 aViewCube->SetColor (aColorRgb);
13655 else if (anArgIter + 1 < theNbArgs
13656 && (anArg == "-transparency"
13657 || anArg == "-boxtransparency"))
13659 const Standard_Real aValue = Draw::Atof (theArgVec[++anArgIter]);
13660 if (aValue < 0.0 || aValue > 1.0)
13662 Message::SendFail() << "Syntax error: invalid transparency value " << theArgVec[anArgIter];
13666 if (anArg == "-boxtransparency")
13668 aViewCube->SetBoxTransparency (aValue);
13672 aViewCube->SetTransparency (aValue);
13675 else if (anArg == "-axes"
13676 || anArg == "-edges"
13677 || anArg == "-vertices"
13678 || anArg == "-vertexes"
13679 || anArg == "-fixedanimation")
13681 bool toShow = true;
13682 if (anArgIter + 1 < theNbArgs
13683 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShow))
13687 if (anArg == "-fixedanimation")
13689 aViewCube->SetFixedAnimationLoop (toShow);
13691 else if (anArg == "-axes")
13693 aViewCube->SetDrawAxes (toShow);
13695 else if (anArg == "-edges")
13697 aViewCube->SetDrawEdges (toShow);
13701 aViewCube->SetDrawVertices (toShow);
13704 else if (anArg == "-yup"
13705 || anArg == "-zup")
13708 if (anArgIter + 1 < theNbArgs
13709 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isOn))
13713 if (anArg == "-yup")
13715 aViewCube->SetYup (isOn);
13719 aViewCube->SetYup (!isOn);
13722 else if (anArgIter + 1 < theNbArgs
13723 && anArg == "-font")
13725 aViewCube->SetFont (theArgVec[++anArgIter]);
13727 else if (anArgIter + 1 < theNbArgs
13728 && anArg == "-fontheight")
13730 aViewCube->SetFontHeight (Draw::Atof (theArgVec[++anArgIter]));
13732 else if (anArgIter + 1 < theNbArgs
13733 && (anArg == "-size"
13734 || anArg == "-boxsize"))
13736 aViewCube->SetSize (Draw::Atof (theArgVec[++anArgIter]),
13737 anArg != "-boxsize");
13739 else if (anArgIter + 1 < theNbArgs
13740 && (anArg == "-boxfacet"
13741 || anArg == "-boxfacetextension"
13742 || anArg == "-facetextension"
13743 || anArg == "-extension"))
13745 aViewCube->SetBoxFacetExtension (Draw::Atof (theArgVec[++anArgIter]));
13747 else if (anArgIter + 1 < theNbArgs
13748 && (anArg == "-boxedgegap"
13749 || anArg == "-edgegap"))
13751 aViewCube->SetBoxEdgeGap (Draw::Atof (theArgVec[++anArgIter]));
13753 else if (anArgIter + 1 < theNbArgs
13754 && (anArg == "-boxedgeminsize"
13755 || anArg == "-edgeminsize"))
13757 aViewCube->SetBoxEdgeMinSize (Draw::Atof (theArgVec[++anArgIter]));
13759 else if (anArgIter + 1 < theNbArgs
13760 && (anArg == "-boxcornerminsize"
13761 || anArg == "-cornerminsize"))
13763 aViewCube->SetBoxCornerMinSize (Draw::Atof (theArgVec[++anArgIter]));
13765 else if (anArgIter + 1 < theNbArgs
13766 && anArg == "-axespadding")
13768 aViewCube->SetAxesPadding (Draw::Atof (theArgVec[++anArgIter]));
13770 else if (anArgIter + 1 < theNbArgs
13771 && anArg == "-roundradius")
13773 aViewCube->SetRoundRadius (Draw::Atof (theArgVec[++anArgIter]));
13775 else if (anArgIter + 1 < theNbArgs
13776 && anArg == "-duration")
13778 aViewCube->SetDuration (Draw::Atof (theArgVec[++anArgIter]));
13780 else if (anArgIter + 1 < theNbArgs
13781 && anArg == "-axesradius")
13783 aViewCube->SetAxesRadius (Draw::Atof (theArgVec[++anArgIter]));
13785 else if (anArgIter + 1 < theNbArgs
13786 && anArg == "-axesconeradius")
13788 aViewCube->SetAxesConeRadius (Draw::Atof (theArgVec[++anArgIter]));
13790 else if (anArgIter + 1 < theNbArgs
13791 && anArg == "-axessphereradius")
13793 aViewCube->SetAxesSphereRadius (Draw::Atof (theArgVec[++anArgIter]));
13797 Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'";
13801 if (aViewCube.IsNull())
13803 Message::SendFail ("Syntax error: wrong number of arguments");
13807 ViewerTest::Display (aName, aViewCube, false);
13811 //===============================================================================================
13812 //function : VColorConvert
13814 //===============================================================================================
13815 static int VColorConvert (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
13817 if (theNbArgs != 6)
13819 std::cerr << "Error: command syntax is incorrect, see help" << std::endl;
13823 Standard_Boolean convertFrom = (! strcasecmp (theArgVec[1], "from"));
13824 if (! convertFrom && strcasecmp (theArgVec[1], "to"))
13826 std::cerr << "Error: first argument must be either \"to\" or \"from\"" << std::endl;
13830 const char* aTypeStr = theArgVec[2];
13831 Quantity_TypeOfColor aType = Quantity_TOC_RGB;
13832 if (! strcasecmp (aTypeStr, "srgb"))
13834 aType = Quantity_TOC_sRGB;
13836 else if (! strcasecmp (aTypeStr, "hls"))
13838 aType = Quantity_TOC_HLS;
13840 else if (! strcasecmp (aTypeStr, "lab"))
13842 aType = Quantity_TOC_CIELab;
13844 else if (! strcasecmp (aTypeStr, "lch"))
13846 aType = Quantity_TOC_CIELch;
13850 std::cerr << "Error: unknown colorspace type: " << aTypeStr << std::endl;
13854 double aC1 = Draw::Atof (theArgVec[3]);
13855 double aC2 = Draw::Atof (theArgVec[4]);
13856 double aC3 = Draw::Atof (theArgVec[5]);
13858 Quantity_Color aColor (aC1, aC2, aC3, convertFrom ? aType : Quantity_TOC_RGB);
13859 aColor.Values (aC1, aC2, aC3, convertFrom ? Quantity_TOC_RGB : aType);
13861 // print values with 6 decimal digits
13863 Sprintf (buffer, "%.6f %.6f %.6f", aC1, aC2, aC3);
13869 //===============================================================================================
13870 //function : VColorDiff
13872 //===============================================================================================
13873 static int VColorDiff (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
13875 if (theNbArgs != 7)
13877 std::cerr << "Error: command syntax is incorrect, see help" << std::endl;
13881 double aR1 = Draw::Atof (theArgVec[1]);
13882 double aG1 = Draw::Atof (theArgVec[2]);
13883 double aB1 = Draw::Atof (theArgVec[3]);
13884 double aR2 = Draw::Atof (theArgVec[4]);
13885 double aG2 = Draw::Atof (theArgVec[5]);
13886 double aB2 = Draw::Atof (theArgVec[6]);
13888 Quantity_Color aColor1 (aR1, aG1, aB1, Quantity_TOC_RGB);
13889 Quantity_Color aColor2 (aR2, aG2, aB2, Quantity_TOC_RGB);
13891 theDI << aColor1.DeltaE2000 (aColor2);
13896 //=======================================================================
13897 //function : ViewerCommands
13899 //=======================================================================
13901 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
13904 const char *group = "ZeViewer";
13905 theCommands.Add("vinit",
13906 "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]"
13907 "\n\t\t: [-exitOnClose] [-closeOnEscape] [-cloneActive] [-2d_mode {on|off}=off]"
13908 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
13909 "\n\t\t: [-display displayName]"
13911 "\n\t\t: Creates new View window with specified name viewName."
13912 "\n\t\t: By default the new view is created in the viewer and in"
13913 "\n\t\t: graphic driver shared with active view."
13914 "\n\t\t: -name {driverName/viewerName/viewName | viewerName/viewName | viewName}"
13915 "\n\t\t: If driverName isn't specified the driver will be shared with active view."
13916 "\n\t\t: If viewerName isn't specified the viewer will be shared with active view."
13917 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
13918 "\n\t\t: -display HostName.DisplayNumber[:ScreenNumber]"
13919 "\n\t\t: Display name will be used within creation of graphic driver, when specified."
13921 "\n\t\t: -left, -top pixel position of left top corner of the window."
13922 "\n\t\t: -width, -height width and heigth of window respectively."
13923 "\n\t\t: -cloneActive floag to copy camera and dimensions of active view."
13924 "\n\t\t: -exitOnClose when specified, closing the view will exit application."
13925 "\n\t\t: -closeOnEscape when specified, view will be closed on pressing Escape."
13926 "\n\t\t: -2d_mode when on, view will not react on rotate scene events"
13927 "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.",
13928 __FILE__,VInit,group);
13929 theCommands.Add("vclose" ,
13930 "[view_id [keep_context=0|1]]\n"
13931 "or vclose ALL - to remove all created views\n"
13932 " - removes view(viewer window) defined by its view_id.\n"
13933 " - keep_context: by default 0; if 1 and the last view is deleted"
13934 " the current context is not removed.",
13935 __FILE__,VClose,group);
13936 theCommands.Add("vactivate" ,
13937 "vactivate view_id [-noUpdate]"
13938 " - activates view(viewer window) defined by its view_id",
13939 __FILE__,VActivate,group);
13940 theCommands.Add("vviewlist",
13941 "vviewlist [format={tree, long}]"
13942 " - prints current list of views per viewer and graphic_driver ID shared between viewers"
13943 " - format: format of result output, if tree the output is a tree view;"
13944 "otherwise it's a list of full view names. By default format = tree",
13945 __FILE__,VViewList,group);
13946 theCommands.Add("vhelp" ,
13947 "vhelp : display help on the viewer commands",
13948 __FILE__,VHelp,group);
13949 theCommands.Add("vviewproj",
13950 "vviewproj [top|bottom|left|right|front|back|axoLeft|axoRight]"
13951 "\n\t\t: [+-X+-Y+-Z] [-Zup|-Yup] [-frame +-X+-Y]"
13952 "\n\t\t: Setup view direction"
13953 "\n\t\t: -Yup use Y-up convention instead of Zup (which is default)."
13954 "\n\t\t: +-X+-Y+-Z define direction as combination of DX, DY and DZ;"
13955 "\n\t\t: for example '+Z' will show front of the model,"
13956 "\n\t\t: '-X-Y+Z' will define left axonometrical view."
13957 "\n\t\t: -frame define camera Up and Right directions (regardless Up convention);"
13958 "\n\t\t: for example '+X+Z' will show front of the model with Z-up."
13959 __FILE__,VViewProj,group);
13960 theCommands.Add("vtop" ,
13961 "vtop or <T> : Top view. Orientation +X+Y" ,
13962 __FILE__,VViewProj,group);
13963 theCommands.Add("vbottom" ,
13964 "vbottom : Bottom view. Orientation +X-Y" ,
13965 __FILE__,VViewProj,group);
13966 theCommands.Add("vleft" ,
13967 "vleft : Left view. Orientation -Y+Z" ,
13968 __FILE__,VViewProj,group);
13969 theCommands.Add("vright" ,
13970 "vright : Right view. Orientation +Y+Z" ,
13971 __FILE__,VViewProj,group);
13972 theCommands.Add("vaxo" ,
13973 " vaxo or <A> : Axonometric view. Orientation +X-Y+Z",
13974 __FILE__,VViewProj,group);
13975 theCommands.Add("vfront" ,
13976 "vfront : Front view. Orientation +X+Z" ,
13977 __FILE__,VViewProj,group);
13978 theCommands.Add("vback" ,
13979 "vback : Back view. Orientation -X+Z" ,
13980 __FILE__,VViewProj,group);
13981 theCommands.Add("vpick" ,
13982 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
13984 theCommands.Add("vfit",
13985 "vfit or <F> [-selected] [-noupdate]"
13986 "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects",
13987 __FILE__,VFit,group);
13988 theCommands.Add ("vfitarea",
13989 "vfitarea x1 y1 x2 y2"
13990 "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2"
13991 "\n\t\t: Fit view to show area located between two points"
13992 "\n\t\t: given in world 2D or 3D corrdinates.",
13993 __FILE__, VFitArea, group);
13994 theCommands.Add ("vzfit", "vzfit [scale]\n"
13995 " Matches Z near, Z far view volume planes to the displayed objects.\n"
13996 " \"scale\" - specifies factor to scale computed z range.\n",
13997 __FILE__, VZFit, group);
13998 theCommands.Add("vrepaint",
13999 "vrepaint [-immediate] [-continuous FPS]"
14000 "\n\t\t: force redraw of active View"
14001 "\n\t\t: -immediate flag performs redraw of immediate layers only;"
14002 "\n\t\t: -continuous activates/deactivates continuous redraw of active View,"
14003 "\n\t\t: 0 means no continuous rendering,"
14004 "\n\t\t: -1 means non-stop redraws,"
14005 "\n\t\t: >0 specifies target framerate,",
14006 __FILE__,VRepaint,group);
14007 theCommands.Add("vclear",
14009 "\n\t\t: remove all the object from the viewer",
14010 __FILE__,VClear,group);
14013 "Changes background or some background settings.\n"
14016 " vbackground -imageFile ImageFile [-imageMode FillType]\n"
14017 " vbackground -imageMode FillType\n"
14018 " vbackground -gradient Color1 Color2 [-gradientMode FillMethod]\n"
14019 " vbackground -gradientMode FillMethod\n"
14020 " vbackground -cubemap CubemapFile1 [CubeMapFiles2-5] [-order TilesIndexes1-6] [-invertedz]\n"
14021 " vbackground -color Color\n"
14022 " vbackground -default -gradient Color1 Color2 [-gradientMode FillType]\n"
14023 " vbackground -default -color Color\n"
14024 " vbackground -help\n"
14027 " -imageFile (-imgFile, -image, -img): sets filename of image used as background\n"
14028 " -imageMode (-imgMode, -imageMd, -imgMd): sets image fill type\n"
14029 " -gradient (-grad, -gr): sets background gradient starting and ending colors\n"
14030 " -gradientMode (-gradMode, -gradMd, -grMode, -grMd): sets gradient fill method\n"
14031 " -cubemap (-cmap, -cm): sets environmet cubemap as background\n"
14032 " -invertedz (-invz, -iz): sets inversion of Z axis for background cubemap rendering\n"
14033 " -order (-o): defines order of tiles in one image cubemap\n"
14034 " (has no effect in case of multi image cubemaps)\n"
14035 " -color (-col): sets background color\n"
14036 " -default (-def): sets background default gradient or color\n"
14037 " -help (-h): outputs short help message\n"
14040 " Color: Red Green Blue - where Red, Green, Blue must be integers within the range [0, 255]\n"
14041 " or reals within the range [0.0, 1.0]\n"
14042 " ColorName - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
14043 " #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
14044 " FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
14046 " FillType: one of CENTERED, TILED, STRETCH, NONE\n"
14047 " ImageFile: a name of the file with the image used as a background\n"
14048 " CubemapFilei: a name of the file with one image packed cubemap or names of separate files with every cubemap side\n"
14049 " TileIndexi: a cubemap side index in range [0, 5] for i tile of one image packed cubemap\n",
14053 theCommands.Add ("vsetbg",
14054 "Loads image as background."
14055 "\n\t\t: vsetbg ImageFile [FillType]"
14056 "\n\t\t: vsetbg -imageFile ImageFile [-imageMode FillType]"
14057 "\n\t\t: Alias for 'vbackground -imageFile ImageFile [-imageMode FillType]'.",
14061 theCommands.Add ("vsetbgmode",
14062 "Changes background image fill type."
14063 "\n\t\t: vsetbgmode [-imageMode] FillType"
14064 "\n\t\t: Alias for 'vbackground -imageMode FillType'.",
14068 theCommands.Add ("vsetgradientbg",
14069 "Mounts gradient background."
14070 "\n\t\t: vsetgradientbg Color1 Color2 [FillMethod]"
14071 "\n\t\t: vsetgradientbg -gradient Color1 Color2 [-gradientMode FillMethod]"
14072 "\n\t\t: Alias for 'vbackground -gradient Color1 Color2 -gradientMode FillMethod'.",
14076 theCommands.Add ("vsetgrbgmode",
14077 "Changes gradient background fill method."
14078 "\n\t\t: vsetgrbgmode [-gradientMode] FillMethod"
14079 "\n\t\t: Alias for 'vbackground -gradientMode FillMethod'.",
14083 theCommands.Add ("vsetcolorbg",
14084 "Sets background color."
14085 "\n\t\t: vsetcolorbg [-color] Color."
14086 "\n\t\t: Alias for 'vbackground -color Color'.",
14090 theCommands.Add ("vsetdefaultbg",
14091 "Sets default viewer background fill color (flat/gradient)."
14092 "\n\t\t: vsetdefaultbg Color1 Color2 [FillMethod]"
14093 "\n\t\t: vsetdefaultbg -gradient Color1 Color2 [-gradientMode FillMethod]"
14094 "\n\t\t: Alias for 'vbackground -default -gradient Color1 Color2 [-gradientMode FillMethod]'."
14095 "\n\t\t: vsetdefaultbg [-color] Color"
14096 "\n\t\t: Alias for 'vbackground -default -color Color'.",
14100 theCommands.Add("vscale",
14101 "vscale : vscale X Y Z",
14102 __FILE__,VScale,group);
14103 theCommands.Add("vzbufftrihedron",
14104 "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]"
14105 "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]"
14106 "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]"
14107 "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]"
14108 "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]"
14109 "\n\t\t: Displays a trihedron",
14110 __FILE__,VZBuffTrihedron,group);
14111 theCommands.Add("vrotate",
14112 "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]"
14113 "\n : Option -mouseStart starts rotation according to the mouse position"
14114 "\n : Option -mouseMove continues rotation with angle computed"
14115 "\n : from last and new mouse position."
14116 "\n : vrotate AX AY AZ [X Y Z]",
14117 __FILE__,VRotate,group);
14118 theCommands.Add("vzoom",
14119 "vzoom : vzoom coef",
14120 __FILE__,VZoom,group);
14121 theCommands.Add("vpan",
14122 "vpan : vpan dx dy",
14123 __FILE__,VPan,group);
14124 theCommands.Add("vcolorscale",
14125 "vcolorscale name [-noupdate|-update] [-demo]"
14126 "\n\t\t: [-range RangeMin=0 RangeMax=1 NbIntervals=10]"
14127 "\n\t\t: [-font HeightFont=20]"
14128 "\n\t\t: [-logarithmic {on|off}=off] [-reversed {on|off}=off]"
14129 "\n\t\t: [-smoothTransition {on|off}=off]"
14130 "\n\t\t: [-hueRange MinAngle=230 MaxAngle=0]"
14131 "\n\t\t: [-colorRange MinColor=BLUE1 MaxColor=RED]"
14132 "\n\t\t: [-textpos {left|right|center|none}=right]"
14133 "\n\t\t: [-labelAtBorder {on|off}=on]"
14134 "\n\t\t: [-colors Color1 Color2 ...] [-color Index Color]"
14135 "\n\t\t: [-labels Label1 Label2 ...] [-label Index Label]"
14136 "\n\t\t: [-freeLabels NbOfLabels Label1 Label2 ...]"
14137 "\n\t\t: [-xy Left=0 Bottom=0]"
14138 "\n\t\t: [-uniform lightness hue_from hue_to]"
14139 "\n\t\t: -demo - displays a color scale with demonstratio values"
14140 "\n\t\t: -colors - set colors for all intervals"
14141 "\n\t\t: -color - set color for specific interval"
14142 "\n\t\t: -uniform - generate colors with the same lightness"
14143 "\n\t\t: -textpos - horizontal label position relative to color scale bar"
14144 "\n\t\t: -labelAtBorder - vertical label position relative to color interval;"
14145 "\n\t\t: at border means the value inbetween neighbor intervals,"
14146 "\n\t\t: at center means the center value within current interval"
14147 "\n\t\t: -labels - set labels for all intervals"
14148 "\n\t\t: -freeLabels - same as -labels but does not require"
14149 "\n\t\t: matching the number of intervals"
14150 "\n\t\t: -label - set label for specific interval"
14151 "\n\t\t: -title - set title"
14152 "\n\t\t: -reversed - setup smooth color transition between intervals"
14153 "\n\t\t: -smoothTransition - swap colorscale direction"
14154 "\n\t\t: -hueRange - set hue angles corresponding to minimum and maximum values",
14155 __FILE__, VColorScale, group);
14156 theCommands.Add("vgraduatedtrihedron",
14157 "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n"
14158 "\t[-namefont Name] [-valuesfont Name]\n"
14159 "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n"
14160 "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]"
14161 "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n"
14162 "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n"
14163 "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]"
14164 "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n"
14165 "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n"
14166 "\t[-xticks Number] [-yticks Number] [-zticks Number]\n"
14167 "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n"
14168 "\t[-drawgrid on/off] [-drawaxes on/off]\n"
14169 " - Displays or erases graduated trihedron"
14170 " - xname, yname, zname - names of axes, default: X, Y, Z\n"
14171 " - namefont - font of axes names. Default: Arial\n"
14172 " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n"
14173 " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n"
14174 " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n"
14175 " - valuesfont - font of axes values. Default: Arial\n"
14176 " - xcolor, ycolor, zcolor - color of axis and values\n"
14177 " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n"
14178 " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n",
14179 __FILE__,VGraduatedTrihedron,group);
14180 theCommands.Add("vtile" ,
14181 "vtile [-totalSize W H] [-lowerLeft X Y] [-upperLeft X Y] [-tileSize W H]"
14182 "\n\t\t: Setup view to draw a tile (a part of virtual bigger viewport)."
14183 "\n\t\t: -totalSize the size of virtual bigger viewport"
14184 "\n\t\t: -tileSize tile size (the view size will be used if omitted)"
14185 "\n\t\t: -lowerLeft tile offset as lower left corner"
14186 "\n\t\t: -upperLeft tile offset as upper left corner",
14187 __FILE__, VTile, group);
14188 theCommands.Add("vzlayer",
14189 "vzlayer [layerId]"
14190 "\n\t\t: [-add|-delete|-get|-settings] [-insertBefore AnotherLayer] [-insertAfter AnotherLayer]"
14191 "\n\t\t: [-origin X Y Z] [-cullDist Distance] [-cullSize Size]"
14192 "\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
14193 "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv|rayTracing}]"
14194 "\n\t\t: ZLayer list management:"
14195 "\n\t\t: -add add new z layer to viewer and print its id"
14196 "\n\t\t: -insertBefore add new z layer and insert it before existing one"
14197 "\n\t\t: -insertAfter add new z layer and insert it after existing one"
14198 "\n\t\t: -delete delete z layer"
14199 "\n\t\t: -get print sequence of z layers"
14200 "\n\t\t: -settings print status of z layer settings"
14201 "\n\t\t: -disable disables given setting"
14202 "\n\t\t: -enable enables given setting",
14203 __FILE__,VZLayer,group);
14204 theCommands.Add("vlayerline",
14205 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
14206 __FILE__,VLayerLine,group);
14207 theCommands.Add("vgrid",
14208 "vgrid [off] [-type {rect|circ}] [-mode {line|point}] [-origin X Y] [-rotAngle Angle] [-zoffset DZ]"
14209 "\n\t\t: [-step X Y] [-size DX DY]"
14210 "\n\t\t: [-step StepRadius NbDivisions] [-radius Radius]",
14211 __FILE__, VGrid, group);
14212 theCommands.Add ("vpriviledgedplane",
14213 "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]"
14214 "\n\t\t: Ox, Oy, Oz - plane origin"
14215 "\n\t\t: Nx, Ny, Nz - plane normal direction"
14216 "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction"
14217 "\n\t\t: Sets or prints viewer's priviledged plane geometry.",
14218 __FILE__, VPriviledgedPlane, group);
14219 theCommands.Add ("vconvert",
14220 "vconvert v [Mode={window|view}]"
14221 "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]"
14222 "\n\t\t: vconvert x y z [Mode={window|grid}]"
14223 "\n\t\t: window - convert to window coordinates, pixels"
14224 "\n\t\t: view - convert to view projection plane"
14225 "\n\t\t: grid - convert to model coordinates, given on grid"
14226 "\n\t\t: ray - convert projection ray to model coordiantes"
14227 "\n\t\t: - vconvert v window : convert view to window;"
14228 "\n\t\t: - vconvert v view : convert window to view;"
14229 "\n\t\t: - vconvert x y window : convert view to window;"
14230 "\n\t\t: - vconvert x y view : convert window to view;"
14231 "\n\t\t: - vconvert x y : convert window to model;"
14232 "\n\t\t: - vconvert x y grid : convert window to model using grid;"
14233 "\n\t\t: - vconvert x y ray : convert window projection line to model;"
14234 "\n\t\t: - vconvert x y z window : convert model to window;"
14235 "\n\t\t: - vconvert x y z grid : convert view to model using grid;"
14236 "\n\t\t: Converts the given coordinates to window/view/model space.",
14237 __FILE__, VConvert, group);
14238 theCommands.Add ("vfps",
14239 "vfps [framesNb=100] [-duration seconds] : estimate average frame rate for active view",
14240 __FILE__, VFps, group);
14241 theCommands.Add ("vgldebug",
14242 "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
14243 "\n\t\t: [-glslCode {off|short|full}] [-extraMsg {0|1}] [{0|1}]"
14244 "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
14245 "\n\t\t: Debug context can be requested only on Windows"
14246 "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
14247 "\n\t\t: -sync - request synchronized debug GL context"
14248 "\n\t\t: -glslWarn - log GLSL compiler/linker warnings,"
14249 "\n\t\t: which are suppressed by default,"
14250 "\n\t\t: -glslCode - log GLSL program source code,"
14251 "\n\t\t: which are suppressed by default,"
14252 "\n\t\t: -extraMsg - log extra diagnostic messages from GL context,"
14253 "\n\t\t: which are suppressed by default",
14254 __FILE__, VGlDebug, group);
14255 theCommands.Add ("vvbo",
14256 "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
14257 __FILE__, VVbo, group);
14258 theCommands.Add ("vstereo",
14259 "vstereo [0|1] [-mode Mode] [-reverse {0|1}]"
14260 "\n\t\t: [-mirrorComposer] [-hmdfov2d AngleDegrees] [-unitFactor MetersFactor]"
14261 "\n\t\t: [-anaglyph Filter]"
14262 "\n\t\t: Control stereo output mode."
14263 "\n\t\t: When -mirrorComposer is specified, VR rendered frame will be mirrored in window (debug)."
14264 "\n\t\t: Parameter -unitFactor specifies meters scale factor for mapping VR input."
14265 "\n\t\t: Available modes for -mode:"
14266 "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo,"
14267 "\n\t\t: requires driver support."
14268 "\n\t\t: Should be called BEFORE vinit!"
14269 "\n\t\t: anaglyph - Anaglyph glasses"
14270 "\n\t\t: rowInterlaced - row-interlaced display"
14271 "\n\t\t: columnInterlaced - column-interlaced display"
14272 "\n\t\t: chessBoard - chess-board output"
14273 "\n\t\t: sideBySide - horizontal pair"
14274 "\n\t\t: overUnder - vertical pair"
14275 "\n\t\t: openVR - OpenVR (HMD)"
14276 "\n\t\t: Available Anaglyph filters for -anaglyph:"
14277 "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple,"
14278 "\n\t\t: greenMagentaSimple",
14279 __FILE__, VStereo, group);
14280 theCommands.Add ("vcaps",
14281 "vcaps [-sRGB {0|1}] [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
14282 "\n\t\t: [-compatibleProfile {0|1}] [-compressedTextures {0|1}]"
14283 "\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
14284 "\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
14285 "\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
14286 "\n\t\t: [-noExtensions {0|1}] [-maxVersion Major Minor]"
14287 "\n\t\t: Modify particular graphic driver options:"
14288 "\n\t\t: sRGB - enable/disable sRGB rendering"
14289 "\n\t\t: FFP - use fixed-function pipeline instead of"
14290 "\n\t\t: built-in GLSL programs"
14291 "\n\t\t: (requires compatible profile)"
14292 "\n\t\t: polygonMode - use Polygon Mode instead of built-in GLSL programs"
14293 "\n\t\t: compressedTexture - allow uploading of GPU-supported compressed texture formats"
14294 "\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
14295 "\n\t\t: arrays to GPU memory)"
14296 "\n\t\t: sprite - use textured sprites instead of bitmaps"
14297 "\n\t\t: vsync - switch VSync on or off"
14298 "\n\t\t: winBuffer - allow using window buffer for rendering"
14299 "\n\t\t: Context creation options:"
14300 "\n\t\t: softMode - software OpenGL implementation"
14301 "\n\t\t: compatibleProfile - backward-compatible profile"
14302 "\n\t\t: quadbuffer - QuadBuffer"
14303 "\n\t\t: noExtensions - disallow usage of extensions"
14304 "\n\t\t: maxVersion - force upper OpenGL version to be used"
14305 "\n\t\t: Unlike vrenderparams, these parameters control alternative"
14306 "\n\t\t: rendering paths producing the same visual result when"
14307 "\n\t\t: possible."
14308 "\n\t\t: Command is intended for testing old hardware compatibility.",
14309 __FILE__, VCaps, group);
14310 theCommands.Add ("vmemgpu",
14311 "vmemgpu [f]: print system-dependent GPU memory information if available;"
14312 " with f option returns free memory in bytes",
14313 __FILE__, VMemGpu, group);
14314 theCommands.Add ("vreadpixel",
14315 "vreadpixel xPixel yPixel [{rgb|rgba|sRGB|sRGBa|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
14316 " : Read pixel value for active view",
14317 __FILE__, VReadPixel, group);
14318 theCommands.Add("diffimage",
14319 "diffimage imageFile1 imageFile2 [diffImageFile]"
14320 "\n\t\t: [-toleranceOfColor {0..1}=0] [-blackWhite {on|off}=off] [-borderFilter {on|off}=off]"
14321 "\n\t\t: [-display viewName prsName1 prsName2 prsNameDiff] [-exitOnClose] [-closeOnEscape]"
14322 "\n\t\t: Compare two images by content and generate difference image."
14323 "\n\t\t: When -exitOnClose is specified, closing the view will exit application."
14324 "\n\t\t: When -closeOnEscape is specified, view will be closed on pressing Escape.",
14325 __FILE__, VDiffImage, group);
14326 theCommands.Add ("vselect",
14327 "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
14328 "- emulates different types of selection:\n"
14329 "- 1) single click selection\n"
14330 "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
14331 "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
14332 "- 4) -allowoverlap manages overlap and inclusion detection in rectangular and polygonal selection.\n"
14333 " If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined \n"
14334 " rectangle or polygon will be detected, otherwise algorithm will chose only fully included sensitives.\n"
14335 " Default behavior is to detect only full inclusion. (partial inclusion - overlap - is not allowed by default)\n"
14336 "- 5) any of these selections with shift button pressed",
14337 __FILE__, VSelect, group);
14338 theCommands.Add ("vmoveto",
14339 "vmoveto [x y] [-reset]"
14340 "\n\t\t: Emulates cursor movement to pixel position (x,y)."
14341 "\n\t\t: -reset resets current highlighting",
14342 __FILE__, VMoveTo, group);
14343 theCommands.Add ("vviewparams",
14344 "vviewparams [-args] [-scale [s]]"
14345 "\n\t\t: [-eye [x y z]] [-at [x y z]] [-up [x y z]]"
14346 "\n\t\t: [-proj [x y z]] [-center x y] [-size sx]"
14347 "\n\t\t: Manage current view parameters or prints all"
14348 "\n\t\t: current values when called without argument."
14349 "\n\t\t: -scale [s] prints or sets viewport relative scale"
14350 "\n\t\t: -eye [x y z] prints or sets eye location"
14351 "\n\t\t: -at [x y z] prints or sets center of look"
14352 "\n\t\t: -up [x y z] prints or sets direction of up vector"
14353 "\n\t\t: -proj [x y z] prints or sets direction of look"
14354 "\n\t\t: -center x y sets location of center of the screen in pixels"
14355 "\n\t\t: -size [sx] prints viewport projection width and height sizes"
14356 "\n\t\t: or changes the size of its maximum dimension"
14357 "\n\t\t: -args prints vviewparams arguments for restoring current view",
14358 __FILE__, VViewParams, group);
14360 theCommands.Add("v2dmode",
14361 "v2dmode [-name viewName] [-mode {-on|-off}=-on]"
14362 "\n\t\t: name - name of existing view, if not defined, the active view is changed"
14363 "\n\t\t: mode - switches On/Off rotation mode"
14364 "\n\t\t: Set 2D mode of the active viewer manipulating. The following mouse and key actions are disabled:"
14365 "\n\t\t: - rotation of the view by 3rd mouse button with Ctrl active"
14366 "\n\t\t: - set view projection using key buttons: A/D/T/B/L/R for AXO, Reset, Top, Bottom, Left, Right"
14367 "\n\t\t: View camera position might be changed only by commands.",
14368 __FILE__, V2DMode, group);
14370 theCommands.Add("vanimation", "Alias for vanim",
14371 __FILE__, VAnimation, group);
14373 theCommands.Add("vanim",
14374 "List existing animations:"
14376 "\n\t\t: Animation playback:"
14377 "\n\t\t: vanim name -play|-resume [playFrom [playDuration]]"
14378 "\n\t\t: [-speed Coeff] [-freeLook] [-lockLoop]"
14379 "\n\t\t: -speed playback speed (1.0 is normal speed)"
14380 "\n\t\t: -freeLook skip camera animations"
14381 "\n\t\t: -lockLoop disable any interactions"
14383 "\n\t\t: Animation definition:"
14384 "\n\t\t: vanim Name/sub/name [-clear] [-delete]"
14385 "\n\t\t: [start TimeSec] [duration TimeSec]"
14387 "\n\t\t: Animation name defined in path-style (anim/name or anim.name)"
14388 "\n\t\t: specifies nested animations."
14389 "\n\t\t: There is no syntax to explicitly add new animation,"
14390 "\n\t\t: and all non-existing animations within the name will be"
14391 "\n\t\t: implicitly created on first use (including parents)."
14393 "\n\t\t: Each animation might define the SINGLE action (see below),"
14394 "\n\t\t: like camera transition, object transformation or custom callback."
14395 "\n\t\t: Child animations can be used for defining concurrent actions."
14397 "\n\t\t: Camera animation:"
14398 "\n\t\t: vanim name -view [-eye1 X Y Z] [-eye2 X Y Z]"
14399 "\n\t\t: [-at1 X Y Z] [-at2 X Y Z]"
14400 "\n\t\t: [-up1 X Y Z] [-up2 X Y Z]"
14401 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
14402 "\n\t\t: -eyeX camera Eye positions pair (start and end)"
14403 "\n\t\t: -atX camera Center positions pair"
14404 "\n\t\t: -upX camera Up directions pair"
14405 "\n\t\t: -scaleX camera Scale factors pair"
14406 "\n\t\t: Object animation:"
14407 "\n\t\t: vanim name -object [-loc1 X Y Z] [-loc2 X Y Z]"
14408 "\n\t\t: [-rot1 QX QY QZ QW] [-rot2 QX QY QZ QW]"
14409 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
14410 "\n\t\t: -locX object Location points pair (translation)"
14411 "\n\t\t: -rotX object Orientations pair (quaternions)"
14412 "\n\t\t: -scaleX object Scale factors pair (quaternions)"
14413 "\n\t\t: Custom callback:"
14414 "\n\t\t: vanim name -invoke \"Command Arg1 Arg2 %Pts %LocalPts %Normalized ArgN\""
14415 "\n\t\t: %Pts overall animation presentation timestamp"
14416 "\n\t\t: %LocalPts local animation timestamp"
14417 "\n\t\t: %Normalized local animation normalized value in range 0..1"
14419 "\n\t\t: Video recording:"
14420 "\n\t\t: vanim name -record FileName [Width Height] [-fps FrameRate=24]"
14421 "\n\t\t: [-format Format] [-vcodec Codec] [-pix_fmt PixelFormat]"
14422 "\n\t\t: [-crf Value] [-preset Preset]"
14423 "\n\t\t: -fps video framerate"
14424 "\n\t\t: -format file format, container (matroska, etc.)"
14425 "\n\t\t: -vcodec video codec identifier (ffv1, mjpeg, etc.)"
14426 "\n\t\t: -pix_fmt image pixel format (yuv420p, rgb24, etc.)"
14427 "\n\t\t: -crf constant rate factor (specific to codec)"
14428 "\n\t\t: -preset codec parameters preset (specific to codec)"
14429 __FILE__, VAnimation, group);
14431 theCommands.Add("vchangeselected",
14432 "vchangeselected shape"
14433 "- adds to shape to selection or remove one from it",
14434 __FILE__, VChangeSelected, group);
14435 theCommands.Add ("vnbselected",
14437 "\n\t\t: Returns number of selected objects", __FILE__, VNbSelected, group);
14438 theCommands.Add ("vcamera",
14439 "vcamera [PrsName] [-ortho] [-projtype]"
14441 "\n\t\t: [-fovy [Angle]] [-distance [Distance]]"
14442 "\n\t\t: [-stereo] [-leftEye] [-rightEye]"
14443 "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]"
14444 "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]"
14445 "\n\t\t: [-fov2d [Angle]] [-lockZup {0|1}]"
14446 "\n\t\t: [-xrPose base|head=base]"
14447 "\n\t\t: Manages camera parameters."
14448 "\n\t\t: Displays frustum when presntation name PrsName is specified."
14449 "\n\t\t: Prints current value when option called without argument."
14450 "\n\t\t: Orthographic camera:"
14451 "\n\t\t: -ortho activate orthographic projection"
14452 "\n\t\t: Perspective camera:"
14453 "\n\t\t: -persp activate perspective projection (mono)"
14454 "\n\t\t: -fovy field of view in y axis, in degrees"
14455 "\n\t\t: -fov2d field of view limit for 2d on-screen elements"
14456 "\n\t\t: -distance distance of eye from camera center"
14457 "\n\t\t: -lockZup lock Z up (tunrtable mode)"
14458 "\n\t\t: Stereoscopic camera:"
14459 "\n\t\t: -stereo perspective projection (stereo)"
14460 "\n\t\t: -leftEye perspective projection (left eye)"
14461 "\n\t\t: -rightEye perspective projection (right eye)"
14462 "\n\t\t: -iod intraocular distance value"
14463 "\n\t\t: -iodType distance type, absolute or relative"
14464 "\n\t\t: -zfocus stereographic focus value"
14465 "\n\t\t: -zfocusType focus type, absolute or relative",
14466 __FILE__, VCamera, group);
14467 theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n"
14468 "- vautozfit [on={1|0}] [scale]\n"
14469 " Prints or changes parameters of automatic z-fit mode:\n"
14470 " \"on\" - turns automatic z-fit on or off\n"
14471 " \"scale\" - specifies factor to scale computed z range.\n",
14472 __FILE__, VAutoZFit, group);
14473 theCommands.Add ("vzrange", "command to manually access znear and zfar values\n"
14474 " vzrange - without parameters shows current values\n"
14475 " vzrange [znear] [zfar] - applies provided values to view",
14476 __FILE__,VZRange, group);
14477 theCommands.Add ("vpurgedisplay",
14479 "- removes structures which don't belong to objects displayed in neutral point",
14480 __FILE__, VPurgeDisplay, group);
14481 theCommands.Add("vsetviewsize",
14482 "vsetviewsize size",
14483 __FILE__,VSetViewSize,group);
14484 theCommands.Add("vmoveview",
14485 "vmoveview Dx Dy Dz [Start = 1|0]",
14486 __FILE__,VMoveView,group);
14487 theCommands.Add("vtranslateview",
14488 "vtranslateview Dx Dy Dz [Start = 1|0)]",
14489 __FILE__,VTranslateView,group);
14490 theCommands.Add("vturnview",
14491 "vturnview Ax Ay Az [Start = 1|0]",
14492 __FILE__,VTurnView,group);
14493 theCommands.Add("vtextureenv",
14494 "Enables or disables environment mapping in the 3D view, loading the texture from the given standard "
14495 "or user-defined file and optionally applying texture mapping parameters\n"
14497 " vtextureenv off - disables environment mapping\n"
14498 " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n"
14499 " std_texture = (0..7)\n"
14500 " rep = {clamp|repeat}\n"
14501 " mod = {decal|modulate}\n"
14502 " flt = {nearest|bilinear|trilinear}\n"
14503 " ss, st - scale factors for s and t texture coordinates\n"
14504 " ts, tt - translation for s and t texture coordinates\n"
14505 " rot - texture rotation angle in degrees",
14506 __FILE__, VTextureEnv, group);
14507 theCommands.Add("vhlr",
14508 "vhlr {on|off} [-showHidden={1|0}] [-algoType={algo|polyAlgo}] [-noupdate]"
14509 "\n\t\t: Hidden Line Removal algorithm."
14510 "\n\t\t: -showHidden if set ON, hidden lines are drawn as dotted ones"
14511 "\n\t\t: -algoType type of HLR algorithm.\n",
14512 __FILE__,VHLR,group);
14513 theCommands.Add("vhlrtype",
14514 "vhlrtype {algo|polyAlgo} [shape_1 ... shape_n] [-noupdate]"
14515 "\n\t\t: Changes the type of HLR algorithm using for shapes:"
14516 "\n\t\t: 'algo' - exact HLR algorithm is applied"
14517 "\n\t\t: 'polyAlgo' - polygonal HLR algorithm is applied"
14518 "\n\t\t: If shapes are not given - option is applied to all shapes in the view",
14519 __FILE__,VHLRType,group);
14520 theCommands.Add("vclipplane",
14521 "vclipplane planeName [{0|1}]"
14522 "\n\t\t: [-equation1 A B C D]"
14523 "\n\t\t: [-equation2 A B C D]"
14524 "\n\t\t: [-boxInterior MinX MinY MinZ MaxX MaxY MaxZ]"
14525 "\n\t\t: [-set|-unset|-setOverrideGlobal [objects|views]]"
14526 "\n\t\t: [-maxPlanes]"
14527 "\n\t\t: [-capping {0|1}]"
14528 "\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]"
14529 "\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
14530 "\n\t\t: [-texRotate Angle]"
14531 "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
14532 "\n\t\t: [-useObjShader {0|1}]"
14533 "\n\t\t: Clipping planes management:"
14534 "\n\t\t: -maxPlanes print plane limit for view"
14535 "\n\t\t: -delete delete plane with given name"
14536 "\n\t\t: {off|on|0|1} turn clipping on/off"
14537 "\n\t\t: -set|-unset set/unset plane for Object or View list;"
14538 "\n\t\t: applied to active View when list is omitted"
14539 "\n\t\t: -equation A B C D change plane equation"
14540 "\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
14541 "\n\t\t: Capping options:"
14542 "\n\t\t: -capping {off|on|0|1} turn capping on/off"
14543 "\n\t\t: -color R G B set capping color"
14544 "\n\t\t: -transparency Value set capping transparency 0..1"
14545 "\n\t\t: -texName Texture set capping texture"
14546 "\n\t\t: -texScale SX SY set capping tex scale"
14547 "\n\t\t: -texOrigin TX TY set capping tex origin"
14548 "\n\t\t: -texRotate Angle set capping tex rotation"
14549 "\n\t\t: -hatch {on|off|ID} set capping hatching mask"
14550 "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
14551 "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
14552 "\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
14553 __FILE__, VClipPlane, group);
14554 theCommands.Add("vdefaults",
14555 "vdefaults [-absDefl value]"
14556 "\n\t\t: [-devCoeff value]"
14557 "\n\t\t: [-angDefl value]"
14558 "\n\t\t: [-autoTriang {off/on | 0/1}]"
14559 , __FILE__, VDefaults, group);
14560 theCommands.Add("vlight",
14561 "tool to manage light sources, without arguments shows list of lights."
14562 "\n Main commands: "
14563 "\n '-clear' to clear lights"
14564 "\n '-{def}aults' to load deafault lights"
14565 "\n '-add' <type> to add any light source"
14566 "\n where <type> is one of {amb}ient|directional|{spot}light|positional"
14567 "\n 'change' <lightId> to edit light source with specified lightId"
14568 "\n\n In addition to 'add' and 'change' commands you can use light parameters:"
14570 "\n -{pos}ition X Y Z"
14571 "\n -{dir}ection X Y Z (for directional light or for spotlight)"
14572 "\n -color colorName"
14573 "\n -{head}light 0|1"
14574 "\n -{sm}oothness value"
14575 "\n -{int}ensity value"
14576 "\n -{constAtten}uation value"
14577 "\n -{linearAtten}uation value"
14578 "\n -angle angleDeg"
14579 "\n -{spotexp}onent value"
14581 "\n -local|-global"
14582 "\n\n example: vlight -add positional -head 1 -pos 0 1 1 -color red"
14583 "\n example: vlight -change 0 -direction 0 -1 0 -linearAttenuation 0.2",
14584 __FILE__, VLight, group);
14585 theCommands.Add("vpbrenv",
14586 "vpbrenv -clear|-generate"
14587 "\n\t\t: Clears or generates PBR environment map of active view."
14588 "\n\t\t: -clear clears PBR environment (fills by white color)"
14589 "\n\t\t: -generate generates PBR environment from current background cubemap",
14590 __FILE__, VPBREnvironment, group);
14591 theCommands.Add("vraytrace",
14593 "\n\t\t: Turns on/off ray-tracing renderer."
14594 "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'."
14595 "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.",
14596 __FILE__, VRenderParams, group);
14597 theCommands.Add("vrenderparams",
14598 "\n Manages rendering parameters: "
14599 "\n '-raster' Disables GPU ray-tracing"
14600 "\n '-msaa 0..4' Specifies number of samples for MSAA"
14601 "\n '-lineFeather > 0' Sets line feather factor"
14602 "\n '-oit off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
14603 "\n '-depthPrePass on|off' Enables/disables depth pre-pass"
14604 "\n '-alphatocoverage on|off' Enables/disables alpha to coverage (needs MSAA)"
14605 "\n '-rendScale value Rendering resolution scale factor"
14606 "\n '-rayTrace' Enables GPU ray-tracing"
14607 "\n '-rayDepth 0..10' Defines maximum ray-tracing depth"
14608 "\n '-shadows on|off' Enables/disables shadows rendering"
14609 "\n '-reflections on|off' Enables/disables specular reflections"
14610 "\n '-fsaa on|off' Enables/disables adaptive anti-aliasing"
14611 "\n '-gleam on|off' Enables/disables transparency shadow effects"
14612 "\n '-gi on|off' Enables/disables global illumination effects"
14613 "\n '-brng on|off' Enables/disables blocked RNG (fast coherent PT)"
14614 "\n '-env on|off' Enables/disables environment map background"
14615 "\n '-ignoreNormalMap on|off' Enables/disables normal map ignoring during path tracing"
14616 "\n '-twoside on|off' Enables/disables two-sided BSDF models (PT mode)"
14617 "\n '-iss on|off' Enables/disables adaptive screen sampling (PT mode)"
14618 "\n '-issd on|off' Shows screen sampling distribution in ISS mode"
14619 "\n '-maxrad > 0.0' Value used for clamping radiance estimation (PT mode)"
14620 "\n '-tileSize 1..4096' Specifies size of screen tiles in ISS mode (32 by default)"
14621 "\n '-nbtiles 64..1024' Specifies number of screen tiles per Redraw in ISS mode (256 by default)"
14622 "\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
14623 "\n '-shadingModel model' Controls shading model from enumeration"
14624 "\n unlit, flat, gouraud, phong"
14625 "\n '-pbrEnvPow2size > 0' Controls size of IBL maps (real size can be calculates as 2^pbrenvpow2size)"
14626 "\n '-pbrEnvSMLN > 1' Controls number of mipmap levels used in specular IBL map"
14627 "\n '-pbrEnvBDSN > 0' Controls number of samples in Monte-Carlo integration during diffuse IBL map's sherical harmonics calculation"
14628 "\n '-pbrEnvBSSN > 0' Controls maximum number of samples per mipmap level in Monte-Carlo integration during specular IBL maps generation"
14629 "\n '-pbrEnvBP [0, 1]' Controls strength of samples number reducing during specular IBL maps generation (1 disables reducing)"
14630 "\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"
14631 "\n '-aperture >= 0.0' Aperture size of perspective camera for depth-of-field effect (0 disables DOF)"
14632 "\n '-focal >= 0.0' Focal distance of perspective camera for depth-of-field effect"
14633 "\n '-exposure value' Exposure value for tone mapping (0.0 value disables the effect)"
14634 "\n '-whitepoint value' White point value for filmic tone mapping"
14635 "\n '-tonemapping mode' Tone mapping mode (disabled, filmic)"
14636 "\n '-perfCounters none|fps|cpu|layers|structures|groups|arrays|triangles|points"
14637 "\n ' |gpuMem|frameTime|basic|extended|full|nofps|skipImmediate'"
14638 "\n Show/hide performance counters (flags can be combined)"
14639 "\n '-perfUpdateInterval nbSeconds' Performance counters update interval"
14640 "\n '-perfChart nbFrames' Show frame timers chart limited by specified number of frames"
14641 "\n '-perfChartMax seconds' Maximum time in seconds with the chart"
14642 "\n '-frustumCulling on|off|noupdate' Enable/disable objects frustum clipping or"
14643 "\n set state to check structures culled previously."
14644 "\n Unlike vcaps, these parameters dramatically change visual properties."
14645 "\n Command is intended to control presentation quality depending on"
14646 "\n hardware capabilities and performance.",
14647 __FILE__, VRenderParams, group);
14648 theCommands.Add("vstatprofiler",
14649 "\n vstatprofiler [fps|cpu|allLayers|layers|allstructures|structures|groups"
14650 "\n |allArrays|fillArrays|lineArrays|pointArrays|textArrays"
14651 "\n |triangles|points|geomMem|textureMem|frameMem"
14652 "\n |elapsedFrame|cpuFrameAverage|cpuPickingAverage|cpuCullingAverage|cpuDynAverage"
14653 "\n |cpuFrameMax|cpuPickingMax|cpuCullingMax|cpuDynMax]"
14655 "\n\t\t: Prints rendering statistics."
14656 "\n\t\t: If there are some parameters - print corresponding statistic counters values,"
14657 "\n\t\t: else - print all performance counters set previously."
14658 "\n\t\t: '-noredraw' Flag to avoid additional redraw call and use already collected values.\n",
14659 __FILE__, VStatProfiler, group);
14660 theCommands.Add ("vplace",
14662 "\n\t\t: Places the point (in pixels) at the center of the window",
14663 __FILE__, VPlace, group);
14664 theCommands.Add("vxrotate",
14666 __FILE__,VXRotate,group);
14668 theCommands.Add("vmanipulator",
14669 "\n vmanipulator Name [-attach AISObject | -detach | ...]"
14670 "\n tool to create and manage AIS manipulators."
14672 "\n '-attach AISObject' attach manipulator to AISObject"
14673 "\n '-adjustPosition {0|1}' adjust position when attaching"
14674 "\n '-adjustSize {0|1}' adjust size when attaching"
14675 "\n '-enableModes {0|1}' enable modes when attaching"
14676 "\n '-view {active | [name of view]}' display manipulator only in defined view,"
14677 "\n by default it is displayed in all views of the current viewer"
14678 "\n '-detach' detach manipulator"
14679 "\n '-startTransform mouse_x mouse_y' - invoke start of transformation"
14680 "\n '-transform mouse_x mouse_y' - invoke transformation"
14681 "\n '-stopTransform [abort]' - invoke stop of transformation"
14682 "\n '-move x y z' - move attached object"
14683 "\n '-rotate x y z dx dy dz angle' - rotate attached object"
14684 "\n '-scale factor' - scale attached object"
14685 "\n '-autoActivate {0|1}' - set activation on detection"
14686 "\n '-followTranslation {0|1}' - set following translation transform"
14687 "\n '-followRotation {0|1}' - set following rotation transform"
14688 "\n '-followDragging {0|1}' - set following dragging transform"
14689 "\n '-gap value' - set gap between sub-parts"
14690 "\n '-part axis mode {0|1}' - set visual part"
14691 "\n '-parts axis mode {0|1}' - set visual part"
14692 "\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator"
14693 "\n '-size value' - set size of manipulator"
14694 "\n '-zoomable {0|1}' - set zoom persistence",
14695 __FILE__, VManipulator, group);
14697 theCommands.Add("vselprops",
14698 "\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]"
14699 "\n Customizes selection and dynamic highlight parameters for the whole interactive context:"
14700 "\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode"
14701 "\n -autoHighlight {0|1} : disables|enables automatic highlighting in 3D Viewer"
14702 "\n -highlightSelected {0|1}: disables|enables highlighting of detected object in selected state"
14703 "\n -pickStrategy {first|topmost} : defines picking strategy"
14704 "\n 'first' to pick first acceptable (default)"
14705 "\n 'topmost' to pick only topmost (and nothing, if topmost is rejected by filters)"
14706 "\n -pixTol value : sets up pixel tolerance"
14707 "\n -dispMode dispMode : sets display mode for highlighting"
14708 "\n -layer ZLayer : sets ZLayer for highlighting"
14709 "\n -color {name|r g b} : sets highlight color"
14710 "\n -transp value : sets transparency coefficient for highlight"
14711 "\n -material material : sets highlight material"
14712 "\n -print : prints current state of all mentioned parameters",
14713 __FILE__, VSelectionProperties, group);
14714 theCommands.Add ("vhighlightselected",
14715 "vhighlightselected [0|1]: alias for vselprops -highlightSelected.\n",
14716 __FILE__, VSelectionProperties, group);
14718 theCommands.Add ("vseldump",
14719 "vseldump file -type {depth|unnormDepth|object|owner|selMode|entity}=depth -pickedIndex Index=1"
14720 "\n\t\t: [-xrPose base|head=base]"
14721 "\n\t\t: Generate an image based on detection results:"
14722 "\n\t\t: depth normalized depth values"
14723 "\n\t\t: unnormDepth unnormalized depth values"
14724 "\n\t\t: object color of detected object"
14725 "\n\t\t: owner color of detected owner"
14726 "\n\t\t: selMode color of selection mode"
14727 "\n\t\t: entity color of etected entity",
14728 __FILE__, VDumpSelectionImage, group);
14730 theCommands.Add ("vviewcube",
14732 "\n\t\t: Displays interactive view manipualtion object."
14733 "\n\t\t: Options: "
14734 "\n\t\t: -reset reset geomertical and visual attributes'"
14735 "\n\t\t: -size Size adapted size of View Cube"
14736 "\n\t\t: -boxSize Size box size"
14737 "\n\t\t: -axes {0|1 } show/hide axes (trihedron)"
14738 "\n\t\t: -edges {0|1} show/hide edges of View Cube"
14739 "\n\t\t: -vertices {0|1} show/hide vertices of View Cube"
14740 "\n\t\t: -Yup {0|1} -Zup {0|1} set Y-up or Z-up view orientation"
14741 "\n\t\t: -color Color color of View Cube"
14742 "\n\t\t: -boxColor Color box color"
14743 "\n\t\t: -boxSideColor Color box sides color"
14744 "\n\t\t: -boxEdgeColor Color box edges color"
14745 "\n\t\t: -boxCornerColor Color box corner color"
14746 "\n\t\t: -textColor Color color of side text of view cube"
14747 "\n\t\t: -innerColor Color inner box color"
14748 "\n\t\t: -transparency Value transparency of object within [0, 1] range"
14749 "\n\t\t: -boxTransparency Value transparency of box within [0, 1] range"
14750 "\n\t\t: -font Name font name"
14751 "\n\t\t: -fontHeight Value font height"
14752 "\n\t\t: -boxFacetExtension Value box facet extension"
14753 "\n\t\t: -boxEdgeGap Value gap between box edges and box sides"
14754 "\n\t\t: -boxEdgeMinSize Value minimal box edge size"
14755 "\n\t\t: -boxCornerMinSize Value minimal box corner size"
14756 "\n\t\t: -axesPadding Value padding between box and arrows"
14757 "\n\t\t: -roundRadius Value relative radius of corners of sides within [0.0, 0.5] range"
14758 "\n\t\t: -axesRadius Value radius of axes of the trihedron"
14759 "\n\t\t: -axesConeRadius Value radius of the cone (arrow) of the trihedron"
14760 "\n\t\t: -axesSphereRadius Value radius of the sphere (central point) of trihedron"
14761 "\n\t\t: -fixedanimation {0|1} uninterruptible animation loop"
14762 "\n\t\t: -duration Seconds animation duration in seconds",
14763 __FILE__, VViewCube, group);
14765 theCommands.Add("vcolorconvert" ,
14766 "vcolorconvert {from|to} type C1 C2 C2"
14767 "\n\t\t: vcolorconvert from type C1 C2 C2: Converts color from specified color space to linear RGB"
14768 "\n\t\t: vcolorconvert to type R G B: Converts linear RGB color to specified color space"
14769 "\n\t\t: type can be sRGB, HLS, Lab, or Lch",
14770 __FILE__,VColorConvert,group);
14771 theCommands.Add("vcolordiff" ,
14772 "vcolordiff R1 G1 B1 R2 G2 B2: returns CIEDE2000 color difference between two RGB colors",
14773 __FILE__,VColorDiff,group);