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 << "A : AxonometricView\n";
3025 di << "D : ResetView\n";
3027 di << "=========================\n";
3028 di << "S : Shading\n";
3029 di << "W : Wireframe\n";
3030 di << "H : HiddenLineRemoval\n";
3031 di << "U : Unset display mode\n";
3032 di << "Delete : Remove selection from viewer\n";
3034 di << "=========================\n";
3035 di << "Selection mode \n";
3036 di << "0 : Shape\n";
3037 di << "1 : Vertex\n";
3041 di << "5 : Shell\n";
3042 di << "6 : Solid\n";
3043 di << "7 : Compound\n";
3045 di << "=========================\n";
3046 di << "< : Hilight next detected\n";
3047 di << "> : Hilight previous detected\n";
3054 static LRESULT WINAPI AdvViewerWindowProc (HWND theWinHandle,
3059 if (ViewerTest_myViews.IsEmpty())
3061 return ViewerWindowProc (theWinHandle, theMsg, wParam, lParam);
3068 // Delete view from map of views
3069 ViewerTest::RemoveView (FindViewIdByWindowHandle (theWinHandle));
3074 if (LOWORD(wParam) == WA_CLICKACTIVE
3075 || LOWORD(wParam) == WA_ACTIVE
3076 || ViewerTest::CurrentView().IsNull())
3078 // Activate inactive window
3079 if (VT_GetWindow().IsNull()
3080 || (HWND )VT_GetWindow()->HWindow() != theWinHandle)
3082 ActivateView (FindViewIdByWindowHandle (theWinHandle));
3089 return ViewerWindowProc (theWinHandle, theMsg, wParam, lParam);
3095 static LRESULT WINAPI ViewerWindowProc (HWND theWinHandle,
3100 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
3103 return DefWindowProcW (theWinHandle, theMsg, wParam, lParam);
3111 BeginPaint(theWinHandle, &aPaint);
3112 EndPaint (theWinHandle, &aPaint);
3113 ViewerTest::CurrentEventManager()->ProcessExpose();
3118 ViewerTest::CurrentEventManager()->ProcessConfigure();
3125 switch (aView->RenderingParams().StereoMode)
3127 case Graphic3d_StereoMode_RowInterlaced:
3128 case Graphic3d_StereoMode_ColumnInterlaced:
3129 case Graphic3d_StereoMode_ChessBoard:
3131 // track window moves to reverse stereo pair
3132 aView->MustBeResized();
3144 const Aspect_VKey aVKey = WNT_Window::VirtualKeyFromNative ((Standard_Integer )wParam);
3145 if (aVKey != Aspect_VKey_UNKNOWN)
3147 const double aTimeStamp = ViewerTest::CurrentEventManager()->EventTime();
3148 if (theMsg == WM_KEYDOWN)
3150 ViewerTest::CurrentEventManager()->KeyDown (aVKey, aTimeStamp);
3154 ViewerTest::CurrentEventManager()->KeyUp (aVKey, aTimeStamp);
3156 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3163 case WM_LBUTTONDOWN:
3164 case WM_MBUTTONDOWN:
3165 case WM_RBUTTONDOWN:
3167 const Graphic3d_Vec2i aPos (LOWORD(lParam), HIWORD(lParam));
3168 const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (wParam);
3169 Aspect_VKeyMouse aButton = Aspect_VKeyMouse_NONE;
3173 case WM_LBUTTONDOWN:
3174 aButton = Aspect_VKeyMouse_LeftButton;
3177 case WM_MBUTTONDOWN:
3178 aButton = Aspect_VKeyMouse_MiddleButton;
3181 case WM_RBUTTONDOWN:
3182 aButton = Aspect_VKeyMouse_RightButton;
3185 if (theMsg == WM_LBUTTONDOWN
3186 || theMsg == WM_MBUTTONDOWN
3187 || theMsg == WM_RBUTTONDOWN)
3189 if (aButton == Aspect_VKeyMouse_LeftButton)
3191 TheIsAnimating = Standard_False;
3194 SetFocus (theWinHandle);
3195 SetCapture(theWinHandle);
3196 ViewerTest::CurrentEventManager()->PressMouseButton (aPos, aButton, aFlags, false);
3201 ViewerTest::CurrentEventManager()->ReleaseMouseButton (aPos, aButton, aFlags, false);
3203 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3208 const int aDelta = GET_WHEEL_DELTA_WPARAM (wParam);
3209 const Standard_Real aDeltaF = Standard_Real(aDelta) / Standard_Real(WHEEL_DELTA);
3210 const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent (wParam);
3211 Graphic3d_Vec2i aPos (int(short(LOWORD(lParam))), int(short(HIWORD(lParam))));
3212 POINT aCursorPnt = { aPos.x(), aPos.y() };
3213 if (ScreenToClient (theWinHandle, &aCursorPnt))
3215 aPos.SetValues (aCursorPnt.x, aCursorPnt.y);
3218 ViewerTest::CurrentEventManager()->UpdateMouseScroll (Aspect_ScrollDelta (aPos, aDeltaF, aFlags));
3219 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3224 Graphic3d_Vec2i aPos (LOWORD(lParam), HIWORD(lParam));
3225 Aspect_VKeyMouse aButtons = WNT_Window::MouseButtonsFromEvent (wParam);
3226 Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent(wParam);
3228 // don't make a slide-show from input events - fetch the actual mouse cursor position
3230 aCursor.cbSize = sizeof(aCursor);
3231 if (::GetCursorInfo (&aCursor) != FALSE)
3233 POINT aCursorPnt = { aCursor.ptScreenPos.x, aCursor.ptScreenPos.y };
3234 if (ScreenToClient (theWinHandle, &aCursorPnt))
3236 // as we override mouse position, we need overriding also mouse state
3237 aPos.SetValues (aCursorPnt.x, aCursorPnt.y);
3238 aButtons = WNT_Window::MouseButtonsAsync();
3239 aFlags = WNT_Window::MouseKeyFlagsAsync();
3243 if (VT_GetWindow().IsNull()
3244 || (HWND )VT_GetWindow()->HWindow() != theWinHandle)
3246 // mouse move events come also for inactive windows
3250 ViewerTest::CurrentEventManager()->UpdateMousePosition (aPos, aButtons, aFlags, false);
3251 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
3256 return DefWindowProcW (theWinHandle, theMsg, wParam, lParam);
3262 //==============================================================================
3263 //function : ViewerMainLoop
3264 //purpose : Get a Event on the view and dispatch it
3265 //==============================================================================
3267 int ViewerMainLoop (Standard_Integer theNbArgs, const char** theArgVec)
3269 Handle(ViewerTest_EventManager) aViewCtrl = ViewerTest::CurrentEventManager();
3270 if (aViewCtrl.IsNull()
3276 aViewCtrl->StartPickPoint (theArgVec[1], theArgVec[2], theArgVec[3]);
3278 std::cout << "Start picking\n";
3282 while (aViewCtrl->ToPickPoint())
3284 // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
3285 if (GetMessageW (&aMsg, NULL, 0, 0))
3287 TranslateMessage (&aMsg);
3288 DispatchMessageW (&aMsg);
3292 std::cout << "Picking done\n";
3296 #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX)
3298 int min( int a, int b )
3306 int max( int a, int b )
3314 int ViewerMainLoop (Standard_Integer theNbArgs, const char** theArgVec)
3316 static XEvent aReport;
3317 const Standard_Boolean toPick = theNbArgs > 0;
3320 if (ViewerTest::CurrentEventManager().IsNull())
3324 ViewerTest::CurrentEventManager()->StartPickPoint (theArgVec[1], theArgVec[2], theArgVec[3]);
3327 Display* aDisplay = GetDisplayConnection()->GetDisplay();
3328 XNextEvent (aDisplay, &aReport);
3330 // Handle event for the chosen display connection
3331 switch (aReport.type)
3335 if ((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW))
3338 ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window));
3339 return toPick ? 0 : 1;
3345 // Activate inactive view
3346 Window aWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3347 if (aWindow != aReport.xfocus.window)
3349 ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window));
3355 Window anXWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3356 if (anXWindow == aReport.xexpose.window)
3358 ViewerTest::CurrentEventManager()->ProcessExpose();
3361 // remove all the ExposureMask and process them at once
3362 for (int aNbMaxEvents = XPending (aDisplay); aNbMaxEvents > 0; --aNbMaxEvents)
3364 if (!XCheckWindowEvent (aDisplay, anXWindow, ExposureMask, &aReport))
3372 case ConfigureNotify:
3374 // remove all the StructureNotifyMask and process them at once
3375 Window anXWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3376 for (int aNbMaxEvents = XPending (aDisplay); aNbMaxEvents > 0; --aNbMaxEvents)
3378 if (!XCheckWindowEvent (aDisplay, anXWindow, StructureNotifyMask, &aReport))
3384 if (anXWindow == aReport.xconfigure.window)
3386 ViewerTest::CurrentEventManager()->ProcessConfigure();
3393 XKeyEvent* aKeyEvent = (XKeyEvent* )&aReport;
3394 const KeySym aKeySym = XLookupKeysym (aKeyEvent, 0);
3395 const Aspect_VKey aVKey = Xw_Window::VirtualKeyFromNative (aKeySym);
3396 if (aVKey != Aspect_VKey_UNKNOWN)
3398 const double aTimeStamp = ViewerTest::CurrentEventManager()->EventTime();
3399 if (aReport.type == KeyPress)
3401 ViewerTest::CurrentEventManager()->KeyDown (aVKey, aTimeStamp);
3405 ViewerTest::CurrentEventManager()->KeyUp (aVKey, aTimeStamp);
3407 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3414 const Graphic3d_Vec2i aPos (aReport.xbutton.x, aReport.xbutton.y);
3415 Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
3416 Aspect_VKeyMouse aButton = Aspect_VKeyMouse_NONE;
3417 if (aReport.xbutton.button == Button1)
3419 aButton = Aspect_VKeyMouse_LeftButton;
3421 if (aReport.xbutton.button == Button2)
3423 aButton = Aspect_VKeyMouse_MiddleButton;
3425 if (aReport.xbutton.button == Button3)
3427 aButton = Aspect_VKeyMouse_RightButton;
3430 if (aReport.xbutton.state & ControlMask)
3432 aFlags |= Aspect_VKeyFlags_CTRL;
3434 if (aReport.xbutton.state & ShiftMask)
3436 aFlags |= Aspect_VKeyFlags_SHIFT;
3438 if (ViewerTest::CurrentEventManager()->Keys().IsKeyDown (Aspect_VKey_Alt))
3440 aFlags |= Aspect_VKeyFlags_ALT;
3443 if (aReport.xbutton.button == Button4
3444 || aReport.xbutton.button == Button5)
3446 if (aReport.type != ButtonPress)
3451 const double aDeltaF = (aReport.xbutton.button == Button4 ? 1.0 : -1.0);
3452 ViewerTest::CurrentEventManager()->UpdateMouseScroll (Aspect_ScrollDelta (aPos, aDeltaF, aFlags));
3454 else if (aReport.type == ButtonPress)
3456 if (aButton == Aspect_VKeyMouse_LeftButton)
3458 TheIsAnimating = Standard_False;
3460 ViewerTest::CurrentEventManager()->PressMouseButton (aPos, aButton, aFlags, false);
3464 ViewerTest::CurrentEventManager()->ReleaseMouseButton (aPos, aButton, aFlags, false);
3466 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3471 Window anXWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0;
3472 if (anXWindow != aReport.xmotion.window)
3477 // remove all the ButtonMotionMask and process them at once
3478 for (int aNbMaxEvents = XPending (aDisplay); aNbMaxEvents > 0; --aNbMaxEvents)
3480 if (!XCheckWindowEvent (aDisplay, anXWindow, ButtonMotionMask | PointerMotionMask, &aReport))
3486 Graphic3d_Vec2i aPos (aReport.xmotion.x, aReport.xmotion.y);
3487 Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
3488 Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
3489 if ((aReport.xmotion.state & Button1Mask) != 0)
3491 aButtons |= Aspect_VKeyMouse_LeftButton;
3493 else if ((aReport.xmotion.state & Button2Mask) != 0)
3495 aButtons |= Aspect_VKeyMouse_MiddleButton;
3497 else if ((aReport.xmotion.state & Button3Mask) != 0)
3499 aButtons |= Aspect_VKeyMouse_RightButton;
3502 if (aReport.xmotion.state & ControlMask)
3504 aFlags |= Aspect_VKeyFlags_CTRL;
3506 if (aReport.xmotion.state & ShiftMask)
3508 aFlags |= Aspect_VKeyFlags_SHIFT;
3510 if (ViewerTest::CurrentEventManager()->Keys().IsKeyDown (Aspect_VKey_Alt))
3512 aFlags |= Aspect_VKeyFlags_ALT;
3515 ViewerTest::CurrentEventManager()->UpdateMousePosition (aPos, aButtons, aFlags, false);
3516 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
3520 return (!toPick || ViewerTest::CurrentEventManager()->ToPickPoint()) ? 1 : 0;
3523 //==============================================================================
3524 //function : VProcessEvents
3525 //purpose : manage the event in the Viewer window (see Tcl_CreateFileHandler())
3526 //==============================================================================
3527 static void VProcessEvents (ClientData theDispX, int)
3529 Display* aDispX = (Display* )theDispX;
3530 Handle(Aspect_DisplayConnection) aDispConn;
3531 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
3532 aDriverIter (ViewerTest_myDrivers); aDriverIter.More(); aDriverIter.Next())
3534 const Handle(Aspect_DisplayConnection)& aDispConnTmp = aDriverIter.Key2()->GetDisplayConnection();
3535 if (aDispConnTmp->GetDisplay() == aDispX)
3537 aDispConn = aDispConnTmp;
3541 if (aDispConn.IsNull())
3543 Message::SendFail ("Error: ViewerTest is unable processing messages for unknown X Display");
3547 // process new events in queue
3548 SetDisplayConnection (aDispConn);
3550 for (int aNbEventsMax = XPending (aDispX), anEventIter (0);;)
3552 const int anEventResult = ViewerMainLoop (0, NULL);
3553 if (anEventResult == 0)
3558 aNbRemain = XPending (aDispX);
3559 if (++anEventIter >= aNbEventsMax
3566 // Listening X events through Tcl_CreateFileHandler() callback is fragile,
3567 // it is possible that new events will arrive to queue before the end of this callback
3568 // so that either this callback should go into an infinite loop (blocking processing of other events)
3569 // or to keep unprocessed events till the next queue update (which can arrive not soon).
3570 // Sending a dummy event in this case is a simple workaround (still, it is possible that new event will be queued in-between).
3574 memset (&aDummyEvent, 0, sizeof(aDummyEvent));
3575 aDummyEvent.type = ClientMessage;
3576 aDummyEvent.xclient.format = 32;
3577 XSendEvent (aDispX, InputFocus, False, 0, &aDummyEvent);
3581 if (const Handle(AIS_InteractiveContext)& anActiveCtx = ViewerTest::GetAISContext())
3583 SetDisplayConnection (anActiveCtx->CurrentViewer()->Driver()->GetDisplayConnection());
3588 //==============================================================================
3589 //function : OSWindowSetup
3590 //purpose : Setup for the X11 window to be able to cath the event
3591 //==============================================================================
3594 static void OSWindowSetup()
3596 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
3599 Window window = VT_GetWindow()->XWindow();
3600 SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection());
3601 Display *aDisplay = GetDisplayConnection()->GetDisplay();
3602 XSynchronize(aDisplay, 1);
3604 // X11 : For keyboard on SUN
3606 wmhints.flags = InputHint;
3609 XSetWMHints( aDisplay, window, &wmhints);
3611 XSelectInput( aDisplay, window, ExposureMask | KeyPressMask | KeyReleaseMask |
3612 ButtonPressMask | ButtonReleaseMask |
3613 StructureNotifyMask |
3615 Button1MotionMask | Button2MotionMask |
3616 Button3MotionMask | FocusChangeMask
3618 Atom aDeleteWindowAtom = GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW);
3619 XSetWMProtocols(aDisplay, window, &aDeleteWindowAtom, 1);
3621 XSynchronize(aDisplay, 0);
3629 //==============================================================================
3632 //==============================================================================
3634 static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgv)
3636 const Handle(V3d_View) aView = ViewerTest::CurrentView();
3639 Message::SendFail ("Error: no active viewer");
3643 Standard_Boolean toFit = Standard_True;
3644 ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
3645 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3647 TCollection_AsciiString anArg (theArgv[anArgIter]);
3649 if (anUpdateTool.parseRedrawMode (anArg))
3653 else if (anArg == "-selected")
3655 ViewerTest::GetAISContext()->FitSelected (aView, 0.01, Standard_False);
3656 toFit = Standard_False;
3660 Message::SendFail() << "Syntax error at '" << anArg << "'";
3666 aView->FitAll (0.01, Standard_False);
3671 //=======================================================================
3672 //function : VFitArea
3673 //purpose : Fit view to show area located between two points
3674 // : given in world 2D or 3D coordinates.
3675 //=======================================================================
3676 static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3678 Handle(V3d_View) aView = ViewerTest::CurrentView();
3681 Message::SendFail ("Error: No active viewer");
3686 gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0);
3687 gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0);
3691 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
3692 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
3693 aWorldPnt2.SetX (Draw::Atof (theArgVec[3]));
3694 aWorldPnt2.SetY (Draw::Atof (theArgVec[4]));
3696 else if (theArgNb == 7)
3698 aWorldPnt1.SetX (Draw::Atof (theArgVec[1]));
3699 aWorldPnt1.SetY (Draw::Atof (theArgVec[2]));
3700 aWorldPnt1.SetZ (Draw::Atof (theArgVec[3]));
3701 aWorldPnt2.SetX (Draw::Atof (theArgVec[4]));
3702 aWorldPnt2.SetY (Draw::Atof (theArgVec[5]));
3703 aWorldPnt2.SetZ (Draw::Atof (theArgVec[6]));
3707 Message::SendFail ("Syntax error: Invalid number of arguments");
3708 theDI.PrintHelp(theArgVec[0]);
3712 // Convert model coordinates to view space
3713 Handle(Graphic3d_Camera) aCamera = aView->Camera();
3714 gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1);
3715 gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2);
3717 // Determine fit area
3718 gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y()));
3719 gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y()));
3721 Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner);
3723 if (aDiagonal < Precision::Confusion())
3725 Message::SendFail ("Error: view area is too small");
3729 aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y());
3733 //==============================================================================
3735 //purpose : ZFitall, no DRAW arguments
3736 //Draw arg : No args
3737 //==============================================================================
3738 static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
3740 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
3742 if (aCurrentView.IsNull())
3744 Message::SendFail ("Error: no active viewer");
3750 aCurrentView->ZFitAll();
3751 aCurrentView->Redraw();
3755 Standard_Real aScale = 1.0;
3759 aScale = Draw::Atoi (theArgVec[1]);
3762 aCurrentView->ZFitAll (aScale);
3763 aCurrentView->Redraw();
3768 //==============================================================================
3769 //function : VRepaint
3771 //==============================================================================
3772 static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgVec)
3774 Handle(V3d_View) aView = ViewerTest::CurrentView();
3777 Message::SendFail ("Error: no active viewer");
3781 Standard_Boolean isImmediateUpdate = Standard_False;
3782 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3784 TCollection_AsciiString anArg (theArgVec[anArgIter]);
3786 if (anArg == "-immediate"
3789 isImmediateUpdate = Standard_True;
3790 if (anArgIter + 1 < theArgNb
3791 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate))
3796 else if (anArg == "-continuous"
3799 || anArg == "-framerate")
3801 Standard_Real aFps = -1.0;
3802 if (anArgIter + 1 < theArgNb
3803 && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsRealValue())
3805 aFps = Draw::Atof (theArgVec[++anArgIter]);
3808 ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
3809 if (Abs (aFps) >= 1.0)
3811 aRedrawer.Start (aView->Window(), aFps);
3820 Message::SendFail() << "Syntax error at '" << anArg << "'";
3825 if (isImmediateUpdate)
3827 aView->RedrawImmediate();
3836 //==============================================================================
3838 //purpose : Remove all the object from the viewer
3839 //Draw arg : No args
3840 //==============================================================================
3842 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
3844 Handle(V3d_View) V = ViewerTest::CurrentView();
3846 ViewerTest::Clear();
3850 //==============================================================================
3853 //==============================================================================
3855 static int VPick (Draw_Interpretor& ,
3856 Standard_Integer theNbArgs,
3857 const char** theArgVec)
3859 if (ViewerTest::CurrentView().IsNull())
3866 Message::SendFail ("Syntax error: wrong number of arguments");
3870 while (ViewerMainLoop (theNbArgs, theArgVec))
3881 //! Changes the background
3882 //! @param theDrawInterpretor the interpreter of the Draw Harness application
3883 //! @param theNumberOfCommandLineArguments the number of passed command line arguments
3884 //! @param theCommandLineArguments the array of command line arguments
3885 //! @return TCL_OK if changing was successful, or TCL_ERROR otherwise
3886 static int vbackground (Draw_Interpretor& theDrawInterpretor,
3887 const Standard_Integer theNumberOfCommandLineArguments,
3888 const char** const theCommandLineArguments)
3890 if (theNumberOfCommandLineArguments < 1)
3894 BackgroundChanger aBackgroundChanger;
3895 if (!aBackgroundChanger.ProcessCommandLine (theDrawInterpretor,
3896 theNumberOfCommandLineArguments,
3897 theCommandLineArguments))
3899 theDrawInterpretor << "Wrong command arguments.\n"
3901 << theCommandLineArguments[0] << "' for information about command options and its arguments.\n";
3909 //==============================================================================
3911 //purpose : View Scaling
3912 //==============================================================================
3914 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3916 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
3917 if ( V3dView.IsNull() ) return 1;
3920 di << argv[0] << "Invalid number of arguments\n";
3923 V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
3926 //==============================================================================
3927 //function : VZBuffTrihedron
3929 //==============================================================================
3931 static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
3932 Standard_Integer theArgNb,
3933 const char** theArgVec)
3935 Handle(V3d_View) aView = ViewerTest::CurrentView();
3938 Message::SendFail ("Error: no active viewer");
3942 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
3944 Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER;
3945 V3d_TypeOfVisualization aVisType = V3d_ZBUFFER;
3946 Quantity_Color aLabelsColor = Quantity_NOC_WHITE;
3947 Quantity_Color anArrowColorX = Quantity_NOC_RED;
3948 Quantity_Color anArrowColorY = Quantity_NOC_GREEN;
3949 Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1;
3950 Standard_Real aScale = 0.1;
3951 Standard_Real aSizeRatio = 0.8;
3952 Standard_Real anArrowDiam = 0.05;
3953 Standard_Integer aNbFacets = 12;
3954 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3956 Standard_CString anArg = theArgVec[anArgIter];
3957 TCollection_AsciiString aFlag (anArg);
3959 if (anUpdateTool.parseRedrawMode (aFlag))
3963 else if (aFlag == "-on")
3967 else if (aFlag == "-off")
3969 aView->TriedronErase();
3972 else if (aFlag == "-pos"
3973 || aFlag == "-position"
3974 || aFlag == "-corner")
3976 if (++anArgIter >= theArgNb)
3978 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
3982 TCollection_AsciiString aPosName (theArgVec[anArgIter]);
3983 aPosName.LowerCase();
3984 if (aPosName == "center")
3986 aPosition = Aspect_TOTP_CENTER;
3988 else if (aPosName == "left_lower"
3989 || aPosName == "lower_left"
3990 || aPosName == "leftlower"
3991 || aPosName == "lowerleft")
3993 aPosition = Aspect_TOTP_LEFT_LOWER;
3995 else if (aPosName == "left_upper"
3996 || aPosName == "upper_left"
3997 || aPosName == "leftupper"
3998 || aPosName == "upperleft")
4000 aPosition = Aspect_TOTP_LEFT_UPPER;
4002 else if (aPosName == "right_lower"
4003 || aPosName == "lower_right"
4004 || aPosName == "rightlower"
4005 || aPosName == "lowerright")
4007 aPosition = Aspect_TOTP_RIGHT_LOWER;
4009 else if (aPosName == "right_upper"
4010 || aPosName == "upper_right"
4011 || aPosName == "rightupper"
4012 || aPosName == "upperright")
4014 aPosition = Aspect_TOTP_RIGHT_UPPER;
4018 Message::SendFail() << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'";
4022 else if (aFlag == "-type")
4024 if (++anArgIter >= theArgNb)
4026 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4030 TCollection_AsciiString aTypeName (theArgVec[anArgIter]);
4031 aTypeName.LowerCase();
4032 if (aTypeName == "wireframe"
4033 || aTypeName == "wire")
4035 aVisType = V3d_WIREFRAME;
4037 else if (aTypeName == "zbuffer"
4038 || aTypeName == "shaded")
4040 aVisType = V3d_ZBUFFER;
4044 Message::SendFail() << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'";
4047 else if (aFlag == "-scale")
4049 if (++anArgIter >= theArgNb)
4051 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4055 aScale = Draw::Atof (theArgVec[anArgIter]);
4057 else if (aFlag == "-size"
4058 || aFlag == "-sizeratio")
4060 if (++anArgIter >= theArgNb)
4062 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4066 aSizeRatio = Draw::Atof (theArgVec[anArgIter]);
4068 else if (aFlag == "-arrowdiam"
4069 || aFlag == "-arrowdiameter")
4071 if (++anArgIter >= theArgNb)
4073 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4077 anArrowDiam = Draw::Atof (theArgVec[anArgIter]);
4079 else if (aFlag == "-nbfacets")
4081 if (++anArgIter >= theArgNb)
4083 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4087 aNbFacets = Draw::Atoi (theArgVec[anArgIter]);
4089 else if (aFlag == "-colorlabel"
4090 || aFlag == "-colorlabels")
4092 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4093 theArgVec + anArgIter + 1,
4097 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4100 anArgIter += aNbParsed;
4102 else if (aFlag == "-colorarrowx")
4104 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4105 theArgVec + anArgIter + 1,
4109 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4112 anArgIter += aNbParsed;
4114 else if (aFlag == "-colorarrowy")
4116 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4117 theArgVec + anArgIter + 1,
4121 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4124 anArgIter += aNbParsed;
4126 else if (aFlag == "-colorarrowz")
4128 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
4129 theArgVec + anArgIter + 1,
4133 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4136 anArgIter += aNbParsed;
4140 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4145 aView->ZBufferTriedronSetup (anArrowColorX.Name(), anArrowColorY.Name(), anArrowColorZ.Name(),
4146 aSizeRatio, anArrowDiam, aNbFacets);
4147 aView->TriedronDisplay (aPosition, aLabelsColor.Name(), aScale, aVisType);
4152 //==============================================================================
4153 //function : VRotate
4154 //purpose : Camera Rotating
4155 //==============================================================================
4157 static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
4159 Handle(V3d_View) aView = ViewerTest::CurrentView();
4162 Message::SendFail ("Error: no active viewer");
4166 Standard_Boolean hasFlags = Standard_False;
4167 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
4169 Standard_CString anArg (theArgVec[anArgIter]);
4170 TCollection_AsciiString aFlag (anArg);
4172 if (aFlag == "-mousestart"
4173 || aFlag == "-mousefrom")
4175 hasFlags = Standard_True;
4176 if (anArgIter + 2 >= theArgNb)
4178 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4182 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
4183 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
4184 aView->StartRotation (anX, anY);
4186 else if (aFlag == "-mousemove")
4188 hasFlags = Standard_True;
4189 if (anArgIter + 2 >= theArgNb)
4191 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4195 Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]);
4196 Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]);
4197 aView->Rotation (anX, anY);
4199 else if (theArgNb != 4
4202 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4211 else if (theArgNb == 4)
4213 Standard_Real anAX = Draw::Atof (theArgVec[1]);
4214 Standard_Real anAY = Draw::Atof (theArgVec[2]);
4215 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
4216 aView->Rotate (anAX, anAY, anAZ);
4219 else if (theArgNb == 7)
4221 Standard_Real anAX = Draw::Atof (theArgVec[1]);
4222 Standard_Real anAY = Draw::Atof (theArgVec[2]);
4223 Standard_Real anAZ = Draw::Atof (theArgVec[3]);
4225 Standard_Real anX = Draw::Atof (theArgVec[4]);
4226 Standard_Real anY = Draw::Atof (theArgVec[5]);
4227 Standard_Real anZ = Draw::Atof (theArgVec[6]);
4229 aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ);
4233 Message::SendFail ("Error: Invalid number of arguments");
4237 //==============================================================================
4239 //purpose : View zoom in / out (relative to current zoom)
4240 //==============================================================================
4242 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
4243 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
4244 if ( V3dView.IsNull() ) {
4249 Standard_Real coef = Draw::Atof(argv[1]);
4250 if ( coef <= 0.0 ) {
4251 di << argv[1] << "Invalid value\n";
4254 V3dView->SetZoom( Draw::Atof(argv[1]) );
4257 di << argv[0] << " Invalid number of arguments\n";
4262 //==============================================================================
4264 //purpose : View panning (in pixels)
4265 //==============================================================================
4267 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
4268 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
4269 if ( V3dView.IsNull() ) return 1;
4272 V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) );
4275 di << argv[0] << " Invalid number of arguments\n";
4280 //==============================================================================
4282 //purpose : Place the point (in pixels) at the center of the window
4283 //==============================================================================
4284 static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs)
4286 Handle(V3d_View) aView = ViewerTest::CurrentView();
4289 Message::SendFail ("Error: no active viewer");
4295 Message::SendFail ("Syntax error: wrong number of arguments");
4299 aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale());
4304 static int VColorScale (Draw_Interpretor& theDI,
4305 Standard_Integer theArgNb,
4306 const char** theArgVec)
4308 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4309 Handle(V3d_View) aView = ViewerTest::CurrentView();
4310 if (aContext.IsNull())
4312 Message::SendFail ("Error: no active viewer");
4317 Message::SendFail() << "Error: wrong syntax at command '" << theArgVec[0] << "'";
4321 Handle(AIS_ColorScale) aColorScale;
4322 if (GetMapOfAIS().IsBound2 (theArgVec[1]))
4324 // find existing object
4325 aColorScale = Handle(AIS_ColorScale)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
4326 if (aColorScale.IsNull())
4328 Message::SendFail() << "Error: object '" << theArgVec[1] << "'is already defined and is not a color scale";
4335 if (aColorScale.IsNull())
4337 Message::SendFail() << "Syntax error: colorscale with a given name does not exist";
4341 theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n"
4342 << "Min range: " << aColorScale->GetMin() << "\n"
4343 << "Max range: " << aColorScale->GetMax() << "\n"
4344 << "Number of intervals: " << aColorScale->GetNumberOfIntervals() << "\n"
4345 << "Text height: " << aColorScale->GetTextHeight() << "\n"
4346 << "Color scale position: " << aColorScale->GetXPosition() << " " << aColorScale->GetYPosition() << "\n"
4347 << "Color scale title: " << aColorScale->GetTitle() << "\n"
4348 << "Label position: ";
4349 switch (aColorScale->GetLabelPosition())
4351 case Aspect_TOCSP_NONE:
4354 case Aspect_TOCSP_LEFT:
4357 case Aspect_TOCSP_RIGHT:
4360 case Aspect_TOCSP_CENTER:
4361 theDI << "Center\n";
4367 if (aColorScale.IsNull())
4369 aColorScale = new AIS_ColorScale();
4370 aColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
4371 aContext->SetTransformPersistence (aColorScale, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
4374 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
4375 for (Standard_Integer anArgIter = 2; anArgIter < theArgNb; ++anArgIter)
4377 Standard_CString anArg = theArgVec[anArgIter];
4378 TCollection_AsciiString aFlag (anArg);
4380 if (anUpdateTool.parseRedrawMode (aFlag))
4384 else if (aFlag == "-range")
4386 if (anArgIter + 3 >= theArgNb)
4388 Message::SendFail() << "Error: wrong syntax at argument '" << anArg << "'";
4392 const TCollection_AsciiString aRangeMin (theArgVec[++anArgIter]);
4393 const TCollection_AsciiString aRangeMax (theArgVec[++anArgIter]);
4394 const TCollection_AsciiString aNbIntervals (theArgVec[++anArgIter]);
4395 if (!aRangeMin.IsRealValue()
4396 || !aRangeMax.IsRealValue())
4398 Message::SendFail ("Syntax error: the range values should be real");
4401 else if (!aNbIntervals.IsIntegerValue())
4403 Message::SendFail ("Syntax error: the number of intervals should be integer");
4407 aColorScale->SetRange (aRangeMin.RealValue(), aRangeMax.RealValue());
4408 aColorScale->SetNumberOfIntervals (aNbIntervals.IntegerValue());
4410 else if (aFlag == "-font")
4412 if (anArgIter + 1 >= theArgNb)
4414 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4417 TCollection_AsciiString aFontArg(theArgVec[anArgIter + 1]);
4418 if (!aFontArg.IsIntegerValue())
4420 Message::SendFail ("Syntax error: HeightFont value should be integer");
4424 aColorScale->SetTextHeight (aFontArg.IntegerValue());
4427 else if (aFlag == "-textpos")
4429 if (anArgIter + 1 >= theArgNb)
4431 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4435 TCollection_AsciiString aTextPosArg(theArgVec[++anArgIter]);
4436 aTextPosArg.LowerCase();
4437 Aspect_TypeOfColorScalePosition aLabPosition = Aspect_TOCSP_NONE;
4438 if (aTextPosArg == "none")
4440 aLabPosition = Aspect_TOCSP_NONE;
4442 else if (aTextPosArg == "left")
4444 aLabPosition = Aspect_TOCSP_LEFT;
4446 else if (aTextPosArg == "right")
4448 aLabPosition = Aspect_TOCSP_RIGHT;
4450 else if (aTextPosArg == "center")
4452 aLabPosition = Aspect_TOCSP_CENTER;
4456 Message::SendFail() << "Syntax error: unknown position '" << aTextPosArg << "'";
4459 aColorScale->SetLabelPosition (aLabPosition);
4461 else if (aFlag == "-logarithmic"
4464 if (anArgIter + 1 >= theArgNb)
4466 Message::SendFail() << "Synta error at argument '" << anArg << "'";
4470 Standard_Boolean IsLog;
4471 if (!ViewerTest::ParseOnOff(theArgVec[++anArgIter], IsLog))
4473 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4476 aColorScale->SetLogarithmic (IsLog);
4478 else if (aFlag == "-huerange"
4481 if (anArgIter + 2 >= theArgNb)
4483 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4487 const Standard_Real aHueMin = Draw::Atof (theArgVec[++anArgIter]);
4488 const Standard_Real aHueMax = Draw::Atof (theArgVec[++anArgIter]);
4489 aColorScale->SetHueRange (aHueMin, aHueMax);
4491 else if (aFlag == "-colorrange")
4493 Quantity_Color aColorMin, aColorMax;
4494 Standard_Integer aNbParsed1 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4495 theArgVec + (anArgIter + 1),
4497 anArgIter += aNbParsed1;
4498 Standard_Integer aNbParsed2 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4499 theArgVec + (anArgIter + 1),
4501 anArgIter += aNbParsed2;
4505 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4509 aColorScale->SetColorRange (aColorMin, aColorMax);
4511 else if (aFlag == "-reversed"
4512 || aFlag == "-inverted"
4513 || aFlag == "-topdown"
4514 || aFlag == "-bottomup")
4516 Standard_Boolean toEnable = Standard_True;
4517 if (anArgIter + 1 < theArgNb
4518 && ViewerTest::ParseOnOff(theArgVec[anArgIter + 1], toEnable))
4522 aColorScale->SetReversed ((aFlag == "-topdown") ? !toEnable : toEnable);
4524 else if (aFlag == "-smooth"
4525 || aFlag == "-smoothtransition")
4527 Standard_Boolean toEnable = Standard_True;
4528 if (anArgIter + 1 < theArgNb
4529 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
4533 aColorScale->SetSmoothTransition (toEnable);
4535 else if (aFlag == "-xy")
4537 if (anArgIter + 2 >= theArgNb)
4539 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4543 const TCollection_AsciiString anX (theArgVec[++anArgIter]);
4544 const TCollection_AsciiString anY (theArgVec[++anArgIter]);
4545 if (!anX.IsIntegerValue()
4546 || !anY.IsIntegerValue())
4548 Message::SendFail ("Syntax error: coordinates should be integer values");
4552 aColorScale->SetPosition (anX.IntegerValue(), anY.IntegerValue());
4554 else if (aFlag == "-width"
4556 || aFlag == "-breadth")
4558 if (anArgIter + 1 >= theArgNb)
4560 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4564 const TCollection_AsciiString aBreadth (theArgVec[++anArgIter]);
4565 if (!aBreadth.IsIntegerValue())
4567 Message::SendFail ("Syntax error: a width should be an integer value");
4570 aColorScale->SetBreadth (aBreadth.IntegerValue());
4572 else if (aFlag == "-height"
4575 if (anArgIter + 1 >= theArgNb)
4577 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4581 const TCollection_AsciiString aHeight (theArgVec[++anArgIter]);
4582 if (!aHeight.IsIntegerValue())
4584 Message::SendFail ("Syntax error: a width should be an integer value");
4587 aColorScale->SetHeight (aHeight.IntegerValue());
4589 else if (aFlag == "-color")
4591 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
4593 Message::SendFail ("Syntax error: wrong color type. Call -colors before to set user-specified colors");
4596 else if (anArgIter + 2 >= theArgNb)
4598 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4602 const TCollection_AsciiString anInd (theArgVec[++anArgIter]);
4603 if (!anInd.IsIntegerValue())
4605 Message::SendFail ("Syntax error: Index value should be integer");
4608 const Standard_Integer anIndex = anInd.IntegerValue();
4609 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals())
4611 Message::SendFail() << "Syntax error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals();
4615 Quantity_Color aColor;
4616 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4617 theArgVec + (anArgIter + 1),
4621 Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
4624 aColorScale->SetIntervalColor (aColor, anIndex);
4625 aColorScale->SetColorType (Aspect_TOCSD_USER);
4626 anArgIter += aNbParsed;
4628 else if (aFlag == "-label")
4630 if (aColorScale->GetColorType() != Aspect_TOCSD_USER)
4632 Message::SendFail ("Syntax error: wrong label type. Call -labels before to set user-specified labels");
4635 else if (anArgIter + 2 >= theArgNb)
4637 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4641 Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]);
4642 if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals() + 1)
4644 Message::SendFail() << "Syntax error: Index value should be within range 1.." << (aColorScale->GetNumberOfIntervals() + 1);
4648 TCollection_ExtendedString aText (theArgVec[anArgIter + 2]);
4649 aColorScale->SetLabel (aText, anIndex);
4650 aColorScale->SetLabelType (Aspect_TOCSD_USER);
4653 else if (aFlag == "-labelat"
4654 || aFlag == "-labat"
4655 || aFlag == "-labelatborder"
4656 || aFlag == "-labatborder"
4657 || aFlag == "-labelatcenter"
4658 || aFlag == "-labatcenter")
4660 Standard_Boolean toEnable = Standard_True;
4661 if (aFlag == "-labelat"
4662 || aFlag == "-labat")
4664 Standard_Integer aLabAtBorder = -1;
4665 if (++anArgIter >= theArgNb)
4667 TCollection_AsciiString anAtBorder (theArgVec[anArgIter]);
4668 anAtBorder.LowerCase();
4669 if (anAtBorder == "border")
4673 else if (anAtBorder == "center")
4678 if (aLabAtBorder == -1)
4680 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4683 toEnable = (aLabAtBorder == 1);
4685 else if (anArgIter + 1 < theArgNb
4686 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
4690 aColorScale->SetLabelAtBorder (aFlag == "-labelatcenter"
4691 || aFlag == "-labatcenter"
4695 else if (aFlag == "-colors")
4697 Aspect_SequenceOfColor aSeq;
4700 Quantity_Color aColor;
4701 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
4702 theArgVec + (anArgIter + 1),
4708 anArgIter += aNbParsed;
4709 aSeq.Append (aColor);
4711 if (aSeq.Length() != aColorScale->GetNumberOfIntervals())
4713 Message::SendFail() << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the "
4714 << aColorScale->GetNumberOfIntervals() << " intervals";
4718 aColorScale->SetColors (aSeq);
4719 aColorScale->SetColorType (Aspect_TOCSD_USER);
4721 else if (aFlag == "-uniform")
4723 const Standard_Real aLightness = Draw::Atof (theArgVec[++anArgIter]);
4724 const Standard_Real aHueStart = Draw::Atof (theArgVec[++anArgIter]);
4725 const Standard_Real aHueEnd = Draw::Atof (theArgVec[++anArgIter]);
4726 aColorScale->SetUniformColors (aLightness, aHueStart, aHueEnd);
4727 aColorScale->SetColorType (Aspect_TOCSD_USER);
4729 else if (aFlag == "-labels"
4730 || aFlag == "-freelabels")
4732 if (anArgIter + 1 >= theArgNb)
4734 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4738 Standard_Integer aNbLabels = aColorScale->IsLabelAtBorder()
4739 ? aColorScale->GetNumberOfIntervals() + 1
4740 : aColorScale->GetNumberOfIntervals();
4741 if (aFlag == "-freelabels")
4744 aNbLabels = Draw::Atoi (theArgVec[anArgIter]);
4746 if (anArgIter + aNbLabels >= theArgNb)
4748 Message::SendFail() << "Syntax error: not enough arguments. " << aNbLabels << " text labels are expected";
4752 TColStd_SequenceOfExtendedString aSeq;
4753 for (Standard_Integer aLabelIter = 0; aLabelIter < aNbLabels; ++aLabelIter)
4755 aSeq.Append (TCollection_ExtendedString (theArgVec[++anArgIter]));
4757 aColorScale->SetLabels (aSeq);
4758 aColorScale->SetLabelType (Aspect_TOCSD_USER);
4760 else if (aFlag == "-title")
4762 if (anArgIter + 1 >= theArgNb)
4764 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4768 Standard_Boolean isTwoArgs = Standard_False;
4769 if (anArgIter + 2 < theArgNb)
4771 TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]);
4772 aSecondArg.LowerCase();
4773 Standard_DISABLE_DEPRECATION_WARNINGS
4774 if (aSecondArg == "none")
4776 aColorScale->SetTitlePosition (Aspect_TOCSP_NONE);
4777 isTwoArgs = Standard_True;
4779 else if (aSecondArg == "left")
4781 aColorScale->SetTitlePosition (Aspect_TOCSP_LEFT);
4782 isTwoArgs = Standard_True;
4784 else if (aSecondArg == "right")
4786 aColorScale->SetTitlePosition (Aspect_TOCSP_RIGHT);
4787 isTwoArgs = Standard_True;
4789 else if (aSecondArg == "center")
4791 aColorScale->SetTitlePosition (Aspect_TOCSP_CENTER);
4792 isTwoArgs = Standard_True;
4794 Standard_ENABLE_DEPRECATION_WARNINGS
4797 aColorScale->SetTitle (theArgVec[anArgIter + 1]);
4804 else if (aFlag == "-demoversion"
4805 || aFlag == "-demo")
4807 aColorScale->SetPosition (0, 0);
4808 aColorScale->SetTextHeight (16);
4809 aColorScale->SetRange (0.0, 100.0);
4810 aColorScale->SetNumberOfIntervals (10);
4811 aColorScale->SetBreadth (0);
4812 aColorScale->SetHeight (0);
4813 aColorScale->SetLabelPosition (Aspect_TOCSP_RIGHT);
4814 aColorScale->SetColorType (Aspect_TOCSD_AUTO);
4815 aColorScale->SetLabelType (Aspect_TOCSD_AUTO);
4817 else if (aFlag == "-findcolor")
4819 if (anArgIter + 1 >= theArgNb)
4821 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
4825 TCollection_AsciiString anArg1 (theArgVec[++anArgIter]);
4827 if (!anArg1.IsRealValue())
4829 Message::SendFail ("Syntax error: the value should be real");
4833 Quantity_Color aColor;
4834 aColorScale->FindColor (anArg1.RealValue(), aColor);
4835 theDI << Quantity_Color::StringName (aColor.Name());
4840 Message::SendFail() << "Syntax error at " << anArg << " - unknown argument";
4845 Standard_Integer aWinWidth = 0, aWinHeight = 0;
4846 aView->Window()->Size (aWinWidth, aWinHeight);
4847 if (aColorScale->GetBreadth() == 0)
4849 aColorScale->SetBreadth (aWinWidth);
4851 if (aColorScale->GetHeight() == 0)
4853 aColorScale->SetHeight (aWinHeight);
4855 aColorScale->SetToUpdate();
4856 ViewerTest::Display (theArgVec[1], aColorScale, Standard_False, Standard_True);
4860 //==============================================================================
4861 //function : VGraduatedTrihedron
4862 //purpose : Displays or hides a graduated trihedron
4863 //==============================================================================
4864 static Standard_Boolean GetColor (const TCollection_AsciiString& theValue,
4865 Quantity_Color& theColor)
4867 Quantity_NameOfColor aColorName;
4868 TCollection_AsciiString aVal = theValue;
4870 if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName))
4872 return Standard_False;
4874 theColor = Quantity_Color (aColorName);
4875 return Standard_True;
4878 static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs)
4882 Message::SendFail() << "Syntax error: wrong number of parameters. Type 'help"
4883 << theArgs[0] <<"' for more information";
4887 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
4888 TCollection_AsciiString aParseKey;
4889 for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt)
4891 TCollection_AsciiString anArg (theArgs [anArgIt]);
4893 if (anArg.Value (1) == '-' && !anArg.IsRealValue())
4896 aParseKey.Remove (1);
4897 aParseKey.LowerCase();
4898 aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
4902 if (aParseKey.IsEmpty())
4907 aMapOfArgs(aParseKey)->Append (anArg);
4911 for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
4912 aMapIt.More(); aMapIt.Next())
4914 const TCollection_AsciiString& aKey = aMapIt.Key();
4915 const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
4917 // Bool key, without arguments
4918 if ((aKey.IsEqual ("on") || aKey.IsEqual ("off"))
4919 && anArgs->IsEmpty())
4925 if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname"))
4926 && anArgs->Length() == 1)
4932 if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname")
4933 || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks")
4934 || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues")
4935 || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes"))
4936 && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off")))
4941 // One string argument
4942 if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor")
4943 || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor"))
4944 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4949 // One integer argument
4950 if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks")
4951 || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength")
4952 || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset")
4953 || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset"))
4954 && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue())
4959 // One real argument
4960 if ( aKey.IsEqual ("arrowlength")
4961 && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue()))
4966 // Two string arguments
4967 if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont"))
4968 && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
4973 TCollection_AsciiString aLowerKey;
4976 aLowerKey.LowerCase();
4977 Message::SendFail() << "Syntax error: " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n"
4978 << "Type help for more information";
4982 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
4983 if (anAISContext.IsNull())
4985 Message::SendFail ("Error: no active viewer");
4989 Standard_Boolean toDisplay = Standard_True;
4990 Quantity_Color aColor;
4991 Graphic3d_GraduatedTrihedron aTrihedronData;
4992 // Process parameters
4993 Handle(TColStd_HSequenceOfAsciiString) aValues;
4994 if (aMapOfArgs.Find ("off", aValues))
4996 toDisplay = Standard_False;
5000 if (aMapOfArgs.Find ("xname", aValues))
5002 aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1));
5004 if (aMapOfArgs.Find ("yname", aValues))
5006 aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1));
5008 if (aMapOfArgs.Find ("zname", aValues))
5010 aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1));
5012 if (aMapOfArgs.Find ("xdrawname", aValues))
5014 aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
5016 if (aMapOfArgs.Find ("ydrawname", aValues))
5018 aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
5020 if (aMapOfArgs.Find ("zdrawname", aValues))
5022 aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on"));
5024 if (aMapOfArgs.Find ("xnameoffset", aValues))
5026 aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
5028 if (aMapOfArgs.Find ("ynameoffset", aValues))
5030 aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
5032 if (aMapOfArgs.Find ("znameoffset", aValues))
5034 aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
5038 if (aMapOfArgs.Find ("xnamecolor", aValues))
5040 if (!GetColor (aValues->Value(1), aColor))
5042 Message::SendFail ("Syntax error: -xnamecolor wrong color name");
5045 aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor);
5047 if (aMapOfArgs.Find ("ynamecolor", aValues))
5049 if (!GetColor (aValues->Value(1), aColor))
5051 Message::SendFail ("Syntax error: -ynamecolor wrong color name");
5054 aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor);
5056 if (aMapOfArgs.Find ("znamecolor", aValues))
5058 if (!GetColor (aValues->Value(1), aColor))
5060 Message::SendFail ("Syntax error: -znamecolor wrong color name");
5063 aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor);
5065 if (aMapOfArgs.Find ("xcolor", aValues))
5067 if (!GetColor (aValues->Value(1), aColor))
5069 Message::SendFail ("Syntax error: -xcolor wrong color name");
5072 aTrihedronData.ChangeXAxisAspect().SetColor (aColor);
5074 if (aMapOfArgs.Find ("ycolor", aValues))
5076 if (!GetColor (aValues->Value(1), aColor))
5078 Message::SendFail ("Syntax error: -ycolor wrong color name");
5081 aTrihedronData.ChangeYAxisAspect().SetColor (aColor);
5083 if (aMapOfArgs.Find ("zcolor", aValues))
5085 if (!GetColor (aValues->Value(1), aColor))
5087 Message::SendFail ("Syntax error: -zcolor wrong color name");
5090 aTrihedronData.ChangeZAxisAspect().SetColor (aColor);
5094 if (aMapOfArgs.Find ("xticks", aValues))
5096 aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
5098 if (aMapOfArgs.Find ("yticks", aValues))
5100 aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
5102 if (aMapOfArgs.Find ("zticks", aValues))
5104 aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue());
5106 if (aMapOfArgs.Find ("xticklength", aValues))
5108 aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
5110 if (aMapOfArgs.Find ("yticklength", aValues))
5112 aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
5114 if (aMapOfArgs.Find ("zticklength", aValues))
5116 aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue());
5118 if (aMapOfArgs.Find ("xdrawticks", aValues))
5120 aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
5122 if (aMapOfArgs.Find ("ydrawticks", aValues))
5124 aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
5126 if (aMapOfArgs.Find ("zdrawticks", aValues))
5128 aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on"));
5132 if (aMapOfArgs.Find ("xdrawvalues", aValues))
5134 aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
5136 if (aMapOfArgs.Find ("ydrawvalues", aValues))
5138 aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
5140 if (aMapOfArgs.Find ("zdrawvalues", aValues))
5142 aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on"));
5144 if (aMapOfArgs.Find ("xvaluesoffset", aValues))
5146 aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
5148 if (aMapOfArgs.Find ("yvaluesoffset", aValues))
5150 aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
5152 if (aMapOfArgs.Find ("zvaluesoffset", aValues))
5154 aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
5158 if (aMapOfArgs.Find ("arrowlength", aValues))
5160 aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue());
5164 if (aMapOfArgs.Find ("namefont", aValues))
5166 aTrihedronData.SetNamesFont (aValues->Value(1));
5168 if (aMapOfArgs.Find ("valuesfont", aValues))
5170 aTrihedronData.SetValuesFont (aValues->Value(1));
5173 if (aMapOfArgs.Find ("drawgrid", aValues))
5175 aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on"));
5177 if (aMapOfArgs.Find ("drawaxes", aValues))
5179 aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on"));
5182 // The final step: display of erase trihedron
5185 ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData);
5189 ViewerTest::CurrentView()->GraduatedTrihedronErase();
5192 ViewerTest::GetAISContext()->UpdateCurrentViewer();
5193 ViewerTest::CurrentView()->Redraw();
5198 //==============================================================================
5201 //==============================================================================
5202 static int VTile (Draw_Interpretor& theDI,
5203 Standard_Integer theArgNb,
5204 const char** theArgVec)
5206 Handle(V3d_View) aView = ViewerTest::CurrentView();
5209 Message::SendFail ("Error: no active viewer");
5213 Graphic3d_CameraTile aTile = aView->Camera()->Tile();
5216 theDI << "Total size: " << aTile.TotalSize.x() << " " << aTile.TotalSize.y() << "\n"
5217 << "Tile size: " << aTile.TileSize.x() << " " << aTile.TileSize.y() << "\n"
5218 << "Lower left: " << aTile.Offset.x() << " " << aTile.Offset.y() << "\n";
5222 aView->Window()->Size (aTile.TileSize.x(), aTile.TileSize.y());
5223 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5225 TCollection_AsciiString anArg (theArgVec[anArgIter]);
5227 if (anArg == "-lowerleft"
5228 || anArg == "-upperleft")
5230 if (anArgIter + 3 < theArgNb)
5232 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
5235 aTile.IsTopDown = (anArg == "-upperleft") == Standard_True;
5236 aTile.Offset.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
5237 aTile.Offset.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
5239 else if (anArg == "-total"
5240 || anArg == "-totalsize"
5241 || anArg == "-viewsize")
5243 if (anArgIter + 3 < theArgNb)
5245 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
5248 aTile.TotalSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
5249 aTile.TotalSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
5250 if (aTile.TotalSize.x() < 1
5251 || aTile.TotalSize.y() < 1)
5253 Message::SendFail ("Error: total size is incorrect");
5257 else if (anArg == "-tilesize")
5259 if (anArgIter + 3 < theArgNb)
5261 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
5265 aTile.TileSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]);
5266 aTile.TileSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]);
5267 if (aTile.TileSize.x() < 1
5268 || aTile.TileSize.y() < 1)
5270 Message::SendFail ("Error: tile size is incorrect");
5274 else if (anArg == "-unset")
5276 aView->Camera()->SetTile (Graphic3d_CameraTile());
5282 if (aTile.TileSize.x() < 1
5283 || aTile.TileSize.y() < 1)
5285 Message::SendFail ("Error: tile size is undefined");
5288 else if (aTile.TotalSize.x() < 1
5289 || aTile.TotalSize.y() < 1)
5291 Message::SendFail ("Error: total size is undefined");
5295 aView->Camera()->SetTile (aTile);
5300 //! Format ZLayer ID.
5301 inline const char* formZLayerId (const Standard_Integer theLayerId)
5305 case Graphic3d_ZLayerId_UNKNOWN: return "[INVALID]";
5306 case Graphic3d_ZLayerId_Default: return "[DEFAULT]";
5307 case Graphic3d_ZLayerId_Top: return "[TOP]";
5308 case Graphic3d_ZLayerId_Topmost: return "[TOPMOST]";
5309 case Graphic3d_ZLayerId_TopOSD: return "[OVERLAY]";
5310 case Graphic3d_ZLayerId_BotOSD: return "[UNDERLAY]";
5315 //! Print the ZLayer information.
5316 inline void printZLayerInfo (Draw_Interpretor& theDI,
5317 const Graphic3d_ZLayerSettings& theLayer)
5319 if (!theLayer.Name().IsEmpty())
5321 theDI << " Name: " << theLayer.Name() << "\n";
5323 if (theLayer.IsImmediate())
5325 theDI << " Immediate: TRUE\n";
5327 theDI << " Origin: " << theLayer.Origin().X() << " " << theLayer.Origin().Y() << " " << theLayer.Origin().Z() << "\n";
5328 theDI << " Culling distance: " << theLayer.CullingDistance() << "\n";
5329 theDI << " Culling size: " << theLayer.CullingSize() << "\n";
5330 theDI << " Depth test: " << (theLayer.ToEnableDepthTest() ? "enabled" : "disabled") << "\n";
5331 theDI << " Depth write: " << (theLayer.ToEnableDepthWrite() ? "enabled" : "disabled") << "\n";
5332 theDI << " Depth buffer clearing: " << (theLayer.ToClearDepth() ? "enabled" : "disabled") << "\n";
5333 if (theLayer.PolygonOffset().Mode != Aspect_POM_None)
5335 theDI << " Depth offset: " << theLayer.PolygonOffset().Factor << " " << theLayer.PolygonOffset().Units << "\n";
5339 //==============================================================================
5340 //function : VZLayer
5341 //purpose : Test z layer operations for v3d viewer
5342 //==============================================================================
5343 static int VZLayer (Draw_Interpretor& theDI,
5344 Standard_Integer theArgNb,
5345 const char** theArgVec)
5347 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
5348 if (aContextAIS.IsNull())
5350 Message::SendFail ("Error: no active viewer");
5354 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
5357 TColStd_SequenceOfInteger aLayers;
5358 aViewer->GetAllZLayers (aLayers);
5359 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
5361 theDI << "ZLayer " << aLayeriter.Value() << " " << formZLayerId (aLayeriter.Value()) << "\n";
5362 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
5363 printZLayerInfo (theDI, aSettings);
5368 Standard_Integer anArgIter = 1;
5369 Standard_Integer aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5370 ViewerTest_AutoUpdater anUpdateTool (aContextAIS, ViewerTest::CurrentView());
5371 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
5377 TCollection_AsciiString aFirstArg (theArgVec[anArgIter]);
5378 if (aFirstArg.IsIntegerValue())
5381 aLayerId = aFirstArg.IntegerValue();
5385 if (ViewerTest::ParseZLayerName (aFirstArg.ToCString(), aLayerId))
5392 Graphic3d_ZLayerId anOtherLayerId = Graphic3d_ZLayerId_UNKNOWN;
5393 for (; anArgIter < theArgNb; ++anArgIter)
5395 // perform operation
5396 TCollection_AsciiString anArg (theArgVec[anArgIter]);
5398 if (anUpdateTool.parseRedrawMode (anArg))
5402 else if (anArg == "-add"
5405 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5406 if (!aViewer->AddZLayer (aLayerId))
5408 Message::SendFail ("Error: can not add a new z layer");
5414 else if (anArg == "-insertbefore"
5415 && anArgIter + 1 < theArgNb
5416 && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
5419 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5420 if (!aViewer->InsertLayerBefore (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
5422 Message::SendFail ("Error: can not add a new z layer");
5428 else if (anArg == "-insertafter"
5429 && anArgIter + 1 < theArgNb
5430 && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
5433 aLayerId = Graphic3d_ZLayerId_UNKNOWN;
5434 if (!aViewer->InsertLayerAfter (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
5436 Message::SendFail ("Error: can not add a new z layer");
5442 else if (anArg == "-del"
5443 || anArg == "-delete"
5446 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5448 if (++anArgIter >= theArgNb)
5450 Message::SendFail ("Syntax error: id of z layer to remove is missing");
5454 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
5457 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN
5458 || aLayerId == Graphic3d_ZLayerId_Default
5459 || aLayerId == Graphic3d_ZLayerId_Top
5460 || aLayerId == Graphic3d_ZLayerId_Topmost
5461 || aLayerId == Graphic3d_ZLayerId_TopOSD
5462 || aLayerId == Graphic3d_ZLayerId_BotOSD)
5464 Message::SendFail ("Syntax error: standard Z layer can not be removed");
5468 // move all object displayed in removing layer to default layer
5469 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
5470 anObjIter.More(); anObjIter.Next())
5472 const Handle(AIS_InteractiveObject)& aPrs = anObjIter.Key1();
5474 || aPrs->ZLayer() != aLayerId)
5478 aPrs->SetZLayer (Graphic3d_ZLayerId_Default);
5481 if (!aViewer->RemoveZLayer (aLayerId))
5483 Message::SendFail ("Z layer can not be removed");
5487 theDI << aLayerId << " ";
5490 else if (anArg == "-get"
5493 TColStd_SequenceOfInteger aLayers;
5494 aViewer->GetAllZLayers (aLayers);
5495 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
5497 theDI << aLayeriter.Value() << " ";
5502 else if (anArg == "-name")
5504 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5506 Message::SendFail ("Syntax error: id of Z layer is missing");
5510 if (++anArgIter >= theArgNb)
5512 Message::SendFail ("Syntax error: name is missing");
5516 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5517 aSettings.SetName (theArgVec[anArgIter]);
5518 aViewer->SetZLayerSettings (aLayerId, aSettings);
5520 else if (anArg == "-origin")
5522 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5524 Message::SendFail ("Syntax error: id of Z layer is missing");
5528 if (anArgIter + 2 >= theArgNb)
5530 Message::SendFail ("Syntax error: origin coordinates are missing");
5534 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5536 anOrigin.SetX (Draw::Atof (theArgVec[anArgIter + 1]));
5537 anOrigin.SetY (Draw::Atof (theArgVec[anArgIter + 2]));
5538 anOrigin.SetZ (0.0);
5539 if (anArgIter + 3 < theArgNb)
5541 anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter + 3]));
5548 aSettings.SetOrigin (anOrigin);
5549 aViewer->SetZLayerSettings (aLayerId, aSettings);
5551 else if (aLayerId != Graphic3d_ZLayerId_UNKNOWN
5552 && anArgIter + 1 < theArgNb
5553 && (anArg == "-cullingdistance"
5554 || anArg == "-cullingdist"
5555 || anArg == "-culldistance"
5556 || anArg == "-culldist"
5557 || anArg == "-distcull"
5558 || anArg == "-distculling"
5559 || anArg == "-distanceculling"))
5561 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5562 const Standard_Real aDist = Draw::Atof (theArgVec[++anArgIter]);
5563 aSettings.SetCullingDistance (aDist);
5564 aViewer->SetZLayerSettings (aLayerId, aSettings);
5566 else if (aLayerId != Graphic3d_ZLayerId_UNKNOWN
5567 && anArgIter + 1 < theArgNb
5568 && (anArg == "-cullingsize"
5569 || anArg == "-cullsize"
5570 || anArg == "-sizecull"
5571 || anArg == "-sizeculling"))
5573 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5574 const Standard_Real aSize = Draw::Atof (theArgVec[++anArgIter]);
5575 aSettings.SetCullingSize (aSize);
5576 aViewer->SetZLayerSettings (aLayerId, aSettings);
5578 else if (anArg == "-settings"
5579 || anArg == "settings")
5581 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5583 if (++anArgIter >= theArgNb)
5585 Message::SendFail ("Syntax error: id of Z layer is missing");
5589 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
5592 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5593 printZLayerInfo (theDI, aSettings);
5595 else if (anArg == "-enable"
5596 || anArg == "enable"
5597 || anArg == "-disable"
5598 || anArg == "disable")
5600 const Standard_Boolean toEnable = anArg == "-enable"
5601 || anArg == "enable";
5602 if (++anArgIter >= theArgNb)
5604 Message::SendFail ("Syntax error: option name is missing");
5608 TCollection_AsciiString aSubOp (theArgVec[anArgIter]);
5610 if (aLayerId == Graphic3d_ZLayerId_UNKNOWN)
5612 if (++anArgIter >= theArgNb)
5614 Message::SendFail ("Syntax error: id of Z layer is missing");
5618 aLayerId = Draw::Atoi (theArgVec[anArgIter]);
5621 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId);
5622 if (aSubOp == "depthtest"
5623 || aSubOp == "test")
5625 aSettings.SetEnableDepthTest (toEnable);
5627 else if (aSubOp == "depthwrite"
5628 || aSubOp == "write")
5630 aSettings.SetEnableDepthWrite (toEnable);
5632 else if (aSubOp == "depthclear"
5633 || aSubOp == "clear")
5635 aSettings.SetClearDepth (toEnable);
5637 else if (aSubOp == "depthoffset"
5638 || aSubOp == "offset")
5640 Graphic3d_PolygonOffset aParams;
5641 aParams.Mode = toEnable ? Aspect_POM_Fill : Aspect_POM_None;
5644 if (anArgIter + 2 >= theArgNb)
5646 Message::SendFail ("Syntax error: factor and units values for depth offset are missing");
5650 aParams.Factor = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
5651 aParams.Units = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter]));
5653 aSettings.SetPolygonOffset (aParams);
5655 else if (aSubOp == "positiveoffset"
5656 || aSubOp == "poffset")
5660 aSettings.SetDepthOffsetPositive();
5664 aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
5667 else if (aSubOp == "negativeoffset"
5668 || aSubOp == "noffset")
5672 aSettings.SetDepthOffsetNegative();
5676 aSettings.SetPolygonOffset(Graphic3d_PolygonOffset());
5679 else if (aSubOp == "textureenv")
5681 aSettings.SetEnvironmentTexture (toEnable);
5683 else if (aSubOp == "raytracing")
5685 aSettings.SetRaytracable (toEnable);
5688 aViewer->SetZLayerSettings (aLayerId, aSettings);
5692 Message::SendFail() << "Syntax error: unknown option " << theArgVec[anArgIter];
5700 // The interactive presentation of 2d layer item
5701 // for "vlayerline" command it provides a presentation of
5702 // line with user-defined linewidth, linetype and transparency.
5703 class V3d_LineItem : public AIS_InteractiveObject
5707 DEFINE_STANDARD_RTTI_INLINE(V3d_LineItem,AIS_InteractiveObject)
5710 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
5711 Standard_Real X2, Standard_Real Y2,
5712 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
5713 Standard_Real theWidth = 0.5,
5714 Standard_Real theTransp = 1.0);
5718 void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
5719 const Handle(Prs3d_Presentation)& thePresentation,
5720 const Standard_Integer theMode) Standard_OVERRIDE;
5722 void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
5723 const Standard_Integer /*aMode*/) Standard_OVERRIDE
5728 Standard_Real myX1, myY1, myX2, myY2;
5729 Aspect_TypeOfLine myType;
5730 Standard_Real myWidth;
5733 // default constructor for line item
5734 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
5735 Standard_Real X2, Standard_Real Y2,
5736 Aspect_TypeOfLine theType,
5737 Standard_Real theWidth,
5738 Standard_Real theTransp) :
5739 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2),
5740 myType(theType), myWidth(theWidth)
5742 SetTransparency (1-theTransp);
5746 void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
5747 const Handle(Prs3d_Presentation)& thePresentation,
5748 const Standard_Integer /*theMode*/)
5750 thePresentation->Clear();
5751 Quantity_Color aColor (Quantity_NOC_RED);
5752 Standard_Integer aWidth, aHeight;
5753 ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
5754 Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
5755 Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
5756 aPrim->AddVertex(myX1, aHeight-myY1, 0.);
5757 aPrim->AddVertex(myX2, aHeight-myY2, 0.);
5758 Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (aColor, (Aspect_TypeOfLine)myType, myWidth);
5759 aGroup->SetPrimitivesAspect (anAspect->Aspect());
5760 aGroup->AddPrimitiveArray (aPrim);
5763 //=============================================================================
5764 //function : VLayerLine
5765 //purpose : Draws line in the v3d view layer with given attributes: linetype,
5766 // : linewidth, transparency coefficient
5767 //============================================================================
5768 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
5770 // get the active view
5771 Handle(V3d_View) aView = ViewerTest::CurrentView();
5774 di << "Call vinit before!\n";
5779 di << "Use: " << argv[0];
5780 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
5781 di << " linetype : { 0 | 1 | 2 | 3 } \n";
5782 di << " 0 - solid \n";
5783 di << " 1 - dashed \n";
5784 di << " 2 - dot \n";
5785 di << " 3 - dashdot\n";
5786 di << " transparency : { 0.0 - 1.0 } \n";
5787 di << " 0.0 - transparent\n";
5788 di << " 1.0 - visible \n";
5792 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5793 // get the input params
5794 Standard_Real X1 = Draw::Atof(argv[1]);
5795 Standard_Real Y1 = Draw::Atof(argv[2]);
5796 Standard_Real X2 = Draw::Atof(argv[3]);
5797 Standard_Real Y2 = Draw::Atof(argv[4]);
5799 Standard_Real aWidth = 0.5;
5800 Standard_Real aTransparency = 1.0;
5804 aWidth = Draw::Atof(argv[5]);
5806 // select appropriate line type
5807 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
5809 && !ViewerTest::ParseLineType (argv[6], aLineType))
5811 Message::SendFail() << "Syntax error: unknown line type '" << argv[6] << "'";
5818 aTransparency = Draw::Atof(argv[7]);
5819 if (aTransparency < 0 || aTransparency > 1.0)
5820 aTransparency = 1.0;
5823 static Handle (V3d_LineItem) aLine;
5824 if (!aLine.IsNull())
5826 aContext->Erase (aLine, Standard_False);
5828 aLine = new V3d_LineItem (X1, Y1, X2, Y2,
5832 aContext->SetTransformPersistence (aLine, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
5833 aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD);
5834 aLine->SetToUpdate();
5835 aContext->Display (aLine, Standard_True);
5841 //==============================================================================
5844 //==============================================================================
5846 static int VGrid (Draw_Interpretor& /*theDI*/,
5847 Standard_Integer theArgNb,
5848 const char** theArgVec)
5850 Handle(V3d_View) aView = ViewerTest::CurrentView();
5851 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
5852 if (aView.IsNull() || aViewer.IsNull())
5854 Message::SendFail ("Error: no active viewer");
5858 Aspect_GridType aType = aViewer->GridType();
5859 Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
5860 Graphic3d_Vec2d aNewOriginXY, aNewStepXY, aNewSizeXY;
5861 Standard_Real aNewRotAngle = 0.0, aNewZOffset = 0.0;
5862 bool hasOrigin = false, hasStep = false, hasRotAngle = false, hasSize = false, hasZOffset = false;
5863 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
5864 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
5866 TCollection_AsciiString anArg (theArgVec[anArgIter]);
5868 if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
5872 else if (anArgIter + 1 < theArgNb
5873 && anArg == "-type")
5875 TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
5876 anArgNext.LowerCase();
5877 if (anArgNext == "r"
5878 || anArgNext == "rect"
5879 || anArgNext == "rectangular")
5881 aType = Aspect_GT_Rectangular;
5883 else if (anArgNext == "c"
5884 || anArgNext == "circ"
5885 || anArgNext == "circular")
5887 aType = Aspect_GT_Circular;
5891 Message::SendFail() << "Syntax error at '" << anArgNext << "'";
5895 else if (anArgIter + 1 < theArgNb
5896 && anArg == "-mode")
5898 TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
5899 anArgNext.LowerCase();
5900 if (anArgNext == "l"
5901 || anArgNext == "line"
5902 || anArgNext == "lines")
5904 aMode = Aspect_GDM_Lines;
5906 else if (anArgNext == "p"
5907 || anArgNext == "point"
5908 || anArgNext == "points")
5910 aMode = Aspect_GDM_Points;
5914 Message::SendFail() << "Syntax error at '" << anArgNext << "'";
5918 else if (anArgIter + 2 < theArgNb
5919 && (anArg == "-origin"
5920 || anArg == "-orig"))
5923 aNewOriginXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
5924 Draw::Atof (theArgVec[anArgIter + 2]));
5927 else if (anArgIter + 2 < theArgNb
5928 && anArg == "-step")
5931 aNewStepXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
5932 Draw::Atof (theArgVec[anArgIter + 2]));
5933 if (aNewStepXY.x() <= 0.0
5934 || aNewStepXY.y() <= 0.0)
5936 Message::SendFail() << "Syntax error: wrong step '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'";
5941 else if (anArgIter + 1 < theArgNb
5942 && (anArg == "-angle"
5943 || anArg == "-rotangle"
5944 || anArg == "-rotationangle"))
5947 aNewRotAngle = Draw::Atof (theArgVec[++anArgIter]);
5949 else if (anArgIter + 1 < theArgNb
5950 && (anArg == "-zoffset"
5954 aNewZOffset = Draw::Atof (theArgVec[++anArgIter]);
5956 else if (anArgIter + 1 < theArgNb
5957 && anArg == "-radius")
5961 aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter]), 0.0);
5962 if (aNewStepXY.x() <= 0.0)
5964 Message::SendFail() << "Syntax error: wrong size '" << theArgVec[anArgIter] << "'";
5968 else if (anArgIter + 2 < theArgNb
5969 && anArg == "-size")
5972 aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]),
5973 Draw::Atof (theArgVec[anArgIter + 2]));
5974 if (aNewStepXY.x() <= 0.0
5975 || aNewStepXY.y() <= 0.0)
5977 Message::SendFail() << "Syntax error: wrong size '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'";
5982 else if (anArg == "r"
5984 || anArg == "rectangular")
5986 aType = Aspect_GT_Rectangular;
5988 else if (anArg == "c"
5990 || anArg == "circular")
5992 aType = Aspect_GT_Circular;
5994 else if (anArg == "l"
5996 || anArg == "lines")
5998 aMode = Aspect_GDM_Lines;
6000 else if (anArg == "p"
6002 || anArg == "points")
6004 aMode = Aspect_GDM_Points;
6006 else if (anArgIter + 1 >= theArgNb
6009 aViewer->DeactivateGrid();
6014 Message::SendFail() << "Syntax error at '" << anArg << "'";
6019 if (aType == Aspect_GT_Rectangular)
6021 Graphic3d_Vec2d anOrigXY, aStepXY;
6022 Standard_Real aRotAngle = 0.0;
6023 aViewer->RectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle);
6026 anOrigXY = aNewOriginXY;
6030 aStepXY = aNewStepXY;
6034 aRotAngle = aNewRotAngle;
6036 aViewer->SetRectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle);
6037 if (hasSize || hasZOffset)
6039 Graphic3d_Vec3d aSize;
6040 aViewer->RectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z());
6043 aSize.x() = aNewSizeXY.x();
6044 aSize.y() = aNewSizeXY.y();
6048 aSize.z() = aNewZOffset;
6050 aViewer->SetRectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z());
6053 else if (aType == Aspect_GT_Circular)
6055 Graphic3d_Vec2d anOrigXY;
6056 Standard_Real aRadiusStep;
6057 Standard_Integer aDivisionNumber;
6058 Standard_Real aRotAngle = 0.0;
6059 aViewer->CircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle);
6062 anOrigXY = aNewOriginXY;
6066 aRadiusStep = aNewStepXY[0];
6067 aDivisionNumber = (int )aNewStepXY[1];
6068 if (aDivisionNumber < 1)
6070 Message::SendFail() << "Syntax error: invalid division number '" << aNewStepXY[1] << "'";
6076 aRotAngle = aNewRotAngle;
6079 aViewer->SetCircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle);
6080 if (hasSize || hasZOffset)
6082 Standard_Real aRadius = 0.0, aZOffset = 0.0;
6083 aViewer->CircularGridGraphicValues (aRadius, aZOffset);
6086 aRadius = aNewSizeXY.x();
6087 if (aNewSizeXY.y() != 0.0)
6089 Message::SendFail ("Syntax error: circular size should be specified as radius");
6095 aZOffset = aNewZOffset;
6097 aViewer->SetCircularGridGraphicValues (aRadius, aZOffset);
6100 aViewer->ActivateGrid (aType, aMode);
6104 //==============================================================================
6105 //function : VPriviledgedPlane
6107 //==============================================================================
6109 static int VPriviledgedPlane (Draw_Interpretor& theDI,
6110 Standard_Integer theArgNb,
6111 const char** theArgVec)
6113 if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10)
6115 Message::SendFail ("Error: wrong number of arguments! See usage:");
6116 theDI.PrintHelp (theArgVec[0]);
6120 // get the active viewer
6121 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
6122 if (aViewer.IsNull())
6124 Message::SendFail ("Error: no active viewer");
6130 gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane();
6131 const gp_Pnt& anOrig = aPriviledgedPlane.Location();
6132 const gp_Dir& aNorm = aPriviledgedPlane.Direction();
6133 const gp_Dir& aXDir = aPriviledgedPlane.XDirection();
6134 theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " "
6135 << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " "
6136 << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n";
6140 Standard_Integer anArgIdx = 1;
6141 Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]);
6142 Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]);
6143 Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]);
6144 Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]);
6145 Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]);
6146 Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]);
6148 gp_Ax3 aPriviledgedPlane;
6149 gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ);
6150 gp_Dir aNorm (aNormX, aNormY, aNormZ);
6153 Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]);
6154 Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]);
6155 Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]);
6156 gp_Dir aXDir (aXDirX, aXDirY, aXDirZ);
6157 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir);
6161 aPriviledgedPlane = gp_Ax3 (anOrig, aNorm);
6164 aViewer->SetPrivilegedPlane (aPriviledgedPlane);
6169 //==============================================================================
6170 //function : VConvert
6172 //==============================================================================
6174 static int VConvert (Draw_Interpretor& theDI,
6175 Standard_Integer theArgNb,
6176 const char** theArgVec)
6178 // get the active view
6179 Handle(V3d_View) aView = ViewerTest::CurrentView();
6182 Message::SendFail ("Error: no active viewer");
6186 enum { Model, Ray, View, Window, Grid } aMode = Model;
6188 // access coordinate arguments
6189 TColStd_SequenceOfReal aCoord;
6190 Standard_Integer anArgIdx = 1;
6191 for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx)
6193 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
6194 if (!anArg.IsRealValue())
6198 aCoord.Append (anArg.RealValue());
6201 // non-numeric argument too early
6202 if (aCoord.IsEmpty())
6204 Message::SendFail ("Error: wrong number of arguments! See usage:");
6205 theDI.PrintHelp (theArgVec[0]);
6209 // collect all other arguments and options
6210 for (; anArgIdx < theArgNb; ++anArgIdx)
6212 TCollection_AsciiString anArg (theArgVec[anArgIdx]);
6214 if (anArg == "window") aMode = Window;
6215 else if (anArg == "view") aMode = View;
6216 else if (anArg == "grid") aMode = Grid;
6217 else if (anArg == "ray") aMode = Ray;
6220 Message::SendFail() << "Error: wrong argument " << anArg << "! See usage:";
6221 theDI.PrintHelp (theArgVec[0]);
6226 // complete input checks
6227 if ((aCoord.Length() == 1 && theArgNb > 3) ||
6228 (aCoord.Length() == 2 && theArgNb > 4) ||
6229 (aCoord.Length() == 3 && theArgNb > 5))
6231 Message::SendFail ("Error: wrong number of arguments! See usage:");
6232 theDI.PrintHelp (theArgVec[0]);
6236 Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
6237 Standard_Integer aXYp[2] = {0, 0};
6239 // convert one-dimensional coordinate
6240 if (aCoord.Length() == 1)
6244 case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer)aCoord (1)); return 0;
6245 case Window : theDI << "Window Vp: " << aView->Convert (aCoord (1)); return 0;
6247 Message::SendFail ("Error: wrong arguments! See usage:");
6248 theDI.PrintHelp (theArgVec[0]);
6253 // convert 2D coordinates from projection or view reference space
6254 if (aCoord.Length() == 2)
6259 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
6260 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
6264 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]);
6265 theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n";
6269 aView->Convert (aCoord (1), aCoord (2), aXYp[0], aXYp[1]);
6270 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
6274 aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]);
6275 aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]);
6276 theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
6280 aView->ConvertWithProj ((Standard_Integer) aCoord (1),
6281 (Standard_Integer) aCoord (2),
6282 aXYZ[0], aXYZ[1], aXYZ[2],
6283 aXYZ[3], aXYZ[4], aXYZ[5]);
6284 theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n";
6288 Message::SendFail ("Error: wrong arguments! See usage:");
6289 theDI.PrintHelp (theArgVec[0]);
6294 // convert 3D coordinates from view reference space
6295 else if (aCoord.Length() == 3)
6300 aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]);
6301 theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n";
6305 aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]);
6306 theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n";
6310 Message::SendFail ("Error: wrong arguments! See usage:");
6311 theDI.PrintHelp (theArgVec[0]);
6319 //==============================================================================
6322 //==============================================================================
6324 static int VFps (Draw_Interpretor& theDI,
6325 Standard_Integer theArgNb,
6326 const char** theArgVec)
6328 // get the active view
6329 Handle(V3d_View) aView = ViewerTest::CurrentView();
6332 Message::SendFail ("Error: no active viewer");
6336 Standard_Integer aFramesNb = -1;
6337 Standard_Real aDuration = -1.0;
6338 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6340 TCollection_AsciiString anArg (theArgVec[anArgIter]);
6343 && anArgIter + 1 < theArgNb
6344 && (anArg == "-duration"
6346 || anArg == "-time"))
6348 aDuration = Draw::Atof (theArgVec[++anArgIter]);
6350 else if (aFramesNb < 0
6351 && anArg.IsIntegerValue())
6353 aFramesNb = anArg.IntegerValue();
6356 Message::SendFail() << "Syntax error at '" << anArg << "'";
6362 Message::SendFail() << "Syntax error at '" << anArg << "'";
6366 if (aFramesNb < 0 && aDuration < 0.0)
6371 // the time is meaningless for first call
6372 // due to async OpenGl rendering
6375 // redraw view in loop to estimate average values
6378 Standard_Integer aFrameIter = 1;
6379 for (;; ++aFrameIter)
6383 && aFrameIter >= aFramesNb)
6385 && aTimer.ElapsedTime() >= aDuration))
6392 const Standard_Real aTime = aTimer.ElapsedTime();
6393 aTimer.OSD_Chronometer::Show (aCpu);
6395 const Standard_Real aFpsAver = Standard_Real(aFrameIter) / aTime;
6396 const Standard_Real aCpuAver = aCpu / Standard_Real(aFrameIter);
6398 // return statistics
6399 theDI << "FPS: " << aFpsAver << "\n"
6400 << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
6402 // compute additional statistics in ray-tracing mode
6403 const Graphic3d_RenderingParams& aParams = aView->RenderingParams();
6404 if (aParams.Method == Graphic3d_RM_RAYTRACING)
6406 Graphic3d_Vec2i aWinSize (0, 0);
6407 aView->Window()->Size (aWinSize.x(), aWinSize.y());
6409 // 1 shadow ray and 1 secondary ray pew each bounce
6410 const Standard_Real aMRays = aWinSize.x() * aWinSize.y() * aFpsAver * aParams.RaytracingDepth * 2 / 1.0e6f;
6411 theDI << "MRays/sec (upper bound): " << aMRays << "\n";
6417 //! Auxiliary function for parsing glsl dump level argument.
6418 static Standard_Boolean parseGlslSourceFlag (Standard_CString theArg,
6419 OpenGl_ShaderProgramDumpLevel& theGlslDumpLevel)
6421 TCollection_AsciiString aTypeStr (theArg);
6422 aTypeStr.LowerCase();
6423 if (aTypeStr == "off"
6426 theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
6428 else if (aTypeStr == "short")
6430 theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Short;
6432 else if (aTypeStr == "full"
6435 theGlslDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
6439 return Standard_False;
6441 return Standard_True;
6444 //==============================================================================
6445 //function : VGlDebug
6447 //==============================================================================
6449 static int VGlDebug (Draw_Interpretor& theDI,
6450 Standard_Integer theArgNb,
6451 const char** theArgVec)
6453 Handle(OpenGl_GraphicDriver) aDriver;
6454 Handle(V3d_View) aView = ViewerTest::CurrentView();
6455 if (!aView.IsNull())
6457 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
6459 OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps;
6460 OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
6464 TCollection_AsciiString aDebActive, aSyncActive;
6471 Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS),
6472 "GL_ARB_debug_output");
6473 aDebActive = isActive ? " (active)" : " (inactive)";
6476 // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
6477 aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
6481 TCollection_AsciiString aGlslCodeDebugStatus = TCollection_AsciiString()
6482 + "glslSourceCode: "
6483 + (aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Off
6485 : aCaps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Short
6489 theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n"
6490 << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n"
6491 << "glslWarn: " << (aCaps->glslWarnings ? "1" : "0") << "\n"
6492 << aGlslCodeDebugStatus
6493 << "extraMsg: " << (aCaps->suppressExtraMsg ? "0" : "1") << "\n";
6497 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6499 Standard_CString anArg = theArgVec[anArgIter];
6500 TCollection_AsciiString anArgCase (anArg);
6501 anArgCase.LowerCase();
6502 Standard_Boolean toEnableDebug = Standard_True;
6503 if (anArgCase == "-glsl"
6504 || anArgCase == "-glslwarn"
6505 || anArgCase == "-glslwarns"
6506 || anArgCase == "-glslwarnings")
6508 Standard_Boolean toShowWarns = Standard_True;
6509 if (++anArgIter < theArgNb
6510 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShowWarns))
6514 aDefCaps->glslWarnings = toShowWarns;
6517 aCaps->glslWarnings = toShowWarns;
6520 else if (anArgCase == "-extra"
6521 || anArgCase == "-extramsg"
6522 || anArgCase == "-extramessages")
6524 Standard_Boolean toShow = Standard_True;
6525 if (++anArgIter < theArgNb
6526 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShow))
6530 aDefCaps->suppressExtraMsg = !toShow;
6533 aCaps->suppressExtraMsg = !toShow;
6536 else if (anArgCase == "-noextra"
6537 || anArgCase == "-noextramsg"
6538 || anArgCase == "-noextramessages")
6540 Standard_Boolean toSuppress = Standard_True;
6541 if (++anArgIter < theArgNb
6542 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSuppress))
6546 aDefCaps->suppressExtraMsg = toSuppress;
6549 aCaps->suppressExtraMsg = toSuppress;
6552 else if (anArgCase == "-sync")
6554 Standard_Boolean toSync = Standard_True;
6555 if (++anArgIter < theArgNb
6556 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSync))
6560 aDefCaps->contextSyncDebug = toSync;
6563 aDefCaps->contextDebug = Standard_True;
6566 else if (anArgCase == "-glslsourcecode"
6567 || anArgCase == "-glslcode")
6569 OpenGl_ShaderProgramDumpLevel aGslsDumpLevel = OpenGl_ShaderProgramDumpLevel_Full;
6570 if (++anArgIter < theArgNb
6571 && !parseGlslSourceFlag (theArgVec[anArgIter], aGslsDumpLevel))
6575 aDefCaps->glslDumpLevel = aGslsDumpLevel;
6578 aCaps->glslDumpLevel = aGslsDumpLevel;
6581 else if (anArgCase == "-debug")
6583 if (++anArgIter < theArgNb
6584 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
6588 aDefCaps->contextDebug = toEnableDebug;
6590 else if (ViewerTest::ParseOnOff (anArg, toEnableDebug)
6591 && (anArgIter + 1 == theArgNb))
6593 // simple alias to turn on almost everything
6594 aDefCaps->contextDebug = toEnableDebug;
6595 aDefCaps->contextSyncDebug = toEnableDebug;
6596 aDefCaps->glslWarnings = toEnableDebug;
6599 aDefCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
6601 aDefCaps->suppressExtraMsg = !toEnableDebug;
6604 aCaps->contextDebug = toEnableDebug;
6605 aCaps->contextSyncDebug = toEnableDebug;
6606 aCaps->glslWarnings = toEnableDebug;
6609 aCaps->glslDumpLevel = OpenGl_ShaderProgramDumpLevel_Off;
6611 aCaps->suppressExtraMsg = !toEnableDebug;
6616 Message::SendFail() << "Syntax error at '" << anArg << "'";
6624 //==============================================================================
6627 //==============================================================================
6629 static int VVbo (Draw_Interpretor& theDI,
6630 Standard_Integer theArgNb,
6631 const char** theArgVec)
6633 const Standard_Boolean toSet = (theArgNb > 1);
6634 const Standard_Boolean toUseVbo = toSet ? (Draw::Atoi (theArgVec[1]) == 0) : 1;
6637 ViewerTest_myDefaultCaps.vboDisable = toUseVbo;
6641 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
6642 if (aContextAIS.IsNull())
6646 Message::SendFail ("Error: no active viewer");
6650 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
6651 if (!aDriver.IsNull())
6655 theDI << (aDriver->Options().vboDisable ? "0" : "1") << "\n";
6659 aDriver->ChangeOptions().vboDisable = toUseVbo;
6666 //==============================================================================
6669 //==============================================================================
6671 static int VCaps (Draw_Interpretor& theDI,
6672 Standard_Integer theArgNb,
6673 const char** theArgVec)
6675 OpenGl_Caps* aCaps = &ViewerTest_myDefaultCaps;
6676 Handle(OpenGl_GraphicDriver) aDriver;
6677 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
6678 if (!aContext.IsNull())
6680 aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
6681 aCaps = &aDriver->ChangeOptions();
6686 theDI << "sRGB: " << (aCaps->sRGBDisable ? "0" : "1") << "\n";
6687 theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n";
6688 theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
6689 theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
6690 theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
6691 theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
6692 theDI << "VSync: " << aCaps->swapInterval << "\n";
6693 theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
6694 theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
6695 theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
6696 theDI << "NoExt:" << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
6697 theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
6698 theDI << "CompressTextures: " << (aCaps->compressedTexturesDisable ? "0" : "1") << "\n";
6702 ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
6703 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
6705 Standard_CString anArg = theArgVec[anArgIter];
6706 TCollection_AsciiString anArgCase (anArg);
6707 anArgCase.LowerCase();
6708 if (anUpdateTool.parseRedrawMode (anArg))
6712 else if (anArgCase == "-vsync"
6713 || anArgCase == "-swapinterval")
6715 Standard_Boolean toEnable = Standard_True;
6716 if (++anArgIter < theArgNb
6717 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6721 aCaps->swapInterval = toEnable;
6723 else if (anArgCase == "-ffp")
6725 Standard_Boolean toEnable = Standard_True;
6726 if (++anArgIter < theArgNb
6727 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6731 aCaps->ffpEnable = toEnable;
6733 else if (anArgCase == "-polygonmode")
6735 Standard_Boolean toEnable = Standard_True;
6736 if (++anArgIter < theArgNb
6737 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6741 aCaps->usePolygonMode = toEnable;
6743 else if (anArgCase == "-srgb")
6745 Standard_Boolean toEnable = Standard_True;
6746 if (++anArgIter < theArgNb
6747 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6751 aCaps->sRGBDisable = !toEnable;
6753 else if (anArgCase == "-compressedtextures")
6755 Standard_Boolean toEnable = Standard_True;
6756 if (++anArgIter < theArgNb
6757 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6761 aCaps->compressedTexturesDisable = !toEnable;
6763 else if (anArgCase == "-vbo")
6765 Standard_Boolean toEnable = Standard_True;
6766 if (++anArgIter < theArgNb
6767 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6771 aCaps->vboDisable = !toEnable;
6773 else if (anArgCase == "-sprite"
6774 || anArgCase == "-sprites")
6776 Standard_Boolean toEnable = Standard_True;
6777 if (++anArgIter < theArgNb
6778 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6782 aCaps->pntSpritesDisable = !toEnable;
6784 else if (anArgCase == "-softmode")
6786 Standard_Boolean toEnable = Standard_True;
6787 if (++anArgIter < theArgNb
6788 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6792 aCaps->contextNoAccel = toEnable;
6794 else if (anArgCase == "-winbuffer"
6795 || anArgCase == "-windowbuffer"
6796 || anArgCase == "-usewinbuffer"
6797 || anArgCase == "-usewindowbuffer"
6798 || anArgCase == "-usesystembuffer")
6800 Standard_Boolean toEnable = Standard_True;
6801 if (++anArgIter < theArgNb
6802 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6806 aCaps->useSystemBuffer = toEnable;
6808 else if (anArgCase == "-accel"
6809 || anArgCase == "-acceleration")
6811 Standard_Boolean toEnable = Standard_True;
6812 if (++anArgIter < theArgNb
6813 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6817 aCaps->contextNoAccel = !toEnable;
6819 else if (anArgCase == "-compat"
6820 || anArgCase == "-compatprofile"
6821 || anArgCase == "-compatible"
6822 || anArgCase == "-compatibleprofile")
6824 Standard_Boolean toEnable = Standard_True;
6825 if (++anArgIter < theArgNb
6826 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6830 aCaps->contextCompatible = toEnable;
6831 if (!aCaps->contextCompatible)
6833 aCaps->ffpEnable = Standard_False;
6836 else if (anArgCase == "-core"
6837 || anArgCase == "-coreprofile")
6839 Standard_Boolean toEnable = Standard_True;
6840 if (++anArgIter < theArgNb
6841 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6845 aCaps->contextCompatible = !toEnable;
6846 if (!aCaps->contextCompatible)
6848 aCaps->ffpEnable = Standard_False;
6851 else if (anArgCase == "-stereo"
6852 || anArgCase == "-quadbuffer")
6854 Standard_Boolean toEnable = Standard_True;
6855 if (++anArgIter < theArgNb
6856 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
6860 aCaps->contextStereo = toEnable;
6862 else if (anArgCase == "-noext"
6863 || anArgCase == "-noextensions"
6864 || anArgCase == "-noextension")
6866 Standard_Boolean toDisable = Standard_True;
6867 if (++anArgIter < theArgNb
6868 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
6872 aCaps->contextNoExtensions = toDisable;
6874 else if (anArgCase == "-maxversion"
6875 || anArgCase == "-upperversion"
6876 || anArgCase == "-limitversion")
6878 Standard_Integer aVer[2] = { -2, -1 };
6879 for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
6881 if (anArgIter + 1 < theArgNb)
6883 const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
6884 if (aStr.IsIntegerValue())
6886 aVer[aValIter] = aStr.IntegerValue();
6894 Message::SendFail() << "Syntax error at '" << anArgCase << "'";
6897 aCaps->contextMajorVersionUpper = aVer[0];
6898 aCaps->contextMinorVersionUpper = aVer[1];
6902 Message::SendFail() << "Error: unknown argument '" << anArg << "'";
6906 if (aCaps != &ViewerTest_myDefaultCaps)
6908 ViewerTest_myDefaultCaps = *aCaps;
6913 //==============================================================================
6914 //function : VMemGpu
6916 //==============================================================================
6918 static int VMemGpu (Draw_Interpretor& theDI,
6919 Standard_Integer theArgNb,
6920 const char** theArgVec)
6923 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
6924 if (aContextAIS.IsNull())
6926 Message::SendFail ("Error: no active viewer");
6930 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
6931 if (aDriver.IsNull())
6933 Message::SendFail ("Error: graphic driver not available");
6937 Standard_Size aFreeBytes = 0;
6938 TCollection_AsciiString anInfo;
6939 if (!aDriver->MemoryInfo (aFreeBytes, anInfo))
6941 Message::SendFail ("Error: information not available");
6945 if (theArgNb > 1 && *theArgVec[1] == 'f')
6947 theDI << Standard_Real (aFreeBytes);
6957 // ==============================================================================
6958 // function : VReadPixel
6960 // ==============================================================================
6961 static int VReadPixel (Draw_Interpretor& theDI,
6962 Standard_Integer theArgNb,
6963 const char** theArgVec)
6965 // get the active view
6966 Handle(V3d_View) aView = ViewerTest::CurrentView();
6969 Message::SendFail ("Error: no active viewer");
6972 else if (theArgNb < 3)
6974 Message::SendFail() << "Syntax error: wrong number of arguments.\n"
6975 << "Usage: " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]";
6979 Image_Format aFormat = Image_Format_RGBA;
6980 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
6982 Standard_Integer aWidth, aHeight;
6983 aView->Window()->Size (aWidth, aHeight);
6984 const Standard_Integer anX = Draw::Atoi (theArgVec[1]);
6985 const Standard_Integer anY = Draw::Atoi (theArgVec[2]);
6986 if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight)
6988 Message::SendFail() << "Error: pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")";
6992 bool toShowName = false, toShowHls = false, toShowHex = false, toShow_sRGB = false;
6993 for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
6995 TCollection_AsciiString aParam (theArgVec[anIter]);
6997 if (aParam == "-rgb"
6999 || aParam == "-srgb"
7000 || aParam == "srgb")
7002 aFormat = Image_Format_RGB;
7003 aBufferType = Graphic3d_BT_RGB;
7004 toShow_sRGB = aParam == "-srgb" || aParam == "srgb";
7006 else if (aParam == "-hls"
7009 aFormat = Image_Format_RGB;
7010 aBufferType = Graphic3d_BT_RGB;
7011 toShowHls = Standard_True;
7013 else if (aParam == "-rgbf"
7014 || aParam == "rgbf")
7016 aFormat = Image_Format_RGBF;
7017 aBufferType = Graphic3d_BT_RGB;
7019 else if (aParam == "-rgba"
7021 || aParam == "-srgba"
7022 || aParam == "srgba")
7024 aFormat = Image_Format_RGBA;
7025 aBufferType = Graphic3d_BT_RGBA;
7026 toShow_sRGB = aParam == "-srgba" || aParam == "srgba";
7028 else if (aParam == "-rgbaf"
7029 || aParam == "rgbaf")
7031 aFormat = Image_Format_RGBAF;
7032 aBufferType = Graphic3d_BT_RGBA;
7034 else if (aParam == "-depth"
7035 || aParam == "depth")
7037 aFormat = Image_Format_GrayF;
7038 aBufferType = Graphic3d_BT_Depth;
7040 else if (aParam == "-name"
7041 || aParam == "name")
7043 toShowName = Standard_True;
7045 else if (aParam == "-hex"
7048 toShowHex = Standard_True;
7052 Message::SendFail() << "Syntax error at '" << aParam << "'";
7057 Image_PixMap anImage;
7058 if (!anImage.InitTrash (aFormat, aWidth, aHeight))
7060 Message::SendFail ("Error: image allocation failed");
7063 else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType))
7065 Message::SendFail ("Error: image dump failed");
7069 // redirect possible warning messages that could have been added by ToPixMap
7070 // into the Tcl interpretor (via DefaultMessenger) to cout, so that they do not
7071 // contaminate result of the command
7072 Standard_CString aWarnLog = theDI.Result();
7073 if (aWarnLog != NULL && aWarnLog[0] != '\0')
7075 std::cout << aWarnLog << std::endl;
7079 Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY, true);
7082 if (aBufferType == Graphic3d_BT_RGBA)
7084 theDI << Quantity_Color::StringName (aColor.GetRGB().Name()) << " " << aColor.Alpha();
7088 theDI << Quantity_Color::StringName (aColor.GetRGB().Name());
7093 if (aBufferType == Graphic3d_BT_RGBA)
7095 theDI << Quantity_ColorRGBA::ColorToHex (aColor);
7099 theDI << Quantity_Color::ColorToHex (aColor.GetRGB());
7104 switch (aBufferType)
7107 case Graphic3d_BT_RGB:
7111 theDI << aColor.GetRGB().Hue() << " " << aColor.GetRGB().Light() << " " << aColor.GetRGB().Saturation();
7113 else if (toShow_sRGB)
7115 const Graphic3d_Vec4 aColor_sRGB = Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor);
7116 theDI << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b();
7120 theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue();
7124 case Graphic3d_BT_RGBA:
7126 const Graphic3d_Vec4 aVec4 = toShow_sRGB ? Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor) : (Graphic3d_Vec4 )aColor;
7127 theDI << aVec4.r() << " " << aVec4.g() << " " << aVec4.b() << " " << aVec4.a();
7130 case Graphic3d_BT_Depth:
7132 theDI << aColor.GetRGB().Red();
7141 //! Auxiliary presentation for an image plane.
7142 class ViewerTest_ImagePrs : public AIS_InteractiveObject
7145 //! Main constructor.
7146 ViewerTest_ImagePrs (const Handle(Image_PixMap)& theImage,
7147 const Standard_Real theWidth,
7148 const Standard_Real theHeight,
7149 const TCollection_AsciiString& theLabel)
7150 : myLabel (theLabel), myWidth (theWidth), myHeight(theHeight)
7154 myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
7156 myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
7157 const Handle(Graphic3d_AspectFillArea3d)& aFillAspect = myDrawer->ShadingAspect()->Aspect();
7158 Graphic3d_MaterialAspect aMat;
7159 aMat.SetMaterialType (Graphic3d_MATERIAL_PHYSIC);
7160 aMat.SetAmbientColor (Quantity_NOC_BLACK);
7161 aMat.SetDiffuseColor (Quantity_NOC_WHITE);
7162 aMat.SetSpecularColor (Quantity_NOC_BLACK);
7163 aMat.SetEmissiveColor (Quantity_NOC_BLACK);
7164 aFillAspect->SetFrontMaterial (aMat);
7165 aFillAspect->SetTextureMap (new Graphic3d_Texture2Dmanual (theImage));
7166 aFillAspect->SetTextureMapOn();
7169 Handle(Prs3d_TextAspect) aTextAspect = new Prs3d_TextAspect();
7170 aTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER);
7171 aTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
7172 myDrawer->SetTextAspect (aTextAspect);
7175 const gp_Dir aNorm (0.0, 0.0, 1.0);
7176 myTris = new Graphic3d_ArrayOfTriangles (4, 6, true, false, true);
7177 myTris->AddVertex (gp_Pnt(-myWidth * 0.5, -myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (0.0, 0.0));
7178 myTris->AddVertex (gp_Pnt( myWidth * 0.5, -myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (1.0, 0.0));
7179 myTris->AddVertex (gp_Pnt(-myWidth * 0.5, myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (0.0, 1.0));
7180 myTris->AddVertex (gp_Pnt( myWidth * 0.5, myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (1.0, 1.0));
7181 myTris->AddEdge (1);
7182 myTris->AddEdge (2);
7183 myTris->AddEdge (3);
7184 myTris->AddEdge (3);
7185 myTris->AddEdge (2);
7186 myTris->AddEdge (4);
7188 myRect = new Graphic3d_ArrayOfPolylines (4);
7189 myRect->AddVertex (myTris->Vertice (1));
7190 myRect->AddVertex (myTris->Vertice (3));
7191 myRect->AddVertex (myTris->Vertice (4));
7192 myRect->AddVertex (myTris->Vertice (2));
7196 //! Returns TRUE for accepted display modes.
7197 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0 || theMode == 1; }
7199 //! Compute presentation.
7200 virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& , const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE
7206 Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
7207 aGroup->AddPrimitiveArray (myTris);
7208 aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
7209 aGroup->AddPrimitiveArray (myRect);
7210 aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
7215 Prs3d_Text::Draw (thePrs->NewGroup(), myDrawer->TextAspect(), myLabel, gp_Pnt(0.0, 0.0, 0.0));
7216 Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
7217 aGroup->AddPrimitiveArray (myRect);
7218 aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
7224 //! Compute selection.
7225 virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, const Standard_Integer theMode) Standard_OVERRIDE
7229 Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 5);
7230 Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anEntityOwner);
7231 aSensitive->InitTriangulation (myTris->Attributes(), myTris->Indices(), TopLoc_Location());
7232 theSel->Add (aSensitive);
7237 Handle(Graphic3d_ArrayOfTriangles) myTris;
7238 Handle(Graphic3d_ArrayOfPolylines) myRect;
7239 TCollection_AsciiString myLabel;
7240 Standard_Real myWidth;
7241 Standard_Real myHeight;
7244 //==============================================================================
7245 //function : VDiffImage
7246 //purpose : The draw-command compares two images.
7247 //==============================================================================
7249 static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
7253 Message::SendFail ("Syntax error: not enough arguments");
7257 Standard_Integer anArgIter = 1;
7258 TCollection_AsciiString anImgPathRef (theArgVec[anArgIter++]);
7259 TCollection_AsciiString anImgPathNew (theArgVec[anArgIter++]);
7260 TCollection_AsciiString aDiffImagePath;
7261 Standard_Real aTolColor = -1.0;
7262 Standard_Integer toBlackWhite = -1;
7263 Standard_Integer isBorderFilterOn = -1;
7264 Standard_Boolean isOldSyntax = Standard_False;
7265 TCollection_AsciiString aViewName, aPrsNameRef, aPrsNameNew, aPrsNameDiff;
7266 for (; anArgIter < theArgNb; ++anArgIter)
7268 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7270 if (anArgIter + 1 < theArgNb
7271 && (anArg == "-toleranceofcolor"
7272 || anArg == "-tolerancecolor"
7273 || anArg == "-tolerance"
7274 || anArg == "-toler"))
7276 aTolColor = Atof (theArgVec[++anArgIter]);
7277 if (aTolColor < 0.0 || aTolColor > 1.0)
7279 Message::SendFail() << "Syntax error at '" << anArg << " " << theArgVec[anArgIter] << "'";
7283 else if (anArg == "-blackwhite")
7285 Standard_Boolean toEnable = Standard_True;
7286 if (anArgIter + 1 < theArgNb
7287 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
7291 toBlackWhite = toEnable ? 1 : 0;
7293 else if (anArg == "-borderfilter")
7295 Standard_Boolean toEnable = Standard_True;
7296 if (anArgIter + 1 < theArgNb
7297 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
7301 isBorderFilterOn = toEnable ? 1 : 0;
7303 else if (anArg == "-exitonclose")
7305 ViewerTest_EventManager::ToExitOnCloseView() = true;
7306 if (anArgIter + 1 < theArgNb
7307 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToExitOnCloseView()))
7312 else if (anArg == "-closeonescape"
7313 || anArg == "-closeonesc")
7315 ViewerTest_EventManager::ToCloseViewOnEscape() = true;
7316 if (anArgIter + 1 < theArgNb
7317 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
7322 else if (anArgIter + 3 < theArgNb
7323 && anArg == "-display")
7325 aViewName = theArgVec[++anArgIter];
7326 aPrsNameRef = theArgVec[++anArgIter];
7327 aPrsNameNew = theArgVec[++anArgIter];
7328 if (anArgIter + 1 < theArgNb
7329 && *theArgVec[anArgIter + 1] != '-')
7331 aPrsNameDiff = theArgVec[++anArgIter];
7334 else if (aTolColor < 0.0
7335 && anArg.IsRealValue())
7337 isOldSyntax = Standard_True;
7338 aTolColor = anArg.RealValue();
7339 if (aTolColor < 0.0 || aTolColor > 1.0)
7341 Message::SendFail() << "Syntax error at '" << anArg << " " << theArgVec[anArgIter] << "'";
7345 else if (isOldSyntax
7346 && toBlackWhite == -1
7347 && (anArg == "0" || anArg == "1"))
7349 toBlackWhite = anArg == "1" ? 1 : 0;
7351 else if (isOldSyntax
7352 && isBorderFilterOn == -1
7353 && (anArg == "0" || anArg == "1"))
7355 isBorderFilterOn = anArg == "1" ? 1 : 0;
7357 else if (aDiffImagePath.IsEmpty())
7359 aDiffImagePath = theArgVec[anArgIter];
7363 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
7368 Handle(Image_AlienPixMap) anImgRef = new Image_AlienPixMap();
7369 Handle(Image_AlienPixMap) anImgNew = new Image_AlienPixMap();
7370 if (!anImgRef->Load (anImgPathRef))
7372 Message::SendFail() << "Error: image file '" << anImgPathRef << "' cannot be read";
7375 if (!anImgNew->Load (anImgPathNew))
7377 Message::SendFail() << "Error: image file '" << anImgPathNew << "' cannot be read";
7381 // compare the images
7382 Image_Diff aComparer;
7383 Standard_Integer aDiffColorsNb = -1;
7384 if (aComparer.Init (anImgRef, anImgNew, toBlackWhite == 1))
7386 aComparer.SetColorTolerance (aTolColor >= 0.0 ? aTolColor : 0.0);
7387 aComparer.SetBorderFilterOn (isBorderFilterOn == 1);
7388 aDiffColorsNb = aComparer.Compare();
7389 theDI << aDiffColorsNb << "\n";
7392 // save image of difference
7393 Handle(Image_AlienPixMap) aDiff;
7394 if (aDiffColorsNb > 0
7395 && (!aDiffImagePath.IsEmpty() || !aPrsNameDiff.IsEmpty()))
7397 aDiff = new Image_AlienPixMap();
7398 if (!aDiff->InitTrash (Image_Format_Gray, anImgRef->SizeX(), anImgRef->SizeY()))
7400 Message::SendFail() << "Error: cannot allocate memory for diff image " << anImgRef->SizeX() << "x" << anImgRef->SizeY();
7403 aComparer.SaveDiffImage (*aDiff);
7404 if (!aDiffImagePath.IsEmpty()
7405 && !aDiff->Save (aDiffImagePath))
7407 Message::SendFail() << "Error: diff image file '" << aDiffImagePath << "' cannot be written";
7412 if (aViewName.IsEmpty())
7417 ViewerTest_Names aViewNames (aViewName);
7418 if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
7420 TCollection_AsciiString aCommand = TCollection_AsciiString ("vclose ") + aViewNames.GetViewName();
7421 theDI.Eval (aCommand.ToCString());
7424 Standard_Integer aPxLeft = 0;
7425 Standard_Integer aPxTop = 0;
7426 Standard_Integer aWinSizeX = int(anImgRef->SizeX() * 2);
7427 Standard_Integer aWinSizeY = !aDiff.IsNull() && !aPrsNameDiff.IsEmpty()
7428 ? int(anImgRef->SizeY() * 2)
7429 : int(anImgRef->SizeY());
7430 TCollection_AsciiString aDisplayName;
7431 TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aWinSizeX, aWinSizeY,
7432 aViewName, aDisplayName);
7434 Standard_Real aRatio = anImgRef->Ratio();
7435 Standard_Real aSizeX = 1.0;
7436 Standard_Real aSizeY = aSizeX / aRatio;
7438 OSD_Path aPath (anImgPathRef);
7439 TCollection_AsciiString aLabelRef;
7440 if (!aPath.Name().IsEmpty())
7442 aLabelRef = aPath.Name() + aPath.Extension();
7444 aLabelRef += TCollection_AsciiString() + "\n" + int(anImgRef->SizeX()) + "x" + int(anImgRef->SizeY());
7446 Handle(ViewerTest_ImagePrs) anImgRefPrs = new ViewerTest_ImagePrs (anImgRef, aSizeX, aSizeY, aLabelRef);
7448 aTrsfRef.SetTranslationPart (gp_Vec (-aSizeX * 0.5, 0.0, 0.0));
7449 anImgRefPrs->SetLocalTransformation (aTrsfRef);
7450 ViewerTest::Display (aPrsNameRef, anImgRefPrs, false, true);
7453 OSD_Path aPath (anImgPathNew);
7454 TCollection_AsciiString aLabelNew;
7455 if (!aPath.Name().IsEmpty())
7457 aLabelNew = aPath.Name() + aPath.Extension();
7459 aLabelNew += TCollection_AsciiString() + "\n" + int(anImgNew->SizeX()) + "x" + int(anImgNew->SizeY());
7461 Handle(ViewerTest_ImagePrs) anImgNewPrs = new ViewerTest_ImagePrs (anImgNew, aSizeX, aSizeY, aLabelNew);
7463 aTrsfRef.SetTranslationPart (gp_Vec (aSizeX * 0.5, 0.0, 0.0));
7464 anImgNewPrs->SetLocalTransformation (aTrsfRef);
7465 ViewerTest::Display (aPrsNameNew, anImgNewPrs, false, true);
7467 Handle(ViewerTest_ImagePrs) anImgDiffPrs;
7468 if (!aDiff.IsNull())
7470 anImgDiffPrs = new ViewerTest_ImagePrs (aDiff, aSizeX, aSizeY, TCollection_AsciiString() + "Difference: " + aDiffColorsNb + " pixels");
7472 aTrsfDiff.SetTranslationPart (gp_Vec (0.0, -aSizeY, 0.0));
7473 anImgDiffPrs->SetLocalTransformation (aTrsfDiff);
7475 if (!aPrsNameDiff.IsEmpty())
7477 ViewerTest::Display (aPrsNameDiff, anImgDiffPrs, false, true);
7479 ViewerTest::CurrentView()->SetProj (V3d_Zpos);
7480 ViewerTest::CurrentView()->FitAll();
7484 //=======================================================================
7485 //function : VSelect
7486 //purpose : Emulates different types of selection by mouse:
7487 // 1) single click selection
7488 // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)
7489 // 3) selection with polygon having corners at
7490 // pixel positions (x1,y1),...,(xn,yn)
7491 // 4) any of these selections with shift button pressed
7492 //=======================================================================
7493 static Standard_Integer VSelect (Draw_Interpretor& ,
7494 Standard_Integer theNbArgs,
7495 const char** theArgVec)
7497 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
7500 Message::SendFail ("Error: no active viewer");
7504 NCollection_Sequence<Graphic3d_Vec2i> aPnts;
7505 bool isShiftSelection = false, toAllowOverlap = false;
7506 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
7508 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7510 if (anArg == "-allowoverlap")
7512 toAllowOverlap = true;
7513 if (anArgIter + 1 < theNbArgs
7514 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toAllowOverlap))
7519 else if (anArgIter + 1 < theNbArgs
7520 && anArg.IsIntegerValue()
7521 && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue())
7523 const TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
7524 aPnts.Append (Graphic3d_Vec2i (anArg.IntegerValue(), anArgNext.IntegerValue()));
7526 else if (anArgIter + 1 == theNbArgs
7527 && anArg.IsIntegerValue())
7529 isShiftSelection = anArg.IntegerValue() == 1;
7533 Message::SendFail() << "Syntax error at '" << anArg << "'";
7540 aCtx->MainSelector()->AllowOverlapDetection (toAllowOverlap);
7543 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
7544 if (aPnts.IsEmpty())
7546 if (isShiftSelection)
7548 aCtx->ShiftSelect (false);
7552 aCtx->Select (false);
7554 aCtx->CurrentViewer()->Invalidate();
7556 else if (aPnts.Length() == 2)
7559 && aPnts.First().y() < aPnts.Last().y())
7561 std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast());
7563 else if (!toAllowOverlap
7564 && aPnts.First().y() > aPnts.Last().y())
7566 std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast());
7568 aCurrentEventManager->SelectInViewer (aPnts, isShiftSelection);
7572 aCurrentEventManager->SelectInViewer (aPnts, isShiftSelection);
7574 aCurrentEventManager->FlushViewEvents (aCtx, ViewerTest::CurrentView(), true);
7578 //=======================================================================
7579 //function : VMoveTo
7580 //purpose : Emulates cursor movement to defined pixel position
7581 //=======================================================================
7582 static Standard_Integer VMoveTo (Draw_Interpretor& theDI,
7583 Standard_Integer theNbArgs,
7584 const char** theArgVec)
7586 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
7587 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
7588 if (aContext.IsNull())
7590 Message::SendFail ("Error: no active viewer");
7594 Graphic3d_Vec2i aMousePos (IntegerLast(), IntegerLast());
7595 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
7597 TCollection_AsciiString anArgStr (theArgVec[anArgIter]);
7598 anArgStr.LowerCase();
7599 if (anArgStr == "-reset"
7600 || anArgStr == "-clear")
7602 if (anArgIter + 1 < theNbArgs)
7604 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter + 1] << "'";
7608 const Standard_Boolean toEchoGrid = aContext->CurrentViewer()->Grid()->IsActive()
7609 && aContext->CurrentViewer()->GridEcho();
7612 aContext->CurrentViewer()->HideGridEcho (aView);
7614 if (aContext->ClearDetected() || toEchoGrid)
7616 aContext->CurrentViewer()->RedrawImmediate();
7620 else if (aMousePos.x() == IntegerLast()
7621 && anArgStr.IsIntegerValue())
7623 aMousePos.x() = anArgStr.IntegerValue();
7625 else if (aMousePos.y() == IntegerLast()
7626 && anArgStr.IsIntegerValue())
7628 aMousePos.y() = anArgStr.IntegerValue();
7632 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
7637 if (aMousePos.x() == IntegerLast()
7638 || aMousePos.y() == IntegerLast())
7640 Message::SendFail ("Syntax error: wrong number of arguments");
7644 ViewerTest::CurrentEventManager()->ResetPreviousMoveTo();
7645 ViewerTest::CurrentEventManager()->UpdateMousePosition (aMousePos, Aspect_VKeyMouse_NONE, Aspect_VKeyFlags_NONE, false);
7646 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
7648 gp_Pnt aTopPnt (RealLast(), RealLast(), RealLast());
7649 const Handle(SelectMgr_EntityOwner)& aDetOwner = aContext->DetectedOwner();
7650 for (Standard_Integer aDetIter = 1; aDetIter <= aContext->MainSelector()->NbPicked(); ++aDetIter)
7652 if (aContext->MainSelector()->Picked (aDetIter) == aDetOwner)
7654 aTopPnt = aContext->MainSelector()->PickedPoint (aDetIter);
7658 theDI << aTopPnt.X() << " " << aTopPnt.Y() << " " << aTopPnt.Z();
7664 //! Global map storing all animations registered in ViewerTest.
7665 static NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)> ViewerTest_AnimationTimelineMap;
7667 //! The animation calling the Draw Harness command.
7668 class ViewerTest_AnimationProc : public AIS_Animation
7672 //! Main constructor.
7673 ViewerTest_AnimationProc (const TCollection_AsciiString& theAnimationName,
7674 Draw_Interpretor* theDI,
7675 const TCollection_AsciiString& theCommand)
7676 : AIS_Animation (theAnimationName),
7678 myCommand (theCommand)
7685 //! Evaluate the command.
7686 virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE
7688 TCollection_AsciiString aCmd = myCommand;
7689 replace (aCmd, "%pts", TCollection_AsciiString(theProgress.Pts));
7690 replace (aCmd, "%localpts", TCollection_AsciiString(theProgress.LocalPts));
7691 replace (aCmd, "%ptslocal", TCollection_AsciiString(theProgress.LocalPts));
7692 replace (aCmd, "%normalized", TCollection_AsciiString(theProgress.LocalNormalized));
7693 replace (aCmd, "%localnormalized", TCollection_AsciiString(theProgress.LocalNormalized));
7694 myDrawInter->Eval (aCmd.ToCString());
7697 //! Find the keyword in the command and replace it with value.
7698 //! @return the position of the keyword to pass value
7699 void replace (TCollection_AsciiString& theCmd,
7700 const TCollection_AsciiString& theKey,
7701 const TCollection_AsciiString& theVal)
7703 TCollection_AsciiString aCmd (theCmd);
7705 const Standard_Integer aPos = aCmd.Search (theKey);
7711 TCollection_AsciiString aPart1, aPart2;
7712 Standard_Integer aPart1To = aPos - 1;
7714 && aPart1To <= theCmd.Length())
7716 aPart1 = theCmd.SubString (1, aPart1To);
7719 Standard_Integer aPart2From = aPos + theKey.Length();
7721 && aPart2From <= theCmd.Length())
7723 aPart2 = theCmd.SubString (aPart2From, theCmd.Length());
7726 theCmd = aPart1 + theVal + aPart2;
7731 Draw_Interpretor* myDrawInter;
7732 TCollection_AsciiString myCommand;
7736 //! Replace the animation with the new one.
7737 static void replaceAnimation (const Handle(AIS_Animation)& theParentAnimation,
7738 Handle(AIS_Animation)& theAnimation,
7739 const Handle(AIS_Animation)& theAnimationNew)
7741 theAnimationNew->CopyFrom (theAnimation);
7742 if (!theParentAnimation.IsNull())
7744 theParentAnimation->Replace (theAnimation, theAnimationNew);
7748 ViewerTest_AnimationTimelineMap.UnBind (theAnimationNew->Name());
7749 ViewerTest_AnimationTimelineMap.Bind (theAnimationNew->Name(), theAnimationNew);
7751 theAnimation = theAnimationNew;
7754 //! Parse the point.
7755 static Standard_Boolean parseXYZ (const char** theArgVec, gp_XYZ& thePnt)
7757 const TCollection_AsciiString anXYZ[3] = { theArgVec[0], theArgVec[1], theArgVec[2] };
7758 if (!anXYZ[0].IsRealValue()
7759 || !anXYZ[1].IsRealValue()
7760 || !anXYZ[2].IsRealValue())
7762 return Standard_False;
7765 thePnt.SetCoord (anXYZ[0].RealValue(), anXYZ[1].RealValue(), anXYZ[2].RealValue());
7766 return Standard_True;
7769 //! Parse the quaternion.
7770 static Standard_Boolean parseQuaternion (const char** theArgVec, gp_Quaternion& theQRot)
7772 const TCollection_AsciiString anXYZW[4] = {theArgVec[0], theArgVec[1], theArgVec[2], theArgVec[3]};
7773 if (!anXYZW[0].IsRealValue()
7774 || !anXYZW[1].IsRealValue()
7775 || !anXYZW[2].IsRealValue()
7776 || !anXYZW[3].IsRealValue())
7778 return Standard_False;
7781 theQRot.Set (anXYZW[0].RealValue(), anXYZW[1].RealValue(), anXYZW[2].RealValue(), anXYZW[3].RealValue());
7782 return Standard_True;
7785 //! Auxiliary class for flipping image upside-down.
7790 //! Empty constructor.
7791 ImageFlipper() : myTmp (NCollection_BaseAllocator::CommonBaseAllocator()) {}
7793 //! Perform flipping.
7794 Standard_Boolean FlipY (Image_PixMap& theImage)
7796 if (theImage.IsEmpty()
7797 || theImage.SizeX() == 0
7798 || theImage.SizeY() == 0)
7800 return Standard_False;
7803 const Standard_Size aRowSize = theImage.SizeRowBytes();
7804 if (myTmp.Size() < aRowSize
7805 && !myTmp.Allocate (aRowSize))
7807 return Standard_False;
7810 // for odd height middle row should be left as is
7811 Standard_Size aNbRowsHalf = theImage.SizeY() / 2;
7812 for (Standard_Size aRowT = 0, aRowB = theImage.SizeY() - 1; aRowT < aNbRowsHalf; ++aRowT, --aRowB)
7814 Standard_Byte* aTop = theImage.ChangeRow (aRowT);
7815 Standard_Byte* aBot = theImage.ChangeRow (aRowB);
7816 memcpy (myTmp.ChangeData(), aTop, aRowSize);
7817 memcpy (aTop, aBot, aRowSize);
7818 memcpy (aBot, myTmp.Data(), aRowSize);
7820 return Standard_True;
7824 NCollection_Buffer myTmp;
7829 //=================================================================================================
7830 //function : VViewParams
7831 //purpose : Gets or sets AIS View characteristics
7832 //=================================================================================================
7833 static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
7835 Handle(V3d_View) aView = ViewerTest::CurrentView();
7838 Message::SendFail ("Error: no active viewer");
7842 Standard_Boolean toSetProj = Standard_False;
7843 Standard_Boolean toSetUp = Standard_False;
7844 Standard_Boolean toSetAt = Standard_False;
7845 Standard_Boolean toSetEye = Standard_False;
7846 Standard_Boolean toSetScale = Standard_False;
7847 Standard_Boolean toSetSize = Standard_False;
7848 Standard_Boolean toSetCenter2d = Standard_False;
7849 Standard_Real aViewScale = aView->Scale();
7850 Standard_Real aViewSize = 1.0;
7851 Graphic3d_Vec2i aCenter2d;
7852 gp_XYZ aViewProj, aViewUp, aViewAt, aViewEye;
7853 aView->Proj (aViewProj.ChangeCoord (1), aViewProj.ChangeCoord (2), aViewProj.ChangeCoord (3));
7854 aView->Up (aViewUp .ChangeCoord (1), aViewUp .ChangeCoord (2), aViewUp .ChangeCoord (3));
7855 aView->At (aViewAt .ChangeCoord (1), aViewAt .ChangeCoord (2), aViewAt .ChangeCoord (3));
7856 aView->Eye (aViewEye .ChangeCoord (1), aViewEye .ChangeCoord (2), aViewEye .ChangeCoord (3));
7859 // print all of the available view parameters
7863 "Proj: %12g %12g %12g\n"
7864 "Up: %12g %12g %12g\n"
7865 "At: %12g %12g %12g\n"
7866 "Eye: %12g %12g %12g\n",
7868 aViewProj.X(), aViewProj.Y(), aViewProj.Z(),
7869 aViewUp.X(), aViewUp.Y(), aViewUp.Z(),
7870 aViewAt.X(), aViewAt.Y(), aViewAt.Z(),
7871 aViewEye.X(), aViewEye.Y(), aViewEye.Z());
7876 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
7877 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
7879 TCollection_AsciiString anArg (theArgVec[anArgIter]);
7881 if (anUpdateTool.parseRedrawMode (anArg))
7885 else if (anArg == "-cmd"
7886 || anArg == "-command"
7887 || anArg == "-args")
7896 aViewProj.X(), aViewProj.Y(), aViewProj.Z(),
7897 aViewUp.X(), aViewUp.Y(), aViewUp.Z(),
7898 aViewAt.X(), aViewAt.Y(), aViewAt.Z());
7901 else if (anArg == "-scale"
7902 || anArg == "-size")
7904 if (anArgIter + 1 < theArgsNb
7905 && *theArgVec[anArgIter + 1] != '-')
7907 const TCollection_AsciiString aValueArg (theArgVec[anArgIter + 1]);
7908 if (aValueArg.IsRealValue())
7911 if (anArg == "-scale")
7913 toSetScale = Standard_True;
7914 aViewScale = aValueArg.RealValue();
7916 else if (anArg == "-size")
7918 toSetSize = Standard_True;
7919 aViewSize = aValueArg.RealValue();
7924 if (anArg == "-scale")
7926 theDi << "Scale: " << aView->Scale() << "\n";
7928 else if (anArg == "-size")
7930 Graphic3d_Vec2d aSizeXY;
7931 aView->Size (aSizeXY.x(), aSizeXY.y());
7932 theDi << "Size: " << aSizeXY.x() << " " << aSizeXY.y() << "\n";
7935 else if (anArg == "-eye"
7938 || anArg == "-proj")
7940 if (anArgIter + 3 < theArgsNb)
7943 if (parseXYZ (theArgVec + anArgIter + 1, anXYZ))
7946 if (anArg == "-eye")
7948 toSetEye = Standard_True;
7951 else if (anArg == "-at")
7953 toSetAt = Standard_True;
7956 else if (anArg == "-up")
7958 toSetUp = Standard_True;
7961 else if (anArg == "-proj")
7963 toSetProj = Standard_True;
7970 if (anArg == "-eye")
7972 theDi << "Eye: " << aViewEye.X() << " " << aViewEye.Y() << " " << aViewEye.Z() << "\n";
7974 else if (anArg == "-at")
7976 theDi << "At: " << aViewAt.X() << " " << aViewAt.Y() << " " << aViewAt.Z() << "\n";
7978 else if (anArg == "-up")
7980 theDi << "Up: " << aViewUp.X() << " " << aViewUp.Y() << " " << aViewUp.Z() << "\n";
7982 else if (anArg == "-proj")
7984 theDi << "Proj: " << aViewProj.X() << " " << aViewProj.Y() << " " << aViewProj.Z() << "\n";
7987 else if (anArg == "-center")
7989 if (anArgIter + 2 < theArgsNb)
7991 const TCollection_AsciiString anX (theArgVec[anArgIter + 1]);
7992 const TCollection_AsciiString anY (theArgVec[anArgIter + 2]);
7993 if (anX.IsIntegerValue()
7994 && anY.IsIntegerValue())
7996 toSetCenter2d = Standard_True;
7997 aCenter2d = Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue());
8003 Message::SendFail() << "Syntax error at '" << anArg << "'";
8008 // change view parameters in proper order
8011 aView->SetScale (aViewScale);
8015 aView->SetSize (aViewSize);
8019 aView->SetEye (aViewEye.X(), aViewEye.Y(), aViewEye.Z());
8023 aView->SetAt (aViewAt.X(), aViewAt.Y(), aViewAt.Z());
8027 aView->SetProj (aViewProj.X(), aViewProj.Y(), aViewProj.Z());
8031 aView->SetUp (aViewUp.X(), aViewUp.Y(), aViewUp.Z());
8035 aView->SetCenter (aCenter2d.x(), aCenter2d.y());
8041 //==============================================================================
8042 //function : V2DMode
8044 //==============================================================================
8045 static Standard_Integer V2DMode (Draw_Interpretor&, Standard_Integer theArgsNb, const char** theArgVec)
8047 bool is2dMode = true;
8048 Handle(ViewerTest_V3dView) aV3dView = Handle(ViewerTest_V3dView)::DownCast (ViewerTest::CurrentView());
8049 if (aV3dView.IsNull())
8051 Message::SendFail ("Error: no active viewer");
8054 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
8056 const TCollection_AsciiString anArg = theArgVec[anArgIt];
8057 TCollection_AsciiString anArgCase = anArg;
8058 anArgCase.LowerCase();
8059 if (anArgIt + 1 < theArgsNb
8060 && anArgCase == "-name")
8062 ViewerTest_Names aViewNames (theArgVec[++anArgIt]);
8063 TCollection_AsciiString aViewName = aViewNames.GetViewName();
8064 if (!ViewerTest_myViews.IsBound1 (aViewName))
8066 Message::SendFail() << "Syntax error: unknown view '" << theArgVec[anArgIt - 1] << "'";
8069 aV3dView = Handle(ViewerTest_V3dView)::DownCast (ViewerTest_myViews.Find1 (aViewName));
8071 else if (anArgCase == "-mode")
8073 if (anArgIt + 1 < theArgsNb
8074 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], is2dMode))
8079 else if (ViewerTest::ParseOnOff (theArgVec[anArgIt], is2dMode))
8085 Message::SendFail() << "Syntax error: unknown argument " << anArg;
8090 aV3dView->SetView2DMode (is2dMode);
8094 //==============================================================================
8095 //function : VAnimation
8097 //==============================================================================
8098 static Standard_Integer VAnimation (Draw_Interpretor& theDI,
8099 Standard_Integer theArgNb,
8100 const char** theArgVec)
8102 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
8105 for (NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)>::Iterator
8106 anAnimIter (ViewerTest_AnimationTimelineMap); anAnimIter.More(); anAnimIter.Next())
8108 theDI << anAnimIter.Key() << " " << anAnimIter.Value()->Duration() << " sec\n";
8114 Message::SendFail ("Error: no active viewer");
8118 Standard_Integer anArgIter = 1;
8119 TCollection_AsciiString aNameArg (theArgVec[anArgIter++]);
8120 if (aNameArg.IsEmpty())
8122 Message::SendFail ("Syntax error: animation name is not defined");
8126 TCollection_AsciiString aNameArgLower = aNameArg;
8127 aNameArgLower.LowerCase();
8128 if (aNameArgLower == "-reset"
8129 || aNameArgLower == "-clear")
8131 ViewerTest_AnimationTimelineMap.Clear();
8134 else if (aNameArg.Value (1) == '-')
8136 Message::SendFail() << "Syntax error: invalid animation name '" << aNameArg << "'";
8140 const char* aNameSplitter = "/";
8141 Standard_Integer aSplitPos = aNameArg.Search (aNameSplitter);
8142 if (aSplitPos == -1)
8144 aNameSplitter = ".";
8145 aSplitPos = aNameArg.Search (aNameSplitter);
8148 // find existing or create a new animation by specified name within syntax "parent.child".
8149 Handle(AIS_Animation) aRootAnimation, aParentAnimation, anAnimation;
8150 for (; !aNameArg.IsEmpty();)
8152 TCollection_AsciiString aNameParent;
8153 if (aSplitPos != -1)
8155 if (aSplitPos == aNameArg.Length())
8157 Message::SendFail ("Syntax error: animation name is not defined");
8161 aNameParent = aNameArg.SubString ( 1, aSplitPos - 1);
8162 aNameArg = aNameArg.SubString (aSplitPos + 1, aNameArg.Length());
8164 aSplitPos = aNameArg.Search (aNameSplitter);
8168 aNameParent = aNameArg;
8172 if (anAnimation.IsNull())
8174 if (!ViewerTest_AnimationTimelineMap.Find (aNameParent, anAnimation))
8176 anAnimation = new AIS_Animation (aNameParent);
8177 ViewerTest_AnimationTimelineMap.Bind (aNameParent, anAnimation);
8179 aRootAnimation = anAnimation;
8183 aParentAnimation = anAnimation;
8184 anAnimation = aParentAnimation->Find (aNameParent);
8185 if (anAnimation.IsNull())
8187 anAnimation = new AIS_Animation (aNameParent);
8188 aParentAnimation->Add (anAnimation);
8193 if (anArgIter >= theArgNb)
8195 // just print the list of children
8196 for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anAnimIter (anAnimation->Children()); anAnimIter.More(); anAnimIter.Next())
8198 theDI << anAnimIter.Value()->Name() << " " << anAnimIter.Value()->Duration() << " sec\n";
8203 // animation parameters
8204 Standard_Boolean toPlay = Standard_False;
8205 Standard_Real aPlaySpeed = 1.0;
8206 Standard_Real aPlayStartTime = anAnimation->StartPts();
8207 Standard_Real aPlayDuration = anAnimation->Duration();
8208 Standard_Boolean isFreeCamera = Standard_False;
8209 Standard_Boolean isLockLoop = Standard_False;
8211 // video recording parameters
8212 TCollection_AsciiString aRecFile;
8213 Image_VideoParams aRecParams;
8215 Handle(V3d_View) aView = ViewerTest::CurrentView();
8216 for (; anArgIter < theArgNb; ++anArgIter)
8218 TCollection_AsciiString anArg (theArgVec[anArgIter]);
8221 if (anArg == "-reset"
8222 || anArg == "-clear")
8224 anAnimation->Clear();
8226 else if (anArg == "-remove"
8228 || anArg == "-delete")
8230 if (!aParentAnimation.IsNull())
8232 ViewerTest_AnimationTimelineMap.UnBind (anAnimation->Name());
8236 aParentAnimation->Remove (anAnimation);
8240 else if (anArg == "-play")
8242 toPlay = Standard_True;
8243 if (++anArgIter < theArgNb)
8245 if (*theArgVec[anArgIter] == '-')
8250 aPlayStartTime = Draw::Atof (theArgVec[anArgIter]);
8252 if (++anArgIter < theArgNb)
8254 if (*theArgVec[anArgIter] == '-')
8259 aPlayDuration = Draw::Atof (theArgVec[anArgIter]);
8263 else if (anArg == "-resume")
8265 toPlay = Standard_True;
8266 aPlayStartTime = anAnimation->ElapsedTime();
8267 if (++anArgIter < theArgNb)
8269 if (*theArgVec[anArgIter] == '-')
8275 aPlayDuration = Draw::Atof (theArgVec[anArgIter]);
8278 else if (anArg == "-playspeed"
8279 || anArg == "-speed")
8281 if (++anArgIter >= theArgNb)
8283 Message::SendFail() << "Syntax error at " << anArg << "";
8286 aPlaySpeed = Draw::Atof (theArgVec[anArgIter]);
8288 else if (anArg == "-lock"
8289 || anArg == "-lockloop"
8290 || anArg == "-playlockloop")
8292 isLockLoop = Standard_True;
8294 else if (anArg == "-freecamera"
8295 || anArg == "-playfreecamera"
8296 || anArg == "-freelook")
8298 isFreeCamera = Standard_True;
8300 // video recodring options
8301 else if (anArg == "-rec"
8302 || anArg == "-record")
8304 if (++anArgIter >= theArgNb)
8306 Message::SendFail() << "Syntax error at " << anArg;
8310 aRecFile = theArgVec[anArgIter];
8311 if (aRecParams.FpsNum <= 0)
8313 aRecParams.FpsNum = 24;
8316 if (anArgIter + 2 < theArgNb
8317 && *theArgVec[anArgIter + 1] != '-'
8318 && *theArgVec[anArgIter + 2] != '-')
8320 TCollection_AsciiString aWidthArg (theArgVec[anArgIter + 1]);
8321 TCollection_AsciiString aHeightArg (theArgVec[anArgIter + 2]);
8322 if (aWidthArg .IsIntegerValue()
8323 && aHeightArg.IsIntegerValue())
8325 aRecParams.Width = aWidthArg .IntegerValue();
8326 aRecParams.Height = aHeightArg.IntegerValue();
8331 else if (anArg == "-fps")
8333 if (++anArgIter >= theArgNb)
8335 Message::SendFail() << "Syntax error at " << anArg;
8339 TCollection_AsciiString aFpsArg (theArgVec[anArgIter]);
8340 Standard_Integer aSplitIndex = aFpsArg.FirstLocationInSet ("/", 1, aFpsArg.Length());
8341 if (aSplitIndex == 0)
8343 aRecParams.FpsNum = aFpsArg.IntegerValue();
8347 const TCollection_AsciiString aDenStr = aFpsArg.Split (aSplitIndex);
8348 aFpsArg.Split (aFpsArg.Length() - 1);
8349 const TCollection_AsciiString aNumStr = aFpsArg;
8350 aRecParams.FpsNum = aNumStr.IntegerValue();
8351 aRecParams.FpsDen = aDenStr.IntegerValue();
8352 if (aRecParams.FpsDen < 1)
8354 Message::SendFail() << "Syntax error at " << anArg;
8359 else if (anArg == "-format")
8361 if (++anArgIter >= theArgNb)
8363 Message::SendFail() << "Syntax error at " << anArg;
8366 aRecParams.Format = theArgVec[anArgIter];
8368 else if (anArg == "-pix_fmt"
8369 || anArg == "-pixfmt"
8370 || anArg == "-pixelformat")
8372 if (++anArgIter >= theArgNb)
8374 Message::SendFail() << "Syntax error at " << anArg;
8377 aRecParams.PixelFormat = theArgVec[anArgIter];
8379 else if (anArg == "-codec"
8380 || anArg == "-vcodec"
8381 || anArg == "-videocodec")
8383 if (++anArgIter >= theArgNb)
8385 Message::SendFail() << "Syntax error at " << anArg;
8388 aRecParams.VideoCodec = theArgVec[anArgIter];
8390 else if (anArg == "-crf"
8391 || anArg == "-preset"
8394 const TCollection_AsciiString aParamName = anArg.SubString (2, anArg.Length());
8395 if (++anArgIter >= theArgNb)
8397 Message::SendFail() << "Syntax error at " << anArg;
8401 aRecParams.VideoCodecParams.Bind (aParamName, theArgVec[anArgIter]);
8403 // animation definition options
8404 else if (anArg == "-start"
8405 || anArg == "-starttime"
8406 || anArg == "-startpts")
8408 if (++anArgIter >= theArgNb)
8410 Message::SendFail() << "Syntax error at " << anArg;
8414 anAnimation->SetStartPts (Draw::Atof (theArgVec[anArgIter]));
8415 aRootAnimation->UpdateTotalDuration();
8417 else if (anArg == "-end"
8418 || anArg == "-endtime"
8419 || anArg == "-endpts")
8421 if (++anArgIter >= theArgNb)
8423 Message::SendFail() << "Syntax error at " << anArg;
8427 anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]) - anAnimation->StartPts());
8428 aRootAnimation->UpdateTotalDuration();
8430 else if (anArg == "-dur"
8431 || anArg == "-duration")
8433 if (++anArgIter >= theArgNb)
8435 Message::SendFail() << "Syntax error at " << anArg;
8439 anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]));
8440 aRootAnimation->UpdateTotalDuration();
8442 else if (anArg == "-command"
8444 || anArg == "-invoke"
8446 || anArg == "-proc")
8448 if (++anArgIter >= theArgNb)
8450 Message::SendFail() << "Syntax error at " << anArg;
8454 Handle(ViewerTest_AnimationProc) aCmdAnimation = new ViewerTest_AnimationProc (anAnimation->Name(), &theDI, theArgVec[anArgIter]);
8455 replaceAnimation (aParentAnimation, anAnimation, aCmdAnimation);
8457 else if (anArg == "-objecttrsf"
8458 || anArg == "-objectransformation"
8459 || anArg == "-objtransformation"
8460 || anArg == "-objtrsf"
8461 || anArg == "-object"
8464 if (++anArgIter >= theArgNb)
8466 Message::SendFail() << "Syntax error at " << anArg;
8470 TCollection_AsciiString anObjName (theArgVec[anArgIter]);
8471 const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfAIS = GetMapOfAIS();
8472 Handle(AIS_InteractiveObject) anObject;
8473 if (!aMapOfAIS.Find2 (anObjName, anObject))
8475 Message::SendFail() << "Syntax error: wrong object name at " << anArg;
8479 gp_Trsf aTrsfs [2] = { anObject->LocalTransformation(), anObject->LocalTransformation() };
8480 gp_Quaternion aRotQuats[2] = { aTrsfs[0].GetRotation(), aTrsfs[1].GetRotation() };
8481 gp_XYZ aLocPnts [2] = { aTrsfs[0].TranslationPart(), aTrsfs[1].TranslationPart() };
8482 Standard_Real aScales [2] = { aTrsfs[0].ScaleFactor(), aTrsfs[1].ScaleFactor() };
8483 Standard_Boolean isTrsfSet = Standard_False;
8484 Standard_Integer aTrsfArgIter = anArgIter + 1;
8485 for (; aTrsfArgIter < theArgNb; ++aTrsfArgIter)
8487 TCollection_AsciiString aTrsfArg (theArgVec[aTrsfArgIter]);
8488 aTrsfArg.LowerCase();
8489 const Standard_Integer anIndex = aTrsfArg.EndsWith ("1") ? 0 : 1;
8490 if (aTrsfArg.StartsWith ("-rotation")
8491 || aTrsfArg.StartsWith ("-rot"))
8493 isTrsfSet = Standard_True;
8494 if (aTrsfArgIter + 4 >= theArgNb
8495 || !parseQuaternion (theArgVec + aTrsfArgIter + 1, aRotQuats[anIndex]))
8497 Message::SendFail() << "Syntax error at " << aTrsfArg;
8502 else if (aTrsfArg.StartsWith ("-location")
8503 || aTrsfArg.StartsWith ("-loc"))
8505 isTrsfSet = Standard_True;
8506 if (aTrsfArgIter + 3 >= theArgNb
8507 || !parseXYZ (theArgVec + aTrsfArgIter + 1, aLocPnts[anIndex]))
8509 Message::SendFail() << "Syntax error at " << aTrsfArg;
8514 else if (aTrsfArg.StartsWith ("-scale"))
8516 isTrsfSet = Standard_True;
8517 if (++aTrsfArgIter >= theArgNb)
8519 Message::SendFail() << "Syntax error at " << aTrsfArg;
8523 const TCollection_AsciiString aScaleStr (theArgVec[aTrsfArgIter]);
8524 if (!aScaleStr.IsRealValue())
8526 Message::SendFail() << "Syntax error at " << aTrsfArg;
8529 aScales[anIndex] = aScaleStr.RealValue();
8533 anArgIter = aTrsfArgIter - 1;
8539 Message::SendFail() << "Syntax error at " << anArg;
8542 else if (aTrsfArgIter >= theArgNb)
8544 anArgIter = theArgNb;
8547 aTrsfs[0].SetRotation (aRotQuats[0]);
8548 aTrsfs[1].SetRotation (aRotQuats[1]);
8549 aTrsfs[0].SetTranslationPart (aLocPnts[0]);
8550 aTrsfs[1].SetTranslationPart (aLocPnts[1]);
8551 aTrsfs[0].SetScaleFactor (aScales[0]);
8552 aTrsfs[1].SetScaleFactor (aScales[1]);
8554 Handle(AIS_AnimationObject) anObjAnimation = new AIS_AnimationObject (anAnimation->Name(), aCtx, anObject, aTrsfs[0], aTrsfs[1]);
8555 replaceAnimation (aParentAnimation, anAnimation, anObjAnimation);
8557 else if (anArg == "-viewtrsf"
8558 || anArg == "-view")
8560 Handle(AIS_AnimationCamera) aCamAnimation = Handle(AIS_AnimationCamera)::DownCast (anAnimation);
8561 if (aCamAnimation.IsNull())
8563 aCamAnimation = new AIS_AnimationCamera (anAnimation->Name(), aView);
8564 replaceAnimation (aParentAnimation, anAnimation, aCamAnimation);
8567 Handle(Graphic3d_Camera) aCams[2] =
8569 new Graphic3d_Camera (aCamAnimation->View()->Camera()),
8570 new Graphic3d_Camera (aCamAnimation->View()->Camera())
8573 Standard_Boolean isTrsfSet = Standard_False;
8574 Standard_Integer aViewArgIter = anArgIter + 1;
8575 for (; aViewArgIter < theArgNb; ++aViewArgIter)
8577 TCollection_AsciiString aViewArg (theArgVec[aViewArgIter]);
8578 aViewArg.LowerCase();
8579 const Standard_Integer anIndex = aViewArg.EndsWith("1") ? 0 : 1;
8580 if (aViewArg.StartsWith ("-scale"))
8582 isTrsfSet = Standard_True;
8583 if (++aViewArgIter >= theArgNb)
8585 Message::SendFail() << "Syntax error at " << anArg;
8589 const TCollection_AsciiString aScaleStr (theArgVec[aViewArgIter]);
8590 if (!aScaleStr.IsRealValue())
8592 Message::SendFail() << "Syntax error at " << aViewArg;
8595 Standard_Real aScale = aScaleStr.RealValue();
8596 aScale = aCamAnimation->View()->DefaultCamera()->Scale() / aScale;
8597 aCams[anIndex]->SetScale (aScale);
8599 else if (aViewArg.StartsWith ("-eye")
8600 || aViewArg.StartsWith ("-center")
8601 || aViewArg.StartsWith ("-at")
8602 || aViewArg.StartsWith ("-up"))
8604 isTrsfSet = Standard_True;
8606 if (aViewArgIter + 3 >= theArgNb
8607 || !parseXYZ (theArgVec + aViewArgIter + 1, anXYZ))
8609 Message::SendFail() << "Syntax error at " << aViewArg;
8614 if (aViewArg.StartsWith ("-eye"))
8616 aCams[anIndex]->SetEye (anXYZ);
8618 else if (aViewArg.StartsWith ("-center")
8619 || aViewArg.StartsWith ("-at"))
8621 aCams[anIndex]->SetCenter (anXYZ);
8623 else if (aViewArg.StartsWith ("-up"))
8625 aCams[anIndex]->SetUp (anXYZ);
8630 anArgIter = aViewArgIter - 1;
8636 Message::SendFail() << "Syntax error at " << anArg;
8639 else if (aViewArgIter >= theArgNb)
8641 anArgIter = theArgNb;
8644 aCamAnimation->SetCameraStart(aCams[0]);
8645 aCamAnimation->SetCameraEnd (aCams[1]);
8649 Message::SendFail() << "Syntax error at " << anArg;
8654 if (!toPlay && aRecFile.IsEmpty())
8659 // Start animation timeline and process frame updating.
8660 TheIsAnimating = Standard_True;
8661 const Standard_Boolean wasImmediateUpdate = aView->SetImmediateUpdate (Standard_False);
8662 Handle(Graphic3d_Camera) aCameraBack = new Graphic3d_Camera (aView->Camera());
8663 anAnimation->StartTimer (aPlayStartTime, aPlaySpeed, Standard_True, aPlayDuration <= 0.0);
8666 aView->Camera()->Copy (aCameraBack);
8669 const Standard_Real anUpperPts = aPlayStartTime + aPlayDuration;
8670 if (aRecParams.FpsNum <= 0)
8672 while (!anAnimation->IsStopped())
8674 aCameraBack->Copy (aView->Camera());
8675 const Standard_Real aPts = anAnimation->UpdateTimer();
8678 aView->Camera()->Copy (aCameraBack);
8681 if (aPts >= anUpperPts)
8683 anAnimation->Pause();
8687 if (aView->IsInvalidated())
8693 aView->RedrawImmediate();
8698 // handle user events
8699 theDI.Eval ("after 1 set waiter 1");
8700 theDI.Eval ("vwait waiter");
8702 if (!TheIsAnimating)
8704 anAnimation->Pause();
8710 if (aView->IsInvalidated())
8716 aView->RedrawImmediate();
8721 OSD_Timer aPerfTimer;
8724 Handle(Image_VideoRecorder) aRecorder;
8725 ImageFlipper aFlipper;
8726 Handle(Draw_ProgressIndicator) aProgress;
8727 if (!aRecFile.IsEmpty())
8729 if (aRecParams.Width <= 0
8730 || aRecParams.Height <= 0)
8732 aView->Window()->Size (aRecParams.Width, aRecParams.Height);
8735 aRecorder = new Image_VideoRecorder();
8736 if (!aRecorder->Open (aRecFile.ToCString(), aRecParams))
8738 Message::SendFail ("Error: failed to open video file for recording");
8742 aProgress = new Draw_ProgressIndicator (theDI, 1);
8745 // Manage frame-rated animation here
8746 Standard_Real aPts = aPlayStartTime;
8747 int64_t aNbFrames = 0;
8748 Message_ProgressSentry aPSentry (aProgress, "Video recording, sec", 0, Max (1, Standard_Integer(aPlayDuration / aPlaySpeed)), 1);
8749 Standard_Integer aSecondsProgress = 0;
8750 for (; aPts <= anUpperPts && aPSentry.More();)
8752 const Standard_Real aRecPts = aPlaySpeed * ((Standard_Real(aRecParams.FpsDen) / Standard_Real(aRecParams.FpsNum)) * Standard_Real(aNbFrames));
8753 aPts = aPlayStartTime + aRecPts;
8755 if (!anAnimation->Update (aPts))
8760 if (!aRecorder.IsNull())
8762 V3d_ImageDumpOptions aDumpParams;
8763 aDumpParams.Width = aRecParams.Width;
8764 aDumpParams.Height = aRecParams.Height;
8765 aDumpParams.BufferType = Graphic3d_BT_RGBA;
8766 aDumpParams.StereoOptions = V3d_SDO_MONO;
8767 aDumpParams.ToAdjustAspect = Standard_True;
8768 if (!aView->ToPixMap (aRecorder->ChangeFrame(), aDumpParams))
8770 Message::SendFail ("Error: view dump is failed");
8773 aFlipper.FlipY (aRecorder->ChangeFrame());
8774 if (!aRecorder->PushFrame())
8784 while (aSecondsProgress < Standard_Integer(aRecPts / aPlaySpeed))
8792 anAnimation->Stop();
8793 const Standard_Real aRecFps = Standard_Real(aNbFrames) / aPerfTimer.ElapsedTime();
8794 theDI << "Average FPS: " << aRecFps << "\n"
8795 << "Nb. Frames: " << Standard_Real(aNbFrames);
8800 aView->SetImmediateUpdate (wasImmediateUpdate);
8801 TheIsAnimating = Standard_False;
8806 //=======================================================================
8807 //function : VChangeSelected
8808 //purpose : Adds the shape to selection or remove one from it
8809 //=======================================================================
8810 static Standard_Integer VChangeSelected (Draw_Interpretor& di,
8811 Standard_Integer argc,
8816 di<<"Usage : " << argv[0] << " shape \n";
8820 TCollection_AsciiString aName(argv[1]);
8821 Handle(AIS_InteractiveObject) anAISObject;
8822 if (!GetMapOfAIS().Find2 (aName, anAISObject)
8823 || anAISObject.IsNull())
8825 di<<"Use 'vdisplay' before";
8829 ViewerTest::GetAISContext()->AddOrRemoveSelected(anAISObject, Standard_True);
8833 //=======================================================================
8834 //function : VNbSelected
8835 //purpose : Returns number of selected objects
8836 //=======================================================================
8837 static Standard_Integer VNbSelected (Draw_Interpretor& di,
8838 Standard_Integer argc,
8843 di << "Usage : " << argv[0] << "\n";
8846 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8847 if(aContext.IsNull())
8849 di << "use 'vinit' command before " << argv[0] << "\n";
8852 di << aContext->NbSelected() << "\n";
8856 //=======================================================================
8857 //function : VPurgeDisplay
8858 //purpose : Switches altialiasing on or off
8859 //=======================================================================
8860 static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
8861 Standard_Integer argc,
8866 di << "Usage : " << argv[0] << "\n";
8869 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8870 if (aContext.IsNull())
8872 di << "use 'vinit' command before " << argv[0] << "\n";
8876 di << aContext->PurgeDisplay() << "\n";
8880 //=======================================================================
8881 //function : VSetViewSize
8883 //=======================================================================
8884 static Standard_Integer VSetViewSize (Draw_Interpretor& di,
8885 Standard_Integer argc,
8888 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8889 if(aContext.IsNull())
8891 di << "use 'vinit' command before " << argv[0] << "\n";
8896 di<<"Usage : " << argv[0] << " Size\n";
8899 Standard_Real aSize = Draw::Atof (argv[1]);
8902 di<<"Bad Size value : " << aSize << "\n";
8906 Handle(V3d_View) aView = ViewerTest::CurrentView();
8907 aView->SetSize(aSize);
8911 //=======================================================================
8912 //function : VMoveView
8914 //=======================================================================
8915 static Standard_Integer VMoveView (Draw_Interpretor& di,
8916 Standard_Integer argc,
8919 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8920 if(aContext.IsNull())
8922 di << "use 'vinit' command before " << argv[0] << "\n";
8925 if(argc < 4 || argc > 5)
8927 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
8930 Standard_Real Dx = Draw::Atof (argv[1]);
8931 Standard_Real Dy = Draw::Atof (argv[2]);
8932 Standard_Real Dz = Draw::Atof (argv[3]);
8933 Standard_Boolean aStart = Standard_True;
8936 aStart = (Draw::Atoi (argv[4]) > 0);
8939 Handle(V3d_View) aView = ViewerTest::CurrentView();
8940 aView->Move(Dx,Dy,Dz,aStart);
8944 //=======================================================================
8945 //function : VTranslateView
8947 //=======================================================================
8948 static Standard_Integer VTranslateView (Draw_Interpretor& di,
8949 Standard_Integer argc,
8952 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8953 if(aContext.IsNull())
8955 di << "use 'vinit' command before " << argv[0] << "\n";
8958 if(argc < 4 || argc > 5)
8960 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
8963 Standard_Real Dx = Draw::Atof (argv[1]);
8964 Standard_Real Dy = Draw::Atof (argv[2]);
8965 Standard_Real Dz = Draw::Atof (argv[3]);
8966 Standard_Boolean aStart = Standard_True;
8969 aStart = (Draw::Atoi (argv[4]) > 0);
8972 Handle(V3d_View) aView = ViewerTest::CurrentView();
8973 aView->Translate(Dx,Dy,Dz,aStart);
8977 //=======================================================================
8978 //function : VTurnView
8980 //=======================================================================
8981 static Standard_Integer VTurnView (Draw_Interpretor& di,
8982 Standard_Integer argc,
8985 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
8986 if(aContext.IsNull()) {
8987 di << "use 'vinit' command before " << argv[0] << "\n";
8990 if(argc < 4 || argc > 5){
8991 di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n";
8994 Standard_Real Ax = Draw::Atof (argv[1]);
8995 Standard_Real Ay = Draw::Atof (argv[2]);
8996 Standard_Real Az = Draw::Atof (argv[3]);
8997 Standard_Boolean aStart = Standard_True;
9000 aStart = (Draw::Atoi (argv[4]) > 0);
9003 Handle(V3d_View) aView = ViewerTest::CurrentView();
9004 aView->Turn(Ax,Ay,Az,aStart);
9008 //==============================================================================
9009 //function : VTextureEnv
9010 //purpose : ENables or disables environment mapping
9011 //==============================================================================
9012 class OCC_TextureEnv : public Graphic3d_TextureEnv
9015 OCC_TextureEnv(const Standard_CString FileName);
9016 OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName);
9017 void SetTextureParameters(const Standard_Boolean theRepeatFlag,
9018 const Standard_Boolean theModulateFlag,
9019 const Graphic3d_TypeOfTextureFilter theFilter,
9020 const Standard_ShortReal theXScale,
9021 const Standard_ShortReal theYScale,
9022 const Standard_ShortReal theXShift,
9023 const Standard_ShortReal theYShift,
9024 const Standard_ShortReal theAngle);
9025 DEFINE_STANDARD_RTTI_INLINE(OCC_TextureEnv,Graphic3d_TextureEnv)
9027 DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv)
9029 OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName)
9030 : Graphic3d_TextureEnv(theFileName)
9034 OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId)
9035 : Graphic3d_TextureEnv(theTexId)
9039 void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag,
9040 const Standard_Boolean theModulateFlag,
9041 const Graphic3d_TypeOfTextureFilter theFilter,
9042 const Standard_ShortReal theXScale,
9043 const Standard_ShortReal theYScale,
9044 const Standard_ShortReal theXShift,
9045 const Standard_ShortReal theYShift,
9046 const Standard_ShortReal theAngle)
9048 myParams->SetRepeat (theRepeatFlag);
9049 myParams->SetModulate (theModulateFlag);
9050 myParams->SetFilter (theFilter);
9051 myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale));
9052 myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift));
9053 myParams->SetRotation (theAngle);
9056 static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec)
9058 // get the active view
9059 Handle(V3d_View) aView = ViewerTest::CurrentView();
9062 Message::SendFail ("Error: no active viewer");
9066 // Checking the input arguments
9067 Standard_Boolean anEnableFlag = Standard_False;
9068 Standard_Boolean isOk = theArgNb >= 2;
9071 TCollection_AsciiString anEnableOpt(theArgVec[1]);
9072 anEnableFlag = anEnableOpt.IsEqual("on");
9073 isOk = anEnableFlag || anEnableOpt.IsEqual("off");
9077 isOk = (theArgNb == 3 || theArgNb == 11);
9080 TCollection_AsciiString aTextureOpt(theArgVec[2]);
9081 isOk = (!aTextureOpt.IsIntegerValue() ||
9082 (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN));
9084 if (isOk && theArgNb == 11)
9086 TCollection_AsciiString aRepeatOpt (theArgVec[3]),
9087 aModulateOpt(theArgVec[4]),
9088 aFilterOpt (theArgVec[5]),
9089 aSScaleOpt (theArgVec[6]),
9090 aTScaleOpt (theArgVec[7]),
9091 aSTransOpt (theArgVec[8]),
9092 aTTransOpt (theArgVec[9]),
9093 anAngleOpt (theArgVec[10]);
9094 isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) &&
9095 (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) &&
9096 (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) &&
9097 aSScaleOpt.IsRealValue() && aTScaleOpt.IsRealValue() &&
9098 aSTransOpt.IsRealValue() && aTTransOpt.IsRealValue() &&
9099 anAngleOpt.IsRealValue());
9106 Message::SendFail() << "Usage:\n"
9107 << theArgVec[0] << " off\n"
9108 << 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]";
9114 TCollection_AsciiString aTextureOpt(theArgVec[2]);
9115 Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ?
9116 new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) :
9117 new OCC_TextureEnv(theArgVec[2]);
9121 TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]);
9122 aTexEnv->SetTextureParameters(
9123 aRepeatOpt. IsEqual("repeat"),
9124 aModulateOpt.IsEqual("modulate"),
9125 aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST :
9126 aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR :
9127 Graphic3d_TOTF_TRILINEAR,
9128 (Standard_ShortReal)Draw::Atof(theArgVec[6]),
9129 (Standard_ShortReal)Draw::Atof(theArgVec[7]),
9130 (Standard_ShortReal)Draw::Atof(theArgVec[8]),
9131 (Standard_ShortReal)Draw::Atof(theArgVec[9]),
9132 (Standard_ShortReal)Draw::Atof(theArgVec[10])
9135 aView->SetTextureEnv(aTexEnv);
9137 else // Disabling environment mapping
9139 Handle(Graphic3d_TextureEnv) aTexture;
9140 aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data
9149 typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
9151 //! Remove registered clipping plane from all views and objects.
9152 static void removePlane (MapOfPlanes& theRegPlanes,
9153 const TCollection_AsciiString& theName)
9155 Handle(Graphic3d_ClipPlane) aClipPlane;
9156 if (!theRegPlanes.Find (theName, aClipPlane))
9158 Message::SendWarning ("Warning: no such plane");
9162 theRegPlanes.UnBind (theName);
9163 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
9164 anIObjIt.More(); anIObjIt.Next())
9166 const Handle(AIS_InteractiveObject)& aPrs = anIObjIt.Key1();
9167 aPrs->RemoveClipPlane (aClipPlane);
9170 for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
9171 aViewIt.More(); aViewIt.Next())
9173 const Handle(V3d_View)& aView = aViewIt.Key2();
9174 aView->RemoveClipPlane(aClipPlane);
9177 ViewerTest::RedrawAllViews();
9181 //===============================================================================================
9182 //function : VClipPlane
9184 //===============================================================================================
9185 static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
9187 // use short-cut for created clip planes map of created (or "registered by name") clip planes
9188 static MapOfPlanes aRegPlanes;
9192 for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More(); aPlaneIter.Next())
9194 theDi << aPlaneIter.Key() << " ";
9199 TCollection_AsciiString aCommand (theArgVec[1]);
9200 aCommand.LowerCase();
9201 const Handle(V3d_View)& anActiveView = ViewerTest::CurrentView();
9202 if (anActiveView.IsNull())
9204 Message::SendFail ("Error: no active viewer");
9208 // print maximum number of planes for current viewer
9209 if (aCommand == "-maxplanes"
9210 || aCommand == "maxplanes")
9212 theDi << anActiveView->Viewer()->Driver()->InquirePlaneLimit()
9213 << " plane slots provided by driver.\n";
9217 // create / delete plane instance
9218 if (aCommand == "-create"
9219 || aCommand == "create"
9220 || aCommand == "-delete"
9221 || aCommand == "delete"
9222 || aCommand == "-clone"
9223 || aCommand == "clone")
9227 Message::SendFail ("Syntax error: plane name is required");
9231 Standard_Boolean toCreate = aCommand == "-create"
9232 || aCommand == "create";
9233 Standard_Boolean toClone = aCommand == "-clone"
9234 || aCommand == "clone";
9235 Standard_Boolean toDelete = aCommand == "-delete"
9236 || aCommand == "delete";
9237 TCollection_AsciiString aPlane (theArgVec[2]);
9241 if (aRegPlanes.IsBound (aPlane))
9243 std::cout << "Warning: existing plane has been overridden.\n";
9248 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
9252 else if (toClone) // toClone
9254 if (!aRegPlanes.IsBound (aPlane))
9256 Message::SendFail ("Error: no such plane");
9259 else if (theArgsNb < 4)
9261 Message::SendFail ("Syntax error: enter name for new plane");
9265 TCollection_AsciiString aClone (theArgVec[3]);
9266 if (aRegPlanes.IsBound (aClone))
9268 Message::SendFail ("Error: plane name is in use");
9272 const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
9274 aRegPlanes.Bind (aClone, aClipPlane->Clone());
9284 for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More();)
9286 aPlane = aPlaneIter.Key();
9287 removePlane (aRegPlanes, aPlane);
9288 aPlaneIter = MapOfPlanes::Iterator (aRegPlanes);
9293 removePlane (aRegPlanes, aPlane);
9299 aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
9304 // set / unset plane command
9305 if (aCommand == "set"
9306 || aCommand == "unset")
9310 Message::SendFail ("Syntax error: need more arguments");
9314 // redirect to new syntax
9315 NCollection_Array1<const char*> anArgVec (1, theArgsNb - 1);
9316 anArgVec.SetValue (1, theArgVec[0]);
9317 anArgVec.SetValue (2, theArgVec[2]);
9318 anArgVec.SetValue (3, aCommand == "set" ? "-set" : "-unset");
9319 for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
9321 anArgVec.SetValue (anIt, theArgVec[anIt]);
9324 return VClipPlane (theDi, anArgVec.Length(), &anArgVec.ChangeFirst());
9327 // change plane command
9328 TCollection_AsciiString aPlaneName;
9329 Handle(Graphic3d_ClipPlane) aClipPlane;
9330 Standard_Integer anArgIter = 0;
9331 if (aCommand == "-change"
9332 || aCommand == "change")
9334 // old syntax support
9337 Message::SendFail ("Syntax error: need more arguments");
9342 aPlaneName = theArgVec[2];
9343 if (!aRegPlanes.Find (aPlaneName, aClipPlane))
9345 Message::SendFail() << "Error: no such plane '" << aPlaneName << "'";
9349 else if (aRegPlanes.Find (theArgVec[1], aClipPlane))
9352 aPlaneName = theArgVec[1];
9357 aPlaneName = theArgVec[1];
9358 aClipPlane = new Graphic3d_ClipPlane();
9359 aRegPlanes.Bind (aPlaneName, aClipPlane);
9360 theDi << "Created new plane " << aPlaneName << ".\n";
9363 if (theArgsNb - anArgIter < 1)
9365 Message::SendFail ("Syntax error: need more arguments");
9369 for (; anArgIter < theArgsNb; ++anArgIter)
9371 const char** aChangeArgs = theArgVec + anArgIter;
9372 Standard_Integer aNbChangeArgs = theArgsNb - anArgIter;
9373 TCollection_AsciiString aChangeArg (aChangeArgs[0]);
9374 aChangeArg.LowerCase();
9376 Standard_Boolean toEnable = Standard_True;
9377 if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable))
9379 aClipPlane->SetOn (toEnable);
9381 else if (aChangeArg.StartsWith ("-equation")
9382 || aChangeArg.StartsWith ("equation"))
9384 if (aNbChangeArgs < 5)
9386 Message::SendFail ("Syntax error: need more arguments");
9390 Standard_Integer aSubIndex = 1;
9391 Standard_Integer aPrefixLen = 8 + (aChangeArg.Value (1) == '-' ? 1 : 0);
9392 if (aPrefixLen < aChangeArg.Length())
9394 TCollection_AsciiString aSubStr = aChangeArg.SubString (aPrefixLen + 1, aChangeArg.Length());
9395 if (!aSubStr.IsIntegerValue()
9396 || aSubStr.IntegerValue() <= 0)
9398 Message::SendFail() << "Syntax error: unknown argument '" << aChangeArg << "'";
9401 aSubIndex = aSubStr.IntegerValue();
9404 Standard_Real aCoeffA = Draw::Atof (aChangeArgs[1]);
9405 Standard_Real aCoeffB = Draw::Atof (aChangeArgs[2]);
9406 Standard_Real aCoeffC = Draw::Atof (aChangeArgs[3]);
9407 Standard_Real aCoeffD = Draw::Atof (aChangeArgs[4]);
9408 Handle(Graphic3d_ClipPlane) aSubPln = aClipPlane;
9409 for (Standard_Integer aSubPlaneIter = 1; aSubPlaneIter < aSubIndex; ++aSubPlaneIter)
9411 if (aSubPln->ChainNextPlane().IsNull())
9413 aSubPln->SetChainNextPlane (new Graphic3d_ClipPlane (*aSubPln));
9415 aSubPln = aSubPln->ChainNextPlane();
9417 aSubPln->SetChainNextPlane (Handle(Graphic3d_ClipPlane)());
9418 aSubPln->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD));
9421 else if ((aChangeArg == "-boxinterior"
9422 || aChangeArg == "-boxint"
9423 || aChangeArg == "-box")
9424 && aNbChangeArgs >= 7)
9426 Graphic3d_BndBox3d aBndBox;
9427 aBndBox.Add (Graphic3d_Vec3d (Draw::Atof (aChangeArgs[1]), Draw::Atof (aChangeArgs[2]), Draw::Atof (aChangeArgs[3])));
9428 aBndBox.Add (Graphic3d_Vec3d (Draw::Atof (aChangeArgs[4]), Draw::Atof (aChangeArgs[5]), Draw::Atof (aChangeArgs[6])));
9431 Standard_Integer aNbSubPlanes = 6;
9432 const Graphic3d_Vec3d aDirArray[6] =
9434 Graphic3d_Vec3d (-1, 0, 0),
9435 Graphic3d_Vec3d ( 1, 0, 0),
9436 Graphic3d_Vec3d ( 0,-1, 0),
9437 Graphic3d_Vec3d ( 0, 1, 0),
9438 Graphic3d_Vec3d ( 0, 0,-1),
9439 Graphic3d_Vec3d ( 0, 0, 1),
9441 Handle(Graphic3d_ClipPlane) aSubPln = aClipPlane;
9442 for (Standard_Integer aSubPlaneIter = 0; aSubPlaneIter < aNbSubPlanes; ++aSubPlaneIter)
9444 const Graphic3d_Vec3d& aDir = aDirArray[aSubPlaneIter];
9445 const Standard_Real aW = -aDir.Dot ((aSubPlaneIter % 2 == 1) ? aBndBox.CornerMax() : aBndBox.CornerMin());
9446 aSubPln->SetEquation (gp_Pln (aDir.x(), aDir.y(), aDir.z(), aW));
9447 if (aSubPlaneIter + 1 == aNbSubPlanes)
9449 aSubPln->SetChainNextPlane (Handle(Graphic3d_ClipPlane)());
9453 aSubPln->SetChainNextPlane (new Graphic3d_ClipPlane (*aSubPln));
9455 aSubPln = aSubPln->ChainNextPlane();
9458 else if (aChangeArg == "-capping"
9459 || aChangeArg == "capping")
9461 if (aNbChangeArgs < 2)
9463 Message::SendFail ("Syntax error: need more arguments");
9467 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9469 aClipPlane->SetCapping (toEnable);
9474 // just skip otherwise (old syntax)
9477 else if (aChangeArg == "-useobjectmaterial"
9478 || aChangeArg == "-useobjectmat"
9479 || aChangeArg == "-useobjmat"
9480 || aChangeArg == "-useobjmaterial")
9482 if (aNbChangeArgs < 2)
9484 Message::SendFail ("Syntax error: need more arguments");
9488 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9490 aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
9494 else if (aChangeArg == "-useobjecttexture"
9495 || aChangeArg == "-useobjecttex"
9496 || aChangeArg == "-useobjtexture"
9497 || aChangeArg == "-useobjtex")
9499 if (aNbChangeArgs < 2)
9501 Message::SendFail ("Syntax error: need more arguments");
9505 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9507 aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
9511 else if (aChangeArg == "-useobjectshader"
9512 || aChangeArg == "-useobjshader")
9514 if (aNbChangeArgs < 2)
9516 Message::SendFail ("Syntax error: need more arguments");
9520 if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
9522 aClipPlane->SetUseObjectShader (toEnable == Standard_True);
9526 else if (aChangeArg == "-color"
9527 || aChangeArg == "color")
9529 Quantity_Color aColor;
9530 Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
9535 Message::SendFail ("Syntax error: need more arguments");
9538 aClipPlane->SetCappingColor (aColor);
9539 anArgIter += aNbParsed;
9541 else if (aNbChangeArgs >= 1
9542 && (aChangeArg == "-material"
9543 || aChangeArg == "material"))
9546 Graphic3d_NameOfMaterial aMatName;
9547 if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeArgs[1], aMatName))
9549 Message::SendFail() << "Syntax error: unknown material '" << aChangeArgs[1] << "'";
9552 aClipPlane->SetCappingMaterial (aMatName);
9554 else if ((aChangeArg == "-transparency"
9555 || aChangeArg == "-transp")
9556 && aNbChangeArgs >= 2)
9558 TCollection_AsciiString aValStr (aChangeArgs[1]);
9559 Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect();
9560 if (aValStr.IsRealValue())
9562 Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
9563 aMat.SetTransparency ((float )aValStr.RealValue());
9564 anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto);
9565 aClipPlane->SetCappingMaterial (aMat);
9569 aValStr.LowerCase();
9570 Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto;
9571 if (aValStr == "opaque")
9573 aMode = Graphic3d_AlphaMode_Opaque;
9575 else if (aValStr == "mask")
9577 aMode = Graphic3d_AlphaMode_Mask;
9579 else if (aValStr == "blend")
9581 aMode = Graphic3d_AlphaMode_Blend;
9583 else if (aValStr == "blendauto")
9585 aMode = Graphic3d_AlphaMode_BlendAuto;
9589 Message::SendFail() << "Syntax error at '" << aValStr << "'";
9592 anAspect->SetAlphaMode (aMode);
9593 aClipPlane->SetCappingAspect (anAspect);
9597 else if (aChangeArg == "-texname"
9598 || aChangeArg == "texname")
9600 if (aNbChangeArgs < 2)
9602 Message::SendFail ("Syntax error: need more arguments");
9606 TCollection_AsciiString aTextureName (aChangeArgs[1]);
9607 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
9608 if (!aTexture->IsDone())
9610 aClipPlane->SetCappingTexture (NULL);
9614 aTexture->EnableModulate();
9615 aTexture->EnableRepeat();
9616 aClipPlane->SetCappingTexture (aTexture);
9620 else if (aChangeArg == "-texscale"
9621 || aChangeArg == "texscale")
9623 if (aClipPlane->CappingTexture().IsNull())
9625 Message::SendFail ("Error: no texture is set");
9629 if (aNbChangeArgs < 3)
9631 Message::SendFail ("Syntax error: need more arguments");
9635 Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
9636 Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
9637 aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
9640 else if (aChangeArg == "-texorigin"
9641 || aChangeArg == "texorigin") // texture origin
9643 if (aClipPlane->CappingTexture().IsNull())
9645 Message::SendFail ("Error: no texture is set");
9649 if (aNbChangeArgs < 3)
9651 Message::SendFail ("Syntax error: need more arguments");
9655 Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
9656 Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
9658 aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
9661 else if (aChangeArg == "-texrotate"
9662 || aChangeArg == "texrotate") // texture rotation
9664 if (aClipPlane->CappingTexture().IsNull())
9666 Message::SendFail ("Error: no texture is set");
9670 if (aNbChangeArgs < 2)
9672 Message::SendFail ("Syntax error: need more arguments");
9676 Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
9677 aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
9680 else if (aChangeArg == "-hatch"
9681 || aChangeArg == "hatch")
9683 if (aNbChangeArgs < 2)
9685 Message::SendFail ("Syntax error: need more arguments");
9689 TCollection_AsciiString aHatchStr (aChangeArgs[1]);
9690 aHatchStr.LowerCase();
9691 if (aHatchStr == "on")
9693 aClipPlane->SetCappingHatchOn();
9695 else if (aHatchStr == "off")
9697 aClipPlane->SetCappingHatchOff();
9701 aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
9705 else if (aChangeArg == "-delete"
9706 || aChangeArg == "delete")
9708 removePlane (aRegPlanes, aPlaneName);
9711 else if (aChangeArg == "-set"
9712 || aChangeArg == "-unset"
9713 || aChangeArg == "-setoverrideglobal")
9715 // set / unset plane command
9716 const Standard_Boolean toSet = aChangeArg.StartsWith ("-set");
9717 const Standard_Boolean toOverrideGlobal = aChangeArg == "-setoverrideglobal";
9718 Standard_Integer anIt = 1;
9719 for (; anIt < aNbChangeArgs; ++anIt)
9721 TCollection_AsciiString anEntityName (aChangeArgs[anIt]);
9722 if (anEntityName.IsEmpty()
9723 || anEntityName.Value (1) == '-')
9727 else if (!toOverrideGlobal
9728 && ViewerTest_myViews.IsBound1 (anEntityName))
9730 Handle(V3d_View) aView = ViewerTest_myViews.Find1 (anEntityName);
9733 aView->AddClipPlane (aClipPlane);
9737 aView->RemoveClipPlane (aClipPlane);
9741 else if (GetMapOfAIS().IsBound2 (anEntityName))
9743 Handle(AIS_InteractiveObject) aIObj = GetMapOfAIS().Find2 (anEntityName);
9746 aIObj->AddClipPlane (aClipPlane);
9750 aIObj->RemoveClipPlane (aClipPlane);
9752 if (!aIObj->ClipPlanes().IsNull())
9754 aIObj->ClipPlanes()->SetOverrideGlobal (toOverrideGlobal);
9759 Message::SendFail() << "Error: object/view '" << anEntityName << "' is not found";
9766 // apply to active view
9769 anActiveView->AddClipPlane (aClipPlane);
9773 anActiveView->RemoveClipPlane (aClipPlane);
9778 anArgIter = anArgIter + anIt - 1;
9783 Message::SendFail() << "Syntax error: unknown argument '" << aChangeArg << "'";
9788 ViewerTest::RedrawAllViews();
9792 //===============================================================================================
9793 //function : VZRange
9795 //===============================================================================================
9796 static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
9798 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
9800 if (aCurrentView.IsNull())
9802 Message::SendFail ("Error: no active viewer");
9806 Handle(Graphic3d_Camera) aCamera = aCurrentView->Camera();
9810 theDi << "ZNear: " << aCamera->ZNear() << "\n";
9811 theDi << "ZFar: " << aCamera->ZFar() << "\n";
9817 Standard_Real aNewZNear = Draw::Atof (theArgVec[1]);
9818 Standard_Real aNewZFar = Draw::Atof (theArgVec[2]);
9820 if (aNewZNear >= aNewZFar)
9822 Message::SendFail ("Syntax error: invalid arguments: znear should be less than zfar");
9826 if (!aCamera->IsOrthographic() && (aNewZNear <= 0.0 || aNewZFar <= 0.0))
9828 Message::SendFail ("Syntax error: invalid arguments: znear, zfar should be positive for perspective camera");
9832 aCamera->SetZRange (aNewZNear, aNewZFar);
9836 Message::SendFail ("Syntax error: wrong command arguments");
9840 aCurrentView->Redraw();
9845 //===============================================================================================
9846 //function : VAutoZFit
9848 //===============================================================================================
9849 static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
9851 const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
9853 if (aCurrentView.IsNull())
9855 Message::SendFail ("Error: no active viewer");
9859 Standard_Real aScale = aCurrentView->AutoZFitScaleFactor();
9863 Message::SendFail ("Syntax error: wrong command arguments");
9869 theDi << "Auto z-fit mode: \n"
9870 << "On: " << (aCurrentView->AutoZFitMode() ? "enabled" : "disabled") << "\n"
9871 << "Scale: " << aScale << "\n";
9875 Standard_Boolean isOn = Draw::Atoi (theArgVec[1]) == 1;
9879 aScale = Draw::Atoi (theArgVec[2]);
9882 aCurrentView->SetAutoZFitMode (isOn, aScale);
9883 aCurrentView->Redraw();
9887 //! Auxiliary function to print projection type
9888 inline const char* projTypeName (Graphic3d_Camera::Projection theProjType)
9890 switch (theProjType)
9892 case Graphic3d_Camera::Projection_Orthographic: return "orthographic";
9893 case Graphic3d_Camera::Projection_Perspective: return "perspective";
9894 case Graphic3d_Camera::Projection_Stereo: return "stereoscopic";
9895 case Graphic3d_Camera::Projection_MonoLeftEye: return "monoLeftEye";
9896 case Graphic3d_Camera::Projection_MonoRightEye: return "monoRightEye";
9901 //===============================================================================================
9902 //function : VCamera
9904 //===============================================================================================
9905 static int VCamera (Draw_Interpretor& theDI,
9906 Standard_Integer theArgsNb,
9907 const char** theArgVec)
9909 Handle(V3d_View) aView = ViewerTest::CurrentView();
9912 Message::SendFail ("Error: no active viewer");
9916 Handle(Graphic3d_Camera) aCamera = aView->Camera();
9919 theDI << "ProjType: " << projTypeName (aCamera->ProjectionType()) << "\n";
9920 theDI << "FOVy: " << aCamera->FOVy() << "\n";
9921 theDI << "FOVx: " << aCamera->FOVx() << "\n";
9922 theDI << "FOV2d: " << aCamera->FOV2d() << "\n";
9923 theDI << "Distance: " << aCamera->Distance() << "\n";
9924 theDI << "IOD: " << aCamera->IOD() << "\n";
9925 theDI << "IODType: " << (aCamera->GetIODType() == Graphic3d_Camera::IODType_Absolute ? "absolute" : "relative") << "\n";
9926 theDI << "ZFocus: " << aCamera->ZFocus() << "\n";
9927 theDI << "ZFocusType: " << (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Absolute ? "absolute" : "relative") << "\n";
9931 TCollection_AsciiString aPrsName;
9932 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
9934 Standard_CString anArg = theArgVec[anArgIter];
9935 TCollection_AsciiString anArgCase (anArg);
9936 anArgCase.LowerCase();
9937 if (anArgCase == "-proj"
9938 || anArgCase == "-projection"
9939 || anArgCase == "-projtype"
9940 || anArgCase == "-projectiontype")
9942 theDI << projTypeName (aCamera->ProjectionType()) << " ";
9944 else if (anArgCase == "-ortho"
9945 || anArgCase == "-orthographic")
9947 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
9949 else if (anArgCase == "-persp"
9950 || anArgCase == "-perspective"
9951 || anArgCase == "-perspmono"
9952 || anArgCase == "-perspectivemono"
9953 || anArgCase == "-mono")
9955 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
9957 else if (anArgCase == "-stereo"
9958 || anArgCase == "-stereoscopic"
9959 || anArgCase == "-perspstereo"
9960 || anArgCase == "-perspectivestereo")
9962 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
9964 else if (anArgCase == "-left"
9965 || anArgCase == "-lefteye"
9966 || anArgCase == "-monoleft"
9967 || anArgCase == "-monolefteye"
9968 || anArgCase == "-perpsleft"
9969 || anArgCase == "-perpslefteye")
9971 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
9973 else if (anArgCase == "-right"
9974 || anArgCase == "-righteye"
9975 || anArgCase == "-monoright"
9976 || anArgCase == "-monorighteye"
9977 || anArgCase == "-perpsright")
9979 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
9981 else if (anArgCase == "-dist"
9982 || anArgCase == "-distance")
9984 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
9985 if (anArgValue != NULL
9986 && *anArgValue != '-')
9989 aCamera->SetDistance (Draw::Atof (anArgValue));
9992 theDI << aCamera->Distance() << " ";
9994 else if (anArgCase == "-iod")
9996 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
9997 if (anArgValue != NULL
9998 && *anArgValue != '-')
10001 aCamera->SetIOD (aCamera->GetIODType(), Draw::Atof (anArgValue));
10004 theDI << aCamera->IOD() << " ";
10006 else if (anArgCase == "-iodtype")
10008 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
10009 TCollection_AsciiString anValueCase (anArgValue);
10010 anValueCase.LowerCase();
10011 if (anValueCase == "abs"
10012 || anValueCase == "absolute")
10015 aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD());
10018 else if (anValueCase == "rel"
10019 || anValueCase == "relative")
10022 aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD());
10025 else if (*anArgValue != '-')
10027 Message::SendFail() << "Error: unknown IOD type '" << anArgValue << "'";
10030 switch (aCamera->GetIODType())
10032 case Graphic3d_Camera::IODType_Absolute: theDI << "absolute "; break;
10033 case Graphic3d_Camera::IODType_Relative: theDI << "relative "; break;
10036 else if (anArgCase == "-zfocus")
10038 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
10039 if (anArgValue != NULL
10040 && *anArgValue != '-')
10043 aCamera->SetZFocus (aCamera->ZFocusType(), Draw::Atof (anArgValue));
10046 theDI << aCamera->ZFocus() << " ";
10048 else if (anArgCase == "-zfocustype")
10050 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : "";
10051 TCollection_AsciiString anValueCase (anArgValue);
10052 anValueCase.LowerCase();
10053 if (anValueCase == "abs"
10054 || anValueCase == "absolute")
10057 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus());
10060 else if (anValueCase == "rel"
10061 || anValueCase == "relative")
10064 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus());
10067 else if (*anArgValue != '-')
10069 Message::SendFail() << "Error: unknown ZFocus type '" << anArgValue << "'";
10072 switch (aCamera->ZFocusType())
10074 case Graphic3d_Camera::FocusType_Absolute: theDI << "absolute "; break;
10075 case Graphic3d_Camera::FocusType_Relative: theDI << "relative "; break;
10078 else if (anArgCase == "-lockzup"
10079 || anArgCase == "-turntable")
10081 bool toLockUp = true;
10082 if (++anArgIter < theArgsNb
10083 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toLockUp))
10087 ViewerTest::CurrentEventManager()->SetLockOrbitZUp (toLockUp);
10089 else if (anArgCase == "-fov"
10090 || anArgCase == "-fovy"
10091 || anArgCase == "-fovx"
10092 || anArgCase == "-fov2d")
10094 Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL;
10095 if (anArgValue != NULL
10096 && *anArgValue != '-')
10099 if (anArgCase == "-fov2d")
10101 aCamera->SetFOV2d (Draw::Atof (anArgValue));
10103 else if (anArgCase == "-fovx")
10105 aCamera->SetFOVy (Draw::Atof (anArgValue) / aCamera->Aspect());///
10109 aCamera->SetFOVy (Draw::Atof (anArgValue));
10113 if (anArgCase == "-fov2d")
10115 theDI << aCamera->FOV2d() << " ";
10117 else if (anArgCase == "-fovx")
10119 theDI << aCamera->FOVx() << " ";
10123 theDI << aCamera->FOVy() << " ";
10126 else if (anArgIter + 1 < theArgsNb
10127 && anArgCase == "-xrpose")
10129 TCollection_AsciiString anXRArg (theArgVec[++anArgIter]);
10130 anXRArg.LowerCase();
10131 if (anXRArg == "base")
10133 aCamera = aView->View()->BaseXRCamera();
10135 else if (anXRArg == "head")
10137 aCamera = aView->View()->PosedXRCamera();
10141 Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'";
10144 if (aCamera.IsNull())
10146 Message::SendFail() << "Error: undefined XR pose";
10149 if (aView->AutoZFitMode())
10151 const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues (false);
10152 const Bnd_Box aGraphicBox = aView->View()->MinMaxValues (true);
10153 aCamera->ZFitAll (aView->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox);
10156 else if (aPrsName.IsEmpty()
10157 && !anArgCase.StartsWith ("-"))
10163 Message::SendFail() << "Error: unknown argument '" << anArg << "'";
10168 if (aPrsName.IsEmpty()
10174 if (!aPrsName.IsEmpty())
10176 Handle(AIS_CameraFrustum) aCameraFrustum;
10177 if (GetMapOfAIS().IsBound2 (aPrsName))
10179 // find existing object
10180 aCameraFrustum = Handle(AIS_CameraFrustum)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
10181 if (aCameraFrustum.IsNull())
10183 Message::SendFail() << "Error: object '" << aPrsName << "'is already defined and is not a camera frustum";
10188 if (aCameraFrustum.IsNull())
10190 aCameraFrustum = new AIS_CameraFrustum();
10194 // not include displayed object of old camera frustum in the new one.
10195 ViewerTest::GetAISContext()->Erase (aCameraFrustum, false);
10198 aCameraFrustum->SetCameraFrustum (aCamera);
10200 ViewerTest::Display (aPrsName, aCameraFrustum);
10206 //! Parse stereo output mode
10207 inline Standard_Boolean parseStereoMode (Standard_CString theArg,
10208 Graphic3d_StereoMode& theMode)
10210 TCollection_AsciiString aFlag (theArg);
10212 if (aFlag == "quadbuffer")
10214 theMode = Graphic3d_StereoMode_QuadBuffer;
10216 else if (aFlag == "anaglyph")
10218 theMode = Graphic3d_StereoMode_Anaglyph;
10220 else if (aFlag == "row"
10221 || aFlag == "rowinterlaced")
10223 theMode = Graphic3d_StereoMode_RowInterlaced;
10225 else if (aFlag == "col"
10226 || aFlag == "colinterlaced"
10227 || aFlag == "columninterlaced")
10229 theMode = Graphic3d_StereoMode_ColumnInterlaced;
10231 else if (aFlag == "chess"
10232 || aFlag == "chessboard")
10234 theMode = Graphic3d_StereoMode_ChessBoard;
10236 else if (aFlag == "sbs"
10237 || aFlag == "sidebyside")
10239 theMode = Graphic3d_StereoMode_SideBySide;
10241 else if (aFlag == "ou"
10242 || aFlag == "overunder")
10244 theMode = Graphic3d_StereoMode_OverUnder;
10246 else if (aFlag == "pageflip"
10247 || aFlag == "softpageflip")
10249 theMode = Graphic3d_StereoMode_SoftPageFlip;
10251 else if (aFlag == "openvr"
10254 theMode = Graphic3d_StereoMode_OpenVR;
10258 return Standard_False;
10260 return Standard_True;
10263 //! Parse anaglyph filter
10264 inline Standard_Boolean parseAnaglyphFilter (Standard_CString theArg,
10265 Graphic3d_RenderingParams::Anaglyph& theFilter)
10267 TCollection_AsciiString aFlag (theArg);
10269 if (aFlag == "redcyansimple")
10271 theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
10273 else if (aFlag == "redcyan"
10274 || aFlag == "redcyanoptimized")
10276 theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized;
10278 else if (aFlag == "yellowbluesimple")
10280 theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple;
10282 else if (aFlag == "yellowblue"
10283 || aFlag == "yellowblueoptimized")
10285 theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized;
10287 else if (aFlag == "greenmagenta"
10288 || aFlag == "greenmagentasimple")
10290 theFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple;
10294 return Standard_False;
10296 return Standard_True;
10299 //==============================================================================
10300 //function : VStereo
10302 //==============================================================================
10304 static int VStereo (Draw_Interpretor& theDI,
10305 Standard_Integer theArgNb,
10306 const char** theArgVec)
10308 Handle(V3d_View) aView = ViewerTest::CurrentView();
10311 if (aView.IsNull())
10313 Message::SendFail ("Error: no active viewer");
10317 Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
10318 theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
10321 TCollection_AsciiString aMode;
10322 switch (aView->RenderingParams().StereoMode)
10324 case Graphic3d_StereoMode_QuadBuffer : aMode = "quadBuffer"; break;
10325 case Graphic3d_StereoMode_RowInterlaced : aMode = "rowInterlaced"; break;
10326 case Graphic3d_StereoMode_ColumnInterlaced : aMode = "columnInterlaced"; break;
10327 case Graphic3d_StereoMode_ChessBoard : aMode = "chessBoard"; break;
10328 case Graphic3d_StereoMode_SideBySide : aMode = "sideBySide"; break;
10329 case Graphic3d_StereoMode_OverUnder : aMode = "overUnder"; break;
10330 case Graphic3d_StereoMode_SoftPageFlip : aMode = "softpageflip"; break;
10331 case Graphic3d_StereoMode_OpenVR : aMode = "openVR"; break;
10332 case Graphic3d_StereoMode_Anaglyph :
10333 aMode = "anaglyph";
10334 switch (aView->RenderingParams().AnaglyphFilter)
10336 case Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple : aMode.AssignCat (" (redCyanSimple)"); break;
10337 case Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized : aMode.AssignCat (" (redCyan)"); break;
10338 case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple : aMode.AssignCat (" (yellowBlueSimple)"); break;
10339 case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized: aMode.AssignCat (" (yellowBlue)"); break;
10340 case Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple : aMode.AssignCat (" (greenMagentaSimple)"); break;
10345 theDI << "Mode " << aMode << "\n";
10350 Handle(Graphic3d_Camera) aCamera;
10351 Graphic3d_RenderingParams* aParams = NULL;
10352 Graphic3d_StereoMode aMode = Graphic3d_StereoMode_QuadBuffer;
10353 if (!aView.IsNull())
10355 aParams = &aView->ChangeRenderingParams();
10356 aMode = aParams->StereoMode;
10357 aCamera = aView->Camera();
10360 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
10361 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
10363 Standard_CString anArg = theArgVec[anArgIter];
10364 TCollection_AsciiString aFlag (anArg);
10366 if (anUpdateTool.parseRedrawMode (aFlag))
10370 else if (aFlag == "0"
10373 if (++anArgIter < theArgNb)
10375 Message::SendFail ("Error: wrong number of arguments");
10379 if (!aCamera.IsNull()
10380 && aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
10382 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
10384 ViewerTest_myDefaultCaps.contextStereo = Standard_False;
10387 else if (aFlag == "1"
10390 if (++anArgIter < theArgNb)
10392 Message::SendFail ("Error: wrong number of arguments");
10396 if (!aCamera.IsNull())
10398 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
10400 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
10401 if (aParams->StereoMode != Graphic3d_StereoMode_OpenVR)
10406 else if (aFlag == "-reverse"
10407 || aFlag == "-reversed"
10408 || aFlag == "-swap")
10410 Standard_Boolean toEnable = Standard_True;
10411 if (++anArgIter < theArgNb
10412 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
10416 aParams->ToReverseStereo = toEnable;
10418 else if (aFlag == "-noreverse"
10419 || aFlag == "-noswap")
10421 Standard_Boolean toDisable = Standard_True;
10422 if (++anArgIter < theArgNb
10423 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
10427 aParams->ToReverseStereo = !toDisable;
10429 else if (aFlag == "-mode"
10430 || aFlag == "-stereomode")
10432 if (++anArgIter >= theArgNb
10433 || !parseStereoMode (theArgVec[anArgIter], aMode))
10435 Message::SendFail() << "Syntax error at '" << anArg << "'";
10439 if (aMode == Graphic3d_StereoMode_QuadBuffer)
10441 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
10444 else if (aFlag == "-anaglyph"
10445 || aFlag == "-anaglyphfilter")
10447 Graphic3d_RenderingParams::Anaglyph aFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple;
10448 if (++anArgIter >= theArgNb
10449 || !parseAnaglyphFilter (theArgVec[anArgIter], aFilter))
10451 Message::SendFail() << "Syntax error at '" << anArg << "'";
10455 aMode = Graphic3d_StereoMode_Anaglyph;
10456 aParams->AnaglyphFilter = aFilter;
10458 else if (parseStereoMode (anArg, aMode)) // short syntax
10460 if (aMode == Graphic3d_StereoMode_QuadBuffer)
10462 ViewerTest_myDefaultCaps.contextStereo = Standard_True;
10465 else if (anArgIter + 1 < theArgNb
10466 && aFlag == "-hmdfov2d")
10468 aParams->HmdFov2d = (float )Draw::Atof (theArgVec[++anArgIter]);
10469 if (aParams->HmdFov2d < 10.0f
10470 || aParams->HmdFov2d > 180.0f)
10472 Message::SendFail() << "Error: FOV is out of range";
10476 else if (aFlag == "-mirror"
10477 || aFlag == "-mirrorcomposer")
10479 Standard_Boolean toEnable = Standard_True;
10480 if (++anArgIter < theArgNb
10481 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
10485 aParams->ToMirrorComposer = toEnable;
10487 else if (anArgIter + 1 < theArgNb
10488 && (aFlag == "-unitfactor"
10489 || aFlag == "-unitscale"))
10491 aView->View()->SetUnitFactor (Draw::Atof (theArgVec[++anArgIter]));
10495 Message::SendFail() << "Syntax error at '" << anArg << "'";
10500 if (!aView.IsNull())
10502 aParams->StereoMode = aMode;
10503 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
10504 if (aParams->StereoMode == Graphic3d_StereoMode_OpenVR)
10506 // initiate implicit continuous rendering
10507 ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
10513 //===============================================================================================
10514 //function : VDefaults
10516 //===============================================================================================
10517 static int VDefaults (Draw_Interpretor& theDi,
10518 Standard_Integer theArgsNb,
10519 const char** theArgVec)
10521 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
10524 Message::SendFail ("Error: no active viewer");
10528 Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer();
10531 if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE)
10533 theDi << "DeflType: relative\n"
10534 << "DeviationCoeff: " << aDefParams->DeviationCoefficient() << "\n";
10538 theDi << "DeflType: absolute\n"
10539 << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n";
10541 theDi << "AngularDeflection: " << (180.0 * aDefParams->DeviationAngle() / M_PI) << "\n";
10542 theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n";
10546 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
10548 TCollection_AsciiString anArg (theArgVec[anArgIter]);
10550 if (anArg == "-ABSDEFL"
10551 || anArg == "-ABSOLUTEDEFLECTION"
10552 || anArg == "-DEFL"
10553 || anArg == "-DEFLECTION")
10555 if (++anArgIter >= theArgsNb)
10557 Message::SendFail() << "Syntax error at " << anArg;
10560 aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
10561 aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter]));
10563 else if (anArg == "-RELDEFL"
10564 || anArg == "-RELATIVEDEFLECTION"
10565 || anArg == "-DEVCOEFF"
10566 || anArg == "-DEVIATIONCOEFF"
10567 || anArg == "-DEVIATIONCOEFFICIENT")
10569 if (++anArgIter >= theArgsNb)
10571 Message::SendFail() << "Syntax error at " << anArg;
10574 aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
10575 aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter]));
10577 else if (anArg == "-ANGDEFL"
10578 || anArg == "-ANGULARDEFL"
10579 || anArg == "-ANGULARDEFLECTION")
10581 if (++anArgIter >= theArgsNb)
10583 Message::SendFail() << "Syntax error at " << anArg;
10586 aDefParams->SetDeviationAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0);
10588 else if (anArg == "-AUTOTR"
10589 || anArg == "-AUTOTRIANG"
10590 || anArg == "-AUTOTRIANGULATION")
10593 bool toTurnOn = true;
10594 if (anArgIter >= theArgsNb
10595 || !ViewerTest::ParseOnOff (theArgVec[anArgIter], toTurnOn))
10597 Message::SendFail() << "Syntax error at '" << anArg << "'";
10600 aDefParams->SetAutoTriangulation (toTurnOn);
10604 Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'";
10612 //! Auxiliary method
10613 inline void addLight (const Handle(V3d_Light)& theLightNew,
10614 const Graphic3d_ZLayerId theLayer,
10615 const Standard_Boolean theIsGlobal)
10617 if (theLightNew.IsNull())
10622 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
10623 if (theLayer == Graphic3d_ZLayerId_UNKNOWN)
10625 aViewer->AddLight (theLightNew);
10628 aViewer->SetLightOn (theLightNew);
10632 ViewerTest::CurrentView()->SetLightOn (theLightNew);
10637 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (theLayer);
10638 if (aSettings.Lights().IsNull())
10640 aSettings.SetLights (new Graphic3d_LightSet());
10642 aSettings.Lights()->Add (theLightNew);
10643 aViewer->SetZLayerSettings (theLayer, aSettings);
10647 //! Auxiliary method
10648 inline Standard_Integer getLightId (const TCollection_AsciiString& theArgNext)
10650 TCollection_AsciiString anArgNextCase (theArgNext);
10651 anArgNextCase.UpperCase();
10652 if (anArgNextCase.Length() > 5
10653 && anArgNextCase.SubString (1, 5).IsEqual ("LIGHT"))
10655 return theArgNext.SubString (6, theArgNext.Length()).IntegerValue();
10659 return theArgNext.IntegerValue();
10663 //===============================================================================================
10664 //function : VLight
10666 //===============================================================================================
10667 static int VLight (Draw_Interpretor& theDi,
10668 Standard_Integer theArgsNb,
10669 const char** theArgVec)
10671 Handle(V3d_View) aView = ViewerTest::CurrentView();
10672 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
10674 || aViewer.IsNull())
10676 Message::SendFail ("Error: no active viewer");
10680 Standard_Real anXYZ[3] = {};
10681 Standard_Real anAtten[2] = {};
10684 // print lights info
10685 Standard_Integer aLightId = 0;
10686 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightId)
10688 Handle(V3d_Light) aLight = aLightIter.Value();
10689 const Quantity_Color aColor = aLight->Color();
10690 theDi << "Light #" << aLightId
10691 << (!aLight->Name().IsEmpty() ? (TCollection_AsciiString(" ") + aLight->Name()) : "")
10692 << " [" << aLight->GetId() << "]" << "\n";
10693 switch (aLight->Type())
10697 theDi << " Type: Ambient\n";
10698 theDi << " Intensity: " << aLight->Intensity() << "\n";
10701 case V3d_DIRECTIONAL:
10703 theDi << " Type: Directional\n";
10704 theDi << " Intensity: " << aLight->Intensity() << "\n";
10705 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
10706 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
10707 aLight->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
10708 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10711 case V3d_POSITIONAL:
10713 theDi << " Type: Positional\n";
10714 theDi << " Intensity: " << aLight->Intensity() << "\n";
10715 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
10716 theDi << " Smoothness: " << aLight->Smoothness() << "\n";
10717 aLight->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
10718 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10719 aLight->Attenuation (anAtten[0], anAtten[1]);
10720 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
10721 theDi << " Range: " << aLight->Range() << "\n";
10726 theDi << " Type: Spot\n";
10727 theDi << " Intensity: " << aLight->Intensity() << "\n";
10728 theDi << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
10729 aLight->Position (anXYZ[0], anXYZ[1], anXYZ[2]);
10730 theDi << " Position: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10731 aLight->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
10732 theDi << " Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
10733 aLight->Attenuation (anAtten[0], anAtten[1]);
10734 theDi << " Atten.: " << anAtten[0] << " " << anAtten[1] << "\n";
10735 theDi << " Angle: " << (aLight->Angle() * 180.0 / M_PI) << "\n";
10736 theDi << " Exponent: " << aLight->Concentration() << "\n";
10737 theDi << " Range: " << aLight->Range() << "\n";
10742 theDi << " Type: UNKNOWN\n";
10746 theDi << " Color: " << aColor.Red() << ", " << aColor.Green() << ", " << aColor.Blue() << " [" << Quantity_Color::StringName (aColor.Name()) << "]\n";
10750 Handle(V3d_Light) aLightNew;
10751 Handle(V3d_Light) aLightOld;
10752 Graphic3d_ZLayerId aLayer = Graphic3d_ZLayerId_UNKNOWN;
10753 Standard_Boolean isGlobal = Standard_True;
10754 Standard_Boolean toCreate = Standard_False;
10755 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
10756 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
10758 Handle(V3d_Light) aLightCurr = aLightNew.IsNull() ? aLightOld : aLightNew;
10760 TCollection_AsciiString aName, aValue;
10761 const TCollection_AsciiString anArg (theArgVec[anArgIt]);
10762 TCollection_AsciiString anArgCase (anArg);
10763 anArgCase.UpperCase();
10764 if (anUpdateTool.parseRedrawMode (anArg))
10769 if (anArgCase.IsEqual ("NEW")
10770 || anArgCase.IsEqual ("ADD")
10771 || anArgCase.IsEqual ("CREATE")
10772 || anArgCase.IsEqual ("-NEW")
10773 || anArgCase.IsEqual ("-ADD")
10774 || anArgCase.IsEqual ("-CREATE"))
10776 toCreate = Standard_True;
10778 else if (anArgCase.IsEqual ("-LAYER")
10779 || anArgCase.IsEqual ("-ZLAYER"))
10781 if (++anArgIt >= theArgsNb)
10783 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10787 TCollection_AsciiString aValStr (theArgVec[anArgIt]);
10788 aValStr.LowerCase();
10789 if (aValStr == "default"
10790 || aValStr == "def")
10792 aLayer = Graphic3d_ZLayerId_Default;
10794 else if (aValStr == "top")
10796 aLayer = Graphic3d_ZLayerId_Top;
10798 else if (aValStr == "topmost")
10800 aLayer = Graphic3d_ZLayerId_Topmost;
10802 else if (aValStr == "toposd"
10803 || aValStr == "osd")
10805 aLayer = Graphic3d_ZLayerId_TopOSD;
10807 else if (aValStr == "botosd"
10808 || aValStr == "bottom")
10810 aLayer = Graphic3d_ZLayerId_BotOSD;
10812 else if (aValStr.IsIntegerValue())
10814 aLayer = Draw::Atoi (theArgVec[anArgIt]);
10818 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10822 else if (anArgCase.IsEqual ("GLOB")
10823 || anArgCase.IsEqual ("GLOBAL")
10824 || anArgCase.IsEqual ("-GLOB")
10825 || anArgCase.IsEqual ("-GLOBAL"))
10827 isGlobal = Standard_True;
10829 else if (anArgCase.IsEqual ("LOC")
10830 || anArgCase.IsEqual ("LOCAL")
10831 || anArgCase.IsEqual ("-LOC")
10832 || anArgCase.IsEqual ("-LOCAL"))
10834 isGlobal = Standard_False;
10836 else if (anArgCase.IsEqual ("DEF")
10837 || anArgCase.IsEqual ("DEFAULTS")
10838 || anArgCase.IsEqual ("-DEF")
10839 || anArgCase.IsEqual ("-DEFAULTS"))
10841 toCreate = Standard_False;
10842 aViewer->SetDefaultLights();
10844 else if (anArgCase.IsEqual ("CLR")
10845 || anArgCase.IsEqual ("CLEAR")
10846 || anArgCase.IsEqual ("-CLR")
10847 || anArgCase.IsEqual ("-CLEAR"))
10849 toCreate = Standard_False;
10851 TColStd_SequenceOfInteger aLayers;
10852 aViewer->GetAllZLayers (aLayers);
10853 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
10855 if (aLayeriter.Value() == aLayer
10856 || aLayer == Graphic3d_ZLayerId_UNKNOWN)
10858 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
10859 aSettings.SetLights (Handle(Graphic3d_LightSet)());
10860 aViewer->SetZLayerSettings (aLayeriter.Value(), aSettings);
10861 if (aLayer != Graphic3d_ZLayerId_UNKNOWN)
10868 if (aLayer == Graphic3d_ZLayerId_UNKNOWN)
10870 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More();)
10872 Handle(V3d_Light) aLight = aLightIter.Value();
10873 aViewer->DelLight (aLight);
10874 aLightIter = aView->ActiveLightIterator();
10878 else if (anArgCase.IsEqual ("AMB")
10879 || anArgCase.IsEqual ("AMBIENT")
10880 || anArgCase.IsEqual ("AMBLIGHT"))
10884 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10888 addLight (aLightNew, aLayer, isGlobal);
10889 toCreate = Standard_False;
10890 aLightNew = new V3d_AmbientLight();
10892 else if (anArgCase.IsEqual ("DIRECTIONAL")
10893 || anArgCase.IsEqual ("DIRLIGHT"))
10897 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10901 addLight (aLightNew, aLayer, isGlobal);
10902 toCreate = Standard_False;
10903 aLightNew = new V3d_DirectionalLight();
10905 else if (anArgCase.IsEqual ("SPOT")
10906 || anArgCase.IsEqual ("SPOTLIGHT"))
10910 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10914 addLight (aLightNew, aLayer, isGlobal);
10915 toCreate = Standard_False;
10916 aLightNew = new V3d_SpotLight (gp_Pnt (0.0, 0.0, 0.0));
10918 else if (anArgCase.IsEqual ("POSLIGHT")
10919 || anArgCase.IsEqual ("POSITIONAL"))
10923 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10927 addLight (aLightNew, aLayer, isGlobal);
10928 toCreate = Standard_False;
10929 aLightNew = new V3d_PositionalLight (gp_Pnt (0.0, 0.0, 0.0));
10931 else if (anArgCase.IsEqual ("CHANGE")
10932 || anArgCase.IsEqual ("-CHANGE"))
10934 if (++anArgIt >= theArgsNb)
10936 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10940 addLight (aLightNew, aLayer, isGlobal);
10941 aLightNew.Nullify();
10942 const Standard_Integer aLightId = getLightId (theArgVec[anArgIt]);
10943 Standard_Integer aLightIt = 0;
10944 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt)
10946 if (aLightIt == aLightId)
10948 aLightOld = aLightIter.Value();
10953 if (aLightOld.IsNull())
10955 Message::SendFail() << "Error: Light " << theArgVec[anArgIt] << " is undefined";
10959 else if (anArgCase.IsEqual ("DEL")
10960 || anArgCase.IsEqual ("DELETE")
10961 || anArgCase.IsEqual ("-DEL")
10962 || anArgCase.IsEqual ("-DELETE"))
10964 Handle(V3d_Light) aLightDel;
10965 if (++anArgIt >= theArgsNb)
10967 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
10971 const TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
10972 const Standard_Integer aLightDelId = getLightId (theArgVec[anArgIt]);
10973 Standard_Integer aLightIt = 0;
10974 for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt)
10976 aLightDel = aLightIter.Value();
10977 if (aLightIt == aLightDelId)
10982 if (aLightDel.IsNull())
10987 TColStd_SequenceOfInteger aLayers;
10988 aViewer->GetAllZLayers (aLayers);
10989 for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
10991 if (aLayeriter.Value() == aLayer
10992 || aLayer == Graphic3d_ZLayerId_UNKNOWN)
10994 Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
10995 if (!aSettings.Lights().IsNull())
10997 aSettings.Lights()->Remove (aLightDel);
10998 if (aSettings.Lights()->IsEmpty())
11000 aSettings.SetLights (Handle(Graphic3d_LightSet)());
11003 aViewer->SetZLayerSettings (aLayeriter.Value(), aSettings);
11004 if (aLayer != Graphic3d_ZLayerId_UNKNOWN)
11011 if (aLayer == Graphic3d_ZLayerId_UNKNOWN)
11013 aViewer->DelLight (aLightDel);
11016 else if (anArgCase.IsEqual ("COLOR")
11017 || anArgCase.IsEqual ("COLOUR")
11018 || anArgCase.IsEqual ("-COLOR")
11019 || anArgCase.IsEqual ("-COLOUR"))
11021 if (++anArgIt >= theArgsNb
11022 || aLightCurr.IsNull())
11024 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11028 TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
11029 anArgNext.UpperCase();
11030 const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString());
11031 aLightCurr->SetColor (aColor);
11033 else if (anArgCase.IsEqual ("POS")
11034 || anArgCase.IsEqual ("POSITION")
11035 || anArgCase.IsEqual ("-POS")
11036 || anArgCase.IsEqual ("-POSITION"))
11038 if ((anArgIt + 3) >= theArgsNb
11039 || aLightCurr.IsNull()
11040 || (aLightCurr->Type() != Graphic3d_TOLS_POSITIONAL
11041 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11043 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11047 anXYZ[0] = Atof (theArgVec[++anArgIt]);
11048 anXYZ[1] = Atof (theArgVec[++anArgIt]);
11049 anXYZ[2] = Atof (theArgVec[++anArgIt]);
11050 aLightCurr->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
11052 else if (anArgCase.IsEqual ("DIR")
11053 || anArgCase.IsEqual ("DIRECTION")
11054 || anArgCase.IsEqual ("-DIR")
11055 || anArgCase.IsEqual ("-DIRECTION"))
11057 if ((anArgIt + 3) >= theArgsNb
11058 || aLightCurr.IsNull()
11059 || (aLightCurr->Type() != Graphic3d_TOLS_DIRECTIONAL
11060 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11062 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11066 anXYZ[0] = Atof (theArgVec[++anArgIt]);
11067 anXYZ[1] = Atof (theArgVec[++anArgIt]);
11068 anXYZ[2] = Atof (theArgVec[++anArgIt]);
11069 aLightCurr->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
11071 else if (anArgCase.IsEqual ("SM")
11072 || anArgCase.IsEqual ("SMOOTHNESS")
11073 || anArgCase.IsEqual ("-SM")
11074 || anArgCase.IsEqual ("-SMOOTHNESS"))
11076 if (++anArgIt >= theArgsNb
11077 || aLightCurr.IsNull())
11079 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11083 Standard_ShortReal aSmoothness = (Standard_ShortReal )Atof (theArgVec[anArgIt]);
11084 if (Abs (aSmoothness) <= ShortRealEpsilon())
11086 aLightCurr->SetIntensity (1.f);
11088 else if (Abs (aLightCurr->Smoothness()) <= ShortRealEpsilon())
11090 aLightCurr->SetIntensity ((aSmoothness * aSmoothness) / 3.f);
11094 Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightCurr->Smoothness());
11095 aLightCurr->SetIntensity (aLightCurr->Intensity() / (aSmoothnessRatio * aSmoothnessRatio));
11098 if (aLightCurr->Type() == Graphic3d_TOLS_POSITIONAL)
11100 aLightCurr->SetSmoothRadius (aSmoothness);
11102 else if (aLightCurr->Type() == Graphic3d_TOLS_DIRECTIONAL)
11104 aLightCurr->SetSmoothAngle (aSmoothness);
11107 else if (anArgCase.IsEqual ("INT")
11108 || anArgCase.IsEqual ("INTENSITY")
11109 || anArgCase.IsEqual ("-INT")
11110 || anArgCase.IsEqual ("-INTENSITY"))
11112 if (++anArgIt >= theArgsNb
11113 || aLightCurr.IsNull())
11115 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11119 Standard_ShortReal aIntensity = (Standard_ShortReal )Atof (theArgVec[anArgIt]);
11120 aLightCurr->SetIntensity (aIntensity);
11122 else if (anArgCase.IsEqual ("ANG")
11123 || anArgCase.IsEqual ("ANGLE")
11124 || anArgCase.IsEqual ("-ANG")
11125 || anArgCase.IsEqual ("-ANGLE"))
11127 if (++anArgIt >= theArgsNb
11128 || aLightCurr.IsNull()
11129 || aLightCurr->Type() != Graphic3d_TOLS_SPOT)
11131 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11135 Standard_ShortReal anAngle = (Standard_ShortReal )Atof (theArgVec[anArgIt]);
11136 aLightCurr->SetAngle (Standard_ShortReal (anAngle / 180.0 * M_PI));
11138 else if (anArgCase.IsEqual ("CONSTATTEN")
11139 || anArgCase.IsEqual ("CONSTATTENUATION")
11140 || anArgCase.IsEqual ("-CONSTATTEN")
11141 || anArgCase.IsEqual ("-CONSTATTENUATION"))
11143 if (++anArgIt >= theArgsNb
11144 || aLightCurr.IsNull()
11145 || (aLightCurr->Type() != Graphic3d_TOLS_POSITIONAL
11146 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11148 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11152 aLightCurr->Attenuation (anAtten[0], anAtten[1]);
11153 anAtten[0] = Atof (theArgVec[anArgIt]);
11154 aLightCurr->SetAttenuation ((Standard_ShortReal )anAtten[0], (Standard_ShortReal )anAtten[1]);
11156 else if (anArgCase.IsEqual ("LINATTEN")
11157 || anArgCase.IsEqual ("LINEARATTEN")
11158 || anArgCase.IsEqual ("LINEARATTENUATION")
11159 || anArgCase.IsEqual ("-LINATTEN")
11160 || anArgCase.IsEqual ("-LINEARATTEN")
11161 || anArgCase.IsEqual ("-LINEARATTENUATION"))
11163 if (++anArgIt >= theArgsNb
11164 || aLightCurr.IsNull()
11165 || (aLightCurr->Type() != Graphic3d_TOLS_POSITIONAL
11166 && aLightCurr->Type() != Graphic3d_TOLS_SPOT))
11168 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11172 aLightCurr->Attenuation (anAtten[0], anAtten[1]);
11173 anAtten[1] = Atof (theArgVec[anArgIt]);
11174 aLightCurr->SetAttenuation ((Standard_ShortReal )anAtten[0], (Standard_ShortReal )anAtten[1]);
11176 else if (anArgCase.IsEqual ("EXP")
11177 || anArgCase.IsEqual ("EXPONENT")
11178 || anArgCase.IsEqual ("SPOTEXP")
11179 || anArgCase.IsEqual ("SPOTEXPONENT")
11180 || anArgCase.IsEqual ("-EXP")
11181 || anArgCase.IsEqual ("-EXPONENT")
11182 || anArgCase.IsEqual ("-SPOTEXP")
11183 || anArgCase.IsEqual ("-SPOTEXPONENT"))
11185 if (++anArgIt >= theArgsNb
11186 || aLightCurr.IsNull()
11187 || aLightCurr->Type() != Graphic3d_TOLS_SPOT)
11189 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11193 aLightCurr->SetConcentration ((Standard_ShortReal )Atof (theArgVec[anArgIt]));
11195 else if (anArgCase.IsEqual("RANGE")
11196 || anArgCase.IsEqual("-RANGE"))
11198 if (++anArgIt >= theArgsNb
11199 || aLightCurr.IsNull()
11200 || aLightCurr->Type() == Graphic3d_TOLS_AMBIENT
11201 || aLightCurr->Type() == Graphic3d_TOLS_DIRECTIONAL)
11203 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11207 aLightCurr->SetRange ((Standard_ShortReal)Atof (theArgVec[anArgIt]));
11209 else if (anArgCase.IsEqual ("HEAD")
11210 || anArgCase.IsEqual ("HEADLIGHT")
11211 || anArgCase.IsEqual ("-HEAD")
11212 || anArgCase.IsEqual ("-HEADLIGHT"))
11214 if (aLightCurr.IsNull()
11215 || aLightCurr->Type() == Graphic3d_TOLS_AMBIENT)
11217 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11221 Standard_Boolean isHeadLight = Standard_True;
11222 if (anArgIt + 1 < theArgsNb
11223 && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], isHeadLight))
11227 aLightCurr->SetHeadlight (isHeadLight);
11231 Message::SendFail() << "Warning: unknown argument '" << anArg << "'";
11235 addLight (aLightNew, aLayer, isGlobal);
11239 //===============================================================================================
11240 //function : VPBREnvironment
11242 //===============================================================================================
11243 static int VPBREnvironment (Draw_Interpretor&,
11244 Standard_Integer theArgsNb,
11245 const char** theArgVec)
11249 Message::SendFail ("Syntax error: 'vpbrenv' command has only one argument");
11253 Handle(V3d_View) aView = ViewerTest::CurrentView();
11254 if (aView.IsNull())
11256 Message::SendFail ("Error: no active viewer");
11260 TCollection_AsciiString anArg = TCollection_AsciiString (theArgVec[1]);
11263 if (anArg == "-generate"
11264 || anArg == "-gen")
11266 aView->GeneratePBREnvironment (Standard_True);
11268 else if (anArg == "-clear")
11270 aView->ClearPBREnvironment (Standard_True);
11274 Message::SendFail() << "Syntax error: unknown argument [" << theArgVec[1] << "] for 'vpbrenv' command";
11281 //! Read Graphic3d_RenderingParams::PerfCounters flag.
11282 static Standard_Boolean parsePerfStatsFlag (const TCollection_AsciiString& theValue,
11283 Standard_Boolean& theToReset,
11284 Graphic3d_RenderingParams::PerfCounters& theFlagsRem,
11285 Graphic3d_RenderingParams::PerfCounters& theFlagsAdd)
11287 Graphic3d_RenderingParams::PerfCounters aFlag = Graphic3d_RenderingParams::PerfCounters_NONE;
11288 TCollection_AsciiString aVal = theValue;
11289 Standard_Boolean toReverse = Standard_False;
11290 if (aVal == "none")
11292 theToReset = Standard_True;
11293 return Standard_True;
11295 else if (aVal.StartsWith ("-"))
11297 toReverse = Standard_True;
11298 aVal = aVal.SubString (2, aVal.Length());
11300 else if (aVal.StartsWith ("no"))
11302 toReverse = Standard_True;
11303 aVal = aVal.SubString (3, aVal.Length());
11305 else if (aVal.StartsWith ("+"))
11307 aVal = aVal.SubString (2, aVal.Length());
11311 theToReset = Standard_True;
11315 || aVal == "framerate") aFlag = Graphic3d_RenderingParams::PerfCounters_FrameRate;
11316 else if (aVal == "cpu") aFlag = Graphic3d_RenderingParams::PerfCounters_CPU;
11317 else if (aVal == "layers") aFlag = Graphic3d_RenderingParams::PerfCounters_Layers;
11318 else if (aVal == "structs"
11319 || aVal == "structures"
11320 || aVal == "objects") aFlag = Graphic3d_RenderingParams::PerfCounters_Structures;
11321 else if (aVal == "groups") aFlag = Graphic3d_RenderingParams::PerfCounters_Groups;
11322 else if (aVal == "arrays") aFlag = Graphic3d_RenderingParams::PerfCounters_GroupArrays;
11323 else if (aVal == "tris"
11324 || aVal == "triangles") aFlag = Graphic3d_RenderingParams::PerfCounters_Triangles;
11325 else if (aVal == "pnts"
11326 || aVal == "points") aFlag = Graphic3d_RenderingParams::PerfCounters_Points;
11327 else if (aVal == "lines") aFlag = Graphic3d_RenderingParams::PerfCounters_Lines;
11328 else if (aVal == "mem"
11329 || aVal == "gpumem"
11330 || aVal == "estimmem") aFlag = Graphic3d_RenderingParams::PerfCounters_EstimMem;
11331 else if (aVal == "skipimmediate"
11332 || aVal == "noimmediate") aFlag = Graphic3d_RenderingParams::PerfCounters_SkipImmediate;
11333 else if (aVal == "frametime"
11334 || aVal == "frametimers"
11335 || aVal == "time") aFlag = Graphic3d_RenderingParams::PerfCounters_FrameTime;
11336 else if (aVal == "basic") aFlag = Graphic3d_RenderingParams::PerfCounters_Basic;
11337 else if (aVal == "extended"
11338 || aVal == "verbose"
11339 || aVal == "extra") aFlag = Graphic3d_RenderingParams::PerfCounters_Extended;
11340 else if (aVal == "full"
11341 || aVal == "all") aFlag = Graphic3d_RenderingParams::PerfCounters_All;
11344 return Standard_False;
11349 theFlagsRem = Graphic3d_RenderingParams::PerfCounters(theFlagsRem | aFlag);
11353 theFlagsAdd = Graphic3d_RenderingParams::PerfCounters(theFlagsAdd | aFlag);
11355 return Standard_True;
11358 //! Read Graphic3d_RenderingParams::PerfCounters flags.
11359 static Standard_Boolean convertToPerfStatsFlags (const TCollection_AsciiString& theValue,
11360 Graphic3d_RenderingParams::PerfCounters& theFlags)
11362 TCollection_AsciiString aValue = theValue;
11363 Graphic3d_RenderingParams::PerfCounters aFlagsRem = Graphic3d_RenderingParams::PerfCounters_NONE;
11364 Graphic3d_RenderingParams::PerfCounters aFlagsAdd = Graphic3d_RenderingParams::PerfCounters_NONE;
11365 Standard_Boolean toReset = Standard_False;
11368 Standard_Integer aSplitPos = aValue.Search ("|");
11369 if (aSplitPos <= 0)
11371 if (!parsePerfStatsFlag (aValue, toReset, aFlagsRem, aFlagsAdd))
11373 return Standard_False;
11377 theFlags = Graphic3d_RenderingParams::PerfCounters_NONE;
11379 theFlags = Graphic3d_RenderingParams::PerfCounters(theFlags | aFlagsAdd);
11380 theFlags = Graphic3d_RenderingParams::PerfCounters(theFlags & ~aFlagsRem);
11381 return Standard_True;
11386 TCollection_AsciiString aSubValue = aValue.SubString (1, aSplitPos - 1);
11387 if (!parsePerfStatsFlag (aSubValue, toReset, aFlagsRem, aFlagsAdd))
11389 return Standard_False;
11392 aValue = aValue.SubString (aSplitPos + 1, aValue.Length());
11396 //=======================================================================
11397 //function : VRenderParams
11398 //purpose : Enables/disables rendering features
11399 //=======================================================================
11401 static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
11402 Standard_Integer theArgNb,
11403 const char** theArgVec)
11405 Handle(V3d_View) aView = ViewerTest::CurrentView();
11406 if (aView.IsNull())
11408 Message::SendFail ("Error: no active viewer");
11412 Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
11413 TCollection_AsciiString aCmdName (theArgVec[0]);
11414 aCmdName.LowerCase();
11415 if (aCmdName == "vraytrace")
11419 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "on" : "off") << " ";
11422 else if (theArgNb == 2)
11424 TCollection_AsciiString aValue (theArgVec[1]);
11425 aValue.LowerCase();
11429 aParams.Method = Graphic3d_RM_RAYTRACING;
11433 else if (aValue == "off"
11436 aParams.Method = Graphic3d_RM_RASTERIZATION;
11442 Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[1] << "'";
11448 Message::SendFail ("Syntax error: wrong number of arguments");
11455 theDI << "renderMode: ";
11456 switch (aParams.Method)
11458 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
11459 case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break;
11462 theDI << "transparency: ";
11463 switch (aParams.TransparencyMethod)
11465 case Graphic3d_RTM_BLEND_UNORDERED: theDI << "Basic blended transparency with non-commuting operator "; break;
11466 case Graphic3d_RTM_BLEND_OIT: theDI << "Weighted Blended Order-Independent Transparency, depth weight factor: "
11467 << TCollection_AsciiString (aParams.OitDepthFactor); break;
11470 theDI << "msaa: " << aParams.NbMsaaSamples << "\n";
11471 theDI << "rendScale: " << aParams.RenderResolutionScale << "\n";
11472 theDI << "rayDepth: " << aParams.RaytracingDepth << "\n";
11473 theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n";
11474 theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n";
11475 theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
11476 theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
11477 theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
11478 theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n";
11479 theDI << "iss: " << (aParams.AdaptiveScreenSampling ? "on" : "off") << "\n";
11480 theDI << "iss debug: " << (aParams.ShowSamplingTiles ? "on" : "off") << "\n";
11481 theDI << "two-sided BSDF: " << (aParams.TwoSidedBsdfModels ? "on" : "off") << "\n";
11482 theDI << "max radiance: " << aParams.RadianceClampingValue << "\n";
11483 theDI << "nb tiles (iss): " << aParams.NbRayTracingTiles << "\n";
11484 theDI << "tile size (iss):" << aParams.RayTracingTileSize << "x" << aParams.RayTracingTileSize << "\n";
11485 theDI << "shadingModel: ";
11486 switch (aView->ShadingModel())
11488 case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
11489 case Graphic3d_TOSM_UNLIT: theDI << "unlit"; break;
11490 case Graphic3d_TOSM_FACET: theDI << "flat"; break;
11491 case Graphic3d_TOSM_VERTEX: theDI << "gouraud"; break;
11492 case Graphic3d_TOSM_FRAGMENT: theDI << "phong"; break;
11493 case Graphic3d_TOSM_PBR: theDI << "pbr"; break;
11494 case Graphic3d_TOSM_PBR_FACET: theDI << "pbr_facet"; break;
11497 theDI << "perfCounters:";
11498 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_FrameRate) != 0)
11502 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_CPU) != 0)
11506 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Structures) != 0)
11508 theDI << " structs";
11510 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Groups) != 0)
11512 theDI << " groups";
11514 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_GroupArrays) != 0)
11516 theDI << " arrays";
11518 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Triangles) != 0)
11522 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Lines) != 0)
11526 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Points) != 0)
11530 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_EstimMem) != 0)
11532 theDI << " gpumem";
11534 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_FrameTime) != 0)
11536 theDI << " frameTime";
11538 if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_SkipImmediate) != 0)
11540 theDI << " skipimmediate";
11542 if (aParams.CollectedStats == Graphic3d_RenderingParams::PerfCounters_NONE)
11548 theDI << "depth pre-pass: " << (aParams.ToEnableDepthPrepass ? "on" : "off") << "\n";
11549 theDI << "alpha to coverage: " << (aParams.ToEnableAlphaToCoverage ? "on" : "off") << "\n";
11550 theDI << "frustum culling: " << (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On ? "on" :
11551 aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off ? "off" :
11552 "noUpdate") << "\n";
11557 Standard_Boolean toPrint = Standard_False;
11558 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
11559 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
11561 Standard_CString anArg (theArgVec[anArgIter]);
11562 TCollection_AsciiString aFlag (anArg);
11564 if (anUpdateTool.parseRedrawMode (aFlag))
11568 else if (aFlag == "-echo"
11569 || aFlag == "-print")
11571 toPrint = Standard_True;
11572 anUpdateTool.Invalidate();
11574 else if (aFlag == "-mode"
11575 || aFlag == "-rendermode"
11576 || aFlag == "-render_mode")
11580 switch (aParams.Method)
11582 case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break;
11583 case Graphic3d_RM_RAYTRACING: theDI << "ray-tracing "; break;
11589 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11593 else if (aFlag == "-ray"
11594 || aFlag == "-raytrace")
11598 theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "true" : "false") << " ";
11602 aParams.Method = Graphic3d_RM_RAYTRACING;
11604 else if (aFlag == "-rast"
11605 || aFlag == "-raster"
11606 || aFlag == "-rasterization")
11610 theDI << (aParams.Method == Graphic3d_RM_RASTERIZATION ? "true" : "false") << " ";
11614 aParams.Method = Graphic3d_RM_RASTERIZATION;
11616 else if (aFlag == "-msaa")
11620 theDI << aParams.NbMsaaSamples << " ";
11623 else if (++anArgIter >= theArgNb)
11625 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11629 const Standard_Integer aNbSamples = Draw::Atoi (theArgVec[anArgIter]);
11630 if (aNbSamples < 0)
11632 Message::SendFail() << "Syntax error: invalid number of MSAA samples " << aNbSamples << "";
11637 aParams.NbMsaaSamples = aNbSamples;
11640 else if (aFlag == "-linefeather"
11641 || aFlag == "-edgefeather"
11642 || aFlag == "-feather")
11646 theDI << " " << aParams.LineFeather << " ";
11649 else if (++anArgIter >= theArgNb)
11651 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11655 TCollection_AsciiString aParam = theArgVec[anArgIter];
11656 const Standard_ShortReal aFeather = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
11657 if (aFeather <= 0.0f)
11659 Message::SendFail() << "Syntax error: invalid value of line width feather " << aFeather << ". Should be > 0";
11662 aParams.LineFeather = aFeather;
11664 else if (aFlag == "-oit")
11668 if (aParams.TransparencyMethod == Graphic3d_RTM_BLEND_OIT)
11670 theDI << "on, depth weight factor: " << TCollection_AsciiString (aParams.OitDepthFactor) << " ";
11674 theDI << "off" << " ";
11678 else if (++anArgIter >= theArgNb)
11680 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11684 TCollection_AsciiString aParam = theArgVec[anArgIter];
11685 aParam.LowerCase();
11686 if (aParam.IsRealValue())
11688 const Standard_ShortReal aWeight = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
11689 if (aWeight < 0.f || aWeight > 1.f)
11691 Message::SendFail() << "Syntax error: invalid value of Weighted Order-Independent Transparency depth weight factor " << aWeight << ". Should be within range [0.0; 1.0]";
11695 aParams.TransparencyMethod = Graphic3d_RTM_BLEND_OIT;
11696 aParams.OitDepthFactor = aWeight;
11698 else if (aParam == "off")
11700 aParams.TransparencyMethod = Graphic3d_RTM_BLEND_UNORDERED;
11704 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11708 else if (aFlag == "-depthprepass")
11712 theDI << (aParams.ToEnableDepthPrepass ? "on " : "off ");
11715 aParams.ToEnableDepthPrepass = Standard_True;
11716 if (anArgIter + 1 < theArgNb
11717 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableDepthPrepass))
11722 else if (aFlag == "-samplealphatocoverage"
11723 || aFlag == "-alphatocoverage")
11727 theDI << (aParams.ToEnableAlphaToCoverage ? "on " : "off ");
11730 aParams.ToEnableAlphaToCoverage = Standard_True;
11731 if (anArgIter + 1 < theArgNb
11732 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableAlphaToCoverage))
11737 else if (aFlag == "-rendscale"
11738 || aFlag == "-renderscale"
11739 || aFlag == "-renderresolutionscale")
11743 theDI << aParams.RenderResolutionScale << " ";
11746 else if (++anArgIter >= theArgNb)
11748 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11752 const Standard_Real aScale = Draw::Atof (theArgVec[anArgIter]);
11755 Message::SendFail() << "Syntax error: invalid rendering resolution scale " << aScale << "";
11760 aParams.RenderResolutionScale = Standard_ShortReal(aScale);
11763 else if (aFlag == "-raydepth"
11764 || aFlag == "-ray_depth")
11768 theDI << aParams.RaytracingDepth << " ";
11771 else if (++anArgIter >= theArgNb)
11773 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11777 const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]);
11779 // We allow RaytracingDepth be more than 10 in case of GI enabled
11780 if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled))
11782 Message::SendFail() << "Syntax error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]";
11787 aParams.RaytracingDepth = aDepth;
11790 else if (aFlag == "-shad"
11791 || aFlag == "-shadows")
11795 theDI << (aParams.IsShadowEnabled ? "on" : "off") << " ";
11799 Standard_Boolean toEnable = Standard_True;
11800 if (++anArgIter < theArgNb
11801 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11805 aParams.IsShadowEnabled = toEnable;
11807 else if (aFlag == "-refl"
11808 || aFlag == "-reflections")
11812 theDI << (aParams.IsReflectionEnabled ? "on" : "off") << " ";
11816 Standard_Boolean toEnable = Standard_True;
11817 if (++anArgIter < theArgNb
11818 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11822 aParams.IsReflectionEnabled = toEnable;
11824 else if (aFlag == "-fsaa")
11828 theDI << (aParams.IsAntialiasingEnabled ? "on" : "off") << " ";
11832 Standard_Boolean toEnable = Standard_True;
11833 if (++anArgIter < theArgNb
11834 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11838 aParams.IsAntialiasingEnabled = toEnable;
11840 else if (aFlag == "-gleam")
11844 theDI << (aParams.IsTransparentShadowEnabled ? "on" : "off") << " ";
11848 Standard_Boolean toEnable = Standard_True;
11849 if (++anArgIter < theArgNb
11850 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11854 aParams.IsTransparentShadowEnabled = toEnable;
11856 else if (aFlag == "-gi")
11860 theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " ";
11864 Standard_Boolean toEnable = Standard_True;
11865 if (++anArgIter < theArgNb
11866 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11870 aParams.IsGlobalIlluminationEnabled = toEnable;
11873 aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
11876 else if (aFlag == "-blockedrng"
11877 || aFlag == "-brng")
11881 theDI << (aParams.CoherentPathTracingMode ? "on" : "off") << " ";
11885 Standard_Boolean toEnable = Standard_True;
11886 if (++anArgIter < theArgNb
11887 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11891 aParams.CoherentPathTracingMode = toEnable;
11893 else if (aFlag == "-maxrad")
11897 theDI << aParams.RadianceClampingValue << " ";
11900 else if (++anArgIter >= theArgNb)
11902 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11906 const TCollection_AsciiString aMaxRadStr = theArgVec[anArgIter];
11907 if (!aMaxRadStr.IsRealValue())
11909 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11913 const Standard_Real aMaxRadiance = aMaxRadStr.RealValue();
11914 if (aMaxRadiance <= 0.0)
11916 Message::SendFail() << "Syntax error: invalid radiance clamping value " << aMaxRadiance;
11921 aParams.RadianceClampingValue = static_cast<Standard_ShortReal> (aMaxRadiance);
11924 else if (aFlag == "-iss")
11928 theDI << (aParams.AdaptiveScreenSampling ? "on" : "off") << " ";
11932 Standard_Boolean toEnable = Standard_True;
11933 if (++anArgIter < theArgNb
11934 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11938 aParams.AdaptiveScreenSampling = toEnable;
11940 else if (aFlag == "-issatomic")
11944 theDI << (aParams.AdaptiveScreenSamplingAtomic ? "on" : "off") << " ";
11948 Standard_Boolean toEnable = Standard_True;
11949 if (++anArgIter < theArgNb
11950 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11954 aParams.AdaptiveScreenSamplingAtomic = toEnable;
11956 else if (aFlag == "-issd")
11960 theDI << (aParams.ShowSamplingTiles ? "on" : "off") << " ";
11964 Standard_Boolean toEnable = Standard_True;
11965 if (++anArgIter < theArgNb
11966 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
11970 aParams.ShowSamplingTiles = toEnable;
11972 else if (aFlag == "-tilesize")
11976 theDI << aParams.RayTracingTileSize << " ";
11979 else if (++anArgIter >= theArgNb)
11981 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
11985 const Standard_Integer aTileSize = Draw::Atoi (theArgVec[anArgIter]);
11988 Message::SendFail() << "Syntax error: invalid size of ISS tile " << aTileSize;
11991 aParams.RayTracingTileSize = aTileSize;
11993 else if (aFlag == "-nbtiles")
11997 theDI << aParams.NbRayTracingTiles << " ";
12000 else if (++anArgIter >= theArgNb)
12002 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12006 const Standard_Integer aNbTiles = Draw::Atoi (theArgVec[anArgIter]);
12009 Message::SendFail() << "Syntax error: invalid number of ISS tiles " << aNbTiles;
12012 else if (aNbTiles > 0
12014 || aNbTiles > 1024))
12016 Message::SendWarning() << "Warning: suboptimal number of ISS tiles " << aNbTiles << ". Recommended range: [64, 1024].";
12018 aParams.NbRayTracingTiles = aNbTiles;
12020 else if (aFlag == "-env")
12024 theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " ";
12028 Standard_Boolean toEnable = Standard_True;
12029 if (++anArgIter < theArgNb
12030 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12034 aParams.UseEnvironmentMapBackground = toEnable;
12036 else if (aFlag == "-ignorenormalmap")
12040 theDI << (aParams.ToIgnoreNormalMapInRayTracing ? "on" : "off") << " ";
12044 Standard_Boolean toEnable = Standard_True;
12045 if (++anArgIter < theArgNb
12046 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12050 aParams.ToIgnoreNormalMapInRayTracing = toEnable;
12052 else if (aFlag == "-twoside")
12056 theDI << (aParams.TwoSidedBsdfModels ? "on" : "off") << " ";
12060 Standard_Boolean toEnable = Standard_True;
12061 if (++anArgIter < theArgNb
12062 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12066 aParams.TwoSidedBsdfModels = toEnable;
12068 else if (aFlag == "-shademodel"
12069 || aFlag == "-shadingmodel"
12070 || aFlag == "-shading")
12074 switch (aView->ShadingModel())
12076 case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
12077 case Graphic3d_TOSM_UNLIT: theDI << "unlit "; break;
12078 case Graphic3d_TOSM_FACET: theDI << "flat "; break;
12079 case Graphic3d_TOSM_VERTEX: theDI << "gouraud "; break;
12080 case Graphic3d_TOSM_FRAGMENT: theDI << "phong "; break;
12081 case Graphic3d_TOSM_PBR: theDI << "pbr"; break;
12082 case Graphic3d_TOSM_PBR_FACET: theDI << "pbr_facet"; break;
12087 if (++anArgIter >= theArgNb)
12089 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12092 Graphic3d_TypeOfShadingModel aModel = Graphic3d_TOSM_DEFAULT;
12093 if (ViewerTest::ParseShadingModel (theArgVec[anArgIter], aModel)
12094 && aModel != Graphic3d_TOSM_DEFAULT)
12096 aView->SetShadingModel (aModel);
12100 Message::SendFail() << "Syntax error: unknown shading model '" << theArgVec[anArgIter] << "'";
12104 else if (aFlag == "-pbrenvpow2size"
12105 || aFlag == "-pbrenvp2s"
12106 || aFlag == "-pep2s")
12108 if (++anArgIter >= theArgNb)
12110 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12114 const Standard_Integer aPbrEnvPow2Size = Draw::Atoi (theArgVec[anArgIter]);
12115 if (aPbrEnvPow2Size < 1)
12117 Message::SendFail ("Syntax error: 'Pow2Size' of PBR Environment has to be greater or equal 1");
12120 aParams.PbrEnvPow2Size = aPbrEnvPow2Size;
12122 else if (aFlag == "-pbrenvspecmaplevelsnumber"
12123 || aFlag == "-pbrenvspecmapnblevels"
12124 || aFlag == "-pbrenvspecmaplevels"
12125 || aFlag == "-pbrenvsmln"
12126 || aFlag == "-pesmln")
12128 if (++anArgIter >= theArgNb)
12130 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12134 const Standard_Integer aPbrEnvSpecMapNbLevels = Draw::Atoi (theArgVec[anArgIter]);
12135 if (aPbrEnvSpecMapNbLevels < 2)
12137 Message::SendFail ("Syntax error: 'SpecMapLevelsNumber' of PBR Environment has to be greater or equal 2");
12140 aParams.PbrEnvSpecMapNbLevels = aPbrEnvSpecMapNbLevels;
12142 else if (aFlag == "-pbrenvbakngdiffsamplesnumber"
12143 || aFlag == "-pbrenvbakingdiffsamples"
12144 || aFlag == "-pbrenvbdsn")
12146 if (++anArgIter >= theArgNb)
12148 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12152 const Standard_Integer aPbrEnvBakingDiffNbSamples = Draw::Atoi (theArgVec[anArgIter]);
12153 if (aPbrEnvBakingDiffNbSamples < 1)
12155 Message::SendFail ("Syntax error: 'BakingDiffSamplesNumber' of PBR Environtment has to be greater or equal 1");
12158 aParams.PbrEnvBakingDiffNbSamples = aPbrEnvBakingDiffNbSamples;
12160 else if (aFlag == "-pbrenvbakngspecsamplesnumber"
12161 || aFlag == "-pbrenvbakingspecsamples"
12162 || aFlag == "-pbrenvbssn")
12164 if (++anArgIter >= theArgNb)
12166 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12170 const Standard_Integer aPbrEnvBakingSpecNbSamples = Draw::Atoi(theArgVec[anArgIter]);
12171 if (aPbrEnvBakingSpecNbSamples < 1)
12173 Message::SendFail ("Syntax error: 'BakingSpecSamplesNumber' of PBR Environtment has to be greater or equal 1");
12176 aParams.PbrEnvBakingSpecNbSamples = aPbrEnvBakingSpecNbSamples;
12178 else if (aFlag == "-pbrenvbakingprobability"
12179 || aFlag == "-pbrenvbp")
12181 if (++anArgIter >= theArgNb)
12183 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12186 const Standard_ShortReal aPbrEnvBakingProbability = static_cast<Standard_ShortReal>(Draw::Atof (theArgVec[anArgIter]));
12187 if (aPbrEnvBakingProbability < 0.f
12188 || aPbrEnvBakingProbability > 1.f)
12190 Message::SendFail ("Syntax error: 'BakingProbability' of PBR Environtment has to be in range of [0, 1]");
12193 aParams.PbrEnvBakingProbability = aPbrEnvBakingProbability;
12195 else if (aFlag == "-resolution")
12197 if (++anArgIter >= theArgNb)
12199 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12203 TCollection_AsciiString aResolution (theArgVec[anArgIter]);
12204 if (aResolution.IsIntegerValue())
12206 aView->ChangeRenderingParams().Resolution = static_cast<unsigned int> (Draw::Atoi (aResolution.ToCString()));
12210 Message::SendFail() << "Syntax error: wrong syntax at argument'" << anArg << "'";
12214 else if (aFlag == "-rebuildglsl"
12215 || aFlag == "-rebuild")
12219 theDI << (aParams.RebuildRayTracingShaders ? "on" : "off") << " ";
12223 Standard_Boolean toEnable = Standard_True;
12224 if (++anArgIter < theArgNb
12225 && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
12229 aParams.RebuildRayTracingShaders = toEnable;
12231 else if (aFlag == "-focal")
12233 if (++anArgIter >= theArgNb)
12235 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12239 TCollection_AsciiString aParam (theArgVec[anArgIter]);
12240 if (aParam.IsRealValue())
12242 float aFocalDist = static_cast<float> (aParam.RealValue());
12243 if (aFocalDist < 0)
12245 Message::SendFail() << "Error: parameter can't be negative at argument '" << anArg << "'";
12248 aView->ChangeRenderingParams().CameraFocalPlaneDist = aFocalDist;
12252 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12256 else if (aFlag == "-aperture")
12258 if (++anArgIter >= theArgNb)
12260 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12264 TCollection_AsciiString aParam(theArgVec[anArgIter]);
12265 if (aParam.IsRealValue())
12267 float aApertureSize = static_cast<float> (aParam.RealValue());
12268 if (aApertureSize < 0)
12270 Message::SendFail() << "Error: parameter can't be negative at argument '" << anArg << "'";
12273 aView->ChangeRenderingParams().CameraApertureRadius = aApertureSize;
12277 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12281 else if (aFlag == "-exposure")
12283 if (++anArgIter >= theArgNb)
12285 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12289 TCollection_AsciiString anExposure (theArgVec[anArgIter]);
12290 if (anExposure.IsRealValue())
12292 aView->ChangeRenderingParams().Exposure = static_cast<float> (anExposure.RealValue());
12296 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12300 else if (aFlag == "-whitepoint")
12302 if (++anArgIter >= theArgNb)
12304 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12308 TCollection_AsciiString aWhitePoint (theArgVec[anArgIter]);
12309 if (aWhitePoint.IsRealValue())
12311 aView->ChangeRenderingParams().WhitePoint = static_cast<float> (aWhitePoint.RealValue());
12315 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12319 else if (aFlag == "-tonemapping")
12321 if (++anArgIter >= theArgNb)
12323 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12327 TCollection_AsciiString aMode (theArgVec[anArgIter]);
12330 if (aMode == "disabled")
12332 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Disabled;
12334 else if (aMode == "filmic")
12336 aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Filmic;
12340 Message::SendFail() << "Syntax error at argument'" << anArg << "'";
12344 else if (aFlag == "-performancestats"
12345 || aFlag == "-performancecounters"
12346 || aFlag == "-perfstats"
12347 || aFlag == "-perfcounters"
12348 || aFlag == "-stats")
12350 if (++anArgIter >= theArgNb)
12352 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12356 TCollection_AsciiString aFlagsStr (theArgVec[anArgIter]);
12357 aFlagsStr.LowerCase();
12358 Graphic3d_RenderingParams::PerfCounters aFlags = aView->ChangeRenderingParams().CollectedStats;
12359 if (!convertToPerfStatsFlags (aFlagsStr, aFlags))
12361 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12364 aView->ChangeRenderingParams().CollectedStats = aFlags;
12365 aView->ChangeRenderingParams().ToShowStats = aFlags != Graphic3d_RenderingParams::PerfCounters_NONE;
12367 else if (aFlag == "-perfupdateinterval"
12368 || aFlag == "-statsupdateinterval")
12370 if (++anArgIter >= theArgNb)
12372 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12375 aView->ChangeRenderingParams().StatsUpdateInterval = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]);
12377 else if (aFlag == "-perfchart"
12378 || aFlag == "-statschart")
12380 if (++anArgIter >= theArgNb)
12382 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12385 aView->ChangeRenderingParams().StatsNbFrames = Draw::Atoi (theArgVec[anArgIter]);
12387 else if (aFlag == "-perfchartmax"
12388 || aFlag == "-statschartmax")
12390 if (++anArgIter >= theArgNb)
12392 Message::SendFail() << "Syntax error at argument '" << anArg << "'";
12395 aView->ChangeRenderingParams().StatsMaxChartTime = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]);
12397 else if (aFlag == "-frustumculling"
12398 || aFlag == "-culling")
12402 theDI << ((aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On) ? "on" :
12403 (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off) ? "off" :
12404 "noUpdate") << " ";
12408 Graphic3d_RenderingParams::FrustumCulling aState = Graphic3d_RenderingParams::FrustumCulling_On;
12409 if (++anArgIter < theArgNb)
12411 TCollection_AsciiString aStateStr(theArgVec[anArgIter]);
12412 aStateStr.LowerCase();
12413 bool toEnable = true;
12414 if (ViewerTest::ParseOnOff (aStateStr.ToCString(), toEnable))
12416 aState = toEnable ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off;
12418 else if (aStateStr == "noupdate"
12419 || aStateStr == "freeze")
12421 aState = Graphic3d_RenderingParams::FrustumCulling_NoUpdate;
12428 aParams.FrustumCullingState = aState;
12432 Message::SendFail() << "Syntax error: unknown flag '" << anArg << "'";
12440 //=======================================================================
12441 //function : searchInfo
12443 //=======================================================================
12444 inline TCollection_AsciiString searchInfo (const TColStd_IndexedDataMapOfStringString& theDict,
12445 const TCollection_AsciiString& theKey)
12447 for (TColStd_IndexedDataMapOfStringString::Iterator anIter (theDict); anIter.More(); anIter.Next())
12449 if (TCollection_AsciiString::IsSameString (anIter.Key(), theKey, Standard_False))
12451 return anIter.Value();
12454 return TCollection_AsciiString();
12457 //=======================================================================
12458 //function : VStatProfiler
12460 //=======================================================================
12461 static Standard_Integer VStatProfiler (Draw_Interpretor& theDI,
12462 Standard_Integer theArgNb,
12463 const char** theArgVec)
12465 Handle(V3d_View) aView = ViewerTest::CurrentView();
12466 if (aView.IsNull())
12468 Message::SendFail ("Error: no active viewer");
12472 Standard_Boolean toRedraw = Standard_True;
12473 Graphic3d_RenderingParams::PerfCounters aPrevCounters = aView->ChangeRenderingParams().CollectedStats;
12474 Standard_ShortReal aPrevUpdInterval = aView->ChangeRenderingParams().StatsUpdateInterval;
12475 Graphic3d_RenderingParams::PerfCounters aRenderParams = Graphic3d_RenderingParams::PerfCounters_NONE;
12476 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
12478 Standard_CString anArg (theArgVec[anArgIter]);
12479 TCollection_AsciiString aFlag (anArg);
12481 if (aFlag == "-noredraw")
12483 toRedraw = Standard_False;
12487 Graphic3d_RenderingParams::PerfCounters aParam = Graphic3d_RenderingParams::PerfCounters_NONE;
12488 if (aFlag == "fps") aParam = Graphic3d_RenderingParams::PerfCounters_FrameRate;
12489 else if (aFlag == "cpu") aParam = Graphic3d_RenderingParams::PerfCounters_CPU;
12490 else if (aFlag == "alllayers"
12491 || aFlag == "layers") aParam = Graphic3d_RenderingParams::PerfCounters_Layers;
12492 else if (aFlag == "allstructs"
12493 || aFlag == "allstructures"
12494 || aFlag == "structs"
12495 || aFlag == "structures") aParam = Graphic3d_RenderingParams::PerfCounters_Structures;
12496 else if (aFlag == "groups") aParam = Graphic3d_RenderingParams::PerfCounters_Groups;
12497 else if (aFlag == "allarrays"
12498 || aFlag == "fillarrays"
12499 || aFlag == "linearrays"
12500 || aFlag == "pointarrays"
12501 || aFlag == "textarrays") aParam = Graphic3d_RenderingParams::PerfCounters_GroupArrays;
12502 else if (aFlag == "triangles") aParam = Graphic3d_RenderingParams::PerfCounters_Triangles;
12503 else if (aFlag == "lines") aParam = Graphic3d_RenderingParams::PerfCounters_Lines;
12504 else if (aFlag == "points") aParam = Graphic3d_RenderingParams::PerfCounters_Points;
12505 else if (aFlag == "geommem"
12506 || aFlag == "texturemem"
12507 || aFlag == "framemem") aParam = Graphic3d_RenderingParams::PerfCounters_EstimMem;
12508 else if (aFlag == "elapsedframe"
12509 || aFlag == "cpuframeaverage"
12510 || aFlag == "cpupickingaverage"
12511 || aFlag == "cpucullingaverage"
12512 || aFlag == "cpudynaverage"
12513 || aFlag == "cpuframemax"
12514 || aFlag == "cpupickingmax"
12515 || aFlag == "cpucullingmax"
12516 || aFlag == "cpudynmax") aParam = Graphic3d_RenderingParams::PerfCounters_FrameTime;
12519 Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'";
12523 aRenderParams = Graphic3d_RenderingParams::PerfCounters (aRenderParams | aParam);
12527 if (aRenderParams != Graphic3d_RenderingParams::PerfCounters_NONE)
12529 aView->ChangeRenderingParams().CollectedStats =
12530 Graphic3d_RenderingParams::PerfCounters (aView->RenderingParams().CollectedStats | aRenderParams);
12534 aView->ChangeRenderingParams().StatsUpdateInterval = -1;
12536 aView->ChangeRenderingParams().StatsUpdateInterval = aPrevUpdInterval;
12539 TColStd_IndexedDataMapOfStringString aDict;
12540 aView->StatisticInformation (aDict);
12542 aView->ChangeRenderingParams().CollectedStats = aPrevCounters;
12544 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
12546 Standard_CString anArg(theArgVec[anArgIter]);
12547 TCollection_AsciiString aFlag(anArg);
12549 if (aFlag == "fps")
12551 theDI << searchInfo (aDict, "FPS") << " ";
12553 else if (aFlag == "cpu")
12555 theDI << searchInfo (aDict, "CPU FPS") << " ";
12557 else if (aFlag == "alllayers")
12559 theDI << searchInfo (aDict, "Layers") << " ";
12561 else if (aFlag == "layers")
12563 theDI << searchInfo (aDict, "Rendered layers") << " ";
12565 else if (aFlag == "allstructs"
12566 || aFlag == "allstructures")
12568 theDI << searchInfo (aDict, "Structs") << " ";
12570 else if (aFlag == "structs"
12571 || aFlag == "structures")
12573 TCollection_AsciiString aRend = searchInfo (aDict, "Rendered structs");
12574 if (aRend.IsEmpty()) // all structures rendered
12576 aRend = searchInfo (aDict, "Structs");
12578 theDI << aRend << " ";
12580 else if (aFlag == "groups")
12582 theDI << searchInfo (aDict, "Rendered groups") << " ";
12584 else if (aFlag == "allarrays")
12586 theDI << searchInfo (aDict, "Rendered arrays") << " ";
12588 else if (aFlag == "fillarrays")
12590 theDI << searchInfo (aDict, "Rendered [fill] arrays") << " ";
12592 else if (aFlag == "linearrays")
12594 theDI << searchInfo (aDict, "Rendered [line] arrays") << " ";
12596 else if (aFlag == "pointarrays")
12598 theDI << searchInfo (aDict, "Rendered [point] arrays") << " ";
12600 else if (aFlag == "textarrays")
12602 theDI << searchInfo (aDict, "Rendered [text] arrays") << " ";
12604 else if (aFlag == "triangles")
12606 theDI << searchInfo (aDict, "Rendered triangles") << " ";
12608 else if (aFlag == "points")
12610 theDI << searchInfo (aDict, "Rendered points") << " ";
12612 else if (aFlag == "geommem")
12614 theDI << searchInfo (aDict, "GPU Memory [geometry]") << " ";
12616 else if (aFlag == "texturemem")
12618 theDI << searchInfo (aDict, "GPU Memory [textures]") << " ";
12620 else if (aFlag == "framemem")
12622 theDI << searchInfo (aDict, "GPU Memory [frames]") << " ";
12624 else if (aFlag == "elapsedframe")
12626 theDI << searchInfo (aDict, "Elapsed Frame (average)") << " ";
12628 else if (aFlag == "cpuframe_average")
12630 theDI << searchInfo (aDict, "CPU Frame (average)") << " ";
12632 else if (aFlag == "cpupicking_average")
12634 theDI << searchInfo (aDict, "CPU Picking (average)") << " ";
12636 else if (aFlag == "cpuculling_average")
12638 theDI << searchInfo (aDict, "CPU Culling (average)") << " ";
12640 else if (aFlag == "cpudyn_average")
12642 theDI << searchInfo (aDict, "CPU Dynamics (average)") << " ";
12644 else if (aFlag == "cpuframe_max")
12646 theDI << searchInfo (aDict, "CPU Frame (max)") << " ";
12648 else if (aFlag == "cpupicking_max")
12650 theDI << searchInfo (aDict, "CPU Picking (max)") << " ";
12652 else if (aFlag == "cpuculling_max")
12654 theDI << searchInfo (aDict, "CPU Culling (max)") << " ";
12656 else if (aFlag == "cpudyn_max")
12658 theDI << searchInfo (aDict, "CPU Dynamics (max)") << " ";
12666 aView->ChangeRenderingParams().StatsUpdateInterval = -1;
12668 aView->ChangeRenderingParams().StatsUpdateInterval = aPrevUpdInterval;
12670 theDI << "Statistic info:\n" << aView->StatisticInformation();
12675 //=======================================================================
12676 //function : VXRotate
12678 //=======================================================================
12679 static Standard_Integer VXRotate (Draw_Interpretor& di,
12680 Standard_Integer argc,
12681 const char ** argv)
12683 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
12684 if (aContext.IsNull())
12686 di << argv[0] << "ERROR : use 'vinit' command before \n";
12692 di << "ERROR : Usage : " << argv[0] << " name angle\n";
12696 TCollection_AsciiString aName (argv[1]);
12697 Standard_Real anAngle = Draw::Atof (argv[2]);
12700 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
12701 Handle(AIS_InteractiveObject) anIObj;
12702 if (!aMap.Find2 (aName, anIObj))
12704 di << "Use 'vdisplay' before\n";
12708 gp_Trsf aTransform;
12709 aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle);
12710 aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart());
12712 aContext->SetLocation (anIObj, aTransform);
12713 aContext->UpdateCurrentViewer();
12717 //===============================================================================================
12718 //function : VManipulator
12720 //===============================================================================================
12721 static int VManipulator (Draw_Interpretor& theDi,
12722 Standard_Integer theArgsNb,
12723 const char** theArgVec)
12725 Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
12726 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
12727 ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_False);
12728 if (aCurrentView.IsNull()
12729 || aViewer.IsNull())
12731 Message::SendFail ("Error: no active viewer");
12735 ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
12736 Standard_Integer anArgIter = 1;
12737 for (; anArgIter < theArgsNb; ++anArgIter)
12739 anUpdateTool.parseRedrawMode (theArgVec[anArgIter]);
12742 ViewerTest_CmdParser aCmd;
12743 aCmd.SetDescription ("Manages manipulator for interactive objects:");
12744 aCmd.AddOption ("attach", "... object - attach manipulator to an object");
12745 aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
12746 aCmd.AddOption ("adjustSize", "... {0|1} - adjust size when attaching ");
12747 aCmd.AddOption ("enableModes", "... {0|1} - enable modes when attaching ");
12748 aCmd.AddOption ("view", "... {active | [view name]} - define view in which manipulator will be displayed, 'all' by default");
12749 aCmd.AddOption ("detach", "... - detach manipulator");
12751 aCmd.AddOption ("startTransform", "... mouse_x mouse_y - invoke start transformation");
12752 aCmd.AddOption ("transform", "... mouse_x mouse_y - invoke transformation");
12753 aCmd.AddOption ("stopTransform", "... [abort] - invoke stop transformation");
12755 aCmd.AddOption ("move", "... x y z - move object");
12756 aCmd.AddOption ("rotate", "... x y z dx dy dz angle - rotate object");
12757 aCmd.AddOption ("scale", "... factor - scale object");
12759 aCmd.AddOption ("autoActivate", "... {0|1} - set activation on detection");
12760 aCmd.AddOption ("followTranslation", "... {0|1} - set following translation transform");
12761 aCmd.AddOption ("followRotation", "... {0|1} - set following rotation transform");
12762 aCmd.AddOption ("followDragging", "... {0|1} - set following dragging transform");
12763 aCmd.AddOption ("gap", "... value - set gap between sub-parts");
12764 aCmd.AddOption ("part", "... axis mode {0|1} - set visual part");
12765 aCmd.AddOption ("parts", "... all axes mode {0|1} - set visual part");
12766 aCmd.AddOption ("pos", "... x y z [nx ny nz [xx xy xz]] - set position of manipulator");
12767 aCmd.AddOption ("size", "... size - set size of manipulator");
12768 aCmd.AddOption ("zoomable", "... {0|1} - set zoom persistence");
12770 aCmd.Parse (theArgsNb, theArgVec);
12772 if (aCmd.HasOption ("help"))
12774 theDi.PrintHelp (theArgVec[0]);
12778 ViewerTest_DoubleMapOfInteractiveAndName& aMapAIS = GetMapOfAIS();
12780 TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str());
12782 if (aName.IsEmpty())
12784 Message::SendFail ("Syntax error: please specify AIS manipulator's name as the first argument");
12788 // ----------------------------------
12789 // detach existing manipulator object
12790 // ----------------------------------
12792 if (aCmd.HasOption ("detach"))
12794 if (!aMapAIS.IsBound2 (aName))
12796 Message::SendFail() << "Syntax error: could not find \"" << aName << "\" AIS object";
12800 Handle(AIS_Manipulator) aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
12801 if (aManipulator.IsNull())
12803 Message::SendFail() << "Syntax error: \"" << aName << "\" is not an AIS manipulator";
12807 aManipulator->Detach();
12808 aMapAIS.UnBind2 (aName);
12809 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_True);
12814 // -----------------------------------------------
12815 // find or create manipulator if it does not exist
12816 // -----------------------------------------------
12818 Handle(AIS_Manipulator) aManipulator;
12819 if (!aMapAIS.IsBound2 (aName))
12821 std::cout << theArgVec[0] << ": AIS object \"" << aName << "\" has been created.\n";
12823 aManipulator = new AIS_Manipulator();
12824 aManipulator->SetModeActivationOnDetection (true);
12825 aMapAIS.Bind (aManipulator, aName);
12829 aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName));
12830 if (aManipulator.IsNull())
12832 Message::SendFail() << "Syntax error: \"" << aName << "\" is not an AIS manipulator";
12837 // -----------------------------------------
12838 // change properties of manipulator instance
12839 // -----------------------------------------
12841 if (aCmd.HasOption ("autoActivate", 1, Standard_True))
12843 aManipulator->SetModeActivationOnDetection (aCmd.ArgBool ("autoActivate"));
12845 if (aCmd.HasOption ("followTranslation", 1, Standard_True))
12847 aManipulator->ChangeTransformBehavior().SetFollowTranslation (aCmd.ArgBool ("followTranslation"));
12849 if (aCmd.HasOption ("followRotation", 1, Standard_True))
12851 aManipulator->ChangeTransformBehavior().SetFollowRotation (aCmd.ArgBool ("followRotation"));
12853 if (aCmd.HasOption("followDragging", 1, Standard_True))
12855 aManipulator->ChangeTransformBehavior().SetFollowDragging(aCmd.ArgBool("followDragging"));
12857 if (aCmd.HasOption ("gap", 1, Standard_True))
12859 aManipulator->SetGap (aCmd.ArgFloat ("gap"));
12861 if (aCmd.HasOption ("part", 3, Standard_True))
12863 Standard_Integer anAxis = aCmd.ArgInt ("part", 0);
12864 Standard_Integer aMode = aCmd.ArgInt ("part", 1);
12865 Standard_Boolean aOnOff = aCmd.ArgBool ("part", 2);
12866 if (aMode < 1 || aMode > 4)
12868 Message::SendFail ("Syntax error: mode value should be in range [1, 4]");
12872 aManipulator->SetPart (anAxis, static_cast<AIS_ManipulatorMode> (aMode), aOnOff);
12874 if (aCmd.HasOption("parts", 2, Standard_True))
12876 Standard_Integer aMode = aCmd.ArgInt("parts", 0);
12877 Standard_Boolean aOnOff = aCmd.ArgBool("parts", 1);
12878 if (aMode < 1 || aMode > 4)
12880 Message::SendFail ("Syntax error: mode value should be in range [1, 4]");
12884 aManipulator->SetPart(static_cast<AIS_ManipulatorMode>(aMode), aOnOff);
12886 if (aCmd.HasOption ("pos", 3, Standard_True))
12888 gp_Pnt aLocation = aCmd.ArgPnt ("pos", 0);
12889 gp_Dir aVDir = aCmd.HasOption ("pos", 6) ? gp_Dir (aCmd.ArgVec ("pos", 3)) : aManipulator->Position().Direction();
12890 gp_Dir aXDir = aCmd.HasOption ("pos", 9) ? gp_Dir (aCmd.ArgVec ("pos", 6)) : aManipulator->Position().XDirection();
12892 aManipulator->SetPosition (gp_Ax2 (aLocation, aVDir, aXDir));
12894 if (aCmd.HasOption ("size", 1, Standard_True))
12896 aManipulator->SetSize (aCmd.ArgFloat ("size"));
12898 if (aCmd.HasOption ("zoomable", 1, Standard_True))
12900 aManipulator->SetZoomPersistence (!aCmd.ArgBool ("zoomable"));
12902 if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator))
12904 ViewerTest::GetAISContext()->Remove (aManipulator, Standard_False);
12905 ViewerTest::GetAISContext()->Display (aManipulator, Standard_False);
12909 // ---------------------------------------------------
12910 // attach, detach or access manipulator from an object
12911 // ---------------------------------------------------
12913 if (aCmd.HasOption ("attach"))
12915 // Find an object and attach manipulator to it
12916 if (!aCmd.HasOption ("attach", 1, Standard_True))
12921 TCollection_AsciiString anObjName (aCmd.Arg ("attach", 0).c_str());
12922 Handle(AIS_InteractiveObject) anObject;
12923 if (!aMapAIS.Find2 (anObjName, anObject))
12925 Message::SendFail() << "Syntax error: AIS object \"" << anObjName << "\" does not exist";
12929 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (aMapAIS);
12930 anIter.More(); anIter.Next())
12932 Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (anIter.Key1());
12933 if (!aManip.IsNull()
12934 && aManip->IsAttached()
12935 && aManip->Object() == anObject)
12937 Message::SendFail() << "Syntax error: AIS object \"" << anObjName << "\" already has manipulator";
12942 AIS_Manipulator::OptionsForAttach anOptions;
12943 if (aCmd.HasOption ("adjustPosition", 1, Standard_True))
12945 anOptions.SetAdjustPosition (aCmd.ArgBool ("adjustPosition"));
12947 if (aCmd.HasOption ("adjustSize", 1, Standard_True))
12949 anOptions.SetAdjustSize (aCmd.ArgBool ("adjustSize"));
12951 if (aCmd.HasOption ("enableModes", 1, Standard_True))
12953 anOptions.SetEnableModes (aCmd.ArgBool ("enableModes"));
12956 aManipulator->Attach (anObject, anOptions);
12958 // Check view option
12959 if (aCmd.HasOption ("view"))
12961 if (!aCmd.HasOption ("view", 1, Standard_True))
12965 TCollection_AsciiString aViewString (aCmd.Arg ("view", 0).c_str());
12966 Handle(V3d_View) aView;
12967 if (aViewString.IsEqual ("active"))
12969 aView = ViewerTest::CurrentView();
12971 else // Check view name
12973 ViewerTest_Names aViewNames (aViewString);
12974 if (!ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
12976 Message::SendFail() << "Syntax error: wrong view name '" << aViewString << "'";
12979 aView = ViewerTest_myViews.Find1 (aViewNames.GetViewName());
12980 if (aView.IsNull())
12982 Message::SendFail() << "Syntax error: cannot find view with name '" << aViewString << "'";
12986 for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
12987 anIter (ViewerTest_myViews); anIter.More(); anIter.Next())
12989 ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Value(), Standard_False);
12991 ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, aView, Standard_True);
12995 // --------------------------------------
12996 // apply transformation using manipulator
12997 // --------------------------------------
12999 if (aCmd.HasOption ("startTransform", 2, Standard_True))
13001 aManipulator->StartTransform (aCmd.ArgInt ("startTransform", 0), aCmd.ArgInt ("startTransform", 1), ViewerTest::CurrentView());
13003 if (aCmd.HasOption ("transform", 2, Standard_True))
13005 aManipulator->Transform (aCmd.ArgInt ("transform", 0), aCmd.ArgInt ("transform", 1), ViewerTest::CurrentView());
13007 if (aCmd.HasOption ("stopTransform"))
13009 Standard_Boolean toApply = !aCmd.HasOption ("stopTransform", 1) || (aCmd.Arg ("stopTransform", 0) != "abort");
13011 aManipulator->StopTransform (toApply);
13015 if (aCmd.HasOption ("move", 3, Standard_True))
13017 aT.SetTranslationPart (aCmd.ArgVec ("move"));
13019 if (aCmd.HasOption ("rotate", 7, Standard_True))
13021 aT.SetRotation (gp_Ax1 (aCmd.ArgPnt ("rotate", 0), aCmd.ArgVec ("rotate", 3)), aCmd.ArgDouble ("rotate", 6));
13023 if (aCmd.HasOption ("scale", 1))
13025 aT.SetScale (gp_Pnt(), aCmd.ArgDouble("scale"));
13028 if (aT.Form() != gp_Identity)
13030 aManipulator->Transform (aT);
13033 ViewerTest::GetAISContext()->Redisplay (aManipulator, Standard_True);
13038 //===============================================================================================
13039 //function : VSelectionProperties
13041 //===============================================================================================
13042 static int VSelectionProperties (Draw_Interpretor& theDi,
13043 Standard_Integer theArgsNb,
13044 const char** theArgVec)
13046 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
13049 Message::SendFail ("Error: no active viewer");
13053 if (TCollection_AsciiString (theArgVec[0]) == "vhighlightselected")
13055 // handle obsolete alias
13056 bool toEnable = true;
13059 theDi << (aCtx->ToHilightSelected() ? "on" : "off");
13062 else if (theArgsNb != 2
13063 || !ViewerTest::ParseOnOff (theArgVec[1], toEnable))
13065 Message::SendFail ("Syntax error: wrong number of parameters");
13068 if (toEnable != aCtx->ToHilightSelected())
13070 aCtx->ClearDetected();
13071 aCtx->SetToHilightSelected (toEnable);
13076 Standard_Boolean toPrint = theArgsNb == 1;
13077 Standard_Boolean toRedraw = Standard_False;
13078 Standard_Integer anArgIter = 1;
13079 Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None;
13080 if (anArgIter < theArgsNb)
13082 TCollection_AsciiString anArgFirst (theArgVec[anArgIter]);
13083 anArgFirst.LowerCase();
13085 if (anArgFirst == "dynhighlight"
13086 || anArgFirst == "dynhilight"
13087 || anArgFirst == "dynamichighlight"
13088 || anArgFirst == "dynamichilight")
13090 aType = Prs3d_TypeOfHighlight_Dynamic;
13092 else if (anArgFirst == "localdynhighlight"
13093 || anArgFirst == "localdynhilight"
13094 || anArgFirst == "localdynamichighlight"
13095 || anArgFirst == "localdynamichilight")
13097 aType = Prs3d_TypeOfHighlight_LocalDynamic;
13099 else if (anArgFirst == "selhighlight"
13100 || anArgFirst == "selhilight"
13101 || anArgFirst == "selectedhighlight"
13102 || anArgFirst == "selectedhilight")
13104 aType = Prs3d_TypeOfHighlight_Selected;
13106 else if (anArgFirst == "localselhighlight"
13107 || anArgFirst == "localselhilight"
13108 || anArgFirst == "localselectedhighlight"
13109 || anArgFirst == "localselectedhilight")
13111 aType = Prs3d_TypeOfHighlight_LocalSelected;
13118 for (; anArgIter < theArgsNb; ++anArgIter)
13120 TCollection_AsciiString anArg (theArgVec[anArgIter]);
13122 if (anArg == "-help")
13124 theDi.PrintHelp (theArgVec[0]);
13127 else if (anArg == "-print")
13129 toPrint = Standard_True;
13131 else if (anArg == "-autoactivate")
13133 Standard_Boolean toEnable = Standard_True;
13134 if (anArgIter + 1 < theArgsNb
13135 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
13139 aCtx->SetAutoActivateSelection (toEnable);
13141 else if (anArg == "-automatichighlight"
13142 || anArg == "-automatichilight"
13143 || anArg == "-autohighlight"
13144 || anArg == "-autohilight")
13146 Standard_Boolean toEnable = Standard_True;
13147 if (anArgIter + 1 < theArgsNb
13148 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
13152 aCtx->ClearSelected (false);
13153 aCtx->ClearDetected();
13154 aCtx->SetAutomaticHilight (toEnable);
13157 else if (anArg == "-highlightselected"
13158 || anArg == "-hilightselected")
13160 Standard_Boolean toEnable = Standard_True;
13161 if (anArgIter + 1 < theArgsNb
13162 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
13166 aCtx->ClearDetected();
13167 aCtx->SetToHilightSelected (toEnable);
13170 else if (anArg == "-pickstrategy"
13171 || anArg == "-pickingstrategy")
13173 if (++anArgIter >= theArgsNb)
13175 Message::SendFail ("Syntax error: type of highlighting is undefined");
13179 SelectMgr_PickingStrategy aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
13180 TCollection_AsciiString aVal (theArgVec[anArgIter]);
13182 if (aVal == "first"
13183 || aVal == "firstaccepted"
13184 || aVal == "firstacceptable")
13186 aStrategy = SelectMgr_PickingStrategy_FirstAcceptable;
13188 else if (aVal == "topmost"
13189 || aVal == "onlyTopmost")
13191 aStrategy = SelectMgr_PickingStrategy_OnlyTopmost;
13195 Message::SendFail() << "Syntax error: unknown picking strategy '" << aVal << "'";
13199 aCtx->SetPickingStrategy (aStrategy);
13201 else if (anArg == "-pixtol"
13202 && anArgIter + 1 < theArgsNb)
13204 aCtx->SetPixelTolerance (Draw::Atoi (theArgVec[++anArgIter]));
13206 else if ((anArg == "-mode"
13207 || anArg == "-dispmode")
13208 && anArgIter + 1 < theArgsNb)
13210 if (aType == Prs3d_TypeOfHighlight_None)
13212 Message::SendFail ("Syntax error: type of highlighting is undefined");
13216 const Standard_Integer aDispMode = Draw::Atoi (theArgVec[++anArgIter]);
13217 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13218 aStyle->SetDisplayMode (aDispMode);
13219 toRedraw = Standard_True;
13221 else if (anArg == "-layer"
13222 && anArgIter + 1 < theArgsNb)
13224 if (aType == Prs3d_TypeOfHighlight_None)
13226 Message::SendFail ("Syntax error: type of highlighting is undefined");
13231 Graphic3d_ZLayerId aNewLayer = Graphic3d_ZLayerId_UNKNOWN;
13232 if (!ViewerTest::ParseZLayer (theArgVec[anArgIter], aNewLayer))
13234 Message::SendFail() << "Syntax error at " << theArgVec[anArgIter];
13238 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13239 aStyle->SetZLayer (aNewLayer);
13240 toRedraw = Standard_True;
13242 else if (anArg == "-hicolor"
13243 || anArg == "-selcolor"
13244 || anArg == "-color")
13246 if (anArg.StartsWith ("-hi"))
13248 aType = Prs3d_TypeOfHighlight_Dynamic;
13250 else if (anArg.StartsWith ("-sel"))
13252 aType = Prs3d_TypeOfHighlight_Selected;
13254 else if (aType == Prs3d_TypeOfHighlight_None)
13256 Message::SendFail ("Syntax error: type of highlighting is undefined");
13260 Quantity_Color aColor;
13261 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIter - 1,
13262 theArgVec + anArgIter + 1,
13264 if (aNbParsed == 0)
13266 Message::SendFail ("Syntax error: need more arguments");
13269 anArgIter += aNbParsed;
13271 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13272 aStyle->SetColor (aColor);
13273 toRedraw = Standard_True;
13275 else if ((anArg == "-transp"
13276 || anArg == "-transparency"
13277 || anArg == "-hitransp"
13278 || anArg == "-seltransp"
13279 || anArg == "-hitransplocal"
13280 || anArg == "-seltransplocal")
13281 && anArgIter + 1 < theArgsNb)
13283 if (anArg.StartsWith ("-hi"))
13285 aType = Prs3d_TypeOfHighlight_Dynamic;
13287 else if (anArg.StartsWith ("-sel"))
13289 aType = Prs3d_TypeOfHighlight_Selected;
13291 else if (aType == Prs3d_TypeOfHighlight_None)
13293 Message::SendFail ("Syntax error: type of highlighting is undefined");
13297 const Standard_Real aTransp = Draw::Atof (theArgVec[++anArgIter]);
13298 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13299 aStyle->SetTransparency ((Standard_ShortReal )aTransp);
13300 toRedraw = Standard_True;
13302 else if ((anArg == "-mat"
13303 || anArg == "-material")
13304 && anArgIter + 1 < theArgsNb)
13306 if (aType == Prs3d_TypeOfHighlight_None)
13308 Message::SendFail ("Syntax error: type of highlighting is undefined");
13312 const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType);
13313 Graphic3d_NameOfMaterial aMatName = Graphic3d_MaterialAspect::MaterialFromName (theArgVec[anArgIter + 1]);
13314 if (aMatName != Graphic3d_NOM_DEFAULT)
13317 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
13318 *anAspect = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
13319 Graphic3d_MaterialAspect aMat (aMatName);
13320 aMat.SetColor (aStyle->Color());
13321 aMat.SetTransparency (aStyle->Transparency());
13322 anAspect->SetFrontMaterial (aMat);
13323 anAspect->SetInteriorColor (aStyle->Color());
13324 aStyle->SetBasicFillAreaAspect (anAspect);
13328 aStyle->SetBasicFillAreaAspect (Handle(Graphic3d_AspectFillArea3d)());
13330 toRedraw = Standard_True;
13334 Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
13340 const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle();
13341 const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle();
13342 theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n";
13343 theDi << "Auto-highlight : " << (aCtx->AutomaticHilight() ? "On" : "Off") << "\n";
13344 theDi << "Highlight selected : " << (aCtx->ToHilightSelected() ? "On" : "Off") << "\n";
13345 theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n";
13346 theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n";
13347 theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n";
13348 theDi << "Selection transparency : " << aSelStyle->Transparency() << "\n";
13349 theDi << "Dynamic highlight transparency : " << aHiStyle->Transparency() << "\n";
13350 theDi << "Selection mode : " << aSelStyle->DisplayMode() << "\n";
13351 theDi << "Dynamic highlight mode : " << aHiStyle->DisplayMode() << "\n";
13352 theDi << "Selection layer : " << aSelStyle->ZLayer() << "\n";
13353 theDi << "Dynamic layer : " << aHiStyle->ZLayer() << "\n";
13356 if (aCtx->NbSelected() != 0 && toRedraw)
13358 aCtx->HilightSelected (Standard_True);
13364 //===============================================================================================
13365 //function : VDumpSelectionImage
13367 //===============================================================================================
13368 static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
13369 Standard_Integer theArgsNb,
13370 const char** theArgVec)
13374 Message::SendFail() << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'";
13378 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
13379 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
13380 if (aContext.IsNull())
13382 Message::SendFail ("Error: no active viewer");
13386 TCollection_AsciiString aFile;
13387 StdSelect_TypeOfSelectionImage aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
13388 Handle(Graphic3d_Camera) aCustomCam;
13389 Image_Format anImgFormat = Image_Format_BGR;
13390 Standard_Integer aPickedIndex = 1;
13391 for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
13393 TCollection_AsciiString aParam (theArgVec[anArgIter]);
13394 aParam.LowerCase();
13395 if (aParam == "-type")
13397 if (++anArgIter >= theArgsNb)
13399 Message::SendFail ("Syntax error: wrong number parameters of flag '-depth'");
13403 TCollection_AsciiString aValue (theArgVec[anArgIter]);
13404 aValue.LowerCase();
13405 if (aValue == "depth"
13406 || aValue == "normdepth"
13407 || aValue == "normalizeddepth")
13409 aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
13410 anImgFormat = Image_Format_GrayF;
13412 if (aValue == "depthinverted"
13413 || aValue == "normdepthinverted"
13414 || aValue == "normalizeddepthinverted"
13415 || aValue == "inverted")
13417 aType = StdSelect_TypeOfSelectionImage_NormalizedDepthInverted;
13418 anImgFormat = Image_Format_GrayF;
13420 else if (aValue == "unnormdepth"
13421 || aValue == "unnormalizeddepth")
13423 aType = StdSelect_TypeOfSelectionImage_UnnormalizedDepth;
13424 anImgFormat = Image_Format_GrayF;
13426 else if (aValue == "objectcolor"
13427 || aValue == "object"
13428 || aValue == "color")
13430 aType = StdSelect_TypeOfSelectionImage_ColoredDetectedObject;
13432 else if (aValue == "entitycolor"
13433 || aValue == "entity")
13435 aType = StdSelect_TypeOfSelectionImage_ColoredEntity;
13437 else if (aValue == "ownercolor"
13438 || aValue == "owner")
13440 aType = StdSelect_TypeOfSelectionImage_ColoredOwner;
13442 else if (aValue == "selectionmodecolor"
13443 || aValue == "selectionmode"
13444 || aValue == "selmodecolor"
13445 || aValue == "selmode")
13447 aType = StdSelect_TypeOfSelectionImage_ColoredSelectionMode;
13450 else if (aParam == "-picked"
13451 || aParam == "-pickeddepth"
13452 || aParam == "-pickedindex")
13454 if (++anArgIter >= theArgsNb)
13456 Message::SendFail() << "Syntax error: wrong number parameters at '" << aParam << "'";
13460 aPickedIndex = Draw::Atoi (theArgVec[anArgIter]);
13462 else if (anArgIter + 1 < theArgsNb
13463 && aParam == "-xrpose")
13465 TCollection_AsciiString anXRArg (theArgVec[++anArgIter]);
13466 anXRArg.LowerCase();
13467 if (anXRArg == "base")
13469 aCustomCam = aView->View()->BaseXRCamera();
13471 else if (anXRArg == "head")
13473 aCustomCam = aView->View()->PosedXRCamera();
13477 Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'";
13480 if (aCustomCam.IsNull())
13482 Message::SendFail() << "Error: undefined XR pose";
13486 else if (aFile.IsEmpty())
13488 aFile = theArgVec[anArgIter];
13492 Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
13496 if (aFile.IsEmpty())
13498 Message::SendFail ("Syntax error: image file name is missing");
13502 Standard_Integer aWidth = 0, aHeight = 0;
13503 aView->Window()->Size (aWidth, aHeight);
13505 Image_AlienPixMap aPixMap;
13506 if (!aPixMap.InitZero (anImgFormat, aWidth, aHeight))
13508 Message::SendFail ("Error: can't allocate image");
13512 const bool wasImmUpdate = aView->SetImmediateUpdate (false);
13513 Handle(Graphic3d_Camera) aCamBack = aView->Camera();
13514 if (!aCustomCam.IsNull())
13516 aView->SetCamera (aCustomCam);
13518 if (!aContext->MainSelector()->ToPixMap (aPixMap, aView, aType, aPickedIndex))
13520 Message::SendFail ("Error: can't generate selection image");
13523 if (!aCustomCam.IsNull())
13525 aView->SetCamera (aCamBack);
13527 aView->SetImmediateUpdate (wasImmUpdate);
13529 if (!aPixMap.Save (aFile))
13531 Message::SendFail ("Error: can't save selection image");
13537 //===============================================================================================
13538 //function : VViewCube
13540 //===============================================================================================
13541 static int VViewCube (Draw_Interpretor& ,
13542 Standard_Integer theNbArgs,
13543 const char** theArgVec)
13545 const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
13546 const Handle(V3d_View)& aView = ViewerTest::CurrentView();
13547 if (aContext.IsNull() || aView.IsNull())
13549 Message::SendFail ("Error: no active viewer");
13552 else if (theNbArgs < 2)
13554 Message::SendFail ("Syntax error: wrong number arguments");
13558 Handle(AIS_ViewCube) aViewCube;
13559 ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
13560 Quantity_Color aColorRgb;
13561 TCollection_AsciiString aName;
13562 for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
13564 TCollection_AsciiString anArg (theArgVec[anArgIter]);
13566 if (anUpdateTool.parseRedrawMode (anArg))
13570 else if (aViewCube.IsNull())
13572 aName = theArgVec[anArgIter];
13573 if (aName.StartsWith ("-"))
13575 Message::SendFail ("Syntax error: object name should be specified");
13578 Handle(AIS_InteractiveObject) aPrs;
13579 GetMapOfAIS().Find2 (aName, aPrs);
13580 aViewCube = Handle(AIS_ViewCube)::DownCast (aPrs);
13581 if (aViewCube.IsNull())
13583 aViewCube = new AIS_ViewCube();
13584 aViewCube->SetBoxColor (Quantity_NOC_GRAY50);
13585 aViewCube->SetViewAnimation (ViewerTest::CurrentEventManager()->ViewAnimation());
13586 aViewCube->SetFixedAnimationLoop (false);
13589 else if (anArg == "-reset")
13591 aViewCube->ResetStyles();
13593 else if (anArg == "-color"
13594 || anArg == "-boxcolor"
13595 || anArg == "-boxsidecolor"
13596 || anArg == "-sidecolor"
13597 || anArg == "-boxedgecolor"
13598 || anArg == "-edgecolor"
13599 || anArg == "-boxcornercolor"
13600 || anArg == "-cornercolor"
13601 || anArg == "-innercolor"
13602 || anArg == "-textcolor")
13604 Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
13605 theArgVec + anArgIter + 1,
13607 if (aNbParsed == 0)
13609 Message::SendFail() << "Syntax error at '" << anArg << "'";
13612 anArgIter += aNbParsed;
13613 if (anArg == "-boxcolor")
13615 aViewCube->SetBoxColor (aColorRgb);
13617 else if (anArg == "-boxsidecolor"
13618 || anArg == "-sidecolor")
13620 aViewCube->BoxSideStyle()->SetColor (aColorRgb);
13621 aViewCube->SynchronizeAspects();
13623 else if (anArg == "-boxedgecolor"
13624 || anArg == "-edgecolor")
13626 aViewCube->BoxEdgeStyle()->SetColor (aColorRgb);
13627 aViewCube->SynchronizeAspects();
13629 else if (anArg == "-boxcornercolor"
13630 || anArg == "-cornercolor")
13632 aViewCube->BoxCornerStyle()->SetColor (aColorRgb);
13633 aViewCube->SynchronizeAspects();
13635 else if (anArg == "-innercolor")
13637 aViewCube->SetInnerColor (aColorRgb);
13639 else if (anArg == "-textcolor")
13641 aViewCube->SetTextColor (aColorRgb);
13645 aViewCube->SetColor (aColorRgb);
13648 else if (anArgIter + 1 < theNbArgs
13649 && (anArg == "-transparency"
13650 || anArg == "-boxtransparency"))
13652 const Standard_Real aValue = Draw::Atof (theArgVec[++anArgIter]);
13653 if (aValue < 0.0 || aValue > 1.0)
13655 Message::SendFail() << "Syntax error: invalid transparency value " << theArgVec[anArgIter];
13659 if (anArg == "-boxtransparency")
13661 aViewCube->SetBoxTransparency (aValue);
13665 aViewCube->SetTransparency (aValue);
13668 else if (anArg == "-axes"
13669 || anArg == "-edges"
13670 || anArg == "-vertices"
13671 || anArg == "-vertexes"
13672 || anArg == "-fixedanimation")
13674 bool toShow = true;
13675 if (anArgIter + 1 < theNbArgs
13676 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShow))
13680 if (anArg == "-fixedanimation")
13682 aViewCube->SetFixedAnimationLoop (toShow);
13684 else if (anArg == "-axes")
13686 aViewCube->SetDrawAxes (toShow);
13688 else if (anArg == "-edges")
13690 aViewCube->SetDrawEdges (toShow);
13694 aViewCube->SetDrawVertices (toShow);
13697 else if (anArg == "-yup"
13698 || anArg == "-zup")
13701 if (anArgIter + 1 < theNbArgs
13702 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isOn))
13706 if (anArg == "-yup")
13708 aViewCube->SetYup (isOn);
13712 aViewCube->SetYup (!isOn);
13715 else if (anArgIter + 1 < theNbArgs
13716 && anArg == "-font")
13718 aViewCube->SetFont (theArgVec[++anArgIter]);
13720 else if (anArgIter + 1 < theNbArgs
13721 && anArg == "-fontheight")
13723 aViewCube->SetFontHeight (Draw::Atof (theArgVec[++anArgIter]));
13725 else if (anArgIter + 1 < theNbArgs
13726 && (anArg == "-size"
13727 || anArg == "-boxsize"))
13729 aViewCube->SetSize (Draw::Atof (theArgVec[++anArgIter]),
13730 anArg != "-boxsize");
13732 else if (anArgIter + 1 < theNbArgs
13733 && (anArg == "-boxfacet"
13734 || anArg == "-boxfacetextension"
13735 || anArg == "-facetextension"
13736 || anArg == "-extension"))
13738 aViewCube->SetBoxFacetExtension (Draw::Atof (theArgVec[++anArgIter]));
13740 else if (anArgIter + 1 < theNbArgs
13741 && (anArg == "-boxedgegap"
13742 || anArg == "-edgegap"))
13744 aViewCube->SetBoxEdgeGap (Draw::Atof (theArgVec[++anArgIter]));
13746 else if (anArgIter + 1 < theNbArgs
13747 && (anArg == "-boxedgeminsize"
13748 || anArg == "-edgeminsize"))
13750 aViewCube->SetBoxEdgeMinSize (Draw::Atof (theArgVec[++anArgIter]));
13752 else if (anArgIter + 1 < theNbArgs
13753 && (anArg == "-boxcornerminsize"
13754 || anArg == "-cornerminsize"))
13756 aViewCube->SetBoxCornerMinSize (Draw::Atof (theArgVec[++anArgIter]));
13758 else if (anArgIter + 1 < theNbArgs
13759 && anArg == "-axespadding")
13761 aViewCube->SetAxesPadding (Draw::Atof (theArgVec[++anArgIter]));
13763 else if (anArgIter + 1 < theNbArgs
13764 && anArg == "-roundradius")
13766 aViewCube->SetRoundRadius (Draw::Atof (theArgVec[++anArgIter]));
13768 else if (anArgIter + 1 < theNbArgs
13769 && anArg == "-duration")
13771 aViewCube->SetDuration (Draw::Atof (theArgVec[++anArgIter]));
13773 else if (anArgIter + 1 < theNbArgs
13774 && anArg == "-axesradius")
13776 aViewCube->SetAxesRadius (Draw::Atof (theArgVec[++anArgIter]));
13778 else if (anArgIter + 1 < theNbArgs
13779 && anArg == "-axesconeradius")
13781 aViewCube->SetAxesConeRadius (Draw::Atof (theArgVec[++anArgIter]));
13783 else if (anArgIter + 1 < theNbArgs
13784 && anArg == "-axessphereradius")
13786 aViewCube->SetAxesSphereRadius (Draw::Atof (theArgVec[++anArgIter]));
13790 Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'";
13794 if (aViewCube.IsNull())
13796 Message::SendFail ("Syntax error: wrong number of arguments");
13800 ViewerTest::Display (aName, aViewCube, false);
13804 //===============================================================================================
13805 //function : VColorConvert
13807 //===============================================================================================
13808 static int VColorConvert (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
13810 if (theNbArgs != 6)
13812 std::cerr << "Error: command syntax is incorrect, see help" << std::endl;
13816 Standard_Boolean convertFrom = (! strcasecmp (theArgVec[1], "from"));
13817 if (! convertFrom && strcasecmp (theArgVec[1], "to"))
13819 std::cerr << "Error: first argument must be either \"to\" or \"from\"" << std::endl;
13823 const char* aTypeStr = theArgVec[2];
13824 Quantity_TypeOfColor aType = Quantity_TOC_RGB;
13825 if (! strcasecmp (aTypeStr, "srgb"))
13827 aType = Quantity_TOC_sRGB;
13829 else if (! strcasecmp (aTypeStr, "hls"))
13831 aType = Quantity_TOC_HLS;
13833 else if (! strcasecmp (aTypeStr, "lab"))
13835 aType = Quantity_TOC_CIELab;
13837 else if (! strcasecmp (aTypeStr, "lch"))
13839 aType = Quantity_TOC_CIELch;
13843 std::cerr << "Error: unknown colorspace type: " << aTypeStr << std::endl;
13847 double aC1 = Draw::Atof (theArgVec[3]);
13848 double aC2 = Draw::Atof (theArgVec[4]);
13849 double aC3 = Draw::Atof (theArgVec[5]);
13851 Quantity_Color aColor (aC1, aC2, aC3, convertFrom ? aType : Quantity_TOC_RGB);
13852 aColor.Values (aC1, aC2, aC3, convertFrom ? Quantity_TOC_RGB : aType);
13854 // print values with 6 decimal digits
13856 Sprintf (buffer, "%.6f %.6f %.6f", aC1, aC2, aC3);
13862 //===============================================================================================
13863 //function : VColorDiff
13865 //===============================================================================================
13866 static int VColorDiff (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
13868 if (theNbArgs != 7)
13870 std::cerr << "Error: command syntax is incorrect, see help" << std::endl;
13874 double aR1 = Draw::Atof (theArgVec[1]);
13875 double aG1 = Draw::Atof (theArgVec[2]);
13876 double aB1 = Draw::Atof (theArgVec[3]);
13877 double aR2 = Draw::Atof (theArgVec[4]);
13878 double aG2 = Draw::Atof (theArgVec[5]);
13879 double aB2 = Draw::Atof (theArgVec[6]);
13881 Quantity_Color aColor1 (aR1, aG1, aB1, Quantity_TOC_RGB);
13882 Quantity_Color aColor2 (aR2, aG2, aB2, Quantity_TOC_RGB);
13884 theDI << aColor1.DeltaE2000 (aColor2);
13889 //=======================================================================
13890 //function : ViewerCommands
13892 //=======================================================================
13894 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
13897 const char *group = "ZeViewer";
13898 theCommands.Add("vinit",
13899 "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]"
13900 "\n\t\t: [-exitOnClose] [-closeOnEscape] [-cloneActive] [-2d_mode {on|off}=off]"
13901 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
13902 "\n\t\t: [-display displayName]"
13904 "\n\t\t: Creates new View window with specified name viewName."
13905 "\n\t\t: By default the new view is created in the viewer and in"
13906 "\n\t\t: graphic driver shared with active view."
13907 "\n\t\t: -name {driverName/viewerName/viewName | viewerName/viewName | viewName}"
13908 "\n\t\t: If driverName isn't specified the driver will be shared with active view."
13909 "\n\t\t: If viewerName isn't specified the viewer will be shared with active view."
13910 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
13911 "\n\t\t: -display HostName.DisplayNumber[:ScreenNumber]"
13912 "\n\t\t: Display name will be used within creation of graphic driver, when specified."
13914 "\n\t\t: -left, -top pixel position of left top corner of the window."
13915 "\n\t\t: -width, -height width and heigth of window respectively."
13916 "\n\t\t: -cloneActive floag to copy camera and dimensions of active view."
13917 "\n\t\t: -exitOnClose when specified, closing the view will exit application."
13918 "\n\t\t: -closeOnEscape when specified, view will be closed on pressing Escape."
13919 "\n\t\t: -2d_mode when on, view will not react on rotate scene events"
13920 "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.",
13921 __FILE__,VInit,group);
13922 theCommands.Add("vclose" ,
13923 "[view_id [keep_context=0|1]]\n"
13924 "or vclose ALL - to remove all created views\n"
13925 " - removes view(viewer window) defined by its view_id.\n"
13926 " - keep_context: by default 0; if 1 and the last view is deleted"
13927 " the current context is not removed.",
13928 __FILE__,VClose,group);
13929 theCommands.Add("vactivate" ,
13930 "vactivate view_id [-noUpdate]"
13931 " - activates view(viewer window) defined by its view_id",
13932 __FILE__,VActivate,group);
13933 theCommands.Add("vviewlist",
13934 "vviewlist [format={tree, long}]"
13935 " - prints current list of views per viewer and graphic_driver ID shared between viewers"
13936 " - format: format of result output, if tree the output is a tree view;"
13937 "otherwise it's a list of full view names. By default format = tree",
13938 __FILE__,VViewList,group);
13939 theCommands.Add("vhelp" ,
13940 "vhelp : display help on the viewer commands",
13941 __FILE__,VHelp,group);
13942 theCommands.Add("vviewproj",
13943 "vviewproj [top|bottom|left|right|front|back|axoLeft|axoRight]"
13944 "\n\t\t: [+-X+-Y+-Z] [-Zup|-Yup] [-frame +-X+-Y]"
13945 "\n\t\t: Setup view direction"
13946 "\n\t\t: -Yup use Y-up convention instead of Zup (which is default)."
13947 "\n\t\t: +-X+-Y+-Z define direction as combination of DX, DY and DZ;"
13948 "\n\t\t: for example '+Z' will show front of the model,"
13949 "\n\t\t: '-X-Y+Z' will define left axonometrical view."
13950 "\n\t\t: -frame define camera Up and Right directions (regardless Up convention);"
13951 "\n\t\t: for example '+X+Z' will show front of the model with Z-up."
13952 __FILE__,VViewProj,group);
13953 theCommands.Add("vtop" ,
13954 "vtop or <T> : Top view. Orientation +X+Y" ,
13955 __FILE__,VViewProj,group);
13956 theCommands.Add("vbottom" ,
13957 "vbottom : Bottom view. Orientation +X-Y" ,
13958 __FILE__,VViewProj,group);
13959 theCommands.Add("vleft" ,
13960 "vleft : Left view. Orientation -Y+Z" ,
13961 __FILE__,VViewProj,group);
13962 theCommands.Add("vright" ,
13963 "vright : Right view. Orientation +Y+Z" ,
13964 __FILE__,VViewProj,group);
13965 theCommands.Add("vaxo" ,
13966 " vaxo or <A> : Axonometric view. Orientation +X-Y+Z",
13967 __FILE__,VViewProj,group);
13968 theCommands.Add("vfront" ,
13969 "vfront : Front view. Orientation +X+Z" ,
13970 __FILE__,VViewProj,group);
13971 theCommands.Add("vback" ,
13972 "vback : Back view. Orientation -X+Z" ,
13973 __FILE__,VViewProj,group);
13974 theCommands.Add("vpick" ,
13975 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
13977 theCommands.Add("vfit",
13978 "vfit or <F> [-selected] [-noupdate]"
13979 "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects",
13980 __FILE__,VFit,group);
13981 theCommands.Add ("vfitarea",
13982 "vfitarea x1 y1 x2 y2"
13983 "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2"
13984 "\n\t\t: Fit view to show area located between two points"
13985 "\n\t\t: given in world 2D or 3D corrdinates.",
13986 __FILE__, VFitArea, group);
13987 theCommands.Add ("vzfit", "vzfit [scale]\n"
13988 " Matches Z near, Z far view volume planes to the displayed objects.\n"
13989 " \"scale\" - specifies factor to scale computed z range.\n",
13990 __FILE__, VZFit, group);
13991 theCommands.Add("vrepaint",
13992 "vrepaint [-immediate] [-continuous FPS]"
13993 "\n\t\t: force redraw of active View"
13994 "\n\t\t: -immediate flag performs redraw of immediate layers only;"
13995 "\n\t\t: -continuous activates/deactivates continuous redraw of active View,"
13996 "\n\t\t: 0 means no continuous rendering,"
13997 "\n\t\t: -1 means non-stop redraws,"
13998 "\n\t\t: >0 specifies target framerate,",
13999 __FILE__,VRepaint,group);
14000 theCommands.Add("vclear",
14002 "\n\t\t: remove all the object from the viewer",
14003 __FILE__,VClear,group);
14006 "Changes background or some background settings.\n"
14009 " vbackground -imageFile ImageFile [-imageMode FillType]\n"
14010 " vbackground -imageMode FillType\n"
14011 " vbackground -gradient Color1 Color2 [-gradientMode FillMethod]\n"
14012 " vbackground -gradientMode FillMethod\n"
14013 " vbackground -cubemap CubemapFile1 [CubeMapFiles2-5] [-order TilesIndexes1-6] [-invertedz]\n"
14014 " vbackground -color Color\n"
14015 " vbackground -default -gradient Color1 Color2 [-gradientMode FillType]\n"
14016 " vbackground -default -color Color\n"
14017 " vbackground -help\n"
14020 " -imageFile (-imgFile, -image, -img): sets filename of image used as background\n"
14021 " -imageMode (-imgMode, -imageMd, -imgMd): sets image fill type\n"
14022 " -gradient (-grad, -gr): sets background gradient starting and ending colors\n"
14023 " -gradientMode (-gradMode, -gradMd, -grMode, -grMd): sets gradient fill method\n"
14024 " -cubemap (-cmap, -cm): sets environmet cubemap as background\n"
14025 " -invertedz (-invz, -iz): sets inversion of Z axis for background cubemap rendering\n"
14026 " -order (-o): defines order of tiles in one image cubemap\n"
14027 " (has no effect in case of multi image cubemaps)\n"
14028 " -color (-col): sets background color\n"
14029 " -default (-def): sets background default gradient or color\n"
14030 " -help (-h): outputs short help message\n"
14033 " Color: Red Green Blue - where Red, Green, Blue must be integers within the range [0, 255]\n"
14034 " or reals within the range [0.0, 1.0]\n"
14035 " ColorName - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
14036 " #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
14037 " FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
14039 " FillType: one of CENTERED, TILED, STRETCH, NONE\n"
14040 " ImageFile: a name of the file with the image used as a background\n"
14041 " CubemapFilei: a name of the file with one image packed cubemap or names of separate files with every cubemap side\n"
14042 " TileIndexi: a cubemap side index in range [0, 5] for i tile of one image packed cubemap\n",
14046 theCommands.Add ("vsetbg",
14047 "Loads image as background."
14048 "\n\t\t: vsetbg ImageFile [FillType]"
14049 "\n\t\t: vsetbg -imageFile ImageFile [-imageMode FillType]"
14050 "\n\t\t: Alias for 'vbackground -imageFile ImageFile [-imageMode FillType]'.",
14054 theCommands.Add ("vsetbgmode",
14055 "Changes background image fill type."
14056 "\n\t\t: vsetbgmode [-imageMode] FillType"
14057 "\n\t\t: Alias for 'vbackground -imageMode FillType'.",
14061 theCommands.Add ("vsetgradientbg",
14062 "Mounts gradient background."
14063 "\n\t\t: vsetgradientbg Color1 Color2 [FillMethod]"
14064 "\n\t\t: vsetgradientbg -gradient Color1 Color2 [-gradientMode FillMethod]"
14065 "\n\t\t: Alias for 'vbackground -gradient Color1 Color2 -gradientMode FillMethod'.",
14069 theCommands.Add ("vsetgrbgmode",
14070 "Changes gradient background fill method."
14071 "\n\t\t: vsetgrbgmode [-gradientMode] FillMethod"
14072 "\n\t\t: Alias for 'vbackground -gradientMode FillMethod'.",
14076 theCommands.Add ("vsetcolorbg",
14077 "Sets background color."
14078 "\n\t\t: vsetcolorbg [-color] Color."
14079 "\n\t\t: Alias for 'vbackground -color Color'.",
14083 theCommands.Add ("vsetdefaultbg",
14084 "Sets default viewer background fill color (flat/gradient)."
14085 "\n\t\t: vsetdefaultbg Color1 Color2 [FillMethod]"
14086 "\n\t\t: vsetdefaultbg -gradient Color1 Color2 [-gradientMode FillMethod]"
14087 "\n\t\t: Alias for 'vbackground -default -gradient Color1 Color2 [-gradientMode FillMethod]'."
14088 "\n\t\t: vsetdefaultbg [-color] Color"
14089 "\n\t\t: Alias for 'vbackground -default -color Color'.",
14093 theCommands.Add("vscale",
14094 "vscale : vscale X Y Z",
14095 __FILE__,VScale,group);
14096 theCommands.Add("vzbufftrihedron",
14097 "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]"
14098 "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]"
14099 "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]"
14100 "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]"
14101 "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]"
14102 "\n\t\t: Displays a trihedron",
14103 __FILE__,VZBuffTrihedron,group);
14104 theCommands.Add("vrotate",
14105 "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]"
14106 "\n : Option -mouseStart starts rotation according to the mouse position"
14107 "\n : Option -mouseMove continues rotation with angle computed"
14108 "\n : from last and new mouse position."
14109 "\n : vrotate AX AY AZ [X Y Z]",
14110 __FILE__,VRotate,group);
14111 theCommands.Add("vzoom",
14112 "vzoom : vzoom coef",
14113 __FILE__,VZoom,group);
14114 theCommands.Add("vpan",
14115 "vpan : vpan dx dy",
14116 __FILE__,VPan,group);
14117 theCommands.Add("vcolorscale",
14118 "vcolorscale name [-noupdate|-update] [-demo]"
14119 "\n\t\t: [-range RangeMin=0 RangeMax=1 NbIntervals=10]"
14120 "\n\t\t: [-font HeightFont=20]"
14121 "\n\t\t: [-logarithmic {on|off}=off] [-reversed {on|off}=off]"
14122 "\n\t\t: [-smoothTransition {on|off}=off]"
14123 "\n\t\t: [-hueRange MinAngle=230 MaxAngle=0]"
14124 "\n\t\t: [-colorRange MinColor=BLUE1 MaxColor=RED]"
14125 "\n\t\t: [-textpos {left|right|center|none}=right]"
14126 "\n\t\t: [-labelAtBorder {on|off}=on]"
14127 "\n\t\t: [-colors Color1 Color2 ...] [-color Index Color]"
14128 "\n\t\t: [-labels Label1 Label2 ...] [-label Index Label]"
14129 "\n\t\t: [-freeLabels NbOfLabels Label1 Label2 ...]"
14130 "\n\t\t: [-xy Left=0 Bottom=0]"
14131 "\n\t\t: [-uniform lightness hue_from hue_to]"
14132 "\n\t\t: -demo - displays a color scale with demonstratio values"
14133 "\n\t\t: -colors - set colors for all intervals"
14134 "\n\t\t: -color - set color for specific interval"
14135 "\n\t\t: -uniform - generate colors with the same lightness"
14136 "\n\t\t: -textpos - horizontal label position relative to color scale bar"
14137 "\n\t\t: -labelAtBorder - vertical label position relative to color interval;"
14138 "\n\t\t: at border means the value inbetween neighbor intervals,"
14139 "\n\t\t: at center means the center value within current interval"
14140 "\n\t\t: -labels - set labels for all intervals"
14141 "\n\t\t: -freeLabels - same as -labels but does not require"
14142 "\n\t\t: matching the number of intervals"
14143 "\n\t\t: -label - set label for specific interval"
14144 "\n\t\t: -title - set title"
14145 "\n\t\t: -reversed - setup smooth color transition between intervals"
14146 "\n\t\t: -smoothTransition - swap colorscale direction"
14147 "\n\t\t: -hueRange - set hue angles corresponding to minimum and maximum values",
14148 __FILE__, VColorScale, group);
14149 theCommands.Add("vgraduatedtrihedron",
14150 "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n"
14151 "\t[-namefont Name] [-valuesfont Name]\n"
14152 "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n"
14153 "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]"
14154 "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n"
14155 "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n"
14156 "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]"
14157 "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n"
14158 "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n"
14159 "\t[-xticks Number] [-yticks Number] [-zticks Number]\n"
14160 "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n"
14161 "\t[-drawgrid on/off] [-drawaxes on/off]\n"
14162 " - Displays or erases graduated trihedron"
14163 " - xname, yname, zname - names of axes, default: X, Y, Z\n"
14164 " - namefont - font of axes names. Default: Arial\n"
14165 " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n"
14166 " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n"
14167 " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n"
14168 " - valuesfont - font of axes values. Default: Arial\n"
14169 " - xcolor, ycolor, zcolor - color of axis and values\n"
14170 " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n"
14171 " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n",
14172 __FILE__,VGraduatedTrihedron,group);
14173 theCommands.Add("vtile" ,
14174 "vtile [-totalSize W H] [-lowerLeft X Y] [-upperLeft X Y] [-tileSize W H]"
14175 "\n\t\t: Setup view to draw a tile (a part of virtual bigger viewport)."
14176 "\n\t\t: -totalSize the size of virtual bigger viewport"
14177 "\n\t\t: -tileSize tile size (the view size will be used if omitted)"
14178 "\n\t\t: -lowerLeft tile offset as lower left corner"
14179 "\n\t\t: -upperLeft tile offset as upper left corner",
14180 __FILE__, VTile, group);
14181 theCommands.Add("vzlayer",
14182 "vzlayer [layerId]"
14183 "\n\t\t: [-add|-delete|-get|-settings] [-insertBefore AnotherLayer] [-insertAfter AnotherLayer]"
14184 "\n\t\t: [-origin X Y Z] [-cullDist Distance] [-cullSize Size]"
14185 "\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
14186 "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv|rayTracing}]"
14187 "\n\t\t: ZLayer list management:"
14188 "\n\t\t: -add add new z layer to viewer and print its id"
14189 "\n\t\t: -insertBefore add new z layer and insert it before existing one"
14190 "\n\t\t: -insertAfter add new z layer and insert it after existing one"
14191 "\n\t\t: -delete delete z layer"
14192 "\n\t\t: -get print sequence of z layers"
14193 "\n\t\t: -settings print status of z layer settings"
14194 "\n\t\t: -disable disables given setting"
14195 "\n\t\t: -enable enables given setting",
14196 __FILE__,VZLayer,group);
14197 theCommands.Add("vlayerline",
14198 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
14199 __FILE__,VLayerLine,group);
14200 theCommands.Add("vgrid",
14201 "vgrid [off] [-type {rect|circ}] [-mode {line|point}] [-origin X Y] [-rotAngle Angle] [-zoffset DZ]"
14202 "\n\t\t: [-step X Y] [-size DX DY]"
14203 "\n\t\t: [-step StepRadius NbDivisions] [-radius Radius]",
14204 __FILE__, VGrid, group);
14205 theCommands.Add ("vpriviledgedplane",
14206 "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]"
14207 "\n\t\t: Ox, Oy, Oz - plane origin"
14208 "\n\t\t: Nx, Ny, Nz - plane normal direction"
14209 "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction"
14210 "\n\t\t: Sets or prints viewer's priviledged plane geometry.",
14211 __FILE__, VPriviledgedPlane, group);
14212 theCommands.Add ("vconvert",
14213 "vconvert v [Mode={window|view}]"
14214 "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]"
14215 "\n\t\t: vconvert x y z [Mode={window|grid}]"
14216 "\n\t\t: window - convert to window coordinates, pixels"
14217 "\n\t\t: view - convert to view projection plane"
14218 "\n\t\t: grid - convert to model coordinates, given on grid"
14219 "\n\t\t: ray - convert projection ray to model coordiantes"
14220 "\n\t\t: - vconvert v window : convert view to window;"
14221 "\n\t\t: - vconvert v view : convert window to view;"
14222 "\n\t\t: - vconvert x y window : convert view to window;"
14223 "\n\t\t: - vconvert x y view : convert window to view;"
14224 "\n\t\t: - vconvert x y : convert window to model;"
14225 "\n\t\t: - vconvert x y grid : convert window to model using grid;"
14226 "\n\t\t: - vconvert x y ray : convert window projection line to model;"
14227 "\n\t\t: - vconvert x y z window : convert model to window;"
14228 "\n\t\t: - vconvert x y z grid : convert view to model using grid;"
14229 "\n\t\t: Converts the given coordinates to window/view/model space.",
14230 __FILE__, VConvert, group);
14231 theCommands.Add ("vfps",
14232 "vfps [framesNb=100] [-duration seconds] : estimate average frame rate for active view",
14233 __FILE__, VFps, group);
14234 theCommands.Add ("vgldebug",
14235 "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
14236 "\n\t\t: [-glslCode {off|short|full}] [-extraMsg {0|1}] [{0|1}]"
14237 "\n\t\t: Request debug GL context. Should be called BEFORE vinit."
14238 "\n\t\t: Debug context can be requested only on Windows"
14239 "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!"
14240 "\n\t\t: -sync - request synchronized debug GL context"
14241 "\n\t\t: -glslWarn - log GLSL compiler/linker warnings,"
14242 "\n\t\t: which are suppressed by default,"
14243 "\n\t\t: -glslCode - log GLSL program source code,"
14244 "\n\t\t: which are suppressed by default,"
14245 "\n\t\t: -extraMsg - log extra diagnostic messages from GL context,"
14246 "\n\t\t: which are suppressed by default",
14247 __FILE__, VGlDebug, group);
14248 theCommands.Add ("vvbo",
14249 "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
14250 __FILE__, VVbo, group);
14251 theCommands.Add ("vstereo",
14252 "vstereo [0|1] [-mode Mode] [-reverse {0|1}]"
14253 "\n\t\t: [-mirrorComposer] [-hmdfov2d AngleDegrees] [-unitFactor MetersFactor]"
14254 "\n\t\t: [-anaglyph Filter]"
14255 "\n\t\t: Control stereo output mode."
14256 "\n\t\t: When -mirrorComposer is specified, VR rendered frame will be mirrored in window (debug)."
14257 "\n\t\t: Parameter -unitFactor specifies meters scale factor for mapping VR input."
14258 "\n\t\t: Available modes for -mode:"
14259 "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo,"
14260 "\n\t\t: requires driver support."
14261 "\n\t\t: Should be called BEFORE vinit!"
14262 "\n\t\t: anaglyph - Anaglyph glasses"
14263 "\n\t\t: rowInterlaced - row-interlaced display"
14264 "\n\t\t: columnInterlaced - column-interlaced display"
14265 "\n\t\t: chessBoard - chess-board output"
14266 "\n\t\t: sideBySide - horizontal pair"
14267 "\n\t\t: overUnder - vertical pair"
14268 "\n\t\t: openVR - OpenVR (HMD)"
14269 "\n\t\t: Available Anaglyph filters for -anaglyph:"
14270 "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple,"
14271 "\n\t\t: greenMagentaSimple",
14272 __FILE__, VStereo, group);
14273 theCommands.Add ("vcaps",
14274 "vcaps [-sRGB {0|1}] [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
14275 "\n\t\t: [-compatibleProfile {0|1}] [-compressedTextures {0|1}]"
14276 "\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
14277 "\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
14278 "\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
14279 "\n\t\t: [-noExtensions {0|1}] [-maxVersion Major Minor]"
14280 "\n\t\t: Modify particular graphic driver options:"
14281 "\n\t\t: sRGB - enable/disable sRGB rendering"
14282 "\n\t\t: FFP - use fixed-function pipeline instead of"
14283 "\n\t\t: built-in GLSL programs"
14284 "\n\t\t: (requires compatible profile)"
14285 "\n\t\t: polygonMode - use Polygon Mode instead of built-in GLSL programs"
14286 "\n\t\t: compressedTexture - allow uploading of GPU-supported compressed texture formats"
14287 "\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
14288 "\n\t\t: arrays to GPU memory)"
14289 "\n\t\t: sprite - use textured sprites instead of bitmaps"
14290 "\n\t\t: vsync - switch VSync on or off"
14291 "\n\t\t: winBuffer - allow using window buffer for rendering"
14292 "\n\t\t: Context creation options:"
14293 "\n\t\t: softMode - software OpenGL implementation"
14294 "\n\t\t: compatibleProfile - backward-compatible profile"
14295 "\n\t\t: quadbuffer - QuadBuffer"
14296 "\n\t\t: noExtensions - disallow usage of extensions"
14297 "\n\t\t: maxVersion - force upper OpenGL version to be used"
14298 "\n\t\t: Unlike vrenderparams, these parameters control alternative"
14299 "\n\t\t: rendering paths producing the same visual result when"
14300 "\n\t\t: possible."
14301 "\n\t\t: Command is intended for testing old hardware compatibility.",
14302 __FILE__, VCaps, group);
14303 theCommands.Add ("vmemgpu",
14304 "vmemgpu [f]: print system-dependent GPU memory information if available;"
14305 " with f option returns free memory in bytes",
14306 __FILE__, VMemGpu, group);
14307 theCommands.Add ("vreadpixel",
14308 "vreadpixel xPixel yPixel [{rgb|rgba|sRGB|sRGBa|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
14309 " : Read pixel value for active view",
14310 __FILE__, VReadPixel, group);
14311 theCommands.Add("diffimage",
14312 "diffimage imageFile1 imageFile2 [diffImageFile]"
14313 "\n\t\t: [-toleranceOfColor {0..1}=0] [-blackWhite {on|off}=off] [-borderFilter {on|off}=off]"
14314 "\n\t\t: [-display viewName prsName1 prsName2 prsNameDiff] [-exitOnClose] [-closeOnEscape]"
14315 "\n\t\t: Compare two images by content and generate difference image."
14316 "\n\t\t: When -exitOnClose is specified, closing the view will exit application."
14317 "\n\t\t: When -closeOnEscape is specified, view will be closed on pressing Escape.",
14318 __FILE__, VDiffImage, group);
14319 theCommands.Add ("vselect",
14320 "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
14321 "- emulates different types of selection:\n"
14322 "- 1) single click selection\n"
14323 "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
14324 "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
14325 "- 4) -allowoverlap manages overlap and inclusion detection in rectangular and polygonal selection.\n"
14326 " If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined \n"
14327 " rectangle or polygon will be detected, otherwise algorithm will chose only fully included sensitives.\n"
14328 " Default behavior is to detect only full inclusion. (partial inclusion - overlap - is not allowed by default)\n"
14329 "- 5) any of these selections with shift button pressed",
14330 __FILE__, VSelect, group);
14331 theCommands.Add ("vmoveto",
14332 "vmoveto [x y] [-reset]"
14333 "\n\t\t: Emulates cursor movement to pixel position (x,y)."
14334 "\n\t\t: -reset resets current highlighting",
14335 __FILE__, VMoveTo, group);
14336 theCommands.Add ("vviewparams",
14337 "vviewparams [-args] [-scale [s]]"
14338 "\n\t\t: [-eye [x y z]] [-at [x y z]] [-up [x y z]]"
14339 "\n\t\t: [-proj [x y z]] [-center x y] [-size sx]"
14340 "\n\t\t: Manage current view parameters or prints all"
14341 "\n\t\t: current values when called without argument."
14342 "\n\t\t: -scale [s] prints or sets viewport relative scale"
14343 "\n\t\t: -eye [x y z] prints or sets eye location"
14344 "\n\t\t: -at [x y z] prints or sets center of look"
14345 "\n\t\t: -up [x y z] prints or sets direction of up vector"
14346 "\n\t\t: -proj [x y z] prints or sets direction of look"
14347 "\n\t\t: -center x y sets location of center of the screen in pixels"
14348 "\n\t\t: -size [sx] prints viewport projection width and height sizes"
14349 "\n\t\t: or changes the size of its maximum dimension"
14350 "\n\t\t: -args prints vviewparams arguments for restoring current view",
14351 __FILE__, VViewParams, group);
14353 theCommands.Add("v2dmode",
14354 "v2dmode [-name viewName] [-mode {-on|-off}=-on]"
14355 "\n\t\t: name - name of existing view, if not defined, the active view is changed"
14356 "\n\t\t: mode - switches On/Off rotation mode"
14357 "\n\t\t: Set 2D mode of the active viewer manipulating. The following mouse and key actions are disabled:"
14358 "\n\t\t: - rotation of the view by 3rd mouse button with Ctrl active"
14359 "\n\t\t: - set view projection using key buttons: A/D/T/B/L/R for AXO, Reset, Top, Bottom, Left, Right"
14360 "\n\t\t: View camera position might be changed only by commands.",
14361 __FILE__, V2DMode, group);
14363 theCommands.Add("vanimation", "Alias for vanim",
14364 __FILE__, VAnimation, group);
14366 theCommands.Add("vanim",
14367 "List existing animations:"
14369 "\n\t\t: Animation playback:"
14370 "\n\t\t: vanim name -play|-resume [playFrom [playDuration]]"
14371 "\n\t\t: [-speed Coeff] [-freeLook] [-lockLoop]"
14372 "\n\t\t: -speed playback speed (1.0 is normal speed)"
14373 "\n\t\t: -freeLook skip camera animations"
14374 "\n\t\t: -lockLoop disable any interactions"
14376 "\n\t\t: Animation definition:"
14377 "\n\t\t: vanim Name/sub/name [-clear] [-delete]"
14378 "\n\t\t: [start TimeSec] [duration TimeSec]"
14380 "\n\t\t: Animation name defined in path-style (anim/name or anim.name)"
14381 "\n\t\t: specifies nested animations."
14382 "\n\t\t: There is no syntax to explicitly add new animation,"
14383 "\n\t\t: and all non-existing animations within the name will be"
14384 "\n\t\t: implicitly created on first use (including parents)."
14386 "\n\t\t: Each animation might define the SINGLE action (see below),"
14387 "\n\t\t: like camera transition, object transformation or custom callback."
14388 "\n\t\t: Child animations can be used for defining concurrent actions."
14390 "\n\t\t: Camera animation:"
14391 "\n\t\t: vanim name -view [-eye1 X Y Z] [-eye2 X Y Z]"
14392 "\n\t\t: [-at1 X Y Z] [-at2 X Y Z]"
14393 "\n\t\t: [-up1 X Y Z] [-up2 X Y Z]"
14394 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
14395 "\n\t\t: -eyeX camera Eye positions pair (start and end)"
14396 "\n\t\t: -atX camera Center positions pair"
14397 "\n\t\t: -upX camera Up directions pair"
14398 "\n\t\t: -scaleX camera Scale factors pair"
14399 "\n\t\t: Object animation:"
14400 "\n\t\t: vanim name -object [-loc1 X Y Z] [-loc2 X Y Z]"
14401 "\n\t\t: [-rot1 QX QY QZ QW] [-rot2 QX QY QZ QW]"
14402 "\n\t\t: [-scale1 Scale] [-scale2 Scale]"
14403 "\n\t\t: -locX object Location points pair (translation)"
14404 "\n\t\t: -rotX object Orientations pair (quaternions)"
14405 "\n\t\t: -scaleX object Scale factors pair (quaternions)"
14406 "\n\t\t: Custom callback:"
14407 "\n\t\t: vanim name -invoke \"Command Arg1 Arg2 %Pts %LocalPts %Normalized ArgN\""
14408 "\n\t\t: %Pts overall animation presentation timestamp"
14409 "\n\t\t: %LocalPts local animation timestamp"
14410 "\n\t\t: %Normalized local animation normalized value in range 0..1"
14412 "\n\t\t: Video recording:"
14413 "\n\t\t: vanim name -record FileName [Width Height] [-fps FrameRate=24]"
14414 "\n\t\t: [-format Format] [-vcodec Codec] [-pix_fmt PixelFormat]"
14415 "\n\t\t: [-crf Value] [-preset Preset]"
14416 "\n\t\t: -fps video framerate"
14417 "\n\t\t: -format file format, container (matroska, etc.)"
14418 "\n\t\t: -vcodec video codec identifier (ffv1, mjpeg, etc.)"
14419 "\n\t\t: -pix_fmt image pixel format (yuv420p, rgb24, etc.)"
14420 "\n\t\t: -crf constant rate factor (specific to codec)"
14421 "\n\t\t: -preset codec parameters preset (specific to codec)"
14422 __FILE__, VAnimation, group);
14424 theCommands.Add("vchangeselected",
14425 "vchangeselected shape"
14426 "- adds to shape to selection or remove one from it",
14427 __FILE__, VChangeSelected, group);
14428 theCommands.Add ("vnbselected",
14430 "\n\t\t: Returns number of selected objects", __FILE__, VNbSelected, group);
14431 theCommands.Add ("vcamera",
14432 "vcamera [PrsName] [-ortho] [-projtype]"
14434 "\n\t\t: [-fovy [Angle]] [-distance [Distance]]"
14435 "\n\t\t: [-stereo] [-leftEye] [-rightEye]"
14436 "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]"
14437 "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]"
14438 "\n\t\t: [-fov2d [Angle]] [-lockZup {0|1}]"
14439 "\n\t\t: [-xrPose base|head=base]"
14440 "\n\t\t: Manages camera parameters."
14441 "\n\t\t: Displays frustum when presntation name PrsName is specified."
14442 "\n\t\t: Prints current value when option called without argument."
14443 "\n\t\t: Orthographic camera:"
14444 "\n\t\t: -ortho activate orthographic projection"
14445 "\n\t\t: Perspective camera:"
14446 "\n\t\t: -persp activate perspective projection (mono)"
14447 "\n\t\t: -fovy field of view in y axis, in degrees"
14448 "\n\t\t: -fov2d field of view limit for 2d on-screen elements"
14449 "\n\t\t: -distance distance of eye from camera center"
14450 "\n\t\t: -lockZup lock Z up (tunrtable mode)"
14451 "\n\t\t: Stereoscopic camera:"
14452 "\n\t\t: -stereo perspective projection (stereo)"
14453 "\n\t\t: -leftEye perspective projection (left eye)"
14454 "\n\t\t: -rightEye perspective projection (right eye)"
14455 "\n\t\t: -iod intraocular distance value"
14456 "\n\t\t: -iodType distance type, absolute or relative"
14457 "\n\t\t: -zfocus stereographic focus value"
14458 "\n\t\t: -zfocusType focus type, absolute or relative",
14459 __FILE__, VCamera, group);
14460 theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n"
14461 "- vautozfit [on={1|0}] [scale]\n"
14462 " Prints or changes parameters of automatic z-fit mode:\n"
14463 " \"on\" - turns automatic z-fit on or off\n"
14464 " \"scale\" - specifies factor to scale computed z range.\n",
14465 __FILE__, VAutoZFit, group);
14466 theCommands.Add ("vzrange", "command to manually access znear and zfar values\n"
14467 " vzrange - without parameters shows current values\n"
14468 " vzrange [znear] [zfar] - applies provided values to view",
14469 __FILE__,VZRange, group);
14470 theCommands.Add ("vpurgedisplay",
14472 "- removes structures which don't belong to objects displayed in neutral point",
14473 __FILE__, VPurgeDisplay, group);
14474 theCommands.Add("vsetviewsize",
14475 "vsetviewsize size",
14476 __FILE__,VSetViewSize,group);
14477 theCommands.Add("vmoveview",
14478 "vmoveview Dx Dy Dz [Start = 1|0]",
14479 __FILE__,VMoveView,group);
14480 theCommands.Add("vtranslateview",
14481 "vtranslateview Dx Dy Dz [Start = 1|0)]",
14482 __FILE__,VTranslateView,group);
14483 theCommands.Add("vturnview",
14484 "vturnview Ax Ay Az [Start = 1|0]",
14485 __FILE__,VTurnView,group);
14486 theCommands.Add("vtextureenv",
14487 "Enables or disables environment mapping in the 3D view, loading the texture from the given standard "
14488 "or user-defined file and optionally applying texture mapping parameters\n"
14490 " vtextureenv off - disables environment mapping\n"
14491 " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n"
14492 " std_texture = (0..7)\n"
14493 " rep = {clamp|repeat}\n"
14494 " mod = {decal|modulate}\n"
14495 " flt = {nearest|bilinear|trilinear}\n"
14496 " ss, st - scale factors for s and t texture coordinates\n"
14497 " ts, tt - translation for s and t texture coordinates\n"
14498 " rot - texture rotation angle in degrees",
14499 __FILE__, VTextureEnv, group);
14500 theCommands.Add("vhlr",
14501 "vhlr {on|off} [-showHidden={1|0}] [-algoType={algo|polyAlgo}] [-noupdate]"
14502 "\n\t\t: Hidden Line Removal algorithm."
14503 "\n\t\t: -showHidden if set ON, hidden lines are drawn as dotted ones"
14504 "\n\t\t: -algoType type of HLR algorithm.\n",
14505 __FILE__,VHLR,group);
14506 theCommands.Add("vhlrtype",
14507 "vhlrtype {algo|polyAlgo} [shape_1 ... shape_n] [-noupdate]"
14508 "\n\t\t: Changes the type of HLR algorithm using for shapes:"
14509 "\n\t\t: 'algo' - exact HLR algorithm is applied"
14510 "\n\t\t: 'polyAlgo' - polygonal HLR algorithm is applied"
14511 "\n\t\t: If shapes are not given - option is applied to all shapes in the view",
14512 __FILE__,VHLRType,group);
14513 theCommands.Add("vclipplane",
14514 "vclipplane planeName [{0|1}]"
14515 "\n\t\t: [-equation1 A B C D]"
14516 "\n\t\t: [-equation2 A B C D]"
14517 "\n\t\t: [-boxInterior MinX MinY MinZ MaxX MaxY MaxZ]"
14518 "\n\t\t: [-set|-unset|-setOverrideGlobal [objects|views]]"
14519 "\n\t\t: [-maxPlanes]"
14520 "\n\t\t: [-capping {0|1}]"
14521 "\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]"
14522 "\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
14523 "\n\t\t: [-texRotate Angle]"
14524 "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
14525 "\n\t\t: [-useObjShader {0|1}]"
14526 "\n\t\t: Clipping planes management:"
14527 "\n\t\t: -maxPlanes print plane limit for view"
14528 "\n\t\t: -delete delete plane with given name"
14529 "\n\t\t: {off|on|0|1} turn clipping on/off"
14530 "\n\t\t: -set|-unset set/unset plane for Object or View list;"
14531 "\n\t\t: applied to active View when list is omitted"
14532 "\n\t\t: -equation A B C D change plane equation"
14533 "\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
14534 "\n\t\t: Capping options:"
14535 "\n\t\t: -capping {off|on|0|1} turn capping on/off"
14536 "\n\t\t: -color R G B set capping color"
14537 "\n\t\t: -transparency Value set capping transparency 0..1"
14538 "\n\t\t: -texName Texture set capping texture"
14539 "\n\t\t: -texScale SX SY set capping tex scale"
14540 "\n\t\t: -texOrigin TX TY set capping tex origin"
14541 "\n\t\t: -texRotate Angle set capping tex rotation"
14542 "\n\t\t: -hatch {on|off|ID} set capping hatching mask"
14543 "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
14544 "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
14545 "\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
14546 __FILE__, VClipPlane, group);
14547 theCommands.Add("vdefaults",
14548 "vdefaults [-absDefl value]"
14549 "\n\t\t: [-devCoeff value]"
14550 "\n\t\t: [-angDefl value]"
14551 "\n\t\t: [-autoTriang {off/on | 0/1}]"
14552 , __FILE__, VDefaults, group);
14553 theCommands.Add("vlight",
14554 "tool to manage light sources, without arguments shows list of lights."
14555 "\n Main commands: "
14556 "\n '-clear' to clear lights"
14557 "\n '-{def}aults' to load deafault lights"
14558 "\n '-add' <type> to add any light source"
14559 "\n where <type> is one of {amb}ient|directional|{spot}light|positional"
14560 "\n 'change' <lightId> to edit light source with specified lightId"
14561 "\n\n In addition to 'add' and 'change' commands you can use light parameters:"
14563 "\n -{pos}ition X Y Z"
14564 "\n -{dir}ection X Y Z (for directional light or for spotlight)"
14565 "\n -color colorName"
14566 "\n -{head}light 0|1"
14567 "\n -{sm}oothness value"
14568 "\n -{int}ensity value"
14569 "\n -{constAtten}uation value"
14570 "\n -{linearAtten}uation value"
14571 "\n -angle angleDeg"
14572 "\n -{spotexp}onent value"
14574 "\n -local|-global"
14575 "\n\n example: vlight -add positional -head 1 -pos 0 1 1 -color red"
14576 "\n example: vlight -change 0 -direction 0 -1 0 -linearAttenuation 0.2",
14577 __FILE__, VLight, group);
14578 theCommands.Add("vpbrenv",
14579 "vpbrenv -clear|-generate"
14580 "\n\t\t: Clears or generates PBR environment map of active view."
14581 "\n\t\t: -clear clears PBR environment (fills by white color)"
14582 "\n\t\t: -generate generates PBR environment from current background cubemap",
14583 __FILE__, VPBREnvironment, group);
14584 theCommands.Add("vraytrace",
14586 "\n\t\t: Turns on/off ray-tracing renderer."
14587 "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'."
14588 "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.",
14589 __FILE__, VRenderParams, group);
14590 theCommands.Add("vrenderparams",
14591 "\n Manages rendering parameters: "
14592 "\n '-raster' Disables GPU ray-tracing"
14593 "\n '-msaa 0..4' Specifies number of samples for MSAA"
14594 "\n '-lineFeather > 0' Sets line feather factor"
14595 "\n '-oit off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
14596 "\n '-depthPrePass on|off' Enables/disables depth pre-pass"
14597 "\n '-alphatocoverage on|off' Enables/disables alpha to coverage (needs MSAA)"
14598 "\n '-rendScale value Rendering resolution scale factor"
14599 "\n '-rayTrace' Enables GPU ray-tracing"
14600 "\n '-rayDepth 0..10' Defines maximum ray-tracing depth"
14601 "\n '-shadows on|off' Enables/disables shadows rendering"
14602 "\n '-reflections on|off' Enables/disables specular reflections"
14603 "\n '-fsaa on|off' Enables/disables adaptive anti-aliasing"
14604 "\n '-gleam on|off' Enables/disables transparency shadow effects"
14605 "\n '-gi on|off' Enables/disables global illumination effects"
14606 "\n '-brng on|off' Enables/disables blocked RNG (fast coherent PT)"
14607 "\n '-env on|off' Enables/disables environment map background"
14608 "\n '-ignoreNormalMap on|off' Enables/disables normal map ignoring during path tracing"
14609 "\n '-twoside on|off' Enables/disables two-sided BSDF models (PT mode)"
14610 "\n '-iss on|off' Enables/disables adaptive screen sampling (PT mode)"
14611 "\n '-issd on|off' Shows screen sampling distribution in ISS mode"
14612 "\n '-maxrad > 0.0' Value used for clamping radiance estimation (PT mode)"
14613 "\n '-tileSize 1..4096' Specifies size of screen tiles in ISS mode (32 by default)"
14614 "\n '-nbtiles 64..1024' Specifies number of screen tiles per Redraw in ISS mode (256 by default)"
14615 "\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
14616 "\n '-shadingModel model' Controls shading model from enumeration"
14617 "\n unlit, flat, gouraud, phong"
14618 "\n '-pbrEnvPow2size > 0' Controls size of IBL maps (real size can be calculates as 2^pbrenvpow2size)"
14619 "\n '-pbrEnvSMLN > 1' Controls number of mipmap levels used in specular IBL map"
14620 "\n '-pbrEnvBDSN > 0' Controls number of samples in Monte-Carlo integration during diffuse IBL map's sherical harmonics calculation"
14621 "\n '-pbrEnvBSSN > 0' Controls maximum number of samples per mipmap level in Monte-Carlo integration during specular IBL maps generation"
14622 "\n '-pbrEnvBP [0, 1]' Controls strength of samples number reducing during specular IBL maps generation (1 disables reducing)"
14623 "\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"
14624 "\n '-aperture >= 0.0' Aperture size of perspective camera for depth-of-field effect (0 disables DOF)"
14625 "\n '-focal >= 0.0' Focal distance of perspective camera for depth-of-field effect"
14626 "\n '-exposure value' Exposure value for tone mapping (0.0 value disables the effect)"
14627 "\n '-whitepoint value' White point value for filmic tone mapping"
14628 "\n '-tonemapping mode' Tone mapping mode (disabled, filmic)"
14629 "\n '-perfCounters none|fps|cpu|layers|structures|groups|arrays|triangles|points"
14630 "\n ' |gpuMem|frameTime|basic|extended|full|nofps|skipImmediate'"
14631 "\n Show/hide performance counters (flags can be combined)"
14632 "\n '-perfUpdateInterval nbSeconds' Performance counters update interval"
14633 "\n '-perfChart nbFrames' Show frame timers chart limited by specified number of frames"
14634 "\n '-perfChartMax seconds' Maximum time in seconds with the chart"
14635 "\n '-frustumCulling on|off|noupdate' Enable/disable objects frustum clipping or"
14636 "\n set state to check structures culled previously."
14637 "\n Unlike vcaps, these parameters dramatically change visual properties."
14638 "\n Command is intended to control presentation quality depending on"
14639 "\n hardware capabilities and performance.",
14640 __FILE__, VRenderParams, group);
14641 theCommands.Add("vstatprofiler",
14642 "\n vstatprofiler [fps|cpu|allLayers|layers|allstructures|structures|groups"
14643 "\n |allArrays|fillArrays|lineArrays|pointArrays|textArrays"
14644 "\n |triangles|points|geomMem|textureMem|frameMem"
14645 "\n |elapsedFrame|cpuFrameAverage|cpuPickingAverage|cpuCullingAverage|cpuDynAverage"
14646 "\n |cpuFrameMax|cpuPickingMax|cpuCullingMax|cpuDynMax]"
14648 "\n\t\t: Prints rendering statistics."
14649 "\n\t\t: If there are some parameters - print corresponding statistic counters values,"
14650 "\n\t\t: else - print all performance counters set previously."
14651 "\n\t\t: '-noredraw' Flag to avoid additional redraw call and use already collected values.\n",
14652 __FILE__, VStatProfiler, group);
14653 theCommands.Add ("vplace",
14655 "\n\t\t: Places the point (in pixels) at the center of the window",
14656 __FILE__, VPlace, group);
14657 theCommands.Add("vxrotate",
14659 __FILE__,VXRotate,group);
14661 theCommands.Add("vmanipulator",
14662 "\n vmanipulator Name [-attach AISObject | -detach | ...]"
14663 "\n tool to create and manage AIS manipulators."
14665 "\n '-attach AISObject' attach manipulator to AISObject"
14666 "\n '-adjustPosition {0|1}' adjust position when attaching"
14667 "\n '-adjustSize {0|1}' adjust size when attaching"
14668 "\n '-enableModes {0|1}' enable modes when attaching"
14669 "\n '-view {active | [name of view]}' display manipulator only in defined view,"
14670 "\n by default it is displayed in all views of the current viewer"
14671 "\n '-detach' detach manipulator"
14672 "\n '-startTransform mouse_x mouse_y' - invoke start of transformation"
14673 "\n '-transform mouse_x mouse_y' - invoke transformation"
14674 "\n '-stopTransform [abort]' - invoke stop of transformation"
14675 "\n '-move x y z' - move attached object"
14676 "\n '-rotate x y z dx dy dz angle' - rotate attached object"
14677 "\n '-scale factor' - scale attached object"
14678 "\n '-autoActivate {0|1}' - set activation on detection"
14679 "\n '-followTranslation {0|1}' - set following translation transform"
14680 "\n '-followRotation {0|1}' - set following rotation transform"
14681 "\n '-followDragging {0|1}' - set following dragging transform"
14682 "\n '-gap value' - set gap between sub-parts"
14683 "\n '-part axis mode {0|1}' - set visual part"
14684 "\n '-parts axis mode {0|1}' - set visual part"
14685 "\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator"
14686 "\n '-size value' - set size of manipulator"
14687 "\n '-zoomable {0|1}' - set zoom persistence",
14688 __FILE__, VManipulator, group);
14690 theCommands.Add("vselprops",
14691 "\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]"
14692 "\n Customizes selection and dynamic highlight parameters for the whole interactive context:"
14693 "\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode"
14694 "\n -autoHighlight {0|1} : disables|enables automatic highlighting in 3D Viewer"
14695 "\n -highlightSelected {0|1}: disables|enables highlighting of detected object in selected state"
14696 "\n -pickStrategy {first|topmost} : defines picking strategy"
14697 "\n 'first' to pick first acceptable (default)"
14698 "\n 'topmost' to pick only topmost (and nothing, if topmost is rejected by filters)"
14699 "\n -pixTol value : sets up pixel tolerance"
14700 "\n -dispMode dispMode : sets display mode for highlighting"
14701 "\n -layer ZLayer : sets ZLayer for highlighting"
14702 "\n -color {name|r g b} : sets highlight color"
14703 "\n -transp value : sets transparency coefficient for highlight"
14704 "\n -material material : sets highlight material"
14705 "\n -print : prints current state of all mentioned parameters",
14706 __FILE__, VSelectionProperties, group);
14707 theCommands.Add ("vhighlightselected",
14708 "vhighlightselected [0|1]: alias for vselprops -highlightSelected.\n",
14709 __FILE__, VSelectionProperties, group);
14711 theCommands.Add ("vseldump",
14712 "vseldump file -type {depth|unnormDepth|object|owner|selMode|entity}=depth -pickedIndex Index=1"
14713 "\n\t\t: [-xrPose base|head=base]"
14714 "\n\t\t: Generate an image based on detection results:"
14715 "\n\t\t: depth normalized depth values"
14716 "\n\t\t: unnormDepth unnormalized depth values"
14717 "\n\t\t: object color of detected object"
14718 "\n\t\t: owner color of detected owner"
14719 "\n\t\t: selMode color of selection mode"
14720 "\n\t\t: entity color of etected entity",
14721 __FILE__, VDumpSelectionImage, group);
14723 theCommands.Add ("vviewcube",
14725 "\n\t\t: Displays interactive view manipualtion object."
14726 "\n\t\t: Options: "
14727 "\n\t\t: -reset reset geomertical and visual attributes'"
14728 "\n\t\t: -size Size adapted size of View Cube"
14729 "\n\t\t: -boxSize Size box size"
14730 "\n\t\t: -axes {0|1 } show/hide axes (trihedron)"
14731 "\n\t\t: -edges {0|1} show/hide edges of View Cube"
14732 "\n\t\t: -vertices {0|1} show/hide vertices of View Cube"
14733 "\n\t\t: -Yup {0|1} -Zup {0|1} set Y-up or Z-up view orientation"
14734 "\n\t\t: -color Color color of View Cube"
14735 "\n\t\t: -boxColor Color box color"
14736 "\n\t\t: -boxSideColor Color box sides color"
14737 "\n\t\t: -boxEdgeColor Color box edges color"
14738 "\n\t\t: -boxCornerColor Color box corner color"
14739 "\n\t\t: -textColor Color color of side text of view cube"
14740 "\n\t\t: -innerColor Color inner box color"
14741 "\n\t\t: -transparency Value transparency of object within [0, 1] range"
14742 "\n\t\t: -boxTransparency Value transparency of box within [0, 1] range"
14743 "\n\t\t: -font Name font name"
14744 "\n\t\t: -fontHeight Value font height"
14745 "\n\t\t: -boxFacetExtension Value box facet extension"
14746 "\n\t\t: -boxEdgeGap Value gap between box edges and box sides"
14747 "\n\t\t: -boxEdgeMinSize Value minimal box edge size"
14748 "\n\t\t: -boxCornerMinSize Value minimal box corner size"
14749 "\n\t\t: -axesPadding Value padding between box and arrows"
14750 "\n\t\t: -roundRadius Value relative radius of corners of sides within [0.0, 0.5] range"
14751 "\n\t\t: -axesRadius Value radius of axes of the trihedron"
14752 "\n\t\t: -axesConeRadius Value radius of the cone (arrow) of the trihedron"
14753 "\n\t\t: -axesSphereRadius Value radius of the sphere (central point) of trihedron"
14754 "\n\t\t: -fixedanimation {0|1} uninterruptible animation loop"
14755 "\n\t\t: -duration Seconds animation duration in seconds",
14756 __FILE__, VViewCube, group);
14758 theCommands.Add("vcolorconvert" ,
14759 "vcolorconvert {from|to} type C1 C2 C2"
14760 "\n\t\t: vcolorconvert from type C1 C2 C2: Converts color from specified color space to linear RGB"
14761 "\n\t\t: vcolorconvert to type R G B: Converts linear RGB color to specified color space"
14762 "\n\t\t: type can be sRGB, HLS, Lab, or Lch",
14763 __FILE__,VColorConvert,group);
14764 theCommands.Add("vcolordiff" ,
14765 "vcolordiff R1 G1 B1 R2 G2 B2: returns CIEDE2000 color difference between two RGB colors",
14766 __FILE__,VColorDiff,group);