Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1998-09-01 |
2 | // Created by: Robert COUBLANC | |
3 | // Copyright (c) 1998-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
b311480e | 16 | |
b8db9379 | 17 | #if defined(_WIN32) |
18 | #include <windows.h> | |
19 | #endif | |
20 | ||
49582f9d | 21 | #include <ViewerTest.hxx> |
1beb58d7 | 22 | |
1beb58d7 | 23 | #include <AIS_AnimationCamera.hxx> |
24 | #include <AIS_AnimationObject.hxx> | |
0461e7fd | 25 | #include <AIS_Axis.hxx> |
30a1b24e | 26 | #include <AIS_CameraFrustum.hxx> |
7a324550 | 27 | #include <AIS_ColorScale.hxx> |
49582f9d | 28 | #include <AIS_InteractiveContext.hxx> |
2daa5d95 | 29 | #include <AIS_LightSource.hxx> |
0a768f56 | 30 | #include <AIS_ListOfInteractive.hxx> |
31 | #include <AIS_ListIteratorOfListOfInteractive.hxx> | |
49582f9d | 32 | #include <AIS_Manipulator.hxx> |
2108d9a2 | 33 | #include <AIS_ViewCube.hxx> |
49582f9d | 34 | #include <AIS_Shape.hxx> |
0461e7fd | 35 | #include <AIS_Point.hxx> |
49582f9d | 36 | #include <Aspect_DisplayConnection.hxx> |
8a590580 | 37 | #include <Aspect_Grid.hxx> |
49582f9d | 38 | #include <Aspect_TypeOfLine.hxx> |
39 | #include <Draw.hxx> | |
40 | #include <Draw_Appli.hxx> | |
41 | #include <Draw_Interpretor.hxx> | |
08f8a185 | 42 | #include <Draw_ProgressIndicator.hxx> |
49582f9d | 43 | #include <gp_Dir.hxx> |
44 | #include <gp_Pln.hxx> | |
45 | #include <gp_Pnt.hxx> | |
0461e7fd | 46 | #include <Geom_Axis2Placement.hxx> |
47 | #include <Geom_CartesianPoint.hxx> | |
61b0191c | 48 | #include <Graphic3d_ArrayOfPolylines.hxx> |
49582f9d | 49 | #include <Graphic3d_AspectFillArea3d.hxx> |
2bd4c032 | 50 | #include <Graphic3d_AspectMarker3d.hxx> |
49582f9d | 51 | #include <Graphic3d_ClipPlane.hxx> |
077a220c | 52 | #include <Graphic3d_CubeMapPacked.hxx> |
53 | #include <Graphic3d_CubeMapSeparate.hxx> | |
a79f67f8 | 54 | #include <Graphic3d_GraduatedTrihedron.hxx> |
b8db9379 | 55 | #include <Graphic3d_GraphicDriver.hxx> |
56 | #include <Graphic3d_GraphicDriverFactory.hxx> | |
49582f9d | 57 | #include <Graphic3d_NameOfTextureEnv.hxx> |
58 | #include <Graphic3d_Texture2Dmanual.hxx> | |
269294d6 | 59 | #include <Graphic3d_TextureEnv.hxx> |
60 | #include <Graphic3d_TextureParams.hxx> | |
61 | #include <Graphic3d_TypeOfTextureFilter.hxx> | |
49582f9d | 62 | #include <Image_AlienPixMap.hxx> |
63 | #include <Image_Diff.hxx> | |
64 | #include <Image_VideoRecorder.hxx> | |
b8db9379 | 65 | #include <Message.hxx> |
7e785937 | 66 | #include <Message_ProgressScope.hxx> |
67 | #include <Message_ProgressRange.hxx> | |
49582f9d | 68 | #include <NCollection_DataMap.hxx> |
18d715bd | 69 | #include <NCollection_List.hxx> |
d6fbb2ab | 70 | #include <NCollection_LocalArray.hxx> |
18d715bd | 71 | #include <NCollection_Vector.hxx> |
8693dfd0 | 72 | #include <OSD.hxx> |
6a2fb7a1 | 73 | #include <OSD_Parallel.hxx> |
208e6839 | 74 | #include <OSD_Timer.hxx> |
4269bd1b | 75 | #include <Prs3d_ShadingAspect.hxx> |
0aeb8984 | 76 | #include <Prs3d_DatumAspect.hxx> |
6262338c | 77 | #include <Prs3d_Drawer.hxx> |
61b0191c | 78 | #include <Prs3d_LineAspect.hxx> |
fd3f6bd0 | 79 | #include <Prs3d_Text.hxx> |
80 | #include <Select3D_SensitivePrimitiveArray.hxx> | |
49582f9d | 81 | #include <TColStd_HSequenceOfAsciiString.hxx> |
82 | #include <TColStd_SequenceOfInteger.hxx> | |
83 | #include <TColStd_HSequenceOfReal.hxx> | |
84 | #include <TColgp_Array1OfPnt2d.hxx> | |
85 | #include <TColStd_MapOfAsciiString.hxx> | |
86 | #include <ViewerTest_AutoUpdater.hxx> | |
08b7a39f | 87 | #include <ViewerTest_ContinuousRedrawer.hxx> |
49582f9d | 88 | #include <ViewerTest_EventManager.hxx> |
89 | #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx> | |
90 | #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx> | |
91 | #include <ViewerTest_CmdParser.hxx> | |
92 | #include <ViewerTest_V3dView.hxx> | |
93 | #include <V3d_AmbientLight.hxx> | |
94 | #include <V3d_DirectionalLight.hxx> | |
95 | #include <V3d_PositionalLight.hxx> | |
96 | #include <V3d_SpotLight.hxx> | |
0aeb8984 | 97 | #include <V3d_Trihedron.hxx> |
1a96d253 | 98 | #include <V3d_Viewer.hxx> |
0461e7fd | 99 | #include <UnitsAPI.hxx> |
7fd59977 | 100 | |
293211ae | 101 | #include <tcl.h> |
102 | ||
692613e5 | 103 | #include <cstdlib> |
25289ec1 | 104 | |
58655684 | 105 | #if defined(_WIN32) |
4fe56619 | 106 | #include <WNT_WClass.hxx> |
107 | #include <WNT_Window.hxx> | |
d6fbb2ab | 108 | #include <WNT_HIDSpaceMouse.hxx> |
b69e576a | 109 | #elif defined(HAVE_XLIB) |
4fe56619 | 110 | #include <Xw_Window.hxx> |
b69e576a | 111 | #include <X11/Xlib.h> |
4fe56619 | 112 | #include <X11/Xutil.h> |
b69e576a | 113 | #elif defined(__APPLE__) |
114 | #include <Cocoa_Window.hxx> | |
f9ab9f7f | 115 | #elif defined(__EMSCRIPTEN__) |
116 | #include <Wasm_Window.hxx> | |
117 | #include <emscripten/emscripten.h> | |
b69e576a | 118 | #else |
119 | #include <Aspect_NeutralWindow.hxx> | |
7fd59977 | 120 | #endif |
121 | ||
7fd59977 | 122 | //============================================================================== |
123 | // VIEWER GLOBAL VARIABLES | |
124 | //============================================================================== | |
125 | ||
126 | Standard_IMPORT Standard_Boolean Draw_VirtualWindows; | |
b514beda | 127 | Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand); |
7fd59977 | 128 | |
129 | Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv); | |
4754e164 | 130 | extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); |
7fd59977 | 131 | |
58655684 | 132 | #if defined(_WIN32) |
b69e576a | 133 | typedef WNT_Window ViewerTest_Window; |
134 | #elif defined(HAVE_XLIB) | |
135 | typedef Xw_Window ViewerTest_Window; | |
136 | static void VProcessEvents(ClientData,int); | |
137 | #elif defined(__APPLE__) | |
138 | typedef Cocoa_Window ViewerTest_Window; | |
4fe56619 | 139 | extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow); |
18d715bd | 140 | extern void GetCocoaScreenResolution (Standard_Integer& theWidth, Standard_Integer& theHeight); |
f9ab9f7f | 141 | #elif defined(__EMSCRIPTEN__) |
142 | typedef Wasm_Window ViewerTest_Window; | |
7fd59977 | 143 | #else |
b69e576a | 144 | typedef Aspect_NeutralWindow ViewerTest_Window; |
7fd59977 | 145 | #endif |
146 | ||
f9ab9f7f | 147 | #if defined(__EMSCRIPTEN__) |
148 | //! Return DOM id of default WebGL canvas from Module.canvas. | |
149 | EM_JS(char*, occJSModuleCanvasId, (), { | |
150 | const aCanvasId = Module.canvas.id; | |
151 | const aNbBytes = lengthBytesUTF8 (aCanvasId) + 1; | |
152 | const aStrPtr = Module._malloc (aNbBytes); | |
153 | stringToUTF8 (aCanvasId, aStrPtr, aNbBytes); | |
154 | return aStrPtr; | |
155 | }); | |
156 | ||
157 | //! Return DOM id of default WebGL canvas from Module.canvas. | |
158 | static TCollection_AsciiString getModuleCanvasId() | |
159 | { | |
160 | char* aRawId = occJSModuleCanvasId(); | |
161 | TCollection_AsciiString anId (aRawId != NULL ? aRawId : ""); | |
162 | free (aRawId); | |
163 | return anId; | |
164 | } | |
165 | #endif | |
166 | ||
b69e576a | 167 | static Handle(ViewerTest_Window)& VT_GetWindow() |
168 | { | |
169 | static Handle(ViewerTest_Window) aWindow; | |
170 | return aWindow; | |
171 | } | |
172 | ||
18d715bd | 173 | static Handle(Aspect_DisplayConnection)& GetDisplayConnection() |
174 | { | |
175 | static Handle(Aspect_DisplayConnection) aDisplayConnection; | |
176 | return aDisplayConnection; | |
177 | } | |
178 | ||
179 | static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDisplayConnection) | |
180 | { | |
181 | GetDisplayConnection() = theDisplayConnection; | |
182 | } | |
183 | ||
18d715bd | 184 | NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews; |
58655684 | 185 | static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts; |
18d715bd | 186 | static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers; |
18d715bd | 187 | |
f42753ed | 188 | static struct |
189 | { | |
190 | Quantity_Color FlatColor; | |
191 | Quantity_Color GradientColor1; | |
192 | Quantity_Color GradientColor2; | |
193 | Aspect_GradientFillMethod FillMethod; | |
293211ae | 194 | |
c585f731 | 195 | //! Sets the gradient filling for a background in a default viewer. |
196 | void SetDefaultGradient() | |
197 | { | |
198 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator aCtxIter (ViewerTest_myContexts); | |
199 | aCtxIter.More(); aCtxIter.Next()) | |
293211ae | 200 | { |
c585f731 | 201 | const Handle (V3d_Viewer)& aViewer = aCtxIter.Value()->CurrentViewer(); |
202 | aViewer->SetDefaultBgGradientColors (GradientColor1, GradientColor2, FillMethod); | |
293211ae | 203 | } |
c585f731 | 204 | } |
293211ae | 205 | |
c585f731 | 206 | //! Sets the color used for filling a background in a default viewer. |
207 | void SetDefaultColor() | |
208 | { | |
209 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator aCtxIter (ViewerTest_myContexts); | |
210 | aCtxIter.More(); aCtxIter.Next()) | |
293211ae | 211 | { |
c585f731 | 212 | const Handle (V3d_Viewer)& aViewer = aCtxIter.Value()->CurrentViewer(); |
213 | aViewer->SetDefaultBackgroundColor (FlatColor); | |
293211ae | 214 | } |
c585f731 | 215 | } |
293211ae | 216 | |
9af0d66b | 217 | } ViewerTest_DefaultBackground = { Quantity_NOC_BLACK, Quantity_NOC_BLACK, Quantity_NOC_BLACK, Aspect_GradientFillMethod_None }; |
b12e1c7b | 218 | |
c585f731 | 219 | //============================================================================== |
220 | // EVENT GLOBAL VARIABLES | |
7fd59977 | 221 | //============================================================================== |
222 | ||
57c28b61 | 223 | #ifdef _WIN32 |
e8e157df | 224 | static LRESULT WINAPI AdvViewerWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
7fd59977 | 225 | #endif |
226 | ||
7fd59977 | 227 | //============================================================================== |
228 | //function : WClass | |
229 | //purpose : | |
230 | //============================================================================== | |
231 | ||
1bd04b5a | 232 | const Handle(WNT_WClass)& ViewerTest::WClass() |
7fd59977 | 233 | { |
1bd04b5a | 234 | static Handle(WNT_WClass) theWClass; |
58655684 | 235 | #if defined(_WIN32) |
4fe56619 | 236 | if (theWClass.IsNull()) |
237 | { | |
7c65581d | 238 | theWClass = new WNT_WClass ("GW3D_Class", (Standard_Address )AdvViewerWindowProc, |
ad03c234 | 239 | CS_VREDRAW | CS_HREDRAW, 0, 0, |
c85a994a | 240 | ::LoadCursor (NULL, IDC_ARROW)); |
7fd59977 | 241 | } |
242 | #endif | |
243 | return theWClass; | |
244 | } | |
245 | ||
18d715bd | 246 | //============================================================================== |
247 | //function : CreateName | |
248 | //purpose : Create numerical name for new object in theMap | |
249 | //============================================================================== | |
250 | template <typename ObjectType> | |
251 | TCollection_AsciiString CreateName (const NCollection_DoubleMap <TCollection_AsciiString, ObjectType>& theObjectMap, | |
252 | const TCollection_AsciiString& theDefaultString) | |
253 | { | |
254 | if (theObjectMap.IsEmpty()) | |
255 | return theDefaultString + TCollection_AsciiString(1); | |
256 | ||
257 | Standard_Integer aNextKey = 1; | |
258 | Standard_Boolean isFound = Standard_False; | |
259 | while (!isFound) | |
260 | { | |
261 | TCollection_AsciiString aStringKey = theDefaultString + TCollection_AsciiString(aNextKey); | |
262 | // Look for objects with default names | |
263 | if (theObjectMap.IsBound1(aStringKey)) | |
264 | { | |
265 | aNextKey++; | |
266 | } | |
267 | else | |
268 | isFound = Standard_True; | |
269 | } | |
270 | ||
271 | return theDefaultString + TCollection_AsciiString(aNextKey); | |
272 | } | |
273 | ||
274 | //============================================================================== | |
275 | //structure : ViewerTest_Names | |
276 | //purpose : Allow to operate with full view name: driverName/viewerName/viewName | |
277 | //============================================================================== | |
278 | struct ViewerTest_Names | |
279 | { | |
280 | private: | |
281 | TCollection_AsciiString myDriverName; | |
282 | TCollection_AsciiString myViewerName; | |
283 | TCollection_AsciiString myViewName; | |
284 | ||
285 | public: | |
286 | ||
287 | const TCollection_AsciiString& GetDriverName () const | |
288 | { | |
289 | return myDriverName; | |
290 | } | |
291 | void SetDriverName (const TCollection_AsciiString& theDriverName) | |
292 | { | |
293 | myDriverName = theDriverName; | |
294 | } | |
295 | const TCollection_AsciiString& GetViewerName () const | |
296 | { | |
297 | return myViewerName; | |
298 | } | |
299 | void SetViewerName (const TCollection_AsciiString& theViewerName) | |
300 | { | |
301 | myViewerName = theViewerName; | |
302 | } | |
303 | const TCollection_AsciiString& GetViewName () const | |
304 | { | |
305 | return myViewName; | |
306 | } | |
307 | void SetViewName (const TCollection_AsciiString& theViewName) | |
308 | { | |
309 | myViewName = theViewName; | |
310 | } | |
311 | ||
312 | //=========================================================================== | |
313 | //function : Constructor for ViewerTest_Names | |
314 | //purpose : Get view, viewer, driver names from custom string | |
315 | //=========================================================================== | |
316 | ||
317 | ViewerTest_Names (const TCollection_AsciiString& theInputString) | |
318 | { | |
319 | TCollection_AsciiString aName(theInputString); | |
320 | if (theInputString.IsEmpty()) | |
321 | { | |
322 | // Get current configuration | |
323 | if (ViewerTest_myDrivers.IsEmpty()) | |
324 | myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)> | |
325 | (ViewerTest_myDrivers, TCollection_AsciiString("Driver")); | |
326 | else | |
327 | myDriverName = ViewerTest_myDrivers.Find2 | |
328 | (ViewerTest::GetAISContext()->CurrentViewer()->Driver()); | |
329 | ||
330 | if(ViewerTest_myContexts.IsEmpty()) | |
331 | { | |
332 | myViewerName = CreateName <Handle(AIS_InteractiveContext)> | |
333 | (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer")); | |
334 | } | |
335 | else | |
c48e2889 | 336 | { |
18d715bd | 337 | myViewerName = ViewerTest_myContexts.Find2 (ViewerTest::GetAISContext()); |
c48e2889 | 338 | } |
18d715bd | 339 | |
c48e2889 | 340 | myViewName = CreateName <Handle(V3d_View)> (ViewerTest_myViews, TCollection_AsciiString(myViewerName + "/View")); |
18d715bd | 341 | } |
342 | else | |
343 | { | |
344 | // There is at least view name | |
345 | Standard_Integer aParserNumber = 0; | |
346 | for (Standard_Integer i = 0; i < 3; ++i) | |
347 | { | |
348 | Standard_Integer aParserPos = aName.SearchFromEnd("/"); | |
349 | if(aParserPos != -1) | |
350 | { | |
351 | aParserNumber++; | |
352 | aName.Split(aParserPos-1); | |
353 | } | |
354 | else | |
355 | break; | |
356 | } | |
357 | if (aParserNumber == 0) | |
358 | { | |
359 | // Only view name | |
360 | if (!ViewerTest::GetAISContext().IsNull()) | |
361 | { | |
362 | myDriverName = ViewerTest_myDrivers.Find2 | |
363 | (ViewerTest::GetAISContext()->CurrentViewer()->Driver()); | |
364 | myViewerName = ViewerTest_myContexts.Find2 | |
365 | (ViewerTest::GetAISContext()); | |
366 | } | |
367 | else | |
368 | { | |
369 | // There is no opened contexts here, need to create names for viewer and driver | |
370 | myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)> | |
371 | (ViewerTest_myDrivers, TCollection_AsciiString("Driver")); | |
372 | ||
373 | myViewerName = CreateName <Handle(AIS_InteractiveContext)> | |
374 | (ViewerTest_myContexts, TCollection_AsciiString (myDriverName + "/Viewer")); | |
375 | } | |
376 | myViewName = TCollection_AsciiString(myViewerName + "/" + theInputString); | |
377 | } | |
378 | else if (aParserNumber == 1) | |
379 | { | |
380 | // Here is viewerName/viewName | |
381 | if (!ViewerTest::GetAISContext().IsNull()) | |
382 | myDriverName = ViewerTest_myDrivers.Find2 | |
383 | (ViewerTest::GetAISContext()->CurrentViewer()->Driver()); | |
384 | else | |
385 | { | |
386 | // There is no opened contexts here, need to create name for driver | |
387 | myDriverName = CreateName<Handle(Graphic3d_GraphicDriver)> | |
388 | (ViewerTest_myDrivers, TCollection_AsciiString("Driver")); | |
389 | } | |
390 | myViewerName = TCollection_AsciiString(myDriverName + "/" + aName); | |
391 | ||
392 | myViewName = TCollection_AsciiString(myDriverName + "/" + theInputString); | |
393 | } | |
394 | else | |
395 | { | |
396 | //Here is driverName/viewerName/viewName | |
397 | myDriverName = TCollection_AsciiString(aName); | |
398 | ||
399 | TCollection_AsciiString aViewerName(theInputString); | |
400 | aViewerName.Split(aViewerName.SearchFromEnd("/") - 1); | |
401 | myViewerName = TCollection_AsciiString(aViewerName); | |
402 | ||
403 | myViewName = TCollection_AsciiString(theInputString); | |
404 | } | |
405 | } | |
406 | } | |
407 | }; | |
408 | ||
409 | //============================================================================== | |
410 | //function : FindContextByView | |
411 | //purpose : Find AIS_InteractiveContext by View | |
412 | //============================================================================== | |
413 | ||
414 | Handle(AIS_InteractiveContext) FindContextByView (const Handle(V3d_View)& theView) | |
415 | { | |
416 | Handle(AIS_InteractiveContext) anAISContext; | |
417 | ||
418 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
419 | anIter (ViewerTest_myContexts); anIter.More(); anIter.Next()) | |
420 | { | |
421 | if (anIter.Value()->CurrentViewer() == theView->Viewer()) | |
422 | return anIter.Key2(); | |
423 | } | |
424 | return anAISContext; | |
425 | } | |
426 | ||
18d715bd | 427 | //============================================================================== |
428 | //function : IsWindowOverlapped | |
429 | //purpose : Check if theWindow overlapp another view | |
430 | //============================================================================== | |
431 | ||
432 | Standard_Boolean IsWindowOverlapped (const Standard_Integer thePxLeft, | |
433 | const Standard_Integer thePxTop, | |
434 | const Standard_Integer thePxRight, | |
435 | const Standard_Integer thePxBottom, | |
436 | TCollection_AsciiString& theViewId) | |
437 | { | |
438 | for(NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator | |
439 | anIter(ViewerTest_myViews); anIter.More(); anIter.Next()) | |
440 | { | |
441 | Standard_Integer aTop = 0, | |
442 | aLeft = 0, | |
443 | aRight = 0, | |
444 | aBottom = 0; | |
445 | anIter.Value()->Window()->Position(aLeft, aTop, aRight, aBottom); | |
446 | if ((thePxLeft >= aLeft && thePxLeft <= aRight && thePxTop >= aTop && thePxTop <= aBottom) || | |
447 | (thePxLeft >= aLeft && thePxLeft <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom) || | |
448 | (thePxRight >= aLeft && thePxRight <= aRight && thePxTop >= aTop && thePxTop <= aBottom) || | |
449 | (thePxRight >= aLeft && thePxRight <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom)) | |
450 | { | |
451 | theViewId = anIter.Key1(); | |
452 | return Standard_True; | |
453 | } | |
454 | } | |
455 | return Standard_False; | |
456 | } | |
457 | ||
458 | // Workaround: to create and delete non-orthographic views outside ViewerTest | |
459 | void ViewerTest::RemoveViewName (const TCollection_AsciiString& theName) | |
460 | { | |
461 | ViewerTest_myViews.UnBind1 (theName); | |
462 | } | |
463 | ||
464 | void ViewerTest::InitViewName (const TCollection_AsciiString& theName, | |
465 | const Handle(V3d_View)& theView) | |
466 | { | |
467 | ViewerTest_myViews.Bind (theName, theView); | |
468 | } | |
469 | ||
470 | TCollection_AsciiString ViewerTest::GetCurrentViewName () | |
471 | { | |
472 | return ViewerTest_myViews.Find2( ViewerTest::CurrentView()); | |
473 | } | |
8693dfd0 | 474 | |
7fd59977 | 475 | //============================================================================== |
476 | //function : ViewerInit | |
477 | //purpose : Create the window viewer and initialize all the global variable | |
478 | //============================================================================== | |
479 | ||
18d715bd | 480 | TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft, |
481 | const Standard_Integer thePxTop, | |
482 | const Standard_Integer thePxWidth, | |
483 | const Standard_Integer thePxHeight, | |
9e04ccdc | 484 | const TCollection_AsciiString& theViewName, |
485 | const TCollection_AsciiString& theDisplayName, | |
72ed0644 | 486 | const Handle(V3d_View)& theViewToClone, |
487 | const Standard_Boolean theIsVirtual) | |
7fd59977 | 488 | { |
8c3c9904 | 489 | // Default position and dimension of the viewer window. |
4fe56619 | 490 | // Note that left top corner is set to be sufficiently small to have |
8c3c9904 | 491 | // window fit in the small screens (actual for remote desktops, see #23003). |
4fe56619 | 492 | // The position corresponds to the window's client area, thus some |
8c3c9904 | 493 | // gap is added for window frame to be visible. |
f9ab9f7f | 494 | Standard_Integer aPxLeft = 20, aPxTop = 40; |
495 | Standard_Integer aPxWidth = 409, aPxHeight = 409; | |
496 | Standard_Boolean isDefViewSize = Standard_True; | |
18d715bd | 497 | Standard_Boolean toCreateViewer = Standard_False; |
72ed0644 | 498 | const Standard_Boolean isVirtual = Draw_VirtualWindows || theIsVirtual; |
9e04ccdc | 499 | if (!theViewToClone.IsNull()) |
500 | { | |
501 | theViewToClone->Window()->Size (aPxWidth, aPxHeight); | |
f9ab9f7f | 502 | isDefViewSize = Standard_False; |
503 | #if !defined(__EMSCRIPTEN__) | |
504 | (void )isDefViewSize; | |
505 | #endif | |
9e04ccdc | 506 | } |
18d715bd | 507 | |
b8db9379 | 508 | Handle(Graphic3d_GraphicDriverFactory) aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory(); |
509 | if (aFactory.IsNull()) | |
510 | { | |
511 | Draw::GetInterpretor().Eval ("pload OPENGL"); | |
512 | aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory(); | |
513 | if (aFactory.IsNull()) | |
514 | { | |
b8ef513c | 515 | Draw::GetInterpretor().Eval ("pload GLES"); |
516 | aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory(); | |
517 | if (aFactory.IsNull()) | |
518 | { | |
519 | throw Standard_ProgramError("Error: no graphic driver factory found"); | |
520 | } | |
b8db9379 | 521 | } |
522 | } | |
523 | ||
524 | Handle(Graphic3d_GraphicDriver) aGraphicDriver; | |
18d715bd | 525 | ViewerTest_Names aViewNames(theViewName); |
f9ab9f7f | 526 | if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName())) |
527 | { | |
18d715bd | 528 | aViewNames.SetViewName (aViewNames.GetViewerName() + "/" + CreateName<Handle(V3d_View)>(ViewerTest_myViews, "View")); |
f9ab9f7f | 529 | } |
18d715bd | 530 | |
531 | if (thePxLeft != 0) | |
f9ab9f7f | 532 | { |
18d715bd | 533 | aPxLeft = thePxLeft; |
f9ab9f7f | 534 | } |
18d715bd | 535 | if (thePxTop != 0) |
f9ab9f7f | 536 | { |
18d715bd | 537 | aPxTop = thePxTop; |
f9ab9f7f | 538 | } |
18d715bd | 539 | if (thePxWidth != 0) |
f9ab9f7f | 540 | { |
541 | isDefViewSize = Standard_False; | |
18d715bd | 542 | aPxWidth = thePxWidth; |
f9ab9f7f | 543 | } |
18d715bd | 544 | if (thePxHeight != 0) |
f9ab9f7f | 545 | { |
546 | isDefViewSize = Standard_False; | |
7fd59977 | 547 | aPxHeight = thePxHeight; |
f9ab9f7f | 548 | } |
4269bd1b | 549 | |
18d715bd | 550 | // Get graphic driver (create it or get from another view) |
8693dfd0 | 551 | const bool isNewDriver = !ViewerTest_myDrivers.IsBound1 (aViewNames.GetDriverName()); |
552 | if (isNewDriver) | |
18d715bd | 553 | { |
554 | // Get connection string | |
b69e576a | 555 | #if defined(HAVE_XLIB) |
8693dfd0 | 556 | if (!theDisplayName.IsEmpty()) |
557 | { | |
558 | SetDisplayConnection (new Aspect_DisplayConnection (theDisplayName)); | |
559 | } | |
18d715bd | 560 | else |
8693dfd0 | 561 | { |
b69e576a | 562 | Aspect_XDisplay* aDispX = NULL; |
8693dfd0 | 563 | // create dedicated display connection instead of reusing Tk connection |
b69e576a | 564 | // so that to proceed events independently through VProcessEvents()/ViewerMainLoop() callbacks |
8693dfd0 | 565 | /*Draw_Interpretor& aCommands = Draw::GetInterpretor(); |
566 | Tcl_Interp* aTclInterp = aCommands.Interp(); | |
567 | Tk_Window aMainWindow = Tk_MainWindow (aTclInterp); | |
568 | aDispX = aMainWindow != NULL ? Tk_Display (aMainWindow) : NULL;*/ | |
569 | SetDisplayConnection (new Aspect_DisplayConnection (aDispX)); | |
570 | } | |
18d715bd | 571 | #else |
498ce76b | 572 | (void)theDisplayName; // avoid warning on unused argument |
18d715bd | 573 | SetDisplayConnection (new Aspect_DisplayConnection ()); |
574 | #endif | |
14cb22a1 | 575 | |
b8db9379 | 576 | aGraphicDriver = aFactory->CreateDriver (GetDisplayConnection()); |
72ed0644 | 577 | if (isVirtual) |
14cb22a1 | 578 | { |
579 | // don't waste the time waiting for VSync when window is not displayed on the screen | |
b8db9379 | 580 | aGraphicDriver->SetVerticalSync (false); |
14cb22a1 | 581 | } |
14cb22a1 | 582 | |
18d715bd | 583 | ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver); |
584 | toCreateViewer = Standard_True; | |
585 | } | |
586 | else | |
587 | { | |
b8db9379 | 588 | aGraphicDriver = ViewerTest_myDrivers.Find1 (aViewNames.GetDriverName()); |
7fd59977 | 589 | } |
590 | ||
18d715bd | 591 | //Dispose the window if input parameters are default |
592 | if (!ViewerTest_myViews.IsEmpty() && thePxLeft == 0 && thePxTop == 0) | |
7fd59977 | 593 | { |
18d715bd | 594 | Standard_Integer aTop = 0, |
595 | aLeft = 0, | |
596 | aRight = 0, | |
597 | aBottom = 0, | |
598 | aScreenWidth = 0, | |
599 | aScreenHeight = 0; | |
600 | ||
601 | // Get screen resolution | |
b69e576a | 602 | #if defined(_WIN32) |
18d715bd | 603 | RECT aWindowSize; |
604 | GetClientRect(GetDesktopWindow(), &aWindowSize); | |
605 | aScreenHeight = aWindowSize.bottom; | |
606 | aScreenWidth = aWindowSize.right; | |
b69e576a | 607 | #elif defined(HAVE_XLIB) |
608 | ::Display* aDispX = (::Display* )GetDisplayConnection()->GetDisplayAspect(); | |
609 | Screen* aScreen = DefaultScreenOfDisplay(aDispX); | |
610 | aScreenWidth = WidthOfScreen(aScreen); | |
611 | aScreenHeight = HeightOfScreen(aScreen); | |
612 | #elif defined(__APPLE__) | |
18d715bd | 613 | GetCocoaScreenResolution (aScreenWidth, aScreenHeight); |
614 | #else | |
b69e576a | 615 | // not implemented |
18d715bd | 616 | #endif |
617 | ||
618 | TCollection_AsciiString anOverlappedViewId(""); | |
773f53f1 | 619 | |
620 | while (IsWindowOverlapped (aPxLeft, aPxTop, aPxLeft + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId)) | |
dc3fe572 | 621 | { |
18d715bd | 622 | ViewerTest_myViews.Find1(anOverlappedViewId)->Window()->Position (aLeft, aTop, aRight, aBottom); |
623 | ||
624 | if (IsWindowOverlapped (aRight + 20, aPxTop, aRight + 20 + aPxWidth, aPxTop + aPxHeight, anOverlappedViewId) | |
625 | && aRight + 2*aPxWidth + 40 > aScreenWidth) | |
626 | { | |
627 | if (aBottom + aPxHeight + 40 > aScreenHeight) | |
628 | { | |
629 | aPxLeft = 20; | |
630 | aPxTop = 40; | |
631 | break; | |
632 | } | |
633 | aPxLeft = 20; | |
634 | aPxTop = aBottom + 40; | |
635 | } | |
636 | else | |
637 | aPxLeft = aRight + 20; | |
dc3fe572 | 638 | } |
18d715bd | 639 | } |
640 | ||
641 | // Get viewer name | |
642 | TCollection_AsciiString aTitle("3D View - "); | |
643 | aTitle = aTitle + aViewNames.GetViewName() + "(*)"; | |
644 | ||
645 | // Change name of current active window | |
49582f9d | 646 | if (const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView()) |
18d715bd | 647 | { |
49582f9d | 648 | aCurrentView->Window()->SetTitle (TCollection_AsciiString ("3D View - ") + ViewerTest_myViews.Find2 (aCurrentView)); |
18d715bd | 649 | } |
650 | ||
651 | // Create viewer | |
eb4320f2 | 652 | Handle(V3d_Viewer) a3DViewer; |
18d715bd | 653 | // If it's the single view, we first look for empty context |
654 | if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty()) | |
655 | { | |
656 | NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
657 | anIter(ViewerTest_myContexts); | |
658 | if (anIter.More()) | |
659 | ViewerTest::SetAISContext (anIter.Value()); | |
660 | a3DViewer = ViewerTest::GetAISContext()->CurrentViewer(); | |
18d715bd | 661 | } |
662 | else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())) | |
663 | { | |
664 | ViewerTest::SetAISContext(ViewerTest_myContexts.Find1(aViewNames.GetViewerName())); | |
665 | a3DViewer = ViewerTest::GetAISContext()->CurrentViewer(); | |
18d715bd | 666 | } |
eb4320f2 | 667 | else if (a3DViewer.IsNull()) |
18d715bd | 668 | { |
669 | toCreateViewer = Standard_True; | |
6a24c6de | 670 | a3DViewer = new V3d_Viewer(aGraphicDriver); |
f42753ed | 671 | a3DViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor); |
672 | a3DViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1, | |
673 | ViewerTest_DefaultBackground.GradientColor2, | |
674 | ViewerTest_DefaultBackground.FillMethod); | |
18d715bd | 675 | } |
676 | ||
677 | // AIS context setup | |
678 | if (ViewerTest::GetAISContext().IsNull() || | |
679 | !(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))) | |
680 | { | |
e79a94b9 | 681 | Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer); |
18d715bd | 682 | ViewerTest::SetAISContext (aContext); |
683 | ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext()); | |
684 | } | |
685 | else | |
e79a94b9 | 686 | { |
18d715bd | 687 | ViewerTest::ResetEventManager(); |
e79a94b9 | 688 | } |
18d715bd | 689 | |
690 | // Create window | |
e79a94b9 | 691 | #if defined(_WIN32) |
1bd04b5a | 692 | VT_GetWindow() = new WNT_Window (aTitle.ToCString(), WClass(), |
72ed0644 | 693 | isVirtual ? WS_POPUP : WS_OVERLAPPEDWINDOW, |
e79a94b9 | 694 | aPxLeft, aPxTop, |
695 | aPxWidth, aPxHeight, | |
696 | Quantity_NOC_BLACK); | |
d6fbb2ab | 697 | VT_GetWindow()->RegisterRawInputDevices (WNT_Window::RawInputMask_SpaceMouse); |
b69e576a | 698 | #elif defined(HAVE_XLIB) |
699 | VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(), | |
700 | aTitle.ToCString(), | |
701 | aPxLeft, aPxTop, | |
702 | aPxWidth, aPxHeight); | |
703 | #elif defined(__APPLE__) | |
e79a94b9 | 704 | VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(), |
705 | aPxLeft, aPxTop, | |
706 | aPxWidth, aPxHeight); | |
707 | ViewerTest_SetCocoaEventManagerView (VT_GetWindow()); | |
f9ab9f7f | 708 | #elif defined(__EMSCRIPTEN__) |
709 | // current EGL implementation in Emscripten supports only one global WebGL canvas returned by Module.canvas property; | |
710 | // the code should be revised for handling multiple canvas elements (which is technically also possible) | |
711 | TCollection_AsciiString aCanvasId = getModuleCanvasId(); | |
712 | if (!aCanvasId.IsEmpty()) | |
713 | { | |
714 | aCanvasId = TCollection_AsciiString("#") + aCanvasId; | |
715 | } | |
716 | ||
717 | VT_GetWindow() = new Wasm_Window (aCanvasId); | |
718 | Graphic3d_Vec2i aRealSize; | |
719 | VT_GetWindow()->Size (aRealSize.x(), aRealSize.y()); | |
720 | if (!isDefViewSize || (aRealSize.x() <= 0 && aRealSize.y() <= 0)) | |
721 | { | |
722 | // Wasm_Window wraps an existing HTML element without creating a new one. | |
723 | // Keep size defined on a web page instead of defaulting to 409x409 (as in case of other platform), | |
724 | // but resize canvas if vinit has been called with explicitly specified dimensions. | |
725 | VT_GetWindow()->SetSizeLogical (Graphic3d_Vec2d (aPxWidth, aPxHeight)); | |
726 | } | |
7fd59977 | 727 | #else |
b69e576a | 728 | // not implemented |
729 | VT_GetWindow() = new Aspect_NeutralWindow(); | |
730 | VT_GetWindow()->SetSize (aPxWidth, aPxHeight); | |
7fd59977 | 731 | #endif |
72ed0644 | 732 | VT_GetWindow()->SetVirtual (isVirtual); |
7fd59977 | 733 | |
d09dda09 | 734 | // View setup |
9e04ccdc | 735 | Handle(V3d_View) aView; |
736 | if (!theViewToClone.IsNull()) | |
737 | { | |
2e93433e | 738 | aView = new ViewerTest_V3dView (a3DViewer, theViewToClone); |
9e04ccdc | 739 | } |
740 | else | |
741 | { | |
2e93433e | 742 | aView = new ViewerTest_V3dView (a3DViewer, a3DViewer->DefaultTypeOfView()); |
9e04ccdc | 743 | } |
744 | ||
d09dda09 | 745 | aView->SetWindow (VT_GetWindow()); |
c3282ec1 | 746 | ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer); |
4269bd1b | 747 | |
18d715bd | 748 | ViewerTest::CurrentView(aView); |
749 | ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView); | |
7fd59977 | 750 | |
18d715bd | 751 | // Setup for X11 or NT |
f9ab9f7f | 752 | SetDisplayConnection (ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection()); |
753 | ViewerTest_EventManager::SetupWindowCallbacks (VT_GetWindow()); | |
7fd59977 | 754 | |
18d715bd | 755 | // Set parameters for V3d_View and V3d_Viewer |
756 | const Handle (V3d_View) aV3dView = ViewerTest::CurrentView(); | |
757 | aV3dView->SetComputedMode(Standard_False); | |
7fd59977 | 758 | |
18d715bd | 759 | a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); |
760 | if (toCreateViewer) | |
761 | { | |
7fd59977 | 762 | a3DViewer->SetDefaultLights(); |
763 | a3DViewer->SetLightOn(); | |
18d715bd | 764 | } |
7fd59977 | 765 | |
b69e576a | 766 | #if defined(HAVE_XLIB) |
8693dfd0 | 767 | if (isNewDriver) |
768 | { | |
b69e576a | 769 | ::Display* aDispX = (::Display* )GetDisplayConnection()->GetDisplayAspect(); |
8693dfd0 | 770 | Tcl_CreateFileHandler (XConnectionNumber (aDispX), TCL_READABLE, VProcessEvents, (ClientData )aDispX); |
771 | } | |
772 | #endif | |
7fd59977 | 773 | |
7fd59977 | 774 | VT_GetWindow()->Map(); |
4269bd1b | 775 | |
18d715bd | 776 | // Set the handle of created view in the event manager |
777 | ViewerTest::ResetEventManager(); | |
778 | ||
4fe56619 | 779 | ViewerTest::CurrentView()->Redraw(); |
18d715bd | 780 | |
781 | aView.Nullify(); | |
782 | a3DViewer.Nullify(); | |
18d715bd | 783 | |
784 | return aViewNames.GetViewName(); | |
785 | } | |
786 | ||
4269bd1b | 787 | //============================================================================== |
788 | //function : RedrawAllViews | |
789 | //purpose : Redraw all created views | |
790 | //============================================================================== | |
791 | void ViewerTest::RedrawAllViews() | |
792 | { | |
793 | NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews); | |
794 | for (; aViewIt.More(); aViewIt.Next()) | |
795 | { | |
796 | const Handle(V3d_View)& aView = aViewIt.Key2(); | |
797 | aView->Redraw(); | |
798 | } | |
799 | } | |
800 | ||
b8db9379 | 801 | //============================================================================== |
802 | //function : VDriver | |
803 | //purpose : | |
804 | //============================================================================== | |
805 | static int VDriver (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
806 | { | |
807 | if (theArgsNb == 1) | |
808 | { | |
809 | theDi << "Registered: "; | |
810 | for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories()); | |
811 | aFactoryIter.More(); aFactoryIter.Next()) | |
812 | { | |
813 | const Handle(Graphic3d_GraphicDriverFactory)& aFactory = aFactoryIter.Value(); | |
814 | theDi << aFactory->Name() << " "; | |
815 | } | |
816 | ||
817 | theDi << "\n"; | |
818 | theDi << "Default: "; | |
819 | if (Handle(Graphic3d_GraphicDriverFactory) aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory()) | |
820 | { | |
821 | theDi << aFactory->Name(); | |
822 | } | |
823 | else | |
824 | { | |
825 | theDi << "NONE"; | |
826 | } | |
827 | return 0; | |
828 | } | |
829 | ||
830 | TCollection_AsciiString aNewActive; | |
831 | bool toLoad = false; | |
832 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
833 | { | |
834 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); | |
835 | anArgCase.LowerCase(); | |
836 | if (anArgCase == "-list") | |
837 | { | |
838 | for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories()); | |
839 | aFactoryIter.More(); aFactoryIter.Next()) | |
840 | { | |
841 | const Handle(Graphic3d_GraphicDriverFactory)& aFactory = aFactoryIter.Value(); | |
842 | theDi << aFactory->Name() << " "; | |
843 | } | |
844 | } | |
845 | else if ((anArgCase == "-default" | |
846 | || anArgCase == "-load") | |
847 | && aNewActive.IsEmpty()) | |
848 | { | |
849 | toLoad = (anArgCase == "-load"); | |
850 | if (anArgIter + 1 < theArgsNb) | |
851 | { | |
852 | aNewActive = theArgVec[++anArgIter]; | |
853 | } | |
854 | else if (toLoad) | |
855 | { | |
856 | theDi << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
857 | return 1; | |
858 | } | |
859 | else | |
860 | { | |
861 | if (Handle(Graphic3d_GraphicDriverFactory) aFactory = Graphic3d_GraphicDriverFactory::DefaultDriverFactory()) | |
862 | { | |
863 | theDi << aFactory->Name(); | |
864 | } | |
865 | else | |
866 | { | |
867 | theDi << "NONE"; | |
868 | } | |
869 | } | |
870 | } | |
871 | else if (aNewActive.IsEmpty()) | |
872 | { | |
873 | aNewActive = theArgVec[anArgIter]; | |
874 | } | |
875 | else | |
876 | { | |
877 | theDi << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'"; | |
878 | return 1; | |
879 | } | |
880 | } | |
881 | ||
882 | if (!aNewActive.IsEmpty()) | |
883 | { | |
884 | const TCollection_AsciiString aNameCopy = aNewActive; | |
885 | if (TCollection_AsciiString::IsSameString (aNewActive, "gl", false) | |
886 | || TCollection_AsciiString::IsSameString (aNewActive, "opengl", false) | |
887 | || TCollection_AsciiString::IsSameString (aNewActive, "tkopengl", false)) | |
888 | { | |
889 | aNewActive = "tkopengl"; | |
890 | } | |
b8ef513c | 891 | else if (TCollection_AsciiString::IsSameString (aNewActive, "gles", false) |
892 | || TCollection_AsciiString::IsSameString (aNewActive, "opengles", false) | |
893 | || TCollection_AsciiString::IsSameString (aNewActive, "tkopengles", false)) | |
894 | { | |
895 | aNewActive = "tkopengles"; | |
896 | } | |
b8db9379 | 897 | else if (TCollection_AsciiString::IsSameString (aNewActive, "d3d", false) |
898 | || TCollection_AsciiString::IsSameString (aNewActive, "d3dhost", false) | |
899 | || TCollection_AsciiString::IsSameString (aNewActive, "tkd3dhost", false)) | |
900 | { | |
901 | aNewActive = "tkd3dhost"; | |
902 | } | |
903 | ||
904 | if (toLoad) | |
905 | { | |
906 | if (aNewActive == "tkopengl") | |
907 | { | |
908 | Draw::GetInterpretor().Eval ("pload OPENGL"); | |
909 | } | |
b8ef513c | 910 | else if (aNewActive == "tkopengles") |
911 | { | |
912 | Draw::GetInterpretor().Eval ("pload GLES"); | |
913 | } | |
b8db9379 | 914 | else if (aNewActive == "tkd3dhost") |
915 | { | |
916 | Draw::GetInterpretor().Eval ("pload D3DHOST"); | |
917 | } | |
918 | else | |
919 | { | |
920 | theDi << "Syntax error: unable to load plugin for unknown driver factory '" << aNameCopy << "'"; | |
921 | return 1; | |
922 | } | |
923 | } | |
924 | ||
925 | bool isFound = false; | |
926 | for (Graphic3d_GraphicDriverFactoryList::Iterator aFactoryIter (Graphic3d_GraphicDriverFactory::DriverFactories()); | |
927 | aFactoryIter.More(); aFactoryIter.Next()) | |
928 | { | |
929 | Handle(Graphic3d_GraphicDriverFactory) aFactory = aFactoryIter.Value(); | |
930 | if (TCollection_AsciiString::IsSameString (aFactory->Name(), aNewActive, false)) | |
931 | { | |
932 | Graphic3d_GraphicDriverFactory::RegisterFactory (aFactory, true); | |
933 | isFound = true; | |
934 | break; | |
935 | } | |
936 | } | |
937 | ||
938 | if (!isFound) | |
939 | { | |
940 | theDi << "Syntax error: driver factory '" << aNameCopy << "' not found"; | |
941 | return 1; | |
942 | } | |
943 | } | |
944 | ||
945 | return 0; | |
946 | } | |
947 | ||
7fd59977 | 948 | //============================================================================== |
949 | //function : Vinit | |
950 | //purpose : Create the window viewer and initialize all the global variable | |
87b68a0f | 951 | // Use Tcl_CreateFileHandler on UNIX to catch the X11 Viewer event |
7fd59977 | 952 | //============================================================================== |
18d715bd | 953 | static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) |
7fd59977 | 954 | { |
e79a94b9 | 955 | TCollection_AsciiString aViewName, aDisplayName; |
956 | Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0; | |
72ed0644 | 957 | Standard_Boolean isVirtual = false; |
9e04ccdc | 958 | Handle(V3d_View) aCopyFrom; |
e79a94b9 | 959 | TCollection_AsciiString aName, aValue; |
2e93433e | 960 | int is2dMode = -1; |
e79a94b9 | 961 | for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) |
18d715bd | 962 | { |
e79a94b9 | 963 | const TCollection_AsciiString anArg = theArgVec[anArgIt]; |
964 | TCollection_AsciiString anArgCase = anArg; | |
fd3f6bd0 | 965 | anArgCase.LowerCase(); |
966 | if (anArgIt + 1 < theArgsNb | |
967 | && anArgCase == "-name") | |
968 | { | |
969 | aViewName = theArgVec[++anArgIt]; | |
970 | } | |
971 | else if (anArgIt + 1 < theArgsNb | |
972 | && (anArgCase == "-left" | |
973 | || anArgCase == "-l")) | |
974 | { | |
975 | aPxLeft = Draw::Atoi (theArgVec[++anArgIt]); | |
976 | } | |
977 | else if (anArgIt + 1 < theArgsNb | |
978 | && (anArgCase == "-top" | |
979 | || anArgCase == "-t")) | |
980 | { | |
981 | aPxTop = Draw::Atoi (theArgVec[++anArgIt]); | |
982 | } | |
983 | else if (anArgIt + 1 < theArgsNb | |
984 | && (anArgCase == "-width" | |
985 | || anArgCase == "-w")) | |
986 | { | |
987 | aPxWidth = Draw::Atoi (theArgVec[++anArgIt]); | |
988 | } | |
989 | else if (anArgIt + 1 < theArgsNb | |
990 | && (anArgCase == "-height" | |
991 | || anArgCase == "-h")) | |
18d715bd | 992 | { |
fd3f6bd0 | 993 | aPxHeight = Draw::Atoi (theArgVec[++anArgIt]); |
994 | } | |
72ed0644 | 995 | else if (anArgCase == "-virtual" |
996 | || anArgCase == "-offscreen") | |
997 | { | |
998 | isVirtual = true; | |
999 | if (anArgIt + 1 < theArgsNb | |
1000 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], isVirtual)) | |
1001 | { | |
1002 | ++anArgIt; | |
1003 | } | |
1004 | } | |
fd3f6bd0 | 1005 | else if (anArgCase == "-exitonclose") |
1006 | { | |
49582f9d | 1007 | ViewerTest_EventManager::ToExitOnCloseView() = true; |
fd3f6bd0 | 1008 | if (anArgIt + 1 < theArgsNb |
dae2a922 | 1009 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToExitOnCloseView())) |
fd3f6bd0 | 1010 | { |
1011 | ++anArgIt; | |
1012 | } | |
1013 | } | |
1014 | else if (anArgCase == "-closeonescape" | |
1015 | || anArgCase == "-closeonesc") | |
1016 | { | |
49582f9d | 1017 | ViewerTest_EventManager::ToCloseViewOnEscape() = true; |
fd3f6bd0 | 1018 | if (anArgIt + 1 < theArgsNb |
dae2a922 | 1019 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToCloseViewOnEscape())) |
fd3f6bd0 | 1020 | { |
1021 | ++anArgIt; | |
1022 | } | |
1023 | } | |
2e93433e | 1024 | else if (anArgCase == "-2d_mode" |
1025 | || anArgCase == "-2dmode" | |
1026 | || anArgCase == "-2d") | |
1027 | { | |
1028 | bool toEnable = true; | |
1029 | if (anArgIt + 1 < theArgsNb | |
dae2a922 | 1030 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], toEnable)) |
2e93433e | 1031 | { |
1032 | ++anArgIt; | |
1033 | } | |
1034 | is2dMode = toEnable ? 1 : 0; | |
1035 | } | |
fd3f6bd0 | 1036 | else if (anArgIt + 1 < theArgsNb |
1037 | && (anArgCase == "-disp" | |
1038 | || anArgCase == "-display")) | |
1039 | { | |
1040 | aDisplayName = theArgVec[++anArgIt]; | |
1041 | } | |
9e04ccdc | 1042 | else if (!ViewerTest::CurrentView().IsNull() |
1043 | && aCopyFrom.IsNull() | |
1044 | && (anArgCase == "-copy" | |
1045 | || anArgCase == "-clone" | |
1046 | || anArgCase == "-cloneactive" | |
1047 | || anArgCase == "-cloneactiveview")) | |
1048 | { | |
1049 | aCopyFrom = ViewerTest::CurrentView(); | |
1050 | } | |
fd3f6bd0 | 1051 | // old syntax |
1052 | else if (ViewerTest::SplitParameter (anArg, aName, aValue)) | |
1053 | { | |
1054 | aName.LowerCase(); | |
1055 | if (aName == "name") | |
18d715bd | 1056 | { |
1057 | aViewName = aValue; | |
1058 | } | |
fd3f6bd0 | 1059 | else if (aName == "l" |
1060 | || aName == "left") | |
e79a94b9 | 1061 | { |
18d715bd | 1062 | aPxLeft = aValue.IntegerValue(); |
e79a94b9 | 1063 | } |
fd3f6bd0 | 1064 | else if (aName == "t" |
1065 | || aName == "top") | |
e79a94b9 | 1066 | { |
18d715bd | 1067 | aPxTop = aValue.IntegerValue(); |
e79a94b9 | 1068 | } |
fd3f6bd0 | 1069 | else if (aName == "disp" |
1070 | || aName == "display") | |
e79a94b9 | 1071 | { |
18d715bd | 1072 | aDisplayName = aValue; |
e79a94b9 | 1073 | } |
fd3f6bd0 | 1074 | else if (aName == "w" |
1075 | || aName == "width") | |
e79a94b9 | 1076 | { |
18d715bd | 1077 | aPxWidth = aValue.IntegerValue(); |
e79a94b9 | 1078 | } |
fd3f6bd0 | 1079 | else if (aName == "h" |
1080 | || aName == "height") | |
e79a94b9 | 1081 | { |
18d715bd | 1082 | aPxHeight = aValue.IntegerValue(); |
e79a94b9 | 1083 | } |
18d715bd | 1084 | else |
1085 | { | |
23fe70ec | 1086 | Message::SendFail() << "Syntax error: unknown argument " << anArg; |
fd3f6bd0 | 1087 | return 1; |
18d715bd | 1088 | } |
1089 | } | |
e79a94b9 | 1090 | else if (aViewName.IsEmpty()) |
1091 | { | |
1092 | aViewName = anArg; | |
1093 | } | |
1094 | else | |
1095 | { | |
23fe70ec | 1096 | Message::SendFail() << "Syntax error: unknown argument " << anArg; |
fd3f6bd0 | 1097 | return 1; |
e79a94b9 | 1098 | } |
18d715bd | 1099 | } |
1100 | ||
b69e576a | 1101 | #if !defined(HAVE_XLIB) |
fd3f6bd0 | 1102 | if (!aDisplayName.IsEmpty()) |
1103 | { | |
1104 | aDisplayName.Clear(); | |
23fe70ec | 1105 | Message::SendWarning() << "Warning: display parameter will be ignored.\n"; |
fd3f6bd0 | 1106 | } |
1107 | #endif | |
1108 | ||
18d715bd | 1109 | ViewerTest_Names aViewNames (aViewName); |
e79a94b9 | 1110 | if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName())) |
18d715bd | 1111 | { |
e79a94b9 | 1112 | TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName(); |
1113 | theDi.Eval (aCommand.ToCString()); | |
2e93433e | 1114 | if (is2dMode != -1) |
1115 | { | |
1116 | ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1); | |
1117 | } | |
18d715bd | 1118 | return 0; |
1119 | } | |
1120 | ||
1121 | TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight, | |
72ed0644 | 1122 | aViewName, aDisplayName, aCopyFrom, isVirtual); |
2e93433e | 1123 | if (is2dMode != -1) |
1124 | { | |
1125 | ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1); | |
1126 | } | |
e79a94b9 | 1127 | theDi << aViewId; |
7fd59977 | 1128 | return 0; |
1129 | } | |
1130 | ||
1eeef710 | 1131 | //! Parse HLR algo type. |
1132 | static Standard_Boolean parseHlrAlgoType (const char* theName, | |
1133 | Prs3d_TypeOfHLR& theType) | |
1134 | { | |
1135 | TCollection_AsciiString aName (theName); | |
1136 | aName.LowerCase(); | |
1137 | if (aName == "polyalgo") | |
1138 | { | |
1139 | theType = Prs3d_TOH_PolyAlgo; | |
1140 | } | |
1141 | else if (aName == "algo") | |
1142 | { | |
1143 | theType = Prs3d_TOH_Algo; | |
1144 | } | |
1145 | else | |
1146 | { | |
1147 | return Standard_False; | |
1148 | } | |
1149 | return Standard_True; | |
1150 | } | |
1151 | ||
0a768f56 | 1152 | //============================================================================== |
1153 | //function : VHLR | |
1154 | //purpose : hidden lines removal algorithm | |
1155 | //============================================================================== | |
1156 | ||
1157 | static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1158 | { | |
1eeef710 | 1159 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); |
1160 | const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
1161 | if (aView.IsNull()) | |
0a768f56 | 1162 | { |
23fe70ec | 1163 | Message::SendFail ("Error: no active viewer"); |
0a768f56 | 1164 | return 1; |
1165 | } | |
1166 | ||
1eeef710 | 1167 | Standard_Boolean hasHlrOnArg = Standard_False; |
1168 | Standard_Boolean hasShowHiddenArg = Standard_False; | |
1169 | Standard_Boolean isHLROn = Standard_False; | |
1170 | Standard_Boolean toShowHidden = aCtx->DefaultDrawer()->DrawHiddenLine(); | |
1171 | Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet; | |
1172 | ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView); | |
1173 | for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) | |
0a768f56 | 1174 | { |
1eeef710 | 1175 | TCollection_AsciiString anArg (argv[anArgIter]); |
1176 | anArg.LowerCase(); | |
1177 | if (anUpdateTool.parseRedrawMode (anArg)) | |
1178 | { | |
1179 | continue; | |
1180 | } | |
1181 | else if (anArg == "-showhidden" | |
1182 | && anArgIter + 1 < argc | |
dae2a922 | 1183 | && Draw::ParseOnOff (argv[anArgIter + 1], toShowHidden)) |
1eeef710 | 1184 | { |
1185 | ++anArgIter; | |
1186 | hasShowHiddenArg = Standard_True; | |
1187 | continue; | |
1188 | } | |
1189 | else if ((anArg == "-type" | |
1190 | || anArg == "-algo" | |
1191 | || anArg == "-algotype") | |
1192 | && anArgIter + 1 < argc | |
1193 | && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR)) | |
1194 | { | |
1195 | ++anArgIter; | |
1196 | continue; | |
1197 | } | |
1198 | else if (!hasHlrOnArg | |
dae2a922 | 1199 | && Draw::ParseOnOff (argv[anArgIter], isHLROn)) |
1eeef710 | 1200 | { |
1201 | hasHlrOnArg = Standard_True; | |
1202 | continue; | |
1203 | } | |
1204 | // old syntax | |
1205 | else if (!hasShowHiddenArg | |
dae2a922 | 1206 | && Draw::ParseOnOff(argv[anArgIter], toShowHidden)) |
1eeef710 | 1207 | { |
1208 | hasShowHiddenArg = Standard_True; | |
1209 | continue; | |
1210 | } | |
1211 | else | |
1212 | { | |
23fe70ec | 1213 | Message::SendFail() << "Syntax error at '" << argv[anArgIter] << "'"; |
1eeef710 | 1214 | return 1; |
1215 | } | |
0a768f56 | 1216 | } |
1eeef710 | 1217 | if (!hasHlrOnArg) |
0a768f56 | 1218 | { |
1eeef710 | 1219 | di << "HLR: " << aView->ComputedMode() << "\n"; |
1220 | di << "HiddenLine: " << aCtx->DefaultDrawer()->DrawHiddenLine() << "\n"; | |
1221 | di << "HlrAlgo: "; | |
1222 | switch (aCtx->DefaultDrawer()->TypeOfHLR()) | |
1223 | { | |
1224 | case Prs3d_TOH_NotSet: di << "NotSet\n"; break; | |
1225 | case Prs3d_TOH_PolyAlgo: di << "PolyAlgo\n"; break; | |
1226 | case Prs3d_TOH_Algo: di << "Algo\n"; break; | |
1227 | } | |
1228 | anUpdateTool.Invalidate(); | |
1229 | return 0; | |
0a768f56 | 1230 | } |
1231 | ||
1eeef710 | 1232 | Standard_Boolean toRecompute = Standard_False; |
1233 | if (aTypeOfHLR != Prs3d_TOH_NotSet | |
1234 | && aTypeOfHLR != aCtx->DefaultDrawer()->TypeOfHLR()) | |
e9224045 | 1235 | { |
1eeef710 | 1236 | toRecompute = Standard_True; |
1237 | aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR); | |
1238 | } | |
1239 | if (toShowHidden != aCtx->DefaultDrawer()->DrawHiddenLine()) | |
1240 | { | |
1241 | toRecompute = Standard_True; | |
1242 | if (toShowHidden) | |
e9224045 | 1243 | { |
1eeef710 | 1244 | aCtx->DefaultDrawer()->EnableDrawHiddenLine(); |
e9224045 | 1245 | } |
1246 | else | |
1247 | { | |
1eeef710 | 1248 | aCtx->DefaultDrawer()->DisableDrawHiddenLine(); |
e9224045 | 1249 | } |
1eeef710 | 1250 | } |
e9224045 | 1251 | |
1eeef710 | 1252 | // redisplay shapes |
1253 | if (aView->ComputedMode() && isHLROn && toRecompute) | |
1254 | { | |
1255 | AIS_ListOfInteractive aListOfShapes; | |
1256 | aCtx->DisplayedObjects (aListOfShapes); | |
1257 | for (AIS_ListIteratorOfListOfInteractive anIter (aListOfShapes); anIter.More(); anIter.Next()) | |
e9224045 | 1258 | { |
1eeef710 | 1259 | if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value())) |
e9224045 | 1260 | { |
1eeef710 | 1261 | aCtx->Redisplay (aShape, Standard_False); |
e9224045 | 1262 | } |
1263 | } | |
1264 | } | |
0a768f56 | 1265 | |
1eeef710 | 1266 | aView->SetComputedMode (isHLROn); |
0a768f56 | 1267 | return 0; |
1268 | } | |
1269 | ||
1270 | //============================================================================== | |
1271 | //function : VHLRType | |
1272 | //purpose : change type of using HLR algorithm | |
1273 | //============================================================================== | |
1274 | ||
1eeef710 | 1275 | static int VHLRType (Draw_Interpretor& , Standard_Integer argc, const char** argv) |
0a768f56 | 1276 | { |
1eeef710 | 1277 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); |
1278 | const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
1279 | if (aView.IsNull()) | |
0a768f56 | 1280 | { |
23fe70ec | 1281 | Message::SendFail ("Error: no active viewer"); |
0a768f56 | 1282 | return 1; |
1283 | } | |
1284 | ||
1eeef710 | 1285 | Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet; |
1286 | ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView); | |
1287 | AIS_ListOfInteractive aListOfShapes; | |
1288 | for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) | |
0a768f56 | 1289 | { |
1eeef710 | 1290 | TCollection_AsciiString anArg (argv[anArgIter]); |
1291 | anArg.LowerCase(); | |
1292 | if (anUpdateTool.parseRedrawMode (anArg)) | |
0a768f56 | 1293 | { |
1eeef710 | 1294 | continue; |
0a768f56 | 1295 | } |
1eeef710 | 1296 | else if ((anArg == "-type" |
1297 | || anArg == "-algo" | |
1298 | || anArg == "-algotype") | |
1299 | && anArgIter + 1 < argc | |
1300 | && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR)) | |
1301 | { | |
1302 | ++anArgIter; | |
1303 | continue; | |
1304 | } | |
1305 | // old syntax | |
1306 | else if (aTypeOfHLR == Prs3d_TOH_NotSet | |
1307 | && parseHlrAlgoType (argv[anArgIter], aTypeOfHLR)) | |
1308 | { | |
1309 | continue; | |
1310 | } | |
1311 | else | |
0a768f56 | 1312 | { |
1313 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); | |
1eeef710 | 1314 | TCollection_AsciiString aName (argv[anArgIter]); |
0a768f56 | 1315 | if (!aMap.IsBound2 (aName)) |
1316 | { | |
23fe70ec | 1317 | Message::SendFail() << "Syntax error: Wrong shape name '" << aName << "'"; |
1eeef710 | 1318 | return 1; |
0a768f56 | 1319 | } |
1eeef710 | 1320 | |
1321 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (aMap.Find2 (aName)); | |
1322 | if (aShape.IsNull()) | |
1323 | { | |
23fe70ec | 1324 | Message::SendFail() << "Syntax error: '" << aName << "' is not a shape presentation"; |
1eeef710 | 1325 | return 1; |
1326 | } | |
1327 | aListOfShapes.Append (aShape); | |
1328 | continue; | |
0a768f56 | 1329 | } |
1eeef710 | 1330 | } |
1331 | if (aTypeOfHLR == Prs3d_TOH_NotSet) | |
1332 | { | |
23fe70ec | 1333 | Message::SendFail ("Syntax error: wrong number of arguments"); |
1eeef710 | 1334 | return 1; |
1335 | } | |
1336 | ||
1337 | const Standard_Boolean isGlobal = aListOfShapes.IsEmpty(); | |
1338 | if (isGlobal) | |
1339 | { | |
1340 | aCtx->DisplayedObjects (aListOfShapes); | |
1341 | aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR); | |
0a768f56 | 1342 | } |
1343 | ||
1eeef710 | 1344 | for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next()) |
1345 | { | |
1346 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()); | |
1347 | if (aShape.IsNull()) | |
1348 | { | |
1349 | continue; | |
1350 | } | |
1351 | ||
1352 | const bool toUpdateShape = aShape->TypeOfHLR() != aTypeOfHLR | |
1353 | && aView->ComputedMode(); | |
1354 | if (!isGlobal | |
1355 | || aShape->TypeOfHLR() != aTypeOfHLR) | |
1356 | { | |
1357 | aShape->SetTypeOfHLR (aTypeOfHLR); | |
1358 | } | |
1359 | if (toUpdateShape) | |
1360 | { | |
1361 | aCtx->Redisplay (aShape, Standard_False); | |
1362 | } | |
1363 | } | |
0a768f56 | 1364 | return 0; |
1365 | } | |
1366 | ||
18d715bd | 1367 | //============================================================================== |
1368 | //function : FindViewIdByWindowHandle | |
1369 | //purpose : Find theView Id in the map of views by window handle | |
1370 | //============================================================================== | |
b69e576a | 1371 | #if defined(_WIN32) || defined(HAVE_XLIB) |
1372 | static TCollection_AsciiString FindViewIdByWindowHandle (Aspect_Drawable theWindowHandle) | |
18d715bd | 1373 | { |
1374 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator | |
1375 | anIter(ViewerTest_myViews); anIter.More(); anIter.Next()) | |
1376 | { | |
49582f9d | 1377 | Aspect_Drawable aWindowHandle = anIter.Value()->Window()->NativeHandle(); |
18d715bd | 1378 | if (aWindowHandle == theWindowHandle) |
1379 | return anIter.Key1(); | |
1380 | } | |
1381 | return TCollection_AsciiString(""); | |
1382 | } | |
1383 | #endif | |
1384 | ||
e084dbbc | 1385 | //! Make the view active |
1386 | void ActivateView (const TCollection_AsciiString& theViewName, | |
1387 | Standard_Boolean theToUpdate = Standard_True) | |
18d715bd | 1388 | { |
1389 | const Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName); | |
e084dbbc | 1390 | if (aView.IsNull()) |
18d715bd | 1391 | { |
e084dbbc | 1392 | return; |
1393 | } | |
18d715bd | 1394 | |
e084dbbc | 1395 | Handle(AIS_InteractiveContext) anAISContext = FindContextByView(aView); |
1396 | if (!anAISContext.IsNull()) | |
1397 | { | |
49582f9d | 1398 | if (const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView()) |
e084dbbc | 1399 | { |
49582f9d | 1400 | aCurrentView->Window()->SetTitle (TCollection_AsciiString ("3D View - ") + ViewerTest_myViews.Find2 (aCurrentView)); |
e084dbbc | 1401 | } |
1402 | ||
1403 | ViewerTest::CurrentView (aView); | |
1404 | ViewerTest::SetAISContext (anAISContext); | |
49582f9d | 1405 | aView->Window()->SetTitle (TCollection_AsciiString("3D View - ") + theViewName + "(*)"); |
f9ab9f7f | 1406 | VT_GetWindow() = Handle(ViewerTest_Window)::DownCast(ViewerTest::CurrentView()->Window()); |
e084dbbc | 1407 | SetDisplayConnection(ViewerTest::CurrentView()->Viewer()->Driver()->GetDisplayConnection()); |
1408 | if (theToUpdate) | |
1409 | { | |
18d715bd | 1410 | ViewerTest::CurrentView()->Redraw(); |
1411 | } | |
1412 | } | |
1413 | } | |
1414 | ||
0e93d9e5 | 1415 | //============================================================================== |
1416 | //function : RemoveView | |
1417 | //purpose : | |
1418 | //============================================================================== | |
1419 | void ViewerTest::RemoveView (const Handle(V3d_View)& theView, | |
1420 | const Standard_Boolean theToRemoveContext) | |
1421 | { | |
1422 | if (!ViewerTest_myViews.IsBound2 (theView)) | |
1423 | { | |
1424 | return; | |
1425 | } | |
1426 | ||
1427 | const TCollection_AsciiString aViewName = ViewerTest_myViews.Find2 (theView); | |
1428 | RemoveView (aViewName, theToRemoveContext); | |
1429 | } | |
1430 | ||
18d715bd | 1431 | //============================================================================== |
1432 | //function : RemoveView | |
4551e1be | 1433 | //purpose : Close and remove view from display, clear maps if necessary |
18d715bd | 1434 | //============================================================================== |
1435 | void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const Standard_Boolean isContextRemoved) | |
1436 | { | |
1437 | if (!ViewerTest_myViews.IsBound1(theViewName)) | |
1438 | { | |
23fe70ec | 1439 | Message::SendFail() << "Wrong view name"; |
18d715bd | 1440 | return; |
1441 | } | |
1442 | ||
1443 | // Activate another view if it's active now | |
1444 | if (ViewerTest_myViews.Find1(theViewName) == ViewerTest::CurrentView()) | |
1445 | { | |
1446 | if (ViewerTest_myViews.Extent() > 1) | |
1447 | { | |
1448 | TCollection_AsciiString aNewViewName; | |
c48e2889 | 1449 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews); |
1450 | anIter.More(); anIter.Next()) | |
1451 | { | |
18d715bd | 1452 | if (anIter.Key1() != theViewName) |
1453 | { | |
1454 | aNewViewName = anIter.Key1(); | |
1455 | break; | |
1456 | } | |
c48e2889 | 1457 | } |
1458 | ActivateView (aNewViewName); | |
18d715bd | 1459 | } |
1460 | else | |
1461 | { | |
e084dbbc | 1462 | VT_GetWindow().Nullify(); |
1463 | ViewerTest::CurrentView (Handle(V3d_View)()); | |
18d715bd | 1464 | if (isContextRemoved) |
1465 | { | |
1466 | Handle(AIS_InteractiveContext) anEmptyContext; | |
1467 | ViewerTest::SetAISContext(anEmptyContext); | |
1468 | } | |
1469 | } | |
1470 | } | |
1471 | ||
1472 | // Delete view | |
1473 | Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName); | |
1474 | Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView); | |
8693dfd0 | 1475 | ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance(); |
f227f3dc | 1476 | aRedrawer.Stop (aView); |
18d715bd | 1477 | |
1478 | // Remove view resources | |
18d715bd | 1479 | ViewerTest_myViews.UnBind1(theViewName); |
851dacdb | 1480 | aView->Window()->Unmap(); |
18d715bd | 1481 | aView->Remove(); |
1482 | ||
b69e576a | 1483 | #if defined(HAVE_XLIB) |
1484 | XFlush ((::Display* )GetDisplayConnection()->GetDisplayAspect()); | |
18d715bd | 1485 | #endif |
1486 | ||
1487 | // Keep context opened only if the closed view is last to avoid | |
1488 | // unused empty contexts | |
1489 | if (!aCurrentContext.IsNull()) | |
1490 | { | |
f227f3dc | 1491 | // Check if there are more defined views in the viewer |
f7fc0c03 | 1492 | if ((isContextRemoved || ViewerTest_myContexts.Size() != 1) |
1493 | && aCurrentContext->CurrentViewer()->DefinedViews().IsEmpty()) | |
18d715bd | 1494 | { |
1495 | // Remove driver if there is no viewers that use it | |
1496 | Standard_Boolean isRemoveDriver = Standard_True; | |
1497 | for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator | |
1498 | anIter(ViewerTest_myContexts); anIter.More(); anIter.Next()) | |
1499 | { | |
1500 | if (aCurrentContext != anIter.Key2() && | |
1501 | aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver()) | |
1502 | { | |
1503 | isRemoveDriver = Standard_False; | |
1504 | break; | |
1505 | } | |
1506 | } | |
2ec85268 | 1507 | |
1508 | aCurrentContext->RemoveAll (Standard_False); | |
18d715bd | 1509 | if(isRemoveDriver) |
1510 | { | |
1511 | ViewerTest_myDrivers.UnBind2 (aCurrentContext->CurrentViewer()->Driver()); | |
b69e576a | 1512 | #if defined(HAVE_XLIB) |
1513 | Tcl_DeleteFileHandler (XConnectionNumber ((::Display* )aCurrentContext->CurrentViewer()->Driver()->GetDisplayConnection()->GetDisplayAspect())); | |
18d715bd | 1514 | #endif |
1515 | } | |
1516 | ||
1517 | ViewerTest_myContexts.UnBind2(aCurrentContext); | |
1518 | } | |
1519 | } | |
23fe70ec | 1520 | Message::SendInfo() << "3D View - " << theViewName << " was deleted.\n"; |
49582f9d | 1521 | if (ViewerTest_EventManager::ToExitOnCloseView()) |
fd3f6bd0 | 1522 | { |
1523 | Draw_Interprete ("exit"); | |
1524 | } | |
18d715bd | 1525 | } |
1526 | ||
1527 | //============================================================================== | |
1528 | //function : VClose | |
1529 | //purpose : Remove the view defined by its name | |
1530 | //============================================================================== | |
1531 | ||
d0cc1cb7 | 1532 | static int VClose (Draw_Interpretor& /*theDi*/, |
1533 | Standard_Integer theArgsNb, | |
1534 | const char** theArgVec) | |
18d715bd | 1535 | { |
18d715bd | 1536 | NCollection_List<TCollection_AsciiString> aViewList; |
d0cc1cb7 | 1537 | if (theArgsNb > 1) |
18d715bd | 1538 | { |
d0cc1cb7 | 1539 | TCollection_AsciiString anArg (theArgVec[1]); |
1540 | anArg.UpperCase(); | |
1541 | if (anArg.IsEqual ("ALL") | |
1542 | || anArg.IsEqual ("*")) | |
1543 | { | |
1544 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews); | |
1545 | anIter.More(); anIter.Next()) | |
1546 | { | |
1547 | aViewList.Append (anIter.Key1()); | |
1548 | } | |
1549 | if (aViewList.IsEmpty()) | |
1550 | { | |
1551 | std::cout << "No view to close\n"; | |
1552 | return 0; | |
1553 | } | |
1554 | } | |
1555 | else | |
18d715bd | 1556 | { |
d0cc1cb7 | 1557 | ViewerTest_Names aViewName (theArgVec[1]); |
1558 | if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName())) | |
1559 | { | |
23fe70ec | 1560 | Message::SendFail() << "Error: the view with name '" << theArgVec[1] << "' does not exist"; |
d0cc1cb7 | 1561 | return 1; |
1562 | } | |
1563 | aViewList.Append (aViewName.GetViewName()); | |
18d715bd | 1564 | } |
1565 | } | |
1566 | else | |
1567 | { | |
d0cc1cb7 | 1568 | // close active view |
1569 | if (ViewerTest::CurrentView().IsNull()) | |
1570 | { | |
23fe70ec | 1571 | Message::SendFail ("Error: no active view"); |
d0cc1cb7 | 1572 | return 1; |
1573 | } | |
1574 | aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView())); | |
18d715bd | 1575 | } |
1576 | ||
d0cc1cb7 | 1577 | Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1); |
18d715bd | 1578 | for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList); |
1579 | anIter.More(); anIter.Next()) | |
1580 | { | |
d0cc1cb7 | 1581 | ViewerTest::RemoveView (anIter.Value(), toRemoveContext); |
18d715bd | 1582 | } |
1583 | ||
1584 | return 0; | |
1585 | } | |
1586 | ||
1587 | //============================================================================== | |
1588 | //function : VActivate | |
1589 | //purpose : Activate the view defined by its ID | |
1590 | //============================================================================== | |
1591 | ||
1592 | static int VActivate (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
1593 | { | |
e084dbbc | 1594 | if (theArgsNb == 1) |
18d715bd | 1595 | { |
1596 | theDi.Eval("vviewlist"); | |
1597 | return 0; | |
1598 | } | |
1599 | ||
e084dbbc | 1600 | TCollection_AsciiString aNameString; |
1601 | Standard_Boolean toUpdate = Standard_True; | |
1602 | Standard_Boolean toActivate = Standard_True; | |
1603 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
18d715bd | 1604 | { |
e084dbbc | 1605 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
1606 | anArg.LowerCase(); | |
1607 | if (toUpdate | |
1608 | && anArg == "-noupdate") | |
1609 | { | |
1610 | toUpdate = Standard_False; | |
1611 | } | |
1612 | else if (toActivate | |
1613 | && aNameString.IsEmpty() | |
1614 | && anArg == "none") | |
1615 | { | |
49582f9d | 1616 | ViewerTest::CurrentView()->Window()->SetTitle (TCollection_AsciiString ("3D View - ") + ViewerTest_myViews.Find2 (ViewerTest::CurrentView())); |
e084dbbc | 1617 | VT_GetWindow().Nullify(); |
1618 | ViewerTest::CurrentView (Handle(V3d_View)()); | |
1619 | ViewerTest::ResetEventManager(); | |
1620 | theDi << theArgVec[0] << ": all views are inactive\n"; | |
1621 | toActivate = Standard_False; | |
1622 | } | |
1623 | else if (toActivate | |
1624 | && aNameString.IsEmpty()) | |
1625 | { | |
1626 | aNameString = theArgVec[anArgIter]; | |
1627 | } | |
1628 | else | |
1629 | { | |
23fe70ec | 1630 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
e084dbbc | 1631 | return 1; |
1632 | } | |
18d715bd | 1633 | } |
1634 | ||
e084dbbc | 1635 | if (!toActivate) |
1636 | { | |
1637 | return 0; | |
1638 | } | |
1639 | else if (aNameString.IsEmpty()) | |
1640 | { | |
23fe70ec | 1641 | Message::SendFail ("Syntax error: wrong number of arguments"); |
e084dbbc | 1642 | return 1; |
1643 | } | |
18d715bd | 1644 | |
1645 | // Check if this view exists in the viewer with the driver | |
e084dbbc | 1646 | ViewerTest_Names aViewNames (aNameString); |
18d715bd | 1647 | if (!ViewerTest_myViews.IsBound1(aViewNames.GetViewName())) |
1648 | { | |
e084dbbc | 1649 | theDi << "Syntax error: wrong view name '" << aNameString << "'\n"; |
18d715bd | 1650 | return 1; |
1651 | } | |
1652 | ||
1653 | // Check if it is active already | |
1654 | if (ViewerTest::CurrentView() == ViewerTest_myViews.Find1(aViewNames.GetViewName())) | |
1655 | { | |
1656 | theDi << theArgVec[0] << ": the view is active already\n"; | |
1657 | return 0; | |
1658 | } | |
1659 | ||
e084dbbc | 1660 | ActivateView (aViewNames.GetViewName(), toUpdate); |
18d715bd | 1661 | return 0; |
1662 | } | |
1663 | ||
1664 | //============================================================================== | |
1665 | //function : VViewList | |
1666 | //purpose : Print current list of views per viewer and graphic driver ID | |
1667 | // shared between viewers | |
1668 | //============================================================================== | |
1669 | ||
1670 | static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
1671 | { | |
1672 | if (theArgsNb > 2) | |
1673 | { | |
1674 | theDi << theArgVec[0] << ": Wrong number of command arguments\n" | |
29cb310a | 1675 | << "Usage: " << theArgVec[0] << " name"; |
18d715bd | 1676 | return 1; |
1677 | } | |
1678 | if (ViewerTest_myContexts.Size() < 1) | |
1679 | return 0; | |
1680 | ||
18d715bd | 1681 | Standard_Boolean isTreeView = |
29cb310a | 1682 | (( theArgsNb==1 ) || ( strcasecmp( theArgVec[1], "long" ) != 0 )); |
18d715bd | 1683 | |
1684 | if (isTreeView) | |
c48e2889 | 1685 | { |
18d715bd | 1686 | theDi << theArgVec[0] <<":\n"; |
c48e2889 | 1687 | } |
18d715bd | 1688 | |
c48e2889 | 1689 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator aDriverIter (ViewerTest_myDrivers); |
1690 | aDriverIter.More(); aDriverIter.Next()) | |
1691 | { | |
1692 | if (isTreeView) | |
1693 | theDi << aDriverIter.Key1() << ":\n"; | |
18d715bd | 1694 | |
c48e2889 | 1695 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator |
1696 | aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next()) | |
1697 | { | |
1698 | if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1) | |
18d715bd | 1699 | { |
c48e2889 | 1700 | if (isTreeView) |
18d715bd | 1701 | { |
c48e2889 | 1702 | TCollection_AsciiString aContextName(aContextIter.Key1()); |
1703 | theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":\n"; | |
1704 | } | |
18d715bd | 1705 | |
c48e2889 | 1706 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIter (ViewerTest_myViews); |
1707 | aViewIter.More(); aViewIter.Next()) | |
1708 | { | |
1709 | if (aViewIter.Key1().Search(aContextIter.Key1()) != -1) | |
18d715bd | 1710 | { |
c48e2889 | 1711 | TCollection_AsciiString aViewName(aViewIter.Key1()); |
1712 | if (isTreeView) | |
18d715bd | 1713 | { |
c48e2889 | 1714 | if (aViewIter.Value() == ViewerTest::CurrentView()) |
1715 | theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)\n"; | |
18d715bd | 1716 | else |
c48e2889 | 1717 | theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n"; |
1718 | } | |
1719 | else | |
1720 | { | |
1721 | theDi << aViewName << " "; | |
18d715bd | 1722 | } |
1723 | } | |
1724 | } | |
1725 | } | |
1726 | } | |
c48e2889 | 1727 | } |
18d715bd | 1728 | return 0; |
1729 | } | |
1730 | ||
7fd59977 | 1731 | //============================================================================== |
49582f9d | 1732 | //function : GetMousePosition |
1733 | //purpose : | |
7fd59977 | 1734 | //============================================================================== |
49582f9d | 1735 | void ViewerTest::GetMousePosition (Standard_Integer& theX, |
1736 | Standard_Integer& theY) | |
7fd59977 | 1737 | { |
49582f9d | 1738 | if (Handle(ViewerTest_EventManager) aViewCtrl = ViewerTest::CurrentEventManager()) |
4fe56619 | 1739 | { |
49582f9d | 1740 | theX = aViewCtrl->LastMousePosition().x(); |
1741 | theY = aViewCtrl->LastMousePosition().y(); | |
4fe56619 | 1742 | } |
7fd59977 | 1743 | } |
1744 | ||
44b8f2d6 | 1745 | //============================================================================== |
fc552d84 | 1746 | //function : VViewProj |
1747 | //purpose : Switch view projection | |
44b8f2d6 | 1748 | //============================================================================== |
fc552d84 | 1749 | static int VViewProj (Draw_Interpretor& , |
1750 | Standard_Integer theNbArgs, | |
1751 | const char** theArgVec) | |
44b8f2d6 | 1752 | { |
fc552d84 | 1753 | static Standard_Boolean isYup = Standard_False; |
1754 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); | |
1755 | if (aView.IsNull()) | |
44b8f2d6 | 1756 | { |
23fe70ec | 1757 | Message::SendFail ("Error: no active viewer"); |
44b8f2d6 | 1758 | return 1; |
1759 | } | |
1760 | ||
fc552d84 | 1761 | TCollection_AsciiString aCmdName (theArgVec[0]); |
1762 | Standard_Boolean isGeneralCmd = Standard_False; | |
1763 | if (aCmdName == "vfront") | |
1764 | { | |
1765 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Front : V3d_TypeOfOrientation_Zup_Front, isYup); | |
1766 | } | |
1767 | else if (aCmdName == "vback") | |
1768 | { | |
1769 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Back : V3d_TypeOfOrientation_Zup_Back, isYup); | |
1770 | } | |
1771 | else if (aCmdName == "vtop") | |
1772 | { | |
1773 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Top : V3d_TypeOfOrientation_Zup_Top, isYup); | |
1774 | } | |
1775 | else if (aCmdName == "vbottom") | |
1776 | { | |
1777 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Bottom : V3d_TypeOfOrientation_Zup_Bottom, isYup); | |
1778 | } | |
1779 | else if (aCmdName == "vleft") | |
1780 | { | |
1781 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Left : V3d_TypeOfOrientation_Zup_Left, isYup); | |
1782 | } | |
1783 | else if (aCmdName == "vright") | |
1784 | { | |
1785 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Right : V3d_TypeOfOrientation_Zup_Right, isYup); | |
1786 | } | |
1787 | else if (aCmdName == "vaxo") | |
1788 | { | |
1789 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_AxoRight : V3d_TypeOfOrientation_Zup_AxoRight, isYup); | |
1790 | } | |
1791 | else | |
1792 | { | |
1793 | isGeneralCmd = Standard_True; | |
1794 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
1795 | { | |
1796 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); | |
1797 | anArgCase.LowerCase(); | |
1798 | if (anArgCase == "-zup") | |
1799 | { | |
1800 | isYup = Standard_False; | |
1801 | } | |
1802 | else if (anArgCase == "-yup") | |
1803 | { | |
1804 | isYup = Standard_True; | |
1805 | } | |
1806 | else if (anArgCase == "-front" | |
1807 | || anArgCase == "front" | |
1808 | || anArgCase == "-f" | |
1809 | || anArgCase == "f") | |
1810 | { | |
1811 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Front : V3d_TypeOfOrientation_Zup_Front, isYup); | |
1812 | } | |
1813 | else if (anArgCase == "-back" | |
1814 | || anArgCase == "back" | |
1815 | || anArgCase == "-b" | |
1816 | || anArgCase == "b") | |
1817 | { | |
1818 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Back : V3d_TypeOfOrientation_Zup_Back, isYup); | |
1819 | } | |
1820 | else if (anArgCase == "-top" | |
1821 | || anArgCase == "top" | |
1822 | || anArgCase == "-t" | |
1823 | || anArgCase == "t") | |
1824 | { | |
1825 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Top : V3d_TypeOfOrientation_Zup_Top, isYup); | |
1826 | } | |
1827 | else if (anArgCase == "-bottom" | |
1828 | || anArgCase == "bottom" | |
1829 | || anArgCase == "-bot" | |
1830 | || anArgCase == "bot" | |
1831 | || anArgCase == "-b" | |
1832 | || anArgCase == "b") | |
1833 | { | |
1834 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Bottom : V3d_TypeOfOrientation_Zup_Bottom, isYup); | |
1835 | } | |
1836 | else if (anArgCase == "-left" | |
1837 | || anArgCase == "left" | |
1838 | || anArgCase == "-l" | |
1839 | || anArgCase == "l") | |
1840 | { | |
1841 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Left : V3d_TypeOfOrientation_Zup_Left, isYup); | |
1842 | } | |
1843 | else if (anArgCase == "-right" | |
1844 | || anArgCase == "right" | |
1845 | || anArgCase == "-r" | |
1846 | || anArgCase == "r") | |
1847 | { | |
1848 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_Right : V3d_TypeOfOrientation_Zup_Right, isYup); | |
1849 | } | |
1850 | else if (anArgCase == "-axoleft" | |
1851 | || anArgCase == "-leftaxo" | |
1852 | || anArgCase == "axoleft" | |
1853 | || anArgCase == "leftaxo") | |
1854 | { | |
1855 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_AxoLeft : V3d_TypeOfOrientation_Zup_AxoLeft, isYup); | |
1856 | } | |
1857 | else if (anArgCase == "-axo" | |
1858 | || anArgCase == "axo" | |
1859 | || anArgCase == "-a" | |
1860 | || anArgCase == "a" | |
1861 | || anArgCase == "-axoright" | |
1862 | || anArgCase == "-rightaxo" | |
1863 | || anArgCase == "axoright" | |
1864 | || anArgCase == "rightaxo") | |
1865 | { | |
1866 | aView->SetProj (isYup ? V3d_TypeOfOrientation_Yup_AxoRight : V3d_TypeOfOrientation_Zup_AxoRight, isYup); | |
1867 | } | |
1868 | else if (anArgCase == "+x") | |
1869 | { | |
1870 | aView->SetProj (V3d_Xpos, isYup); | |
1871 | } | |
1872 | else if (anArgCase == "-x") | |
1873 | { | |
1874 | aView->SetProj (V3d_Xneg, isYup); | |
1875 | } | |
1876 | else if (anArgCase == "+y") | |
1877 | { | |
1878 | aView->SetProj (V3d_Ypos, isYup); | |
1879 | } | |
1880 | else if (anArgCase == "-y") | |
1881 | { | |
1882 | aView->SetProj (V3d_Yneg, isYup); | |
1883 | } | |
1884 | else if (anArgCase == "+z") | |
1885 | { | |
1886 | aView->SetProj (V3d_Zpos, isYup); | |
1887 | } | |
1888 | else if (anArgCase == "-z") | |
1889 | { | |
1890 | aView->SetProj (V3d_Zneg, isYup); | |
1891 | } | |
1892 | else if (anArgCase == "+x+y+z") | |
1893 | { | |
1894 | aView->SetProj (V3d_XposYposZpos, isYup); | |
1895 | } | |
1896 | else if (anArgCase == "+x+y-z") | |
1897 | { | |
1898 | aView->SetProj (V3d_XposYposZneg, isYup); | |
1899 | } | |
1900 | else if (anArgCase == "+x-y+z") | |
1901 | { | |
1902 | aView->SetProj (V3d_XposYnegZpos, isYup); | |
1903 | } | |
1904 | else if (anArgCase == "+x-y-z") | |
1905 | { | |
1906 | aView->SetProj (V3d_XposYnegZneg, isYup); | |
1907 | } | |
1908 | else if (anArgCase == "-x+y+z") | |
1909 | { | |
1910 | aView->SetProj (V3d_XnegYposZpos, isYup); | |
1911 | } | |
1912 | else if (anArgCase == "-x+y-z") | |
1913 | { | |
1914 | aView->SetProj (V3d_XnegYposZneg, isYup); | |
1915 | } | |
1916 | else if (anArgCase == "-x-y+z") | |
1917 | { | |
1918 | aView->SetProj (V3d_XnegYnegZpos, isYup); | |
1919 | } | |
1920 | else if (anArgCase == "-x-y-z") | |
1921 | { | |
1922 | aView->SetProj (V3d_XnegYnegZneg, isYup); | |
1923 | } | |
1924 | else if (anArgCase == "+x+y") | |
1925 | { | |
1926 | aView->SetProj (V3d_XposYpos, isYup); | |
1927 | } | |
1928 | else if (anArgCase == "+x-y") | |
1929 | { | |
1930 | aView->SetProj (V3d_XposYneg, isYup); | |
1931 | } | |
1932 | else if (anArgCase == "-x+y") | |
1933 | { | |
1934 | aView->SetProj (V3d_XnegYpos, isYup); | |
1935 | } | |
1936 | else if (anArgCase == "-x-y") | |
1937 | { | |
1938 | aView->SetProj (V3d_XnegYneg, isYup); | |
1939 | } | |
1940 | else if (anArgCase == "+x+z") | |
1941 | { | |
1942 | aView->SetProj (V3d_XposZpos, isYup); | |
1943 | } | |
1944 | else if (anArgCase == "+x-z") | |
1945 | { | |
1946 | aView->SetProj (V3d_XposZneg, isYup); | |
1947 | } | |
1948 | else if (anArgCase == "-x+z") | |
1949 | { | |
1950 | aView->SetProj (V3d_XnegZpos, isYup); | |
1951 | } | |
1952 | else if (anArgCase == "-x-z") | |
1953 | { | |
1954 | aView->SetProj (V3d_XnegZneg, isYup); | |
1955 | } | |
1956 | else if (anArgCase == "+y+z") | |
1957 | { | |
1958 | aView->SetProj (V3d_YposZpos, isYup); | |
1959 | } | |
1960 | else if (anArgCase == "+y-z") | |
1961 | { | |
1962 | aView->SetProj (V3d_YposZneg, isYup); | |
1963 | } | |
1964 | else if (anArgCase == "-y+z") | |
1965 | { | |
1966 | aView->SetProj (V3d_YnegZpos, isYup); | |
1967 | } | |
1968 | else if (anArgCase == "-y-z") | |
1969 | { | |
1970 | aView->SetProj (V3d_YnegZneg, isYup); | |
1971 | } | |
1972 | else if (anArgIter + 1 < theNbArgs | |
1973 | && anArgCase == "-frame" | |
1974 | && TCollection_AsciiString (theArgVec[anArgIter + 1]).Length() == 4) | |
1975 | { | |
1976 | TCollection_AsciiString aFrameDef (theArgVec[++anArgIter]); | |
1977 | aFrameDef.LowerCase(); | |
1978 | gp_Dir aRight, anUp; | |
1979 | if (aFrameDef.Value (2) == aFrameDef.Value (4)) | |
1980 | { | |
23fe70ec | 1981 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
fc552d84 | 1982 | return 1; |
1983 | } | |
44b8f2d6 | 1984 | |
fc552d84 | 1985 | if (aFrameDef.Value (2) == 'x') |
1986 | { | |
1987 | aRight = aFrameDef.Value (1) == '+' ? gp::DX() : -gp::DX(); | |
1988 | } | |
1989 | else if (aFrameDef.Value (2) == 'y') | |
1990 | { | |
1991 | aRight = aFrameDef.Value (1) == '+' ? gp::DY() : -gp::DY(); | |
1992 | } | |
1993 | else if (aFrameDef.Value (2) == 'z') | |
1994 | { | |
1995 | aRight = aFrameDef.Value (1) == '+' ? gp::DZ() : -gp::DZ(); | |
1996 | } | |
1997 | else | |
1998 | { | |
23fe70ec | 1999 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
fc552d84 | 2000 | return 1; |
2001 | } | |
7fd59977 | 2002 | |
fc552d84 | 2003 | if (aFrameDef.Value (4) == 'x') |
2004 | { | |
2005 | anUp = aFrameDef.Value (3) == '+' ? gp::DX() : -gp::DX(); | |
2006 | } | |
2007 | else if (aFrameDef.Value (4) == 'y') | |
2008 | { | |
2009 | anUp = aFrameDef.Value (3) == '+' ? gp::DY() : -gp::DY(); | |
2010 | } | |
2011 | else if (aFrameDef.Value (4) == 'z') | |
2012 | { | |
2013 | anUp = aFrameDef.Value (3) == '+' ? gp::DZ() : -gp::DZ(); | |
2014 | } | |
2015 | else | |
2016 | { | |
23fe70ec | 2017 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
fc552d84 | 2018 | return 1; |
2019 | } | |
44b8f2d6 | 2020 | |
fc552d84 | 2021 | const Handle(Graphic3d_Camera)& aCamera = aView->Camera(); |
2022 | const gp_Pnt anOriginVCS = aCamera->ConvertWorld2View (gp::Origin()); | |
2023 | const gp_Dir aDir = anUp.Crossed (aRight); | |
2024 | aCamera->SetCenter (gp_Pnt (0, 0, 0)); | |
2025 | aCamera->SetDirection (aDir); | |
2026 | aCamera->SetUp (anUp); | |
2027 | aCamera->OrthogonalizeUp(); | |
44b8f2d6 | 2028 | |
fc552d84 | 2029 | aView->Panning (anOriginVCS.X(), anOriginVCS.Y()); |
2030 | aView->Update(); | |
2031 | } | |
2032 | else | |
2033 | { | |
23fe70ec | 2034 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
fc552d84 | 2035 | return 1; |
2036 | } | |
2037 | } | |
2038 | } | |
44b8f2d6 | 2039 | |
fc552d84 | 2040 | if (!isGeneralCmd |
2041 | && theNbArgs != 1) | |
2042 | { | |
23fe70ec | 2043 | Message::SendFail ("Syntax error: wrong number of arguments"); |
fc552d84 | 2044 | return 1; |
2045 | } | |
2046 | return 0; | |
7fd59977 | 2047 | } |
2048 | ||
2049 | //============================================================================== | |
2050 | //function : VHelp | |
2051 | //purpose : Dsiplay help on viewer Keyboead and mouse commands | |
2052 | //Draw arg : No args | |
2053 | //============================================================================== | |
2054 | ||
2055 | static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** ) | |
2056 | { | |
586db386 | 2057 | di << "=========================\n"; |
2058 | di << "F : FitAll\n"; | |
2059 | di << "T : TopView\n"; | |
2060 | di << "B : BottomView\n"; | |
2061 | di << "R : RightView\n"; | |
2062 | di << "L : LeftView\n"; | |
d22962e4 | 2063 | di << "Backspace : AxonometricView\n"; |
586db386 | 2064 | |
2065 | di << "=========================\n"; | |
d22962e4 | 2066 | di << "W, S : Fly forward/backward\n"; |
2067 | di << "A, D : Slide left/right\n"; | |
2068 | di << "Q, E : Bank left/right\n"; | |
2069 | di << "-, + : Change flying speed\n"; | |
2070 | di << "Arrows : look left/right/up/down\n"; | |
2071 | di << "Arrows+Shift : slide left/right/up/down\n"; | |
2072 | ||
2073 | di << "=========================\n"; | |
2074 | di << "S + Ctrl : Shading\n"; | |
2075 | di << "W + Ctrl : Wireframe\n"; | |
49582f9d | 2076 | di << "H : HiddenLineRemoval\n"; |
586db386 | 2077 | di << "U : Unset display mode\n"; |
2078 | di << "Delete : Remove selection from viewer\n"; | |
2079 | ||
2080 | di << "=========================\n"; | |
2081 | di << "Selection mode \n"; | |
2082 | di << "0 : Shape\n"; | |
2083 | di << "1 : Vertex\n"; | |
2084 | di << "2 : Edge\n"; | |
2085 | di << "3 : Wire\n"; | |
2086 | di << "4 : Face\n"; | |
2087 | di << "5 : Shell\n"; | |
2088 | di << "6 : Solid\n"; | |
2089 | di << "7 : Compound\n"; | |
2090 | ||
2091 | di << "=========================\n"; | |
49582f9d | 2092 | di << "< : Hilight next detected\n"; |
2093 | di << "> : Hilight previous detected\n"; | |
7fd59977 | 2094 | |
2095 | return 0; | |
2096 | } | |
2097 | ||
57c28b61 | 2098 | #ifdef _WIN32 |
7fd59977 | 2099 | |
49582f9d | 2100 | static LRESULT WINAPI AdvViewerWindowProc (HWND theWinHandle, |
2101 | UINT theMsg, | |
2102 | WPARAM wParam, | |
2103 | LPARAM lParam ) | |
7fd59977 | 2104 | { |
49582f9d | 2105 | if (ViewerTest_myViews.IsEmpty()) |
2106 | { | |
e8e157df | 2107 | return DefWindowProcW (theWinHandle, theMsg, wParam, lParam); |
49582f9d | 2108 | } |
7fd59977 | 2109 | |
49582f9d | 2110 | switch (theMsg) |
2111 | { | |
18d715bd | 2112 | case WM_CLOSE: |
49582f9d | 2113 | { |
2114 | // Delete view from map of views | |
2115 | ViewerTest::RemoveView (FindViewIdByWindowHandle (theWinHandle)); | |
2116 | return 0; | |
2117 | } | |
18d715bd | 2118 | case WM_ACTIVATE: |
49582f9d | 2119 | { |
2120 | if (LOWORD(wParam) == WA_CLICKACTIVE | |
2121 | || LOWORD(wParam) == WA_ACTIVE | |
2122 | || ViewerTest::CurrentView().IsNull()) | |
18d715bd | 2123 | { |
2124 | // Activate inactive window | |
49582f9d | 2125 | if (VT_GetWindow().IsNull() |
2126 | || (HWND )VT_GetWindow()->HWindow() != theWinHandle) | |
625e1958 | 2127 | { |
49582f9d | 2128 | ActivateView (FindViewIdByWindowHandle (theWinHandle)); |
625e1958 | 2129 | } |
7fd59977 | 2130 | } |
e8e157df | 2131 | return 0; |
49582f9d | 2132 | } |
e8e157df | 2133 | default: |
49582f9d | 2134 | { |
e8e157df | 2135 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); |
2136 | if (!aView.IsNull() | |
2137 | && !VT_GetWindow().IsNull()) | |
49582f9d | 2138 | { |
e8e157df | 2139 | MSG aMsg = {}; |
2140 | aMsg.hwnd = theWinHandle; | |
2141 | aMsg.message = theMsg; | |
2142 | aMsg.wParam = wParam; | |
2143 | aMsg.lParam = lParam; | |
2144 | if (VT_GetWindow()->ProcessMessage (*ViewerTest::CurrentEventManager(), aMsg)) | |
49582f9d | 2145 | { |
e8e157df | 2146 | return 0; |
49582f9d | 2147 | } |
2148 | } | |
7fd59977 | 2149 | } |
49582f9d | 2150 | } |
e8e157df | 2151 | return DefWindowProcW (theWinHandle, theMsg, wParam, lParam); |
7fd59977 | 2152 | } |
2153 | ||
7fd59977 | 2154 | //============================================================================== |
2155 | //function : ViewerMainLoop | |
2156 | //purpose : Get a Event on the view and dispatch it | |
2157 | //============================================================================== | |
2158 | ||
49582f9d | 2159 | int ViewerMainLoop (Standard_Integer theNbArgs, const char** theArgVec) |
7fd59977 | 2160 | { |
49582f9d | 2161 | Handle(ViewerTest_EventManager) aViewCtrl = ViewerTest::CurrentEventManager(); |
2162 | if (aViewCtrl.IsNull() | |
2163 | || theNbArgs < 4) | |
2164 | { | |
2165 | return 0; | |
2166 | } | |
7fd59977 | 2167 | |
49582f9d | 2168 | aViewCtrl->StartPickPoint (theArgVec[1], theArgVec[2], theArgVec[3]); |
7fd59977 | 2169 | |
49582f9d | 2170 | std::cout << "Start picking\n"; |
7fd59977 | 2171 | |
49582f9d | 2172 | MSG aMsg; |
2173 | aMsg.wParam = 1; | |
2174 | while (aViewCtrl->ToPickPoint()) | |
2175 | { | |
2176 | // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0 | |
2177 | if (GetMessageW (&aMsg, NULL, 0, 0)) | |
2178 | { | |
2179 | TranslateMessage (&aMsg); | |
2180 | DispatchMessageW (&aMsg); | |
7fd59977 | 2181 | } |
7fd59977 | 2182 | } |
2183 | ||
49582f9d | 2184 | std::cout << "Picking done\n"; |
2185 | return 0; | |
7fd59977 | 2186 | } |
2187 | ||
b69e576a | 2188 | #elif defined(HAVE_XLIB) |
7fd59977 | 2189 | |
49582f9d | 2190 | int ViewerMainLoop (Standard_Integer theNbArgs, const char** theArgVec) |
4269bd1b | 2191 | { |
18d715bd | 2192 | static XEvent aReport; |
49582f9d | 2193 | const Standard_Boolean toPick = theNbArgs > 0; |
2194 | if (theNbArgs > 0) | |
2195 | { | |
2196 | if (ViewerTest::CurrentEventManager().IsNull()) | |
2197 | { | |
2198 | return 0; | |
2199 | } | |
2200 | ViewerTest::CurrentEventManager()->StartPickPoint (theArgVec[1], theArgVec[2], theArgVec[3]); | |
2201 | } | |
2202 | ||
b69e576a | 2203 | Display* aDisplay = (Display* )GetDisplayConnection()->GetDisplayAspect(); |
18d715bd | 2204 | XNextEvent (aDisplay, &aReport); |
7fd59977 | 2205 | |
18d715bd | 2206 | // Handle event for the chosen display connection |
8693dfd0 | 2207 | switch (aReport.type) |
2208 | { | |
2209 | case ClientMessage: | |
2210 | { | |
2211 | if ((Atom)aReport.xclient.data.l[0] == GetDisplayConnection()->GetAtom(Aspect_XA_DELETE_WINDOW)) | |
2212 | { | |
2213 | // Close the window | |
2214 | ViewerTest::RemoveView(FindViewIdByWindowHandle (aReport.xclient.window)); | |
2215 | return toPick ? 0 : 1; | |
2216 | } | |
2217 | break; | |
2218 | } | |
2219 | case FocusIn: | |
2220 | { | |
2221 | // Activate inactive view | |
49582f9d | 2222 | Window aWindow = !VT_GetWindow().IsNull() ? VT_GetWindow()->XWindow() : 0; |
8693dfd0 | 2223 | if (aWindow != aReport.xfocus.window) |
2224 | { | |
2225 | ActivateView (FindViewIdByWindowHandle (aReport.xfocus.window)); | |
2226 | } | |
2227 | break; | |
2228 | } | |
e8e157df | 2229 | default: |
8693dfd0 | 2230 | { |
e8e157df | 2231 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); |
2232 | if (!aView.IsNull() | |
2233 | && !VT_GetWindow().IsNull()) | |
8693dfd0 | 2234 | { |
e8e157df | 2235 | VT_GetWindow()->ProcessMessage (*ViewerTest::CurrentEventManager(), aReport); |
49582f9d | 2236 | } |
8693dfd0 | 2237 | break; |
2238 | } | |
2239 | } | |
49582f9d | 2240 | return (!toPick || ViewerTest::CurrentEventManager()->ToPickPoint()) ? 1 : 0; |
7fd59977 | 2241 | } |
2242 | ||
2243 | //============================================================================== | |
2244 | //function : VProcessEvents | |
8693dfd0 | 2245 | //purpose : manage the event in the Viewer window (see Tcl_CreateFileHandler()) |
7fd59977 | 2246 | //============================================================================== |
8693dfd0 | 2247 | static void VProcessEvents (ClientData theDispX, int) |
7fd59977 | 2248 | { |
8693dfd0 | 2249 | Display* aDispX = (Display* )theDispX; |
2250 | Handle(Aspect_DisplayConnection) aDispConn; | |
2251 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator | |
2252 | aDriverIter (ViewerTest_myDrivers); aDriverIter.More(); aDriverIter.Next()) | |
18d715bd | 2253 | { |
8693dfd0 | 2254 | const Handle(Aspect_DisplayConnection)& aDispConnTmp = aDriverIter.Key2()->GetDisplayConnection(); |
b69e576a | 2255 | if ((Display* )aDispConnTmp->GetDisplayAspect() == aDispX) |
8693dfd0 | 2256 | { |
2257 | aDispConn = aDispConnTmp; | |
2258 | break; | |
2259 | } | |
2260 | } | |
2261 | if (aDispConn.IsNull()) | |
2262 | { | |
23fe70ec | 2263 | Message::SendFail ("Error: ViewerTest is unable processing messages for unknown X Display"); |
8693dfd0 | 2264 | return; |
4269bd1b | 2265 | } |
8693dfd0 | 2266 | |
2267 | // process new events in queue | |
2268 | SetDisplayConnection (aDispConn); | |
2269 | int aNbRemain = 0; | |
2270 | for (int aNbEventsMax = XPending (aDispX), anEventIter (0);;) | |
18d715bd | 2271 | { |
8693dfd0 | 2272 | const int anEventResult = ViewerMainLoop (0, NULL); |
2273 | if (anEventResult == 0) | |
18d715bd | 2274 | { |
8693dfd0 | 2275 | return; |
2276 | } | |
2277 | ||
2278 | aNbRemain = XPending (aDispX); | |
2279 | if (++anEventIter >= aNbEventsMax | |
2280 | || aNbRemain <= 0) | |
2281 | { | |
2282 | break; | |
18d715bd | 2283 | } |
7fd59977 | 2284 | } |
4269bd1b | 2285 | |
8693dfd0 | 2286 | // Listening X events through Tcl_CreateFileHandler() callback is fragile, |
2287 | // it is possible that new events will arrive to queue before the end of this callback | |
2288 | // so that either this callback should go into an infinite loop (blocking processing of other events) | |
2289 | // or to keep unprocessed events till the next queue update (which can arrive not soon). | |
2290 | // Sending a dummy event in this case is a simple workaround (still, it is possible that new event will be queued in-between). | |
2291 | if (aNbRemain != 0) | |
2292 | { | |
2293 | XEvent aDummyEvent; | |
2294 | memset (&aDummyEvent, 0, sizeof(aDummyEvent)); | |
2295 | aDummyEvent.type = ClientMessage; | |
2296 | aDummyEvent.xclient.format = 32; | |
2297 | XSendEvent (aDispX, InputFocus, False, 0, &aDummyEvent); | |
2298 | XFlush (aDispX); | |
2299 | } | |
4269bd1b | 2300 | |
8693dfd0 | 2301 | if (const Handle(AIS_InteractiveContext)& anActiveCtx = ViewerTest::GetAISContext()) |
2302 | { | |
2303 | SetDisplayConnection (anActiveCtx->CurrentViewer()->Driver()->GetDisplayConnection()); | |
2304 | } | |
7fd59977 | 2305 | } |
b69e576a | 2306 | #elif !defined(__APPLE__) |
2307 | // ======================================================================= | |
2308 | // function : ViewerMainLoop | |
2309 | // purpose : | |
2310 | // ======================================================================= | |
2311 | int ViewerMainLoop (Standard_Integer , const char** ) | |
2312 | { | |
2313 | // unused | |
2314 | return 0; | |
2315 | } | |
7fd59977 | 2316 | #endif |
2317 | ||
7fd59977 | 2318 | //============================================================================== |
2319 | //function : VFit | |
1beb58d7 | 2320 | //purpose : |
7fd59977 | 2321 | //============================================================================== |
2322 | ||
1beb58d7 | 2323 | static int VFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgv) |
7fd59977 | 2324 | { |
1beb58d7 | 2325 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); |
2326 | if (aView.IsNull()) | |
b586500b | 2327 | { |
23fe70ec | 2328 | Message::SendFail ("Error: no active viewer"); |
1beb58d7 | 2329 | return 1; |
b586500b | 2330 | } |
2331 | ||
1beb58d7 | 2332 | Standard_Boolean toFit = Standard_True; |
2333 | ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView); | |
2334 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
b586500b | 2335 | { |
1beb58d7 | 2336 | TCollection_AsciiString anArg (theArgv[anArgIter]); |
b586500b | 2337 | anArg.LowerCase(); |
1beb58d7 | 2338 | if (anUpdateTool.parseRedrawMode (anArg)) |
b586500b | 2339 | { |
1beb58d7 | 2340 | continue; |
2341 | } | |
2342 | else if (anArg == "-selected") | |
2343 | { | |
2344 | ViewerTest::GetAISContext()->FitSelected (aView, 0.01, Standard_False); | |
2345 | toFit = Standard_False; | |
2346 | } | |
2347 | else | |
2348 | { | |
23fe70ec | 2349 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
b586500b | 2350 | } |
2351 | } | |
2352 | ||
1beb58d7 | 2353 | if (toFit) |
2354 | { | |
2355 | aView->FitAll (0.01, Standard_False); | |
7fd59977 | 2356 | } |
2357 | return 0; | |
2358 | } | |
2359 | ||
6262a303 | 2360 | //======================================================================= |
2361 | //function : VFitArea | |
2362 | //purpose : Fit view to show area located between two points | |
2363 | // : given in world 2D or 3D coordinates. | |
2364 | //======================================================================= | |
2365 | static int VFitArea (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
2366 | { | |
2367 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2368 | if (aView.IsNull()) | |
2369 | { | |
23fe70ec | 2370 | Message::SendFail ("Error: No active viewer"); |
6262a303 | 2371 | return 1; |
2372 | } | |
2373 | ||
2374 | // Parse arguments. | |
2375 | gp_Pnt aWorldPnt1 (0.0, 0.0, 0.0); | |
2376 | gp_Pnt aWorldPnt2 (0.0, 0.0, 0.0); | |
2377 | ||
2378 | if (theArgNb == 5) | |
2379 | { | |
2380 | aWorldPnt1.SetX (Draw::Atof (theArgVec[1])); | |
2381 | aWorldPnt1.SetY (Draw::Atof (theArgVec[2])); | |
2382 | aWorldPnt2.SetX (Draw::Atof (theArgVec[3])); | |
2383 | aWorldPnt2.SetY (Draw::Atof (theArgVec[4])); | |
2384 | } | |
2385 | else if (theArgNb == 7) | |
2386 | { | |
2387 | aWorldPnt1.SetX (Draw::Atof (theArgVec[1])); | |
2388 | aWorldPnt1.SetY (Draw::Atof (theArgVec[2])); | |
2389 | aWorldPnt1.SetZ (Draw::Atof (theArgVec[3])); | |
2390 | aWorldPnt2.SetX (Draw::Atof (theArgVec[4])); | |
2391 | aWorldPnt2.SetY (Draw::Atof (theArgVec[5])); | |
2392 | aWorldPnt2.SetZ (Draw::Atof (theArgVec[6])); | |
2393 | } | |
2394 | else | |
2395 | { | |
23fe70ec | 2396 | Message::SendFail ("Syntax error: Invalid number of arguments"); |
6262a303 | 2397 | theDI.PrintHelp(theArgVec[0]); |
2398 | return 1; | |
2399 | } | |
2400 | ||
2401 | // Convert model coordinates to view space | |
2402 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); | |
2403 | gp_Pnt aViewPnt1 = aCamera->ConvertWorld2View (aWorldPnt1); | |
2404 | gp_Pnt aViewPnt2 = aCamera->ConvertWorld2View (aWorldPnt2); | |
2405 | ||
2406 | // Determine fit area | |
2407 | gp_Pnt2d aMinCorner (Min (aViewPnt1.X(), aViewPnt2.X()), Min (aViewPnt1.Y(), aViewPnt2.Y())); | |
2408 | gp_Pnt2d aMaxCorner (Max (aViewPnt1.X(), aViewPnt2.X()), Max (aViewPnt1.Y(), aViewPnt2.Y())); | |
2409 | ||
2410 | Standard_Real aDiagonal = aMinCorner.Distance (aMaxCorner); | |
2411 | ||
2412 | if (aDiagonal < Precision::Confusion()) | |
2413 | { | |
23fe70ec | 2414 | Message::SendFail ("Error: view area is too small"); |
6262a303 | 2415 | return 1; |
2416 | } | |
2417 | ||
2418 | aView->FitAll (aMinCorner.X(), aMinCorner.Y(), aMaxCorner.X(), aMaxCorner.Y()); | |
2419 | return 0; | |
2420 | } | |
2421 | ||
7fd59977 | 2422 | //============================================================================== |
2423 | //function : VZFit | |
2424 | //purpose : ZFitall, no DRAW arguments | |
2425 | //Draw arg : No args | |
2426 | //============================================================================== | |
197ac94e | 2427 | static int VZFit (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec) |
7fd59977 | 2428 | { |
197ac94e | 2429 | const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView(); |
2430 | ||
2431 | if (aCurrentView.IsNull()) | |
2432 | { | |
23fe70ec | 2433 | Message::SendFail ("Error: no active viewer"); |
197ac94e | 2434 | return 1; |
2435 | } | |
2436 | ||
2437 | if (theArgsNb == 1) | |
2438 | { | |
c357e426 | 2439 | aCurrentView->ZFitAll(); |
197ac94e | 2440 | aCurrentView->Redraw(); |
2441 | return 0; | |
2442 | } | |
2443 | ||
2444 | Standard_Real aScale = 1.0; | |
2445 | ||
2446 | if (theArgsNb >= 2) | |
2447 | { | |
2448 | aScale = Draw::Atoi (theArgVec[1]); | |
2449 | } | |
2450 | ||
c357e426 | 2451 | aCurrentView->ZFitAll (aScale); |
197ac94e | 2452 | aCurrentView->Redraw(); |
7fd59977 | 2453 | |
197ac94e | 2454 | return 0; |
2455 | } | |
7fd59977 | 2456 | |
197ac94e | 2457 | //============================================================================== |
2458 | //function : VRepaint | |
2459 | //purpose : | |
2460 | //============================================================================== | |
56689b27 | 2461 | static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgVec) |
7fd59977 | 2462 | { |
56689b27 | 2463 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
2464 | if (aView.IsNull()) | |
2465 | { | |
23fe70ec | 2466 | Message::SendFail ("Error: no active viewer"); |
56689b27 | 2467 | return 1; |
2468 | } | |
2469 | ||
2470 | Standard_Boolean isImmediateUpdate = Standard_False; | |
2471 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
2472 | { | |
2473 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
2474 | anArg.LowerCase(); | |
8693dfd0 | 2475 | if (anArg == "-immediate" |
2476 | || anArg == "-imm") | |
56689b27 | 2477 | { |
2478 | isImmediateUpdate = Standard_True; | |
2479 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 2480 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate)) |
56689b27 | 2481 | { |
2482 | ++anArgIter; | |
2483 | } | |
2484 | } | |
8693dfd0 | 2485 | else if (anArg == "-continuous" |
2486 | || anArg == "-cont" | |
2487 | || anArg == "-fps" | |
2488 | || anArg == "-framerate") | |
2489 | { | |
2490 | Standard_Real aFps = -1.0; | |
2491 | if (anArgIter + 1 < theArgNb | |
d45edf24 | 2492 | && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsRealValue (Standard_True)) |
8693dfd0 | 2493 | { |
2494 | aFps = Draw::Atof (theArgVec[++anArgIter]); | |
2495 | } | |
2496 | ||
2497 | ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance(); | |
f227f3dc | 2498 | ViewerTest::CurrentEventManager()->SetContinuousRedraw (false); |
2499 | if (aFps >= 1.0) | |
8693dfd0 | 2500 | { |
f227f3dc | 2501 | aRedrawer.Start (aView, aFps); |
2502 | } | |
2503 | else if (aFps < 0.0) | |
2504 | { | |
2505 | if (ViewerTest::GetViewerFromContext()->ActiveViews().Extent() == 1) | |
2506 | { | |
2507 | aRedrawer.Stop(); | |
2508 | ViewerTest::CurrentEventManager()->SetContinuousRedraw (true); | |
2509 | ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true); | |
2510 | continue; | |
2511 | } | |
2512 | aRedrawer.Start (aView, aFps); | |
8693dfd0 | 2513 | } |
2514 | else | |
2515 | { | |
2516 | aRedrawer.Stop(); | |
2517 | } | |
2518 | } | |
56689b27 | 2519 | else |
2520 | { | |
23fe70ec | 2521 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
8693dfd0 | 2522 | return 1; |
56689b27 | 2523 | } |
2524 | } | |
2525 | ||
2526 | if (isImmediateUpdate) | |
2527 | { | |
2528 | aView->RedrawImmediate(); | |
2529 | } | |
2530 | else | |
2531 | { | |
2532 | aView->Redraw(); | |
2533 | } | |
2534 | return 0; | |
7fd59977 | 2535 | } |
2536 | ||
7fd59977 | 2537 | //============================================================================== |
2538 | //function : VClear | |
2539 | //purpose : Remove all the object from the viewer | |
2540 | //Draw arg : No args | |
2541 | //============================================================================== | |
2542 | ||
2543 | static int VClear(Draw_Interpretor& , Standard_Integer , const char** ) | |
2544 | { | |
2545 | Handle(V3d_View) V = ViewerTest::CurrentView(); | |
2546 | if(!V.IsNull()) | |
2547 | ViewerTest::Clear(); | |
2548 | return 0; | |
2549 | } | |
2550 | ||
2551 | //============================================================================== | |
2552 | //function : VPick | |
2553 | //purpose : | |
2554 | //============================================================================== | |
2555 | ||
49582f9d | 2556 | static int VPick (Draw_Interpretor& , |
2557 | Standard_Integer theNbArgs, | |
2558 | const char** theArgVec) | |
2559 | { | |
2560 | if (ViewerTest::CurrentView().IsNull()) | |
2561 | { | |
2562 | return 1; | |
2563 | } | |
7fd59977 | 2564 | |
49582f9d | 2565 | if (theNbArgs < 4) |
2566 | { | |
23fe70ec | 2567 | Message::SendFail ("Syntax error: wrong number of arguments"); |
49582f9d | 2568 | return 1; |
2569 | } | |
7fd59977 | 2570 | |
49582f9d | 2571 | while (ViewerMainLoop (theNbArgs, theArgVec)) |
2572 | { | |
2573 | // | |
2574 | } | |
7fd59977 | 2575 | |
49582f9d | 2576 | return 0; |
7fd59977 | 2577 | } |
2578 | ||
c585f731 | 2579 | //! Parse image fill method. |
2580 | static bool parseImageMode (const TCollection_AsciiString& theName, | |
2581 | Aspect_FillMethod& theMode) | |
2582 | { | |
2583 | TCollection_AsciiString aName = theName; | |
2584 | aName.LowerCase(); | |
2585 | if (aName == "none") | |
2586 | { | |
2587 | theMode = Aspect_FM_NONE; | |
2588 | } | |
2589 | else if (aName == "centered") | |
2590 | { | |
2591 | theMode = Aspect_FM_CENTERED; | |
2592 | } | |
2593 | else if (aName == "tiled") | |
2594 | { | |
2595 | theMode = Aspect_FM_TILED; | |
2596 | } | |
2597 | else if (aName == "stretch") | |
2598 | { | |
2599 | theMode = Aspect_FM_STRETCH; | |
2600 | } | |
2601 | else | |
2602 | { | |
2603 | return false; | |
2604 | } | |
2605 | return true; | |
2606 | } | |
2607 | ||
2608 | //! Parse gradient fill method. | |
2609 | static bool parseGradientMode (const TCollection_AsciiString& theName, | |
2610 | Aspect_GradientFillMethod& theMode) | |
2611 | { | |
2612 | TCollection_AsciiString aName = theName; | |
2613 | aName.LowerCase(); | |
2614 | if (aName == "none") | |
2615 | { | |
9af0d66b | 2616 | theMode = Aspect_GradientFillMethod_None; |
c585f731 | 2617 | } |
2618 | else if (aName == "hor" | |
2619 | || aName == "horizontal") | |
2620 | { | |
9af0d66b | 2621 | theMode = Aspect_GradientFillMethod_Horizontal; |
c585f731 | 2622 | } |
2623 | else if (aName == "ver" | |
2624 | || aName == "vert" | |
2625 | || aName == "vertical") | |
2626 | { | |
9af0d66b | 2627 | theMode = Aspect_GradientFillMethod_Vertical; |
c585f731 | 2628 | } |
2629 | else if (aName == "diag" | |
2630 | || aName == "diagonal" | |
2631 | || aName == "diag1" | |
2632 | || aName == "diagonal1") | |
2633 | { | |
9af0d66b | 2634 | theMode = Aspect_GradientFillMethod_Diagonal1; |
c585f731 | 2635 | } |
2636 | else if (aName == "diag2" | |
2637 | || aName == "diagonal2") | |
2638 | { | |
9af0d66b | 2639 | theMode = Aspect_GradientFillMethod_Diagonal2; |
c585f731 | 2640 | } |
2641 | else if (aName == "corner1") | |
2642 | { | |
9af0d66b | 2643 | theMode = Aspect_GradientFillMethod_Corner1; |
c585f731 | 2644 | } |
2645 | else if (aName == "corner2") | |
2646 | { | |
9af0d66b | 2647 | theMode = Aspect_GradientFillMethod_Corner2; |
c585f731 | 2648 | } |
2649 | else if (aName == "corner3") | |
2650 | { | |
9af0d66b | 2651 | theMode = Aspect_GradientFillMethod_Corner3; |
c585f731 | 2652 | } |
2653 | else if (aName == "corner4") | |
2654 | { | |
9af0d66b | 2655 | theMode = Aspect_GradientFillMethod_Corner4; |
2656 | } | |
2657 | else if (aName == "ellip" | |
2658 | || aName == "elliptical") | |
2659 | { | |
2660 | theMode = Aspect_GradientFillMethod_Elliptical; | |
c585f731 | 2661 | } |
2662 | else | |
2663 | { | |
2664 | return false; | |
2665 | } | |
2666 | return true; | |
2667 | } | |
2668 | ||
2669 | //============================================================================== | |
2670 | //function : VBackground | |
2671 | //purpose : | |
2672 | //============================================================================== | |
2673 | static int VBackground (Draw_Interpretor& theDI, | |
2674 | Standard_Integer theNbArgs, | |
2675 | const char** theArgVec) | |
7fd59977 | 2676 | { |
c585f731 | 2677 | if (theNbArgs < 2) |
2678 | { | |
2679 | theDI << "Syntax error: wrong number of arguments"; | |
2680 | return 1; | |
2681 | } | |
2682 | ||
2683 | const TCollection_AsciiString aCmdName (theArgVec[0]); | |
2684 | bool isDefault = aCmdName == "vsetdefaultbg"; | |
2685 | Standard_Integer aNbColors = 0; | |
2686 | Quantity_ColorRGBA aColors[2]; | |
2687 | ||
9af0d66b | 2688 | Aspect_GradientFillMethod aGradientMode = Aspect_GradientFillMethod_None; |
c585f731 | 2689 | bool hasGradientMode = false; |
2690 | ||
2691 | TCollection_AsciiString anImagePath; | |
2692 | Aspect_FillMethod anImageMode = Aspect_FM_CENTERED; | |
2693 | bool hasImageMode = false; | |
2694 | ||
2695 | NCollection_Sequence<TCollection_AsciiString> aCubeMapSeq; | |
2696 | Graphic3d_CubeMapOrder aCubeOrder = Graphic3d_CubeMapOrder::Default(); | |
3e9cb806 | 2697 | bool isCubeZInverted = false; |
c585f731 | 2698 | bool isSRgb = true; |
2699 | ||
3e9cb806 | 2700 | int toUseIBL = 1; |
2701 | ||
c585f731 | 2702 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
2703 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); | |
2704 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
2705 | { | |
2706 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
2707 | anArg.LowerCase(); | |
2708 | if (anUpdateTool.parseRedrawMode (anArg)) | |
2709 | { | |
2710 | continue; | |
2711 | } | |
2712 | else if (anArg == "-default" | |
2713 | || anArg == "-def") | |
2714 | { | |
2715 | isDefault = true; | |
2716 | } | |
2717 | else if (anArgIter + 1 < theNbArgs | |
2718 | && (anArg == "-imagefile" | |
2719 | || anArg == "-imgfile" | |
2720 | || anArg == "-image" | |
2721 | || anArg == "-img")) | |
2722 | { | |
2723 | anImagePath = theArgVec[++anArgIter]; | |
2724 | } | |
2725 | else if (anArgIter + 1 < theNbArgs | |
2726 | && aCubeMapSeq.IsEmpty() | |
2727 | && (anArg == "-cubemap" | |
2728 | || anArg == "-cmap" | |
2729 | || anArg == "-cm")) | |
2730 | { | |
2731 | aCubeMapSeq.Append (theArgVec[++anArgIter]); | |
2732 | for (Standard_Integer aCubeSideIter = 1; anArgIter + aCubeSideIter < theNbArgs; ++aCubeSideIter) | |
2733 | { | |
2734 | TCollection_AsciiString aSideArg (theArgVec[anArgIter + aCubeSideIter]); | |
2735 | if (!aSideArg.IsEmpty() | |
2736 | && aSideArg.Value (1) == '-') | |
2737 | { | |
2738 | break; | |
2739 | } | |
2740 | ||
2741 | aCubeMapSeq.Append (aSideArg); | |
2742 | if (aCubeMapSeq.Size() == 6) | |
2743 | { | |
2744 | anArgIter += 5; | |
2745 | break; | |
2746 | } | |
2747 | } | |
2748 | ||
2749 | if (aCubeMapSeq.Size() > 1 | |
2750 | && aCubeMapSeq.Size() < 6) | |
2751 | { | |
2752 | aCubeMapSeq.Remove (2, aCubeMapSeq.Size()); | |
2753 | } | |
2754 | } | |
2755 | else if (anArgIter + 6 < theNbArgs | |
2756 | && anArg == "-order") | |
2757 | { | |
2758 | for (Standard_Integer aCubeSideIter = 0; aCubeSideIter < 6; ++aCubeSideIter) | |
2759 | { | |
2760 | Standard_Integer aSideArg = 0; | |
2761 | if (!Draw::ParseInteger (theArgVec[anArgIter + aCubeSideIter + 1], aSideArg) | |
2762 | || aSideArg < 0 | |
2763 | || aSideArg > 5) | |
2764 | { | |
2765 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
2766 | return 1; | |
2767 | } | |
2768 | aCubeOrder.Set ((Graphic3d_CubeMapSide )aCubeSideIter, (unsigned char )aSideArg); | |
2769 | } | |
2770 | if (!aCubeOrder.IsValid()) | |
2771 | { | |
2772 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
2773 | return 1; | |
2774 | } | |
2775 | anArgIter += 6; | |
2776 | } | |
2777 | else if (anArg == "-invertedz" | |
2778 | || anArg == "-noinvertedz" | |
2779 | || anArg == "-invz" | |
2780 | || anArg == "-noinvz") | |
2781 | { | |
2782 | isCubeZInverted = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); | |
2783 | } | |
2784 | else if (anArg == "-pbrenv" | |
3e9cb806 | 2785 | || anArg == "-nopbrenv" |
2786 | || anArg == "-ibl" | |
2787 | || anArg == "-noibl") | |
c585f731 | 2788 | { |
3e9cb806 | 2789 | toUseIBL = !anArg.StartsWith ("-no") ? 1 : 0; |
2790 | if (anArgIter + 1 < theNbArgs) | |
2791 | { | |
2792 | TCollection_AsciiString anIblArg (theArgVec[anArgIter + 1]); | |
2793 | anIblArg.LowerCase(); | |
2794 | if (anIblArg == "keep" | |
2795 | || anIblArg == "-1") | |
2796 | { | |
2797 | toUseIBL = -1; | |
2798 | ++anArgIter; | |
2799 | } | |
2800 | else if (anIblArg == "ibl" | |
2801 | || anIblArg == "1" | |
2802 | || anIblArg == "on") | |
2803 | { | |
2804 | toUseIBL = !anArg.StartsWith ("-no") ? 1 : 0; | |
2805 | ++anArgIter; | |
2806 | } | |
2807 | else if (anIblArg == "noibl" | |
2808 | || anIblArg == "0" | |
2809 | || anIblArg == "off") | |
2810 | { | |
2811 | toUseIBL = !anArg.StartsWith ("-no") ? 0 : 1; | |
2812 | ++anArgIter; | |
2813 | } | |
2814 | } | |
c585f731 | 2815 | } |
2816 | else if (anArg == "-srgb" | |
2817 | || anArg == "-nosrgb") | |
2818 | { | |
2819 | isSRgb = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); | |
2820 | } | |
2821 | else if (aNbColors < 2 | |
2822 | && (anArg == "-color" | |
2823 | || anArg == "-col")) | |
2824 | { | |
2825 | Standard_Integer aNbParsed = Draw::ParseColor (theNbArgs - (anArgIter + 1), | |
2826 | theArgVec + (anArgIter + 1), | |
2827 | aColors[aNbColors].ChangeRGB()); | |
2828 | if (aNbParsed == 0) | |
2829 | { | |
2830 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
2831 | return 1; | |
2832 | } | |
2833 | anArgIter += aNbParsed; | |
2834 | ++aNbColors; | |
2835 | } | |
2836 | else if (anArgIter + 1 < theNbArgs | |
2837 | && (anArg == "-gradientmode" | |
2838 | || anArg == "-gradmode" | |
2839 | || anArg == "-gradmd" | |
2840 | || anArg == "-grmode" | |
2841 | || anArg == "-grmd") | |
2842 | && parseGradientMode (theArgVec[anArgIter + 1], aGradientMode)) | |
2843 | { | |
2844 | ++anArgIter; | |
2845 | hasGradientMode = true; | |
2846 | } | |
2847 | else if (anArgIter + 1 < theNbArgs | |
2848 | && (anArg == "-imagemode" | |
2849 | || anArg == "-imgmode" | |
2850 | || anArg == "-imagemd" | |
2851 | || anArg == "-imgmd") | |
2852 | && parseImageMode (theArgVec[anArgIter + 1], anImageMode)) | |
2853 | { | |
2854 | ++anArgIter; | |
2855 | hasImageMode = true; | |
2856 | } | |
2857 | else if (aNbColors == 0 | |
2858 | && anArgIter + 2 < theNbArgs | |
2859 | && (anArg == "-gradient" | |
2860 | || anArg == "-grad" | |
2861 | || anArg == "-gr")) | |
2862 | { | |
2863 | Standard_Integer aNbParsed1 = Draw::ParseColor (theNbArgs - (anArgIter + 1), | |
2864 | theArgVec + (anArgIter + 1), | |
2865 | aColors[aNbColors].ChangeRGB()); | |
2866 | anArgIter += aNbParsed1; | |
2867 | ++aNbColors; | |
2868 | if (aNbParsed1 == 0) | |
2869 | { | |
2870 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
2871 | return 1; | |
2872 | } | |
2873 | Standard_Integer aNbParsed2 = Draw::ParseColor (theNbArgs - (anArgIter + 1), | |
2874 | theArgVec + (anArgIter + 1), | |
2875 | aColors[aNbColors].ChangeRGB()); | |
2876 | anArgIter += aNbParsed2; | |
2877 | ++aNbColors; | |
2878 | if (aNbParsed2 == 0) | |
2879 | { | |
2880 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
2881 | return 1; | |
2882 | } | |
2883 | } | |
2884 | else if (parseGradientMode (theArgVec[anArgIter], aGradientMode)) | |
2885 | { | |
2886 | hasGradientMode = true; | |
2887 | } | |
2888 | else if (aNbColors < 2 | |
2889 | && (Quantity_ColorRGBA::ColorFromName(theArgVec[anArgIter], aColors[aNbColors]) | |
2890 | || Quantity_ColorRGBA::ColorFromHex (theArgVec[anArgIter], aColors[aNbColors]))) | |
2891 | { | |
2892 | ++aNbColors; | |
2893 | } | |
2894 | else if (anImagePath.IsEmpty() | |
2895 | && aNbColors == 0 | |
2896 | && !hasGradientMode | |
2897 | && aCubeMapSeq.IsEmpty()) | |
2898 | { | |
2899 | anImagePath = theArgVec[anArgIter]; | |
2900 | } | |
2901 | else | |
2902 | { | |
2903 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
2904 | return 1; | |
2905 | } | |
2906 | } | |
2907 | ||
2908 | if (!isDefault | |
2909 | && aView.IsNull()) | |
2910 | { | |
2911 | theDI << "Error: no active viewer"; | |
2912 | return 1; | |
2913 | } | |
2914 | else if (isDefault | |
2915 | && aNbColors == 0 | |
2916 | && !hasGradientMode) | |
2917 | { | |
2918 | theDI << "Syntax error at '-default'"; | |
2919 | return 1; | |
2920 | } | |
2921 | ||
2922 | if (aNbColors == 1) | |
2923 | { | |
2924 | if (isDefault) | |
2925 | { | |
2926 | ViewerTest_DefaultBackground.GradientColor1 = Quantity_Color(); | |
2927 | ViewerTest_DefaultBackground.GradientColor2 = Quantity_Color(); | |
9af0d66b | 2928 | ViewerTest_DefaultBackground.FillMethod = Aspect_GradientFillMethod_None; |
c585f731 | 2929 | ViewerTest_DefaultBackground.FlatColor = aColors[0].GetRGB(); |
2930 | ViewerTest_DefaultBackground.SetDefaultGradient(); | |
2931 | ViewerTest_DefaultBackground.SetDefaultColor(); | |
2932 | } | |
2933 | else | |
2934 | { | |
9af0d66b | 2935 | aView->SetBgGradientStyle (hasGradientMode ? aGradientMode : Aspect_GradientFillMethod_None); |
c585f731 | 2936 | aView->SetBackgroundColor (aColors[0].GetRGB()); |
3e9cb806 | 2937 | if (toUseIBL != -1) |
2938 | { | |
2939 | aView->SetBackgroundCubeMap (Handle(Graphic3d_CubeMap)(), true); | |
2940 | } | |
c585f731 | 2941 | } |
2942 | } | |
2943 | else if (aNbColors == 2) | |
2944 | { | |
2945 | if (isDefault) | |
2946 | { | |
2947 | ViewerTest_DefaultBackground.GradientColor1 = aColors[0].GetRGB(); | |
2948 | ViewerTest_DefaultBackground.GradientColor2 = aColors[1].GetRGB(); | |
2949 | if (hasGradientMode) | |
2950 | { | |
2951 | ViewerTest_DefaultBackground.FillMethod = aGradientMode; | |
2952 | } | |
9af0d66b | 2953 | else if (ViewerTest_DefaultBackground.FillMethod == Aspect_GradientFillMethod_None) |
c585f731 | 2954 | { |
9af0d66b | 2955 | ViewerTest_DefaultBackground.FillMethod = Aspect_GradientFillMethod_Vertical; |
c585f731 | 2956 | } |
2957 | ViewerTest_DefaultBackground.SetDefaultGradient(); | |
2958 | } | |
2959 | else | |
2960 | { | |
2961 | if (!hasGradientMode) | |
2962 | { | |
2963 | aGradientMode = aView->GradientBackground().BgGradientFillMethod(); | |
9af0d66b | 2964 | if (aGradientMode == Aspect_GradientFillMethod_None) |
c585f731 | 2965 | { |
9af0d66b | 2966 | aGradientMode = Aspect_GradientFillMethod_Vertical; |
c585f731 | 2967 | } |
2968 | } | |
2969 | aView->SetBgGradientColors (aColors[0].GetRGB(), aColors[1].GetRGB(), aGradientMode); | |
3e9cb806 | 2970 | if (toUseIBL != -1) |
2971 | { | |
2972 | aView->SetBackgroundCubeMap (Handle(Graphic3d_CubeMap)(), true); | |
2973 | } | |
c585f731 | 2974 | } |
2975 | } | |
2976 | else if (hasGradientMode) | |
2977 | { | |
2978 | if (isDefault) | |
2979 | { | |
2980 | ViewerTest_DefaultBackground.FillMethod = aGradientMode; | |
2981 | ViewerTest_DefaultBackground.SetDefaultGradient(); | |
2982 | } | |
2983 | else | |
2984 | { | |
2985 | aView->SetBgGradientStyle (aGradientMode); | |
2986 | } | |
2987 | } | |
7fd59977 | 2988 | |
c585f731 | 2989 | if (!anImagePath.IsEmpty()) |
7fd59977 | 2990 | { |
c585f731 | 2991 | Handle(Graphic3d_Texture2D) aTextureMap = new Graphic3d_Texture2Dmanual (anImagePath); |
2992 | aTextureMap->DisableModulate(); | |
2993 | aTextureMap->SetColorMap (isSRgb); | |
2994 | if (!aTextureMap->IsDone()) | |
7fd59977 | 2995 | { |
c585f731 | 2996 | theDI << "Syntax error at '" << anImagePath << "'"; |
2997 | return 1; | |
2998 | } | |
2999 | aView->SetBackgroundImage (aTextureMap, anImageMode); | |
3000 | } | |
3001 | else if (hasImageMode) | |
3002 | { | |
3003 | aView->SetBgImageStyle (anImageMode); | |
3004 | } | |
3005 | ||
3006 | if (!aCubeMapSeq.IsEmpty()) | |
3007 | { | |
3008 | Handle(Graphic3d_CubeMap) aCubeMap; | |
3009 | if (aCubeMapSeq.Size() == 1) | |
3010 | { | |
3011 | aCubeMap = new Graphic3d_CubeMapPacked (aCubeMapSeq.First(), aCubeOrder.Validated()); | |
7fd59977 | 3012 | } |
c585f731 | 3013 | else |
f8b2ed36 | 3014 | { |
c585f731 | 3015 | NCollection_Array1<TCollection_AsciiString> aCubeMapArr (0, 5); |
3016 | Standard_Integer aCubeSide = 0; | |
3017 | for (NCollection_Sequence<TCollection_AsciiString>::Iterator aFileIter (aCubeMapSeq); aFileIter.More(); aFileIter.Next(), ++aCubeSide) | |
3018 | { | |
3019 | aCubeMapArr[aCubeSide] = aFileIter.Value(); | |
3020 | } | |
3021 | aCubeMap = new Graphic3d_CubeMapSeparate (aCubeMapArr); | |
f8b2ed36 | 3022 | } |
c585f731 | 3023 | |
3024 | aCubeMap->SetZInversion (isCubeZInverted); | |
3025 | aCubeMap->SetColorMap (isSRgb); | |
3026 | ||
3027 | aCubeMap->GetParams()->SetFilter (Graphic3d_TOTF_BILINEAR); | |
3028 | aCubeMap->GetParams()->SetRepeat (false); | |
3029 | aCubeMap->GetParams()->SetTextureUnit (Graphic3d_TextureUnit_EnvMap); | |
3030 | ||
3e9cb806 | 3031 | aView->SetBackgroundCubeMap (aCubeMap, toUseIBL != -1); |
3032 | } | |
3033 | if (toUseIBL != -1 | |
3034 | && !aView.IsNull()) | |
3035 | { | |
3036 | aView->SetImageBasedLighting (toUseIBL == 1); | |
f8b2ed36 | 3037 | } |
3038 | ||
c585f731 | 3039 | return 0; |
3040 | } | |
f42753ed | 3041 | |
7fd59977 | 3042 | //============================================================================== |
3043 | //function : VScale | |
3044 | //purpose : View Scaling | |
3045 | //============================================================================== | |
3046 | ||
3047 | static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
3048 | { | |
3049 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
3050 | if ( V3dView.IsNull() ) return 1; | |
3051 | ||
3052 | if ( argc != 4 ) { | |
586db386 | 3053 | di << argv[0] << "Invalid number of arguments\n"; |
7fd59977 | 3054 | return 1; |
3055 | } | |
91322f44 | 3056 | V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) ); |
7fd59977 | 3057 | return 0; |
3058 | } | |
3059 | //============================================================================== | |
536d98e2 | 3060 | //function : VZBuffTrihedron |
3061 | //purpose : | |
7fd59977 | 3062 | //============================================================================== |
3063 | ||
536d98e2 | 3064 | static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/, |
3065 | Standard_Integer theArgNb, | |
3066 | const char** theArgVec) | |
7fd59977 | 3067 | { |
536d98e2 | 3068 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
3069 | if (aView.IsNull()) | |
3070 | { | |
23fe70ec | 3071 | Message::SendFail ("Error: no active viewer"); |
536d98e2 | 3072 | return 1; |
3073 | } | |
7fd59977 | 3074 | |
536d98e2 | 3075 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
7c8a8fcc | 3076 | |
536d98e2 | 3077 | Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER; |
3078 | V3d_TypeOfVisualization aVisType = V3d_ZBUFFER; | |
0aeb8984 | 3079 | Quantity_Color aLabelsColorX = Quantity_NOC_WHITE; |
3080 | Quantity_Color aLabelsColorY = Quantity_NOC_WHITE; | |
3081 | Quantity_Color aLabelsColorZ = Quantity_NOC_WHITE; | |
536d98e2 | 3082 | Quantity_Color anArrowColorX = Quantity_NOC_RED; |
3083 | Quantity_Color anArrowColorY = Quantity_NOC_GREEN; | |
3084 | Quantity_Color anArrowColorZ = Quantity_NOC_BLUE1; | |
3085 | Standard_Real aScale = 0.1; | |
3086 | Standard_Real aSizeRatio = 0.8; | |
3087 | Standard_Real anArrowDiam = 0.05; | |
3088 | Standard_Integer aNbFacets = 12; | |
3089 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
7c8a8fcc | 3090 | { |
536d98e2 | 3091 | Standard_CString anArg = theArgVec[anArgIter]; |
3092 | TCollection_AsciiString aFlag (anArg); | |
3093 | aFlag.LowerCase(); | |
3094 | if (anUpdateTool.parseRedrawMode (aFlag)) | |
7c8a8fcc | 3095 | { |
536d98e2 | 3096 | continue; |
3097 | } | |
3098 | else if (aFlag == "-on") | |
7c8a8fcc | 3099 | { |
536d98e2 | 3100 | continue; |
3101 | } | |
3102 | else if (aFlag == "-off") | |
7c8a8fcc | 3103 | { |
536d98e2 | 3104 | aView->TriedronErase(); |
3105 | return 0; | |
3106 | } | |
3107 | else if (aFlag == "-pos" | |
3108 | || aFlag == "-position" | |
3109 | || aFlag == "-corner") | |
7c8a8fcc | 3110 | { |
536d98e2 | 3111 | if (++anArgIter >= theArgNb) |
3112 | { | |
23fe70ec | 3113 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3114 | return 1; |
3115 | } | |
3116 | ||
3117 | TCollection_AsciiString aPosName (theArgVec[anArgIter]); | |
3118 | aPosName.LowerCase(); | |
3119 | if (aPosName == "center") | |
3120 | { | |
3121 | aPosition = Aspect_TOTP_CENTER; | |
3122 | } | |
3123 | else if (aPosName == "left_lower" | |
3124 | || aPosName == "lower_left" | |
3125 | || aPosName == "leftlower" | |
3126 | || aPosName == "lowerleft") | |
3127 | { | |
3128 | aPosition = Aspect_TOTP_LEFT_LOWER; | |
3129 | } | |
3130 | else if (aPosName == "left_upper" | |
3131 | || aPosName == "upper_left" | |
3132 | || aPosName == "leftupper" | |
3133 | || aPosName == "upperleft") | |
3134 | { | |
3135 | aPosition = Aspect_TOTP_LEFT_UPPER; | |
3136 | } | |
3137 | else if (aPosName == "right_lower" | |
3138 | || aPosName == "lower_right" | |
3139 | || aPosName == "rightlower" | |
3140 | || aPosName == "lowerright") | |
3141 | { | |
3142 | aPosition = Aspect_TOTP_RIGHT_LOWER; | |
3143 | } | |
3144 | else if (aPosName == "right_upper" | |
3145 | || aPosName == "upper_right" | |
3146 | || aPosName == "rightupper" | |
3147 | || aPosName == "upperright") | |
3148 | { | |
3149 | aPosition = Aspect_TOTP_RIGHT_UPPER; | |
3150 | } | |
3151 | else | |
3152 | { | |
23fe70ec | 3153 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "' - unknown position '" << aPosName << "'"; |
536d98e2 | 3154 | return 1; |
3155 | } | |
3156 | } | |
3157 | else if (aFlag == "-type") | |
7c8a8fcc | 3158 | { |
536d98e2 | 3159 | if (++anArgIter >= theArgNb) |
3160 | { | |
23fe70ec | 3161 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3162 | return 1; |
3163 | } | |
3164 | ||
3165 | TCollection_AsciiString aTypeName (theArgVec[anArgIter]); | |
3166 | aTypeName.LowerCase(); | |
3167 | if (aTypeName == "wireframe" | |
3168 | || aTypeName == "wire") | |
3169 | { | |
3170 | aVisType = V3d_WIREFRAME; | |
3171 | } | |
3172 | else if (aTypeName == "zbuffer" | |
3173 | || aTypeName == "shaded") | |
3174 | { | |
3175 | aVisType = V3d_ZBUFFER; | |
3176 | } | |
3177 | else | |
3178 | { | |
23fe70ec | 3179 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "' - unknown type '" << aTypeName << "'"; |
536d98e2 | 3180 | } |
3181 | } | |
3182 | else if (aFlag == "-scale") | |
7c8a8fcc | 3183 | { |
536d98e2 | 3184 | if (++anArgIter >= theArgNb) |
3185 | { | |
23fe70ec | 3186 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3187 | return 1; |
3188 | } | |
3189 | ||
3190 | aScale = Draw::Atof (theArgVec[anArgIter]); | |
7c8a8fcc | 3191 | } |
536d98e2 | 3192 | else if (aFlag == "-size" |
3193 | || aFlag == "-sizeratio") | |
3194 | { | |
3195 | if (++anArgIter >= theArgNb) | |
3196 | { | |
23fe70ec | 3197 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3198 | return 1; |
3199 | } | |
7c8a8fcc | 3200 | |
536d98e2 | 3201 | aSizeRatio = Draw::Atof (theArgVec[anArgIter]); |
3202 | } | |
3203 | else if (aFlag == "-arrowdiam" | |
3204 | || aFlag == "-arrowdiameter") | |
3205 | { | |
3206 | if (++anArgIter >= theArgNb) | |
3207 | { | |
23fe70ec | 3208 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3209 | return 1; |
3210 | } | |
7c8a8fcc | 3211 | |
536d98e2 | 3212 | anArrowDiam = Draw::Atof (theArgVec[anArgIter]); |
3213 | } | |
3214 | else if (aFlag == "-nbfacets") | |
3215 | { | |
3216 | if (++anArgIter >= theArgNb) | |
3217 | { | |
23fe70ec | 3218 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3219 | return 1; |
3220 | } | |
7c8a8fcc | 3221 | |
536d98e2 | 3222 | aNbFacets = Draw::Atoi (theArgVec[anArgIter]); |
3223 | } | |
3224 | else if (aFlag == "-colorlabel" | |
0aeb8984 | 3225 | || aFlag == "-colorlabels" |
3226 | || aFlag == "-colorlabelx" | |
3227 | || aFlag == "-colorlabely" | |
3228 | || aFlag == "-colorlabelz" | |
3229 | || aFlag == "-colorarrowx" | |
3230 | || aFlag == "-colorarrowy" | |
3231 | || aFlag == "-colorarrowz") | |
7c8a8fcc | 3232 | { |
0aeb8984 | 3233 | Quantity_Color aColor; |
dae2a922 | 3234 | Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1, |
3235 | theArgVec + anArgIter + 1, | |
0aeb8984 | 3236 | aColor); |
536d98e2 | 3237 | if (aNbParsed == 0) |
3238 | { | |
23fe70ec | 3239 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
536d98e2 | 3240 | return 1; |
3241 | } | |
0aeb8984 | 3242 | |
3243 | if (aFlag == "-colorarrowx") | |
536d98e2 | 3244 | { |
0aeb8984 | 3245 | anArrowColorX = aColor; |
536d98e2 | 3246 | } |
0aeb8984 | 3247 | else if (aFlag == "-colorarrowy") |
536d98e2 | 3248 | { |
0aeb8984 | 3249 | anArrowColorY = aColor; |
536d98e2 | 3250 | } |
0aeb8984 | 3251 | else if (aFlag == "-colorarrowz") |
536d98e2 | 3252 | { |
0aeb8984 | 3253 | anArrowColorZ = aColor; |
3254 | } | |
3255 | else if (aFlag == "-colorlabelx") | |
3256 | { | |
3257 | aLabelsColorX = aColor; | |
3258 | } | |
3259 | else if (aFlag == "-colorlabely") | |
3260 | { | |
3261 | aLabelsColorY = aColor; | |
3262 | } | |
3263 | else if (aFlag == "-colorlabelz") | |
3264 | { | |
3265 | aLabelsColorZ = aColor; | |
3266 | } | |
3267 | else | |
3268 | { | |
3269 | aLabelsColorZ = aLabelsColorY = aLabelsColorX = aColor; | |
536d98e2 | 3270 | } |
3271 | anArgIter += aNbParsed; | |
3272 | } | |
3273 | else | |
3274 | { | |
23fe70ec | 3275 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
7c8a8fcc | 3276 | return 1; |
3277 | } | |
7c8a8fcc | 3278 | } |
3279 | ||
0aeb8984 | 3280 | const Handle(V3d_Trihedron)& aTrihedron = aView->Trihedron(); |
3281 | aTrihedron->SetArrowsColor (anArrowColorX, anArrowColorY, anArrowColorZ); | |
3282 | aTrihedron->SetLabelsColor (aLabelsColorX, aLabelsColorY, aLabelsColorZ); | |
3283 | aTrihedron->SetSizeRatio (aSizeRatio); | |
3284 | aTrihedron->SetNbFacets (aNbFacets); | |
3285 | aTrihedron->SetArrowDiameter(anArrowDiam); | |
3286 | aTrihedron->SetScale (aScale); | |
3287 | aTrihedron->SetPosition (aPosition); | |
3288 | aTrihedron->SetWireframe (aVisType == V3d_WIREFRAME); | |
3289 | aTrihedron->Display (aView); | |
3290 | ||
c357e426 | 3291 | aView->ZFitAll(); |
7fd59977 | 3292 | return 0; |
3293 | } | |
3294 | ||
3295 | //============================================================================== | |
3296 | //function : VRotate | |
3297 | //purpose : Camera Rotating | |
3298 | //============================================================================== | |
3299 | ||
4af098ba | 3300 | static int VRotate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec) |
3301 | { | |
3302 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
3303 | if (aView.IsNull()) | |
3304 | { | |
23fe70ec | 3305 | Message::SendFail ("Error: no active viewer"); |
7fd59977 | 3306 | return 1; |
3307 | } | |
3308 | ||
4af098ba | 3309 | Standard_Boolean hasFlags = Standard_False; |
3310 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
3311 | { | |
3312 | Standard_CString anArg (theArgVec[anArgIter]); | |
3313 | TCollection_AsciiString aFlag (anArg); | |
3314 | aFlag.LowerCase(); | |
3315 | if (aFlag == "-mousestart" | |
3316 | || aFlag == "-mousefrom") | |
3317 | { | |
3318 | hasFlags = Standard_True; | |
3319 | if (anArgIter + 2 >= theArgNb) | |
3320 | { | |
23fe70ec | 3321 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
4af098ba | 3322 | return 1; |
3323 | } | |
3324 | ||
3325 | Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]); | |
3326 | Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]); | |
3327 | aView->StartRotation (anX, anY); | |
3328 | } | |
3329 | else if (aFlag == "-mousemove") | |
3330 | { | |
3331 | hasFlags = Standard_True; | |
3332 | if (anArgIter + 2 >= theArgNb) | |
3333 | { | |
23fe70ec | 3334 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
4af098ba | 3335 | return 1; |
3336 | } | |
3337 | ||
3338 | Standard_Integer anX = Draw::Atoi (theArgVec[++anArgIter]); | |
3339 | Standard_Integer anY = Draw::Atoi (theArgVec[++anArgIter]); | |
3340 | aView->Rotation (anX, anY); | |
3341 | } | |
3342 | else if (theArgNb != 4 | |
3343 | && theArgNb != 7) | |
3344 | { | |
23fe70ec | 3345 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
4af098ba | 3346 | return 1; |
3347 | } | |
3348 | } | |
3349 | ||
3350 | if (hasFlags) | |
3351 | { | |
7fd59977 | 3352 | return 0; |
4af098ba | 3353 | } |
3354 | else if (theArgNb == 4) | |
3355 | { | |
3356 | Standard_Real anAX = Draw::Atof (theArgVec[1]); | |
3357 | Standard_Real anAY = Draw::Atof (theArgVec[2]); | |
3358 | Standard_Real anAZ = Draw::Atof (theArgVec[3]); | |
3359 | aView->Rotate (anAX, anAY, anAZ); | |
3360 | return 0; | |
3361 | } | |
3362 | else if (theArgNb == 7) | |
3363 | { | |
3364 | Standard_Real anAX = Draw::Atof (theArgVec[1]); | |
3365 | Standard_Real anAY = Draw::Atof (theArgVec[2]); | |
3366 | Standard_Real anAZ = Draw::Atof (theArgVec[3]); | |
3367 | ||
3368 | Standard_Real anX = Draw::Atof (theArgVec[4]); | |
3369 | Standard_Real anY = Draw::Atof (theArgVec[5]); | |
3370 | Standard_Real anZ = Draw::Atof (theArgVec[6]); | |
3371 | ||
3372 | aView->Rotate (anAX, anAY, anAZ, anX, anY, anZ); | |
7fd59977 | 3373 | return 0; |
7fd59977 | 3374 | } |
4af098ba | 3375 | |
23fe70ec | 3376 | Message::SendFail ("Error: Invalid number of arguments"); |
4af098ba | 3377 | return 1; |
7fd59977 | 3378 | } |
3379 | ||
3380 | //============================================================================== | |
3381 | //function : VZoom | |
3382 | //purpose : View zoom in / out (relative to current zoom) | |
3383 | //============================================================================== | |
3384 | ||
3385 | static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
3386 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
3387 | if ( V3dView.IsNull() ) { | |
3388 | return 1; | |
3389 | } | |
3390 | ||
3391 | if ( argc == 2 ) { | |
91322f44 | 3392 | Standard_Real coef = Draw::Atof(argv[1]); |
7fd59977 | 3393 | if ( coef <= 0.0 ) { |
586db386 | 3394 | di << argv[1] << "Invalid value\n"; |
7fd59977 | 3395 | return 1; |
3396 | } | |
91322f44 | 3397 | V3dView->SetZoom( Draw::Atof(argv[1]) ); |
7fd59977 | 3398 | return 0; |
3399 | } else { | |
586db386 | 3400 | di << argv[0] << " Invalid number of arguments\n"; |
7fd59977 | 3401 | return 1; |
3402 | } | |
3403 | } | |
3404 | ||
3405 | //============================================================================== | |
3406 | //function : VPan | |
3407 | //purpose : View panning (in pixels) | |
3408 | //============================================================================== | |
3409 | ||
3410 | static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) { | |
3411 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
3412 | if ( V3dView.IsNull() ) return 1; | |
3413 | ||
3414 | if ( argc == 3 ) { | |
91322f44 | 3415 | V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) ); |
7fd59977 | 3416 | return 0; |
3417 | } else { | |
586db386 | 3418 | di << argv[0] << " Invalid number of arguments\n"; |
7fd59977 | 3419 | return 1; |
3420 | } | |
3421 | } | |
3422 | ||
49e1a5c7 | 3423 | //============================================================================== |
3424 | //function : VPlace | |
3425 | //purpose : Place the point (in pixels) at the center of the window | |
3426 | //============================================================================== | |
3427 | static int VPlace (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgs) | |
3428 | { | |
3429 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
3430 | if (aView.IsNull()) | |
3431 | { | |
23fe70ec | 3432 | Message::SendFail ("Error: no active viewer"); |
49e1a5c7 | 3433 | return 1; |
3434 | } | |
3435 | ||
3436 | if (theArgNb != 3) | |
3437 | { | |
23fe70ec | 3438 | Message::SendFail ("Syntax error: wrong number of arguments"); |
49e1a5c7 | 3439 | return 1; |
3440 | } | |
3441 | ||
3442 | aView->Place (Draw::Atoi (theArgs[1]), Draw::Atoi (theArgs[2]), aView->Scale()); | |
3443 | ||
3444 | return 0; | |
3445 | } | |
7fd59977 | 3446 | |
71215351 | 3447 | static int VColorScale (Draw_Interpretor& theDI, |
3448 | Standard_Integer theArgNb, | |
3449 | const char** theArgVec) | |
3450 | { | |
7fd59977 | 3451 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
71215351 | 3452 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
3453 | if (aContext.IsNull()) | |
3454 | { | |
23fe70ec | 3455 | Message::SendFail ("Error: no active viewer"); |
71215351 | 3456 | return 1; |
7fd59977 | 3457 | } |
24a88697 | 3458 | if (theArgNb <= 1) |
3459 | { | |
23fe70ec | 3460 | Message::SendFail() << "Error: wrong syntax at command '" << theArgVec[0] << "'"; |
24a88697 | 3461 | return 1; |
3462 | } | |
7fd59977 | 3463 | |
4b3d6eb1 | 3464 | Handle(AIS_ColorScale) aColorScale; |
7a324550 | 3465 | if (GetMapOfAIS().IsBound2 (theArgVec[1])) |
71215351 | 3466 | { |
4b3d6eb1 | 3467 | // find existing object |
3468 | aColorScale = Handle(AIS_ColorScale)::DownCast (GetMapOfAIS().Find2 (theArgVec[1])); | |
3469 | if (aColorScale.IsNull()) | |
7a324550 | 3470 | { |
23fe70ec | 3471 | Message::SendFail() << "Error: object '" << theArgVec[1] << "'is already defined and is not a color scale"; |
7a324550 | 3472 | return 1; |
3473 | } | |
3474 | } | |
71215351 | 3475 | |
7a324550 | 3476 | if (theArgNb <= 2) |
3477 | { | |
4b3d6eb1 | 3478 | if (aColorScale.IsNull()) |
3479 | { | |
23fe70ec | 3480 | Message::SendFail() << "Syntax error: colorscale with a given name does not exist"; |
4b3d6eb1 | 3481 | return 1; |
3482 | } | |
3483 | ||
7a324550 | 3484 | theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n" |
4b3d6eb1 | 3485 | << "Min range: " << aColorScale->GetMin() << "\n" |
3486 | << "Max range: " << aColorScale->GetMax() << "\n" | |
3487 | << "Number of intervals: " << aColorScale->GetNumberOfIntervals() << "\n" | |
3488 | << "Text height: " << aColorScale->GetTextHeight() << "\n" | |
3489 | << "Color scale position: " << aColorScale->GetXPosition() << " " << aColorScale->GetYPosition() << "\n" | |
3490 | << "Color scale title: " << aColorScale->GetTitle() << "\n" | |
71215351 | 3491 | << "Label position: "; |
4b3d6eb1 | 3492 | switch (aColorScale->GetLabelPosition()) |
71215351 | 3493 | { |
3494 | case Aspect_TOCSP_NONE: | |
3495 | theDI << "None\n"; | |
3496 | break; | |
3497 | case Aspect_TOCSP_LEFT: | |
3498 | theDI << "Left\n"; | |
3499 | break; | |
3500 | case Aspect_TOCSP_RIGHT: | |
3501 | theDI << "Right\n"; | |
3502 | break; | |
3503 | case Aspect_TOCSP_CENTER: | |
3504 | theDI << "Center\n"; | |
3505 | break; | |
3506 | } | |
3507 | return 0; | |
3508 | } | |
71215351 | 3509 | |
4b3d6eb1 | 3510 | if (aColorScale.IsNull()) |
3511 | { | |
3512 | aColorScale = new AIS_ColorScale(); | |
3513 | aColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD); | |
3514 | aContext->SetTransformPersistence (aColorScale, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER)); | |
3515 | } | |
3516 | ||
3517 | ViewerTest_AutoUpdater anUpdateTool (aContext, aView); | |
7a324550 | 3518 | for (Standard_Integer anArgIter = 2; anArgIter < theArgNb; ++anArgIter) |
71215351 | 3519 | { |
3520 | Standard_CString anArg = theArgVec[anArgIter]; | |
3521 | TCollection_AsciiString aFlag (anArg); | |
3522 | aFlag.LowerCase(); | |
3523 | if (anUpdateTool.parseRedrawMode (aFlag)) | |
3524 | { | |
3525 | continue; | |
3526 | } | |
3527 | else if (aFlag == "-range") | |
3528 | { | |
3529 | if (anArgIter + 3 >= theArgNb) | |
3530 | { | |
23fe70ec | 3531 | Message::SendFail() << "Error: wrong syntax at argument '" << anArg << "'"; |
71215351 | 3532 | return 1; |
3533 | } | |
3534 | ||
4b3d6eb1 | 3535 | const TCollection_AsciiString aRangeMin (theArgVec[++anArgIter]); |
3536 | const TCollection_AsciiString aRangeMax (theArgVec[++anArgIter]); | |
3537 | const TCollection_AsciiString aNbIntervals (theArgVec[++anArgIter]); | |
d45edf24 | 3538 | if (!aRangeMin.IsRealValue (Standard_True) |
3539 | || !aRangeMax.IsRealValue (Standard_True)) | |
71215351 | 3540 | { |
23fe70ec | 3541 | Message::SendFail ("Syntax error: the range values should be real"); |
71215351 | 3542 | return 1; |
3543 | } | |
4b3d6eb1 | 3544 | else if (!aNbIntervals.IsIntegerValue()) |
71215351 | 3545 | { |
23fe70ec | 3546 | Message::SendFail ("Syntax error: the number of intervals should be integer"); |
71215351 | 3547 | return 1; |
3548 | } | |
3549 | ||
4b3d6eb1 | 3550 | aColorScale->SetRange (aRangeMin.RealValue(), aRangeMax.RealValue()); |
3551 | aColorScale->SetNumberOfIntervals (aNbIntervals.IntegerValue()); | |
71215351 | 3552 | } |
3553 | else if (aFlag == "-font") | |
3554 | { | |
3555 | if (anArgIter + 1 >= theArgNb) | |
3556 | { | |
23fe70ec | 3557 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
71215351 | 3558 | return 1; |
3559 | } | |
51740958 | 3560 | TCollection_AsciiString aFontArg(theArgVec[anArgIter + 1]); |
3561 | if (!aFontArg.IsIntegerValue()) | |
71215351 | 3562 | { |
23fe70ec | 3563 | Message::SendFail ("Syntax error: HeightFont value should be integer"); |
71215351 | 3564 | return 1; |
3565 | } | |
3566 | ||
4b3d6eb1 | 3567 | aColorScale->SetTextHeight (aFontArg.IntegerValue()); |
71215351 | 3568 | anArgIter += 1; |
3569 | } | |
3570 | else if (aFlag == "-textpos") | |
3571 | { | |
3572 | if (anArgIter + 1 >= theArgNb) | |
3573 | { | |
23fe70ec | 3574 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
71215351 | 3575 | return 1; |
3576 | } | |
4b3d6eb1 | 3577 | |
51740958 | 3578 | TCollection_AsciiString aTextPosArg(theArgVec[++anArgIter]); |
3579 | aTextPosArg.LowerCase(); | |
4b3d6eb1 | 3580 | Aspect_TypeOfColorScalePosition aLabPosition = Aspect_TOCSP_NONE; |
51740958 | 3581 | if (aTextPosArg == "none") |
71215351 | 3582 | { |
3583 | aLabPosition = Aspect_TOCSP_NONE; | |
3584 | } | |
51740958 | 3585 | else if (aTextPosArg == "left") |
71215351 | 3586 | { |
3587 | aLabPosition = Aspect_TOCSP_LEFT; | |
3588 | } | |
51740958 | 3589 | else if (aTextPosArg == "right") |
71215351 | 3590 | { |
3591 | aLabPosition = Aspect_TOCSP_RIGHT; | |
3592 | } | |
51740958 | 3593 | else if (aTextPosArg == "center") |
71215351 | 3594 | { |
3595 | aLabPosition = Aspect_TOCSP_CENTER; | |
3596 | } | |
3597 | else | |
3598 | { | |
23fe70ec | 3599 | Message::SendFail() << "Syntax error: unknown position '" << aTextPosArg << "'"; |
71215351 | 3600 | return 1; |
3601 | } | |
4b3d6eb1 | 3602 | aColorScale->SetLabelPosition (aLabPosition); |
71215351 | 3603 | } |
24a88697 | 3604 | else if (aFlag == "-logarithmic" |
3605 | || aFlag == "-log") | |
3606 | { | |
3607 | if (anArgIter + 1 >= theArgNb) | |
3608 | { | |
23fe70ec | 3609 | Message::SendFail() << "Synta error at argument '" << anArg << "'"; |
24a88697 | 3610 | return 1; |
3611 | } | |
4b3d6eb1 | 3612 | |
24a88697 | 3613 | Standard_Boolean IsLog; |
dae2a922 | 3614 | if (!Draw::ParseOnOff(theArgVec[++anArgIter], IsLog)) |
24a88697 | 3615 | { |
23fe70ec | 3616 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
24a88697 | 3617 | return 1; |
3618 | } | |
4b3d6eb1 | 3619 | aColorScale->SetLogarithmic (IsLog); |
3620 | } | |
3621 | else if (aFlag == "-huerange" | |
3622 | || aFlag == "-hue") | |
3623 | { | |
3624 | if (anArgIter + 2 >= theArgNb) | |
3625 | { | |
23fe70ec | 3626 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
4b3d6eb1 | 3627 | return 1; |
3628 | } | |
3629 | ||
3630 | const Standard_Real aHueMin = Draw::Atof (theArgVec[++anArgIter]); | |
3631 | const Standard_Real aHueMax = Draw::Atof (theArgVec[++anArgIter]); | |
3632 | aColorScale->SetHueRange (aHueMin, aHueMax); | |
3633 | } | |
3634 | else if (aFlag == "-colorrange") | |
3635 | { | |
3636 | Quantity_Color aColorMin, aColorMax; | |
dae2a922 | 3637 | Standard_Integer aNbParsed1 = Draw::ParseColor (theArgNb - (anArgIter + 1), |
3638 | theArgVec + (anArgIter + 1), | |
3639 | aColorMin); | |
4b3d6eb1 | 3640 | anArgIter += aNbParsed1; |
dae2a922 | 3641 | Standard_Integer aNbParsed2 = Draw::ParseColor (theArgNb - (anArgIter + 1), |
3642 | theArgVec + (anArgIter + 1), | |
3643 | aColorMax); | |
4b3d6eb1 | 3644 | anArgIter += aNbParsed2; |
3645 | if (aNbParsed1 == 0 | |
3646 | || aNbParsed2 == 0) | |
3647 | { | |
23fe70ec | 3648 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
4b3d6eb1 | 3649 | return 1; |
3650 | } | |
3651 | ||
3652 | aColorScale->SetColorRange (aColorMin, aColorMax); | |
3653 | } | |
3654 | else if (aFlag == "-reversed" | |
3655 | || aFlag == "-inverted" | |
3656 | || aFlag == "-topdown" | |
3657 | || aFlag == "-bottomup") | |
3658 | { | |
3659 | Standard_Boolean toEnable = Standard_True; | |
3660 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 3661 | && Draw::ParseOnOff(theArgVec[anArgIter + 1], toEnable)) |
4b3d6eb1 | 3662 | { |
3663 | ++anArgIter; | |
3664 | } | |
3665 | aColorScale->SetReversed ((aFlag == "-topdown") ? !toEnable : toEnable); | |
3666 | } | |
3667 | else if (aFlag == "-smooth" | |
3668 | || aFlag == "-smoothtransition") | |
3669 | { | |
3670 | Standard_Boolean toEnable = Standard_True; | |
3671 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 3672 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
4b3d6eb1 | 3673 | { |
3674 | ++anArgIter; | |
3675 | } | |
3676 | aColorScale->SetSmoothTransition (toEnable); | |
24a88697 | 3677 | } |
71215351 | 3678 | else if (aFlag == "-xy") |
3679 | { | |
3680 | if (anArgIter + 2 >= theArgNb) | |
3681 | { | |
23fe70ec | 3682 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
71215351 | 3683 | return 1; |
3684 | } | |
3685 | ||
4b3d6eb1 | 3686 | const TCollection_AsciiString anX (theArgVec[++anArgIter]); |
3687 | const TCollection_AsciiString anY (theArgVec[++anArgIter]); | |
3688 | if (!anX.IsIntegerValue() | |
3689 | || !anY.IsIntegerValue()) | |
71215351 | 3690 | { |
23fe70ec | 3691 | Message::SendFail ("Syntax error: coordinates should be integer values"); |
71215351 | 3692 | return 1; |
3693 | } | |
3694 | ||
4b3d6eb1 | 3695 | aColorScale->SetPosition (anX.IntegerValue(), anY.IntegerValue()); |
b4b2ecca | 3696 | } |
3697 | else if (aFlag == "-width" | |
4b3d6eb1 | 3698 | || aFlag == "-w" |
3699 | || aFlag == "-breadth") | |
b4b2ecca | 3700 | { |
3701 | if (anArgIter + 1 >= theArgNb) | |
3702 | { | |
23fe70ec | 3703 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
b4b2ecca | 3704 | return 1; |
3705 | } | |
3706 | ||
4b3d6eb1 | 3707 | const TCollection_AsciiString aBreadth (theArgVec[++anArgIter]); |
3708 | if (!aBreadth.IsIntegerValue()) | |
b4b2ecca | 3709 | { |
23fe70ec | 3710 | Message::SendFail ("Syntax error: a width should be an integer value"); |
b4b2ecca | 3711 | return 1; |
3712 | } | |
4b3d6eb1 | 3713 | aColorScale->SetBreadth (aBreadth.IntegerValue()); |
b4b2ecca | 3714 | } |
3715 | else if (aFlag == "-height" | |
3716 | || aFlag == "-h") | |
3717 | { | |
3718 | if (anArgIter + 1 >= theArgNb) | |
3719 | { | |
23fe70ec | 3720 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
b4b2ecca | 3721 | return 1; |
3722 | } | |
3723 | ||
4b3d6eb1 | 3724 | const TCollection_AsciiString aHeight (theArgVec[++anArgIter]); |
3725 | if (!aHeight.IsIntegerValue()) | |
b4b2ecca | 3726 | { |
23fe70ec | 3727 | Message::SendFail ("Syntax error: a width should be an integer value"); |
b4b2ecca | 3728 | return 1; |
3729 | } | |
4b3d6eb1 | 3730 | aColorScale->SetHeight (aHeight.IntegerValue()); |
71215351 | 3731 | } |
3732 | else if (aFlag == "-color") | |
3733 | { | |
4b3d6eb1 | 3734 | if (aColorScale->GetColorType() != Aspect_TOCSD_USER) |
71215351 | 3735 | { |
23fe70ec | 3736 | Message::SendFail ("Syntax error: wrong color type. Call -colors before to set user-specified colors"); |
71215351 | 3737 | return 1; |
3738 | } | |
4b3d6eb1 | 3739 | else if (anArgIter + 2 >= theArgNb) |
71215351 | 3740 | { |
23fe70ec | 3741 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
4b3d6eb1 | 3742 | return 1; |
71215351 | 3743 | } |
3744 | ||
4b3d6eb1 | 3745 | const TCollection_AsciiString anInd (theArgVec[++anArgIter]); |
71215351 | 3746 | if (!anInd.IsIntegerValue()) |
3747 | { | |
23fe70ec | 3748 | Message::SendFail ("Syntax error: Index value should be integer"); |
71215351 | 3749 | return 1; |
3750 | } | |
4b3d6eb1 | 3751 | const Standard_Integer anIndex = anInd.IntegerValue(); |
3752 | if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals()) | |
71215351 | 3753 | { |
23fe70ec | 3754 | Message::SendFail() << "Syntax error: Index value should be within range 1.." << aColorScale->GetNumberOfIntervals(); |
71215351 | 3755 | return 1; |
3756 | } | |
3757 | ||
4b3d6eb1 | 3758 | Quantity_Color aColor; |
dae2a922 | 3759 | Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - (anArgIter + 1), |
3760 | theArgVec + (anArgIter + 1), | |
3761 | aColor); | |
4b3d6eb1 | 3762 | if (aNbParsed == 0) |
71215351 | 3763 | { |
23fe70ec | 3764 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
71215351 | 3765 | return 1; |
3766 | } | |
4b3d6eb1 | 3767 | aColorScale->SetIntervalColor (aColor, anIndex); |
3768 | aColorScale->SetColorType (Aspect_TOCSD_USER); | |
3769 | anArgIter += aNbParsed; | |
71215351 | 3770 | } |
3771 | else if (aFlag == "-label") | |
3772 | { | |
4b3d6eb1 | 3773 | if (aColorScale->GetColorType() != Aspect_TOCSD_USER) |
71215351 | 3774 | { |
23fe70ec | 3775 | Message::SendFail ("Syntax error: wrong label type. Call -labels before to set user-specified labels"); |
71215351 | 3776 | return 1; |
3777 | } | |
3778 | else if (anArgIter + 2 >= theArgNb) | |
3779 | { | |
23fe70ec | 3780 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
71215351 | 3781 | return 1; |
3782 | } | |
3783 | ||
3784 | Standard_Integer anIndex = Draw::Atoi (theArgVec[anArgIter + 1]); | |
4b3d6eb1 | 3785 | if (anIndex <= 0 || anIndex > aColorScale->GetNumberOfIntervals() + 1) |
71215351 | 3786 | { |
23fe70ec | 3787 | Message::SendFail() << "Syntax error: Index value should be within range 1.." << (aColorScale->GetNumberOfIntervals() + 1); |
71215351 | 3788 | return 1; |
3789 | } | |
3790 | ||
94f16a89 | 3791 | TCollection_ExtendedString aText (theArgVec[anArgIter + 2], Standard_True); |
4b3d6eb1 | 3792 | aColorScale->SetLabel (aText, anIndex); |
3793 | aColorScale->SetLabelType (Aspect_TOCSD_USER); | |
71215351 | 3794 | anArgIter += 2; |
3795 | } | |
4b3d6eb1 | 3796 | else if (aFlag == "-labelat" |
3797 | || aFlag == "-labat" | |
3798 | || aFlag == "-labelatborder" | |
3799 | || aFlag == "-labatborder" | |
3800 | || aFlag == "-labelatcenter" | |
3801 | || aFlag == "-labatcenter") | |
71215351 | 3802 | { |
4b3d6eb1 | 3803 | Standard_Boolean toEnable = Standard_True; |
3804 | if (aFlag == "-labelat" | |
3805 | || aFlag == "-labat") | |
71215351 | 3806 | { |
4b3d6eb1 | 3807 | Standard_Integer aLabAtBorder = -1; |
3808 | if (++anArgIter >= theArgNb) | |
71215351 | 3809 | { |
4b3d6eb1 | 3810 | TCollection_AsciiString anAtBorder (theArgVec[anArgIter]); |
3811 | anAtBorder.LowerCase(); | |
3812 | if (anAtBorder == "border") | |
71215351 | 3813 | { |
4b3d6eb1 | 3814 | aLabAtBorder = 1; |
71215351 | 3815 | } |
4b3d6eb1 | 3816 | else if (anAtBorder == "center") |
71215351 | 3817 | { |
4b3d6eb1 | 3818 | aLabAtBorder = 0; |
71215351 | 3819 | } |
71215351 | 3820 | } |
4b3d6eb1 | 3821 | if (aLabAtBorder == -1) |
3822 | { | |
23fe70ec | 3823 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
4b3d6eb1 | 3824 | return 1; |
3825 | } | |
3826 | toEnable = (aLabAtBorder == 1); | |
3827 | } | |
3828 | else if (anArgIter + 1 < theArgNb | |
dae2a922 | 3829 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
4b3d6eb1 | 3830 | { |
3831 | ++anArgIter; | |
71215351 | 3832 | } |
4b3d6eb1 | 3833 | aColorScale->SetLabelAtBorder (aFlag == "-labelatcenter" |
3834 | || aFlag == "-labatcenter" | |
3835 | ? !toEnable | |
3836 | : toEnable); | |
3837 | } | |
3838 | else if (aFlag == "-colors") | |
3839 | { | |
3840 | Aspect_SequenceOfColor aSeq; | |
3841 | for (;;) | |
3842 | { | |
3843 | Quantity_Color aColor; | |
dae2a922 | 3844 | Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - (anArgIter + 1), |
3845 | theArgVec + (anArgIter + 1), | |
3846 | aColor); | |
4b3d6eb1 | 3847 | if (aNbParsed == 0) |
3848 | { | |
3849 | break; | |
3850 | } | |
3851 | anArgIter += aNbParsed; | |
3852 | aSeq.Append (aColor); | |
3853 | } | |
3854 | if (aSeq.Length() != aColorScale->GetNumberOfIntervals()) | |
71215351 | 3855 | { |
23fe70ec | 3856 | Message::SendFail() << "Error: not enough arguments! You should provide color names or RGB color values for every interval of the " |
3857 | << aColorScale->GetNumberOfIntervals() << " intervals"; | |
71215351 | 3858 | return 1; |
3859 | } | |
3860 | ||
4b3d6eb1 | 3861 | aColorScale->SetColors (aSeq); |
3862 | aColorScale->SetColorType (Aspect_TOCSD_USER); | |
71215351 | 3863 | } |
14b741b0 | 3864 | else if (aFlag == "-uniform") |
3865 | { | |
3866 | const Standard_Real aLightness = Draw::Atof (theArgVec[++anArgIter]); | |
3867 | const Standard_Real aHueStart = Draw::Atof (theArgVec[++anArgIter]); | |
3868 | const Standard_Real aHueEnd = Draw::Atof (theArgVec[++anArgIter]); | |
3869 | aColorScale->SetUniformColors (aLightness, aHueStart, aHueEnd); | |
3870 | aColorScale->SetColorType (Aspect_TOCSD_USER); | |
3871 | } | |
4b3d6eb1 | 3872 | else if (aFlag == "-labels" |
3873 | || aFlag == "-freelabels") | |
71215351 | 3874 | { |
4b3d6eb1 | 3875 | if (anArgIter + 1 >= theArgNb) |
3876 | { | |
23fe70ec | 3877 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
4b3d6eb1 | 3878 | return 1; |
3879 | } | |
3880 | ||
3881 | Standard_Integer aNbLabels = aColorScale->IsLabelAtBorder() | |
3882 | ? aColorScale->GetNumberOfIntervals() + 1 | |
3883 | : aColorScale->GetNumberOfIntervals(); | |
3884 | if (aFlag == "-freelabels") | |
3885 | { | |
3886 | ++anArgIter; | |
3887 | aNbLabels = Draw::Atoi (theArgVec[anArgIter]); | |
3888 | } | |
3889 | if (anArgIter + aNbLabels >= theArgNb) | |
71215351 | 3890 | { |
23fe70ec | 3891 | Message::SendFail() << "Syntax error: not enough arguments. " << aNbLabels << " text labels are expected"; |
71215351 | 3892 | return 1; |
3893 | } | |
3894 | ||
3895 | TColStd_SequenceOfExtendedString aSeq; | |
4b3d6eb1 | 3896 | for (Standard_Integer aLabelIter = 0; aLabelIter < aNbLabels; ++aLabelIter) |
71215351 | 3897 | { |
94f16a89 | 3898 | aSeq.Append (TCollection_ExtendedString (theArgVec[++anArgIter], Standard_True)); |
71215351 | 3899 | } |
4b3d6eb1 | 3900 | aColorScale->SetLabels (aSeq); |
3901 | aColorScale->SetLabelType (Aspect_TOCSD_USER); | |
71215351 | 3902 | } |
3903 | else if (aFlag == "-title") | |
3904 | { | |
3905 | if (anArgIter + 1 >= theArgNb) | |
3906 | { | |
23fe70ec | 3907 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
71215351 | 3908 | return 1; |
3909 | } | |
3910 | ||
3911 | Standard_Boolean isTwoArgs = Standard_False; | |
3912 | if (anArgIter + 2 < theArgNb) | |
3913 | { | |
3914 | TCollection_AsciiString aSecondArg (theArgVec[anArgIter + 2]); | |
3915 | aSecondArg.LowerCase(); | |
4b3d6eb1 | 3916 | Standard_DISABLE_DEPRECATION_WARNINGS |
71215351 | 3917 | if (aSecondArg == "none") |
3918 | { | |
4b3d6eb1 | 3919 | aColorScale->SetTitlePosition (Aspect_TOCSP_NONE); |
71215351 | 3920 | isTwoArgs = Standard_True; |
3921 | } | |
3922 | else if (aSecondArg == "left") | |
3923 | { | |
4b3d6eb1 | 3924 | aColorScale->SetTitlePosition (Aspect_TOCSP_LEFT); |
71215351 | 3925 | isTwoArgs = Standard_True; |
3926 | } | |
3927 | else if (aSecondArg == "right") | |
3928 | { | |
4b3d6eb1 | 3929 | aColorScale->SetTitlePosition (Aspect_TOCSP_RIGHT); |
71215351 | 3930 | isTwoArgs = Standard_True; |
3931 | } | |
3932 | else if (aSecondArg == "center") | |
3933 | { | |
4b3d6eb1 | 3934 | aColorScale->SetTitlePosition (Aspect_TOCSP_CENTER); |
71215351 | 3935 | isTwoArgs = Standard_True; |
3936 | } | |
4b3d6eb1 | 3937 | Standard_ENABLE_DEPRECATION_WARNINGS |
71215351 | 3938 | } |
3939 | ||
94f16a89 | 3940 | TCollection_ExtendedString aTitle(theArgVec[anArgIter + 1], Standard_True); |
3941 | aColorScale->SetTitle (aTitle); | |
71215351 | 3942 | if (isTwoArgs) |
3943 | { | |
3944 | anArgIter += 1; | |
3945 | } | |
3946 | anArgIter += 1; | |
3947 | } | |
3948 | else if (aFlag == "-demoversion" | |
3949 | || aFlag == "-demo") | |
3950 | { | |
4b3d6eb1 | 3951 | aColorScale->SetPosition (0, 0); |
3952 | aColorScale->SetTextHeight (16); | |
3953 | aColorScale->SetRange (0.0, 100.0); | |
3954 | aColorScale->SetNumberOfIntervals (10); | |
3955 | aColorScale->SetBreadth (0); | |
3956 | aColorScale->SetHeight (0); | |
3957 | aColorScale->SetLabelPosition (Aspect_TOCSP_RIGHT); | |
3958 | aColorScale->SetColorType (Aspect_TOCSD_AUTO); | |
3959 | aColorScale->SetLabelType (Aspect_TOCSD_AUTO); | |
71215351 | 3960 | } |
d5514578 | 3961 | else if (aFlag == "-findcolor") |
3962 | { | |
3963 | if (anArgIter + 1 >= theArgNb) | |
3964 | { | |
23fe70ec | 3965 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
d5514578 | 3966 | return 1; |
3967 | } | |
3968 | ||
3969 | TCollection_AsciiString anArg1 (theArgVec[++anArgIter]); | |
3970 | ||
d45edf24 | 3971 | if (!anArg1.IsRealValue (Standard_True)) |
d5514578 | 3972 | { |
23fe70ec | 3973 | Message::SendFail ("Syntax error: the value should be real"); |
d5514578 | 3974 | return 1; |
3975 | } | |
3976 | ||
3977 | Quantity_Color aColor; | |
4b3d6eb1 | 3978 | aColorScale->FindColor (anArg1.RealValue(), aColor); |
d5514578 | 3979 | theDI << Quantity_Color::StringName (aColor.Name()); |
3980 | return 0; | |
3981 | } | |
71215351 | 3982 | else |
3983 | { | |
23fe70ec | 3984 | Message::SendFail() << "Syntax error at " << anArg << " - unknown argument"; |
71215351 | 3985 | return 1; |
3986 | } | |
3987 | } | |
4b3d6eb1 | 3988 | |
3989 | Standard_Integer aWinWidth = 0, aWinHeight = 0; | |
3990 | aView->Window()->Size (aWinWidth, aWinHeight); | |
3991 | if (aColorScale->GetBreadth() == 0) | |
b4b2ecca | 3992 | { |
4b3d6eb1 | 3993 | aColorScale->SetBreadth (aWinWidth); |
b4b2ecca | 3994 | } |
4b3d6eb1 | 3995 | if (aColorScale->GetHeight() == 0) |
3996 | { | |
3997 | aColorScale->SetHeight (aWinHeight); | |
3998 | } | |
3999 | aColorScale->SetToUpdate(); | |
4000 | ViewerTest::Display (theArgVec[1], aColorScale, Standard_False, Standard_True); | |
7fd59977 | 4001 | return 0; |
4002 | } | |
4003 | ||
4004 | //============================================================================== | |
4005 | //function : VGraduatedTrihedron | |
a79f67f8 | 4006 | //purpose : Displays or hides a graduated trihedron |
7fd59977 | 4007 | //============================================================================== |
a79f67f8 | 4008 | static Standard_Boolean GetColor (const TCollection_AsciiString& theValue, |
4009 | Quantity_Color& theColor) | |
13a22457 | 4010 | { |
a79f67f8 | 4011 | Quantity_NameOfColor aColorName; |
4012 | TCollection_AsciiString aVal = theValue; | |
4013 | aVal.UpperCase(); | |
4014 | if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName)) | |
13a22457 | 4015 | { |
a79f67f8 | 4016 | return Standard_False; |
13a22457 | 4017 | } |
a79f67f8 | 4018 | theColor = Quantity_Color (aColorName); |
4019 | return Standard_True; | |
13a22457 S |
4020 | } |
4021 | ||
a79f67f8 | 4022 | static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs) |
7fd59977 | 4023 | { |
a79f67f8 | 4024 | if (theArgNum < 2) |
13a22457 | 4025 | { |
23fe70ec | 4026 | Message::SendFail() << "Syntax error: wrong number of parameters. Type 'help" |
4027 | << theArgs[0] <<"' for more information"; | |
4028 | return 1; | |
13a22457 | 4029 | } |
7fd59977 | 4030 | |
a79f67f8 | 4031 | NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs; |
4032 | TCollection_AsciiString aParseKey; | |
4033 | for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt) | |
4034 | { | |
4035 | TCollection_AsciiString anArg (theArgs [anArgIt]); | |
4036 | ||
d45edf24 | 4037 | if (anArg.Value (1) == '-' && !anArg.IsRealValue (Standard_True)) |
a79f67f8 | 4038 | { |
4039 | aParseKey = anArg; | |
4040 | aParseKey.Remove (1); | |
4041 | aParseKey.LowerCase(); | |
4042 | aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString); | |
4043 | continue; | |
4044 | } | |
13a22457 | 4045 | |
a79f67f8 | 4046 | if (aParseKey.IsEmpty()) |
4047 | { | |
4048 | continue; | |
4049 | } | |
4050 | ||
4051 | aMapOfArgs(aParseKey)->Append (anArg); | |
4052 | } | |
4053 | ||
4054 | // Check parameters | |
4055 | for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs); | |
4056 | aMapIt.More(); aMapIt.Next()) | |
7fd59977 | 4057 | { |
a79f67f8 | 4058 | const TCollection_AsciiString& aKey = aMapIt.Key(); |
4059 | const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value(); | |
4060 | ||
4061 | // Bool key, without arguments | |
4062 | if ((aKey.IsEqual ("on") || aKey.IsEqual ("off")) | |
4063 | && anArgs->IsEmpty()) | |
4064 | { | |
4065 | continue; | |
4066 | } | |
4067 | ||
4068 | // One argument | |
4069 | if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname")) | |
4070 | && anArgs->Length() == 1) | |
4071 | { | |
4072 | continue; | |
4073 | } | |
4074 | ||
4075 | // On/off arguments | |
4076 | if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname") | |
4077 | || aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks") | |
536d98e2 | 4078 | || aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues") |
4079 | || aKey.IsEqual ("drawgrid") || aKey.IsEqual ("drawaxes")) | |
a79f67f8 | 4080 | && anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off"))) |
4081 | { | |
4082 | continue; | |
4083 | } | |
4084 | ||
4085 | // One string argument | |
4086 | if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor") | |
4087 | || aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor")) | |
d45edf24 | 4088 | && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue (Standard_True)) |
a79f67f8 | 4089 | { |
4090 | continue; | |
4091 | } | |
4092 | ||
4093 | // One integer argument | |
4094 | if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks") | |
4095 | || aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength") | |
4096 | || aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset") | |
4097 | || aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset")) | |
4098 | && anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue()) | |
4099 | { | |
4100 | continue; | |
4101 | } | |
4102 | ||
4103 | // One real argument | |
4104 | if ( aKey.IsEqual ("arrowlength") | |
d45edf24 | 4105 | && anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue (Standard_True))) |
a79f67f8 | 4106 | { |
4107 | continue; | |
4108 | } | |
4109 | ||
4110 | // Two string arguments | |
4111 | if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont")) | |
d45edf24 | 4112 | && anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue (Standard_True)) |
13a22457 | 4113 | { |
a79f67f8 | 4114 | continue; |
13a22457 | 4115 | } |
a79f67f8 | 4116 | |
4117 | TCollection_AsciiString aLowerKey; | |
4118 | aLowerKey = "-"; | |
4119 | aLowerKey += aKey; | |
4120 | aLowerKey.LowerCase(); | |
23fe70ec | 4121 | Message::SendFail() << "Syntax error: " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n" |
4122 | << "Type help for more information"; | |
a79f67f8 | 4123 | return 1; |
7fd59977 | 4124 | } |
4125 | ||
a79f67f8 | 4126 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); |
4127 | if (anAISContext.IsNull()) | |
4128 | { | |
23fe70ec | 4129 | Message::SendFail ("Error: no active viewer"); |
a79f67f8 | 4130 | return 1; |
4131 | } | |
7fd59977 | 4132 | |
a79f67f8 | 4133 | Standard_Boolean toDisplay = Standard_True; |
4134 | Quantity_Color aColor; | |
4135 | Graphic3d_GraduatedTrihedron aTrihedronData; | |
4136 | // Process parameters | |
4137 | Handle(TColStd_HSequenceOfAsciiString) aValues; | |
4138 | if (aMapOfArgs.Find ("off", aValues)) | |
7fd59977 | 4139 | { |
a79f67f8 | 4140 | toDisplay = Standard_False; |
4141 | } | |
13a22457 | 4142 | |
a79f67f8 | 4143 | // AXES NAMES |
4144 | if (aMapOfArgs.Find ("xname", aValues)) | |
4145 | { | |
4146 | aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1)); | |
4147 | } | |
4148 | if (aMapOfArgs.Find ("yname", aValues)) | |
4149 | { | |
4150 | aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1)); | |
4151 | } | |
4152 | if (aMapOfArgs.Find ("zname", aValues)) | |
4153 | { | |
4154 | aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1)); | |
4155 | } | |
4156 | if (aMapOfArgs.Find ("xdrawname", aValues)) | |
4157 | { | |
536d98e2 | 4158 | aTrihedronData.ChangeXAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4159 | } |
4160 | if (aMapOfArgs.Find ("ydrawname", aValues)) | |
4161 | { | |
536d98e2 | 4162 | aTrihedronData.ChangeYAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4163 | } |
4164 | if (aMapOfArgs.Find ("zdrawname", aValues)) | |
4165 | { | |
536d98e2 | 4166 | aTrihedronData.ChangeZAxisAspect().SetDrawName (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4167 | } |
4168 | if (aMapOfArgs.Find ("xnameoffset", aValues)) | |
4169 | { | |
4170 | aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue()); | |
4171 | } | |
4172 | if (aMapOfArgs.Find ("ynameoffset", aValues)) | |
4173 | { | |
4174 | aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue()); | |
4175 | } | |
4176 | if (aMapOfArgs.Find ("znameoffset", aValues)) | |
4177 | { | |
4178 | aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue()); | |
4179 | } | |
13a22457 | 4180 | |
a79f67f8 | 4181 | // COLORS |
4182 | if (aMapOfArgs.Find ("xnamecolor", aValues)) | |
4183 | { | |
4184 | if (!GetColor (aValues->Value(1), aColor)) | |
13a22457 | 4185 | { |
23fe70ec | 4186 | Message::SendFail ("Syntax error: -xnamecolor wrong color name"); |
a79f67f8 | 4187 | return 1; |
13a22457 | 4188 | } |
a79f67f8 | 4189 | aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor); |
4190 | } | |
4191 | if (aMapOfArgs.Find ("ynamecolor", aValues)) | |
4192 | { | |
4193 | if (!GetColor (aValues->Value(1), aColor)) | |
13a22457 | 4194 | { |
23fe70ec | 4195 | Message::SendFail ("Syntax error: -ynamecolor wrong color name"); |
a79f67f8 | 4196 | return 1; |
4197 | } | |
4198 | aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor); | |
4199 | } | |
4200 | if (aMapOfArgs.Find ("znamecolor", aValues)) | |
4201 | { | |
4202 | if (!GetColor (aValues->Value(1), aColor)) | |
4203 | { | |
23fe70ec | 4204 | Message::SendFail ("Syntax error: -znamecolor wrong color name"); |
a79f67f8 | 4205 | return 1; |
4206 | } | |
4207 | aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor); | |
4208 | } | |
4209 | if (aMapOfArgs.Find ("xcolor", aValues)) | |
4210 | { | |
4211 | if (!GetColor (aValues->Value(1), aColor)) | |
4212 | { | |
23fe70ec | 4213 | Message::SendFail ("Syntax error: -xcolor wrong color name"); |
a79f67f8 | 4214 | return 1; |
4215 | } | |
4216 | aTrihedronData.ChangeXAxisAspect().SetColor (aColor); | |
4217 | } | |
4218 | if (aMapOfArgs.Find ("ycolor", aValues)) | |
4219 | { | |
4220 | if (!GetColor (aValues->Value(1), aColor)) | |
4221 | { | |
23fe70ec | 4222 | Message::SendFail ("Syntax error: -ycolor wrong color name"); |
a79f67f8 | 4223 | return 1; |
4224 | } | |
4225 | aTrihedronData.ChangeYAxisAspect().SetColor (aColor); | |
4226 | } | |
4227 | if (aMapOfArgs.Find ("zcolor", aValues)) | |
4228 | { | |
4229 | if (!GetColor (aValues->Value(1), aColor)) | |
4230 | { | |
23fe70ec | 4231 | Message::SendFail ("Syntax error: -zcolor wrong color name"); |
a79f67f8 | 4232 | return 1; |
4233 | } | |
4234 | aTrihedronData.ChangeZAxisAspect().SetColor (aColor); | |
4235 | } | |
4236 | ||
4237 | // TICKMARKS | |
4238 | if (aMapOfArgs.Find ("xticks", aValues)) | |
4239 | { | |
536d98e2 | 4240 | aTrihedronData.ChangeXAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4241 | } |
4242 | if (aMapOfArgs.Find ("yticks", aValues)) | |
4243 | { | |
536d98e2 | 4244 | aTrihedronData.ChangeYAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4245 | } |
4246 | if (aMapOfArgs.Find ("zticks", aValues)) | |
4247 | { | |
536d98e2 | 4248 | aTrihedronData.ChangeZAxisAspect().SetTickmarksNumber (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4249 | } |
4250 | if (aMapOfArgs.Find ("xticklength", aValues)) | |
4251 | { | |
536d98e2 | 4252 | aTrihedronData.ChangeXAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4253 | } |
4254 | if (aMapOfArgs.Find ("yticklength", aValues)) | |
4255 | { | |
536d98e2 | 4256 | aTrihedronData.ChangeYAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4257 | } |
4258 | if (aMapOfArgs.Find ("zticklength", aValues)) | |
4259 | { | |
536d98e2 | 4260 | aTrihedronData.ChangeZAxisAspect().SetTickmarksLength (aValues->Value(1).IntegerValue()); |
a79f67f8 | 4261 | } |
4262 | if (aMapOfArgs.Find ("xdrawticks", aValues)) | |
4263 | { | |
536d98e2 | 4264 | aTrihedronData.ChangeXAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4265 | } |
4266 | if (aMapOfArgs.Find ("ydrawticks", aValues)) | |
4267 | { | |
536d98e2 | 4268 | aTrihedronData.ChangeYAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4269 | } |
4270 | if (aMapOfArgs.Find ("zdrawticks", aValues)) | |
4271 | { | |
536d98e2 | 4272 | aTrihedronData.ChangeZAxisAspect().SetDrawTickmarks (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4273 | } |
4274 | ||
4275 | // VALUES | |
4276 | if (aMapOfArgs.Find ("xdrawvalues", aValues)) | |
4277 | { | |
536d98e2 | 4278 | aTrihedronData.ChangeXAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4279 | } |
4280 | if (aMapOfArgs.Find ("ydrawvalues", aValues)) | |
4281 | { | |
536d98e2 | 4282 | aTrihedronData.ChangeYAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4283 | } |
4284 | if (aMapOfArgs.Find ("zdrawvalues", aValues)) | |
4285 | { | |
536d98e2 | 4286 | aTrihedronData.ChangeZAxisAspect().SetDrawValues (aValues->Value(1).IsEqual ("on")); |
a79f67f8 | 4287 | } |
4288 | if (aMapOfArgs.Find ("xvaluesoffset", aValues)) | |
4289 | { | |
4290 | aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue()); | |
4291 | } | |
4292 | if (aMapOfArgs.Find ("yvaluesoffset", aValues)) | |
4293 | { | |
4294 | aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue()); | |
4295 | } | |
4296 | if (aMapOfArgs.Find ("zvaluesoffset", aValues)) | |
4297 | { | |
4298 | aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue()); | |
4299 | } | |
4300 | ||
4301 | // ARROWS | |
4302 | if (aMapOfArgs.Find ("arrowlength", aValues)) | |
4303 | { | |
536d98e2 | 4304 | aTrihedronData.SetArrowsLength ((Standard_ShortReal) aValues->Value(1).RealValue()); |
a79f67f8 | 4305 | } |
4306 | ||
4307 | // FONTS | |
4308 | if (aMapOfArgs.Find ("namefont", aValues)) | |
4309 | { | |
4310 | aTrihedronData.SetNamesFont (aValues->Value(1)); | |
4311 | } | |
4312 | if (aMapOfArgs.Find ("valuesfont", aValues)) | |
4313 | { | |
4314 | aTrihedronData.SetValuesFont (aValues->Value(1)); | |
4315 | } | |
4316 | ||
536d98e2 | 4317 | if (aMapOfArgs.Find ("drawgrid", aValues)) |
4318 | { | |
4319 | aTrihedronData.SetDrawGrid (aValues->Value(1).IsEqual ("on")); | |
4320 | } | |
4321 | if (aMapOfArgs.Find ("drawaxes", aValues)) | |
4322 | { | |
4323 | aTrihedronData.SetDrawAxes (aValues->Value(1).IsEqual ("on")); | |
4324 | } | |
4325 | ||
a79f67f8 | 4326 | // The final step: display of erase trihedron |
4327 | if (toDisplay) | |
4328 | { | |
4329 | ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData); | |
13a22457 | 4330 | } |
7fd59977 | 4331 | else |
a79f67f8 | 4332 | { |
4333 | ViewerTest::CurrentView()->GraduatedTrihedronErase(); | |
4334 | } | |
7fd59977 | 4335 | |
4336 | ViewerTest::GetAISContext()->UpdateCurrentViewer(); | |
a79f67f8 | 4337 | ViewerTest::CurrentView()->Redraw(); |
13a22457 | 4338 | |
7fd59977 | 4339 | return 0; |
4340 | } | |
4341 | ||
3bffef55 | 4342 | //============================================================================== |
4343 | //function : VTile | |
4344 | //purpose : | |
4345 | //============================================================================== | |
4346 | static int VTile (Draw_Interpretor& theDI, | |
4347 | Standard_Integer theArgNb, | |
4348 | const char** theArgVec) | |
4349 | { | |
4350 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
4351 | if (aView.IsNull()) | |
4352 | { | |
23fe70ec | 4353 | Message::SendFail ("Error: no active viewer"); |
3bffef55 | 4354 | return 1; |
4355 | } | |
4356 | ||
4357 | Graphic3d_CameraTile aTile = aView->Camera()->Tile(); | |
4358 | if (theArgNb < 2) | |
4359 | { | |
4360 | theDI << "Total size: " << aTile.TotalSize.x() << " " << aTile.TotalSize.y() << "\n" | |
4361 | << "Tile size: " << aTile.TileSize.x() << " " << aTile.TileSize.y() << "\n" | |
4362 | << "Lower left: " << aTile.Offset.x() << " " << aTile.Offset.y() << "\n"; | |
4363 | return 0; | |
4364 | } | |
4365 | ||
4366 | aView->Window()->Size (aTile.TileSize.x(), aTile.TileSize.y()); | |
4367 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
4368 | { | |
4369 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
4370 | anArg.LowerCase(); | |
4371 | if (anArg == "-lowerleft" | |
4372 | || anArg == "-upperleft") | |
4373 | { | |
4374 | if (anArgIter + 3 < theArgNb) | |
4375 | { | |
23fe70ec | 4376 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
3bffef55 | 4377 | return 1; |
4378 | } | |
4379 | aTile.IsTopDown = (anArg == "-upperleft") == Standard_True; | |
4380 | aTile.Offset.x() = Draw::Atoi (theArgVec[anArgIter + 1]); | |
4381 | aTile.Offset.y() = Draw::Atoi (theArgVec[anArgIter + 2]); | |
4382 | } | |
4383 | else if (anArg == "-total" | |
4384 | || anArg == "-totalsize" | |
4385 | || anArg == "-viewsize") | |
4386 | { | |
4387 | if (anArgIter + 3 < theArgNb) | |
4388 | { | |
23fe70ec | 4389 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
3bffef55 | 4390 | return 1; |
4391 | } | |
4392 | aTile.TotalSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]); | |
4393 | aTile.TotalSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]); | |
4394 | if (aTile.TotalSize.x() < 1 | |
4395 | || aTile.TotalSize.y() < 1) | |
4396 | { | |
23fe70ec | 4397 | Message::SendFail ("Error: total size is incorrect"); |
3bffef55 | 4398 | return 1; |
4399 | } | |
4400 | } | |
4401 | else if (anArg == "-tilesize") | |
4402 | { | |
4403 | if (anArgIter + 3 < theArgNb) | |
4404 | { | |
23fe70ec | 4405 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
3bffef55 | 4406 | return 1; |
4407 | } | |
4408 | ||
4409 | aTile.TileSize.x() = Draw::Atoi (theArgVec[anArgIter + 1]); | |
4410 | aTile.TileSize.y() = Draw::Atoi (theArgVec[anArgIter + 2]); | |
4411 | if (aTile.TileSize.x() < 1 | |
4412 | || aTile.TileSize.y() < 1) | |
4413 | { | |
23fe70ec | 4414 | Message::SendFail ("Error: tile size is incorrect"); |
3bffef55 | 4415 | return 1; |
4416 | } | |
4417 | } | |
4418 | else if (anArg == "-unset") | |
4419 | { | |
4420 | aView->Camera()->SetTile (Graphic3d_CameraTile()); | |
4421 | aView->Redraw(); | |
4422 | return 0; | |
4423 | } | |
4424 | } | |
4425 | ||
4426 | if (aTile.TileSize.x() < 1 | |
4427 | || aTile.TileSize.y() < 1) | |
4428 | { | |
23fe70ec | 4429 | Message::SendFail ("Error: tile size is undefined"); |
3bffef55 | 4430 | return 1; |
4431 | } | |
4432 | else if (aTile.TotalSize.x() < 1 | |
4433 | || aTile.TotalSize.y() < 1) | |
4434 | { | |
23fe70ec | 4435 | Message::SendFail ("Error: total size is undefined"); |
3bffef55 | 4436 | return 1; |
4437 | } | |
4438 | ||
4439 | aView->Camera()->SetTile (aTile); | |
4440 | aView->Redraw(); | |
4441 | return 0; | |
4442 | } | |
4443 | ||
7c3ef2f7 | 4444 | //! Format ZLayer ID. |
4445 | inline const char* formZLayerId (const Standard_Integer theLayerId) | |
4446 | { | |
4447 | switch (theLayerId) | |
4448 | { | |
4449 | case Graphic3d_ZLayerId_UNKNOWN: return "[INVALID]"; | |
4450 | case Graphic3d_ZLayerId_Default: return "[DEFAULT]"; | |
4451 | case Graphic3d_ZLayerId_Top: return "[TOP]"; | |
4452 | case Graphic3d_ZLayerId_Topmost: return "[TOPMOST]"; | |
4453 | case Graphic3d_ZLayerId_TopOSD: return "[OVERLAY]"; | |
4454 | case Graphic3d_ZLayerId_BotOSD: return "[UNDERLAY]"; | |
4455 | } | |
4456 | return ""; | |
4457 | } | |
4458 | ||
4459 | //! Print the ZLayer information. | |
4460 | inline void printZLayerInfo (Draw_Interpretor& theDI, | |
4461 | const Graphic3d_ZLayerSettings& theLayer) | |
4462 | { | |
4463 | if (!theLayer.Name().IsEmpty()) | |
4464 | { | |
4465 | theDI << " Name: " << theLayer.Name() << "\n"; | |
4466 | } | |
4467 | if (theLayer.IsImmediate()) | |
4468 | { | |
4469 | theDI << " Immediate: TRUE\n"; | |
4470 | } | |
4471 | theDI << " Origin: " << theLayer.Origin().X() << " " << theLayer.Origin().Y() << " " << theLayer.Origin().Z() << "\n"; | |
4ecf34cc | 4472 | theDI << " Culling distance: " << theLayer.CullingDistance() << "\n"; |
4473 | theDI << " Culling size: " << theLayer.CullingSize() << "\n"; | |
7c3ef2f7 | 4474 | theDI << " Depth test: " << (theLayer.ToEnableDepthTest() ? "enabled" : "disabled") << "\n"; |
4475 | theDI << " Depth write: " << (theLayer.ToEnableDepthWrite() ? "enabled" : "disabled") << "\n"; | |
4476 | theDI << " Depth buffer clearing: " << (theLayer.ToClearDepth() ? "enabled" : "disabled") << "\n"; | |
4477 | if (theLayer.PolygonOffset().Mode != Aspect_POM_None) | |
4478 | { | |
4479 | theDI << " Depth offset: " << theLayer.PolygonOffset().Factor << " " << theLayer.PolygonOffset().Units << "\n"; | |
4480 | } | |
4481 | } | |
4482 | ||
59f45b7c | 4483 | //============================================================================== |
4484 | //function : VZLayer | |
4485 | //purpose : Test z layer operations for v3d viewer | |
4486 | //============================================================================== | |
7c3ef2f7 | 4487 | static int VZLayer (Draw_Interpretor& theDI, |
4488 | Standard_Integer theArgNb, | |
4489 | const char** theArgVec) | |
59f45b7c | 4490 | { |
7c3ef2f7 | 4491 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); |
59f45b7c | 4492 | if (aContextAIS.IsNull()) |
4493 | { | |
23fe70ec | 4494 | Message::SendFail ("Error: no active viewer"); |
59f45b7c | 4495 | return 1; |
4496 | } | |
4497 | ||
4498 | const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer(); | |
7c3ef2f7 | 4499 | if (theArgNb < 2) |
59f45b7c | 4500 | { |
7c3ef2f7 | 4501 | TColStd_SequenceOfInteger aLayers; |
4502 | aViewer->GetAllZLayers (aLayers); | |
4503 | for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next()) | |
4504 | { | |
4505 | theDI << "ZLayer " << aLayeriter.Value() << " " << formZLayerId (aLayeriter.Value()) << "\n"; | |
4506 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value()); | |
4507 | printZLayerInfo (theDI, aSettings); | |
4508 | } | |
95bdefb2 | 4509 | return 0; |
59f45b7c | 4510 | } |
4511 | ||
7c3ef2f7 | 4512 | Standard_Integer anArgIter = 1; |
4513 | Standard_Integer aLayerId = Graphic3d_ZLayerId_UNKNOWN; | |
4514 | ViewerTest_AutoUpdater anUpdateTool (aContextAIS, ViewerTest::CurrentView()); | |
4515 | if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter])) | |
59f45b7c | 4516 | { |
7c3ef2f7 | 4517 | ++anArgIter; |
4518 | } | |
59f45b7c | 4519 | |
7c3ef2f7 | 4520 | { |
55c8f0f7 BB |
4521 | TCollection_AsciiString aFirstArg (theArgVec[anArgIter]); |
4522 | if (aFirstArg.IsIntegerValue()) | |
c5751993 | 4523 | { |
7c3ef2f7 | 4524 | ++anArgIter; |
55c8f0f7 | 4525 | aLayerId = aFirstArg.IntegerValue(); |
c5751993 | 4526 | } |
7c3ef2f7 | 4527 | else |
c5751993 | 4528 | { |
55c8f0f7 | 4529 | if (ViewerTest::ParseZLayerName (aFirstArg.ToCString(), aLayerId)) |
7c3ef2f7 | 4530 | { |
55c8f0f7 | 4531 | ++anArgIter; |
7c3ef2f7 | 4532 | } |
c5751993 | 4533 | } |
7c3ef2f7 | 4534 | } |
c5751993 | 4535 | |
1c728f2d | 4536 | Graphic3d_ZLayerId anOtherLayerId = Graphic3d_ZLayerId_UNKNOWN; |
7c3ef2f7 | 4537 | for (; anArgIter < theArgNb; ++anArgIter) |
4538 | { | |
4539 | // perform operation | |
4540 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
4541 | anArg.LowerCase(); | |
4542 | if (anUpdateTool.parseRedrawMode (anArg)) | |
c5751993 | 4543 | { |
7c3ef2f7 | 4544 | // |
c5751993 | 4545 | } |
7c3ef2f7 | 4546 | else if (anArg == "-add" |
4547 | || anArg == "add") | |
c5751993 | 4548 | { |
7c3ef2f7 | 4549 | aLayerId = Graphic3d_ZLayerId_UNKNOWN; |
4550 | if (!aViewer->AddZLayer (aLayerId)) | |
4551 | { | |
23fe70ec | 4552 | Message::SendFail ("Error: can not add a new z layer"); |
7c3ef2f7 | 4553 | return 0; |
4554 | } | |
4555 | ||
4556 | theDI << aLayerId; | |
c5751993 | 4557 | } |
1c728f2d | 4558 | else if (anArg == "-insertbefore" |
4559 | && anArgIter + 1 < theArgNb | |
4560 | && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId)) | |
4561 | { | |
4562 | ++anArgIter; | |
4563 | aLayerId = Graphic3d_ZLayerId_UNKNOWN; | |
4564 | if (!aViewer->InsertLayerBefore (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId)) | |
4565 | { | |
23fe70ec | 4566 | Message::SendFail ("Error: can not add a new z layer"); |
1c728f2d | 4567 | return 0; |
4568 | } | |
4569 | ||
4570 | theDI << aLayerId; | |
4571 | } | |
4572 | else if (anArg == "-insertafter" | |
4573 | && anArgIter + 1 < theArgNb | |
4574 | && ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId)) | |
4575 | { | |
4576 | ++anArgIter; | |
4577 | aLayerId = Graphic3d_ZLayerId_UNKNOWN; | |
4578 | if (!aViewer->InsertLayerAfter (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId)) | |
4579 | { | |
23fe70ec | 4580 | Message::SendFail ("Error: can not add a new z layer"); |
1c728f2d | 4581 | return 0; |
4582 | } | |
4583 | ||
4584 | theDI << aLayerId; | |
4585 | } | |
7c3ef2f7 | 4586 | else if (anArg == "-del" |
4587 | || anArg == "-delete" | |
4588 | || anArg == "del") | |
c5751993 | 4589 | { |
7c3ef2f7 | 4590 | if (aLayerId == Graphic3d_ZLayerId_UNKNOWN) |
4591 | { | |
4592 | if (++anArgIter >= theArgNb) | |
4593 | { | |
23fe70ec | 4594 | Message::SendFail ("Syntax error: id of z layer to remove is missing"); |
7c3ef2f7 | 4595 | return 1; |
4596 | } | |
4597 | ||
4598 | aLayerId = Draw::Atoi (theArgVec[anArgIter]); | |
4599 | } | |
4600 | ||
4601 | if (aLayerId == Graphic3d_ZLayerId_UNKNOWN | |
4602 | || aLayerId == Graphic3d_ZLayerId_Default | |
4603 | || aLayerId == Graphic3d_ZLayerId_Top | |
4604 | || aLayerId == Graphic3d_ZLayerId_Topmost | |
4605 | || aLayerId == Graphic3d_ZLayerId_TopOSD | |
4606 | || aLayerId == Graphic3d_ZLayerId_BotOSD) | |
4607 | { | |
23fe70ec | 4608 | Message::SendFail ("Syntax error: standard Z layer can not be removed"); |
7c3ef2f7 | 4609 | return 1; |
4610 | } | |
4611 | ||
4612 | // move all object displayed in removing layer to default layer | |
4613 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); | |
4614 | anObjIter.More(); anObjIter.Next()) | |
4615 | { | |
8f521168 | 4616 | const Handle(AIS_InteractiveObject)& aPrs = anObjIter.Key1(); |
7c3ef2f7 | 4617 | if (aPrs.IsNull() |
4618 | || aPrs->ZLayer() != aLayerId) | |
4619 | { | |
4620 | continue; | |
4621 | } | |
4622 | aPrs->SetZLayer (Graphic3d_ZLayerId_Default); | |
4623 | } | |
4624 | ||
4625 | if (!aViewer->RemoveZLayer (aLayerId)) | |
4626 | { | |
23fe70ec | 4627 | Message::SendFail ("Z layer can not be removed"); |
7c3ef2f7 | 4628 | } |
4629 | else | |
4630 | { | |
4631 | theDI << aLayerId << " "; | |
4632 | } | |
c5751993 | 4633 | } |
7c3ef2f7 | 4634 | else if (anArg == "-get" |
4635 | || anArg == "get") | |
c5751993 | 4636 | { |
7c3ef2f7 | 4637 | TColStd_SequenceOfInteger aLayers; |
4638 | aViewer->GetAllZLayers (aLayers); | |
4639 | for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next()) | |
4640 | { | |
4641 | theDI << aLayeriter.Value() << " "; | |
4642 | } | |
4643 | ||
4644 | theDI << "\n"; | |
c5751993 | 4645 | } |
7c3ef2f7 | 4646 | else if (anArg == "-name") |
c5751993 | 4647 | { |
7c3ef2f7 | 4648 | if (aLayerId == Graphic3d_ZLayerId_UNKNOWN) |
c5751993 | 4649 | { |
23fe70ec | 4650 | Message::SendFail ("Syntax error: id of Z layer is missing"); |
c5751993 | 4651 | return 1; |
4652 | } | |
4653 | ||
7c3ef2f7 | 4654 | if (++anArgIter >= theArgNb) |
4655 | { | |
23fe70ec | 4656 | Message::SendFail ("Syntax error: name is missing"); |
7c3ef2f7 | 4657 | return 1; |
4658 | } | |
c5751993 | 4659 | |
7c3ef2f7 | 4660 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId); |
4661 | aSettings.SetName (theArgVec[anArgIter]); | |
4662 | aViewer->SetZLayerSettings (aLayerId, aSettings); | |
c5751993 | 4663 | } |
7c3ef2f7 | 4664 | else if (anArg == "-origin") |
c5751993 | 4665 | { |
7c3ef2f7 | 4666 | if (aLayerId == Graphic3d_ZLayerId_UNKNOWN) |
4667 | { | |
23fe70ec | 4668 | Message::SendFail ("Syntax error: id of Z layer is missing"); |
7c3ef2f7 | 4669 | return 1; |
4670 | } | |
4671 | ||
4672 | if (anArgIter + 2 >= theArgNb) | |
4673 | { | |
23fe70ec | 4674 | Message::SendFail ("Syntax error: origin coordinates are missing"); |
7c3ef2f7 | 4675 | return 1; |
4676 | } | |
4677 | ||
4678 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId); | |
4679 | gp_XYZ anOrigin; | |
4680 | anOrigin.SetX (Draw::Atof (theArgVec[anArgIter + 1])); | |
4681 | anOrigin.SetY (Draw::Atof (theArgVec[anArgIter + 2])); | |
4682 | anOrigin.SetZ (0.0); | |
4683 | if (anArgIter + 3 < theArgNb) | |
4684 | { | |
4685 | anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter + 3])); | |
4686 | anArgIter += 3; | |
4687 | } | |
4688 | else | |
4689 | { | |
4690 | anArgIter += 2; | |
4691 | } | |
4692 | aSettings.SetOrigin (anOrigin); | |
4693 | aViewer->SetZLayerSettings (aLayerId, aSettings); | |
c5751993 | 4694 | } |
4ecf34cc | 4695 | else if (aLayerId != Graphic3d_ZLayerId_UNKNOWN |
4696 | && anArgIter + 1 < theArgNb | |
4697 | && (anArg == "-cullingdistance" | |
4698 | || anArg == "-cullingdist" | |
4699 | || anArg == "-culldistance" | |
4700 | || anArg == "-culldist" | |
4701 | || anArg == "-distcull" | |
4702 | || anArg == "-distculling" | |
4703 | || anArg == "-distanceculling")) | |
4704 | { | |
4705 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId); | |
4706 | const Standard_Real aDist = Draw::Atof (theArgVec[++anArgIter]); | |
4707 | aSettings.SetCullingDistance (aDist); | |
4708 | aViewer->SetZLayerSettings (aLayerId, aSettings); | |
4709 | } | |
4710 | else if (aLayerId != Graphic3d_ZLayerId_UNKNOWN | |
4711 | && anArgIter + 1 < theArgNb | |
4712 | && (anArg == "-cullingsize" | |
4713 | || anArg == "-cullsize" | |
4714 | || anArg == "-sizecull" | |
4715 | || anArg == "-sizeculling")) | |
4716 | { | |
4717 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId); | |
4718 | const Standard_Real aSize = Draw::Atof (theArgVec[++anArgIter]); | |
4719 | aSettings.SetCullingSize (aSize); | |
4720 | aViewer->SetZLayerSettings (aLayerId, aSettings); | |
4721 | } | |
7c3ef2f7 | 4722 | else if (anArg == "-settings" |
4723 | || anArg == "settings") | |
c5751993 | 4724 | { |
7c3ef2f7 | 4725 | if (aLayerId == Graphic3d_ZLayerId_UNKNOWN) |
4726 | { | |
4727 | if (++anArgIter >= theArgNb) | |
4728 | { | |
23fe70ec | 4729 | Message::SendFail ("Syntax error: id of Z layer is missing"); |
7c3ef2f7 | 4730 | return 1; |
4731 | } | |
4732 | ||
4733 | aLayerId = Draw::Atoi (theArgVec[anArgIter]); | |
4734 | } | |
4735 | ||
4736 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId); | |
4737 | printZLayerInfo (theDI, aSettings); | |
c5751993 | 4738 | } |
7c3ef2f7 | 4739 | else if (anArg == "-enable" |
4740 | || anArg == "enable" | |
4741 | || anArg == "-disable" | |
4742 | || anArg == "disable") | |
83da37b1 | 4743 | { |
7c3ef2f7 | 4744 | const Standard_Boolean toEnable = anArg == "-enable" |
4745 | || anArg == "enable"; | |
4746 | if (++anArgIter >= theArgNb) | |
4747 | { | |
23fe70ec | 4748 | Message::SendFail ("Syntax error: option name is missing"); |
7c3ef2f7 | 4749 | return 1; |
4750 | } | |
c5751993 | 4751 | |
7c3ef2f7 | 4752 | TCollection_AsciiString aSubOp (theArgVec[anArgIter]); |
4753 | aSubOp.LowerCase(); | |
4754 | if (aLayerId == Graphic3d_ZLayerId_UNKNOWN) | |
4755 | { | |
4756 | if (++anArgIter >= theArgNb) | |
4757 | { | |
23fe70ec | 4758 | Message::SendFail ("Syntax error: id of Z layer is missing"); |
7c3ef2f7 | 4759 | return 1; |
4760 | } | |
c5751993 | 4761 | |
7c3ef2f7 | 4762 | aLayerId = Draw::Atoi (theArgVec[anArgIter]); |
4763 | } | |
c5751993 | 4764 | |
7c3ef2f7 | 4765 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerId); |
4766 | if (aSubOp == "depthtest" | |
4767 | || aSubOp == "test") | |
4768 | { | |
4769 | aSettings.SetEnableDepthTest (toEnable); | |
4770 | } | |
4771 | else if (aSubOp == "depthwrite" | |
4772 | || aSubOp == "write") | |
4773 | { | |
4774 | aSettings.SetEnableDepthWrite (toEnable); | |
4775 | } | |
4776 | else if (aSubOp == "depthclear" | |
4777 | || aSubOp == "clear") | |
4778 | { | |
4779 | aSettings.SetClearDepth (toEnable); | |
4780 | } | |
4781 | else if (aSubOp == "depthoffset" | |
4782 | || aSubOp == "offset") | |
4783 | { | |
4784 | Graphic3d_PolygonOffset aParams; | |
4785 | aParams.Mode = toEnable ? Aspect_POM_Fill : Aspect_POM_None; | |
4786 | if (toEnable) | |
4787 | { | |
4788 | if (anArgIter + 2 >= theArgNb) | |
4789 | { | |
23fe70ec | 4790 | Message::SendFail ("Syntax error: factor and units values for depth offset are missing"); |
7c3ef2f7 | 4791 | return 1; |
4792 | } | |
c5751993 | 4793 | |
7c3ef2f7 | 4794 | aParams.Factor = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter])); |
4795 | aParams.Units = static_cast<Standard_ShortReal> (Draw::Atof (theArgVec[++anArgIter])); | |
4796 | } | |
4797 | aSettings.SetPolygonOffset (aParams); | |
4798 | } | |
4799 | else if (aSubOp == "positiveoffset" | |
4800 | || aSubOp == "poffset") | |
4801 | { | |
4802 | if (toEnable) | |
4803 | { | |
4804 | aSettings.SetDepthOffsetPositive(); | |
4805 | } | |
4806 | else | |
4807 | { | |
4808 | aSettings.SetPolygonOffset (Graphic3d_PolygonOffset()); | |
4809 | } | |
4810 | } | |
4811 | else if (aSubOp == "negativeoffset" | |
4812 | || aSubOp == "noffset") | |
4813 | { | |
4814 | if (toEnable) | |
4815 | { | |
4816 | aSettings.SetDepthOffsetNegative(); | |
4817 | } | |
4818 | else | |
4819 | { | |
4820 | aSettings.SetPolygonOffset(Graphic3d_PolygonOffset()); | |
4821 | } | |
4822 | } | |
4823 | else if (aSubOp == "textureenv") | |
4824 | { | |
4825 | aSettings.SetEnvironmentTexture (toEnable); | |
4826 | } | |
1c728f2d | 4827 | else if (aSubOp == "raytracing") |
4828 | { | |
4829 | aSettings.SetRaytracable (toEnable); | |
4830 | } | |
7c3ef2f7 | 4831 | |
4832 | aViewer->SetZLayerSettings (aLayerId, aSettings); | |
c5751993 | 4833 | } |
7c3ef2f7 | 4834 | else |
83da37b1 | 4835 | { |
23fe70ec | 4836 | Message::SendFail() << "Syntax error: unknown option " << theArgVec[anArgIter]; |
7c3ef2f7 | 4837 | return 1; |
83da37b1 | 4838 | } |
59f45b7c | 4839 | } |
4840 | ||
4841 | return 0; | |
4842 | } | |
4843 | ||
c357e426 | 4844 | // The interactive presentation of 2d layer item |
4845 | // for "vlayerline" command it provides a presentation of | |
4846 | // line with user-defined linewidth, linetype and transparency. | |
61b0191c | 4847 | class V3d_LineItem : public AIS_InteractiveObject |
20637bd2 | 4848 | { |
4849 | public: | |
4850 | // CASCADE RTTI | |
92efcf78 | 4851 | DEFINE_STANDARD_RTTI_INLINE(V3d_LineItem,AIS_InteractiveObject) |
4fe56619 | 4852 | |
20637bd2 | 4853 | // constructor |
4854 | Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1, | |
4855 | Standard_Real X2, Standard_Real Y2, | |
20637bd2 | 4856 | Aspect_TypeOfLine theType = Aspect_TOL_SOLID, |
4857 | Standard_Real theWidth = 0.5, | |
4858 | Standard_Real theTransp = 1.0); | |
4859 | ||
decbff0d | 4860 | private: |
61b0191c | 4861 | |
decbff0d | 4862 | virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, |
4863 | const Handle(Prs3d_Presentation)& thePrs, | |
4864 | const Standard_Integer theMode) Standard_OVERRIDE; | |
61b0191c | 4865 | |
decbff0d | 4866 | virtual void ComputeSelection (const Handle(SelectMgr_Selection)& , |
4867 | const Standard_Integer ) Standard_OVERRIDE | |
79104795 | 4868 | {} |
20637bd2 | 4869 | |
4870 | private: | |
4871 | ||
4872 | Standard_Real myX1, myY1, myX2, myY2; | |
eafb234b | 4873 | Aspect_TypeOfLine myType; |
20637bd2 | 4874 | Standard_Real myWidth; |
20637bd2 | 4875 | }; |
4876 | ||
20637bd2 | 4877 | // default constructor for line item |
4fe56619 | 4878 | V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1, |
20637bd2 | 4879 | Standard_Real X2, Standard_Real Y2, |
20637bd2 | 4880 | Aspect_TypeOfLine theType, |
4881 | Standard_Real theWidth, | |
4882 | Standard_Real theTransp) : | |
61b0191c | 4883 | myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), |
4884 | myType(theType), myWidth(theWidth) | |
20637bd2 | 4885 | { |
61b0191c | 4886 | SetTransparency (1-theTransp); |
20637bd2 | 4887 | } |
4888 | ||
4889 | // render line | |
decbff0d | 4890 | void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager)& , |
61b0191c | 4891 | const Handle(Prs3d_Presentation)& thePresentation, |
decbff0d | 4892 | const Standard_Integer ) |
20637bd2 | 4893 | { |
61b0191c | 4894 | thePresentation->Clear(); |
ba00aab7 | 4895 | Quantity_Color aColor (Quantity_NOC_RED); |
61b0191c | 4896 | Standard_Integer aWidth, aHeight; |
4897 | ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight); | |
d6c48921 | 4898 | Handle(Graphic3d_Group) aGroup = thePresentation->CurrentGroup(); |
61b0191c | 4899 | Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5); |
4900 | aPrim->AddVertex(myX1, aHeight-myY1, 0.); | |
4901 | aPrim->AddVertex(myX2, aHeight-myY2, 0.); | |
4902 | Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (aColor, (Aspect_TypeOfLine)myType, myWidth); | |
4903 | aGroup->SetPrimitivesAspect (anAspect->Aspect()); | |
4904 | aGroup->AddPrimitiveArray (aPrim); | |
20637bd2 | 4905 | } |
4906 | ||
4907 | //============================================================================= | |
4908 | //function : VLayerLine | |
4909 | //purpose : Draws line in the v3d view layer with given attributes: linetype, | |
4910 | // : linewidth, transparency coefficient | |
4911 | //============================================================================ | |
4912 | static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
4913 | { | |
4914 | // get the active view | |
4915 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
4916 | if (aView.IsNull()) | |
4917 | { | |
4918 | di << "Call vinit before!\n"; | |
4919 | return 1; | |
4920 | } | |
4921 | else if (argc < 5) | |
4922 | { | |
4923 | di << "Use: " << argv[0]; | |
4924 | di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n"; | |
4925 | di << " linetype : { 0 | 1 | 2 | 3 } \n"; | |
4926 | di << " 0 - solid \n"; | |
4927 | di << " 1 - dashed \n"; | |
4928 | di << " 2 - dot \n"; | |
4929 | di << " 3 - dashdot\n"; | |
4930 | di << " transparency : { 0.0 - 1.0 } \n"; | |
4931 | di << " 0.0 - transparent\n"; | |
4932 | di << " 1.0 - visible \n"; | |
4933 | return 1; | |
4934 | } | |
4935 | ||
61b0191c | 4936 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
20637bd2 | 4937 | // get the input params |
91322f44 | 4938 | Standard_Real X1 = Draw::Atof(argv[1]); |
4939 | Standard_Real Y1 = Draw::Atof(argv[2]); | |
4940 | Standard_Real X2 = Draw::Atof(argv[3]); | |
4941 | Standard_Real Y2 = Draw::Atof(argv[4]); | |
20637bd2 | 4942 | |
3a4a3962 | 4943 | Standard_Real aWidth = 0.5; |
4944 | Standard_Real aTransparency = 1.0; | |
20637bd2 | 4945 | |
4946 | // has width | |
4947 | if (argc > 5) | |
91322f44 | 4948 | aWidth = Draw::Atof(argv[5]); |
20637bd2 | 4949 | |
3a4a3962 | 4950 | // select appropriate line type |
4951 | Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID; | |
4952 | if (argc > 6 | |
4953 | && !ViewerTest::ParseLineType (argv[6], aLineType)) | |
4954 | { | |
23fe70ec | 4955 | Message::SendFail() << "Syntax error: unknown line type '" << argv[6] << "'"; |
3a4a3962 | 4956 | return 1; |
4957 | } | |
20637bd2 | 4958 | |
4959 | // has transparency | |
4960 | if (argc > 7) | |
4961 | { | |
91322f44 | 4962 | aTransparency = Draw::Atof(argv[7]); |
4fe56619 | 4963 | if (aTransparency < 0 || aTransparency > 1.0) |
20637bd2 | 4964 | aTransparency = 1.0; |
4965 | } | |
4966 | ||
61b0191c | 4967 | static Handle (V3d_LineItem) aLine; |
4968 | if (!aLine.IsNull()) | |
25289ec1 | 4969 | { |
0577ae8c | 4970 | aContext->Erase (aLine, Standard_False); |
25289ec1 | 4971 | } |
61b0191c | 4972 | aLine = new V3d_LineItem (X1, Y1, X2, Y2, |
4973 | aLineType, aWidth, | |
4974 | aTransparency); | |
25289ec1 | 4975 | |
778cd667 | 4976 | aContext->SetTransformPersistence (aLine, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER)); |
61b0191c | 4977 | aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD); |
4978 | aLine->SetToUpdate(); | |
4979 | aContext->Display (aLine, Standard_True); | |
25289ec1 | 4980 | |
4981 | return 0; | |
4982 | } | |
4983 | ||
61b0191c | 4984 | |
2bd4c032 | 4985 | //============================================================================== |
4986 | //function : VGrid | |
4987 | //purpose : | |
4988 | //============================================================================== | |
4989 | ||
35e08fe8 | 4990 | static int VGrid (Draw_Interpretor& /*theDI*/, |
2bd4c032 | 4991 | Standard_Integer theArgNb, |
4992 | const char** theArgVec) | |
4993 | { | |
2bd4c032 | 4994 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
4995 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
4996 | if (aView.IsNull() || aViewer.IsNull()) | |
4997 | { | |
23fe70ec | 4998 | Message::SendFail ("Error: no active viewer"); |
2bd4c032 | 4999 | return 1; |
5000 | } | |
5001 | ||
5002 | Aspect_GridType aType = aViewer->GridType(); | |
5003 | Aspect_GridDrawMode aMode = aViewer->GridDrawMode(); | |
79931835 | 5004 | Graphic3d_Vec2d aNewOriginXY, aNewStepXY, aNewSizeXY; |
5005 | Standard_Real aNewRotAngle = 0.0, aNewZOffset = 0.0; | |
5006 | bool hasOrigin = false, hasStep = false, hasRotAngle = false, hasSize = false, hasZOffset = false; | |
224f48fa | 5007 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
79931835 | 5008 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
2bd4c032 | 5009 | { |
79931835 | 5010 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
5011 | anArg.LowerCase(); | |
5012 | if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter])) | |
224f48fa | 5013 | { |
5014 | continue; | |
5015 | } | |
79931835 | 5016 | else if (anArgIter + 1 < theArgNb |
5017 | && anArg == "-type") | |
5018 | { | |
5019 | TCollection_AsciiString anArgNext (theArgVec[++anArgIter]); | |
5020 | anArgNext.LowerCase(); | |
5021 | if (anArgNext == "r" | |
5022 | || anArgNext == "rect" | |
5023 | || anArgNext == "rectangular") | |
5024 | { | |
5025 | aType = Aspect_GT_Rectangular; | |
5026 | } | |
5027 | else if (anArgNext == "c" | |
5028 | || anArgNext == "circ" | |
5029 | || anArgNext == "circular") | |
5030 | { | |
5031 | aType = Aspect_GT_Circular; | |
5032 | } | |
5033 | else | |
5034 | { | |
23fe70ec | 5035 | Message::SendFail() << "Syntax error at '" << anArgNext << "'"; |
79931835 | 5036 | return 1; |
5037 | } | |
5038 | } | |
5039 | else if (anArgIter + 1 < theArgNb | |
5040 | && anArg == "-mode") | |
5041 | { | |
5042 | TCollection_AsciiString anArgNext (theArgVec[++anArgIter]); | |
5043 | anArgNext.LowerCase(); | |
5044 | if (anArgNext == "l" | |
5045 | || anArgNext == "line" | |
5046 | || anArgNext == "lines") | |
5047 | { | |
5048 | aMode = Aspect_GDM_Lines; | |
5049 | } | |
5050 | else if (anArgNext == "p" | |
5051 | || anArgNext == "point" | |
5052 | || anArgNext == "points") | |
5053 | { | |
5054 | aMode = Aspect_GDM_Points; | |
5055 | } | |
5056 | else | |
5057 | { | |
23fe70ec | 5058 | Message::SendFail() << "Syntax error at '" << anArgNext << "'"; |
79931835 | 5059 | return 1; |
5060 | } | |
5061 | } | |
5062 | else if (anArgIter + 2 < theArgNb | |
5063 | && (anArg == "-origin" | |
5064 | || anArg == "-orig")) | |
5065 | { | |
5066 | hasOrigin = true; | |
5067 | aNewOriginXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]), | |
5068 | Draw::Atof (theArgVec[anArgIter + 2])); | |
5069 | anArgIter += 2; | |
5070 | } | |
5071 | else if (anArgIter + 2 < theArgNb | |
5072 | && anArg == "-step") | |
5073 | { | |
5074 | hasStep = true; | |
5075 | aNewStepXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]), | |
5076 | Draw::Atof (theArgVec[anArgIter + 2])); | |
5077 | if (aNewStepXY.x() <= 0.0 | |
5078 | || aNewStepXY.y() <= 0.0) | |
5079 | { | |
23fe70ec | 5080 | Message::SendFail() << "Syntax error: wrong step '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'"; |
79931835 | 5081 | return 1; |
5082 | } | |
5083 | anArgIter += 2; | |
5084 | } | |
5085 | else if (anArgIter + 1 < theArgNb | |
5086 | && (anArg == "-angle" | |
5087 | || anArg == "-rotangle" | |
5088 | || anArg == "-rotationangle")) | |
5089 | { | |
5090 | hasRotAngle = true; | |
5091 | aNewRotAngle = Draw::Atof (theArgVec[++anArgIter]); | |
5092 | } | |
5093 | else if (anArgIter + 1 < theArgNb | |
5094 | && (anArg == "-zoffset" | |
5095 | || anArg == "-dz")) | |
5096 | { | |
5097 | hasZOffset = true; | |
5098 | aNewZOffset = Draw::Atof (theArgVec[++anArgIter]); | |
5099 | } | |
5100 | else if (anArgIter + 1 < theArgNb | |
5101 | && anArg == "-radius") | |
5102 | { | |
5103 | hasSize = true; | |
5104 | ++anArgIter; | |
5105 | aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter]), 0.0); | |
5106 | if (aNewStepXY.x() <= 0.0) | |
5107 | { | |
23fe70ec | 5108 | Message::SendFail() << "Syntax error: wrong size '" << theArgVec[anArgIter] << "'"; |
79931835 | 5109 | return 1; |
5110 | } | |
5111 | } | |
5112 | else if (anArgIter + 2 < theArgNb | |
5113 | && anArg == "-size") | |
5114 | { | |
5115 | hasSize = true; | |
5116 | aNewSizeXY.SetValues (Draw::Atof (theArgVec[anArgIter + 1]), | |
5117 | Draw::Atof (theArgVec[anArgIter + 2])); | |
5118 | if (aNewStepXY.x() <= 0.0 | |
5119 | || aNewStepXY.y() <= 0.0) | |
5120 | { | |
23fe70ec | 5121 | Message::SendFail() << "Syntax error: wrong size '" << theArgVec[anArgIter + 1] << " " << theArgVec[anArgIter + 2] << "'"; |
79931835 | 5122 | return 1; |
5123 | } | |
5124 | anArgIter += 2; | |
5125 | } | |
5126 | else if (anArg == "r" | |
5127 | || anArg == "rect" | |
5128 | || anArg == "rectangular") | |
2bd4c032 | 5129 | { |
5130 | aType = Aspect_GT_Rectangular; | |
5131 | } | |
79931835 | 5132 | else if (anArg == "c" |
5133 | || anArg == "circ" | |
5134 | || anArg == "circular") | |
2bd4c032 | 5135 | { |
5136 | aType = Aspect_GT_Circular; | |
5137 | } | |
79931835 | 5138 | else if (anArg == "l" |
5139 | || anArg == "line" | |
5140 | || anArg == "lines") | |
2bd4c032 | 5141 | { |
5142 | aMode = Aspect_GDM_Lines; | |
5143 | } | |
79931835 | 5144 | else if (anArg == "p" |
5145 | || anArg == "point" | |
5146 | || anArg == "points") | |
2bd4c032 | 5147 | { |
5148 | aMode = Aspect_GDM_Points; | |
5149 | } | |
79931835 | 5150 | else if (anArgIter + 1 >= theArgNb |
5151 | && anArg == "off") | |
2bd4c032 | 5152 | { |
5153 | aViewer->DeactivateGrid(); | |
5154 | return 0; | |
5155 | } | |
5156 | else | |
5157 | { | |
23fe70ec | 5158 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
79931835 | 5159 | return 1; |
2bd4c032 | 5160 | } |
5161 | } | |
5162 | ||
2bd4c032 | 5163 | if (aType == Aspect_GT_Rectangular) |
5164 | { | |
79931835 | 5165 | Graphic3d_Vec2d anOrigXY, aStepXY; |
5166 | Standard_Real aRotAngle = 0.0; | |
5167 | aViewer->RectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle); | |
5168 | if (hasOrigin) | |
5169 | { | |
5170 | anOrigXY = aNewOriginXY; | |
5171 | } | |
5172 | if (hasStep) | |
5173 | { | |
5174 | aStepXY = aNewStepXY; | |
5175 | } | |
5176 | if (hasRotAngle) | |
5177 | { | |
5178 | aRotAngle = aNewRotAngle; | |
5179 | } | |
5180 | aViewer->SetRectangularGridValues (anOrigXY.x(), anOrigXY.y(), aStepXY.x(), aStepXY.y(), aRotAngle); | |
5181 | if (hasSize || hasZOffset) | |
2bd4c032 | 5182 | { |
79931835 | 5183 | Graphic3d_Vec3d aSize; |
5184 | aViewer->RectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z()); | |
5185 | if (hasSize) | |
5186 | { | |
5187 | aSize.x() = aNewSizeXY.x(); | |
5188 | aSize.y() = aNewSizeXY.y(); | |
5189 | } | |
5190 | if (hasZOffset) | |
5191 | { | |
5192 | aSize.z() = aNewZOffset; | |
5193 | } | |
5194 | aViewer->SetRectangularGridGraphicValues (aSize.x(), aSize.y(), aSize.z()); | |
2bd4c032 | 5195 | } |
2bd4c032 | 5196 | } |
5197 | else if (aType == Aspect_GT_Circular) | |
5198 | { | |
79931835 | 5199 | Graphic3d_Vec2d anOrigXY; |
ee2be2a8 | 5200 | Standard_Real aRadiusStep; |
2bd4c032 | 5201 | Standard_Integer aDivisionNumber; |
79931835 | 5202 | Standard_Real aRotAngle = 0.0; |
5203 | aViewer->CircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle); | |
5204 | if (hasOrigin) | |
5205 | { | |
5206 | anOrigXY = aNewOriginXY; | |
5207 | } | |
5208 | if (hasStep) | |
5209 | { | |
5210 | aRadiusStep = aNewStepXY[0]; | |
5211 | aDivisionNumber = (int )aNewStepXY[1]; | |
5212 | if (aDivisionNumber < 1) | |
5213 | { | |
23fe70ec | 5214 | Message::SendFail() << "Syntax error: invalid division number '" << aNewStepXY[1] << "'"; |
79931835 | 5215 | return 1; |
5216 | } | |
5217 | } | |
5218 | if (hasRotAngle) | |
2bd4c032 | 5219 | { |
79931835 | 5220 | aRotAngle = aNewRotAngle; |
2bd4c032 | 5221 | } |
5222 | ||
79931835 | 5223 | aViewer->SetCircularGridValues (anOrigXY.x(), anOrigXY.y(), aRadiusStep, aDivisionNumber, aRotAngle); |
5224 | if (hasSize || hasZOffset) | |
5225 | { | |
5226 | Standard_Real aRadius = 0.0, aZOffset = 0.0; | |
5227 | aViewer->CircularGridGraphicValues (aRadius, aZOffset); | |
5228 | if (hasSize) | |
5229 | { | |
5230 | aRadius = aNewSizeXY.x(); | |
5231 | if (aNewSizeXY.y() != 0.0) | |
5232 | { | |
23fe70ec | 5233 | Message::SendFail ("Syntax error: circular size should be specified as radius"); |
79931835 | 5234 | return 1; |
5235 | } | |
5236 | } | |
5237 | if (hasZOffset) | |
5238 | { | |
5239 | aZOffset = aNewZOffset; | |
5240 | } | |
5241 | aViewer->SetCircularGridGraphicValues (aRadius, aZOffset); | |
5242 | } | |
2bd4c032 | 5243 | } |
79931835 | 5244 | aViewer->ActivateGrid (aType, aMode); |
2bd4c032 | 5245 | return 0; |
5246 | } | |
5247 | ||
c40b7d58 | 5248 | //============================================================================== |
5249 | //function : VPriviledgedPlane | |
5250 | //purpose : | |
5251 | //============================================================================== | |
5252 | ||
5253 | static int VPriviledgedPlane (Draw_Interpretor& theDI, | |
5254 | Standard_Integer theArgNb, | |
5255 | const char** theArgVec) | |
5256 | { | |
5257 | if (theArgNb != 1 && theArgNb != 7 && theArgNb != 10) | |
5258 | { | |
23fe70ec | 5259 | Message::SendFail ("Error: wrong number of arguments! See usage:"); |
c40b7d58 | 5260 | theDI.PrintHelp (theArgVec[0]); |
5261 | return 1; | |
5262 | } | |
5263 | ||
5264 | // get the active viewer | |
5265 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
5266 | if (aViewer.IsNull()) | |
5267 | { | |
23fe70ec | 5268 | Message::SendFail ("Error: no active viewer"); |
c40b7d58 | 5269 | return 1; |
5270 | } | |
5271 | ||
5272 | if (theArgNb == 1) | |
5273 | { | |
5274 | gp_Ax3 aPriviledgedPlane = aViewer->PrivilegedPlane(); | |
5275 | const gp_Pnt& anOrig = aPriviledgedPlane.Location(); | |
5276 | const gp_Dir& aNorm = aPriviledgedPlane.Direction(); | |
5277 | const gp_Dir& aXDir = aPriviledgedPlane.XDirection(); | |
5278 | theDI << "Origin: " << anOrig.X() << " " << anOrig.Y() << " " << anOrig.Z() << " " | |
5279 | << "Normal: " << aNorm.X() << " " << aNorm.Y() << " " << aNorm.Z() << " " | |
5280 | << "X-dir: " << aXDir.X() << " " << aXDir.Y() << " " << aXDir.Z() << "\n"; | |
5281 | return 0; | |
5282 | } | |
5283 | ||
5284 | Standard_Integer anArgIdx = 1; | |
5285 | Standard_Real anOrigX = Draw::Atof (theArgVec[anArgIdx++]); | |
5286 | Standard_Real anOrigY = Draw::Atof (theArgVec[anArgIdx++]); | |
5287 | Standard_Real anOrigZ = Draw::Atof (theArgVec[anArgIdx++]); | |
5288 | Standard_Real aNormX = Draw::Atof (theArgVec[anArgIdx++]); | |
5289 | Standard_Real aNormY = Draw::Atof (theArgVec[anArgIdx++]); | |
5290 | Standard_Real aNormZ = Draw::Atof (theArgVec[anArgIdx++]); | |
5291 | ||
5292 | gp_Ax3 aPriviledgedPlane; | |
5293 | gp_Pnt anOrig (anOrigX, anOrigY, anOrigZ); | |
5294 | gp_Dir aNorm (aNormX, aNormY, aNormZ); | |
5295 | if (theArgNb > 7) | |
5296 | { | |
5297 | Standard_Real aXDirX = Draw::Atof (theArgVec[anArgIdx++]); | |
5298 | Standard_Real aXDirY = Draw::Atof (theArgVec[anArgIdx++]); | |
5299 | Standard_Real aXDirZ = Draw::Atof (theArgVec[anArgIdx++]); | |
5300 | gp_Dir aXDir (aXDirX, aXDirY, aXDirZ); | |
5301 | aPriviledgedPlane = gp_Ax3 (anOrig, aNorm, aXDir); | |
5302 | } | |
5303 | else | |
5304 | { | |
5305 | aPriviledgedPlane = gp_Ax3 (anOrig, aNorm); | |
5306 | } | |
5307 | ||
5308 | aViewer->SetPrivilegedPlane (aPriviledgedPlane); | |
5309 | ||
5310 | return 0; | |
5311 | } | |
5312 | ||
f25b82d6 | 5313 | //============================================================================== |
5314 | //function : VConvert | |
5315 | //purpose : | |
5316 | //============================================================================== | |
5317 | ||
5318 | static int VConvert (Draw_Interpretor& theDI, | |
5319 | Standard_Integer theArgNb, | |
5320 | const char** theArgVec) | |
5321 | { | |
5322 | // get the active view | |
5323 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5324 | if (aView.IsNull()) | |
5325 | { | |
23fe70ec | 5326 | Message::SendFail ("Error: no active viewer"); |
f25b82d6 | 5327 | return 1; |
5328 | } | |
5329 | ||
5330 | enum { Model, Ray, View, Window, Grid } aMode = Model; | |
5331 | ||
5332 | // access coordinate arguments | |
5333 | TColStd_SequenceOfReal aCoord; | |
5334 | Standard_Integer anArgIdx = 1; | |
5335 | for (; anArgIdx < 4 && anArgIdx < theArgNb; ++anArgIdx) | |
5336 | { | |
5337 | TCollection_AsciiString anArg (theArgVec[anArgIdx]); | |
d45edf24 | 5338 | if (!anArg.IsRealValue (Standard_True)) |
f25b82d6 | 5339 | { |
5340 | break; | |
5341 | } | |
5342 | aCoord.Append (anArg.RealValue()); | |
5343 | } | |
5344 | ||
5345 | // non-numeric argument too early | |
5346 | if (aCoord.IsEmpty()) | |
5347 | { | |
23fe70ec | 5348 | Message::SendFail ("Error: wrong number of arguments! See usage:"); |
f25b82d6 | 5349 | theDI.PrintHelp (theArgVec[0]); |
5350 | return 1; | |
5351 | } | |
5352 | ||
5353 | // collect all other arguments and options | |
5354 | for (; anArgIdx < theArgNb; ++anArgIdx) | |
5355 | { | |
5356 | TCollection_AsciiString anArg (theArgVec[anArgIdx]); | |
5357 | anArg.LowerCase(); | |
5358 | if (anArg == "window") aMode = Window; | |
5359 | else if (anArg == "view") aMode = View; | |
5360 | else if (anArg == "grid") aMode = Grid; | |
5361 | else if (anArg == "ray") aMode = Ray; | |
5362 | else | |
5363 | { | |
23fe70ec | 5364 | Message::SendFail() << "Error: wrong argument " << anArg << "! See usage:"; |
f25b82d6 | 5365 | theDI.PrintHelp (theArgVec[0]); |
5366 | return 1; | |
5367 | } | |
5368 | } | |
5369 | ||
5370 | // complete input checks | |
5371 | if ((aCoord.Length() == 1 && theArgNb > 3) || | |
5372 | (aCoord.Length() == 2 && theArgNb > 4) || | |
5373 | (aCoord.Length() == 3 && theArgNb > 5)) | |
5374 | { | |
23fe70ec | 5375 | Message::SendFail ("Error: wrong number of arguments! See usage:"); |
f25b82d6 | 5376 | theDI.PrintHelp (theArgVec[0]); |
5377 | return 1; | |
5378 | } | |
5379 | ||
5380 | Standard_Real aXYZ[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; | |
5381 | Standard_Integer aXYp[2] = {0, 0}; | |
5382 | ||
5383 | // convert one-dimensional coordinate | |
5384 | if (aCoord.Length() == 1) | |
5385 | { | |
5386 | switch (aMode) | |
5387 | { | |
ee2be2a8 | 5388 | case View : theDI << "View Vv: " << aView->Convert ((Standard_Integer)aCoord (1)); return 0; |
5389 | case Window : theDI << "Window Vp: " << aView->Convert (aCoord (1)); return 0; | |
f25b82d6 | 5390 | default: |
23fe70ec | 5391 | Message::SendFail ("Error: wrong arguments! See usage:"); |
f25b82d6 | 5392 | theDI.PrintHelp (theArgVec[0]); |
5393 | return 1; | |
5394 | } | |
5395 | } | |
5396 | ||
5397 | // convert 2D coordinates from projection or view reference space | |
5398 | if (aCoord.Length() == 2) | |
5399 | { | |
5400 | switch (aMode) | |
5401 | { | |
5402 | case Model : | |
5403 | aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]); | |
5404 | theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n"; | |
5405 | return 0; | |
5406 | ||
5407 | case View : | |
5408 | aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1]); | |
5409 | theDI << "View Xv,Yv: " << aXYZ[0] << " " << aXYZ[1] << "\n"; | |
5410 | return 0; | |
5411 | ||
5412 | case Window : | |
ee2be2a8 | 5413 | aView->Convert (aCoord (1), aCoord (2), aXYp[0], aXYp[1]); |
f25b82d6 | 5414 | theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n"; |
5415 | return 0; | |
5416 | ||
5417 | case Grid : | |
5418 | aView->Convert ((Standard_Integer) aCoord (1), (Standard_Integer) aCoord (2), aXYZ[0], aXYZ[1], aXYZ[2]); | |
5419 | aView->ConvertToGrid (aXYZ[0], aXYZ[1], aXYZ[2], aXYZ[3], aXYZ[4], aXYZ[5]); | |
5420 | theDI << "Model X,Y,Z: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n"; | |
5421 | return 0; | |
5422 | ||
5423 | case Ray : | |
5424 | aView->ConvertWithProj ((Standard_Integer) aCoord (1), | |
5425 | (Standard_Integer) aCoord (2), | |
5426 | aXYZ[0], aXYZ[1], aXYZ[2], | |
5427 | aXYZ[3], aXYZ[4], aXYZ[5]); | |
5428 | theDI << "Model DX,DY,DZ: " << aXYZ[3] << " " << aXYZ[4] << " " << aXYZ[5] << "\n"; | |
5429 | return 0; | |
5430 | ||
5431 | default: | |
23fe70ec | 5432 | Message::SendFail ("Error: wrong arguments! See usage:"); |
f25b82d6 | 5433 | theDI.PrintHelp (theArgVec[0]); |
5434 | return 1; | |
5435 | } | |
5436 | } | |
5437 | ||
5438 | // convert 3D coordinates from view reference space | |
5439 | else if (aCoord.Length() == 3) | |
5440 | { | |
5441 | switch (aMode) | |
5442 | { | |
5443 | case Window : | |
5444 | aView->Convert (aCoord (1), aCoord (2), aCoord (3), aXYp[0], aXYp[1]); | |
5445 | theDI << "Window Xp,Yp: " << aXYp[0] << " " << aXYp[1] << "\n"; | |
5446 | return 0; | |
5447 | ||
5448 | case Grid : | |
5449 | aView->ConvertToGrid (aCoord (1), aCoord (2), aCoord (3), aXYZ[0], aXYZ[1], aXYZ[2]); | |
5450 | theDI << "Model X,Y,Z: " << aXYZ[0] << " " << aXYZ[1] << " " << aXYZ[2] << "\n"; | |
5451 | return 0; | |
5452 | ||
5453 | default: | |
23fe70ec | 5454 | Message::SendFail ("Error: wrong arguments! See usage:"); |
f25b82d6 | 5455 | theDI.PrintHelp (theArgVec[0]); |
5456 | return 1; | |
5457 | } | |
5458 | } | |
5459 | ||
5460 | return 0; | |
5461 | } | |
5462 | ||
208e6839 | 5463 | //============================================================================== |
5464 | //function : VFps | |
5465 | //purpose : | |
5466 | //============================================================================== | |
5467 | ||
5468 | static int VFps (Draw_Interpretor& theDI, | |
5469 | Standard_Integer theArgNb, | |
5470 | const char** theArgVec) | |
5471 | { | |
5472 | // get the active view | |
5473 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5474 | if (aView.IsNull()) | |
5475 | { | |
23fe70ec | 5476 | Message::SendFail ("Error: no active viewer"); |
208e6839 | 5477 | return 1; |
5478 | } | |
5479 | ||
e084dbbc | 5480 | Standard_Integer aFramesNb = -1; |
5481 | Standard_Real aDuration = -1.0; | |
5482 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
208e6839 | 5483 | { |
e084dbbc | 5484 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
5485 | anArg.LowerCase(); | |
5486 | if (aDuration < 0.0 | |
5487 | && anArgIter + 1 < theArgNb | |
5488 | && (anArg == "-duration" | |
5489 | || anArg == "-dur" | |
5490 | || anArg == "-time")) | |
5491 | { | |
5492 | aDuration = Draw::Atof (theArgVec[++anArgIter]); | |
5493 | } | |
5494 | else if (aFramesNb < 0 | |
5495 | && anArg.IsIntegerValue()) | |
5496 | { | |
5497 | aFramesNb = anArg.IntegerValue(); | |
5498 | if (aFramesNb <= 0) | |
5499 | { | |
23fe70ec | 5500 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
e084dbbc | 5501 | return 1; |
5502 | } | |
5503 | } | |
5504 | else | |
5505 | { | |
23fe70ec | 5506 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
e084dbbc | 5507 | return 1; |
5508 | } | |
5509 | } | |
5510 | if (aFramesNb < 0 && aDuration < 0.0) | |
5511 | { | |
5512 | aFramesNb = 100; | |
208e6839 | 5513 | } |
5514 | ||
5515 | // the time is meaningless for first call | |
5516 | // due to async OpenGl rendering | |
5517 | aView->Redraw(); | |
5518 | ||
5519 | // redraw view in loop to estimate average values | |
5520 | OSD_Timer aTimer; | |
5521 | aTimer.Start(); | |
e084dbbc | 5522 | Standard_Integer aFrameIter = 1; |
5523 | for (;; ++aFrameIter) | |
208e6839 | 5524 | { |
5525 | aView->Redraw(); | |
e084dbbc | 5526 | if ((aFramesNb > 0 |
5527 | && aFrameIter >= aFramesNb) | |
5528 | || (aDuration > 0.0 | |
5529 | && aTimer.ElapsedTime() >= aDuration)) | |
5530 | { | |
5531 | break; | |
5532 | } | |
208e6839 | 5533 | } |
5534 | aTimer.Stop(); | |
5535 | Standard_Real aCpu; | |
5536 | const Standard_Real aTime = aTimer.ElapsedTime(); | |
5537 | aTimer.OSD_Chronometer::Show (aCpu); | |
5538 | ||
e084dbbc | 5539 | const Standard_Real aFpsAver = Standard_Real(aFrameIter) / aTime; |
5540 | const Standard_Real aCpuAver = aCpu / Standard_Real(aFrameIter); | |
208e6839 | 5541 | |
5542 | // return statistics | |
5543 | theDI << "FPS: " << aFpsAver << "\n" | |
5544 | << "CPU: " << (1000.0 * aCpuAver) << " msec\n"; | |
5545 | ||
8c820969 | 5546 | // compute additional statistics in ray-tracing mode |
e084dbbc | 5547 | const Graphic3d_RenderingParams& aParams = aView->RenderingParams(); |
8c820969 | 5548 | if (aParams.Method == Graphic3d_RM_RAYTRACING) |
5549 | { | |
e084dbbc | 5550 | Graphic3d_Vec2i aWinSize (0, 0); |
5551 | aView->Window()->Size (aWinSize.x(), aWinSize.y()); | |
8c820969 | 5552 | |
5553 | // 1 shadow ray and 1 secondary ray pew each bounce | |
e084dbbc | 5554 | const Standard_Real aMRays = aWinSize.x() * aWinSize.y() * aFpsAver * aParams.RaytracingDepth * 2 / 1.0e6f; |
8c820969 | 5555 | theDI << "MRays/sec (upper bound): " << aMRays << "\n"; |
5556 | } | |
5557 | ||
208e6839 | 5558 | return 0; |
5559 | } | |
5560 | ||
a577aaab | 5561 | |
f0430952 | 5562 | //============================================================================== |
5563 | //function : VMemGpu | |
5564 | //purpose : | |
5565 | //============================================================================== | |
5566 | ||
5567 | static int VMemGpu (Draw_Interpretor& theDI, | |
5568 | Standard_Integer theArgNb, | |
5569 | const char** theArgVec) | |
5570 | { | |
5571 | // get the context | |
5572 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); | |
5573 | if (aContextAIS.IsNull()) | |
5574 | { | |
23fe70ec | 5575 | Message::SendFail ("Error: no active viewer"); |
f0430952 | 5576 | return 1; |
5577 | } | |
5578 | ||
dc3fe572 | 5579 | Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver(); |
f0430952 | 5580 | if (aDriver.IsNull()) |
5581 | { | |
23fe70ec | 5582 | Message::SendFail ("Error: graphic driver not available"); |
f0430952 | 5583 | return 1; |
5584 | } | |
5585 | ||
5586 | Standard_Size aFreeBytes = 0; | |
5587 | TCollection_AsciiString anInfo; | |
5588 | if (!aDriver->MemoryInfo (aFreeBytes, anInfo)) | |
5589 | { | |
23fe70ec | 5590 | Message::SendFail ("Error: information not available"); |
f0430952 | 5591 | return 1; |
5592 | } | |
5593 | ||
5594 | if (theArgNb > 1 && *theArgVec[1] == 'f') | |
5595 | { | |
5596 | theDI << Standard_Real (aFreeBytes); | |
5597 | } | |
5598 | else | |
5599 | { | |
5600 | theDI << anInfo; | |
5601 | } | |
5602 | ||
5603 | return 0; | |
5604 | } | |
5605 | ||
85e096c3 | 5606 | // ============================================================================== |
5607 | // function : VReadPixel | |
5608 | // purpose : | |
5609 | // ============================================================================== | |
5610 | static int VReadPixel (Draw_Interpretor& theDI, | |
5611 | Standard_Integer theArgNb, | |
5612 | const char** theArgVec) | |
5613 | { | |
5614 | // get the active view | |
5615 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
5616 | if (aView.IsNull()) | |
5617 | { | |
23fe70ec | 5618 | Message::SendFail ("Error: no active viewer"); |
85e096c3 | 5619 | return 1; |
5620 | } | |
5621 | else if (theArgNb < 3) | |
5622 | { | |
23fe70ec | 5623 | Message::SendFail() << "Syntax error: wrong number of arguments.\n" |
5624 | << "Usage: " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]"; | |
85e096c3 | 5625 | return 1; |
5626 | } | |
5627 | ||
dc858f4c | 5628 | Image_Format aFormat = Image_Format_RGBA; |
5629 | Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA; | |
692613e5 | 5630 | |
85e096c3 | 5631 | Standard_Integer aWidth, aHeight; |
5632 | aView->Window()->Size (aWidth, aHeight); | |
91322f44 | 5633 | const Standard_Integer anX = Draw::Atoi (theArgVec[1]); |
5634 | const Standard_Integer anY = Draw::Atoi (theArgVec[2]); | |
85e096c3 | 5635 | if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight) |
5636 | { | |
23fe70ec | 5637 | Message::SendFail() << "Error: pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")"; |
85e096c3 | 5638 | return 1; |
5639 | } | |
5640 | ||
ba00aab7 | 5641 | bool toShowName = false, toShowHls = false, toShowHex = false, toShow_sRGB = false; |
85e096c3 | 5642 | for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter) |
5643 | { | |
dc858f4c | 5644 | TCollection_AsciiString aParam (theArgVec[anIter]); |
5645 | aParam.LowerCase(); | |
55c8f0f7 | 5646 | if (aParam == "-rgb" |
ba00aab7 | 5647 | || aParam == "rgb" |
5648 | || aParam == "-srgb" | |
5649 | || aParam == "srgb") | |
85e096c3 | 5650 | { |
dc858f4c | 5651 | aFormat = Image_Format_RGB; |
692613e5 | 5652 | aBufferType = Graphic3d_BT_RGB; |
ba00aab7 | 5653 | toShow_sRGB = aParam == "-srgb" || aParam == "srgb"; |
85e096c3 | 5654 | } |
55c8f0f7 BB |
5655 | else if (aParam == "-hls" |
5656 | || aParam == "hls") | |
85e096c3 | 5657 | { |
dc858f4c | 5658 | aFormat = Image_Format_RGB; |
692613e5 | 5659 | aBufferType = Graphic3d_BT_RGB; |
85e096c3 | 5660 | toShowHls = Standard_True; |
5661 | } | |
55c8f0f7 BB |
5662 | else if (aParam == "-rgbf" |
5663 | || aParam == "rgbf") | |
85e096c3 | 5664 | { |
dc858f4c | 5665 | aFormat = Image_Format_RGBF; |
692613e5 | 5666 | aBufferType = Graphic3d_BT_RGB; |
85e096c3 | 5667 | } |
55c8f0f7 | 5668 | else if (aParam == "-rgba" |
ba00aab7 | 5669 | || aParam == "rgba" |
5670 | || aParam == "-srgba" | |
5671 | || aParam == "srgba") | |
85e096c3 | 5672 | { |
dc858f4c | 5673 | aFormat = Image_Format_RGBA; |
692613e5 | 5674 | aBufferType = Graphic3d_BT_RGBA; |
ba00aab7 | 5675 | toShow_sRGB = aParam == "-srgba" || aParam == "srgba"; |
85e096c3 | 5676 | } |
55c8f0f7 BB |
5677 | else if (aParam == "-rgbaf" |
5678 | || aParam == "rgbaf") | |
85e096c3 | 5679 | { |
dc858f4c | 5680 | aFormat = Image_Format_RGBAF; |
692613e5 | 5681 | aBufferType = Graphic3d_BT_RGBA; |
85e096c3 | 5682 | } |
55c8f0f7 BB |
5683 | else if (aParam == "-depth" |
5684 | || aParam == "depth") | |
85e096c3 | 5685 | { |
dc858f4c | 5686 | aFormat = Image_Format_GrayF; |
692613e5 | 5687 | aBufferType = Graphic3d_BT_Depth; |
85e096c3 | 5688 | } |
55c8f0f7 BB |
5689 | else if (aParam == "-name" |
5690 | || aParam == "name") | |
85e096c3 | 5691 | { |
5692 | toShowName = Standard_True; | |
5693 | } | |
9196ea9d | 5694 | else if (aParam == "-hex" |
5695 | || aParam == "hex") | |
5696 | { | |
5697 | toShowHex = Standard_True; | |
5698 | } | |
55c8f0f7 BB |
5699 | else |
5700 | { | |
23fe70ec | 5701 | Message::SendFail() << "Syntax error at '" << aParam << "'"; |
9196ea9d | 5702 | return 1; |
55c8f0f7 | 5703 | } |
85e096c3 | 5704 | } |
5705 | ||
692613e5 | 5706 | Image_PixMap anImage; |
5707 | if (!anImage.InitTrash (aFormat, aWidth, aHeight)) | |
5708 | { | |
23fe70ec | 5709 | Message::SendFail ("Error: image allocation failed"); |
692613e5 | 5710 | return 1; |
5711 | } | |
5712 | else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType)) | |
85e096c3 | 5713 | { |
23fe70ec | 5714 | Message::SendFail ("Error: image dump failed"); |
85e096c3 | 5715 | return 1; |
5716 | } | |
5717 | ||
68beaa3c | 5718 | // redirect possible warning messages that could have been added by ToPixMap |
5719 | // into the Tcl interpretor (via DefaultMessenger) to cout, so that they do not | |
5720 | // contaminate result of the command | |
5721 | Standard_CString aWarnLog = theDI.Result(); | |
5722 | if (aWarnLog != NULL && aWarnLog[0] != '\0') | |
5723 | { | |
5724 | std::cout << aWarnLog << std::endl; | |
5725 | } | |
5726 | theDI.Reset(); | |
5727 | ||
ba00aab7 | 5728 | Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY, true); |
85e096c3 | 5729 | if (toShowName) |
5730 | { | |
692613e5 | 5731 | if (aBufferType == Graphic3d_BT_RGBA) |
85e096c3 | 5732 | { |
e958a649 | 5733 | theDI << Quantity_Color::StringName (aColor.GetRGB().Name()) << " " << aColor.Alpha(); |
85e096c3 | 5734 | } |
5735 | else | |
5736 | { | |
e958a649 | 5737 | theDI << Quantity_Color::StringName (aColor.GetRGB().Name()); |
85e096c3 | 5738 | } |
5739 | } | |
9196ea9d | 5740 | else if (toShowHex) |
5741 | { | |
5742 | if (aBufferType == Graphic3d_BT_RGBA) | |
5743 | { | |
5744 | theDI << Quantity_ColorRGBA::ColorToHex (aColor); | |
5745 | } | |
5746 | else | |
5747 | { | |
5748 | theDI << Quantity_Color::ColorToHex (aColor.GetRGB()); | |
5749 | } | |
5750 | } | |
85e096c3 | 5751 | else |
5752 | { | |
5753 | switch (aBufferType) | |
5754 | { | |
5755 | default: | |
692613e5 | 5756 | case Graphic3d_BT_RGB: |
85e096c3 | 5757 | { |
5758 | if (toShowHls) | |
5759 | { | |
e958a649 | 5760 | theDI << aColor.GetRGB().Hue() << " " << aColor.GetRGB().Light() << " " << aColor.GetRGB().Saturation(); |
85e096c3 | 5761 | } |
ba00aab7 | 5762 | else if (toShow_sRGB) |
5763 | { | |
5764 | const Graphic3d_Vec4 aColor_sRGB = Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor); | |
5765 | theDI << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b(); | |
5766 | } | |
85e096c3 | 5767 | else |
5768 | { | |
e958a649 | 5769 | theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue(); |
85e096c3 | 5770 | } |
5771 | break; | |
5772 | } | |
692613e5 | 5773 | case Graphic3d_BT_RGBA: |
85e096c3 | 5774 | { |
ba00aab7 | 5775 | const Graphic3d_Vec4 aVec4 = toShow_sRGB ? Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor) : (Graphic3d_Vec4 )aColor; |
5776 | theDI << aVec4.r() << " " << aVec4.g() << " " << aVec4.b() << " " << aVec4.a(); | |
85e096c3 | 5777 | break; |
5778 | } | |
692613e5 | 5779 | case Graphic3d_BT_Depth: |
85e096c3 | 5780 | { |
e958a649 | 5781 | theDI << aColor.GetRGB().Red(); |
85e096c3 | 5782 | break; |
5783 | } | |
5784 | } | |
5785 | } | |
5786 | ||
5787 | return 0; | |
5788 | } | |
5789 | ||
fd3f6bd0 | 5790 | //! Auxiliary presentation for an image plane. |
5791 | class ViewerTest_ImagePrs : public AIS_InteractiveObject | |
5792 | { | |
5793 | public: | |
5794 | //! Main constructor. | |
5795 | ViewerTest_ImagePrs (const Handle(Image_PixMap)& theImage, | |
5796 | const Standard_Real theWidth, | |
5797 | const Standard_Real theHeight, | |
5798 | const TCollection_AsciiString& theLabel) | |
5799 | : myLabel (theLabel), myWidth (theWidth), myHeight(theHeight) | |
5800 | { | |
5801 | SetDisplayMode (0); | |
5802 | SetHilightMode (1); | |
5803 | myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost); | |
5804 | { | |
5805 | myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); | |
5806 | const Handle(Graphic3d_AspectFillArea3d)& aFillAspect = myDrawer->ShadingAspect()->Aspect(); | |
5807 | Graphic3d_MaterialAspect aMat; | |
5808 | aMat.SetMaterialType (Graphic3d_MATERIAL_PHYSIC); | |
61168418 | 5809 | aMat.SetAmbientColor (Quantity_NOC_BLACK); |
5810 | aMat.SetDiffuseColor (Quantity_NOC_WHITE); | |
5811 | aMat.SetSpecularColor (Quantity_NOC_BLACK); | |
5812 | aMat.SetEmissiveColor (Quantity_NOC_BLACK); | |
fd3f6bd0 | 5813 | aFillAspect->SetFrontMaterial (aMat); |
5814 | aFillAspect->SetTextureMap (new Graphic3d_Texture2Dmanual (theImage)); | |
5815 | aFillAspect->SetTextureMapOn(); | |
5816 | } | |
5817 | { | |
5818 | Handle(Prs3d_TextAspect) aTextAspect = new Prs3d_TextAspect(); | |
5819 | aTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER); | |
5820 | aTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); | |
5821 | myDrawer->SetTextAspect (aTextAspect); | |
5822 | } | |
5823 | { | |
5824 | const gp_Dir aNorm (0.0, 0.0, 1.0); | |
5825 | myTris = new Graphic3d_ArrayOfTriangles (4, 6, true, false, true); | |
5826 | myTris->AddVertex (gp_Pnt(-myWidth * 0.5, -myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (0.0, 0.0)); | |
5827 | myTris->AddVertex (gp_Pnt( myWidth * 0.5, -myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (1.0, 0.0)); | |
5828 | myTris->AddVertex (gp_Pnt(-myWidth * 0.5, myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (0.0, 1.0)); | |
5829 | myTris->AddVertex (gp_Pnt( myWidth * 0.5, myHeight * 0.5, 0.0), aNorm, gp_Pnt2d (1.0, 1.0)); | |
5830 | myTris->AddEdge (1); | |
5831 | myTris->AddEdge (2); | |
5832 | myTris->AddEdge (3); | |
5833 | myTris->AddEdge (3); | |
5834 | myTris->AddEdge (2); | |
5835 | myTris->AddEdge (4); | |
5836 | ||
5837 | myRect = new Graphic3d_ArrayOfPolylines (4); | |
5838 | myRect->AddVertex (myTris->Vertice (1)); | |
5839 | myRect->AddVertex (myTris->Vertice (3)); | |
5840 | myRect->AddVertex (myTris->Vertice (4)); | |
5841 | myRect->AddVertex (myTris->Vertice (2)); | |
5842 | } | |
5843 | } | |
5844 | ||
5845 | //! Returns TRUE for accepted display modes. | |
5846 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0 || theMode == 1; } | |
5847 | ||
5848 | //! Compute presentation. | |
decbff0d | 5849 | virtual void Compute (const Handle(PrsMgr_PresentationManager)& , |
5850 | const Handle(Prs3d_Presentation)& thePrs, | |
5851 | const Standard_Integer theMode) Standard_OVERRIDE | |
fd3f6bd0 | 5852 | { |
5853 | switch (theMode) | |
5854 | { | |
5855 | case 0: | |
5856 | { | |
5857 | Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); | |
5858 | aGroup->AddPrimitiveArray (myTris); | |
5859 | aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); | |
5860 | aGroup->AddPrimitiveArray (myRect); | |
5861 | aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); | |
5862 | return; | |
5863 | } | |
5864 | case 1: | |
5865 | { | |
5866 | Prs3d_Text::Draw (thePrs->NewGroup(), myDrawer->TextAspect(), myLabel, gp_Pnt(0.0, 0.0, 0.0)); | |
5867 | Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); | |
5868 | aGroup->AddPrimitiveArray (myRect); | |
5869 | aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); | |
5870 | return; | |
5871 | } | |
5872 | } | |
5873 | } | |
5874 | ||
5875 | //! Compute selection. | |
5876 | virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, const Standard_Integer theMode) Standard_OVERRIDE | |
5877 | { | |
5878 | if (theMode == 0) | |
5879 | { | |
5880 | Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 5); | |
5881 | Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anEntityOwner); | |
5882 | aSensitive->InitTriangulation (myTris->Attributes(), myTris->Indices(), TopLoc_Location()); | |
5883 | theSel->Add (aSensitive); | |
5884 | } | |
5885 | } | |
5886 | ||
5887 | private: | |
5888 | Handle(Graphic3d_ArrayOfTriangles) myTris; | |
5889 | Handle(Graphic3d_ArrayOfPolylines) myRect; | |
5890 | TCollection_AsciiString myLabel; | |
5891 | Standard_Real myWidth; | |
5892 | Standard_Real myHeight; | |
5893 | }; | |
5894 | ||
692613e5 | 5895 | //============================================================================== |
5896 | //function : VDiffImage | |
5897 | //purpose : The draw-command compares two images. | |
5898 | //============================================================================== | |
5899 | ||
5900 | static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
5901 | { | |
fd3f6bd0 | 5902 | if (theArgNb < 3) |
692613e5 | 5903 | { |
23fe70ec | 5904 | Message::SendFail ("Syntax error: not enough arguments"); |
692613e5 | 5905 | return 1; |
5906 | } | |
5907 | ||
fd3f6bd0 | 5908 | Standard_Integer anArgIter = 1; |
5909 | TCollection_AsciiString anImgPathRef (theArgVec[anArgIter++]); | |
5910 | TCollection_AsciiString anImgPathNew (theArgVec[anArgIter++]); | |
5911 | TCollection_AsciiString aDiffImagePath; | |
5912 | Standard_Real aTolColor = -1.0; | |
5913 | Standard_Integer toBlackWhite = -1; | |
5914 | Standard_Integer isBorderFilterOn = -1; | |
5915 | Standard_Boolean isOldSyntax = Standard_False; | |
5916 | TCollection_AsciiString aViewName, aPrsNameRef, aPrsNameNew, aPrsNameDiff; | |
5917 | for (; anArgIter < theArgNb; ++anArgIter) | |
5918 | { | |
5919 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
5920 | anArg.LowerCase(); | |
5921 | if (anArgIter + 1 < theArgNb | |
5922 | && (anArg == "-toleranceofcolor" | |
5923 | || anArg == "-tolerancecolor" | |
5924 | || anArg == "-tolerance" | |
5925 | || anArg == "-toler")) | |
5926 | { | |
5927 | aTolColor = Atof (theArgVec[++anArgIter]); | |
5928 | if (aTolColor < 0.0 || aTolColor > 1.0) | |
5929 | { | |
23fe70ec | 5930 | Message::SendFail() << "Syntax error at '" << anArg << " " << theArgVec[anArgIter] << "'"; |
fd3f6bd0 | 5931 | return 1; |
5932 | } | |
5933 | } | |
5934 | else if (anArg == "-blackwhite") | |
5935 | { | |
5936 | Standard_Boolean toEnable = Standard_True; | |
5937 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 5938 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
fd3f6bd0 | 5939 | { |
5940 | ++anArgIter; | |
5941 | } | |
5942 | toBlackWhite = toEnable ? 1 : 0; | |
5943 | } | |
5944 | else if (anArg == "-borderfilter") | |
5945 | { | |
5946 | Standard_Boolean toEnable = Standard_True; | |
5947 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 5948 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
fd3f6bd0 | 5949 | { |
5950 | ++anArgIter; | |
5951 | } | |
5952 | isBorderFilterOn = toEnable ? 1 : 0; | |
5953 | } | |
5954 | else if (anArg == "-exitonclose") | |
5955 | { | |
49582f9d | 5956 | ViewerTest_EventManager::ToExitOnCloseView() = true; |
fd3f6bd0 | 5957 | if (anArgIter + 1 < theArgNb |
dae2a922 | 5958 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToExitOnCloseView())) |
fd3f6bd0 | 5959 | { |
5960 | ++anArgIter; | |
5961 | } | |
5962 | } | |
5963 | else if (anArg == "-closeonescape" | |
5964 | || anArg == "-closeonesc") | |
5965 | { | |
49582f9d | 5966 | ViewerTest_EventManager::ToCloseViewOnEscape() = true; |
fd3f6bd0 | 5967 | if (anArgIter + 1 < theArgNb |
dae2a922 | 5968 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToCloseViewOnEscape())) |
fd3f6bd0 | 5969 | { |
5970 | ++anArgIter; | |
5971 | } | |
5972 | } | |
5973 | else if (anArgIter + 3 < theArgNb | |
5974 | && anArg == "-display") | |
5975 | { | |
5976 | aViewName = theArgVec[++anArgIter]; | |
5977 | aPrsNameRef = theArgVec[++anArgIter]; | |
5978 | aPrsNameNew = theArgVec[++anArgIter]; | |
5979 | if (anArgIter + 1 < theArgNb | |
5980 | && *theArgVec[anArgIter + 1] != '-') | |
5981 | { | |
5982 | aPrsNameDiff = theArgVec[++anArgIter]; | |
5983 | } | |
5984 | } | |
5985 | else if (aTolColor < 0.0 | |
d45edf24 | 5986 | && anArg.IsRealValue (Standard_True)) |
fd3f6bd0 | 5987 | { |
5988 | isOldSyntax = Standard_True; | |
5989 | aTolColor = anArg.RealValue(); | |
5990 | if (aTolColor < 0.0 || aTolColor > 1.0) | |
5991 | { | |
23fe70ec | 5992 | Message::SendFail() << "Syntax error at '" << anArg << " " << theArgVec[anArgIter] << "'"; |
fd3f6bd0 | 5993 | return 1; |
5994 | } | |
5995 | } | |
5996 | else if (isOldSyntax | |
5997 | && toBlackWhite == -1 | |
5998 | && (anArg == "0" || anArg == "1")) | |
5999 | { | |
6000 | toBlackWhite = anArg == "1" ? 1 : 0; | |
6001 | } | |
6002 | else if (isOldSyntax | |
6003 | && isBorderFilterOn == -1 | |
6004 | && (anArg == "0" || anArg == "1")) | |
6005 | { | |
6006 | isBorderFilterOn = anArg == "1" ? 1 : 0; | |
6007 | } | |
6008 | else if (aDiffImagePath.IsEmpty()) | |
6009 | { | |
6010 | aDiffImagePath = theArgVec[anArgIter]; | |
6011 | } | |
6012 | else | |
6013 | { | |
23fe70ec | 6014 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
fd3f6bd0 | 6015 | return 1; |
6016 | } | |
6017 | } | |
692613e5 | 6018 | |
fd3f6bd0 | 6019 | Handle(Image_AlienPixMap) anImgRef = new Image_AlienPixMap(); |
6020 | Handle(Image_AlienPixMap) anImgNew = new Image_AlienPixMap(); | |
6021 | if (!anImgRef->Load (anImgPathRef)) | |
6022 | { | |
23fe70ec | 6023 | Message::SendFail() << "Error: image file '" << anImgPathRef << "' cannot be read"; |
fd3f6bd0 | 6024 | return 1; |
6025 | } | |
6026 | if (!anImgNew->Load (anImgPathNew)) | |
6027 | { | |
23fe70ec | 6028 | Message::SendFail() << "Error: image file '" << anImgPathNew << "' cannot be read"; |
fd3f6bd0 | 6029 | return 1; |
6030 | } | |
692613e5 | 6031 | |
6032 | // compare the images | |
6033 | Image_Diff aComparer; | |
fd3f6bd0 | 6034 | Standard_Integer aDiffColorsNb = -1; |
6035 | if (aComparer.Init (anImgRef, anImgNew, toBlackWhite == 1)) | |
692613e5 | 6036 | { |
fd3f6bd0 | 6037 | aComparer.SetColorTolerance (aTolColor >= 0.0 ? aTolColor : 0.0); |
6038 | aComparer.SetBorderFilterOn (isBorderFilterOn == 1); | |
6039 | aDiffColorsNb = aComparer.Compare(); | |
6040 | theDI << aDiffColorsNb << "\n"; | |
692613e5 | 6041 | } |
6042 | ||
692613e5 | 6043 | // save image of difference |
fd3f6bd0 | 6044 | Handle(Image_AlienPixMap) aDiff; |
6045 | if (aDiffColorsNb > 0 | |
6046 | && (!aDiffImagePath.IsEmpty() || !aPrsNameDiff.IsEmpty())) | |
6047 | { | |
6048 | aDiff = new Image_AlienPixMap(); | |
6049 | if (!aDiff->InitTrash (Image_Format_Gray, anImgRef->SizeX(), anImgRef->SizeY())) | |
6050 | { | |
23fe70ec | 6051 | Message::SendFail() << "Error: cannot allocate memory for diff image " << anImgRef->SizeX() << "x" << anImgRef->SizeY(); |
fd3f6bd0 | 6052 | return 1; |
6053 | } | |
6054 | aComparer.SaveDiffImage (*aDiff); | |
6055 | if (!aDiffImagePath.IsEmpty() | |
6056 | && !aDiff->Save (aDiffImagePath)) | |
6057 | { | |
23fe70ec | 6058 | Message::SendFail() << "Error: diff image file '" << aDiffImagePath << "' cannot be written"; |
fd3f6bd0 | 6059 | return 1; |
6060 | } | |
6061 | } | |
6062 | ||
6063 | if (aViewName.IsEmpty()) | |
6064 | { | |
6065 | return 0; | |
6066 | } | |
6067 | ||
6068 | ViewerTest_Names aViewNames (aViewName); | |
6069 | if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName())) | |
6070 | { | |
6071 | TCollection_AsciiString aCommand = TCollection_AsciiString ("vclose ") + aViewNames.GetViewName(); | |
6072 | theDI.Eval (aCommand.ToCString()); | |
6073 | } | |
6074 | ||
6075 | Standard_Integer aPxLeft = 0; | |
6076 | Standard_Integer aPxTop = 0; | |
6077 | Standard_Integer aWinSizeX = int(anImgRef->SizeX() * 2); | |
6078 | Standard_Integer aWinSizeY = !aDiff.IsNull() && !aPrsNameDiff.IsEmpty() | |
6079 | ? int(anImgRef->SizeY() * 2) | |
6080 | : int(anImgRef->SizeY()); | |
6081 | TCollection_AsciiString aDisplayName; | |
9e04ccdc | 6082 | TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aWinSizeX, aWinSizeY, |
6083 | aViewName, aDisplayName); | |
fd3f6bd0 | 6084 | |
6085 | Standard_Real aRatio = anImgRef->Ratio(); | |
6086 | Standard_Real aSizeX = 1.0; | |
6087 | Standard_Real aSizeY = aSizeX / aRatio; | |
692613e5 | 6088 | { |
fd3f6bd0 | 6089 | OSD_Path aPath (anImgPathRef); |
6090 | TCollection_AsciiString aLabelRef; | |
6091 | if (!aPath.Name().IsEmpty()) | |
6092 | { | |
6093 | aLabelRef = aPath.Name() + aPath.Extension(); | |
6094 | } | |
6095 | aLabelRef += TCollection_AsciiString() + "\n" + int(anImgRef->SizeX()) + "x" + int(anImgRef->SizeY()); | |
6096 | ||
6097 | Handle(ViewerTest_ImagePrs) anImgRefPrs = new ViewerTest_ImagePrs (anImgRef, aSizeX, aSizeY, aLabelRef); | |
6098 | gp_Trsf aTrsfRef; | |
6099 | aTrsfRef.SetTranslationPart (gp_Vec (-aSizeX * 0.5, 0.0, 0.0)); | |
6100 | anImgRefPrs->SetLocalTransformation (aTrsfRef); | |
6101 | ViewerTest::Display (aPrsNameRef, anImgRefPrs, false, true); | |
692613e5 | 6102 | } |
fd3f6bd0 | 6103 | { |
6104 | OSD_Path aPath (anImgPathNew); | |
6105 | TCollection_AsciiString aLabelNew; | |
6106 | if (!aPath.Name().IsEmpty()) | |
6107 | { | |
6108 | aLabelNew = aPath.Name() + aPath.Extension(); | |
6109 | } | |
6110 | aLabelNew += TCollection_AsciiString() + "\n" + int(anImgNew->SizeX()) + "x" + int(anImgNew->SizeY()); | |
692613e5 | 6111 | |
fd3f6bd0 | 6112 | Handle(ViewerTest_ImagePrs) anImgNewPrs = new ViewerTest_ImagePrs (anImgNew, aSizeX, aSizeY, aLabelNew); |
6113 | gp_Trsf aTrsfRef; | |
6114 | aTrsfRef.SetTranslationPart (gp_Vec (aSizeX * 0.5, 0.0, 0.0)); | |
6115 | anImgNewPrs->SetLocalTransformation (aTrsfRef); | |
6116 | ViewerTest::Display (aPrsNameNew, anImgNewPrs, false, true); | |
6117 | } | |
6118 | Handle(ViewerTest_ImagePrs) anImgDiffPrs; | |
6119 | if (!aDiff.IsNull()) | |
6120 | { | |
6121 | anImgDiffPrs = new ViewerTest_ImagePrs (aDiff, aSizeX, aSizeY, TCollection_AsciiString() + "Difference: " + aDiffColorsNb + " pixels"); | |
6122 | gp_Trsf aTrsfDiff; | |
6123 | aTrsfDiff.SetTranslationPart (gp_Vec (0.0, -aSizeY, 0.0)); | |
6124 | anImgDiffPrs->SetLocalTransformation (aTrsfDiff); | |
6125 | } | |
6126 | if (!aPrsNameDiff.IsEmpty()) | |
6127 | { | |
6128 | ViewerTest::Display (aPrsNameDiff, anImgDiffPrs, false, true); | |
6129 | } | |
6130 | ViewerTest::CurrentView()->SetProj (V3d_Zpos); | |
6131 | ViewerTest::CurrentView()->FitAll(); | |
692613e5 | 6132 | return 0; |
6133 | } | |
6134 | ||
4754e164 | 6135 | //======================================================================= |
6136 | //function : VSelect | |
6137 | //purpose : Emulates different types of selection by mouse: | |
6138 | // 1) single click selection | |
6139 | // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2) | |
6140 | // 3) selection with polygon having corners at | |
dc3fe572 | 6141 | // pixel positions (x1,y1),...,(xn,yn) |
4754e164 | 6142 | // 4) any of these selections with shift button pressed |
6143 | //======================================================================= | |
49582f9d | 6144 | static Standard_Integer VSelect (Draw_Interpretor& , |
6145 | Standard_Integer theNbArgs, | |
6146 | const char** theArgVec) | |
4754e164 | 6147 | { |
49582f9d | 6148 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
6149 | if (aCtx.IsNull()) | |
4754e164 | 6150 | { |
23fe70ec | 6151 | Message::SendFail ("Error: no active viewer"); |
4754e164 | 6152 | return 1; |
6153 | } | |
2157d6ac | 6154 | |
49582f9d | 6155 | NCollection_Sequence<Graphic3d_Vec2i> aPnts; |
75cf8250 | 6156 | bool toAllowOverlap = false; |
6157 | AIS_SelectionScheme aSelScheme = AIS_SelectionScheme_Replace; | |
49582f9d | 6158 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) |
2157d6ac | 6159 | { |
49582f9d | 6160 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
6161 | anArg.LowerCase(); | |
6162 | if (anArg == "-allowoverlap") | |
6163 | { | |
6164 | toAllowOverlap = true; | |
6165 | if (anArgIter + 1 < theNbArgs | |
dae2a922 | 6166 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toAllowOverlap)) |
49582f9d | 6167 | { |
6168 | ++anArgIter; | |
6169 | } | |
6170 | } | |
e3d4b879 | 6171 | else if (anArg == "-replace") |
6172 | { | |
6173 | aSelScheme = AIS_SelectionScheme_Replace; | |
6174 | } | |
e76471b5 | 6175 | else if (anArg == "-replaceextra") |
6176 | { | |
6177 | aSelScheme = AIS_SelectionScheme_ReplaceExtra; | |
6178 | } | |
e3d4b879 | 6179 | else if (anArg == "-xor" |
6180 | || anArg == "-shift") | |
6181 | { | |
6182 | aSelScheme = AIS_SelectionScheme_XOR; | |
6183 | } | |
6184 | else if (anArg == "-add") | |
6185 | { | |
6186 | aSelScheme = AIS_SelectionScheme_Add; | |
6187 | } | |
6188 | else if (anArg == "-remove") | |
6189 | { | |
6190 | aSelScheme = AIS_SelectionScheme_Remove; | |
6191 | } | |
49582f9d | 6192 | else if (anArgIter + 1 < theNbArgs |
6193 | && anArg.IsIntegerValue() | |
6194 | && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue()) | |
2157d6ac | 6195 | { |
49582f9d | 6196 | const TCollection_AsciiString anArgNext (theArgVec[++anArgIter]); |
6197 | aPnts.Append (Graphic3d_Vec2i (anArg.IntegerValue(), anArgNext.IntegerValue())); | |
6198 | } | |
6199 | else if (anArgIter + 1 == theNbArgs | |
6200 | && anArg.IsIntegerValue()) | |
6201 | { | |
75cf8250 | 6202 | if (anArg.IntegerValue() == 1) |
6203 | { | |
6204 | aSelScheme = AIS_SelectionScheme_XOR; | |
6205 | } | |
49582f9d | 6206 | } |
6207 | else | |
6208 | { | |
23fe70ec | 6209 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
2157d6ac | 6210 | return 1; |
6211 | } | |
49582f9d | 6212 | } |
a24a7821 | 6213 | |
49582f9d | 6214 | if (toAllowOverlap) |
6215 | { | |
6216 | aCtx->MainSelector()->AllowOverlapDetection (toAllowOverlap); | |
2157d6ac | 6217 | } |
6218 | ||
4754e164 | 6219 | Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager(); |
49582f9d | 6220 | if (aPnts.IsEmpty()) |
4754e164 | 6221 | { |
75cf8250 | 6222 | aCtx->SelectDetected (aSelScheme); |
49582f9d | 6223 | aCtx->CurrentViewer()->Invalidate(); |
4754e164 | 6224 | } |
49582f9d | 6225 | else if (aPnts.Length() == 2) |
4754e164 | 6226 | { |
49582f9d | 6227 | if (toAllowOverlap |
6228 | && aPnts.First().y() < aPnts.Last().y()) | |
6229 | { | |
6230 | std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast()); | |
6231 | } | |
6232 | else if (!toAllowOverlap | |
6233 | && aPnts.First().y() > aPnts.Last().y()) | |
6234 | { | |
6235 | std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast()); | |
6236 | } | |
e3d4b879 | 6237 | |
6238 | aCurrentEventManager->SelectInViewer (aPnts, aSelScheme); | |
4754e164 | 6239 | } |
6240 | else | |
6241 | { | |
e3d4b879 | 6242 | aCurrentEventManager->SelectInViewer (aPnts, aSelScheme); |
4754e164 | 6243 | } |
49582f9d | 6244 | aCurrentEventManager->FlushViewEvents (aCtx, ViewerTest::CurrentView(), true); |
4754e164 | 6245 | return 0; |
6246 | } | |
6247 | ||
6248 | //======================================================================= | |
6249 | //function : VMoveTo | |
dc3fe572 | 6250 | //purpose : Emulates cursor movement to defined pixel position |
4754e164 | 6251 | //======================================================================= |
1e756cb9 | 6252 | static Standard_Integer VMoveTo (Draw_Interpretor& theDI, |
8a590580 | 6253 | Standard_Integer theNbArgs, |
6254 | const char** theArgVec) | |
4754e164 | 6255 | { |
8a590580 | 6256 | const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext(); |
6257 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); | |
6258 | if (aContext.IsNull()) | |
4754e164 | 6259 | { |
23fe70ec | 6260 | Message::SendFail ("Error: no active viewer"); |
4754e164 | 6261 | return 1; |
6262 | } | |
6263 | ||
8a590580 | 6264 | Graphic3d_Vec2i aMousePos (IntegerLast(), IntegerLast()); |
6265 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
4754e164 | 6266 | { |
8a590580 | 6267 | TCollection_AsciiString anArgStr (theArgVec[anArgIter]); |
6268 | anArgStr.LowerCase(); | |
6269 | if (anArgStr == "-reset" | |
6270 | || anArgStr == "-clear") | |
6271 | { | |
6272 | if (anArgIter + 1 < theNbArgs) | |
6273 | { | |
23fe70ec | 6274 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter + 1] << "'"; |
8a590580 | 6275 | return 1; |
6276 | } | |
6277 | ||
5634c81a | 6278 | const Standard_Boolean toEchoGrid = aContext->CurrentViewer()->IsGridActive() |
8a590580 | 6279 | && aContext->CurrentViewer()->GridEcho(); |
6280 | if (toEchoGrid) | |
6281 | { | |
6282 | aContext->CurrentViewer()->HideGridEcho (aView); | |
6283 | } | |
6284 | if (aContext->ClearDetected() || toEchoGrid) | |
6285 | { | |
6286 | aContext->CurrentViewer()->RedrawImmediate(); | |
6287 | } | |
6288 | return 0; | |
6289 | } | |
6290 | else if (aMousePos.x() == IntegerLast() | |
6291 | && anArgStr.IsIntegerValue()) | |
6292 | { | |
6293 | aMousePos.x() = anArgStr.IntegerValue(); | |
6294 | } | |
6295 | else if (aMousePos.y() == IntegerLast() | |
6296 | && anArgStr.IsIntegerValue()) | |
6297 | { | |
6298 | aMousePos.y() = anArgStr.IntegerValue(); | |
6299 | } | |
6300 | else | |
6301 | { | |
23fe70ec | 6302 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
8a590580 | 6303 | return 1; |
6304 | } | |
6305 | } | |
6306 | ||
6307 | if (aMousePos.x() == IntegerLast() | |
6308 | || aMousePos.y() == IntegerLast()) | |
6309 | { | |
23fe70ec | 6310 | Message::SendFail ("Syntax error: wrong number of arguments"); |
4754e164 | 6311 | return 1; |
6312 | } | |
8a590580 | 6313 | |
49582f9d | 6314 | ViewerTest::CurrentEventManager()->ResetPreviousMoveTo(); |
6315 | ViewerTest::CurrentEventManager()->UpdateMousePosition (aMousePos, Aspect_VKeyMouse_NONE, Aspect_VKeyFlags_NONE, false); | |
6316 | ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true); | |
6317 | ||
1e756cb9 | 6318 | gp_Pnt aTopPnt (RealLast(), RealLast(), RealLast()); |
6319 | const Handle(SelectMgr_EntityOwner)& aDetOwner = aContext->DetectedOwner(); | |
6320 | for (Standard_Integer aDetIter = 1; aDetIter <= aContext->MainSelector()->NbPicked(); ++aDetIter) | |
6321 | { | |
6322 | if (aContext->MainSelector()->Picked (aDetIter) == aDetOwner) | |
6323 | { | |
6324 | aTopPnt = aContext->MainSelector()->PickedPoint (aDetIter); | |
6325 | break; | |
6326 | } | |
6327 | } | |
6328 | theDI << aTopPnt.X() << " " << aTopPnt.Y() << " " << aTopPnt.Z(); | |
4754e164 | 6329 | return 0; |
6330 | } | |
6331 | ||
0461e7fd | 6332 | //======================================================================= |
6333 | //function : VSelectByAxis | |
6334 | //purpose : | |
6335 | //======================================================================= | |
6336 | static Standard_Integer VSelectByAxis (Draw_Interpretor& theDI, | |
6337 | Standard_Integer theNbArgs, | |
6338 | const char** theArgVec) | |
6339 | { | |
6340 | const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext(); | |
6341 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); | |
6342 | if (aContext.IsNull()) | |
6343 | { | |
6344 | Message::SendFail ("Error: no active viewer"); | |
6345 | return 1; | |
6346 | } | |
6347 | ||
6348 | TCollection_AsciiString aName; | |
6349 | gp_XYZ anAxisLocation(RealLast(), RealLast(), RealLast()); | |
6350 | gp_XYZ anAxisDirection(RealLast(), RealLast(), RealLast()); | |
6351 | Standard_Boolean isOnlyTop = true; | |
6352 | Standard_Boolean toShowNormal = false; | |
6353 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
6354 | { | |
6355 | TCollection_AsciiString anArgStr (theArgVec[anArgIter]); | |
6356 | anArgStr.LowerCase(); | |
6357 | if (anArgStr == "-display") | |
6358 | { | |
6359 | if (anArgIter + 1 >= theNbArgs) | |
6360 | { | |
6361 | Message::SendFail() << "Syntax error at argument '" << anArgStr << "'"; | |
6362 | return 1; | |
6363 | } | |
6364 | aName = theArgVec[++anArgIter]; | |
6365 | } | |
6366 | else if (anArgStr == "-onlytop") | |
6367 | { | |
6368 | isOnlyTop = true; | |
6369 | if (anArgIter + 1 < theNbArgs | |
6370 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], isOnlyTop)) | |
6371 | { | |
6372 | ++anArgIter; | |
6373 | } | |
6374 | } | |
6375 | else if (anArgStr == "-shownormal") | |
6376 | { | |
6377 | toShowNormal = true; | |
6378 | if (anArgIter + 1 < theNbArgs | |
6379 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toShowNormal)) | |
6380 | { | |
6381 | ++anArgIter; | |
6382 | } | |
6383 | } | |
6384 | else if (Precision::IsInfinite(anAxisLocation.X()) | |
6385 | && anArgStr.IsRealValue()) | |
6386 | { | |
6387 | anAxisLocation.SetX (anArgStr.RealValue()); | |
6388 | } | |
6389 | else if (Precision::IsInfinite(anAxisLocation.Y()) | |
6390 | && anArgStr.IsRealValue()) | |
6391 | { | |
6392 | anAxisLocation.SetY (anArgStr.RealValue()); | |
6393 | } | |
6394 | else if (Precision::IsInfinite(anAxisLocation.Z()) | |
6395 | && anArgStr.IsRealValue()) | |
6396 | { | |
6397 | anAxisLocation.SetZ (anArgStr.RealValue()); | |
6398 | } | |
6399 | else if (Precision::IsInfinite(anAxisDirection.X()) | |
6400 | && anArgStr.IsRealValue()) | |
6401 | { | |
6402 | anAxisDirection.SetX (anArgStr.RealValue()); | |
6403 | } | |
6404 | else if (Precision::IsInfinite(anAxisDirection.Y()) | |
6405 | && anArgStr.IsRealValue()) | |
6406 | { | |
6407 | anAxisDirection.SetY (anArgStr.RealValue()); | |
6408 | } | |
6409 | else if (Precision::IsInfinite(anAxisDirection.Z()) | |
6410 | && anArgStr.IsRealValue()) | |
6411 | { | |
6412 | anAxisDirection.SetZ (anArgStr.RealValue()); | |
6413 | } | |
6414 | else | |
6415 | { | |
6416 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
6417 | return 1; | |
6418 | } | |
6419 | } | |
6420 | ||
6421 | if (Precision::IsInfinite (anAxisLocation.X()) || | |
6422 | Precision::IsInfinite (anAxisLocation.Y()) || | |
6423 | Precision::IsInfinite (anAxisLocation.Z()) || | |
6424 | Precision::IsInfinite (anAxisDirection.X()) || | |
6425 | Precision::IsInfinite (anAxisDirection.Y()) || | |
6426 | Precision::IsInfinite (anAxisDirection.Z())) | |
6427 | { | |
6428 | Message::SendFail() << "Invalid axis location and direction"; | |
6429 | return 1; | |
6430 | } | |
6431 | ||
6432 | gp_Ax1 anAxis(anAxisLocation, anAxisDirection); | |
6433 | gp_Pnt aTopPnt; | |
6434 | if (!ViewerTest::CurrentEventManager()->PickAxis (aTopPnt, aContext, aView, anAxis)) | |
6435 | { | |
6436 | theDI << "There are no any intersections with this axis."; | |
6437 | return 0; | |
6438 | } | |
6439 | NCollection_Sequence<gp_Pnt> aPoints; | |
6440 | NCollection_Sequence<Graphic3d_Vec3> aNormals; | |
6441 | NCollection_Sequence<Standard_Real> aNormalLengths; | |
6442 | for (Standard_Integer aPickIter = 1; aPickIter <= aContext->MainSelector()->NbPicked(); ++aPickIter) | |
6443 | { | |
6444 | const SelectMgr_SortCriterion& aPickedData = aContext->MainSelector()->PickedData (aPickIter); | |
6445 | aPoints.Append (aPickedData.Point); | |
6446 | aNormals.Append (aPickedData.Normal); | |
6447 | Standard_Real aNormalLength = 1.0; | |
6448 | if (!aPickedData.Entity.IsNull()) | |
6449 | { | |
6450 | aNormalLength = 0.2 * aPickedData.Entity->BoundingBox().Size().maxComp(); | |
6451 | } | |
6452 | aNormalLengths.Append (aNormalLength); | |
6453 | } | |
6454 | if (!aName.IsEmpty()) | |
6455 | { | |
6456 | Standard_Boolean wasAuto = aContext->GetAutoActivateSelection(); | |
6457 | aContext->SetAutoActivateSelection (false); | |
6458 | ||
6459 | // Display axis | |
6460 | Quantity_Color anAxisColor = Quantity_NOC_GREEN; | |
6461 | Handle(Geom_Axis2Placement) anAx2Axis = | |
6462 | new Geom_Axis2Placement (gp_Ax2(anAxisLocation, anAxisDirection)); | |
1f3c5058 | 6463 | Handle(AIS_Axis) anAISAxis = new AIS_Axis (gp_Ax1 (anAxisLocation, anAxisDirection)); |
6464 | anAISAxis->SetColor (anAxisColor); | |
6465 | ViewerTest::Display (TCollection_AsciiString (aName) + "_axis", anAISAxis, false); | |
0461e7fd | 6466 | |
6467 | // Display axis start point | |
6468 | Handle(AIS_Point) anAISStartPnt = new AIS_Point (new Geom_CartesianPoint (anAxisLocation)); | |
6469 | anAISStartPnt->SetMarker (Aspect_TOM_O); | |
6470 | anAISStartPnt->SetColor (anAxisColor); | |
6471 | ViewerTest::Display (TCollection_AsciiString(aName) + "_start", anAISStartPnt, false); | |
6472 | ||
6473 | Standard_Integer anIndex = 0; | |
6474 | for (NCollection_Sequence<gp_Pnt>::Iterator aPntIter(aPoints); aPntIter.More(); aPntIter.Next(), anIndex++) | |
6475 | { | |
6476 | const gp_Pnt& aPoint = aPntIter.Value(); | |
6477 | ||
6478 | // Display normals in intersection points | |
6479 | if (toShowNormal) | |
6480 | { | |
6481 | const Graphic3d_Vec3& aNormal = aNormals.Value (anIndex + 1); | |
6482 | Standard_Real aNormalLength = aNormalLengths.Value (anIndex + 1); | |
6483 | if (aNormal.SquareModulus() > ShortRealEpsilon()) | |
6484 | { | |
1f3c5058 | 6485 | gp_Dir aNormalDir ((Standard_Real)aNormal.x(), (Standard_Real)aNormal.y(), (Standard_Real)aNormal.z()); |
6486 | Handle(AIS_Axis) anAISNormal = new AIS_Axis (gp_Ax1 (aPoint, aNormalDir), aNormalLength); | |
0461e7fd | 6487 | anAISNormal->SetColor (Quantity_NOC_BLUE); |
0461e7fd | 6488 | anAISNormal->SetInfiniteState (false); |
6489 | ViewerTest::Display (TCollection_AsciiString(aName) + "_normal_" + anIndex, anAISNormal, false); | |
6490 | } | |
6491 | } | |
6492 | ||
6493 | // Display intersection points | |
6494 | Handle(Geom_CartesianPoint) anIntersectPnt = new Geom_CartesianPoint (aPoint); | |
6495 | Handle(AIS_Point) anAISIntersectPoint = new AIS_Point (anIntersectPnt); | |
6496 | anAISIntersectPoint->SetMarker (Aspect_TOM_PLUS); | |
6497 | anAISIntersectPoint->SetColor (Quantity_NOC_RED); | |
6498 | ViewerTest::Display (TCollection_AsciiString(aName) + "_intersect_" + anIndex, anAISIntersectPoint, true); | |
6499 | } | |
6500 | ||
6501 | aContext->SetAutoActivateSelection (wasAuto); | |
6502 | } | |
6503 | ||
6504 | Standard_Integer anIndex = 0; | |
6505 | for (NCollection_Sequence<gp_Pnt>::Iterator anIter(aPoints); anIter.More(); anIter.Next(), anIndex++) | |
6506 | { | |
6507 | const gp_Pnt& aPnt = anIter.Value(); | |
6508 | theDI << aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z() << "\n"; | |
6509 | } | |
6510 | return 0; | |
6511 | } | |
6512 | ||
1beb58d7 | 6513 | namespace |
6514 | { | |
6515 | //! Global map storing all animations registered in ViewerTest. | |
6516 | static NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)> ViewerTest_AnimationTimelineMap; | |
6517 | ||
6518 | //! The animation calling the Draw Harness command. | |
6519 | class ViewerTest_AnimationProc : public AIS_Animation | |
6520 | { | |
8f709595 | 6521 | DEFINE_STANDARD_RTTI_INLINE(ViewerTest_AnimationProc, AIS_Animation) |
1beb58d7 | 6522 | public: |
6523 | ||
6524 | //! Main constructor. | |
6525 | ViewerTest_AnimationProc (const TCollection_AsciiString& theAnimationName, | |
6526 | Draw_Interpretor* theDI, | |
6527 | const TCollection_AsciiString& theCommand) | |
6528 | : AIS_Animation (theAnimationName), | |
6529 | myDrawInter(theDI), | |
6530 | myCommand (theCommand) | |
6531 | { | |
6532 | // | |
6533 | } | |
6534 | ||
6535 | protected: | |
6536 | ||
6537 | //! Evaluate the command. | |
6538 | virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE | |
6539 | { | |
6540 | TCollection_AsciiString aCmd = myCommand; | |
6541 | replace (aCmd, "%pts", TCollection_AsciiString(theProgress.Pts)); | |
6542 | replace (aCmd, "%localpts", TCollection_AsciiString(theProgress.LocalPts)); | |
6543 | replace (aCmd, "%ptslocal", TCollection_AsciiString(theProgress.LocalPts)); | |
6544 | replace (aCmd, "%normalized", TCollection_AsciiString(theProgress.LocalNormalized)); | |
6545 | replace (aCmd, "%localnormalized", TCollection_AsciiString(theProgress.LocalNormalized)); | |
6546 | myDrawInter->Eval (aCmd.ToCString()); | |
6547 | } | |
6548 | ||
6549 | //! Find the keyword in the command and replace it with value. | |
6550 | //! @return the position of the keyword to pass value | |
6551 | void replace (TCollection_AsciiString& theCmd, | |
6552 | const TCollection_AsciiString& theKey, | |
6553 | const TCollection_AsciiString& theVal) | |
6554 | { | |
6555 | TCollection_AsciiString aCmd (theCmd); | |
6556 | aCmd.LowerCase(); | |
6557 | const Standard_Integer aPos = aCmd.Search (theKey); | |
6558 | if (aPos == -1) | |
6559 | { | |
6560 | return; | |
6561 | } | |
6562 | ||
6563 | TCollection_AsciiString aPart1, aPart2; | |
6564 | Standard_Integer aPart1To = aPos - 1; | |
6565 | if (aPart1To >= 1 | |
6566 | && aPart1To <= theCmd.Length()) | |
6567 | { | |
6568 | aPart1 = theCmd.SubString (1, aPart1To); | |
6569 | } | |
6570 | ||
6571 | Standard_Integer aPart2From = aPos + theKey.Length(); | |
6572 | if (aPart2From >= 1 | |
6573 | && aPart2From <= theCmd.Length()) | |
6574 | { | |
6575 | aPart2 = theCmd.SubString (aPart2From, theCmd.Length()); | |
6576 | } | |
6577 | ||
6578 | theCmd = aPart1 + theVal + aPart2; | |
6579 | } | |
6580 | ||
6581 | protected: | |
6582 | ||
6583 | Draw_Interpretor* myDrawInter; | |
6584 | TCollection_AsciiString myCommand; | |
6585 | ||
6586 | }; | |
6587 | ||
8f709595 | 6588 | //! Auxiliary animation holder. |
6589 | class ViewerTest_AnimationHolder : public AIS_AnimationCamera | |
6590 | { | |
6591 | DEFINE_STANDARD_RTTI_INLINE(ViewerTest_AnimationHolder, AIS_AnimationCamera) | |
6592 | public: | |
6593 | ViewerTest_AnimationHolder (const Handle(AIS_Animation)& theAnim, | |
6594 | const Handle(V3d_View)& theView, | |
6595 | const Standard_Boolean theIsFreeView) | |
6596 | : AIS_AnimationCamera ("ViewerTest_AnimationHolder", Handle(V3d_View)()) | |
6597 | { | |
6598 | if (theAnim->Timer().IsNull()) | |
6599 | { | |
6600 | theAnim->SetTimer (new Media_Timer()); | |
6601 | } | |
6602 | myTimer = theAnim->Timer(); | |
6603 | myView = theView; | |
6604 | if (theIsFreeView) | |
6605 | { | |
6606 | myCamStart = new Graphic3d_Camera (theView->Camera()); | |
6607 | } | |
6608 | Add (theAnim); | |
6609 | } | |
6610 | ||
6611 | //! Start playback. | |
6612 | virtual void StartTimer (const Standard_Real theStartPts, | |
6613 | const Standard_Real thePlaySpeed, | |
6614 | const Standard_Boolean theToUpdate, | |
6615 | const Standard_Boolean theToStopTimer) Standard_OVERRIDE | |
6616 | { | |
6617 | base_type::StartTimer (theStartPts, thePlaySpeed, theToUpdate, theToStopTimer); | |
6618 | if (theToStopTimer) | |
6619 | { | |
6620 | abortPlayback(); | |
6621 | } | |
6622 | } | |
6623 | ||
6624 | //! Pause animation. | |
6625 | virtual void Pause() Standard_OVERRIDE | |
6626 | { | |
6627 | myState = AnimationState_Paused; | |
6628 | // default implementation would stop all children, | |
6629 | // but we want to keep wrapped animation paused | |
6630 | myAnimations.First()->Pause(); | |
6631 | abortPlayback(); | |
6632 | } | |
6633 | ||
6634 | //! Stop animation. | |
6635 | virtual void Stop() Standard_OVERRIDE | |
6636 | { | |
6637 | base_type::Stop(); | |
6638 | abortPlayback(); | |
6639 | } | |
6640 | ||
6641 | //! Process one step of the animation according to the input time progress, including all children. | |
6642 | virtual void updateWithChildren (const AIS_AnimationProgress& thePosition) Standard_OVERRIDE | |
6643 | { | |
6644 | Handle(V3d_View) aView = myView; | |
6645 | if (!aView.IsNull() | |
6646 | && !myCamStart.IsNull()) | |
6647 | { | |
6648 | myCamStart->Copy (aView->Camera()); | |
6649 | } | |
6650 | base_type::updateWithChildren (thePosition); | |
6651 | if (!aView.IsNull() | |
6652 | && !myCamStart.IsNull()) | |
6653 | { | |
6654 | aView->Camera()->Copy (myCamStart); | |
6655 | } | |
6656 | } | |
6657 | private: | |
6658 | void abortPlayback() | |
6659 | { | |
6660 | if (!myView.IsNull()) | |
6661 | { | |
6662 | myView.Nullify(); | |
6663 | } | |
6664 | } | |
6665 | }; | |
6666 | ||
1beb58d7 | 6667 | //! Replace the animation with the new one. |
6668 | static void replaceAnimation (const Handle(AIS_Animation)& theParentAnimation, | |
6669 | Handle(AIS_Animation)& theAnimation, | |
6670 | const Handle(AIS_Animation)& theAnimationNew) | |
6671 | { | |
6672 | theAnimationNew->CopyFrom (theAnimation); | |
6673 | if (!theParentAnimation.IsNull()) | |
6674 | { | |
6675 | theParentAnimation->Replace (theAnimation, theAnimationNew); | |
6676 | } | |
6677 | else | |
6678 | { | |
6679 | ViewerTest_AnimationTimelineMap.UnBind (theAnimationNew->Name()); | |
6680 | ViewerTest_AnimationTimelineMap.Bind (theAnimationNew->Name(), theAnimationNew); | |
6681 | } | |
6682 | theAnimation = theAnimationNew; | |
6683 | } | |
6684 | ||
6685 | //! Parse the point. | |
6686 | static Standard_Boolean parseXYZ (const char** theArgVec, gp_XYZ& thePnt) | |
6687 | { | |
6688 | const TCollection_AsciiString anXYZ[3] = { theArgVec[0], theArgVec[1], theArgVec[2] }; | |
d45edf24 | 6689 | if (!anXYZ[0].IsRealValue (Standard_True) |
6690 | || !anXYZ[1].IsRealValue (Standard_True) | |
6691 | || !anXYZ[2].IsRealValue (Standard_True)) | |
1beb58d7 | 6692 | { |
6693 | return Standard_False; | |
6694 | } | |
6695 | ||
6696 | thePnt.SetCoord (anXYZ[0].RealValue(), anXYZ[1].RealValue(), anXYZ[2].RealValue()); | |
6697 | return Standard_True; | |
6698 | } | |
6699 | ||
6700 | //! Parse the quaternion. | |
6701 | static Standard_Boolean parseQuaternion (const char** theArgVec, gp_Quaternion& theQRot) | |
6702 | { | |
6703 | const TCollection_AsciiString anXYZW[4] = {theArgVec[0], theArgVec[1], theArgVec[2], theArgVec[3]}; | |
d45edf24 | 6704 | if (!anXYZW[0].IsRealValue (Standard_True) |
6705 | || !anXYZW[1].IsRealValue (Standard_True) | |
6706 | || !anXYZW[2].IsRealValue (Standard_True) | |
6707 | || !anXYZW[3].IsRealValue (Standard_True)) | |
1beb58d7 | 6708 | { |
6709 | return Standard_False; | |
6710 | } | |
6711 | ||
6712 | theQRot.Set (anXYZW[0].RealValue(), anXYZW[1].RealValue(), anXYZW[2].RealValue(), anXYZW[3].RealValue()); | |
6713 | return Standard_True; | |
6714 | } | |
6715 | ||
08f8a185 | 6716 | //! Auxiliary class for flipping image upside-down. |
6717 | class ImageFlipper | |
6718 | { | |
6719 | public: | |
6720 | ||
6721 | //! Empty constructor. | |
6722 | ImageFlipper() : myTmp (NCollection_BaseAllocator::CommonBaseAllocator()) {} | |
6723 | ||
6724 | //! Perform flipping. | |
6725 | Standard_Boolean FlipY (Image_PixMap& theImage) | |
6726 | { | |
6727 | if (theImage.IsEmpty() | |
6728 | || theImage.SizeX() == 0 | |
6729 | || theImage.SizeY() == 0) | |
6730 | { | |
6731 | return Standard_False; | |
6732 | } | |
6733 | ||
6734 | const Standard_Size aRowSize = theImage.SizeRowBytes(); | |
6735 | if (myTmp.Size() < aRowSize | |
6736 | && !myTmp.Allocate (aRowSize)) | |
6737 | { | |
6738 | return Standard_False; | |
6739 | } | |
6740 | ||
6741 | // for odd height middle row should be left as is | |
6742 | Standard_Size aNbRowsHalf = theImage.SizeY() / 2; | |
6743 | for (Standard_Size aRowT = 0, aRowB = theImage.SizeY() - 1; aRowT < aNbRowsHalf; ++aRowT, --aRowB) | |
6744 | { | |
6745 | Standard_Byte* aTop = theImage.ChangeRow (aRowT); | |
6746 | Standard_Byte* aBot = theImage.ChangeRow (aRowB); | |
6747 | memcpy (myTmp.ChangeData(), aTop, aRowSize); | |
6748 | memcpy (aTop, aBot, aRowSize); | |
6749 | memcpy (aBot, myTmp.Data(), aRowSize); | |
6750 | } | |
6751 | return Standard_True; | |
6752 | } | |
6753 | ||
6754 | private: | |
6755 | NCollection_Buffer myTmp; | |
6756 | }; | |
6757 | ||
1beb58d7 | 6758 | } |
6759 | ||
197ac94e | 6760 | //================================================================================================= |
4754e164 | 6761 | //function : VViewParams |
dc3fe572 | 6762 | //purpose : Gets or sets AIS View characteristics |
197ac94e | 6763 | //================================================================================================= |
6764 | static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
4754e164 | 6765 | { |
1beb58d7 | 6766 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
6767 | if (aView.IsNull()) | |
4754e164 | 6768 | { |
23fe70ec | 6769 | Message::SendFail ("Error: no active viewer"); |
4754e164 | 6770 | return 1; |
6771 | } | |
197ac94e | 6772 | |
1beb58d7 | 6773 | Standard_Boolean toSetProj = Standard_False; |
6774 | Standard_Boolean toSetUp = Standard_False; | |
6775 | Standard_Boolean toSetAt = Standard_False; | |
6776 | Standard_Boolean toSetEye = Standard_False; | |
6777 | Standard_Boolean toSetScale = Standard_False; | |
6778 | Standard_Boolean toSetSize = Standard_False; | |
6779 | Standard_Boolean toSetCenter2d = Standard_False; | |
ee2be2a8 | 6780 | Standard_Real aViewScale = aView->Scale(); |
168c27c6 | 6781 | Standard_Real aViewAspect = aView->Camera()->Aspect(); |
ee2be2a8 | 6782 | Standard_Real aViewSize = 1.0; |
1beb58d7 | 6783 | Graphic3d_Vec2i aCenter2d; |
6784 | gp_XYZ aViewProj, aViewUp, aViewAt, aViewEye; | |
6785 | aView->Proj (aViewProj.ChangeCoord (1), aViewProj.ChangeCoord (2), aViewProj.ChangeCoord (3)); | |
6786 | aView->Up (aViewUp .ChangeCoord (1), aViewUp .ChangeCoord (2), aViewUp .ChangeCoord (3)); | |
6787 | aView->At (aViewAt .ChangeCoord (1), aViewAt .ChangeCoord (2), aViewAt .ChangeCoord (3)); | |
6788 | aView->Eye (aViewEye .ChangeCoord (1), aViewEye .ChangeCoord (2), aViewEye .ChangeCoord (3)); | |
168c27c6 | 6789 | const Graphic3d_Mat4d& anOrientMat = aView->Camera()->OrientationMatrix(); |
6790 | const Graphic3d_Mat4d& aProjMat = aView->Camera()->ProjectionMatrix(); | |
197ac94e | 6791 | if (theArgsNb == 1) |
4754e164 | 6792 | { |
197ac94e | 6793 | // print all of the available view parameters |
1beb58d7 | 6794 | char aText[4096]; |
6795 | Sprintf (aText, | |
168c27c6 | 6796 | "Scale: %g\n" |
6797 | "Aspect: %g\n" | |
6798 | "Proj: %12g %12g %12g\n" | |
6799 | "Up: %12g %12g %12g\n" | |
6800 | "At: %12g %12g %12g\n" | |
6801 | "Eye: %12g %12g %12g\n" | |
6802 | "OrientMat: %12g %12g %12g %12g\n" | |
6803 | " %12g %12g %12g %12g\n" | |
6804 | " %12g %12g %12g %12g\n" | |
6805 | " %12g %12g %12g %12g\n" | |
6806 | "ProjMat: %12g %12g %12g %12g\n" | |
6807 | " %12g %12g %12g %12g\n" | |
6808 | " %12g %12g %12g %12g\n" | |
6809 | " %12g %12g %12g %12g\n", | |
6810 | aViewScale, aViewAspect, | |
1beb58d7 | 6811 | aViewProj.X(), aViewProj.Y(), aViewProj.Z(), |
6812 | aViewUp.X(), aViewUp.Y(), aViewUp.Z(), | |
6813 | aViewAt.X(), aViewAt.Y(), aViewAt.Z(), | |
168c27c6 | 6814 | aViewEye.X(), aViewEye.Y(), aViewEye.Z(), |
6815 | anOrientMat.GetValue (0, 0), anOrientMat.GetValue (0, 1), anOrientMat.GetValue (0, 2), anOrientMat.GetValue (0, 3), | |
6816 | anOrientMat.GetValue (1, 0), anOrientMat.GetValue (1, 1), anOrientMat.GetValue (1, 2), anOrientMat.GetValue (1, 3), | |
6817 | anOrientMat.GetValue (2, 0), anOrientMat.GetValue (2, 1), anOrientMat.GetValue (2, 2), anOrientMat.GetValue (2, 3), | |
6818 | anOrientMat.GetValue (3, 0), anOrientMat.GetValue (3, 1), anOrientMat.GetValue (3, 2), anOrientMat.GetValue (3, 3), | |
6819 | aProjMat.GetValue (0, 0), aProjMat.GetValue (0, 1), aProjMat.GetValue (0, 2), aProjMat.GetValue (0, 3), | |
6820 | aProjMat.GetValue (1, 0), aProjMat.GetValue (1, 1), aProjMat.GetValue (1, 2), aProjMat.GetValue (1, 3), | |
6821 | aProjMat.GetValue (2, 0), aProjMat.GetValue (2, 1), aProjMat.GetValue (2, 2), aProjMat.GetValue (2, 3), | |
6822 | aProjMat.GetValue (3, 0), aProjMat.GetValue (3, 1), aProjMat.GetValue (3, 2), aProjMat.GetValue (3, 3)); | |
1beb58d7 | 6823 | theDi << aText; |
197ac94e | 6824 | return 0; |
4754e164 | 6825 | } |
197ac94e | 6826 | |
1beb58d7 | 6827 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
6828 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
197ac94e | 6829 | { |
1beb58d7 | 6830 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
6831 | anArg.LowerCase(); | |
6832 | if (anUpdateTool.parseRedrawMode (anArg)) | |
197ac94e | 6833 | { |
197ac94e | 6834 | continue; |
6835 | } | |
1beb58d7 | 6836 | else if (anArg == "-cmd" |
6837 | || anArg == "-command" | |
6838 | || anArg == "-args") | |
6839 | { | |
6840 | char aText[4096]; | |
6841 | Sprintf (aText, | |
6842 | "-scale %g " | |
6843 | "-proj %g %g %g " | |
6844 | "-up %g %g %g " | |
6845 | "-at %g %g %g\n", | |
6846 | aViewScale, | |
6847 | aViewProj.X(), aViewProj.Y(), aViewProj.Z(), | |
6848 | aViewUp.X(), aViewUp.Y(), aViewUp.Z(), | |
6849 | aViewAt.X(), aViewAt.Y(), aViewAt.Z()); | |
6850 | theDi << aText; | |
6851 | } | |
6852 | else if (anArg == "-scale" | |
6853 | || anArg == "-size") | |
6854 | { | |
6855 | if (anArgIter + 1 < theArgsNb | |
6856 | && *theArgVec[anArgIter + 1] != '-') | |
6857 | { | |
6858 | const TCollection_AsciiString aValueArg (theArgVec[anArgIter + 1]); | |
d45edf24 | 6859 | if (aValueArg.IsRealValue (Standard_True)) |
1beb58d7 | 6860 | { |
6861 | ++anArgIter; | |
6862 | if (anArg == "-scale") | |
6863 | { | |
6864 | toSetScale = Standard_True; | |
6865 | aViewScale = aValueArg.RealValue(); | |
6866 | } | |
6867 | else if (anArg == "-size") | |
6868 | { | |
6869 | toSetSize = Standard_True; | |
6870 | aViewSize = aValueArg.RealValue(); | |
6871 | } | |
6872 | continue; | |
6873 | } | |
6874 | } | |
6875 | if (anArg == "-scale") | |
6876 | { | |
6877 | theDi << "Scale: " << aView->Scale() << "\n"; | |
6878 | } | |
6879 | else if (anArg == "-size") | |
6880 | { | |
6881 | Graphic3d_Vec2d aSizeXY; | |
6882 | aView->Size (aSizeXY.x(), aSizeXY.y()); | |
6883 | theDi << "Size: " << aSizeXY.x() << " " << aSizeXY.y() << "\n"; | |
6884 | } | |
6885 | } | |
6886 | else if (anArg == "-eye" | |
6887 | || anArg == "-at" | |
6888 | || anArg == "-up" | |
6889 | || anArg == "-proj") | |
6890 | { | |
6891 | if (anArgIter + 3 < theArgsNb) | |
6892 | { | |
6893 | gp_XYZ anXYZ; | |
6894 | if (parseXYZ (theArgVec + anArgIter + 1, anXYZ)) | |
6895 | { | |
6896 | anArgIter += 3; | |
6897 | if (anArg == "-eye") | |
6898 | { | |
6899 | toSetEye = Standard_True; | |
6900 | aViewEye = anXYZ; | |
6901 | } | |
6902 | else if (anArg == "-at") | |
6903 | { | |
6904 | toSetAt = Standard_True; | |
6905 | aViewAt = anXYZ; | |
6906 | } | |
6907 | else if (anArg == "-up") | |
6908 | { | |
6909 | toSetUp = Standard_True; | |
6910 | aViewUp = anXYZ; | |
6911 | } | |
6912 | else if (anArg == "-proj") | |
6913 | { | |
6914 | toSetProj = Standard_True; | |
6915 | aViewProj = anXYZ; | |
6916 | } | |
6917 | continue; | |
6918 | } | |
6919 | } | |
197ac94e | 6920 | |
1beb58d7 | 6921 | if (anArg == "-eye") |
6922 | { | |
6923 | theDi << "Eye: " << aViewEye.X() << " " << aViewEye.Y() << " " << aViewEye.Z() << "\n"; | |
6924 | } | |
6925 | else if (anArg == "-at") | |
6926 | { | |
6927 | theDi << "At: " << aViewAt.X() << " " << aViewAt.Y() << " " << aViewAt.Z() << "\n"; | |
6928 | } | |
6929 | else if (anArg == "-up") | |
6930 | { | |
6931 | theDi << "Up: " << aViewUp.X() << " " << aViewUp.Y() << " " << aViewUp.Z() << "\n"; | |
6932 | } | |
6933 | else if (anArg == "-proj") | |
6934 | { | |
6935 | theDi << "Proj: " << aViewProj.X() << " " << aViewProj.Y() << " " << aViewProj.Z() << "\n"; | |
6936 | } | |
6937 | } | |
6938 | else if (anArg == "-center") | |
3dfe95cd | 6939 | { |
1beb58d7 | 6940 | if (anArgIter + 2 < theArgsNb) |
6941 | { | |
6942 | const TCollection_AsciiString anX (theArgVec[anArgIter + 1]); | |
6943 | const TCollection_AsciiString anY (theArgVec[anArgIter + 2]); | |
6944 | if (anX.IsIntegerValue() | |
6945 | && anY.IsIntegerValue()) | |
6946 | { | |
6947 | toSetCenter2d = Standard_True; | |
6948 | aCenter2d = Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue()); | |
6949 | } | |
6950 | } | |
6951 | } | |
6952 | else | |
6953 | { | |
23fe70ec | 6954 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
3dfe95cd | 6955 | return 1; |
6956 | } | |
1beb58d7 | 6957 | } |
3dfe95cd | 6958 | |
1beb58d7 | 6959 | // change view parameters in proper order |
6960 | if (toSetScale) | |
6961 | { | |
6962 | aView->SetScale (aViewScale); | |
6963 | } | |
6964 | if (toSetSize) | |
6965 | { | |
6966 | aView->SetSize (aViewSize); | |
6967 | } | |
6968 | if (toSetEye) | |
6969 | { | |
6970 | aView->SetEye (aViewEye.X(), aViewEye.Y(), aViewEye.Z()); | |
6971 | } | |
6972 | if (toSetAt) | |
6973 | { | |
6974 | aView->SetAt (aViewAt.X(), aViewAt.Y(), aViewAt.Z()); | |
6975 | } | |
6976 | if (toSetProj) | |
6977 | { | |
6978 | aView->SetProj (aViewProj.X(), aViewProj.Y(), aViewProj.Z()); | |
6979 | } | |
6980 | if (toSetUp) | |
6981 | { | |
6982 | aView->SetUp (aViewUp.X(), aViewUp.Y(), aViewUp.Z()); | |
6983 | } | |
6984 | if (toSetCenter2d) | |
6985 | { | |
6986 | aView->SetCenter (aCenter2d.x(), aCenter2d.y()); | |
197ac94e | 6987 | } |
6988 | ||
1beb58d7 | 6989 | return 0; |
6990 | } | |
197ac94e | 6991 | |
2e93433e | 6992 | //============================================================================== |
6993 | //function : V2DMode | |
6994 | //purpose : | |
6995 | //============================================================================== | |
6996 | static Standard_Integer V2DMode (Draw_Interpretor&, Standard_Integer theArgsNb, const char** theArgVec) | |
6997 | { | |
6998 | bool is2dMode = true; | |
6999 | Handle(ViewerTest_V3dView) aV3dView = Handle(ViewerTest_V3dView)::DownCast (ViewerTest::CurrentView()); | |
7000 | if (aV3dView.IsNull()) | |
7001 | { | |
23fe70ec | 7002 | Message::SendFail ("Error: no active viewer"); |
2e93433e | 7003 | return 1; |
7004 | } | |
7005 | for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) | |
7006 | { | |
7007 | const TCollection_AsciiString anArg = theArgVec[anArgIt]; | |
7008 | TCollection_AsciiString anArgCase = anArg; | |
7009 | anArgCase.LowerCase(); | |
7010 | if (anArgIt + 1 < theArgsNb | |
7011 | && anArgCase == "-name") | |
7012 | { | |
7013 | ViewerTest_Names aViewNames (theArgVec[++anArgIt]); | |
7014 | TCollection_AsciiString aViewName = aViewNames.GetViewName(); | |
7015 | if (!ViewerTest_myViews.IsBound1 (aViewName)) | |
7016 | { | |
23fe70ec | 7017 | Message::SendFail() << "Syntax error: unknown view '" << theArgVec[anArgIt - 1] << "'"; |
2e93433e | 7018 | return 1; |
7019 | } | |
7020 | aV3dView = Handle(ViewerTest_V3dView)::DownCast (ViewerTest_myViews.Find1 (aViewName)); | |
7021 | } | |
7022 | else if (anArgCase == "-mode") | |
7023 | { | |
7024 | if (anArgIt + 1 < theArgsNb | |
dae2a922 | 7025 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], is2dMode)) |
2e93433e | 7026 | { |
7027 | ++anArgIt; | |
7028 | } | |
7029 | } | |
dae2a922 | 7030 | else if (Draw::ParseOnOff (theArgVec[anArgIt], is2dMode)) |
2e93433e | 7031 | { |
7032 | // | |
7033 | } | |
7034 | else | |
7035 | { | |
23fe70ec | 7036 | Message::SendFail() << "Syntax error: unknown argument " << anArg; |
2e93433e | 7037 | return 1; |
7038 | } | |
7039 | } | |
7040 | ||
7041 | aV3dView->SetView2DMode (is2dMode); | |
7042 | return 0; | |
7043 | } | |
7044 | ||
1beb58d7 | 7045 | //============================================================================== |
7046 | //function : VAnimation | |
7047 | //purpose : | |
7048 | //============================================================================== | |
7049 | static Standard_Integer VAnimation (Draw_Interpretor& theDI, | |
7050 | Standard_Integer theArgNb, | |
7051 | const char** theArgVec) | |
7052 | { | |
7053 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
7054 | if (theArgNb < 2) | |
4754e164 | 7055 | { |
1beb58d7 | 7056 | for (NCollection_DataMap<TCollection_AsciiString, Handle(AIS_Animation)>::Iterator |
7057 | anAnimIter (ViewerTest_AnimationTimelineMap); anAnimIter.More(); anAnimIter.Next()) | |
7058 | { | |
7059 | theDI << anAnimIter.Key() << " " << anAnimIter.Value()->Duration() << " sec\n"; | |
197ac94e | 7060 | } |
1beb58d7 | 7061 | return 0; |
7062 | } | |
7063 | if (aCtx.IsNull()) | |
7064 | { | |
23fe70ec | 7065 | Message::SendFail ("Error: no active viewer"); |
1beb58d7 | 7066 | return 1; |
4754e164 | 7067 | } |
197ac94e | 7068 | |
1beb58d7 | 7069 | Standard_Integer anArgIter = 1; |
7070 | TCollection_AsciiString aNameArg (theArgVec[anArgIter++]); | |
7071 | if (aNameArg.IsEmpty()) | |
7072 | { | |
23fe70ec | 7073 | Message::SendFail ("Syntax error: animation name is not defined"); |
1beb58d7 | 7074 | return 1; |
7075 | } | |
7076 | ||
7077 | TCollection_AsciiString aNameArgLower = aNameArg; | |
7078 | aNameArgLower.LowerCase(); | |
7079 | if (aNameArgLower == "-reset" | |
7080 | || aNameArgLower == "-clear") | |
7081 | { | |
7082 | ViewerTest_AnimationTimelineMap.Clear(); | |
7083 | return 0; | |
7084 | } | |
7085 | else if (aNameArg.Value (1) == '-') | |
7086 | { | |
23fe70ec | 7087 | Message::SendFail() << "Syntax error: invalid animation name '" << aNameArg << "'"; |
1beb58d7 | 7088 | return 1; |
7089 | } | |
197ac94e | 7090 | |
1beb58d7 | 7091 | const char* aNameSplitter = "/"; |
7092 | Standard_Integer aSplitPos = aNameArg.Search (aNameSplitter); | |
7093 | if (aSplitPos == -1) | |
197ac94e | 7094 | { |
1beb58d7 | 7095 | aNameSplitter = "."; |
7096 | aSplitPos = aNameArg.Search (aNameSplitter); | |
7097 | } | |
7098 | ||
7099 | // find existing or create a new animation by specified name within syntax "parent.child". | |
7100 | Handle(AIS_Animation) aRootAnimation, aParentAnimation, anAnimation; | |
7101 | for (; !aNameArg.IsEmpty();) | |
7102 | { | |
7103 | TCollection_AsciiString aNameParent; | |
7104 | if (aSplitPos != -1) | |
197ac94e | 7105 | { |
1beb58d7 | 7106 | if (aSplitPos == aNameArg.Length()) |
7107 | { | |
23fe70ec | 7108 | Message::SendFail ("Syntax error: animation name is not defined"); |
1beb58d7 | 7109 | return 1; |
7110 | } | |
7111 | ||
7112 | aNameParent = aNameArg.SubString ( 1, aSplitPos - 1); | |
7113 | aNameArg = aNameArg.SubString (aSplitPos + 1, aNameArg.Length()); | |
7114 | ||
7115 | aSplitPos = aNameArg.Search (aNameSplitter); | |
197ac94e | 7116 | } |
7117 | else | |
7118 | { | |
1beb58d7 | 7119 | aNameParent = aNameArg; |
7120 | aNameArg.Clear(); | |
197ac94e | 7121 | } |
1beb58d7 | 7122 | |
7123 | if (anAnimation.IsNull()) | |
3dfe95cd | 7124 | { |
1beb58d7 | 7125 | if (!ViewerTest_AnimationTimelineMap.Find (aNameParent, anAnimation)) |
7126 | { | |
7127 | anAnimation = new AIS_Animation (aNameParent); | |
7128 | ViewerTest_AnimationTimelineMap.Bind (aNameParent, anAnimation); | |
7129 | } | |
7130 | aRootAnimation = anAnimation; | |
3dfe95cd | 7131 | } |
7132 | else | |
7133 | { | |
1beb58d7 | 7134 | aParentAnimation = anAnimation; |
7135 | anAnimation = aParentAnimation->Find (aNameParent); | |
7136 | if (anAnimation.IsNull()) | |
7137 | { | |
7138 | anAnimation = new AIS_Animation (aNameParent); | |
7139 | aParentAnimation->Add (anAnimation); | |
7140 | } | |
3dfe95cd | 7141 | } |
7142 | } | |
1beb58d7 | 7143 | |
7144 | if (anArgIter >= theArgNb) | |
197ac94e | 7145 | { |
1beb58d7 | 7146 | // just print the list of children |
7147 | for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anAnimIter (anAnimation->Children()); anAnimIter.More(); anAnimIter.Next()) | |
197ac94e | 7148 | { |
1beb58d7 | 7149 | theDI << anAnimIter.Value()->Name() << " " << anAnimIter.Value()->Duration() << " sec\n"; |
197ac94e | 7150 | } |
1beb58d7 | 7151 | return 0; |
197ac94e | 7152 | } |
1beb58d7 | 7153 | |
bf7b2ceb | 7154 | // animation parameters |
1beb58d7 | 7155 | Standard_Boolean toPlay = Standard_False; |
7156 | Standard_Real aPlaySpeed = 1.0; | |
7157 | Standard_Real aPlayStartTime = anAnimation->StartPts(); | |
7158 | Standard_Real aPlayDuration = anAnimation->Duration(); | |
1beb58d7 | 7159 | Standard_Boolean isFreeCamera = Standard_False; |
8f709595 | 7160 | Standard_Boolean toPauseOnClick = Standard_True; |
1beb58d7 | 7161 | Standard_Boolean isLockLoop = Standard_False; |
08f8a185 | 7162 | |
7163 | // video recording parameters | |
7164 | TCollection_AsciiString aRecFile; | |
7165 | Image_VideoParams aRecParams; | |
7166 | ||
1beb58d7 | 7167 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
7168 | for (; anArgIter < theArgNb; ++anArgIter) | |
197ac94e | 7169 | { |
1beb58d7 | 7170 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
7171 | anArg.LowerCase(); | |
bf7b2ceb | 7172 | // general options |
1beb58d7 | 7173 | if (anArg == "-reset" |
7174 | || anArg == "-clear") | |
197ac94e | 7175 | { |
1beb58d7 | 7176 | anAnimation->Clear(); |
7177 | } | |
7178 | else if (anArg == "-remove" | |
7179 | || anArg == "-del" | |
7180 | || anArg == "-delete") | |
7181 | { | |
7182 | if (!aParentAnimation.IsNull()) | |
7183 | { | |
7184 | ViewerTest_AnimationTimelineMap.UnBind (anAnimation->Name()); | |
7185 | } | |
7186 | else | |
7187 | { | |
7188 | aParentAnimation->Remove (anAnimation); | |
7189 | } | |
7190 | } | |
bf7b2ceb | 7191 | // playback options |
1beb58d7 | 7192 | else if (anArg == "-play") |
7193 | { | |
7194 | toPlay = Standard_True; | |
7195 | if (++anArgIter < theArgNb) | |
7196 | { | |
7197 | if (*theArgVec[anArgIter] == '-') | |
7198 | { | |
7199 | --anArgIter; | |
7200 | continue; | |
7201 | } | |
7202 | aPlayStartTime = Draw::Atof (theArgVec[anArgIter]); | |
7203 | ||
7204 | if (++anArgIter < theArgNb) | |
7205 | { | |
7206 | if (*theArgVec[anArgIter] == '-') | |
7207 | { | |
7208 | --anArgIter; | |
7209 | continue; | |
7210 | } | |
7211 | aPlayDuration = Draw::Atof (theArgVec[anArgIter]); | |
7212 | } | |
7213 | } | |
7214 | } | |
7215 | else if (anArg == "-resume") | |
7216 | { | |
7217 | toPlay = Standard_True; | |
7218 | aPlayStartTime = anAnimation->ElapsedTime(); | |
7219 | if (++anArgIter < theArgNb) | |
7220 | { | |
7221 | if (*theArgVec[anArgIter] == '-') | |
7222 | { | |
7223 | --anArgIter; | |
7224 | continue; | |
7225 | } | |
7226 | ||
7227 | aPlayDuration = Draw::Atof (theArgVec[anArgIter]); | |
7228 | } | |
7229 | } | |
8f709595 | 7230 | else if (anArg == "-pause") |
7231 | { | |
7232 | anAnimation->Pause(); | |
7233 | } | |
7234 | else if (anArg == "-stop") | |
7235 | { | |
7236 | anAnimation->Stop(); | |
7237 | } | |
1beb58d7 | 7238 | else if (anArg == "-playspeed" |
7239 | || anArg == "-speed") | |
7240 | { | |
7241 | if (++anArgIter >= theArgNb) | |
7242 | { | |
23fe70ec | 7243 | Message::SendFail() << "Syntax error at " << anArg << ""; |
1beb58d7 | 7244 | return 1; |
7245 | } | |
7246 | aPlaySpeed = Draw::Atof (theArgVec[anArgIter]); | |
7247 | } | |
7248 | else if (anArg == "-lock" | |
7249 | || anArg == "-lockloop" | |
7250 | || anArg == "-playlockloop") | |
7251 | { | |
8f709595 | 7252 | isLockLoop = Draw::ParseOnOffIterator (theArgNb, theArgVec, anArgIter); |
1beb58d7 | 7253 | } |
7254 | else if (anArg == "-freecamera" | |
8f709595 | 7255 | || anArg == "-nofreecamera" |
1beb58d7 | 7256 | || anArg == "-playfreecamera" |
8f709595 | 7257 | || anArg == "-noplayfreecamera" |
7258 | || anArg == "-freelook" | |
7259 | || anArg == "-nofreelook") | |
7260 | { | |
7261 | isFreeCamera = Draw::ParseOnOffNoIterator (theArgNb, theArgVec, anArgIter); | |
7262 | } | |
7263 | else if (anArg == "-pauseonclick" | |
7264 | || anArg == "-nopauseonclick" | |
7265 | || anArg == "-nopause") | |
1beb58d7 | 7266 | { |
8f709595 | 7267 | toPauseOnClick = Draw::ParseOnOffNoIterator (theArgNb, theArgVec, anArgIter); |
1beb58d7 | 7268 | } |
08f8a185 | 7269 | // video recodring options |
7270 | else if (anArg == "-rec" | |
7271 | || anArg == "-record") | |
7272 | { | |
7273 | if (++anArgIter >= theArgNb) | |
7274 | { | |
23fe70ec | 7275 | Message::SendFail() << "Syntax error at " << anArg; |
08f8a185 | 7276 | return 1; |
7277 | } | |
7278 | ||
7279 | aRecFile = theArgVec[anArgIter]; | |
7280 | if (aRecParams.FpsNum <= 0) | |
7281 | { | |
7282 | aRecParams.FpsNum = 24; | |
7283 | } | |
7284 | ||
7285 | if (anArgIter + 2 < theArgNb | |
7286 | && *theArgVec[anArgIter + 1] != '-' | |
7287 | && *theArgVec[anArgIter + 2] != '-') | |
7288 | { | |
7289 | TCollection_AsciiString aWidthArg (theArgVec[anArgIter + 1]); | |
7290 | TCollection_AsciiString aHeightArg (theArgVec[anArgIter + 2]); | |
7291 | if (aWidthArg .IsIntegerValue() | |
7292 | && aHeightArg.IsIntegerValue()) | |
7293 | { | |
7294 | aRecParams.Width = aWidthArg .IntegerValue(); | |
7295 | aRecParams.Height = aHeightArg.IntegerValue(); | |
7296 | anArgIter += 2; | |
7297 | } | |
7298 | } | |
7299 | } | |
1beb58d7 | 7300 | else if (anArg == "-fps") |
7301 | { | |
7302 | if (++anArgIter >= theArgNb) | |
7303 | { | |
23fe70ec | 7304 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7305 | return 1; |
7306 | } | |
bf7b2ceb | 7307 | |
7308 | TCollection_AsciiString aFpsArg (theArgVec[anArgIter]); | |
7309 | Standard_Integer aSplitIndex = aFpsArg.FirstLocationInSet ("/", 1, aFpsArg.Length()); | |
7310 | if (aSplitIndex == 0) | |
7311 | { | |
08f8a185 | 7312 | aRecParams.FpsNum = aFpsArg.IntegerValue(); |
bf7b2ceb | 7313 | } |
7314 | else | |
7315 | { | |
7316 | const TCollection_AsciiString aDenStr = aFpsArg.Split (aSplitIndex); | |
7317 | aFpsArg.Split (aFpsArg.Length() - 1); | |
7318 | const TCollection_AsciiString aNumStr = aFpsArg; | |
08f8a185 | 7319 | aRecParams.FpsNum = aNumStr.IntegerValue(); |
7320 | aRecParams.FpsDen = aDenStr.IntegerValue(); | |
7321 | if (aRecParams.FpsDen < 1) | |
bf7b2ceb | 7322 | { |
23fe70ec | 7323 | Message::SendFail() << "Syntax error at " << anArg; |
bf7b2ceb | 7324 | return 1; |
7325 | } | |
7326 | } | |
1beb58d7 | 7327 | } |
08f8a185 | 7328 | else if (anArg == "-format") |
7329 | { | |
7330 | if (++anArgIter >= theArgNb) | |
7331 | { | |
23fe70ec | 7332 | Message::SendFail() << "Syntax error at " << anArg; |
08f8a185 | 7333 | return 1; |
7334 | } | |
7335 | aRecParams.Format = theArgVec[anArgIter]; | |
7336 | } | |
7337 | else if (anArg == "-pix_fmt" | |
7338 | || anArg == "-pixfmt" | |
7339 | || anArg == "-pixelformat") | |
7340 | { | |
7341 | if (++anArgIter >= theArgNb) | |
7342 | { | |
23fe70ec | 7343 | Message::SendFail() << "Syntax error at " << anArg; |
08f8a185 | 7344 | return 1; |
7345 | } | |
7346 | aRecParams.PixelFormat = theArgVec[anArgIter]; | |
7347 | } | |
7348 | else if (anArg == "-codec" | |
7349 | || anArg == "-vcodec" | |
7350 | || anArg == "-videocodec") | |
7351 | { | |
7352 | if (++anArgIter >= theArgNb) | |
7353 | { | |
23fe70ec | 7354 | Message::SendFail() << "Syntax error at " << anArg; |
08f8a185 | 7355 | return 1; |
7356 | } | |
7357 | aRecParams.VideoCodec = theArgVec[anArgIter]; | |
7358 | } | |
7359 | else if (anArg == "-crf" | |
7360 | || anArg == "-preset" | |
7361 | || anArg == "-qp") | |
7362 | { | |
7363 | const TCollection_AsciiString aParamName = anArg.SubString (2, anArg.Length()); | |
7364 | if (++anArgIter >= theArgNb) | |
7365 | { | |
23fe70ec | 7366 | Message::SendFail() << "Syntax error at " << anArg; |
08f8a185 | 7367 | return 1; |
7368 | } | |
7369 | ||
7370 | aRecParams.VideoCodecParams.Bind (aParamName, theArgVec[anArgIter]); | |
7371 | } | |
bf7b2ceb | 7372 | // animation definition options |
1beb58d7 | 7373 | else if (anArg == "-start" |
7374 | || anArg == "-starttime" | |
7375 | || anArg == "-startpts") | |
7376 | { | |
7377 | if (++anArgIter >= theArgNb) | |
7378 | { | |
23fe70ec | 7379 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7380 | return 1; |
7381 | } | |
7382 | ||
7383 | anAnimation->SetStartPts (Draw::Atof (theArgVec[anArgIter])); | |
7384 | aRootAnimation->UpdateTotalDuration(); | |
7385 | } | |
7386 | else if (anArg == "-end" | |
7387 | || anArg == "-endtime" | |
7388 | || anArg == "-endpts") | |
7389 | { | |
7390 | if (++anArgIter >= theArgNb) | |
7391 | { | |
23fe70ec | 7392 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7393 | return 1; |
7394 | } | |
7395 | ||
7396 | anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter]) - anAnimation->StartPts()); | |
7397 | aRootAnimation->UpdateTotalDuration(); | |
7398 | } | |
7399 | else if (anArg == "-dur" | |
7400 | || anArg == "-duration") | |
7401 | { | |
7402 | if (++anArgIter >= theArgNb) | |
7403 | { | |
23fe70ec | 7404 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7405 | return 1; |
7406 | } | |
7407 | ||
7408 | anAnimation->SetOwnDuration (Draw::Atof (theArgVec[anArgIter])); | |
7409 | aRootAnimation->UpdateTotalDuration(); | |
7410 | } | |
7411 | else if (anArg == "-command" | |
7412 | || anArg == "-cmd" | |
7413 | || anArg == "-invoke" | |
7414 | || anArg == "-eval" | |
7415 | || anArg == "-proc") | |
7416 | { | |
7417 | if (++anArgIter >= theArgNb) | |
7418 | { | |
23fe70ec | 7419 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7420 | return 1; |
7421 | } | |
7422 | ||
7423 | Handle(ViewerTest_AnimationProc) aCmdAnimation = new ViewerTest_AnimationProc (anAnimation->Name(), &theDI, theArgVec[anArgIter]); | |
7424 | replaceAnimation (aParentAnimation, anAnimation, aCmdAnimation); | |
7425 | } | |
7426 | else if (anArg == "-objecttrsf" | |
7427 | || anArg == "-objectransformation" | |
7428 | || anArg == "-objtransformation" | |
7429 | || anArg == "-objtrsf" | |
7430 | || anArg == "-object" | |
7431 | || anArg == "-obj") | |
7432 | { | |
7433 | if (++anArgIter >= theArgNb) | |
7434 | { | |
23fe70ec | 7435 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7436 | return 1; |
7437 | } | |
7438 | ||
7439 | TCollection_AsciiString anObjName (theArgVec[anArgIter]); | |
7440 | const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfAIS = GetMapOfAIS(); | |
8f521168 | 7441 | Handle(AIS_InteractiveObject) anObject; |
7442 | if (!aMapOfAIS.Find2 (anObjName, anObject)) | |
1beb58d7 | 7443 | { |
23fe70ec | 7444 | Message::SendFail() << "Syntax error: wrong object name at " << anArg; |
1beb58d7 | 7445 | return 1; |
7446 | } | |
7447 | ||
1beb58d7 | 7448 | gp_Trsf aTrsfs [2] = { anObject->LocalTransformation(), anObject->LocalTransformation() }; |
7449 | gp_Quaternion aRotQuats[2] = { aTrsfs[0].GetRotation(), aTrsfs[1].GetRotation() }; | |
7450 | gp_XYZ aLocPnts [2] = { aTrsfs[0].TranslationPart(), aTrsfs[1].TranslationPart() }; | |
7451 | Standard_Real aScales [2] = { aTrsfs[0].ScaleFactor(), aTrsfs[1].ScaleFactor() }; | |
7452 | Standard_Boolean isTrsfSet = Standard_False; | |
7453 | Standard_Integer aTrsfArgIter = anArgIter + 1; | |
7454 | for (; aTrsfArgIter < theArgNb; ++aTrsfArgIter) | |
7455 | { | |
7456 | TCollection_AsciiString aTrsfArg (theArgVec[aTrsfArgIter]); | |
7457 | aTrsfArg.LowerCase(); | |
7458 | const Standard_Integer anIndex = aTrsfArg.EndsWith ("1") ? 0 : 1; | |
7459 | if (aTrsfArg.StartsWith ("-rotation") | |
7460 | || aTrsfArg.StartsWith ("-rot")) | |
7461 | { | |
7462 | isTrsfSet = Standard_True; | |
7463 | if (aTrsfArgIter + 4 >= theArgNb | |
7464 | || !parseQuaternion (theArgVec + aTrsfArgIter + 1, aRotQuats[anIndex])) | |
7465 | { | |
23fe70ec | 7466 | Message::SendFail() << "Syntax error at " << aTrsfArg; |
1beb58d7 | 7467 | return 1; |
7468 | } | |
7469 | aTrsfArgIter += 4; | |
7470 | } | |
7471 | else if (aTrsfArg.StartsWith ("-location") | |
7472 | || aTrsfArg.StartsWith ("-loc")) | |
7473 | { | |
7474 | isTrsfSet = Standard_True; | |
7475 | if (aTrsfArgIter + 3 >= theArgNb | |
7476 | || !parseXYZ (theArgVec + aTrsfArgIter + 1, aLocPnts[anIndex])) | |
7477 | { | |
23fe70ec | 7478 | Message::SendFail() << "Syntax error at " << aTrsfArg; |
1beb58d7 | 7479 | return 1; |
7480 | } | |
7481 | aTrsfArgIter += 3; | |
7482 | } | |
7483 | else if (aTrsfArg.StartsWith ("-scale")) | |
7484 | { | |
7485 | isTrsfSet = Standard_True; | |
7486 | if (++aTrsfArgIter >= theArgNb) | |
7487 | { | |
23fe70ec | 7488 | Message::SendFail() << "Syntax error at " << aTrsfArg; |
1beb58d7 | 7489 | return 1; |
7490 | } | |
7491 | ||
7492 | const TCollection_AsciiString aScaleStr (theArgVec[aTrsfArgIter]); | |
d45edf24 | 7493 | if (!aScaleStr.IsRealValue (Standard_True)) |
1beb58d7 | 7494 | { |
23fe70ec | 7495 | Message::SendFail() << "Syntax error at " << aTrsfArg; |
1beb58d7 | 7496 | return 1; |
7497 | } | |
7498 | aScales[anIndex] = aScaleStr.RealValue(); | |
7499 | } | |
7500 | else | |
7501 | { | |
7502 | anArgIter = aTrsfArgIter - 1; | |
7503 | break; | |
7504 | } | |
7505 | } | |
7506 | if (!isTrsfSet) | |
7507 | { | |
23fe70ec | 7508 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7509 | return 1; |
7510 | } | |
7511 | else if (aTrsfArgIter >= theArgNb) | |
7512 | { | |
7513 | anArgIter = theArgNb; | |
7514 | } | |
7515 | ||
7516 | aTrsfs[0].SetRotation (aRotQuats[0]); | |
7517 | aTrsfs[1].SetRotation (aRotQuats[1]); | |
7518 | aTrsfs[0].SetTranslationPart (aLocPnts[0]); | |
7519 | aTrsfs[1].SetTranslationPart (aLocPnts[1]); | |
7520 | aTrsfs[0].SetScaleFactor (aScales[0]); | |
7521 | aTrsfs[1].SetScaleFactor (aScales[1]); | |
7522 | ||
7523 | Handle(AIS_AnimationObject) anObjAnimation = new AIS_AnimationObject (anAnimation->Name(), aCtx, anObject, aTrsfs[0], aTrsfs[1]); | |
7524 | replaceAnimation (aParentAnimation, anAnimation, anObjAnimation); | |
7525 | } | |
7526 | else if (anArg == "-viewtrsf" | |
7527 | || anArg == "-view") | |
7528 | { | |
7529 | Handle(AIS_AnimationCamera) aCamAnimation = Handle(AIS_AnimationCamera)::DownCast (anAnimation); | |
7530 | if (aCamAnimation.IsNull()) | |
7531 | { | |
7532 | aCamAnimation = new AIS_AnimationCamera (anAnimation->Name(), aView); | |
7533 | replaceAnimation (aParentAnimation, anAnimation, aCamAnimation); | |
7534 | } | |
7535 | ||
7536 | Handle(Graphic3d_Camera) aCams[2] = | |
7537 | { | |
7538 | new Graphic3d_Camera (aCamAnimation->View()->Camera()), | |
7539 | new Graphic3d_Camera (aCamAnimation->View()->Camera()) | |
7540 | }; | |
7541 | ||
7542 | Standard_Boolean isTrsfSet = Standard_False; | |
7543 | Standard_Integer aViewArgIter = anArgIter + 1; | |
7544 | for (; aViewArgIter < theArgNb; ++aViewArgIter) | |
7545 | { | |
7546 | TCollection_AsciiString aViewArg (theArgVec[aViewArgIter]); | |
7547 | aViewArg.LowerCase(); | |
7548 | const Standard_Integer anIndex = aViewArg.EndsWith("1") ? 0 : 1; | |
7549 | if (aViewArg.StartsWith ("-scale")) | |
7550 | { | |
7551 | isTrsfSet = Standard_True; | |
7552 | if (++aViewArgIter >= theArgNb) | |
7553 | { | |
23fe70ec | 7554 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7555 | return 1; |
7556 | } | |
7557 | ||
7558 | const TCollection_AsciiString aScaleStr (theArgVec[aViewArgIter]); | |
d45edf24 | 7559 | if (!aScaleStr.IsRealValue (Standard_True)) |
1beb58d7 | 7560 | { |
23fe70ec | 7561 | Message::SendFail() << "Syntax error at " << aViewArg; |
1beb58d7 | 7562 | return 1; |
7563 | } | |
7564 | Standard_Real aScale = aScaleStr.RealValue(); | |
7565 | aScale = aCamAnimation->View()->DefaultCamera()->Scale() / aScale; | |
7566 | aCams[anIndex]->SetScale (aScale); | |
7567 | } | |
7568 | else if (aViewArg.StartsWith ("-eye") | |
7569 | || aViewArg.StartsWith ("-center") | |
7570 | || aViewArg.StartsWith ("-at") | |
7571 | || aViewArg.StartsWith ("-up")) | |
7572 | { | |
7573 | isTrsfSet = Standard_True; | |
7574 | gp_XYZ anXYZ; | |
7575 | if (aViewArgIter + 3 >= theArgNb | |
7576 | || !parseXYZ (theArgVec + aViewArgIter + 1, anXYZ)) | |
7577 | { | |
23fe70ec | 7578 | Message::SendFail() << "Syntax error at " << aViewArg; |
1beb58d7 | 7579 | return 1; |
7580 | } | |
7581 | aViewArgIter += 3; | |
7582 | ||
7583 | if (aViewArg.StartsWith ("-eye")) | |
7584 | { | |
7585 | aCams[anIndex]->SetEye (anXYZ); | |
7586 | } | |
7587 | else if (aViewArg.StartsWith ("-center") | |
7588 | || aViewArg.StartsWith ("-at")) | |
7589 | { | |
7590 | aCams[anIndex]->SetCenter (anXYZ); | |
7591 | } | |
7592 | else if (aViewArg.StartsWith ("-up")) | |
7593 | { | |
7594 | aCams[anIndex]->SetUp (anXYZ); | |
7595 | } | |
7596 | } | |
7597 | else | |
7598 | { | |
7599 | anArgIter = aViewArgIter - 1; | |
7600 | break; | |
7601 | } | |
7602 | } | |
7603 | if (!isTrsfSet) | |
7604 | { | |
23fe70ec | 7605 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7606 | return 1; |
7607 | } | |
7608 | else if (aViewArgIter >= theArgNb) | |
7609 | { | |
7610 | anArgIter = theArgNb; | |
7611 | } | |
7612 | ||
7613 | aCamAnimation->SetCameraStart(aCams[0]); | |
7614 | aCamAnimation->SetCameraEnd (aCams[1]); | |
197ac94e | 7615 | } |
7616 | else | |
7617 | { | |
23fe70ec | 7618 | Message::SendFail() << "Syntax error at " << anArg; |
1beb58d7 | 7619 | return 1; |
197ac94e | 7620 | } |
7621 | } | |
1beb58d7 | 7622 | |
8f709595 | 7623 | ViewerTest::CurrentEventManager()->AbortViewAnimation(); |
7624 | ViewerTest::CurrentEventManager()->SetObjectsAnimation (Handle(AIS_Animation)()); | |
08f8a185 | 7625 | if (!toPlay && aRecFile.IsEmpty()) |
197ac94e | 7626 | { |
1beb58d7 | 7627 | return 0; |
7628 | } | |
7629 | ||
7630 | // Start animation timeline and process frame updating. | |
8f709595 | 7631 | if (aRecParams.FpsNum <= 0 |
7632 | && !isLockLoop) | |
7633 | { | |
7634 | Handle(ViewerTest_AnimationHolder) aHolder = new ViewerTest_AnimationHolder (anAnimation, aView, isFreeCamera); | |
7635 | aHolder->StartTimer (aPlayStartTime, aPlaySpeed, Standard_True, aPlayDuration <= 0.0); | |
7636 | ViewerTest::CurrentEventManager()->SetPauseObjectsAnimation (toPauseOnClick); | |
7637 | ViewerTest::CurrentEventManager()->SetObjectsAnimation (aHolder); | |
7638 | ViewerTest::CurrentEventManager()->ProcessExpose(); | |
7639 | return 0; | |
1beb58d7 | 7640 | } |
7641 | ||
8f709595 | 7642 | // Perform video recording |
7643 | const Standard_Boolean wasImmediateUpdate = aView->SetImmediateUpdate (Standard_False); | |
1beb58d7 | 7644 | const Standard_Real anUpperPts = aPlayStartTime + aPlayDuration; |
8f709595 | 7645 | anAnimation->StartTimer (aPlayStartTime, aPlaySpeed, Standard_True, aPlayDuration <= 0.0); |
1beb58d7 | 7646 | |
8f709595 | 7647 | OSD_Timer aPerfTimer; |
7648 | aPerfTimer.Start(); | |
1beb58d7 | 7649 | |
8f709595 | 7650 | Handle(Image_VideoRecorder) aRecorder; |
7651 | ImageFlipper aFlipper; | |
7652 | Handle(Draw_ProgressIndicator) aProgress; | |
7653 | if (!aRecFile.IsEmpty()) | |
7654 | { | |
7655 | if (aRecParams.Width <= 0 | |
7656 | || aRecParams.Height <= 0) | |
7657 | { | |
7658 | aView->Window()->Size (aRecParams.Width, aRecParams.Height); | |
7659 | } | |
1beb58d7 | 7660 | |
8f709595 | 7661 | aRecorder = new Image_VideoRecorder(); |
7662 | if (!aRecorder->Open (aRecFile.ToCString(), aRecParams)) | |
7663 | { | |
7664 | Message::SendFail ("Error: failed to open video file for recording"); | |
7665 | return 0; | |
1beb58d7 | 7666 | } |
7667 | ||
8f709595 | 7668 | aProgress = new Draw_ProgressIndicator (theDI, 1); |
7669 | } | |
7670 | ||
7671 | // Manage frame-rated animation here | |
7672 | Standard_Real aPts = aPlayStartTime; | |
7673 | int64_t aNbFrames = 0; | |
7674 | Message_ProgressScope aPS(Message_ProgressIndicator::Start(aProgress), | |
7675 | "Video recording, sec", Max(1, Standard_Integer(aPlayDuration / aPlaySpeed))); | |
7676 | Standard_Integer aSecondsProgress = 0; | |
7677 | for (; aPts <= anUpperPts && aPS.More();) | |
7678 | { | |
7679 | Standard_Real aRecPts = 0.0; | |
7680 | if (aRecParams.FpsNum > 0) | |
1beb58d7 | 7681 | { |
8f709595 | 7682 | aRecPts = aPlaySpeed * ((Standard_Real(aRecParams.FpsDen) / Standard_Real(aRecParams.FpsNum)) * Standard_Real(aNbFrames)); |
197ac94e | 7683 | } |
7684 | else | |
7685 | { | |
8f709595 | 7686 | aRecPts = aPlaySpeed * aPerfTimer.ElapsedTime(); |
197ac94e | 7687 | } |
1beb58d7 | 7688 | |
8f709595 | 7689 | aPts = aPlayStartTime + aRecPts; |
7690 | ++aNbFrames; | |
7691 | if (!anAnimation->Update (aPts)) | |
08f8a185 | 7692 | { |
8f709595 | 7693 | break; |
08f8a185 | 7694 | } |
7695 | ||
8f709595 | 7696 | if (!aRecorder.IsNull()) |
197ac94e | 7697 | { |
8f709595 | 7698 | V3d_ImageDumpOptions aDumpParams; |
7699 | aDumpParams.Width = aRecParams.Width; | |
7700 | aDumpParams.Height = aRecParams.Height; | |
7701 | aDumpParams.BufferType = Graphic3d_BT_RGBA; | |
7702 | aDumpParams.StereoOptions = V3d_SDO_MONO; | |
7703 | aDumpParams.ToAdjustAspect = Standard_True; | |
7704 | if (!aView->ToPixMap (aRecorder->ChangeFrame(), aDumpParams)) | |
08f8a185 | 7705 | { |
8f709595 | 7706 | Message::SendFail ("Error: view dump is failed"); |
7707 | return 0; | |
08f8a185 | 7708 | } |
8f709595 | 7709 | aFlipper.FlipY (aRecorder->ChangeFrame()); |
7710 | if (!aRecorder->PushFrame()) | |
08f8a185 | 7711 | { |
8f709595 | 7712 | return 0; |
08f8a185 | 7713 | } |
197ac94e | 7714 | } |
8f709595 | 7715 | else |
7716 | { | |
7717 | aView->Redraw(); | |
7718 | } | |
bf7b2ceb | 7719 | |
8f709595 | 7720 | while (aSecondsProgress < Standard_Integer(aRecPts / aPlaySpeed)) |
7721 | { | |
7722 | aPS.Next(); | |
7723 | ++aSecondsProgress; | |
7724 | } | |
197ac94e | 7725 | } |
7726 | ||
8f709595 | 7727 | aPerfTimer.Stop(); |
7728 | anAnimation->Stop(); | |
7729 | const Standard_Real aRecFps = Standard_Real(aNbFrames) / aPerfTimer.ElapsedTime(); | |
7730 | theDI << "Average FPS: " << aRecFps << "\n" | |
7731 | << "Nb. Frames: " << Standard_Real(aNbFrames); | |
7732 | ||
7733 | aView->Redraw(); | |
1beb58d7 | 7734 | aView->SetImmediateUpdate (wasImmediateUpdate); |
4754e164 | 7735 | return 0; |
7736 | } | |
7737 | ||
1beb58d7 | 7738 | |
4754e164 | 7739 | //======================================================================= |
7740 | //function : VChangeSelected | |
dc3fe572 | 7741 | //purpose : Adds the shape to selection or remove one from it |
4754e164 | 7742 | //======================================================================= |
7743 | static Standard_Integer VChangeSelected (Draw_Interpretor& di, | |
7744 | Standard_Integer argc, | |
7745 | const char ** argv) | |
7746 | { | |
7747 | if(argc != 2) | |
7748 | { | |
7749 | di<<"Usage : " << argv[0] << " shape \n"; | |
7750 | return 1; | |
7751 | } | |
7752 | //get AIS_Shape: | |
4754e164 | 7753 | TCollection_AsciiString aName(argv[1]); |
7754 | Handle(AIS_InteractiveObject) anAISObject; | |
8f521168 | 7755 | if (!GetMapOfAIS().Find2 (aName, anAISObject) |
7756 | || anAISObject.IsNull()) | |
4754e164 | 7757 | { |
7758 | di<<"Use 'vdisplay' before"; | |
7759 | return 1; | |
7760 | } | |
4754e164 | 7761 | |
8f521168 | 7762 | ViewerTest::GetAISContext()->AddOrRemoveSelected(anAISObject, Standard_True); |
4754e164 | 7763 | return 0; |
7764 | } | |
7765 | ||
4754e164 | 7766 | //======================================================================= |
7767 | //function : VNbSelected | |
dc3fe572 | 7768 | //purpose : Returns number of selected objects |
4754e164 | 7769 | //======================================================================= |
7770 | static Standard_Integer VNbSelected (Draw_Interpretor& di, | |
7771 | Standard_Integer argc, | |
7772 | const char ** argv) | |
7773 | { | |
7774 | if(argc != 1) | |
7775 | { | |
7776 | di << "Usage : " << argv[0] << "\n"; | |
7777 | return 1; | |
7778 | } | |
7779 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
7780 | if(aContext.IsNull()) | |
7781 | { | |
7782 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
7783 | return 1; | |
7784 | } | |
7785 | di << aContext->NbSelected() << "\n"; | |
7786 | return 0; | |
7787 | } | |
7788 | ||
4754e164 | 7789 | //======================================================================= |
7790 | //function : VSetViewSize | |
7791 | //purpose : | |
7792 | //======================================================================= | |
7793 | static Standard_Integer VSetViewSize (Draw_Interpretor& di, | |
7794 | Standard_Integer argc, | |
7795 | const char ** argv) | |
7796 | { | |
7797 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
7798 | if(aContext.IsNull()) | |
7799 | { | |
7800 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
7801 | return 1; | |
7802 | } | |
7803 | if(argc != 2) | |
7804 | { | |
7805 | di<<"Usage : " << argv[0] << " Size\n"; | |
7806 | return 1; | |
7807 | } | |
6b62b2da | 7808 | Standard_Real aSize = Draw::Atof (argv[1]); |
4754e164 | 7809 | if (aSize <= 0.) |
7810 | { | |
7811 | di<<"Bad Size value : " << aSize << "\n"; | |
7812 | return 1; | |
7813 | } | |
7814 | ||
7815 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7816 | aView->SetSize(aSize); | |
7817 | return 0; | |
7818 | } | |
7819 | ||
7820 | //======================================================================= | |
7821 | //function : VMoveView | |
7822 | //purpose : | |
7823 | //======================================================================= | |
7824 | static Standard_Integer VMoveView (Draw_Interpretor& di, | |
7825 | Standard_Integer argc, | |
7826 | const char ** argv) | |
7827 | { | |
7828 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
7829 | if(aContext.IsNull()) | |
7830 | { | |
7831 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
7832 | return 1; | |
7833 | } | |
7834 | if(argc < 4 || argc > 5) | |
7835 | { | |
7836 | di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n"; | |
7837 | return 1; | |
7838 | } | |
6b62b2da | 7839 | Standard_Real Dx = Draw::Atof (argv[1]); |
7840 | Standard_Real Dy = Draw::Atof (argv[2]); | |
7841 | Standard_Real Dz = Draw::Atof (argv[3]); | |
4754e164 | 7842 | Standard_Boolean aStart = Standard_True; |
7843 | if (argc == 5) | |
7844 | { | |
6b62b2da | 7845 | aStart = (Draw::Atoi (argv[4]) > 0); |
4754e164 | 7846 | } |
7847 | ||
7848 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7849 | aView->Move(Dx,Dy,Dz,aStart); | |
7850 | return 0; | |
7851 | } | |
7852 | ||
7853 | //======================================================================= | |
7854 | //function : VTranslateView | |
7855 | //purpose : | |
7856 | //======================================================================= | |
7857 | static Standard_Integer VTranslateView (Draw_Interpretor& di, | |
7858 | Standard_Integer argc, | |
7859 | const char ** argv) | |
7860 | { | |
7861 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
7862 | if(aContext.IsNull()) | |
7863 | { | |
7864 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
7865 | return 1; | |
7866 | } | |
7867 | if(argc < 4 || argc > 5) | |
7868 | { | |
7869 | di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n"; | |
7870 | return 1; | |
7871 | } | |
6b62b2da | 7872 | Standard_Real Dx = Draw::Atof (argv[1]); |
7873 | Standard_Real Dy = Draw::Atof (argv[2]); | |
7874 | Standard_Real Dz = Draw::Atof (argv[3]); | |
4754e164 | 7875 | Standard_Boolean aStart = Standard_True; |
dc3fe572 | 7876 | if (argc == 5) |
4754e164 | 7877 | { |
6b62b2da | 7878 | aStart = (Draw::Atoi (argv[4]) > 0); |
4754e164 | 7879 | } |
7880 | ||
7881 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7882 | aView->Translate(Dx,Dy,Dz,aStart); | |
7883 | return 0; | |
7884 | } | |
7885 | ||
7886 | //======================================================================= | |
7887 | //function : VTurnView | |
7888 | //purpose : | |
7889 | //======================================================================= | |
7890 | static Standard_Integer VTurnView (Draw_Interpretor& di, | |
7891 | Standard_Integer argc, | |
7892 | const char ** argv) | |
7893 | { | |
7894 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
7895 | if(aContext.IsNull()) { | |
7896 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
7897 | return 1; | |
7898 | } | |
7899 | if(argc < 4 || argc > 5){ | |
7900 | di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n"; | |
7901 | return 1; | |
7902 | } | |
6b62b2da | 7903 | Standard_Real Ax = Draw::Atof (argv[1]); |
7904 | Standard_Real Ay = Draw::Atof (argv[2]); | |
7905 | Standard_Real Az = Draw::Atof (argv[3]); | |
4754e164 | 7906 | Standard_Boolean aStart = Standard_True; |
dc3fe572 | 7907 | if (argc == 5) |
4754e164 | 7908 | { |
6b62b2da | 7909 | aStart = (Draw::Atoi (argv[4]) > 0); |
4754e164 | 7910 | } |
7911 | ||
7912 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7913 | aView->Turn(Ax,Ay,Az,aStart); | |
7914 | return 0; | |
7915 | } | |
7916 | ||
269294d6 | 7917 | //============================================================================== |
7918 | //function : VTextureEnv | |
7919 | //purpose : ENables or disables environment mapping | |
7920 | //============================================================================== | |
7921 | class OCC_TextureEnv : public Graphic3d_TextureEnv | |
7922 | { | |
7923 | public: | |
7924 | OCC_TextureEnv(const Standard_CString FileName); | |
7925 | OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName); | |
7926 | void SetTextureParameters(const Standard_Boolean theRepeatFlag, | |
7927 | const Standard_Boolean theModulateFlag, | |
7928 | const Graphic3d_TypeOfTextureFilter theFilter, | |
7929 | const Standard_ShortReal theXScale, | |
7930 | const Standard_ShortReal theYScale, | |
7931 | const Standard_ShortReal theXShift, | |
7932 | const Standard_ShortReal theYShift, | |
7933 | const Standard_ShortReal theAngle); | |
68858c7d | 7934 | DEFINE_STANDARD_RTTI_INLINE(OCC_TextureEnv,Graphic3d_TextureEnv) |
269294d6 | 7935 | }; |
a3f6f591 | 7936 | DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv) |
ec357c5c | 7937 | |
269294d6 | 7938 | OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName) |
7939 | : Graphic3d_TextureEnv(theFileName) | |
7940 | { | |
7941 | } | |
7942 | ||
7943 | OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId) | |
7944 | : Graphic3d_TextureEnv(theTexId) | |
7945 | { | |
7946 | } | |
7947 | ||
7948 | void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag, | |
7949 | const Standard_Boolean theModulateFlag, | |
7950 | const Graphic3d_TypeOfTextureFilter theFilter, | |
7951 | const Standard_ShortReal theXScale, | |
7952 | const Standard_ShortReal theYScale, | |
7953 | const Standard_ShortReal theXShift, | |
7954 | const Standard_ShortReal theYShift, | |
7955 | const Standard_ShortReal theAngle) | |
7956 | { | |
7957 | myParams->SetRepeat (theRepeatFlag); | |
7958 | myParams->SetModulate (theModulateFlag); | |
7959 | myParams->SetFilter (theFilter); | |
7960 | myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale)); | |
7961 | myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift)); | |
7962 | myParams->SetRotation (theAngle); | |
7963 | } | |
7964 | ||
35e08fe8 | 7965 | static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec) |
269294d6 | 7966 | { |
7967 | // get the active view | |
7968 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
7969 | if (aView.IsNull()) | |
7970 | { | |
23fe70ec | 7971 | Message::SendFail ("Error: no active viewer"); |
269294d6 | 7972 | return 1; |
7973 | } | |
7974 | ||
7975 | // Checking the input arguments | |
7976 | Standard_Boolean anEnableFlag = Standard_False; | |
7977 | Standard_Boolean isOk = theArgNb >= 2; | |
7978 | if (isOk) | |
7979 | { | |
7980 | TCollection_AsciiString anEnableOpt(theArgVec[1]); | |
7981 | anEnableFlag = anEnableOpt.IsEqual("on"); | |
7982 | isOk = anEnableFlag || anEnableOpt.IsEqual("off"); | |
7983 | } | |
7984 | if (anEnableFlag) | |
7985 | { | |
7986 | isOk = (theArgNb == 3 || theArgNb == 11); | |
7987 | if (isOk) | |
7988 | { | |
7989 | TCollection_AsciiString aTextureOpt(theArgVec[2]); | |
7990 | isOk = (!aTextureOpt.IsIntegerValue() || | |
7991 | (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN)); | |
7992 | ||
7993 | if (isOk && theArgNb == 11) | |
7994 | { | |
7995 | TCollection_AsciiString aRepeatOpt (theArgVec[3]), | |
7996 | aModulateOpt(theArgVec[4]), | |
7997 | aFilterOpt (theArgVec[5]), | |
7998 | aSScaleOpt (theArgVec[6]), | |
7999 | aTScaleOpt (theArgVec[7]), | |
8000 | aSTransOpt (theArgVec[8]), | |
8001 | aTTransOpt (theArgVec[9]), | |
8002 | anAngleOpt (theArgVec[10]); | |
8003 | isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) && | |
8004 | (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) && | |
8005 | (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) && | |
d45edf24 | 8006 | aSScaleOpt.IsRealValue (Standard_True) && aTScaleOpt.IsRealValue (Standard_True) && |
8007 | aSTransOpt.IsRealValue (Standard_True) && aTTransOpt.IsRealValue (Standard_True) && | |
8008 | anAngleOpt.IsRealValue (Standard_True)); | |
269294d6 | 8009 | } |
8010 | } | |
8011 | } | |
8012 | ||
8013 | if (!isOk) | |
8014 | { | |
23fe70ec | 8015 | Message::SendFail() << "Usage:\n" |
8016 | << theArgVec[0] << " off\n" | |
8017 | << 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]"; | |
269294d6 | 8018 | return 1; |
8019 | } | |
8020 | ||
8021 | if (anEnableFlag) | |
8022 | { | |
8023 | TCollection_AsciiString aTextureOpt(theArgVec[2]); | |
8024 | Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ? | |
8025 | new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) : | |
8026 | new OCC_TextureEnv(theArgVec[2]); | |
8027 | ||
8028 | if (theArgNb == 11) | |
8029 | { | |
8030 | TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]); | |
8031 | aTexEnv->SetTextureParameters( | |
8032 | aRepeatOpt. IsEqual("repeat"), | |
8033 | aModulateOpt.IsEqual("modulate"), | |
8034 | aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST : | |
8035 | aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR : | |
8036 | Graphic3d_TOTF_TRILINEAR, | |
8037 | (Standard_ShortReal)Draw::Atof(theArgVec[6]), | |
8038 | (Standard_ShortReal)Draw::Atof(theArgVec[7]), | |
8039 | (Standard_ShortReal)Draw::Atof(theArgVec[8]), | |
8040 | (Standard_ShortReal)Draw::Atof(theArgVec[9]), | |
8041 | (Standard_ShortReal)Draw::Atof(theArgVec[10]) | |
8042 | ); | |
8043 | } | |
8044 | aView->SetTextureEnv(aTexEnv); | |
269294d6 | 8045 | } |
8046 | else // Disabling environment mapping | |
8047 | { | |
269294d6 | 8048 | Handle(Graphic3d_TextureEnv) aTexture; |
8049 | aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data | |
8050 | } | |
8051 | ||
8052 | aView->Redraw(); | |
8053 | return 0; | |
8054 | } | |
8055 | ||
3e05329c | 8056 | namespace |
8057 | { | |
8058 | typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes; | |
8059 | ||
8060 | //! Remove registered clipping plane from all views and objects. | |
8061 | static void removePlane (MapOfPlanes& theRegPlanes, | |
8062 | const TCollection_AsciiString& theName) | |
8063 | { | |
8064 | Handle(Graphic3d_ClipPlane) aClipPlane; | |
8065 | if (!theRegPlanes.Find (theName, aClipPlane)) | |
8066 | { | |
23fe70ec | 8067 | Message::SendWarning ("Warning: no such plane"); |
3e05329c | 8068 | return; |
8069 | } | |
8070 | ||
8071 | theRegPlanes.UnBind (theName); | |
8072 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS()); | |
8073 | anIObjIt.More(); anIObjIt.Next()) | |
8074 | { | |
8f521168 | 8075 | const Handle(AIS_InteractiveObject)& aPrs = anIObjIt.Key1(); |
3e05329c | 8076 | aPrs->RemoveClipPlane (aClipPlane); |
8077 | } | |
8078 | ||
8079 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews); | |
8080 | aViewIt.More(); aViewIt.Next()) | |
8081 | { | |
8082 | const Handle(V3d_View)& aView = aViewIt.Key2(); | |
8083 | aView->RemoveClipPlane(aClipPlane); | |
8084 | } | |
8085 | ||
8086 | ViewerTest::RedrawAllViews(); | |
8087 | } | |
8088 | } | |
8089 | ||
4269bd1b | 8090 | //=============================================================================================== |
8091 | //function : VClipPlane | |
8092 | //purpose : | |
8093 | //=============================================================================================== | |
8094 | static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
8095 | { | |
8096 | // use short-cut for created clip planes map of created (or "registered by name") clip planes | |
4269bd1b | 8097 | static MapOfPlanes aRegPlanes; |
8098 | ||
8099 | if (theArgsNb < 2) | |
8100 | { | |
3e05329c | 8101 | for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More(); aPlaneIter.Next()) |
8102 | { | |
8103 | theDi << aPlaneIter.Key() << " "; | |
8104 | } | |
8105 | return 0; | |
4269bd1b | 8106 | } |
8107 | ||
8108 | TCollection_AsciiString aCommand (theArgVec[1]); | |
3e05329c | 8109 | aCommand.LowerCase(); |
8110 | const Handle(V3d_View)& anActiveView = ViewerTest::CurrentView(); | |
8111 | if (anActiveView.IsNull()) | |
8112 | { | |
23fe70ec | 8113 | Message::SendFail ("Error: no active viewer"); |
3e05329c | 8114 | return 1; |
8115 | } | |
4269bd1b | 8116 | |
8117 | // print maximum number of planes for current viewer | |
3e05329c | 8118 | if (aCommand == "-maxplanes" |
8119 | || aCommand == "maxplanes") | |
4269bd1b | 8120 | { |
3e05329c | 8121 | theDi << anActiveView->Viewer()->Driver()->InquirePlaneLimit() |
8122 | << " plane slots provided by driver.\n"; | |
4269bd1b | 8123 | return 0; |
8124 | } | |
8125 | ||
8126 | // create / delete plane instance | |
3e05329c | 8127 | if (aCommand == "-create" |
8128 | || aCommand == "create" | |
8129 | || aCommand == "-delete" | |
8130 | || aCommand == "delete" | |
8131 | || aCommand == "-clone" | |
8132 | || aCommand == "clone") | |
4269bd1b | 8133 | { |
8134 | if (theArgsNb < 3) | |
8135 | { | |
23fe70ec | 8136 | Message::SendFail ("Syntax error: plane name is required"); |
4269bd1b | 8137 | return 1; |
8138 | } | |
8139 | ||
3e05329c | 8140 | Standard_Boolean toCreate = aCommand == "-create" |
8141 | || aCommand == "create"; | |
8142 | Standard_Boolean toClone = aCommand == "-clone" | |
8143 | || aCommand == "clone"; | |
8144 | Standard_Boolean toDelete = aCommand == "-delete" | |
8145 | || aCommand == "delete"; | |
4269bd1b | 8146 | TCollection_AsciiString aPlane (theArgVec[2]); |
8147 | ||
8148 | if (toCreate) | |
8149 | { | |
8150 | if (aRegPlanes.IsBound (aPlane)) | |
8151 | { | |
3e05329c | 8152 | std::cout << "Warning: existing plane has been overridden.\n"; |
8153 | toDelete = true; | |
8154 | } | |
8155 | else | |
8156 | { | |
8157 | aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane()); | |
8158 | return 0; | |
4269bd1b | 8159 | } |
4269bd1b | 8160 | } |
8161 | else if (toClone) // toClone | |
8162 | { | |
8163 | if (!aRegPlanes.IsBound (aPlane)) | |
8164 | { | |
23fe70ec | 8165 | Message::SendFail ("Error: no such plane"); |
4269bd1b | 8166 | return 1; |
8167 | } | |
3e05329c | 8168 | else if (theArgsNb < 4) |
4269bd1b | 8169 | { |
23fe70ec | 8170 | Message::SendFail ("Syntax error: enter name for new plane"); |
4269bd1b | 8171 | return 1; |
8172 | } | |
8173 | ||
8174 | TCollection_AsciiString aClone (theArgVec[3]); | |
8175 | if (aRegPlanes.IsBound (aClone)) | |
8176 | { | |
23fe70ec | 8177 | Message::SendFail ("Error: plane name is in use"); |
4269bd1b | 8178 | return 1; |
8179 | } | |
8180 | ||
8181 | const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane); | |
8182 | ||
8183 | aRegPlanes.Bind (aClone, aClipPlane->Clone()); | |
3e05329c | 8184 | return 0; |
4269bd1b | 8185 | } |
4269bd1b | 8186 | |
3e05329c | 8187 | if (toDelete) |
8188 | { | |
8189 | if (aPlane == "ALL" | |
8190 | || aPlane == "all" | |
8191 | || aPlane == "*") | |
4269bd1b | 8192 | { |
3e05329c | 8193 | for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More();) |
8194 | { | |
8195 | aPlane = aPlaneIter.Key(); | |
8196 | removePlane (aRegPlanes, aPlane); | |
8197 | aPlaneIter = MapOfPlanes::Iterator (aRegPlanes); | |
8198 | } | |
4269bd1b | 8199 | } |
3e05329c | 8200 | else |
4269bd1b | 8201 | { |
3e05329c | 8202 | removePlane (aRegPlanes, aPlane); |
4269bd1b | 8203 | } |
4269bd1b | 8204 | } |
8205 | ||
3e05329c | 8206 | if (toCreate) |
8207 | { | |
8208 | aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane()); | |
8209 | } | |
4269bd1b | 8210 | return 0; |
8211 | } | |
8212 | ||
8213 | // set / unset plane command | |
3e05329c | 8214 | if (aCommand == "set" |
8215 | || aCommand == "unset") | |
4269bd1b | 8216 | { |
3e05329c | 8217 | if (theArgsNb < 5) |
4269bd1b | 8218 | { |
23fe70ec | 8219 | Message::SendFail ("Syntax error: need more arguments"); |
4269bd1b | 8220 | return 1; |
8221 | } | |
8222 | ||
3e05329c | 8223 | // redirect to new syntax |
8224 | NCollection_Array1<const char*> anArgVec (1, theArgsNb - 1); | |
8225 | anArgVec.SetValue (1, theArgVec[0]); | |
8226 | anArgVec.SetValue (2, theArgVec[2]); | |
8227 | anArgVec.SetValue (3, aCommand == "set" ? "-set" : "-unset"); | |
8228 | for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt) | |
4269bd1b | 8229 | { |
3e05329c | 8230 | anArgVec.SetValue (anIt, theArgVec[anIt]); |
4269bd1b | 8231 | } |
8232 | ||
3e05329c | 8233 | return VClipPlane (theDi, anArgVec.Length(), &anArgVec.ChangeFirst()); |
4269bd1b | 8234 | } |
8235 | ||
8236 | // change plane command | |
3e05329c | 8237 | TCollection_AsciiString aPlaneName; |
8238 | Handle(Graphic3d_ClipPlane) aClipPlane; | |
8239 | Standard_Integer anArgIter = 0; | |
8240 | if (aCommand == "-change" | |
8241 | || aCommand == "change") | |
4269bd1b | 8242 | { |
3e05329c | 8243 | // old syntax support |
8244 | if (theArgsNb < 3) | |
4269bd1b | 8245 | { |
23fe70ec | 8246 | Message::SendFail ("Syntax error: need more arguments"); |
4269bd1b | 8247 | return 1; |
8248 | } | |
8249 | ||
3e05329c | 8250 | anArgIter = 3; |
8251 | aPlaneName = theArgVec[2]; | |
8252 | if (!aRegPlanes.Find (aPlaneName, aClipPlane)) | |
4269bd1b | 8253 | { |
23fe70ec | 8254 | Message::SendFail() << "Error: no such plane '" << aPlaneName << "'"; |
4269bd1b | 8255 | return 1; |
8256 | } | |
3e05329c | 8257 | } |
8258 | else if (aRegPlanes.Find (theArgVec[1], aClipPlane)) | |
8259 | { | |
8260 | anArgIter = 2; | |
8261 | aPlaneName = theArgVec[1]; | |
8262 | } | |
8263 | else | |
8264 | { | |
8265 | anArgIter = 2; | |
8266 | aPlaneName = theArgVec[1]; | |
8267 | aClipPlane = new Graphic3d_ClipPlane(); | |
8268 | aRegPlanes.Bind (aPlaneName, aClipPlane); | |
8269 | theDi << "Created new plane " << aPlaneName << ".\n"; | |
8270 | } | |
4269bd1b | 8271 | |
3e05329c | 8272 | if (theArgsNb - anArgIter < 1) |
8273 | { | |
23fe70ec | 8274 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8275 | return 1; |
8276 | } | |
4269bd1b | 8277 | |
3e05329c | 8278 | for (; anArgIter < theArgsNb; ++anArgIter) |
8279 | { | |
8280 | const char** aChangeArgs = theArgVec + anArgIter; | |
8281 | Standard_Integer aNbChangeArgs = theArgsNb - anArgIter; | |
8282 | TCollection_AsciiString aChangeArg (aChangeArgs[0]); | |
8283 | aChangeArg.LowerCase(); | |
4269bd1b | 8284 | |
3e05329c | 8285 | Standard_Boolean toEnable = Standard_True; |
dae2a922 | 8286 | if (Draw::ParseOnOff (aChangeArgs[0], toEnable)) |
4269bd1b | 8287 | { |
3e05329c | 8288 | aClipPlane->SetOn (toEnable); |
4269bd1b | 8289 | } |
25c35042 | 8290 | else if (aChangeArg.StartsWith ("-equation") |
8291 | || aChangeArg.StartsWith ("equation")) | |
4269bd1b | 8292 | { |
3e05329c | 8293 | if (aNbChangeArgs < 5) |
4269bd1b | 8294 | { |
23fe70ec | 8295 | Message::SendFail ("Syntax error: need more arguments"); |
4269bd1b | 8296 | return 1; |
8297 | } | |
8298 | ||
25c35042 | 8299 | Standard_Integer aSubIndex = 1; |
8300 | Standard_Integer aPrefixLen = 8 + (aChangeArg.Value (1) == '-' ? 1 : 0); | |
8301 | if (aPrefixLen < aChangeArg.Length()) | |
8302 | { | |
8303 | TCollection_AsciiString aSubStr = aChangeArg.SubString (aPrefixLen + 1, aChangeArg.Length()); | |
8304 | if (!aSubStr.IsIntegerValue() | |
8305 | || aSubStr.IntegerValue() <= 0) | |
8306 | { | |
23fe70ec | 8307 | Message::SendFail() << "Syntax error: unknown argument '" << aChangeArg << "'"; |
25c35042 | 8308 | return 1; |
8309 | } | |
8310 | aSubIndex = aSubStr.IntegerValue(); | |
8311 | } | |
8312 | ||
8313 | Standard_Real aCoeffA = Draw::Atof (aChangeArgs[1]); | |
8314 | Standard_Real aCoeffB = Draw::Atof (aChangeArgs[2]); | |
8315 | Standard_Real aCoeffC = Draw::Atof (aChangeArgs[3]); | |
8316 | Standard_Real aCoeffD = Draw::Atof (aChangeArgs[4]); | |
8317 | Handle(Graphic3d_ClipPlane) aSubPln = aClipPlane; | |
8318 | for (Standard_Integer aSubPlaneIter = 1; aSubPlaneIter < aSubIndex; ++aSubPlaneIter) | |
8319 | { | |
8320 | if (aSubPln->ChainNextPlane().IsNull()) | |
8321 | { | |
8322 | aSubPln->SetChainNextPlane (new Graphic3d_ClipPlane (*aSubPln)); | |
8323 | } | |
8324 | aSubPln = aSubPln->ChainNextPlane(); | |
8325 | } | |
8326 | aSubPln->SetChainNextPlane (Handle(Graphic3d_ClipPlane)()); | |
8327 | aSubPln->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD)); | |
3e05329c | 8328 | anArgIter += 4; |
4269bd1b | 8329 | } |
25c35042 | 8330 | else if ((aChangeArg == "-boxinterior" |
8331 | || aChangeArg == "-boxint" | |
8332 | || aChangeArg == "-box") | |
8333 | && aNbChangeArgs >= 7) | |
8334 | { | |
8335 | Graphic3d_BndBox3d aBndBox; | |
8336 | aBndBox.Add (Graphic3d_Vec3d (Draw::Atof (aChangeArgs[1]), Draw::Atof (aChangeArgs[2]), Draw::Atof (aChangeArgs[3]))); | |
8337 | aBndBox.Add (Graphic3d_Vec3d (Draw::Atof (aChangeArgs[4]), Draw::Atof (aChangeArgs[5]), Draw::Atof (aChangeArgs[6]))); | |
8338 | anArgIter += 6; | |
8339 | ||
8340 | Standard_Integer aNbSubPlanes = 6; | |
8341 | const Graphic3d_Vec3d aDirArray[6] = | |
8342 | { | |
8343 | Graphic3d_Vec3d (-1, 0, 0), | |
8344 | Graphic3d_Vec3d ( 1, 0, 0), | |
8345 | Graphic3d_Vec3d ( 0,-1, 0), | |
8346 | Graphic3d_Vec3d ( 0, 1, 0), | |
8347 | Graphic3d_Vec3d ( 0, 0,-1), | |
8348 | Graphic3d_Vec3d ( 0, 0, 1), | |
8349 | }; | |
8350 | Handle(Graphic3d_ClipPlane) aSubPln = aClipPlane; | |
8351 | for (Standard_Integer aSubPlaneIter = 0; aSubPlaneIter < aNbSubPlanes; ++aSubPlaneIter) | |
8352 | { | |
8353 | const Graphic3d_Vec3d& aDir = aDirArray[aSubPlaneIter]; | |
8354 | const Standard_Real aW = -aDir.Dot ((aSubPlaneIter % 2 == 1) ? aBndBox.CornerMax() : aBndBox.CornerMin()); | |
8355 | aSubPln->SetEquation (gp_Pln (aDir.x(), aDir.y(), aDir.z(), aW)); | |
8356 | if (aSubPlaneIter + 1 == aNbSubPlanes) | |
8357 | { | |
8358 | aSubPln->SetChainNextPlane (Handle(Graphic3d_ClipPlane)()); | |
8359 | } | |
8360 | else | |
8361 | { | |
8362 | aSubPln->SetChainNextPlane (new Graphic3d_ClipPlane (*aSubPln)); | |
8363 | } | |
8364 | aSubPln = aSubPln->ChainNextPlane(); | |
8365 | } | |
8366 | } | |
3e05329c | 8367 | else if (aChangeArg == "-capping" |
8368 | || aChangeArg == "capping") | |
4269bd1b | 8369 | { |
3e05329c | 8370 | if (aNbChangeArgs < 2) |
4269bd1b | 8371 | { |
23fe70ec | 8372 | Message::SendFail ("Syntax error: need more arguments"); |
4269bd1b | 8373 | return 1; |
8374 | } | |
8375 | ||
dae2a922 | 8376 | if (Draw::ParseOnOff (aChangeArgs[1], toEnable)) |
4269bd1b | 8377 | { |
3e05329c | 8378 | aClipPlane->SetCapping (toEnable); |
8379 | anArgIter += 1; | |
8380 | } | |
8381 | else | |
8382 | { | |
8383 | // just skip otherwise (old syntax) | |
8384 | } | |
8385 | } | |
8386 | else if (aChangeArg == "-useobjectmaterial" | |
8387 | || aChangeArg == "-useobjectmat" | |
8388 | || aChangeArg == "-useobjmat" | |
8389 | || aChangeArg == "-useobjmaterial") | |
8390 | { | |
8391 | if (aNbChangeArgs < 2) | |
8392 | { | |
23fe70ec | 8393 | Message::SendFail ("Syntax error: need more arguments"); |
4269bd1b | 8394 | return 1; |
8395 | } | |
8396 | ||
dae2a922 | 8397 | if (Draw::ParseOnOff (aChangeArgs[1], toEnable)) |
4269bd1b | 8398 | { |
3e05329c | 8399 | aClipPlane->SetUseObjectMaterial (toEnable == Standard_True); |
8400 | anArgIter += 1; | |
4269bd1b | 8401 | } |
3e05329c | 8402 | } |
8403 | else if (aChangeArg == "-useobjecttexture" | |
8404 | || aChangeArg == "-useobjecttex" | |
8405 | || aChangeArg == "-useobjtexture" | |
8406 | || aChangeArg == "-useobjtex") | |
8407 | { | |
8408 | if (aNbChangeArgs < 2) | |
4269bd1b | 8409 | { |
23fe70ec | 8410 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8411 | return 1; |
8412 | } | |
4269bd1b | 8413 | |
dae2a922 | 8414 | if (Draw::ParseOnOff (aChangeArgs[1], toEnable)) |
3e05329c | 8415 | { |
8416 | aClipPlane->SetUseObjectTexture (toEnable == Standard_True); | |
8417 | anArgIter += 1; | |
8418 | } | |
8419 | } | |
8420 | else if (aChangeArg == "-useobjectshader" | |
8421 | || aChangeArg == "-useobjshader") | |
8422 | { | |
8423 | if (aNbChangeArgs < 2) | |
8424 | { | |
23fe70ec | 8425 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8426 | return 1; |
8427 | } | |
4269bd1b | 8428 | |
dae2a922 | 8429 | if (Draw::ParseOnOff (aChangeArgs[1], toEnable)) |
3e05329c | 8430 | { |
8431 | aClipPlane->SetUseObjectShader (toEnable == Standard_True); | |
8432 | anArgIter += 1; | |
4269bd1b | 8433 | } |
3e05329c | 8434 | } |
8435 | else if (aChangeArg == "-color" | |
8436 | || aChangeArg == "color") | |
8437 | { | |
8438 | Quantity_Color aColor; | |
dae2a922 | 8439 | Standard_Integer aNbParsed = Draw::ParseColor (aNbChangeArgs - 1, |
8440 | aChangeArgs + 1, | |
8441 | aColor); | |
3e05329c | 8442 | if (aNbParsed == 0) |
4269bd1b | 8443 | { |
23fe70ec | 8444 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8445 | return 1; |
8446 | } | |
61168418 | 8447 | aClipPlane->SetCappingColor (aColor); |
3e05329c | 8448 | anArgIter += aNbParsed; |
8449 | } | |
61168418 | 8450 | else if (aNbChangeArgs >= 1 |
8451 | && (aChangeArg == "-material" | |
8452 | || aChangeArg == "material")) | |
8453 | { | |
8454 | ++anArgIter; | |
8455 | Graphic3d_NameOfMaterial aMatName; | |
8456 | if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeArgs[1], aMatName)) | |
8457 | { | |
23fe70ec | 8458 | Message::SendFail() << "Syntax error: unknown material '" << aChangeArgs[1] << "'"; |
61168418 | 8459 | return 1; |
8460 | } | |
8461 | aClipPlane->SetCappingMaterial (aMatName); | |
8462 | } | |
1b661a81 | 8463 | else if ((aChangeArg == "-transparency" |
8464 | || aChangeArg == "-transp") | |
8465 | && aNbChangeArgs >= 2) | |
8466 | { | |
8467 | TCollection_AsciiString aValStr (aChangeArgs[1]); | |
8468 | Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect(); | |
d45edf24 | 8469 | if (aValStr.IsRealValue (Standard_True)) |
1b661a81 | 8470 | { |
8471 | Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial(); | |
8472 | aMat.SetTransparency ((float )aValStr.RealValue()); | |
8473 | anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto); | |
8474 | aClipPlane->SetCappingMaterial (aMat); | |
8475 | } | |
8476 | else | |
8477 | { | |
8478 | aValStr.LowerCase(); | |
8479 | Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto; | |
8480 | if (aValStr == "opaque") | |
8481 | { | |
8482 | aMode = Graphic3d_AlphaMode_Opaque; | |
8483 | } | |
8484 | else if (aValStr == "mask") | |
8485 | { | |
8486 | aMode = Graphic3d_AlphaMode_Mask; | |
8487 | } | |
8488 | else if (aValStr == "blend") | |
8489 | { | |
8490 | aMode = Graphic3d_AlphaMode_Blend; | |
8491 | } | |
33425a46 | 8492 | else if (aValStr == "maskblend" |
8493 | || aValStr == "blendmask") | |
8494 | { | |
8495 | aMode = Graphic3d_AlphaMode_MaskBlend; | |
8496 | } | |
1b661a81 | 8497 | else if (aValStr == "blendauto") |
8498 | { | |
8499 | aMode = Graphic3d_AlphaMode_BlendAuto; | |
8500 | } | |
8501 | else | |
8502 | { | |
23fe70ec | 8503 | Message::SendFail() << "Syntax error at '" << aValStr << "'"; |
1b661a81 | 8504 | return 1; |
8505 | } | |
8506 | anAspect->SetAlphaMode (aMode); | |
8507 | aClipPlane->SetCappingAspect (anAspect); | |
8508 | } | |
8509 | anArgIter += 1; | |
8510 | } | |
3e05329c | 8511 | else if (aChangeArg == "-texname" |
8512 | || aChangeArg == "texname") | |
8513 | { | |
8514 | if (aNbChangeArgs < 2) | |
8515 | { | |
23fe70ec | 8516 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8517 | return 1; |
8518 | } | |
4269bd1b | 8519 | |
3e05329c | 8520 | TCollection_AsciiString aTextureName (aChangeArgs[1]); |
8521 | Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); | |
8522 | if (!aTexture->IsDone()) | |
8523 | { | |
8524 | aClipPlane->SetCappingTexture (NULL); | |
4269bd1b | 8525 | } |
3e05329c | 8526 | else |
4269bd1b | 8527 | { |
3e05329c | 8528 | aTexture->EnableModulate(); |
8529 | aTexture->EnableRepeat(); | |
8530 | aClipPlane->SetCappingTexture (aTexture); | |
8531 | } | |
8532 | anArgIter += 1; | |
8533 | } | |
8534 | else if (aChangeArg == "-texscale" | |
8535 | || aChangeArg == "texscale") | |
8536 | { | |
8537 | if (aClipPlane->CappingTexture().IsNull()) | |
8538 | { | |
23fe70ec | 8539 | Message::SendFail ("Error: no texture is set"); |
3e05329c | 8540 | return 1; |
8541 | } | |
4269bd1b | 8542 | |
3e05329c | 8543 | if (aNbChangeArgs < 3) |
8544 | { | |
23fe70ec | 8545 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8546 | return 1; |
8547 | } | |
4269bd1b | 8548 | |
3e05329c | 8549 | Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); |
8550 | Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); | |
8551 | aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); | |
8552 | anArgIter += 2; | |
8553 | } | |
8554 | else if (aChangeArg == "-texorigin" | |
8555 | || aChangeArg == "texorigin") // texture origin | |
8556 | { | |
8557 | if (aClipPlane->CappingTexture().IsNull()) | |
8558 | { | |
23fe70ec | 8559 | Message::SendFail ("Error: no texture is set"); |
3e05329c | 8560 | return 1; |
8561 | } | |
4269bd1b | 8562 | |
3e05329c | 8563 | if (aNbChangeArgs < 3) |
8564 | { | |
23fe70ec | 8565 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8566 | return 1; |
4269bd1b | 8567 | } |
3e05329c | 8568 | |
8569 | Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); | |
8570 | Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); | |
8571 | ||
8572 | aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); | |
8573 | anArgIter += 2; | |
8574 | } | |
8575 | else if (aChangeArg == "-texrotate" | |
8576 | || aChangeArg == "texrotate") // texture rotation | |
8577 | { | |
8578 | if (aClipPlane->CappingTexture().IsNull()) | |
4269bd1b | 8579 | { |
23fe70ec | 8580 | Message::SendFail ("Error: no texture is set"); |
3e05329c | 8581 | return 1; |
8582 | } | |
4269bd1b | 8583 | |
3e05329c | 8584 | if (aNbChangeArgs < 2) |
8585 | { | |
23fe70ec | 8586 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8587 | return 1; |
8588 | } | |
4269bd1b | 8589 | |
3e05329c | 8590 | Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); |
8591 | aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot); | |
8592 | anArgIter += 1; | |
8593 | } | |
8594 | else if (aChangeArg == "-hatch" | |
8595 | || aChangeArg == "hatch") | |
8596 | { | |
8597 | if (aNbChangeArgs < 2) | |
8598 | { | |
23fe70ec | 8599 | Message::SendFail ("Syntax error: need more arguments"); |
3e05329c | 8600 | return 1; |
8601 | } | |
4269bd1b | 8602 | |
3e05329c | 8603 | TCollection_AsciiString aHatchStr (aChangeArgs[1]); |
8604 | aHatchStr.LowerCase(); | |
8605 | if (aHatchStr == "on") | |
8606 | { | |
8607 | aClipPlane->SetCappingHatchOn(); | |
8608 | } | |
8609 | else if (aHatchStr == "off") | |
8610 | { | |
8611 | aClipPlane->SetCappingHatchOff(); | |
4269bd1b | 8612 | } |
3e05329c | 8613 | else |
4269bd1b | 8614 | { |
3e05329c | 8615 | aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1])); |
8616 | } | |
8617 | anArgIter += 1; | |
8618 | } | |
8619 | else if (aChangeArg == "-delete" | |
8620 | || aChangeArg == "delete") | |
8621 | { | |
8622 | removePlane (aRegPlanes, aPlaneName); | |
8623 | return 0; | |
8624 | } | |
8625 | else if (aChangeArg == "-set" | |
32ca7711 | 8626 | || aChangeArg == "-unset" |
8627 | || aChangeArg == "-setoverrideglobal") | |
3e05329c | 8628 | { |
8629 | // set / unset plane command | |
32ca7711 | 8630 | const Standard_Boolean toSet = aChangeArg.StartsWith ("-set"); |
8631 | const Standard_Boolean toOverrideGlobal = aChangeArg == "-setoverrideglobal"; | |
3e05329c | 8632 | Standard_Integer anIt = 1; |
8633 | for (; anIt < aNbChangeArgs; ++anIt) | |
8634 | { | |
8635 | TCollection_AsciiString anEntityName (aChangeArgs[anIt]); | |
8636 | if (anEntityName.IsEmpty() | |
8637 | || anEntityName.Value (1) == '-') | |
4269bd1b | 8638 | { |
3e05329c | 8639 | break; |
4269bd1b | 8640 | } |
32ca7711 | 8641 | else if (!toOverrideGlobal |
8642 | && ViewerTest_myViews.IsBound1 (anEntityName)) | |
4269bd1b | 8643 | { |
3e05329c | 8644 | Handle(V3d_View) aView = ViewerTest_myViews.Find1 (anEntityName); |
8645 | if (toSet) | |
8646 | { | |
8647 | aView->AddClipPlane (aClipPlane); | |
8648 | } | |
8649 | else | |
8650 | { | |
8651 | aView->RemoveClipPlane (aClipPlane); | |
8652 | } | |
8653 | continue; | |
4269bd1b | 8654 | } |
3e05329c | 8655 | else if (GetMapOfAIS().IsBound2 (anEntityName)) |
4269bd1b | 8656 | { |
8f521168 | 8657 | Handle(AIS_InteractiveObject) aIObj = GetMapOfAIS().Find2 (anEntityName); |
3e05329c | 8658 | if (toSet) |
8659 | { | |
8660 | aIObj->AddClipPlane (aClipPlane); | |
8661 | } | |
8662 | else | |
8663 | { | |
8664 | aIObj->RemoveClipPlane (aClipPlane); | |
8665 | } | |
32ca7711 | 8666 | if (!aIObj->ClipPlanes().IsNull()) |
8667 | { | |
8668 | aIObj->ClipPlanes()->SetOverrideGlobal (toOverrideGlobal); | |
8669 | } | |
4269bd1b | 8670 | } |
3e05329c | 8671 | else |
4269bd1b | 8672 | { |
23fe70ec | 8673 | Message::SendFail() << "Error: object/view '" << anEntityName << "' is not found"; |
3e05329c | 8674 | return 1; |
4269bd1b | 8675 | } |
3e05329c | 8676 | } |
8677 | ||
8678 | if (anIt == 1) | |
8679 | { | |
8680 | // apply to active view | |
8681 | if (toSet) | |
4269bd1b | 8682 | { |
3e05329c | 8683 | anActiveView->AddClipPlane (aClipPlane); |
4269bd1b | 8684 | } |
8685 | else | |
8686 | { | |
3e05329c | 8687 | anActiveView->RemoveClipPlane (aClipPlane); |
4269bd1b | 8688 | } |
8689 | } | |
3e05329c | 8690 | else |
8691 | { | |
8692 | anArgIter = anArgIter + anIt - 1; | |
8693 | } | |
8694 | } | |
8695 | else | |
8696 | { | |
23fe70ec | 8697 | Message::SendFail() << "Syntax error: unknown argument '" << aChangeArg << "'"; |
3e05329c | 8698 | return 1; |
4269bd1b | 8699 | } |
4269bd1b | 8700 | } |
8701 | ||
3e05329c | 8702 | ViewerTest::RedrawAllViews(); |
8703 | return 0; | |
4269bd1b | 8704 | } |
8705 | ||
b5ac8292 | 8706 | //=============================================================================================== |
8707 | //function : VZRange | |
8708 | //purpose : | |
8709 | //=============================================================================================== | |
8710 | static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
8711 | { | |
197ac94e | 8712 | const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView(); |
8713 | ||
8714 | if (aCurrentView.IsNull()) | |
b5ac8292 | 8715 | { |
23fe70ec | 8716 | Message::SendFail ("Error: no active viewer"); |
b5ac8292 | 8717 | return 1; |
8718 | } | |
8719 | ||
197ac94e | 8720 | Handle(Graphic3d_Camera) aCamera = aCurrentView->Camera(); |
b5ac8292 | 8721 | |
8722 | if (theArgsNb < 2) | |
8723 | { | |
8724 | theDi << "ZNear: " << aCamera->ZNear() << "\n"; | |
8725 | theDi << "ZFar: " << aCamera->ZFar() << "\n"; | |
8726 | return 0; | |
8727 | } | |
8728 | ||
8729 | if (theArgsNb == 3) | |
8730 | { | |
6b62b2da | 8731 | Standard_Real aNewZNear = Draw::Atof (theArgVec[1]); |
8732 | Standard_Real aNewZFar = Draw::Atof (theArgVec[2]); | |
197ac94e | 8733 | |
8734 | if (aNewZNear >= aNewZFar) | |
8735 | { | |
23fe70ec | 8736 | Message::SendFail ("Syntax error: invalid arguments: znear should be less than zfar"); |
197ac94e | 8737 | return 1; |
8738 | } | |
8739 | ||
8740 | if (!aCamera->IsOrthographic() && (aNewZNear <= 0.0 || aNewZFar <= 0.0)) | |
8741 | { | |
23fe70ec | 8742 | Message::SendFail ("Syntax error: invalid arguments: znear, zfar should be positive for perspective camera"); |
197ac94e | 8743 | return 1; |
8744 | } | |
8745 | ||
8746 | aCamera->SetZRange (aNewZNear, aNewZFar); | |
b5ac8292 | 8747 | } |
8748 | else | |
8749 | { | |
23fe70ec | 8750 | Message::SendFail ("Syntax error: wrong command arguments"); |
b5ac8292 | 8751 | return 1; |
8752 | } | |
8753 | ||
197ac94e | 8754 | aCurrentView->Redraw(); |
8755 | ||
b5ac8292 | 8756 | return 0; |
8757 | } | |
8758 | ||
8759 | //=============================================================================================== | |
8760 | //function : VAutoZFit | |
8761 | //purpose : | |
8762 | //=============================================================================================== | |
8763 | static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) | |
8764 | { | |
197ac94e | 8765 | const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView(); |
8766 | ||
8767 | if (aCurrentView.IsNull()) | |
b5ac8292 | 8768 | { |
23fe70ec | 8769 | Message::SendFail ("Error: no active viewer"); |
b5ac8292 | 8770 | return 1; |
8771 | } | |
8772 | ||
c357e426 | 8773 | Standard_Real aScale = aCurrentView->AutoZFitScaleFactor(); |
197ac94e | 8774 | |
8775 | if (theArgsNb > 3) | |
b5ac8292 | 8776 | { |
23fe70ec | 8777 | Message::SendFail ("Syntax error: wrong command arguments"); |
197ac94e | 8778 | return 1; |
b5ac8292 | 8779 | } |
8780 | ||
197ac94e | 8781 | if (theArgsNb < 2) |
b5ac8292 | 8782 | { |
586db386 | 8783 | theDi << "Auto z-fit mode: \n" |
c357e426 | 8784 | << "On: " << (aCurrentView->AutoZFitMode() ? "enabled" : "disabled") << "\n" |
197ac94e | 8785 | << "Scale: " << aScale << "\n"; |
8786 | return 0; | |
b5ac8292 | 8787 | } |
197ac94e | 8788 | |
8789 | Standard_Boolean isOn = Draw::Atoi (theArgVec[1]) == 1; | |
8790 | ||
8791 | if (theArgsNb >= 3) | |
b5ac8292 | 8792 | { |
197ac94e | 8793 | aScale = Draw::Atoi (theArgVec[2]); |
b5ac8292 | 8794 | } |
8795 | ||
c357e426 | 8796 | aCurrentView->SetAutoZFitMode (isOn, aScale); |
197ac94e | 8797 | aCurrentView->Redraw(); |
b5ac8292 | 8798 | return 0; |
8799 | } | |
8800 | ||
6b62b2da | 8801 | //! Auxiliary function to print projection type |
8802 | inline const char* projTypeName (Graphic3d_Camera::Projection theProjType) | |
8803 | { | |
8804 | switch (theProjType) | |
8805 | { | |
8806 | case Graphic3d_Camera::Projection_Orthographic: return "orthographic"; | |
8807 | case Graphic3d_Camera::Projection_Perspective: return "perspective"; | |
8808 | case Graphic3d_Camera::Projection_Stereo: return "stereoscopic"; | |
8809 | case Graphic3d_Camera::Projection_MonoLeftEye: return "monoLeftEye"; | |
8810 | case Graphic3d_Camera::Projection_MonoRightEye: return "monoRightEye"; | |
8811 | } | |
8812 | return "UNKNOWN"; | |
8813 | } | |
8814 | ||
b5ac8292 | 8815 | //=============================================================================================== |
6b62b2da | 8816 | //function : VCamera |
b5ac8292 | 8817 | //purpose : |
8818 | //=============================================================================================== | |
6b62b2da | 8819 | static int VCamera (Draw_Interpretor& theDI, |
8820 | Standard_Integer theArgsNb, | |
8821 | const char** theArgVec) | |
b5ac8292 | 8822 | { |
6b62b2da | 8823 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
8824 | if (aView.IsNull()) | |
b5ac8292 | 8825 | { |
23fe70ec | 8826 | Message::SendFail ("Error: no active viewer"); |
b5ac8292 | 8827 | return 1; |
8828 | } | |
8829 | ||
6b62b2da | 8830 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); |
8831 | if (theArgsNb < 2) | |
b5ac8292 | 8832 | { |
6b62b2da | 8833 | theDI << "ProjType: " << projTypeName (aCamera->ProjectionType()) << "\n"; |
8834 | theDI << "FOVy: " << aCamera->FOVy() << "\n"; | |
b40cdc2b | 8835 | theDI << "FOVx: " << aCamera->FOVx() << "\n"; |
8836 | theDI << "FOV2d: " << aCamera->FOV2d() << "\n"; | |
6b62b2da | 8837 | theDI << "Distance: " << aCamera->Distance() << "\n"; |
8838 | theDI << "IOD: " << aCamera->IOD() << "\n"; | |
8839 | theDI << "IODType: " << (aCamera->GetIODType() == Graphic3d_Camera::IODType_Absolute ? "absolute" : "relative") << "\n"; | |
8840 | theDI << "ZFocus: " << aCamera->ZFocus() << "\n"; | |
8841 | theDI << "ZFocusType: " << (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Absolute ? "absolute" : "relative") << "\n"; | |
168c27c6 | 8842 | theDI << "ZNear: " << aCamera->ZNear() << "\n"; |
8843 | theDI << "ZFar: " << aCamera->ZFar() << "\n"; | |
6b62b2da | 8844 | return 0; |
b5ac8292 | 8845 | } |
8846 | ||
30a1b24e | 8847 | TCollection_AsciiString aPrsName; |
6b62b2da | 8848 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) |
b5ac8292 | 8849 | { |
6b62b2da | 8850 | Standard_CString anArg = theArgVec[anArgIter]; |
8851 | TCollection_AsciiString anArgCase (anArg); | |
8852 | anArgCase.LowerCase(); | |
8853 | if (anArgCase == "-proj" | |
8854 | || anArgCase == "-projection" | |
8855 | || anArgCase == "-projtype" | |
8856 | || anArgCase == "-projectiontype") | |
8857 | { | |
8858 | theDI << projTypeName (aCamera->ProjectionType()) << " "; | |
8859 | } | |
8860 | else if (anArgCase == "-ortho" | |
8861 | || anArgCase == "-orthographic") | |
b5ac8292 | 8862 | { |
8863 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic); | |
6b62b2da | 8864 | } |
8865 | else if (anArgCase == "-persp" | |
8866 | || anArgCase == "-perspective" | |
8867 | || anArgCase == "-perspmono" | |
8868 | || anArgCase == "-perspectivemono" | |
8869 | || anArgCase == "-mono") | |
b5ac8292 | 8870 | { |
8871 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective); | |
8872 | } | |
6b62b2da | 8873 | else if (anArgCase == "-stereo" |
8874 | || anArgCase == "-stereoscopic" | |
8875 | || anArgCase == "-perspstereo" | |
8876 | || anArgCase == "-perspectivestereo") | |
8877 | { | |
8878 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo); | |
8879 | } | |
8880 | else if (anArgCase == "-left" | |
8881 | || anArgCase == "-lefteye" | |
8882 | || anArgCase == "-monoleft" | |
8883 | || anArgCase == "-monolefteye" | |
8884 | || anArgCase == "-perpsleft" | |
8885 | || anArgCase == "-perpslefteye") | |
b5ac8292 | 8886 | { |
8887 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye); | |
8888 | } | |
6b62b2da | 8889 | else if (anArgCase == "-right" |
8890 | || anArgCase == "-righteye" | |
8891 | || anArgCase == "-monoright" | |
8892 | || anArgCase == "-monorighteye" | |
8893 | || anArgCase == "-perpsright") | |
b5ac8292 | 8894 | { |
8895 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye); | |
8896 | } | |
6b62b2da | 8897 | else if (anArgCase == "-dist" |
8898 | || anArgCase == "-distance") | |
b5ac8292 | 8899 | { |
6b62b2da | 8900 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
8901 | if (anArgValue != NULL | |
8902 | && *anArgValue != '-') | |
8903 | { | |
8904 | ++anArgIter; | |
8905 | aCamera->SetDistance (Draw::Atof (anArgValue)); | |
8906 | continue; | |
8907 | } | |
8908 | theDI << aCamera->Distance() << " "; | |
b5ac8292 | 8909 | } |
6b62b2da | 8910 | else if (anArgCase == "-iod") |
b5ac8292 | 8911 | { |
6b62b2da | 8912 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
8913 | if (anArgValue != NULL | |
8914 | && *anArgValue != '-') | |
8915 | { | |
8916 | ++anArgIter; | |
8917 | aCamera->SetIOD (aCamera->GetIODType(), Draw::Atof (anArgValue)); | |
8918 | continue; | |
8919 | } | |
8920 | theDI << aCamera->IOD() << " "; | |
b5ac8292 | 8921 | } |
6b62b2da | 8922 | else if (anArgCase == "-iodtype") |
b5ac8292 | 8923 | { |
6b62b2da | 8924 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : ""; |
8925 | TCollection_AsciiString anValueCase (anArgValue); | |
8926 | anValueCase.LowerCase(); | |
8927 | if (anValueCase == "abs" | |
8928 | || anValueCase == "absolute") | |
8929 | { | |
8930 | ++anArgIter; | |
8931 | aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD()); | |
8932 | continue; | |
8933 | } | |
8934 | else if (anValueCase == "rel" | |
8935 | || anValueCase == "relative") | |
8936 | { | |
8937 | ++anArgIter; | |
8938 | aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD()); | |
8939 | continue; | |
8940 | } | |
8941 | else if (*anArgValue != '-') | |
8942 | { | |
23fe70ec | 8943 | Message::SendFail() << "Error: unknown IOD type '" << anArgValue << "'"; |
6b62b2da | 8944 | return 1; |
8945 | } | |
8946 | switch (aCamera->GetIODType()) | |
8947 | { | |
8948 | case Graphic3d_Camera::IODType_Absolute: theDI << "absolute "; break; | |
8949 | case Graphic3d_Camera::IODType_Relative: theDI << "relative "; break; | |
8950 | } | |
b5ac8292 | 8951 | } |
6b62b2da | 8952 | else if (anArgCase == "-zfocus") |
b5ac8292 | 8953 | { |
6b62b2da | 8954 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
8955 | if (anArgValue != NULL | |
8956 | && *anArgValue != '-') | |
8957 | { | |
8958 | ++anArgIter; | |
8959 | aCamera->SetZFocus (aCamera->ZFocusType(), Draw::Atof (anArgValue)); | |
8960 | continue; | |
8961 | } | |
8962 | theDI << aCamera->ZFocus() << " "; | |
b5ac8292 | 8963 | } |
6b62b2da | 8964 | else if (anArgCase == "-zfocustype") |
b5ac8292 | 8965 | { |
6b62b2da | 8966 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : ""; |
8967 | TCollection_AsciiString anValueCase (anArgValue); | |
8968 | anValueCase.LowerCase(); | |
8969 | if (anValueCase == "abs" | |
8970 | || anValueCase == "absolute") | |
8971 | { | |
8972 | ++anArgIter; | |
8973 | aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus()); | |
8974 | continue; | |
8975 | } | |
8976 | else if (anValueCase == "rel" | |
8977 | || anValueCase == "relative") | |
8978 | { | |
8979 | ++anArgIter; | |
8980 | aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus()); | |
8981 | continue; | |
8982 | } | |
8983 | else if (*anArgValue != '-') | |
8984 | { | |
23fe70ec | 8985 | Message::SendFail() << "Error: unknown ZFocus type '" << anArgValue << "'"; |
6b62b2da | 8986 | return 1; |
8987 | } | |
8988 | switch (aCamera->ZFocusType()) | |
8989 | { | |
8990 | case Graphic3d_Camera::FocusType_Absolute: theDI << "absolute "; break; | |
8991 | case Graphic3d_Camera::FocusType_Relative: theDI << "relative "; break; | |
8992 | } | |
8993 | } | |
b40cdc2b | 8994 | else if (anArgCase == "-lockzup" |
8995 | || anArgCase == "-turntable") | |
8996 | { | |
8997 | bool toLockUp = true; | |
8998 | if (++anArgIter < theArgsNb | |
dae2a922 | 8999 | && !Draw::ParseOnOff (theArgVec[anArgIter], toLockUp)) |
b40cdc2b | 9000 | { |
9001 | --anArgIter; | |
9002 | } | |
9003 | ViewerTest::CurrentEventManager()->SetLockOrbitZUp (toLockUp); | |
9004 | } | |
6b62b2da | 9005 | else if (anArgCase == "-fov" |
b40cdc2b | 9006 | || anArgCase == "-fovy" |
9007 | || anArgCase == "-fovx" | |
9008 | || anArgCase == "-fov2d") | |
b5ac8292 | 9009 | { |
6b62b2da | 9010 | Standard_CString anArgValue = (anArgIter + 1 < theArgsNb) ? theArgVec[anArgIter + 1] : NULL; |
9011 | if (anArgValue != NULL | |
9012 | && *anArgValue != '-') | |
9013 | { | |
9014 | ++anArgIter; | |
b40cdc2b | 9015 | if (anArgCase == "-fov2d") |
9016 | { | |
9017 | aCamera->SetFOV2d (Draw::Atof (anArgValue)); | |
9018 | } | |
9019 | else if (anArgCase == "-fovx") | |
9020 | { | |
9021 | aCamera->SetFOVy (Draw::Atof (anArgValue) / aCamera->Aspect());/// | |
9022 | } | |
9023 | else | |
9024 | { | |
9025 | aCamera->SetFOVy (Draw::Atof (anArgValue)); | |
9026 | } | |
6b62b2da | 9027 | continue; |
9028 | } | |
b40cdc2b | 9029 | if (anArgCase == "-fov2d") |
9030 | { | |
9031 | theDI << aCamera->FOV2d() << " "; | |
9032 | } | |
9033 | else if (anArgCase == "-fovx") | |
9034 | { | |
9035 | theDI << aCamera->FOVx() << " "; | |
9036 | } | |
9037 | else | |
9038 | { | |
9039 | theDI << aCamera->FOVy() << " "; | |
9040 | } | |
9041 | } | |
9042 | else if (anArgIter + 1 < theArgsNb | |
9043 | && anArgCase == "-xrpose") | |
9044 | { | |
9045 | TCollection_AsciiString anXRArg (theArgVec[++anArgIter]); | |
9046 | anXRArg.LowerCase(); | |
9047 | if (anXRArg == "base") | |
9048 | { | |
9049 | aCamera = aView->View()->BaseXRCamera(); | |
9050 | } | |
9051 | else if (anXRArg == "head") | |
9052 | { | |
9053 | aCamera = aView->View()->PosedXRCamera(); | |
9054 | } | |
9055 | else | |
9056 | { | |
9057 | Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'"; | |
9058 | return 1; | |
9059 | } | |
9060 | if (aCamera.IsNull()) | |
9061 | { | |
9062 | Message::SendFail() << "Error: undefined XR pose"; | |
9063 | return 0; | |
9064 | } | |
9065 | if (aView->AutoZFitMode()) | |
9066 | { | |
9067 | const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues (false); | |
9068 | const Bnd_Box aGraphicBox = aView->View()->MinMaxValues (true); | |
9069 | aCamera->ZFitAll (aView->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox); | |
9070 | } | |
b5ac8292 | 9071 | } |
30a1b24e | 9072 | else if (aPrsName.IsEmpty() |
9073 | && !anArgCase.StartsWith ("-")) | |
9074 | { | |
9075 | aPrsName = anArg; | |
9076 | } | |
b5ac8292 | 9077 | else |
9078 | { | |
23fe70ec | 9079 | Message::SendFail() << "Error: unknown argument '" << anArg << "'"; |
b5ac8292 | 9080 | return 1; |
9081 | } | |
9082 | } | |
b5ac8292 | 9083 | |
30a1b24e | 9084 | if (aPrsName.IsEmpty() |
9085 | || theArgsNb > 2) | |
9086 | { | |
30a1b24e | 9087 | aView->Redraw(); |
9088 | } | |
9089 | ||
9090 | if (!aPrsName.IsEmpty()) | |
9091 | { | |
9092 | Handle(AIS_CameraFrustum) aCameraFrustum; | |
9093 | if (GetMapOfAIS().IsBound2 (aPrsName)) | |
9094 | { | |
9095 | // find existing object | |
9096 | aCameraFrustum = Handle(AIS_CameraFrustum)::DownCast (GetMapOfAIS().Find2 (theArgVec[1])); | |
9097 | if (aCameraFrustum.IsNull()) | |
9098 | { | |
23fe70ec | 9099 | Message::SendFail() << "Error: object '" << aPrsName << "'is already defined and is not a camera frustum"; |
30a1b24e | 9100 | return 1; |
9101 | } | |
9102 | } | |
9103 | ||
9104 | if (aCameraFrustum.IsNull()) | |
9105 | { | |
9106 | aCameraFrustum = new AIS_CameraFrustum(); | |
9107 | } | |
9108 | else | |
9109 | { | |
9110 | // not include displayed object of old camera frustum in the new one. | |
9111 | ViewerTest::GetAISContext()->Erase (aCameraFrustum, false); | |
9112 | aView->ZFitAll(); | |
9113 | } | |
b40cdc2b | 9114 | aCameraFrustum->SetCameraFrustum (aCamera); |
30a1b24e | 9115 | |
9116 | ViewerTest::Display (aPrsName, aCameraFrustum); | |
9117 | } | |
b5ac8292 | 9118 | |
9119 | return 0; | |
9120 | } | |
9121 | ||
f978241f | 9122 | //! Parse stereo output mode |
9123 | inline Standard_Boolean parseStereoMode (Standard_CString theArg, | |
9124 | Graphic3d_StereoMode& theMode) | |
9125 | { | |
9126 | TCollection_AsciiString aFlag (theArg); | |
9127 | aFlag.LowerCase(); | |
9128 | if (aFlag == "quadbuffer") | |
9129 | { | |
9130 | theMode = Graphic3d_StereoMode_QuadBuffer; | |
9131 | } | |
9132 | else if (aFlag == "anaglyph") | |
9133 | { | |
9134 | theMode = Graphic3d_StereoMode_Anaglyph; | |
9135 | } | |
9136 | else if (aFlag == "row" | |
9137 | || aFlag == "rowinterlaced") | |
9138 | { | |
9139 | theMode = Graphic3d_StereoMode_RowInterlaced; | |
9140 | } | |
9141 | else if (aFlag == "col" | |
9142 | || aFlag == "colinterlaced" | |
9143 | || aFlag == "columninterlaced") | |
9144 | { | |
9145 | theMode = Graphic3d_StereoMode_ColumnInterlaced; | |
9146 | } | |
9147 | else if (aFlag == "chess" | |
9148 | || aFlag == "chessboard") | |
9149 | { | |
9150 | theMode = Graphic3d_StereoMode_ChessBoard; | |
9151 | } | |
9152 | else if (aFlag == "sbs" | |
9153 | || aFlag == "sidebyside") | |
9154 | { | |
9155 | theMode = Graphic3d_StereoMode_SideBySide; | |
9156 | } | |
9157 | else if (aFlag == "ou" | |
9158 | || aFlag == "overunder") | |
9159 | { | |
9160 | theMode = Graphic3d_StereoMode_OverUnder; | |
9161 | } | |
9162 | else if (aFlag == "pageflip" | |
9163 | || aFlag == "softpageflip") | |
9164 | { | |
9165 | theMode = Graphic3d_StereoMode_SoftPageFlip; | |
9166 | } | |
b40cdc2b | 9167 | else if (aFlag == "openvr" |
9168 | || aFlag == "vr") | |
9169 | { | |
9170 | theMode = Graphic3d_StereoMode_OpenVR; | |
9171 | } | |
f978241f | 9172 | else |
9173 | { | |
9174 | return Standard_False; | |
9175 | } | |
9176 | return Standard_True; | |
9177 | } | |
9178 | ||
9179 | //! Parse anaglyph filter | |
9180 | inline Standard_Boolean parseAnaglyphFilter (Standard_CString theArg, | |
9181 | Graphic3d_RenderingParams::Anaglyph& theFilter) | |
9182 | { | |
9183 | TCollection_AsciiString aFlag (theArg); | |
9184 | aFlag.LowerCase(); | |
9185 | if (aFlag == "redcyansimple") | |
9186 | { | |
9187 | theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple; | |
9188 | } | |
9189 | else if (aFlag == "redcyan" | |
9190 | || aFlag == "redcyanoptimized") | |
9191 | { | |
9192 | theFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized; | |
9193 | } | |
9194 | else if (aFlag == "yellowbluesimple") | |
9195 | { | |
9196 | theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple; | |
9197 | } | |
9198 | else if (aFlag == "yellowblue" | |
9199 | || aFlag == "yellowblueoptimized") | |
9200 | { | |
9201 | theFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized; | |
9202 | } | |
9203 | else if (aFlag == "greenmagenta" | |
9204 | || aFlag == "greenmagentasimple") | |
9205 | { | |
9206 | theFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple; | |
9207 | } | |
9208 | else | |
9209 | { | |
9210 | return Standard_False; | |
9211 | } | |
9212 | return Standard_True; | |
9213 | } | |
9214 | ||
b5ac8292 | 9215 | //============================================================================== |
9216 | //function : VStereo | |
9217 | //purpose : | |
9218 | //============================================================================== | |
9219 | ||
9220 | static int VStereo (Draw_Interpretor& theDI, | |
9221 | Standard_Integer theArgNb, | |
9222 | const char** theArgVec) | |
9223 | { | |
f978241f | 9224 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
b8db9379 | 9225 | if (aView.IsNull()) |
b5ac8292 | 9226 | { |
b8db9379 | 9227 | Message::SendFail ("Error: no active viewer"); |
9228 | return 0; | |
9229 | } | |
b5ac8292 | 9230 | |
b8db9379 | 9231 | Handle(Graphic3d_Camera) aCamera = aView->Camera(); |
9232 | Graphic3d_RenderingParams* aParams = &aView->ChangeRenderingParams(); | |
9233 | if (theArgNb < 2) | |
9234 | { | |
9235 | Standard_Boolean isActive = aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo; | |
b5ac8292 | 9236 | theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n"; |
bf02aa7d | 9237 | if (isActive) |
9238 | { | |
9239 | TCollection_AsciiString aMode; | |
9240 | switch (aView->RenderingParams().StereoMode) | |
9241 | { | |
9242 | case Graphic3d_StereoMode_QuadBuffer : aMode = "quadBuffer"; break; | |
9243 | case Graphic3d_StereoMode_RowInterlaced : aMode = "rowInterlaced"; break; | |
9244 | case Graphic3d_StereoMode_ColumnInterlaced : aMode = "columnInterlaced"; break; | |
9245 | case Graphic3d_StereoMode_ChessBoard : aMode = "chessBoard"; break; | |
9246 | case Graphic3d_StereoMode_SideBySide : aMode = "sideBySide"; break; | |
9247 | case Graphic3d_StereoMode_OverUnder : aMode = "overUnder"; break; | |
9248 | case Graphic3d_StereoMode_SoftPageFlip : aMode = "softpageflip"; break; | |
b40cdc2b | 9249 | case Graphic3d_StereoMode_OpenVR : aMode = "openVR"; break; |
bf02aa7d | 9250 | case Graphic3d_StereoMode_Anaglyph : |
9251 | aMode = "anaglyph"; | |
9252 | switch (aView->RenderingParams().AnaglyphFilter) | |
9253 | { | |
9254 | case Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple : aMode.AssignCat (" (redCyanSimple)"); break; | |
9255 | case Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized : aMode.AssignCat (" (redCyan)"); break; | |
9256 | case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple : aMode.AssignCat (" (yellowBlueSimple)"); break; | |
9257 | case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized: aMode.AssignCat (" (yellowBlue)"); break; | |
9258 | case Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple : aMode.AssignCat (" (greenMagentaSimple)"); break; | |
9259 | default: break; | |
9260 | } | |
9261 | default: break; | |
9262 | } | |
9263 | theDI << "Mode " << aMode << "\n"; | |
9264 | } | |
b5ac8292 | 9265 | return 0; |
9266 | } | |
9267 | ||
b8db9379 | 9268 | Graphic3d_StereoMode aMode = aParams->StereoMode; |
f978241f | 9269 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
9270 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
9271 | { | |
9272 | Standard_CString anArg = theArgVec[anArgIter]; | |
9273 | TCollection_AsciiString aFlag (anArg); | |
9274 | aFlag.LowerCase(); | |
9275 | if (anUpdateTool.parseRedrawMode (aFlag)) | |
9276 | { | |
9277 | continue; | |
9278 | } | |
9279 | else if (aFlag == "0" | |
9280 | || aFlag == "off") | |
9281 | { | |
9282 | if (++anArgIter < theArgNb) | |
9283 | { | |
23fe70ec | 9284 | Message::SendFail ("Error: wrong number of arguments"); |
f978241f | 9285 | return 1; |
9286 | } | |
9287 | ||
b8db9379 | 9288 | if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo) |
f978241f | 9289 | { |
9290 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective); | |
9291 | } | |
f978241f | 9292 | return 0; |
9293 | } | |
9294 | else if (aFlag == "1" | |
9295 | || aFlag == "on") | |
9296 | { | |
9297 | if (++anArgIter < theArgNb) | |
9298 | { | |
23fe70ec | 9299 | Message::SendFail ("Error: wrong number of arguments"); |
f978241f | 9300 | return 1; |
9301 | } | |
9302 | ||
b8db9379 | 9303 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo); |
b40cdc2b | 9304 | if (aParams->StereoMode != Graphic3d_StereoMode_OpenVR) |
9305 | { | |
9306 | return 0; | |
9307 | } | |
f978241f | 9308 | } |
9309 | else if (aFlag == "-reverse" | |
9310 | || aFlag == "-reversed" | |
9311 | || aFlag == "-swap") | |
9312 | { | |
9313 | Standard_Boolean toEnable = Standard_True; | |
9314 | if (++anArgIter < theArgNb | |
dae2a922 | 9315 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
f978241f | 9316 | { |
9317 | --anArgIter; | |
9318 | } | |
9319 | aParams->ToReverseStereo = toEnable; | |
9320 | } | |
9321 | else if (aFlag == "-noreverse" | |
9322 | || aFlag == "-noswap") | |
9323 | { | |
9324 | Standard_Boolean toDisable = Standard_True; | |
9325 | if (++anArgIter < theArgNb | |
dae2a922 | 9326 | && !Draw::ParseOnOff (theArgVec[anArgIter], toDisable)) |
f978241f | 9327 | { |
9328 | --anArgIter; | |
9329 | } | |
9330 | aParams->ToReverseStereo = !toDisable; | |
9331 | } | |
9332 | else if (aFlag == "-mode" | |
9333 | || aFlag == "-stereomode") | |
9334 | { | |
9335 | if (++anArgIter >= theArgNb | |
9336 | || !parseStereoMode (theArgVec[anArgIter], aMode)) | |
9337 | { | |
23fe70ec | 9338 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
f978241f | 9339 | return 1; |
9340 | } | |
9341 | ||
9342 | if (aMode == Graphic3d_StereoMode_QuadBuffer) | |
9343 | { | |
b8db9379 | 9344 | Message::SendInfo() << "Warning: make sure to call 'vcaps -stereo 1' before creating a view"; |
f978241f | 9345 | } |
9346 | } | |
9347 | else if (aFlag == "-anaglyph" | |
9348 | || aFlag == "-anaglyphfilter") | |
9349 | { | |
9350 | Graphic3d_RenderingParams::Anaglyph aFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple; | |
9351 | if (++anArgIter >= theArgNb | |
9352 | || !parseAnaglyphFilter (theArgVec[anArgIter], aFilter)) | |
9353 | { | |
23fe70ec | 9354 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
f978241f | 9355 | return 1; |
9356 | } | |
9357 | ||
9358 | aMode = Graphic3d_StereoMode_Anaglyph; | |
9359 | aParams->AnaglyphFilter = aFilter; | |
9360 | } | |
9361 | else if (parseStereoMode (anArg, aMode)) // short syntax | |
9362 | { | |
9363 | if (aMode == Graphic3d_StereoMode_QuadBuffer) | |
9364 | { | |
b8db9379 | 9365 | Message::SendInfo() << "Warning: make sure to call 'vcaps -stereo 1' before creating a view"; |
f978241f | 9366 | } |
9367 | } | |
b40cdc2b | 9368 | else if (anArgIter + 1 < theArgNb |
9369 | && aFlag == "-hmdfov2d") | |
9370 | { | |
9371 | aParams->HmdFov2d = (float )Draw::Atof (theArgVec[++anArgIter]); | |
9372 | if (aParams->HmdFov2d < 10.0f | |
9373 | || aParams->HmdFov2d > 180.0f) | |
9374 | { | |
9375 | Message::SendFail() << "Error: FOV is out of range"; | |
9376 | return 1; | |
9377 | } | |
9378 | } | |
9379 | else if (aFlag == "-mirror" | |
9380 | || aFlag == "-mirrorcomposer") | |
9381 | { | |
9382 | Standard_Boolean toEnable = Standard_True; | |
9383 | if (++anArgIter < theArgNb | |
dae2a922 | 9384 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
b40cdc2b | 9385 | { |
9386 | --anArgIter; | |
9387 | } | |
9388 | aParams->ToMirrorComposer = toEnable; | |
9389 | } | |
9390 | else if (anArgIter + 1 < theArgNb | |
9391 | && (aFlag == "-unitfactor" | |
9392 | || aFlag == "-unitscale")) | |
9393 | { | |
9394 | aView->View()->SetUnitFactor (Draw::Atof (theArgVec[++anArgIter])); | |
9395 | } | |
f978241f | 9396 | else |
9397 | { | |
23fe70ec | 9398 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
f978241f | 9399 | return 1; |
9400 | } | |
9401 | } | |
9402 | ||
b8db9379 | 9403 | aParams->StereoMode = aMode; |
9404 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo); | |
9405 | if (aParams->StereoMode == Graphic3d_StereoMode_OpenVR) | |
f978241f | 9406 | { |
b8db9379 | 9407 | // initiate implicit continuous rendering |
9408 | ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true); | |
f978241f | 9409 | } |
b5ac8292 | 9410 | return 0; |
9411 | } | |
9412 | ||
392ac980 | 9413 | //=============================================================================================== |
9414 | //function : VDefaults | |
9415 | //purpose : | |
9416 | //=============================================================================================== | |
9417 | static int VDefaults (Draw_Interpretor& theDi, | |
9418 | Standard_Integer theArgsNb, | |
9419 | const char** theArgVec) | |
9420 | { | |
9421 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); | |
9422 | if (aCtx.IsNull()) | |
9423 | { | |
23fe70ec | 9424 | Message::SendFail ("Error: no active viewer"); |
392ac980 | 9425 | return 1; |
9426 | } | |
9427 | ||
9428 | Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer(); | |
9429 | if (theArgsNb < 2) | |
9430 | { | |
9431 | if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE) | |
9432 | { | |
9433 | theDi << "DeflType: relative\n" | |
9434 | << "DeviationCoeff: " << aDefParams->DeviationCoefficient() << "\n"; | |
9435 | } | |
9436 | else | |
9437 | { | |
9438 | theDi << "DeflType: absolute\n" | |
9439 | << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n"; | |
9440 | } | |
67441d0c | 9441 | theDi << "AngularDeflection: " << (180.0 * aDefParams->DeviationAngle() / M_PI) << "\n"; |
4c513386 | 9442 | theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n"; |
392ac980 | 9443 | return 0; |
9444 | } | |
9445 | ||
9446 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
9447 | { | |
9448 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
4c513386 | 9449 | anArg.UpperCase(); |
9450 | if (anArg == "-ABSDEFL" | |
9451 | || anArg == "-ABSOLUTEDEFLECTION" | |
9452 | || anArg == "-DEFL" | |
9453 | || anArg == "-DEFLECTION") | |
392ac980 | 9454 | { |
4c513386 | 9455 | if (++anArgIter >= theArgsNb) |
9456 | { | |
23fe70ec | 9457 | Message::SendFail() << "Syntax error at " << anArg; |
4c513386 | 9458 | return 1; |
9459 | } | |
392ac980 | 9460 | aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE); |
4c513386 | 9461 | aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter])); |
392ac980 | 9462 | } |
4c513386 | 9463 | else if (anArg == "-RELDEFL" |
9464 | || anArg == "-RELATIVEDEFLECTION" | |
9465 | || anArg == "-DEVCOEFF" | |
9466 | || anArg == "-DEVIATIONCOEFF" | |
9467 | || anArg == "-DEVIATIONCOEFFICIENT") | |
392ac980 | 9468 | { |
4c513386 | 9469 | if (++anArgIter >= theArgsNb) |
9470 | { | |
23fe70ec | 9471 | Message::SendFail() << "Syntax error at " << anArg; |
4c513386 | 9472 | return 1; |
9473 | } | |
392ac980 | 9474 | aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE); |
4c513386 | 9475 | aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter])); |
392ac980 | 9476 | } |
4c513386 | 9477 | else if (anArg == "-ANGDEFL" |
9478 | || anArg == "-ANGULARDEFL" | |
9479 | || anArg == "-ANGULARDEFLECTION") | |
392ac980 | 9480 | { |
4c513386 | 9481 | if (++anArgIter >= theArgsNb) |
9482 | { | |
23fe70ec | 9483 | Message::SendFail() << "Syntax error at " << anArg; |
4c513386 | 9484 | return 1; |
9485 | } | |
67441d0c | 9486 | aDefParams->SetDeviationAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0); |
4c513386 | 9487 | } |
385c43e7 | 9488 | else if (anArg == "-AUTOTR" |
9489 | || anArg == "-AUTOTRIANG" | |
9490 | || anArg == "-AUTOTRIANGULATION") | |
4c513386 | 9491 | { |
14c7f553 | 9492 | ++anArgIter; |
9493 | bool toTurnOn = true; | |
9494 | if (anArgIter >= theArgsNb | |
dae2a922 | 9495 | || !Draw::ParseOnOff (theArgVec[anArgIter], toTurnOn)) |
4c513386 | 9496 | { |
23fe70ec | 9497 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
4c513386 | 9498 | return 1; |
9499 | } | |
14c7f553 | 9500 | aDefParams->SetAutoTriangulation (toTurnOn); |
392ac980 | 9501 | } |
9502 | else | |
9503 | { | |
23fe70ec | 9504 | Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'"; |
14c7f553 | 9505 | return 1; |
392ac980 | 9506 | } |
9507 | } | |
9508 | ||
9509 | return 0; | |
9510 | } | |
9511 | ||
06d40093 | 9512 | //! Parse light source type from string. |
9513 | static bool parseLightSourceType (const TCollection_AsciiString& theTypeName, | |
9514 | Graphic3d_TypeOfLightSource& theType) | |
12381341 | 9515 | { |
06d40093 | 9516 | TCollection_AsciiString aType (theTypeName); |
9517 | aType.LowerCase(); | |
9518 | if (aType == "amb" | |
9519 | || aType == "ambient" | |
9520 | || aType == "amblight") | |
12381341 | 9521 | { |
06d40093 | 9522 | theType = Graphic3d_TypeOfLightSource_Ambient; |
12381341 | 9523 | } |
06d40093 | 9524 | else if (aType == "directional" |
9525 | || aType == "dirlight") | |
12381341 | 9526 | { |
06d40093 | 9527 | theType = Graphic3d_TypeOfLightSource_Directional; |
12381341 | 9528 | } |
06d40093 | 9529 | else if (aType == "spot" |
9530 | || aType == "spotlight") | |
12381341 | 9531 | { |
06d40093 | 9532 | theType = Graphic3d_TypeOfLightSource_Spot; |
12381341 | 9533 | } |
06d40093 | 9534 | else if (aType == "poslight" |
9535 | || aType == "positional" | |
9536 | || aType == "point" | |
9537 | || aType == "pnt") | |
12381341 | 9538 | { |
06d40093 | 9539 | theType = Graphic3d_TypeOfLightSource_Positional; |
12381341 | 9540 | } |
9541 | else | |
9542 | { | |
06d40093 | 9543 | return false; |
12381341 | 9544 | } |
06d40093 | 9545 | return true; |
12381341 | 9546 | } |
9547 | ||
06d40093 | 9548 | //! Find existing light by name or index. |
9549 | static Handle(V3d_Light) findLightSource (const TCollection_AsciiString& theName) | |
2daa5d95 | 9550 | { |
06d40093 | 9551 | Handle(V3d_Light) aLight; |
9552 | Standard_Integer aLightIndex = -1; | |
9553 | Draw::ParseInteger (theName.ToCString(), aLightIndex); | |
9554 | Standard_Integer aLightIt = 0; | |
9555 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
9556 | for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightIt) | |
2daa5d95 | 9557 | { |
06d40093 | 9558 | if (aLightIndex != -1) |
2daa5d95 | 9559 | { |
06d40093 | 9560 | if (aLightIt == aLightIndex) |
9561 | { | |
9562 | return aLightIter.Value(); | |
9563 | } | |
2daa5d95 | 9564 | } |
06d40093 | 9565 | else if (aLightIter.Value()->GetId() == theName |
9566 | || aLightIter.Value()->Name() == theName) | |
2daa5d95 | 9567 | { |
06d40093 | 9568 | if (!aLight.IsNull()) |
9569 | { | |
9570 | Message::SendWarning() << "Warning: ambiguous light name '" << theName << "'"; | |
9571 | break; | |
9572 | } | |
9573 | aLight = aLightIter.Value(); | |
2daa5d95 | 9574 | } |
9575 | } | |
06d40093 | 9576 | return aLight; |
2daa5d95 | 9577 | } |
9578 | ||
12381341 | 9579 | //=============================================================================================== |
9580 | //function : VLight | |
9581 | //purpose : | |
9582 | //=============================================================================================== | |
9583 | static int VLight (Draw_Interpretor& theDi, | |
9584 | Standard_Integer theArgsNb, | |
9585 | const char** theArgVec) | |
9586 | { | |
9587 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
9588 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
06d40093 | 9589 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
12381341 | 9590 | if (aView.IsNull() |
9591 | || aViewer.IsNull()) | |
9592 | { | |
23fe70ec | 9593 | Message::SendFail ("Error: no active viewer"); |
12381341 | 9594 | return 1; |
9595 | } | |
9596 | ||
12381341 | 9597 | if (theArgsNb < 2) |
9598 | { | |
9599 | // print lights info | |
9600 | Standard_Integer aLightId = 0; | |
6a24c6de | 9601 | for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next(), ++aLightId) |
12381341 | 9602 | { |
6a24c6de | 9603 | Handle(V3d_Light) aLight = aLightIter.Value(); |
12381341 | 9604 | const Quantity_Color aColor = aLight->Color(); |
992ed6b3 | 9605 | theDi << "Light #" << aLightId |
9606 | << (!aLight->Name().IsEmpty() ? (TCollection_AsciiString(" ") + aLight->Name()) : "") | |
06d40093 | 9607 | << " [" << aLight->GetId() << "] " |
9608 | << (aLight->IsEnabled() ? "ON" : "OFF") << "\n"; | |
12381341 | 9609 | switch (aLight->Type()) |
9610 | { | |
9611 | case V3d_AMBIENT: | |
9612 | { | |
06d40093 | 9613 | theDi << " Type: Ambient\n" |
9614 | << " Intensity: " << aLight->Intensity() << "\n"; | |
12381341 | 9615 | break; |
9616 | } | |
9617 | case V3d_DIRECTIONAL: | |
9618 | { | |
06d40093 | 9619 | theDi << " Type: Directional\n" |
9620 | << " Intensity: " << aLight->Intensity() << "\n" | |
9621 | << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n" | |
9622 | << " CastShadows:" << (aLight->ToCastShadows() ? "TRUE" : "FALSE") << "\n" | |
9623 | << " Smoothness: " << aLight->Smoothness() << "\n" | |
9624 | << " Direction: " << aLight->PackedDirection().x() << " " << aLight->PackedDirection().y() << " " << aLight->PackedDirection().z() << "\n"; | |
12381341 | 9625 | break; |
9626 | } | |
9627 | case V3d_POSITIONAL: | |
9628 | { | |
06d40093 | 9629 | theDi << " Type: Positional\n" |
9630 | << " Intensity: " << aLight->Intensity() << "\n" | |
9631 | << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n" | |
9632 | << " CastShadows:" << (aLight->ToCastShadows() ? "TRUE" : "FALSE") << "\n" | |
9633 | << " Smoothness: " << aLight->Smoothness() << "\n" | |
9634 | << " Position: " << aLight->Position().X() << " " << aLight->Position().Y() << " " << aLight->Position().Z() << "\n" | |
9635 | << " Atten.: " << aLight->ConstAttenuation() << " " << aLight->LinearAttenuation() << "\n" | |
9636 | << " Range: " << aLight->Range() << "\n"; | |
12381341 | 9637 | break; |
9638 | } | |
9639 | case V3d_SPOT: | |
9640 | { | |
06d40093 | 9641 | theDi << " Type: Spot\n" |
9642 | << " Intensity: " << aLight->Intensity() << "\n" | |
9643 | << " Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n" | |
9644 | << " CastShadows:" << (aLight->ToCastShadows() ? "TRUE" : "FALSE") << "\n" | |
9645 | << " Position: " << aLight->Position().X() << " " << aLight->Position().Y() << " " << aLight->Position().Z() << "\n" | |
9646 | << " Direction: " << aLight->PackedDirection().x() << " " << aLight->PackedDirection().y() << " " << aLight->PackedDirection().z() << "\n" | |
9647 | << " Atten.: " << aLight->ConstAttenuation() << " " << aLight->LinearAttenuation() << "\n" | |
9648 | << " Angle: " << (aLight->Angle() * 180.0 / M_PI) << "\n" | |
9649 | << " Exponent: " << aLight->Concentration() << "\n" | |
9650 | << " Range: " << aLight->Range() << "\n"; | |
12381341 | 9651 | break; |
9652 | } | |
9653 | default: | |
9654 | { | |
189f85a3 | 9655 | theDi << " Type: UNKNOWN\n"; |
12381341 | 9656 | break; |
9657 | } | |
9658 | } | |
06d40093 | 9659 | theDi << " Color: " << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " [" << Quantity_Color::StringName (aColor.Name()) << "]\n"; |
12381341 | 9660 | } |
9661 | } | |
9662 | ||
06d40093 | 9663 | Handle(V3d_Light) aLightOld, aLightNew; |
992ed6b3 | 9664 | Graphic3d_ZLayerId aLayer = Graphic3d_ZLayerId_UNKNOWN; |
06d40093 | 9665 | bool isGlobal = true; |
9666 | ViewerTest_AutoUpdater anUpdateTool (aCtx, aView); | |
9667 | Handle(AIS_LightSource) aLightPrs; | |
12381341 | 9668 | for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) |
9669 | { | |
12381341 | 9670 | const TCollection_AsciiString anArg (theArgVec[anArgIt]); |
9671 | TCollection_AsciiString anArgCase (anArg); | |
06d40093 | 9672 | anArgCase.LowerCase(); |
761d8807 | 9673 | if (anUpdateTool.parseRedrawMode (anArg)) |
9674 | { | |
9675 | continue; | |
9676 | } | |
06d40093 | 9677 | else if (anArgCase == "-new" |
9678 | || anArgCase == "-add" | |
9679 | || anArgCase == "-create" | |
9680 | || anArgCase == "-type" | |
9681 | || (anArgCase == "-reset" | |
9682 | && !aLightNew.IsNull()) | |
9683 | || (anArgCase == "-defaults" | |
9684 | && !aLightNew.IsNull()) | |
9685 | || anArgCase == "add" | |
9686 | || anArgCase == "new" | |
9687 | || anArgCase == "create") | |
992ed6b3 | 9688 | { |
06d40093 | 9689 | Graphic3d_TypeOfLightSource aType = Graphic3d_TypeOfLightSource_Ambient; |
9690 | if (anArgCase == "-reset") | |
992ed6b3 | 9691 | { |
06d40093 | 9692 | aType = aLightNew->Type(); |
992ed6b3 | 9693 | } |
06d40093 | 9694 | else if (anArgIt + 1 >= theArgsNb |
9695 | || !parseLightSourceType (theArgVec[++anArgIt], aType)) | |
992ed6b3 | 9696 | { |
06d40093 | 9697 | theDi << "Syntax error at '" << theArgVec[anArgIt] << "'\n"; |
9698 | return 1; | |
992ed6b3 | 9699 | } |
06d40093 | 9700 | |
9701 | TCollection_AsciiString aName; | |
9702 | if (!aLightNew.IsNull()) | |
992ed6b3 | 9703 | { |
06d40093 | 9704 | aName = aLightNew->Name(); |
992ed6b3 | 9705 | } |
06d40093 | 9706 | switch (aType) |
992ed6b3 | 9707 | { |
06d40093 | 9708 | case Graphic3d_TypeOfLightSource_Ambient: |
9709 | { | |
9710 | aLightNew = new V3d_AmbientLight(); | |
9711 | break; | |
9712 | } | |
9713 | case Graphic3d_TypeOfLightSource_Directional: | |
9714 | { | |
9715 | aLightNew = new V3d_DirectionalLight(); | |
9716 | break; | |
9717 | } | |
9718 | case Graphic3d_TypeOfLightSource_Spot: | |
9719 | { | |
9720 | aLightNew = new V3d_SpotLight (gp_Pnt (0.0, 0.0, 0.0)); | |
9721 | break; | |
9722 | } | |
9723 | case Graphic3d_TypeOfLightSource_Positional: | |
9724 | { | |
9725 | aLightNew = new V3d_PositionalLight (gp_Pnt (0.0, 0.0, 0.0)); | |
9726 | break; | |
9727 | } | |
992ed6b3 | 9728 | } |
06d40093 | 9729 | |
9730 | if (anArgCase == "-type" | |
9731 | && !aLightOld.IsNull()) | |
992ed6b3 | 9732 | { |
06d40093 | 9733 | aLightNew->CopyFrom (aLightOld); |
992ed6b3 | 9734 | } |
06d40093 | 9735 | aLightNew->SetName (aName); |
9736 | } | |
9737 | else if ((anArgCase == "-layer" | |
9738 | || anArgCase == "-zlayer") | |
9739 | && anArgIt + 1 < theArgsNb) | |
9740 | { | |
9741 | if (!ViewerTest::ParseZLayer (theArgVec[++anArgIt], aLayer) | |
9742 | || aLayer == Graphic3d_ZLayerId_UNKNOWN) | |
992ed6b3 | 9743 | { |
06d40093 | 9744 | Message::SendFail() << "Error: wrong syntax at '" << theArgVec[anArgIt] << "'"; |
992ed6b3 | 9745 | return 1; |
9746 | } | |
9747 | } | |
06d40093 | 9748 | else if (anArgCase == "-glob" |
9749 | || anArgCase == "-global" | |
9750 | || anArgCase == "-loc" | |
9751 | || anArgCase == "-local") | |
12381341 | 9752 | { |
06d40093 | 9753 | isGlobal = anArgCase.StartsWith ("-glob"); |
12381341 | 9754 | } |
06d40093 | 9755 | else if (anArgCase == "-def" |
9756 | || anArgCase == "-defaults" | |
9757 | || anArgCase == "-reset") | |
12381341 | 9758 | { |
4fe9ad57 | 9759 | aViewer->SetDefaultLights(); |
06d40093 | 9760 | aLightOld.Nullify(); |
9761 | aLightNew.Nullify(); | |
9762 | aLightPrs.Nullify(); | |
4fe9ad57 | 9763 | } |
06d40093 | 9764 | else if (anArgCase == "-clr" |
9765 | || anArgCase == "-clear" | |
9766 | || anArgCase == "clear") | |
4fe9ad57 | 9767 | { |
992ed6b3 | 9768 | TColStd_SequenceOfInteger aLayers; |
9769 | aViewer->GetAllZLayers (aLayers); | |
9770 | for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next()) | |
4fe9ad57 | 9771 | { |
992ed6b3 | 9772 | if (aLayeriter.Value() == aLayer |
9773 | || aLayer == Graphic3d_ZLayerId_UNKNOWN) | |
9774 | { | |
9775 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value()); | |
9776 | aSettings.SetLights (Handle(Graphic3d_LightSet)()); | |
9777 | aViewer->SetZLayerSettings (aLayeriter.Value(), aSettings); | |
9778 | if (aLayer != Graphic3d_ZLayerId_UNKNOWN) | |
9779 | { | |
9780 | break; | |
9781 | } | |
9782 | } | |
9783 | } | |
9784 | ||
9785 | if (aLayer == Graphic3d_ZLayerId_UNKNOWN) | |
9786 | { | |
06d40093 | 9787 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); |
992ed6b3 | 9788 | for (V3d_ListOfLightIterator aLightIter (aView->ActiveLightIterator()); aLightIter.More();) |
9789 | { | |
9790 | Handle(V3d_Light) aLight = aLightIter.Value(); | |
06d40093 | 9791 | Handle(AIS_InteractiveObject) aPrsObject; |
9792 | GetMapOfAIS().Find2 (aLight->Name(), aPrsObject); | |
9793 | if (Handle(AIS_LightSource) aLightSourceDel = Handle(AIS_LightSource)::DownCast (aPrsObject)) | |
2daa5d95 | 9794 | { |
06d40093 | 9795 | aCtx->Remove (aLightSourceDel, false); |
9796 | aMap.UnBind1 (aLightSourceDel); | |
2daa5d95 | 9797 | } |
992ed6b3 | 9798 | aViewer->DelLight (aLight); |
9799 | aLightIter = aView->ActiveLightIterator(); | |
9800 | } | |
4fe9ad57 | 9801 | } |
12381341 | 9802 | |
06d40093 | 9803 | aLightOld.Nullify(); |
992ed6b3 | 9804 | aLightNew.Nullify(); |
06d40093 | 9805 | aLightPrs.Nullify(); |
12381341 | 9806 | } |
06d40093 | 9807 | else if (!aLightNew.IsNull() |
9808 | && (anArgCase == "-display" | |
9809 | || anArgCase == "-disp" | |
9810 | || anArgCase == "-presentation" | |
9811 | || anArgCase == "-prs")) | |
2daa5d95 | 9812 | { |
06d40093 | 9813 | TCollection_AsciiString aLightName = aLightNew->Name(); |
9814 | if (anArgIt + 1 < theArgsNb | |
9815 | && theArgVec[anArgIt + 1][0] != '-') | |
2daa5d95 | 9816 | { |
06d40093 | 9817 | // old syntax |
9818 | aLightName = theArgVec[++anArgIt]; | |
9819 | if (aLightNew->Name() != aLightName) | |
2daa5d95 | 9820 | { |
06d40093 | 9821 | if (Handle(V3d_Light) anOtherLight = findLightSource (aLightName)) |
9822 | { | |
9823 | theDi << "Syntax error: light with name '" << aLightName << "' is already defined"; | |
9824 | return 1; | |
9825 | } | |
9826 | aLightNew->SetName (aLightName); | |
2daa5d95 | 9827 | } |
9828 | } | |
9829 | if (aLightName.IsEmpty()) | |
9830 | { | |
06d40093 | 9831 | Message::SendFail() << "Error: nameless light source cannot be displayed"; |
12381341 | 9832 | return 1; |
9833 | } | |
06d40093 | 9834 | if (aLightPrs.IsNull()) |
992ed6b3 | 9835 | { |
06d40093 | 9836 | aLightPrs = new AIS_LightSource (aLightNew); |
992ed6b3 | 9837 | } |
06d40093 | 9838 | theDi << aLightName << " "; |
9839 | } | |
9840 | else if (!aLightNew.IsNull() | |
9841 | && (anArgCase == "-disable" | |
9842 | || anArgCase == "-disabled" | |
9843 | || anArgCase == "-enable" | |
9844 | || anArgCase == "-enabled")) | |
9845 | { | |
9846 | bool toEnable = Draw::ParseOnOffIterator (theArgsNb, theArgVec, anArgIt); | |
9847 | if (anArgCase == "-disable" | |
9848 | || anArgCase == "-disabled") | |
12381341 | 9849 | { |
06d40093 | 9850 | toEnable = !toEnable; |
12381341 | 9851 | } |
06d40093 | 9852 | aLightNew->SetEnabled (toEnable); |
12381341 | 9853 | } |
06d40093 | 9854 | else if (!aLightNew.IsNull() |
9855 | && (anArgCase == "-color" | |
9856 | || anArgCase == "-colour" | |
9857 | || anArgCase == "color")) | |
12381341 | 9858 | { |
dae2a922 | 9859 | Quantity_Color aColor; |
9860 | Standard_Integer aNbParsed = Draw::ParseColor (theArgsNb - anArgIt - 1, | |
9861 | theArgVec + anArgIt + 1, | |
9862 | aColor); | |
9863 | anArgIt += aNbParsed; | |
06d40093 | 9864 | if (aNbParsed == 0) |
12381341 | 9865 | { |
23fe70ec | 9866 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
12381341 | 9867 | return 1; |
9868 | } | |
06d40093 | 9869 | aLightNew->SetColor (aColor); |
12381341 | 9870 | } |
06d40093 | 9871 | else if (!aLightNew.IsNull() |
9872 | && (anArgCase == "-pos" | |
9873 | || anArgCase == "-position" | |
9874 | || anArgCase == "-prsposition" | |
9875 | || anArgCase == "-prspos" | |
9876 | || anArgCase == "pos" | |
9877 | || anArgCase == "position") | |
9878 | && (anArgIt + 3) < theArgsNb) | |
12381341 | 9879 | { |
2daa5d95 | 9880 | gp_XYZ aPosXYZ; |
06d40093 | 9881 | if (!parseXYZ (theArgVec + anArgIt + 1, aPosXYZ)) |
12381341 | 9882 | { |
23fe70ec | 9883 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
12381341 | 9884 | return 1; |
9885 | } | |
9886 | ||
2daa5d95 | 9887 | anArgIt += 3; |
06d40093 | 9888 | if (anArgCase == "-prsposition" |
9889 | || anArgCase == "-prspos") | |
2daa5d95 | 9890 | { |
06d40093 | 9891 | aLightNew->SetDisplayPosition (aPosXYZ); |
2daa5d95 | 9892 | } |
9893 | else | |
9894 | { | |
06d40093 | 9895 | if (aLightNew->Type() != Graphic3d_TypeOfLightSource_Positional |
9896 | && aLightNew->Type() != Graphic3d_TypeOfLightSource_Spot) | |
2daa5d95 | 9897 | { |
9898 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; | |
9899 | return 1; | |
9900 | } | |
9901 | ||
06d40093 | 9902 | aLightNew->SetPosition (aPosXYZ); |
2daa5d95 | 9903 | } |
12381341 | 9904 | } |
06d40093 | 9905 | else if (!aLightNew.IsNull() |
9906 | && (aLightNew->Type() == Graphic3d_TypeOfLightSource_Directional | |
9907 | || aLightNew->Type() == Graphic3d_TypeOfLightSource_Spot) | |
9908 | && (anArgCase == "-dir" | |
9909 | || anArgCase == "-direction") | |
9910 | && (anArgIt + 3) < theArgsNb) | |
12381341 | 9911 | { |
2daa5d95 | 9912 | gp_XYZ aDirXYZ; |
06d40093 | 9913 | if (!parseXYZ (theArgVec + anArgIt + 1, aDirXYZ)) |
12381341 | 9914 | { |
23fe70ec | 9915 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
12381341 | 9916 | return 1; |
9917 | } | |
9918 | ||
2daa5d95 | 9919 | anArgIt += 3; |
06d40093 | 9920 | aLightNew->SetDirection (gp_Dir (aDirXYZ)); |
12381341 | 9921 | } |
06d40093 | 9922 | else if (!aLightNew.IsNull() |
9923 | && (anArgCase == "-smoothangle" | |
9924 | || anArgCase == "-smoothradius" | |
9925 | || anArgCase == "-sm" | |
9926 | || anArgCase == "-smoothness") | |
9927 | && anArgIt + 1 < theArgsNb) | |
189f85a3 | 9928 | { |
06d40093 | 9929 | Standard_ShortReal aSmoothness = (Standard_ShortReal )Atof (theArgVec[++anArgIt]); |
9930 | if (aLightNew->Type() == Graphic3d_TypeOfLightSource_Directional) | |
189f85a3 | 9931 | { |
06d40093 | 9932 | aSmoothness = Standard_ShortReal(aSmoothness * M_PI / 180.0); |
189f85a3 | 9933 | } |
992ed6b3 | 9934 | if (Abs (aSmoothness) <= ShortRealEpsilon()) |
189f85a3 | 9935 | { |
06d40093 | 9936 | aLightNew->SetIntensity (1.f); |
189f85a3 | 9937 | } |
06d40093 | 9938 | else if (Abs (aLightNew->Smoothness()) <= ShortRealEpsilon()) |
189f85a3 | 9939 | { |
06d40093 | 9940 | aLightNew->SetIntensity ((aSmoothness * aSmoothness) / 3.f); |
189f85a3 | 9941 | } |
9942 | else | |
9943 | { | |
06d40093 | 9944 | Standard_ShortReal aSmoothnessRatio = static_cast<Standard_ShortReal> (aSmoothness / aLightNew->Smoothness()); |
9945 | aLightNew->SetIntensity (aLightNew->Intensity() / (aSmoothnessRatio * aSmoothnessRatio)); | |
189f85a3 | 9946 | } |
9947 | ||
06d40093 | 9948 | if (aLightNew->Type() == Graphic3d_TypeOfLightSource_Positional) |
189f85a3 | 9949 | { |
06d40093 | 9950 | aLightNew->SetSmoothRadius (aSmoothness); |
189f85a3 | 9951 | } |
06d40093 | 9952 | else if (aLightNew->Type() == Graphic3d_TypeOfLightSource_Directional) |
189f85a3 | 9953 | { |
06d40093 | 9954 | aLightNew->SetSmoothAngle (aSmoothness); |
189f85a3 | 9955 | } |
9956 | } | |
06d40093 | 9957 | else if (!aLightNew.IsNull() |
9958 | && (anArgCase == "-int" | |
9959 | || anArgCase == "-intensity") | |
9960 | && anArgIt + 1 < theArgsNb) | |
189f85a3 | 9961 | { |
06d40093 | 9962 | Standard_ShortReal aIntensity = (Standard_ShortReal )Atof (theArgVec[++anArgIt]); |
9963 | aLightNew->SetIntensity (aIntensity); | |
189f85a3 | 9964 | } |
06d40093 | 9965 | else if (!aLightNew.IsNull() |
9966 | && aLightNew->Type() == Graphic3d_TypeOfLightSource_Spot | |
9967 | && (anArgCase == "-spotangle" | |
9968 | || anArgCase == "-ang" | |
9969 | || anArgCase == "-angle") | |
9970 | && anArgIt + 1 < theArgsNb) | |
4fe9ad57 | 9971 | { |
06d40093 | 9972 | Standard_ShortReal anAngle = (Standard_ShortReal )Atof (theArgVec[++anArgIt]); |
2daa5d95 | 9973 | anAngle = (Standard_ShortReal (anAngle / 180.0 * M_PI)); |
06d40093 | 9974 | aLightNew->SetAngle (anAngle); |
9975 | } | |
9976 | else if (!aLightNew.IsNull() | |
9977 | && (aLightNew->Type() == Graphic3d_TypeOfLightSource_Positional | |
9978 | || aLightNew->Type() == Graphic3d_TypeOfLightSource_Spot) | |
9979 | && (anArgCase == "-constatten" | |
9980 | || anArgCase == "-constattenuation") | |
9981 | && anArgIt + 1 < theArgsNb) | |
9982 | { | |
9983 | const Standard_ShortReal aConstAtten = (Standard_ShortReal )Atof (theArgVec[++anArgIt]); | |
9984 | aLightNew->SetAttenuation (aConstAtten, aLightNew->LinearAttenuation()); | |
9985 | } | |
9986 | else if (!aLightNew.IsNull() | |
9987 | && (aLightNew->Type() == Graphic3d_TypeOfLightSource_Positional | |
9988 | || aLightNew->Type() == Graphic3d_TypeOfLightSource_Spot) | |
9989 | && (anArgCase == "-linatten" | |
9990 | || anArgCase == "-linearatten" | |
9991 | || anArgCase == "-linearattenuation") | |
9992 | && anArgIt + 1 < theArgsNb) | |
9993 | { | |
9994 | const Standard_ShortReal aLinAtten = (Standard_ShortReal )Atof (theArgVec[++anArgIt]); | |
9995 | aLightNew->SetAttenuation (aLightNew->ConstAttenuation(), aLinAtten); | |
9996 | } | |
9997 | else if (!aLightNew.IsNull() | |
9998 | && aLightNew->Type() == Graphic3d_TypeOfLightSource_Spot | |
9999 | && (anArgCase == "-spotexp" | |
10000 | || anArgCase == "-spotexponent" | |
10001 | || anArgCase == "-exp" | |
10002 | || anArgCase == "-exponent") | |
10003 | && anArgIt + 1 < theArgsNb) | |
10004 | { | |
10005 | aLightNew->SetConcentration ((Standard_ShortReal )Atof (theArgVec[++anArgIt])); | |
10006 | } | |
10007 | else if (!aLightNew.IsNull() | |
10008 | && aLightNew->Type() != Graphic3d_TypeOfLightSource_Ambient | |
10009 | && aLightNew->Type() != Graphic3d_TypeOfLightSource_Directional | |
10010 | && anArgCase == "-range" | |
10011 | && anArgIt + 1 < theArgsNb) | |
10012 | { | |
10013 | Standard_ShortReal aRange ((Standard_ShortReal)Atof (theArgVec[++anArgIt])); | |
10014 | aLightNew->SetRange (aRange); | |
10015 | } | |
10016 | else if (!aLightNew.IsNull() | |
10017 | && aLightNew->Type() != Graphic3d_TypeOfLightSource_Ambient | |
10018 | && (anArgCase == "-head" | |
10019 | || anArgCase == "-headlight")) | |
12381341 | 10020 | { |
06d40093 | 10021 | Standard_Boolean isHeadLight = Standard_True; |
10022 | if (anArgIt + 1 < theArgsNb | |
10023 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], isHeadLight)) | |
12381341 | 10024 | { |
06d40093 | 10025 | ++anArgIt; |
12381341 | 10026 | } |
06d40093 | 10027 | aLightNew->SetHeadlight (isHeadLight); |
12381341 | 10028 | } |
06d40093 | 10029 | else if (!aLightNew.IsNull() |
10030 | && anArgCase == "-name" | |
10031 | && anArgIt + 1 < theArgsNb) | |
12381341 | 10032 | { |
06d40093 | 10033 | const TCollection_AsciiString aName = theArgVec[++anArgIt]; |
10034 | if (aLightNew->Name() == aName) | |
12381341 | 10035 | { |
06d40093 | 10036 | continue; |
12381341 | 10037 | } |
10038 | ||
06d40093 | 10039 | if (Handle(V3d_Light) anOtherLight = findLightSource (aName)) |
12381341 | 10040 | { |
06d40093 | 10041 | theDi << "Syntax error: light with name '" << aName << "' is already defined"; |
12381341 | 10042 | return 1; |
10043 | } | |
06d40093 | 10044 | aLightNew->SetName (aName); |
12381341 | 10045 | } |
06d40093 | 10046 | else if (!aLightPrs.IsNull() |
10047 | && (anArgCase == "-showzoomable" | |
10048 | || anArgCase == "-prszoomable" | |
10049 | || anArgCase == "-zoomable")) | |
88b312d3 | 10050 | { |
06d40093 | 10051 | const bool isZoomable = Draw::ParseOnOffIterator (theArgsNb, theArgVec, anArgIt); |
10052 | aLightPrs->SetZoomable (isZoomable); | |
10053 | } | |
a3b2aaef | 10054 | else if (!aLightPrs.IsNull() |
10055 | && (anArgCase == "-showdraggable" | |
10056 | || anArgCase == "-prsdraggable" | |
10057 | || anArgCase == "-draggable")) | |
10058 | { | |
10059 | const bool isDraggable = Draw::ParseOnOffIterator (theArgsNb, theArgVec, anArgIt); | |
10060 | aLightPrs->SetDraggable (isDraggable); | |
10061 | } | |
06d40093 | 10062 | else if (!aLightPrs.IsNull() |
10063 | && (anArgCase == "-showname" | |
10064 | || anArgCase == "-prsname")) | |
10065 | { | |
10066 | const bool toDisplay = Draw::ParseOnOffIterator (theArgsNb, theArgVec, anArgIt); | |
10067 | aLightPrs->SetDisplayName (toDisplay); | |
88b312d3 | 10068 | } |
06d40093 | 10069 | else if (!aLightPrs.IsNull() |
10070 | && (aLightNew->Type() == Graphic3d_TypeOfLightSource_Spot | |
10071 | || aLightNew->Type() == Graphic3d_TypeOfLightSource_Positional) | |
10072 | && (anArgCase == "-showrange" | |
10073 | || anArgCase == "-prsrange")) | |
12381341 | 10074 | { |
06d40093 | 10075 | const bool toDisplay = Draw::ParseOnOffIterator (theArgsNb, theArgVec, anArgIt); |
10076 | aLightPrs->SetDisplayRange (toDisplay); | |
10077 | } | |
10078 | else if (!aLightPrs.IsNull() | |
10079 | && (anArgCase == "-showsize" | |
10080 | || anArgCase == "-prssize") | |
10081 | && anArgIt + 1 < theArgsNb) | |
10082 | { | |
10083 | Standard_Real aSize = 0.0; | |
10084 | if (!Draw::ParseReal (theArgVec[++anArgIt], aSize) | |
10085 | || aSize <= 0.0 | |
10086 | || aLightPrs.IsNull()) | |
12381341 | 10087 | { |
23fe70ec | 10088 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
12381341 | 10089 | return 1; |
10090 | } | |
10091 | ||
06d40093 | 10092 | aLightPrs->SetSize (aSize); |
10093 | } | |
a3b2aaef | 10094 | else if (!aLightPrs.IsNull() |
10095 | && (anArgCase == "-dirarcsize" | |
10096 | || anArgCase == "-arcsize" | |
10097 | || anArgCase == "-arc") | |
10098 | && anArgIt + 1 < theArgsNb) | |
10099 | { | |
10100 | Standard_Integer aSize = 0; | |
10101 | if (!Draw::ParseInteger (theArgVec[anArgIt + 1], aSize) | |
10102 | || aSize <= 0 | |
10103 | || aLightPrs->Light()->Type() != Graphic3d_TypeOfLightSource_Directional) | |
10104 | { | |
10105 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; | |
10106 | return 1; | |
10107 | } | |
10108 | ++anArgIt; | |
10109 | aLightPrs->SetArcSize (aSize); | |
10110 | } | |
06d40093 | 10111 | else if (!aLightNew.IsNull() |
10112 | && aLightNew->Type() != Graphic3d_TypeOfLightSource_Ambient | |
10113 | && (anArgCase == "-castshadow" | |
10114 | || anArgCase == "-castshadows" | |
10115 | || anArgCase == "-shadows")) | |
10116 | { | |
10117 | bool toCastShadows = true; | |
992ed6b3 | 10118 | if (anArgIt + 1 < theArgsNb |
06d40093 | 10119 | && Draw::ParseOnOff (theArgVec[anArgIt + 1], toCastShadows)) |
12381341 | 10120 | { |
992ed6b3 | 10121 | ++anArgIt; |
12381341 | 10122 | } |
06d40093 | 10123 | aLightNew->SetCastShadows (toCastShadows); |
12381341 | 10124 | } |
06d40093 | 10125 | else if (anArgCase == "-del" |
10126 | || anArgCase == "-delete" | |
10127 | || anArgCase == "-remove" | |
10128 | || anArgCase == "del" | |
10129 | || anArgCase == "delete" | |
10130 | || anArgCase == "remove") | |
2daa5d95 | 10131 | { |
06d40093 | 10132 | if (aLightOld.IsNull()) |
2daa5d95 | 10133 | { |
06d40093 | 10134 | if (!aLightNew.IsNull()) |
10135 | { | |
10136 | aLightNew.Nullify(); | |
10137 | continue; | |
10138 | } | |
10139 | ||
10140 | if (++anArgIt >= theArgsNb) | |
10141 | { | |
10142 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; | |
10143 | return 1; | |
10144 | } | |
10145 | ||
10146 | const TCollection_AsciiString anOldName (theArgVec[anArgIt]); | |
10147 | aLightOld = findLightSource (anOldName); | |
10148 | if (aLightOld.IsNull()) | |
10149 | { | |
10150 | Message::SendWarning() << "Warning: light '" << anOldName << "' not found"; | |
10151 | continue; | |
10152 | } | |
2daa5d95 | 10153 | } |
06d40093 | 10154 | |
10155 | aLightNew.Nullify(); | |
10156 | aLightPrs.Nullify(); | |
2daa5d95 | 10157 | } |
06d40093 | 10158 | else if (anArgCase == "-change" |
10159 | || anArgCase == "change") | |
2daa5d95 | 10160 | { |
06d40093 | 10161 | // just skip old syntax |
2daa5d95 | 10162 | } |
06d40093 | 10163 | else if (aLightNew.IsNull() |
10164 | && !anArgCase.StartsWith ("-")) | |
2daa5d95 | 10165 | { |
06d40093 | 10166 | if (!aLightNew.IsNull()) |
2daa5d95 | 10167 | { |
06d40093 | 10168 | continue; |
2daa5d95 | 10169 | } |
10170 | ||
06d40093 | 10171 | const TCollection_AsciiString anOldName (theArgVec[anArgIt]); |
10172 | aLightOld = findLightSource (anOldName); | |
10173 | if (!aLightOld.IsNull()) | |
2daa5d95 | 10174 | { |
06d40093 | 10175 | aLightNew = aLightOld; |
10176 | ||
10177 | Handle(AIS_InteractiveObject) aPrsObject; | |
10178 | GetMapOfAIS().Find2 (aLightOld->Name(), aPrsObject); | |
10179 | aLightPrs = Handle(AIS_LightSource)::DownCast (aPrsObject); | |
2daa5d95 | 10180 | } |
10181 | else | |
10182 | { | |
06d40093 | 10183 | Standard_Integer aLightIndex = -1; |
10184 | Draw::ParseInteger (anOldName.ToCString(), aLightIndex); | |
10185 | if (aLightIndex != -1) | |
10186 | { | |
10187 | Message::SendFail() << "Syntax error: light source with index '" << aLightIndex << "' is not found"; | |
10188 | return 1; | |
10189 | } | |
10190 | ||
10191 | aLightNew = new V3d_AmbientLight(); | |
10192 | aLightNew->SetName (anOldName); | |
2daa5d95 | 10193 | } |
10194 | } | |
06d40093 | 10195 | else |
2daa5d95 | 10196 | { |
06d40093 | 10197 | Message::SendFail() << "Warning: unknown argument '" << anArg << "'"; |
10198 | return 1; | |
10199 | } | |
10200 | } | |
2daa5d95 | 10201 | |
06d40093 | 10202 | // delete old light source |
10203 | if (!aLightOld.IsNull() | |
10204 | && aLightOld != aLightNew) | |
10205 | { | |
10206 | TColStd_SequenceOfInteger aLayers; | |
10207 | aViewer->GetAllZLayers (aLayers); | |
10208 | for (TColStd_SequenceOfInteger::Iterator aLayerIter (aLayers); aLayerIter.More(); aLayerIter.Next()) | |
10209 | { | |
10210 | if (aLayerIter.Value() == aLayer | |
10211 | || aLayer == Graphic3d_ZLayerId_UNKNOWN) | |
2daa5d95 | 10212 | { |
06d40093 | 10213 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayerIter.Value()); |
10214 | if (!aSettings.Lights().IsNull()) | |
10215 | { | |
10216 | aSettings.Lights()->Remove (aLightOld); | |
10217 | if (aSettings.Lights()->IsEmpty()) | |
10218 | { | |
10219 | aSettings.SetLights (Handle(Graphic3d_LightSet)()); | |
10220 | } | |
10221 | } | |
10222 | aViewer->SetZLayerSettings (aLayerIter.Value(), aSettings); | |
10223 | if (aLayer != Graphic3d_ZLayerId_UNKNOWN) | |
10224 | { | |
10225 | break; | |
10226 | } | |
2daa5d95 | 10227 | } |
10228 | } | |
06d40093 | 10229 | |
10230 | if (aLayer == Graphic3d_ZLayerId_UNKNOWN) | |
2daa5d95 | 10231 | { |
06d40093 | 10232 | Handle(AIS_InteractiveObject) aPrsObject; |
10233 | GetMapOfAIS().Find2 (aLightOld->Name(), aPrsObject); | |
10234 | if (Handle(AIS_LightSource) aLightSourceDel = Handle(AIS_LightSource)::DownCast (aPrsObject)) | |
2daa5d95 | 10235 | { |
06d40093 | 10236 | aCtx->Remove (aLightSourceDel, false); |
10237 | GetMapOfAIS().UnBind1 (aLightSourceDel); | |
2daa5d95 | 10238 | } |
06d40093 | 10239 | aViewer->DelLight (aLightOld); |
10240 | } | |
10241 | aLightOld.Nullify(); | |
10242 | } | |
2daa5d95 | 10243 | |
06d40093 | 10244 | // add new light source |
10245 | if (!aLightNew.IsNull()) | |
10246 | { | |
10247 | if (aLayer == Graphic3d_ZLayerId_UNKNOWN) | |
10248 | { | |
10249 | aViewer->AddLight (aLightNew); | |
10250 | if (isGlobal) | |
2daa5d95 | 10251 | { |
06d40093 | 10252 | aViewer->SetLightOn (aLightNew); |
2daa5d95 | 10253 | } |
10254 | else | |
10255 | { | |
06d40093 | 10256 | aView->SetLightOn (aLightNew); |
2daa5d95 | 10257 | } |
10258 | } | |
06d40093 | 10259 | else |
d84e8669 | 10260 | { |
06d40093 | 10261 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayer); |
10262 | if (aSettings.Lights().IsNull()) | |
d84e8669 | 10263 | { |
06d40093 | 10264 | aSettings.SetLights (new Graphic3d_LightSet()); |
d84e8669 | 10265 | } |
06d40093 | 10266 | aSettings.Lights()->Add (aLightNew); |
10267 | aViewer->SetZLayerSettings (aLayer, aSettings); | |
d84e8669 | 10268 | } |
06d40093 | 10269 | |
10270 | if (!aLightPrs.IsNull()) | |
12381341 | 10271 | { |
06d40093 | 10272 | aLightPrs->SetLight (aLightNew); |
10273 | ViewerTest::Display (aLightNew->Name(), aLightPrs, false); | |
12381341 | 10274 | } |
10275 | } | |
10276 | ||
06d40093 | 10277 | // manage presentations |
2daa5d95 | 10278 | struct LightPrsSort |
10279 | { | |
10280 | bool operator() (const Handle(AIS_LightSource)& theLeft, | |
10281 | const Handle(AIS_LightSource)& theRight) | |
10282 | { | |
10283 | return theLeft->Light()->GetId() < theRight->Light()->GetId(); | |
10284 | } | |
10285 | }; | |
10286 | ||
10287 | AIS_ListOfInteractive aPrsList; | |
06d40093 | 10288 | aCtx->DisplayedObjects (AIS_KindOfInteractive_LightSource, -1, aPrsList); |
2daa5d95 | 10289 | if (!aPrsList.IsEmpty()) |
10290 | { | |
10291 | // update light source presentations | |
10292 | std::vector<Handle(AIS_LightSource)> aLightPrsVec; | |
10293 | for (AIS_ListOfInteractive::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next()) | |
10294 | { | |
06d40093 | 10295 | if (Handle(AIS_LightSource) aLightPrs2 = Handle(AIS_LightSource)::DownCast (aPrsIter.Value())) |
2daa5d95 | 10296 | { |
06d40093 | 10297 | aLightPrsVec.push_back (aLightPrs2); |
2daa5d95 | 10298 | } |
10299 | } | |
10300 | ||
10301 | // sort objects by id as AIS_InteractiveContext stores them in unordered map | |
10302 | std::sort (aLightPrsVec.begin(), aLightPrsVec.end(), LightPrsSort()); | |
10303 | ||
10304 | Standard_Integer aTopStack = 0; | |
10305 | for (std::vector<Handle(AIS_LightSource)>::iterator aPrsIter = aLightPrsVec.begin(); aPrsIter != aLightPrsVec.end(); ++aPrsIter) | |
10306 | { | |
06d40093 | 10307 | Handle(AIS_LightSource) aLightPrs2 = *aPrsIter; |
10308 | if (!aLightPrs2->TransformPersistence().IsNull() | |
10309 | && aLightPrs2->TransformPersistence()->IsTrihedronOr2d()) | |
2daa5d95 | 10310 | { |
06d40093 | 10311 | const Standard_Integer aPrsSize = (Standard_Integer )aLightPrs2->Size(); |
10312 | aLightPrs2->TransformPersistence()->SetOffset2d (Graphic3d_Vec2i (aTopStack + aPrsSize, aPrsSize)); | |
2daa5d95 | 10313 | aTopStack += aPrsSize + aPrsSize / 2; |
10314 | } | |
06d40093 | 10315 | aCtx->Redisplay (aLightPrs2, false); |
10316 | aCtx->SetTransformPersistence (aLightPrs2, aLightPrs2->TransformPersistence()); | |
2daa5d95 | 10317 | } |
10318 | } | |
12381341 | 10319 | return 0; |
10320 | } | |
10321 | ||
67312b79 | 10322 | //=============================================================================================== |
10323 | //function : VPBREnvironment | |
10324 | //purpose : | |
10325 | //=============================================================================================== | |
10326 | static int VPBREnvironment (Draw_Interpretor&, | |
10327 | Standard_Integer theArgsNb, | |
10328 | const char** theArgVec) | |
10329 | { | |
10330 | if (theArgsNb > 2) | |
10331 | { | |
23fe70ec | 10332 | Message::SendFail ("Syntax error: 'vpbrenv' command has only one argument"); |
67312b79 | 10333 | return 1; |
10334 | } | |
10335 | ||
10336 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
10337 | if (aView.IsNull()) | |
10338 | { | |
23fe70ec | 10339 | Message::SendFail ("Error: no active viewer"); |
67312b79 | 10340 | return 1; |
10341 | } | |
10342 | ||
10343 | TCollection_AsciiString anArg = TCollection_AsciiString (theArgVec[1]); | |
10344 | anArg.LowerCase(); | |
10345 | ||
10346 | if (anArg == "-generate" | |
10347 | || anArg == "-gen") | |
10348 | { | |
10349 | aView->GeneratePBREnvironment (Standard_True); | |
10350 | } | |
10351 | else if (anArg == "-clear") | |
10352 | { | |
10353 | aView->ClearPBREnvironment (Standard_True); | |
10354 | } | |
10355 | else | |
10356 | { | |
23fe70ec | 10357 | Message::SendFail() << "Syntax error: unknown argument [" << theArgVec[1] << "] for 'vpbrenv' command"; |
67312b79 | 10358 | return 1; |
10359 | } | |
10360 | ||
10361 | return 0; | |
10362 | } | |
10363 | ||
15669413 | 10364 | //! Read Graphic3d_RenderingParams::PerfCounters flag. |
10365 | static Standard_Boolean parsePerfStatsFlag (const TCollection_AsciiString& theValue, | |
10366 | Standard_Boolean& theToReset, | |
10367 | Graphic3d_RenderingParams::PerfCounters& theFlagsRem, | |
10368 | Graphic3d_RenderingParams::PerfCounters& theFlagsAdd) | |
10369 | { | |
10370 | Graphic3d_RenderingParams::PerfCounters aFlag = Graphic3d_RenderingParams::PerfCounters_NONE; | |
10371 | TCollection_AsciiString aVal = theValue; | |
10372 | Standard_Boolean toReverse = Standard_False; | |
10373 | if (aVal == "none") | |
10374 | { | |
10375 | theToReset = Standard_True; | |
10376 | return Standard_True; | |
10377 | } | |
10378 | else if (aVal.StartsWith ("-")) | |
10379 | { | |
10380 | toReverse = Standard_True; | |
10381 | aVal = aVal.SubString (2, aVal.Length()); | |
10382 | } | |
10383 | else if (aVal.StartsWith ("no")) | |
10384 | { | |
10385 | toReverse = Standard_True; | |
10386 | aVal = aVal.SubString (3, aVal.Length()); | |
10387 | } | |
10388 | else if (aVal.StartsWith ("+")) | |
10389 | { | |
10390 | aVal = aVal.SubString (2, aVal.Length()); | |
10391 | } | |
10392 | else | |
10393 | { | |
10394 | theToReset = Standard_True; | |
10395 | } | |
10396 | ||
10397 | if ( aVal == "fps" | |
10398 | || aVal == "framerate") aFlag = Graphic3d_RenderingParams::PerfCounters_FrameRate; | |
10399 | else if (aVal == "cpu") aFlag = Graphic3d_RenderingParams::PerfCounters_CPU; | |
10400 | else if (aVal == "layers") aFlag = Graphic3d_RenderingParams::PerfCounters_Layers; | |
10401 | else if (aVal == "structs" | |
10402 | || aVal == "structures" | |
10403 | || aVal == "objects") aFlag = Graphic3d_RenderingParams::PerfCounters_Structures; | |
10404 | else if (aVal == "groups") aFlag = Graphic3d_RenderingParams::PerfCounters_Groups; | |
10405 | else if (aVal == "arrays") aFlag = Graphic3d_RenderingParams::PerfCounters_GroupArrays; | |
10406 | else if (aVal == "tris" | |
10407 | || aVal == "triangles") aFlag = Graphic3d_RenderingParams::PerfCounters_Triangles; | |
10408 | else if (aVal == "pnts" | |
10409 | || aVal == "points") aFlag = Graphic3d_RenderingParams::PerfCounters_Points; | |
b9f43ad1 | 10410 | else if (aVal == "lines") aFlag = Graphic3d_RenderingParams::PerfCounters_Lines; |
15669413 | 10411 | else if (aVal == "mem" |
10412 | || aVal == "gpumem" | |
10413 | || aVal == "estimmem") aFlag = Graphic3d_RenderingParams::PerfCounters_EstimMem; | |
5e30547b | 10414 | else if (aVal == "skipimmediate" |
10415 | || aVal == "noimmediate") aFlag = Graphic3d_RenderingParams::PerfCounters_SkipImmediate; | |
10416 | else if (aVal == "frametime" | |
10417 | || aVal == "frametimers" | |
10418 | || aVal == "time") aFlag = Graphic3d_RenderingParams::PerfCounters_FrameTime; | |
15669413 | 10419 | else if (aVal == "basic") aFlag = Graphic3d_RenderingParams::PerfCounters_Basic; |
10420 | else if (aVal == "extended" | |
10421 | || aVal == "verbose" | |
10422 | || aVal == "extra") aFlag = Graphic3d_RenderingParams::PerfCounters_Extended; | |
5e30547b | 10423 | else if (aVal == "full" |
10424 | || aVal == "all") aFlag = Graphic3d_RenderingParams::PerfCounters_All; | |
15669413 | 10425 | else |
10426 | { | |
10427 | return Standard_False; | |
10428 | } | |
10429 | ||
10430 | if (toReverse) | |
10431 | { | |
10432 | theFlagsRem = Graphic3d_RenderingParams::PerfCounters(theFlagsRem | aFlag); | |
10433 | } | |
10434 | else | |
10435 | { | |
10436 | theFlagsAdd = Graphic3d_RenderingParams::PerfCounters(theFlagsAdd | aFlag); | |
10437 | } | |
10438 | return Standard_True; | |
10439 | } | |
10440 | ||
10441 | //! Read Graphic3d_RenderingParams::PerfCounters flags. | |
10442 | static Standard_Boolean convertToPerfStatsFlags (const TCollection_AsciiString& theValue, | |
10443 | Graphic3d_RenderingParams::PerfCounters& theFlags) | |
10444 | { | |
10445 | TCollection_AsciiString aValue = theValue; | |
10446 | Graphic3d_RenderingParams::PerfCounters aFlagsRem = Graphic3d_RenderingParams::PerfCounters_NONE; | |
10447 | Graphic3d_RenderingParams::PerfCounters aFlagsAdd = Graphic3d_RenderingParams::PerfCounters_NONE; | |
10448 | Standard_Boolean toReset = Standard_False; | |
10449 | for (;;) | |
10450 | { | |
10451 | Standard_Integer aSplitPos = aValue.Search ("|"); | |
10452 | if (aSplitPos <= 0) | |
10453 | { | |
10454 | if (!parsePerfStatsFlag (aValue, toReset, aFlagsRem, aFlagsAdd)) | |
10455 | { | |
10456 | return Standard_False; | |
10457 | } | |
10458 | if (toReset) | |
10459 | { | |
10460 | theFlags = Graphic3d_RenderingParams::PerfCounters_NONE; | |
10461 | } | |
10462 | theFlags = Graphic3d_RenderingParams::PerfCounters(theFlags | aFlagsAdd); | |
10463 | theFlags = Graphic3d_RenderingParams::PerfCounters(theFlags & ~aFlagsRem); | |
10464 | return Standard_True; | |
10465 | } | |
10466 | ||
10467 | if (aSplitPos > 1) | |
10468 | { | |
10469 | TCollection_AsciiString aSubValue = aValue.SubString (1, aSplitPos - 1); | |
10470 | if (!parsePerfStatsFlag (aSubValue, toReset, aFlagsRem, aFlagsAdd)) | |
10471 | { | |
10472 | return Standard_False; | |
10473 | } | |
10474 | } | |
10475 | aValue = aValue.SubString (aSplitPos + 1, aValue.Length()); | |
10476 | } | |
10477 | } | |
10478 | ||
e276548b | 10479 | //======================================================================= |
bc8c79bb | 10480 | //function : VRenderParams |
10481 | //purpose : Enables/disables rendering features | |
e276548b | 10482 | //======================================================================= |
10483 | ||
bc8c79bb | 10484 | static Standard_Integer VRenderParams (Draw_Interpretor& theDI, |
10485 | Standard_Integer theArgNb, | |
10486 | const char** theArgVec) | |
e276548b | 10487 | { |
7ae4a307 | 10488 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
10489 | if (aView.IsNull()) | |
e276548b | 10490 | { |
23fe70ec | 10491 | Message::SendFail ("Error: no active viewer"); |
e276548b | 10492 | return 1; |
10493 | } | |
bc8c79bb | 10494 | |
10495 | Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams(); | |
6b62b2da | 10496 | TCollection_AsciiString aCmdName (theArgVec[0]); |
10497 | aCmdName.LowerCase(); | |
10498 | if (aCmdName == "vraytrace") | |
10499 | { | |
10500 | if (theArgNb == 1) | |
10501 | { | |
10502 | theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "on" : "off") << " "; | |
10503 | return 0; | |
10504 | } | |
10505 | else if (theArgNb == 2) | |
10506 | { | |
10507 | TCollection_AsciiString aValue (theArgVec[1]); | |
10508 | aValue.LowerCase(); | |
10509 | if (aValue == "on" | |
10510 | || aValue == "1") | |
10511 | { | |
10512 | aParams.Method = Graphic3d_RM_RAYTRACING; | |
10513 | aView->Redraw(); | |
10514 | return 0; | |
10515 | } | |
10516 | else if (aValue == "off" | |
10517 | || aValue == "0") | |
10518 | { | |
10519 | aParams.Method = Graphic3d_RM_RASTERIZATION; | |
10520 | aView->Redraw(); | |
10521 | return 0; | |
10522 | } | |
10523 | else | |
10524 | { | |
23fe70ec | 10525 | Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[1] << "'"; |
6b62b2da | 10526 | return 1; |
10527 | } | |
10528 | } | |
10529 | else | |
10530 | { | |
23fe70ec | 10531 | Message::SendFail ("Syntax error: wrong number of arguments"); |
6b62b2da | 10532 | return 1; |
10533 | } | |
10534 | } | |
bc8c79bb | 10535 | |
10536 | if (theArgNb < 2) | |
e276548b | 10537 | { |
bc8c79bb | 10538 | theDI << "renderMode: "; |
10539 | switch (aParams.Method) | |
10540 | { | |
10541 | case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break; | |
10542 | case Graphic3d_RM_RAYTRACING: theDI << "raytrace "; break; | |
10543 | } | |
10544 | theDI << "\n"; | |
a1073ae2 | 10545 | theDI << "transparency: "; |
10546 | switch (aParams.TransparencyMethod) | |
10547 | { | |
10548 | case Graphic3d_RTM_BLEND_UNORDERED: theDI << "Basic blended transparency with non-commuting operator "; break; | |
10549 | case Graphic3d_RTM_BLEND_OIT: theDI << "Weighted Blended Order-Independent Transparency, depth weight factor: " | |
10550 | << TCollection_AsciiString (aParams.OitDepthFactor); break; | |
78c4e836 | 10551 | case Graphic3d_RTM_DEPTH_PEELING_OIT: theDI << "Depth Peeling Order-Independent Transparency, Nb.Layers: " |
10552 | << TCollection_AsciiString (aParams.NbOitDepthPeelingLayers); break; | |
a1073ae2 | 10553 | } |
10554 | theDI << "\n"; | |
b4327ba8 | 10555 | theDI << "msaa: " << aParams.NbMsaaSamples << "\n"; |
56689b27 | 10556 | theDI << "rendScale: " << aParams.RenderResolutionScale << "\n"; |
b4327ba8 | 10557 | theDI << "rayDepth: " << aParams.RaytracingDepth << "\n"; |
10558 | theDI << "fsaa: " << (aParams.IsAntialiasingEnabled ? "on" : "off") << "\n"; | |
10559 | theDI << "shadows: " << (aParams.IsShadowEnabled ? "on" : "off") << "\n"; | |
d84e8669 | 10560 | theDI << "shadowMapRes: " << aParams.ShadowMapResolution << "\n"; |
10561 | theDI << "shadowMapBias: " << aParams.ShadowMapBias << "\n"; | |
b4327ba8 | 10562 | theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n"; |
10563 | theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n"; | |
10564 | theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n"; | |
10565 | theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n"; | |
10566 | theDI << "iss: " << (aParams.AdaptiveScreenSampling ? "on" : "off") << "\n"; | |
10567 | theDI << "iss debug: " << (aParams.ShowSamplingTiles ? "on" : "off") << "\n"; | |
10568 | theDI << "two-sided BSDF: " << (aParams.TwoSidedBsdfModels ? "on" : "off") << "\n"; | |
b09447ed | 10569 | theDI << "max radiance: " << aParams.RadianceClampingValue << "\n"; |
4eaaf9d8 | 10570 | theDI << "nb tiles (iss): " << aParams.NbRayTracingTiles << "\n"; |
66d1cdc6 | 10571 | theDI << "tile size (iss):" << aParams.RayTracingTileSize << "x" << aParams.RayTracingTileSize << "\n"; |
8625ef7e | 10572 | theDI << "shadingModel: "; |
10573 | switch (aView->ShadingModel()) | |
10574 | { | |
13b36bb1 | 10575 | case Graphic3d_TypeOfShadingModel_DEFAULT: theDI << "default"; break; |
10576 | case Graphic3d_TypeOfShadingModel_Unlit: theDI << "unlit"; break; | |
10577 | case Graphic3d_TypeOfShadingModel_PhongFacet: theDI << "flat"; break; | |
10578 | case Graphic3d_TypeOfShadingModel_Gouraud: theDI << "gouraud"; break; | |
10579 | case Graphic3d_TypeOfShadingModel_Phong: theDI << "phong"; break; | |
10580 | case Graphic3d_TypeOfShadingModel_Pbr: theDI << "pbr"; break; | |
10581 | case Graphic3d_TypeOfShadingModel_PbrFacet: theDI << "pbr_facet"; break; | |
8625ef7e | 10582 | } |
37f80e16 | 10583 | theDI << "\n"; |
15669413 | 10584 | { |
10585 | theDI << "perfCounters:"; | |
10586 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_FrameRate) != 0) | |
10587 | { | |
10588 | theDI << " fps"; | |
10589 | } | |
10590 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_CPU) != 0) | |
10591 | { | |
10592 | theDI << " cpu"; | |
10593 | } | |
10594 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Structures) != 0) | |
10595 | { | |
10596 | theDI << " structs"; | |
10597 | } | |
10598 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Groups) != 0) | |
10599 | { | |
10600 | theDI << " groups"; | |
10601 | } | |
10602 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_GroupArrays) != 0) | |
10603 | { | |
10604 | theDI << " arrays"; | |
10605 | } | |
10606 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Triangles) != 0) | |
10607 | { | |
10608 | theDI << " tris"; | |
10609 | } | |
b9f43ad1 | 10610 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Lines) != 0) |
10611 | { | |
10612 | theDI << " lines"; | |
10613 | } | |
15669413 | 10614 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_Points) != 0) |
10615 | { | |
10616 | theDI << " pnts"; | |
10617 | } | |
10618 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_EstimMem) != 0) | |
10619 | { | |
10620 | theDI << " gpumem"; | |
10621 | } | |
5e30547b | 10622 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_FrameTime) != 0) |
10623 | { | |
10624 | theDI << " frameTime"; | |
10625 | } | |
10626 | if ((aParams.CollectedStats & Graphic3d_RenderingParams::PerfCounters_SkipImmediate) != 0) | |
10627 | { | |
10628 | theDI << " skipimmediate"; | |
10629 | } | |
15669413 | 10630 | if (aParams.CollectedStats == Graphic3d_RenderingParams::PerfCounters_NONE) |
10631 | { | |
10632 | theDI << " none"; | |
10633 | } | |
10634 | theDI << "\n"; | |
10635 | } | |
f88457e6 | 10636 | theDI << "depth pre-pass: " << (aParams.ToEnableDepthPrepass ? "on" : "off") << "\n"; |
c40eb6b9 | 10637 | theDI << "alpha to coverage: " << (aParams.ToEnableAlphaToCoverage ? "on" : "off") << "\n"; |
0e3025bc | 10638 | theDI << "frustum culling: " << (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On ? "on" : |
10639 | aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off ? "off" : | |
10640 | "noUpdate") << "\n"; | |
8625ef7e | 10641 | theDI << "\n"; |
bc8c79bb | 10642 | return 0; |
e276548b | 10643 | } |
10644 | ||
4c7a3fae | 10645 | bool toPrint = false, toSyncDefaults = false, toSyncAllViews = false; |
8625ef7e | 10646 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView); |
e276548b | 10647 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
10648 | { | |
bc8c79bb | 10649 | Standard_CString anArg (theArgVec[anArgIter]); |
10650 | TCollection_AsciiString aFlag (anArg); | |
10651 | aFlag.LowerCase(); | |
8625ef7e | 10652 | if (anUpdateTool.parseRedrawMode (aFlag)) |
10653 | { | |
10654 | continue; | |
10655 | } | |
10656 | else if (aFlag == "-echo" | |
10657 | || aFlag == "-print") | |
e276548b | 10658 | { |
bc8c79bb | 10659 | toPrint = Standard_True; |
8625ef7e | 10660 | anUpdateTool.Invalidate(); |
e276548b | 10661 | } |
4c7a3fae | 10662 | else if (aFlag == "-reset") |
10663 | { | |
10664 | aParams = ViewerTest::GetViewerFromContext()->DefaultRenderingParams(); | |
10665 | } | |
10666 | else if (aFlag == "-sync" | |
10667 | && (anArgIter + 1 < theArgNb)) | |
10668 | { | |
10669 | TCollection_AsciiString aSyncFlag (theArgVec[++anArgIter]); | |
10670 | aSyncFlag.LowerCase(); | |
10671 | if (aSyncFlag == "default" | |
10672 | || aSyncFlag == "defaults" | |
10673 | || aSyncFlag == "viewer") | |
10674 | { | |
10675 | toSyncDefaults = true; | |
10676 | } | |
10677 | else if (aSyncFlag == "allviews" | |
10678 | || aSyncFlag == "views") | |
10679 | { | |
10680 | toSyncAllViews = true; | |
10681 | } | |
10682 | else | |
10683 | { | |
10684 | Message::SendFail ("Syntax error: unknown parameter to -sync argument"); | |
10685 | return 1; | |
10686 | } | |
10687 | } | |
bc8c79bb | 10688 | else if (aFlag == "-mode" |
10689 | || aFlag == "-rendermode" | |
10690 | || aFlag == "-render_mode") | |
e276548b | 10691 | { |
bc8c79bb | 10692 | if (toPrint) |
10693 | { | |
10694 | switch (aParams.Method) | |
10695 | { | |
10696 | case Graphic3d_RM_RASTERIZATION: theDI << "rasterization "; break; | |
10697 | case Graphic3d_RM_RAYTRACING: theDI << "ray-tracing "; break; | |
10698 | } | |
10699 | continue; | |
10700 | } | |
e276548b | 10701 | else |
bc8c79bb | 10702 | { |
23fe70ec | 10703 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
bc8c79bb | 10704 | return 1; |
10705 | } | |
10706 | } | |
10707 | else if (aFlag == "-ray" | |
10708 | || aFlag == "-raytrace") | |
10709 | { | |
10710 | if (toPrint) | |
10711 | { | |
10712 | theDI << (aParams.Method == Graphic3d_RM_RAYTRACING ? "true" : "false") << " "; | |
10713 | continue; | |
10714 | } | |
10715 | ||
4c7a3fae | 10716 | bool isRayTrace = true; |
10717 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 10718 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], isRayTrace)) |
4c7a3fae | 10719 | { |
10720 | ++anArgIter; | |
10721 | } | |
10722 | aParams.Method = isRayTrace ? Graphic3d_RM_RAYTRACING : Graphic3d_RM_RASTERIZATION; | |
e276548b | 10723 | } |
bc8c79bb | 10724 | else if (aFlag == "-rast" |
10725 | || aFlag == "-raster" | |
10726 | || aFlag == "-rasterization") | |
e276548b | 10727 | { |
bc8c79bb | 10728 | if (toPrint) |
10729 | { | |
10730 | theDI << (aParams.Method == Graphic3d_RM_RASTERIZATION ? "true" : "false") << " "; | |
10731 | continue; | |
10732 | } | |
10733 | ||
4c7a3fae | 10734 | bool isRaster = true; |
10735 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 10736 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], isRaster)) |
4c7a3fae | 10737 | { |
10738 | ++anArgIter; | |
10739 | } | |
10740 | aParams.Method = isRaster ? Graphic3d_RM_RASTERIZATION : Graphic3d_RM_RAYTRACING; | |
bc8c79bb | 10741 | } |
3c4b62a4 | 10742 | else if (aFlag == "-msaa") |
10743 | { | |
10744 | if (toPrint) | |
10745 | { | |
10746 | theDI << aParams.NbMsaaSamples << " "; | |
10747 | continue; | |
10748 | } | |
10749 | else if (++anArgIter >= theArgNb) | |
10750 | { | |
23fe70ec | 10751 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
3c4b62a4 | 10752 | return 1; |
10753 | } | |
10754 | ||
10755 | const Standard_Integer aNbSamples = Draw::Atoi (theArgVec[anArgIter]); | |
10756 | if (aNbSamples < 0) | |
10757 | { | |
23fe70ec | 10758 | Message::SendFail() << "Syntax error: invalid number of MSAA samples " << aNbSamples << ""; |
3c4b62a4 | 10759 | return 1; |
10760 | } | |
10761 | else | |
10762 | { | |
10763 | aParams.NbMsaaSamples = aNbSamples; | |
10764 | } | |
10765 | } | |
2a332745 | 10766 | else if (aFlag == "-linefeather" |
10767 | || aFlag == "-edgefeather" | |
10768 | || aFlag == "-feather") | |
10769 | { | |
10770 | if (toPrint) | |
10771 | { | |
10772 | theDI << " " << aParams.LineFeather << " "; | |
10773 | continue; | |
10774 | } | |
10775 | else if (++anArgIter >= theArgNb) | |
10776 | { | |
23fe70ec | 10777 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
2a332745 | 10778 | return 1; |
10779 | } | |
10780 | ||
10781 | TCollection_AsciiString aParam = theArgVec[anArgIter]; | |
10782 | const Standard_ShortReal aFeather = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]); | |
10783 | if (aFeather <= 0.0f) | |
10784 | { | |
23fe70ec | 10785 | Message::SendFail() << "Syntax error: invalid value of line width feather " << aFeather << ". Should be > 0"; |
2a332745 | 10786 | return 1; |
10787 | } | |
10788 | aParams.LineFeather = aFeather; | |
10789 | } | |
a1073ae2 | 10790 | else if (aFlag == "-oit") |
10791 | { | |
10792 | if (toPrint) | |
10793 | { | |
10794 | if (aParams.TransparencyMethod == Graphic3d_RTM_BLEND_OIT) | |
10795 | { | |
10796 | theDI << "on, depth weight factor: " << TCollection_AsciiString (aParams.OitDepthFactor) << " "; | |
10797 | } | |
78c4e836 | 10798 | else if (aParams.TransparencyMethod == Graphic3d_RTM_DEPTH_PEELING_OIT) |
10799 | { | |
10800 | theDI << "on, depth peeling layers: " << TCollection_AsciiString (aParams.NbOitDepthPeelingLayers) << " "; | |
10801 | } | |
a1073ae2 | 10802 | else |
10803 | { | |
10804 | theDI << "off" << " "; | |
10805 | } | |
10806 | continue; | |
10807 | } | |
10808 | else if (++anArgIter >= theArgNb) | |
10809 | { | |
23fe70ec | 10810 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
a1073ae2 | 10811 | return 1; |
10812 | } | |
10813 | ||
10814 | TCollection_AsciiString aParam = theArgVec[anArgIter]; | |
10815 | aParam.LowerCase(); | |
78c4e836 | 10816 | if (aParam == "peeling" |
10817 | || aParam == "peel") | |
10818 | { | |
10819 | aParams.TransparencyMethod = Graphic3d_RTM_DEPTH_PEELING_OIT; | |
10820 | if (anArgIter + 1 < theArgNb | |
10821 | && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue()) | |
10822 | { | |
10823 | ++anArgIter; | |
10824 | const Standard_Integer aNbLayers = TCollection_AsciiString (theArgVec[anArgIter]).IntegerValue(); | |
10825 | if (aNbLayers < 2) | |
10826 | { | |
10827 | Message::SendFail() << "Syntax error: invalid layers number specified for Depth Peeling OIT " << aNbLayers; | |
10828 | return 1; | |
10829 | } | |
10830 | aParams.NbOitDepthPeelingLayers = TCollection_AsciiString (theArgVec[anArgIter]).IntegerValue(); | |
10831 | } | |
10832 | } | |
10833 | else if (aParam == "weighted" | |
10834 | || aParam == "weight") | |
10835 | { | |
10836 | aParams.TransparencyMethod = Graphic3d_RTM_BLEND_OIT; | |
10837 | if (anArgIter + 1 < theArgNb | |
10838 | && TCollection_AsciiString (theArgVec[anArgIter + 1]).IsRealValue()) | |
10839 | { | |
10840 | ++anArgIter; | |
10841 | const Standard_ShortReal aWeight = (Standard_ShortReal)TCollection_AsciiString (theArgVec[anArgIter]).RealValue(); | |
10842 | if (aWeight < 0.f || aWeight > 1.f) | |
10843 | { | |
10844 | Message::SendFail() << "Syntax error: invalid value of Weighted Order-Independent Transparency depth weight factor " << aWeight << ". Should be within range [0.0; 1.0]"; | |
10845 | return 1; | |
10846 | } | |
10847 | aParams.OitDepthFactor = aWeight; | |
10848 | } | |
10849 | } | |
10850 | else if (aParam.IsRealValue()) | |
a1073ae2 | 10851 | { |
10852 | const Standard_ShortReal aWeight = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]); | |
10853 | if (aWeight < 0.f || aWeight > 1.f) | |
10854 | { | |
23fe70ec | 10855 | Message::SendFail() << "Syntax error: invalid value of Weighted Order-Independent Transparency depth weight factor " << aWeight << ". Should be within range [0.0; 1.0]"; |
a1073ae2 | 10856 | return 1; |
10857 | } | |
10858 | ||
10859 | aParams.TransparencyMethod = Graphic3d_RTM_BLEND_OIT; | |
10860 | aParams.OitDepthFactor = aWeight; | |
10861 | } | |
10862 | else if (aParam == "off") | |
10863 | { | |
10864 | aParams.TransparencyMethod = Graphic3d_RTM_BLEND_UNORDERED; | |
10865 | } | |
10866 | else | |
10867 | { | |
23fe70ec | 10868 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
a1073ae2 | 10869 | return 1; |
10870 | } | |
10871 | } | |
d37aef5c | 10872 | else if (aFlag == "-fonthinting" |
10873 | || aFlag == "-fonthint") | |
10874 | { | |
10875 | if (toPrint) | |
10876 | { | |
10877 | if ((aParams.FontHinting & Font_Hinting_Normal) != 0) | |
10878 | { | |
10879 | theDI << "normal" << " "; | |
10880 | } | |
10881 | else if ((aParams.FontHinting & Font_Hinting_Normal) != 0) | |
10882 | { | |
10883 | theDI << "light" << " "; | |
10884 | } | |
10885 | else | |
10886 | { | |
10887 | theDI << "off" << " "; | |
10888 | } | |
10889 | continue; | |
10890 | } | |
10891 | else if (anArgIter + 1 >= theArgNb) | |
10892 | { | |
10893 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
10894 | return 1; | |
10895 | } | |
10896 | ||
10897 | TCollection_AsciiString aHintStyle (theArgVec[++anArgIter]); | |
10898 | aHintStyle.LowerCase(); | |
10899 | if (aHintStyle == "normal" | |
10900 | || aHintStyle == "on" | |
10901 | || aHintStyle == "1") | |
10902 | { | |
10903 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_Light); | |
10904 | aParams.FontHinting = Font_Hinting(aParams.FontHinting | Font_Hinting_Normal); | |
10905 | } | |
10906 | else if (aHintStyle == "light") | |
10907 | { | |
10908 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_Normal); | |
10909 | aParams.FontHinting = Font_Hinting(aParams.FontHinting | Font_Hinting_Light); | |
10910 | } | |
10911 | else if (aHintStyle == "no" | |
10912 | || aHintStyle == "off" | |
10913 | || aHintStyle == "0") | |
10914 | { | |
10915 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_Normal); | |
10916 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_Light); | |
10917 | } | |
10918 | else | |
10919 | { | |
10920 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
10921 | return 1; | |
10922 | } | |
10923 | } | |
10924 | else if (aFlag == "-fontautohinting" | |
10925 | || aFlag == "-fontautohint") | |
10926 | { | |
10927 | if (toPrint) | |
10928 | { | |
10929 | if ((aParams.FontHinting & Font_Hinting_ForceAutohint) != 0) | |
10930 | { | |
10931 | theDI << "force" << " "; | |
10932 | } | |
10933 | else if ((aParams.FontHinting & Font_Hinting_NoAutohint) != 0) | |
10934 | { | |
10935 | theDI << "disallow" << " "; | |
10936 | } | |
10937 | else | |
10938 | { | |
10939 | theDI << "auto" << " "; | |
10940 | } | |
10941 | continue; | |
10942 | } | |
10943 | else if (anArgIter + 1 >= theArgNb) | |
10944 | { | |
10945 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
10946 | return 1; | |
10947 | } | |
10948 | ||
10949 | TCollection_AsciiString aHintStyle (theArgVec[++anArgIter]); | |
10950 | aHintStyle.LowerCase(); | |
10951 | if (aHintStyle == "force") | |
10952 | { | |
10953 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_NoAutohint); | |
10954 | aParams.FontHinting = Font_Hinting(aParams.FontHinting | Font_Hinting_ForceAutohint); | |
10955 | } | |
10956 | else if (aHintStyle == "disallow" | |
10957 | || aHintStyle == "no") | |
10958 | { | |
10959 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_ForceAutohint); | |
10960 | aParams.FontHinting = Font_Hinting(aParams.FontHinting | Font_Hinting_NoAutohint); | |
10961 | } | |
10962 | else if (aHintStyle == "auto") | |
10963 | { | |
10964 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_ForceAutohint); | |
10965 | aParams.FontHinting = Font_Hinting(aParams.FontHinting & ~Font_Hinting_NoAutohint); | |
10966 | } | |
10967 | else | |
10968 | { | |
10969 | theDI << "Syntax error at '" << theArgVec[anArgIter] << "'"; | |
10970 | return 1; | |
10971 | } | |
10972 | } | |
f88457e6 | 10973 | else if (aFlag == "-depthprepass") |
10974 | { | |
10975 | if (toPrint) | |
10976 | { | |
10977 | theDI << (aParams.ToEnableDepthPrepass ? "on " : "off "); | |
10978 | continue; | |
10979 | } | |
10980 | aParams.ToEnableDepthPrepass = Standard_True; | |
10981 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 10982 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableDepthPrepass)) |
f88457e6 | 10983 | { |
10984 | ++anArgIter; | |
10985 | } | |
10986 | } | |
c40eb6b9 | 10987 | else if (aFlag == "-samplealphatocoverage" |
10988 | || aFlag == "-alphatocoverage") | |
10989 | { | |
10990 | if (toPrint) | |
10991 | { | |
10992 | theDI << (aParams.ToEnableAlphaToCoverage ? "on " : "off "); | |
10993 | continue; | |
10994 | } | |
10995 | aParams.ToEnableAlphaToCoverage = Standard_True; | |
10996 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 10997 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableAlphaToCoverage)) |
c40eb6b9 | 10998 | { |
10999 | ++anArgIter; | |
11000 | } | |
11001 | } | |
56689b27 | 11002 | else if (aFlag == "-rendscale" |
11003 | || aFlag == "-renderscale" | |
11004 | || aFlag == "-renderresolutionscale") | |
11005 | { | |
11006 | if (toPrint) | |
11007 | { | |
11008 | theDI << aParams.RenderResolutionScale << " "; | |
11009 | continue; | |
11010 | } | |
11011 | else if (++anArgIter >= theArgNb) | |
11012 | { | |
23fe70ec | 11013 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
56689b27 | 11014 | return 1; |
11015 | } | |
11016 | ||
11017 | const Standard_Real aScale = Draw::Atof (theArgVec[anArgIter]); | |
11018 | if (aScale < 0.01) | |
11019 | { | |
23fe70ec | 11020 | Message::SendFail() << "Syntax error: invalid rendering resolution scale " << aScale << ""; |
56689b27 | 11021 | return 1; |
11022 | } | |
11023 | else | |
11024 | { | |
11025 | aParams.RenderResolutionScale = Standard_ShortReal(aScale); | |
11026 | } | |
11027 | } | |
bc8c79bb | 11028 | else if (aFlag == "-raydepth" |
11029 | || aFlag == "-ray_depth") | |
11030 | { | |
11031 | if (toPrint) | |
11032 | { | |
11033 | theDI << aParams.RaytracingDepth << " "; | |
11034 | continue; | |
11035 | } | |
11036 | else if (++anArgIter >= theArgNb) | |
11037 | { | |
23fe70ec | 11038 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
bc8c79bb | 11039 | return 1; |
11040 | } | |
11041 | ||
11042 | const Standard_Integer aDepth = Draw::Atoi (theArgVec[anArgIter]); | |
189f85a3 | 11043 | |
11044 | // We allow RaytracingDepth be more than 10 in case of GI enabled | |
11045 | if (aDepth < 1 || (aDepth > 10 && !aParams.IsGlobalIlluminationEnabled)) | |
bc8c79bb | 11046 | { |
23fe70ec | 11047 | Message::SendFail() << "Syntax error: invalid ray-tracing depth " << aDepth << ". Should be within range [1; 10]"; |
bc8c79bb | 11048 | return 1; |
11049 | } | |
e276548b | 11050 | else |
bc8c79bb | 11051 | { |
11052 | aParams.RaytracingDepth = aDepth; | |
11053 | } | |
11054 | } | |
11055 | else if (aFlag == "-shad" | |
11056 | || aFlag == "-shadows") | |
11057 | { | |
11058 | if (toPrint) | |
11059 | { | |
11060 | theDI << (aParams.IsShadowEnabled ? "on" : "off") << " "; | |
11061 | continue; | |
11062 | } | |
11063 | ||
11064 | Standard_Boolean toEnable = Standard_True; | |
11065 | if (++anArgIter < theArgNb | |
dae2a922 | 11066 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
bc8c79bb | 11067 | { |
11068 | --anArgIter; | |
11069 | } | |
11070 | aParams.IsShadowEnabled = toEnable; | |
11071 | } | |
d84e8669 | 11072 | else if (aFlag == "-shadowmapresolution" |
11073 | || aFlag == "-shadowmap") | |
11074 | { | |
11075 | if (toPrint) | |
11076 | { | |
11077 | theDI << aParams.ShadowMapResolution << " "; | |
11078 | continue; | |
11079 | } | |
11080 | else if (++anArgIter >= theArgNb) | |
11081 | { | |
11082 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; | |
11083 | return 1; | |
11084 | } | |
11085 | ||
11086 | aParams.ShadowMapResolution = Draw::Atoi (theArgVec[anArgIter]); | |
11087 | } | |
11088 | else if (aFlag == "-shadowmapbias") | |
11089 | { | |
11090 | if (toPrint) | |
11091 | { | |
11092 | theDI << aParams.ShadowMapBias << " "; | |
11093 | continue; | |
11094 | } | |
11095 | else if (++anArgIter >= theArgNb) | |
11096 | { | |
11097 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; | |
11098 | return 1; | |
11099 | } | |
11100 | ||
11101 | aParams.ShadowMapBias = (float )Draw::Atof (theArgVec[anArgIter]); | |
11102 | } | |
bc8c79bb | 11103 | else if (aFlag == "-refl" |
11104 | || aFlag == "-reflections") | |
11105 | { | |
11106 | if (toPrint) | |
11107 | { | |
11108 | theDI << (aParams.IsReflectionEnabled ? "on" : "off") << " "; | |
11109 | continue; | |
11110 | } | |
11111 | ||
11112 | Standard_Boolean toEnable = Standard_True; | |
11113 | if (++anArgIter < theArgNb | |
dae2a922 | 11114 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
bc8c79bb | 11115 | { |
11116 | --anArgIter; | |
11117 | } | |
11118 | aParams.IsReflectionEnabled = toEnable; | |
11119 | } | |
11120 | else if (aFlag == "-fsaa") | |
11121 | { | |
11122 | if (toPrint) | |
11123 | { | |
11124 | theDI << (aParams.IsAntialiasingEnabled ? "on" : "off") << " "; | |
11125 | continue; | |
11126 | } | |
11127 | ||
11128 | Standard_Boolean toEnable = Standard_True; | |
11129 | if (++anArgIter < theArgNb | |
dae2a922 | 11130 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
bc8c79bb | 11131 | { |
11132 | --anArgIter; | |
11133 | } | |
11134 | aParams.IsAntialiasingEnabled = toEnable; | |
11135 | } | |
11136 | else if (aFlag == "-gleam") | |
11137 | { | |
11138 | if (toPrint) | |
11139 | { | |
11140 | theDI << (aParams.IsTransparentShadowEnabled ? "on" : "off") << " "; | |
11141 | continue; | |
11142 | } | |
11143 | ||
11144 | Standard_Boolean toEnable = Standard_True; | |
11145 | if (++anArgIter < theArgNb | |
dae2a922 | 11146 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
bc8c79bb | 11147 | { |
11148 | --anArgIter; | |
11149 | } | |
11150 | aParams.IsTransparentShadowEnabled = toEnable; | |
e276548b | 11151 | } |
189f85a3 | 11152 | else if (aFlag == "-gi") |
11153 | { | |
11154 | if (toPrint) | |
11155 | { | |
11156 | theDI << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << " "; | |
11157 | continue; | |
11158 | } | |
11159 | ||
11160 | Standard_Boolean toEnable = Standard_True; | |
11161 | if (++anArgIter < theArgNb | |
dae2a922 | 11162 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
189f85a3 | 11163 | { |
11164 | --anArgIter; | |
11165 | } | |
11166 | aParams.IsGlobalIlluminationEnabled = toEnable; | |
11167 | if (!toEnable) | |
11168 | { | |
11169 | aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10); | |
11170 | } | |
11171 | } | |
8c820969 | 11172 | else if (aFlag == "-blockedrng" |
11173 | || aFlag == "-brng") | |
11174 | { | |
11175 | if (toPrint) | |
11176 | { | |
11177 | theDI << (aParams.CoherentPathTracingMode ? "on" : "off") << " "; | |
11178 | continue; | |
11179 | } | |
11180 | ||
11181 | Standard_Boolean toEnable = Standard_True; | |
11182 | if (++anArgIter < theArgNb | |
dae2a922 | 11183 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
8c820969 | 11184 | { |
11185 | --anArgIter; | |
11186 | } | |
11187 | aParams.CoherentPathTracingMode = toEnable; | |
11188 | } | |
b09447ed | 11189 | else if (aFlag == "-maxrad") |
11190 | { | |
11191 | if (toPrint) | |
11192 | { | |
11193 | theDI << aParams.RadianceClampingValue << " "; | |
11194 | continue; | |
11195 | } | |
11196 | else if (++anArgIter >= theArgNb) | |
11197 | { | |
23fe70ec | 11198 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
b09447ed | 11199 | return 1; |
11200 | } | |
11201 | ||
11202 | const TCollection_AsciiString aMaxRadStr = theArgVec[anArgIter]; | |
d45edf24 | 11203 | if (!aMaxRadStr.IsRealValue (Standard_True)) |
b09447ed | 11204 | { |
23fe70ec | 11205 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
b09447ed | 11206 | return 1; |
11207 | } | |
11208 | ||
11209 | const Standard_Real aMaxRadiance = aMaxRadStr.RealValue(); | |
11210 | if (aMaxRadiance <= 0.0) | |
11211 | { | |
23fe70ec | 11212 | Message::SendFail() << "Syntax error: invalid radiance clamping value " << aMaxRadiance; |
b09447ed | 11213 | return 1; |
11214 | } | |
11215 | else | |
11216 | { | |
11217 | aParams.RadianceClampingValue = static_cast<Standard_ShortReal> (aMaxRadiance); | |
11218 | } | |
11219 | } | |
3a9b5dc8 | 11220 | else if (aFlag == "-iss") |
11221 | { | |
11222 | if (toPrint) | |
11223 | { | |
11224 | theDI << (aParams.AdaptiveScreenSampling ? "on" : "off") << " "; | |
11225 | continue; | |
11226 | } | |
11227 | ||
11228 | Standard_Boolean toEnable = Standard_True; | |
11229 | if (++anArgIter < theArgNb | |
dae2a922 | 11230 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
3a9b5dc8 | 11231 | { |
11232 | --anArgIter; | |
11233 | } | |
11234 | aParams.AdaptiveScreenSampling = toEnable; | |
11235 | } | |
e084dbbc | 11236 | else if (aFlag == "-issatomic") |
11237 | { | |
11238 | if (toPrint) | |
11239 | { | |
11240 | theDI << (aParams.AdaptiveScreenSamplingAtomic ? "on" : "off") << " "; | |
11241 | continue; | |
11242 | } | |
11243 | ||
11244 | Standard_Boolean toEnable = Standard_True; | |
11245 | if (++anArgIter < theArgNb | |
dae2a922 | 11246 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
e084dbbc | 11247 | { |
11248 | --anArgIter; | |
11249 | } | |
11250 | aParams.AdaptiveScreenSamplingAtomic = toEnable; | |
11251 | } | |
3a9b5dc8 | 11252 | else if (aFlag == "-issd") |
11253 | { | |
11254 | if (toPrint) | |
11255 | { | |
11256 | theDI << (aParams.ShowSamplingTiles ? "on" : "off") << " "; | |
11257 | continue; | |
11258 | } | |
11259 | ||
11260 | Standard_Boolean toEnable = Standard_True; | |
11261 | if (++anArgIter < theArgNb | |
dae2a922 | 11262 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
3a9b5dc8 | 11263 | { |
11264 | --anArgIter; | |
11265 | } | |
11266 | aParams.ShowSamplingTiles = toEnable; | |
11267 | } | |
66d1cdc6 | 11268 | else if (aFlag == "-tilesize") |
11269 | { | |
11270 | if (toPrint) | |
11271 | { | |
11272 | theDI << aParams.RayTracingTileSize << " "; | |
11273 | continue; | |
11274 | } | |
11275 | else if (++anArgIter >= theArgNb) | |
11276 | { | |
23fe70ec | 11277 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
66d1cdc6 | 11278 | return 1; |
11279 | } | |
11280 | ||
11281 | const Standard_Integer aTileSize = Draw::Atoi (theArgVec[anArgIter]); | |
11282 | if (aTileSize < 1) | |
11283 | { | |
23fe70ec | 11284 | Message::SendFail() << "Syntax error: invalid size of ISS tile " << aTileSize; |
66d1cdc6 | 11285 | return 1; |
11286 | } | |
11287 | aParams.RayTracingTileSize = aTileSize; | |
11288 | } | |
4eaaf9d8 | 11289 | else if (aFlag == "-nbtiles") |
11290 | { | |
11291 | if (toPrint) | |
11292 | { | |
11293 | theDI << aParams.NbRayTracingTiles << " "; | |
11294 | continue; | |
11295 | } | |
11296 | else if (++anArgIter >= theArgNb) | |
11297 | { | |
23fe70ec | 11298 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
4eaaf9d8 | 11299 | return 1; |
11300 | } | |
11301 | ||
11302 | const Standard_Integer aNbTiles = Draw::Atoi (theArgVec[anArgIter]); | |
66d1cdc6 | 11303 | if (aNbTiles < -1) |
4eaaf9d8 | 11304 | { |
23fe70ec | 11305 | Message::SendFail() << "Syntax error: invalid number of ISS tiles " << aNbTiles; |
4eaaf9d8 | 11306 | return 1; |
11307 | } | |
66d1cdc6 | 11308 | else if (aNbTiles > 0 |
11309 | && (aNbTiles < 64 | |
11310 | || aNbTiles > 1024)) | |
4eaaf9d8 | 11311 | { |
23fe70ec | 11312 | Message::SendWarning() << "Warning: suboptimal number of ISS tiles " << aNbTiles << ". Recommended range: [64, 1024]."; |
4eaaf9d8 | 11313 | } |
66d1cdc6 | 11314 | aParams.NbRayTracingTiles = aNbTiles; |
4eaaf9d8 | 11315 | } |
189f85a3 | 11316 | else if (aFlag == "-env") |
11317 | { | |
11318 | if (toPrint) | |
11319 | { | |
11320 | theDI << (aParams.UseEnvironmentMapBackground ? "on" : "off") << " "; | |
11321 | continue; | |
11322 | } | |
11323 | ||
11324 | Standard_Boolean toEnable = Standard_True; | |
11325 | if (++anArgIter < theArgNb | |
dae2a922 | 11326 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
189f85a3 | 11327 | { |
11328 | --anArgIter; | |
11329 | } | |
11330 | aParams.UseEnvironmentMapBackground = toEnable; | |
11331 | } | |
78607702 | 11332 | else if (aFlag == "-ignorenormalmap") |
11333 | { | |
11334 | if (toPrint) | |
11335 | { | |
11336 | theDI << (aParams.ToIgnoreNormalMapInRayTracing ? "on" : "off") << " "; | |
11337 | continue; | |
11338 | } | |
11339 | ||
11340 | Standard_Boolean toEnable = Standard_True; | |
11341 | if (++anArgIter < theArgNb | |
dae2a922 | 11342 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
78607702 | 11343 | { |
11344 | --anArgIter; | |
11345 | } | |
11346 | aParams.ToIgnoreNormalMapInRayTracing = toEnable; | |
11347 | } | |
b4327ba8 | 11348 | else if (aFlag == "-twoside") |
11349 | { | |
11350 | if (toPrint) | |
11351 | { | |
11352 | theDI << (aParams.TwoSidedBsdfModels ? "on" : "off") << " "; | |
11353 | continue; | |
11354 | } | |
11355 | ||
11356 | Standard_Boolean toEnable = Standard_True; | |
11357 | if (++anArgIter < theArgNb | |
dae2a922 | 11358 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
b4327ba8 | 11359 | { |
11360 | --anArgIter; | |
11361 | } | |
11362 | aParams.TwoSidedBsdfModels = toEnable; | |
11363 | } | |
8625ef7e | 11364 | else if (aFlag == "-shademodel" |
11365 | || aFlag == "-shadingmodel" | |
11366 | || aFlag == "-shading") | |
11367 | { | |
11368 | if (toPrint) | |
11369 | { | |
11370 | switch (aView->ShadingModel()) | |
11371 | { | |
13b36bb1 | 11372 | case Graphic3d_TypeOfShadingModel_DEFAULT: theDI << "default"; break; |
11373 | case Graphic3d_TypeOfShadingModel_Unlit: theDI << "unlit "; break; | |
11374 | case Graphic3d_TypeOfShadingModel_PhongFacet: theDI << "flat "; break; | |
11375 | case Graphic3d_TypeOfShadingModel_Gouraud: theDI << "gouraud "; break; | |
11376 | case Graphic3d_TypeOfShadingModel_Phong: theDI << "phong "; break; | |
11377 | case Graphic3d_TypeOfShadingModel_Pbr: theDI << "pbr"; break; | |
11378 | case Graphic3d_TypeOfShadingModel_PbrFacet: theDI << "pbr_facet"; break; | |
8625ef7e | 11379 | } |
11380 | continue; | |
11381 | } | |
11382 | ||
11383 | if (++anArgIter >= theArgNb) | |
11384 | { | |
23fe70ec | 11385 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
8625ef7e | 11386 | } |
11387 | ||
13b36bb1 | 11388 | Graphic3d_TypeOfShadingModel aModel = Graphic3d_TypeOfShadingModel_DEFAULT; |
dc89236f | 11389 | if (ViewerTest::ParseShadingModel (theArgVec[anArgIter], aModel) |
13b36bb1 | 11390 | && aModel != Graphic3d_TypeOfShadingModel_DEFAULT) |
8625ef7e | 11391 | { |
dc89236f | 11392 | aView->SetShadingModel (aModel); |
8625ef7e | 11393 | } |
11394 | else | |
11395 | { | |
23fe70ec | 11396 | Message::SendFail() << "Syntax error: unknown shading model '" << theArgVec[anArgIter] << "'"; |
8625ef7e | 11397 | return 1; |
11398 | } | |
11399 | } | |
67312b79 | 11400 | else if (aFlag == "-pbrenvpow2size" |
11401 | || aFlag == "-pbrenvp2s" | |
11402 | || aFlag == "-pep2s") | |
11403 | { | |
11404 | if (++anArgIter >= theArgNb) | |
11405 | { | |
23fe70ec | 11406 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
67312b79 | 11407 | return 1; |
11408 | } | |
11409 | ||
11410 | const Standard_Integer aPbrEnvPow2Size = Draw::Atoi (theArgVec[anArgIter]); | |
11411 | if (aPbrEnvPow2Size < 1) | |
11412 | { | |
23fe70ec | 11413 | Message::SendFail ("Syntax error: 'Pow2Size' of PBR Environment has to be greater or equal 1"); |
67312b79 | 11414 | return 1; |
11415 | } | |
11416 | aParams.PbrEnvPow2Size = aPbrEnvPow2Size; | |
11417 | } | |
11418 | else if (aFlag == "-pbrenvspecmaplevelsnumber" | |
11419 | || aFlag == "-pbrenvspecmapnblevels" | |
11420 | || aFlag == "-pbrenvspecmaplevels" | |
11421 | || aFlag == "-pbrenvsmln" | |
11422 | || aFlag == "-pesmln") | |
11423 | { | |
11424 | if (++anArgIter >= theArgNb) | |
11425 | { | |
23fe70ec | 11426 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
67312b79 | 11427 | return 1; |
11428 | } | |
11429 | ||
11430 | const Standard_Integer aPbrEnvSpecMapNbLevels = Draw::Atoi (theArgVec[anArgIter]); | |
11431 | if (aPbrEnvSpecMapNbLevels < 2) | |
11432 | { | |
23fe70ec | 11433 | Message::SendFail ("Syntax error: 'SpecMapLevelsNumber' of PBR Environment has to be greater or equal 2"); |
67312b79 | 11434 | return 1; |
11435 | } | |
11436 | aParams.PbrEnvSpecMapNbLevels = aPbrEnvSpecMapNbLevels; | |
11437 | } | |
11438 | else if (aFlag == "-pbrenvbakngdiffsamplesnumber" | |
11439 | || aFlag == "-pbrenvbakingdiffsamples" | |
11440 | || aFlag == "-pbrenvbdsn") | |
11441 | { | |
11442 | if (++anArgIter >= theArgNb) | |
11443 | { | |
23fe70ec | 11444 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
67312b79 | 11445 | return 1; |
11446 | } | |
11447 | ||
11448 | const Standard_Integer aPbrEnvBakingDiffNbSamples = Draw::Atoi (theArgVec[anArgIter]); | |
11449 | if (aPbrEnvBakingDiffNbSamples < 1) | |
11450 | { | |
4551e1be | 11451 | Message::SendFail ("Syntax error: 'BakingDiffSamplesNumber' of PBR Environment has to be greater or equal 1"); |
67312b79 | 11452 | return 1; |
11453 | } | |
11454 | aParams.PbrEnvBakingDiffNbSamples = aPbrEnvBakingDiffNbSamples; | |
11455 | } | |
11456 | else if (aFlag == "-pbrenvbakngspecsamplesnumber" | |
11457 | || aFlag == "-pbrenvbakingspecsamples" | |
11458 | || aFlag == "-pbrenvbssn") | |
11459 | { | |
11460 | if (++anArgIter >= theArgNb) | |
11461 | { | |
23fe70ec | 11462 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
67312b79 | 11463 | return 1; |
11464 | } | |
11465 | ||
11466 | const Standard_Integer aPbrEnvBakingSpecNbSamples = Draw::Atoi(theArgVec[anArgIter]); | |
11467 | if (aPbrEnvBakingSpecNbSamples < 1) | |
11468 | { | |
4551e1be | 11469 | Message::SendFail ("Syntax error: 'BakingSpecSamplesNumber' of PBR Environment has to be greater or equal 1"); |
67312b79 | 11470 | return 1; |
11471 | } | |
11472 | aParams.PbrEnvBakingSpecNbSamples = aPbrEnvBakingSpecNbSamples; | |
11473 | } | |
11474 | else if (aFlag == "-pbrenvbakingprobability" | |
11475 | || aFlag == "-pbrenvbp") | |
11476 | { | |
11477 | if (++anArgIter >= theArgNb) | |
11478 | { | |
23fe70ec | 11479 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
67312b79 | 11480 | return 1; |
11481 | } | |
11482 | const Standard_ShortReal aPbrEnvBakingProbability = static_cast<Standard_ShortReal>(Draw::Atof (theArgVec[anArgIter])); | |
11483 | if (aPbrEnvBakingProbability < 0.f | |
11484 | || aPbrEnvBakingProbability > 1.f) | |
11485 | { | |
4551e1be | 11486 | Message::SendFail ("Syntax error: 'BakingProbability' of PBR Environment has to be in range of [0, 1]"); |
67312b79 | 11487 | return 1; |
11488 | } | |
11489 | aParams.PbrEnvBakingProbability = aPbrEnvBakingProbability; | |
11490 | } | |
4b1c8733 | 11491 | else if (aFlag == "-resolution") |
11492 | { | |
11493 | if (++anArgIter >= theArgNb) | |
11494 | { | |
23fe70ec | 11495 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
4b1c8733 | 11496 | return 1; |
11497 | } | |
11498 | ||
11499 | TCollection_AsciiString aResolution (theArgVec[anArgIter]); | |
11500 | if (aResolution.IsIntegerValue()) | |
11501 | { | |
11502 | aView->ChangeRenderingParams().Resolution = static_cast<unsigned int> (Draw::Atoi (aResolution.ToCString())); | |
11503 | } | |
11504 | else | |
11505 | { | |
23fe70ec | 11506 | Message::SendFail() << "Syntax error: wrong syntax at argument'" << anArg << "'"; |
4b1c8733 | 11507 | return 1; |
11508 | } | |
11509 | } | |
d877e610 | 11510 | else if (aFlag == "-rebuildglsl" |
11511 | || aFlag == "-rebuild") | |
11512 | { | |
11513 | if (toPrint) | |
11514 | { | |
11515 | theDI << (aParams.RebuildRayTracingShaders ? "on" : "off") << " "; | |
11516 | continue; | |
11517 | } | |
11518 | ||
11519 | Standard_Boolean toEnable = Standard_True; | |
11520 | if (++anArgIter < theArgNb | |
dae2a922 | 11521 | && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable)) |
d877e610 | 11522 | { |
11523 | --anArgIter; | |
11524 | } | |
11525 | aParams.RebuildRayTracingShaders = toEnable; | |
11526 | } | |
b27ab03d | 11527 | else if (aFlag == "-focal") |
11528 | { | |
11529 | if (++anArgIter >= theArgNb) | |
11530 | { | |
23fe70ec | 11531 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
b27ab03d | 11532 | return 1; |
11533 | } | |
11534 | ||
11535 | TCollection_AsciiString aParam (theArgVec[anArgIter]); | |
d45edf24 | 11536 | if (aParam.IsRealValue (Standard_True)) |
b27ab03d | 11537 | { |
11538 | float aFocalDist = static_cast<float> (aParam.RealValue()); | |
11539 | if (aFocalDist < 0) | |
11540 | { | |
23fe70ec | 11541 | Message::SendFail() << "Error: parameter can't be negative at argument '" << anArg << "'"; |
b27ab03d | 11542 | return 1; |
11543 | } | |
11544 | aView->ChangeRenderingParams().CameraFocalPlaneDist = aFocalDist; | |
11545 | } | |
11546 | else | |
11547 | { | |
23fe70ec | 11548 | Message::SendFail() << "Syntax error at argument'" << anArg << "'"; |
b27ab03d | 11549 | return 1; |
11550 | } | |
11551 | } | |
11552 | else if (aFlag == "-aperture") | |
11553 | { | |
11554 | if (++anArgIter >= theArgNb) | |
11555 | { | |
23fe70ec | 11556 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
b27ab03d | 11557 | return 1; |
11558 | } | |
11559 | ||
11560 | TCollection_AsciiString aParam(theArgVec[anArgIter]); | |
d45edf24 | 11561 | if (aParam.IsRealValue (Standard_True)) |
b27ab03d | 11562 | { |
11563 | float aApertureSize = static_cast<float> (aParam.RealValue()); | |
11564 | if (aApertureSize < 0) | |
11565 | { | |
23fe70ec | 11566 | Message::SendFail() << "Error: parameter can't be negative at argument '" << anArg << "'"; |
b27ab03d | 11567 | return 1; |
11568 | } | |
11569 | aView->ChangeRenderingParams().CameraApertureRadius = aApertureSize; | |
11570 | } | |
11571 | else | |
11572 | { | |
23fe70ec | 11573 | Message::SendFail() << "Syntax error at argument'" << anArg << "'"; |
b27ab03d | 11574 | return 1; |
11575 | } | |
11576 | } | |
eb85ed36 | 11577 | else if (aFlag == "-exposure") |
11578 | { | |
11579 | if (++anArgIter >= theArgNb) | |
11580 | { | |
23fe70ec | 11581 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
eb85ed36 | 11582 | return 1; |
11583 | } | |
11584 | ||
11585 | TCollection_AsciiString anExposure (theArgVec[anArgIter]); | |
d45edf24 | 11586 | if (anExposure.IsRealValue (Standard_True)) |
eb85ed36 | 11587 | { |
11588 | aView->ChangeRenderingParams().Exposure = static_cast<float> (anExposure.RealValue()); | |
11589 | } | |
11590 | else | |
11591 | { | |
23fe70ec | 11592 | Message::SendFail() << "Syntax error at argument'" << anArg << "'"; |
eb85ed36 | 11593 | return 1; |
11594 | } | |
11595 | } | |
11596 | else if (aFlag == "-whitepoint") | |
11597 | { | |
11598 | if (++anArgIter >= theArgNb) | |
11599 | { | |
23fe70ec | 11600 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
eb85ed36 | 11601 | return 1; |
11602 | } | |
11603 | ||
11604 | TCollection_AsciiString aWhitePoint (theArgVec[anArgIter]); | |
d45edf24 | 11605 | if (aWhitePoint.IsRealValue (Standard_True)) |
eb85ed36 | 11606 | { |
11607 | aView->ChangeRenderingParams().WhitePoint = static_cast<float> (aWhitePoint.RealValue()); | |
11608 | } | |
11609 | else | |
11610 | { | |
23fe70ec | 11611 | Message::SendFail() << "Syntax error at argument'" << anArg << "'"; |
eb85ed36 | 11612 | return 1; |
11613 | } | |
11614 | } | |
11615 | else if (aFlag == "-tonemapping") | |
11616 | { | |
11617 | if (++anArgIter >= theArgNb) | |
11618 | { | |
23fe70ec | 11619 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
eb85ed36 | 11620 | return 1; |
11621 | } | |
11622 | ||
11623 | TCollection_AsciiString aMode (theArgVec[anArgIter]); | |
11624 | aMode.LowerCase(); | |
11625 | ||
11626 | if (aMode == "disabled") | |
11627 | { | |
11628 | aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Disabled; | |
11629 | } | |
11630 | else if (aMode == "filmic") | |
11631 | { | |
11632 | aView->ChangeRenderingParams().ToneMappingMethod = Graphic3d_ToneMappingMethod_Filmic; | |
11633 | } | |
11634 | else | |
11635 | { | |
23fe70ec | 11636 | Message::SendFail() << "Syntax error at argument'" << anArg << "'"; |
eb85ed36 | 11637 | return 1; |
11638 | } | |
11639 | } | |
15669413 | 11640 | else if (aFlag == "-performancestats" |
11641 | || aFlag == "-performancecounters" | |
11642 | || aFlag == "-perfstats" | |
11643 | || aFlag == "-perfcounters" | |
11644 | || aFlag == "-stats") | |
11645 | { | |
11646 | if (++anArgIter >= theArgNb) | |
11647 | { | |
23fe70ec | 11648 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
15669413 | 11649 | return 1; |
11650 | } | |
11651 | ||
11652 | TCollection_AsciiString aFlagsStr (theArgVec[anArgIter]); | |
11653 | aFlagsStr.LowerCase(); | |
11654 | Graphic3d_RenderingParams::PerfCounters aFlags = aView->ChangeRenderingParams().CollectedStats; | |
11655 | if (!convertToPerfStatsFlags (aFlagsStr, aFlags)) | |
11656 | { | |
23fe70ec | 11657 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
15669413 | 11658 | return 1; |
11659 | } | |
11660 | aView->ChangeRenderingParams().CollectedStats = aFlags; | |
11661 | aView->ChangeRenderingParams().ToShowStats = aFlags != Graphic3d_RenderingParams::PerfCounters_NONE; | |
11662 | } | |
11663 | else if (aFlag == "-perfupdateinterval" | |
11664 | || aFlag == "-statsupdateinterval") | |
11665 | { | |
11666 | if (++anArgIter >= theArgNb) | |
11667 | { | |
23fe70ec | 11668 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
15669413 | 11669 | return 1; |
11670 | } | |
11671 | aView->ChangeRenderingParams().StatsUpdateInterval = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]); | |
11672 | } | |
5e30547b | 11673 | else if (aFlag == "-perfchart" |
11674 | || aFlag == "-statschart") | |
11675 | { | |
11676 | if (++anArgIter >= theArgNb) | |
11677 | { | |
23fe70ec | 11678 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
5e30547b | 11679 | return 1; |
11680 | } | |
11681 | aView->ChangeRenderingParams().StatsNbFrames = Draw::Atoi (theArgVec[anArgIter]); | |
11682 | } | |
11683 | else if (aFlag == "-perfchartmax" | |
11684 | || aFlag == "-statschartmax") | |
11685 | { | |
11686 | if (++anArgIter >= theArgNb) | |
11687 | { | |
23fe70ec | 11688 | Message::SendFail() << "Syntax error at argument '" << anArg << "'"; |
5e30547b | 11689 | return 1; |
11690 | } | |
11691 | aView->ChangeRenderingParams().StatsMaxChartTime = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]); | |
11692 | } | |
0e3025bc | 11693 | else if (aFlag == "-frustumculling" |
11694 | || aFlag == "-culling") | |
11695 | { | |
11696 | if (toPrint) | |
11697 | { | |
11698 | theDI << ((aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On) ? "on" : | |
11699 | (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off) ? "off" : | |
11700 | "noUpdate") << " "; | |
11701 | continue; | |
11702 | } | |
11703 | ||
11704 | Graphic3d_RenderingParams::FrustumCulling aState = Graphic3d_RenderingParams::FrustumCulling_On; | |
11705 | if (++anArgIter < theArgNb) | |
11706 | { | |
11707 | TCollection_AsciiString aStateStr(theArgVec[anArgIter]); | |
11708 | aStateStr.LowerCase(); | |
11709 | bool toEnable = true; | |
dae2a922 | 11710 | if (Draw::ParseOnOff (aStateStr.ToCString(), toEnable)) |
0e3025bc | 11711 | { |
11712 | aState = toEnable ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off; | |
11713 | } | |
11714 | else if (aStateStr == "noupdate" | |
11715 | || aStateStr == "freeze") | |
11716 | { | |
11717 | aState = Graphic3d_RenderingParams::FrustumCulling_NoUpdate; | |
11718 | } | |
11719 | else | |
11720 | { | |
11721 | --anArgIter; | |
11722 | } | |
11723 | } | |
11724 | aParams.FrustumCullingState = aState; | |
11725 | } | |
e276548b | 11726 | else |
11727 | { | |
23fe70ec | 11728 | Message::SendFail() << "Syntax error: unknown flag '" << anArg << "'"; |
bc8c79bb | 11729 | return 1; |
e276548b | 11730 | } |
11731 | } | |
189f85a3 | 11732 | |
4c7a3fae | 11733 | // set current view parameters as defaults |
11734 | if (toSyncDefaults) | |
11735 | { | |
11736 | ViewerTest::GetViewerFromContext()->SetDefaultRenderingParams (aParams); | |
11737 | } | |
11738 | if (toSyncAllViews) | |
11739 | { | |
11740 | for (V3d_ListOfViewIterator aViewIter = ViewerTest::GetViewerFromContext()->DefinedViewIterator(); aViewIter.More(); aViewIter.Next()) | |
11741 | { | |
11742 | aViewIter.Value()->ChangeRenderingParams() = aParams; | |
11743 | } | |
11744 | } | |
189f85a3 | 11745 | return 0; |
11746 | } | |
11747 | ||
79b544e6 | 11748 | //======================================================================= |
11749 | //function : searchInfo | |
11750 | //purpose : | |
11751 | //======================================================================= | |
11752 | inline TCollection_AsciiString searchInfo (const TColStd_IndexedDataMapOfStringString& theDict, | |
11753 | const TCollection_AsciiString& theKey) | |
11754 | { | |
11755 | for (TColStd_IndexedDataMapOfStringString::Iterator anIter (theDict); anIter.More(); anIter.Next()) | |
11756 | { | |
11757 | if (TCollection_AsciiString::IsSameString (anIter.Key(), theKey, Standard_False)) | |
11758 | { | |
11759 | return anIter.Value(); | |
11760 | } | |
11761 | } | |
11762 | return TCollection_AsciiString(); | |
11763 | } | |
11764 | ||
11765 | //======================================================================= | |
11766 | //function : VStatProfiler | |
11767 | //purpose : | |
11768 | //======================================================================= | |
11769 | static Standard_Integer VStatProfiler (Draw_Interpretor& theDI, | |
11770 | Standard_Integer theArgNb, | |
11771 | const char** theArgVec) | |
11772 | { | |
11773 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
11774 | if (aView.IsNull()) | |
11775 | { | |
23fe70ec | 11776 | Message::SendFail ("Error: no active viewer"); |
79b544e6 | 11777 | return 1; |
11778 | } | |
11779 | ||
11780 | Standard_Boolean toRedraw = Standard_True; | |
11781 | Graphic3d_RenderingParams::PerfCounters aPrevCounters = aView->ChangeRenderingParams().CollectedStats; | |
11782 | Standard_ShortReal aPrevUpdInterval = aView->ChangeRenderingParams().StatsUpdateInterval; | |
11783 | Graphic3d_RenderingParams::PerfCounters aRenderParams = Graphic3d_RenderingParams::PerfCounters_NONE; | |
11784 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
11785 | { | |
11786 | Standard_CString anArg (theArgVec[anArgIter]); | |
11787 | TCollection_AsciiString aFlag (anArg); | |
11788 | aFlag.LowerCase(); | |
11789 | if (aFlag == "-noredraw") | |
11790 | { | |
11791 | toRedraw = Standard_False; | |
11792 | } | |
11793 | else | |
11794 | { | |
11795 | Graphic3d_RenderingParams::PerfCounters aParam = Graphic3d_RenderingParams::PerfCounters_NONE; | |
11796 | if (aFlag == "fps") aParam = Graphic3d_RenderingParams::PerfCounters_FrameRate; | |
11797 | else if (aFlag == "cpu") aParam = Graphic3d_RenderingParams::PerfCounters_CPU; | |
11798 | else if (aFlag == "alllayers" | |
11799 | || aFlag == "layers") aParam = Graphic3d_RenderingParams::PerfCounters_Layers; | |
11800 | else if (aFlag == "allstructs" | |
a2803f37 | 11801 | || aFlag == "allstructures" |
11802 | || aFlag == "structs" | |
11803 | || aFlag == "structures") aParam = Graphic3d_RenderingParams::PerfCounters_Structures; | |
79b544e6 | 11804 | else if (aFlag == "groups") aParam = Graphic3d_RenderingParams::PerfCounters_Groups; |
11805 | else if (aFlag == "allarrays" | |
11806 | || aFlag == "fillarrays" | |
11807 | || aFlag == "linearrays" | |
11808 | || aFlag == "pointarrays" | |
11809 | || aFlag == "textarrays") aParam = Graphic3d_RenderingParams::PerfCounters_GroupArrays; | |
11810 | else if (aFlag == "triangles") aParam = Graphic3d_RenderingParams::PerfCounters_Triangles; | |
b9f43ad1 | 11811 | else if (aFlag == "lines") aParam = Graphic3d_RenderingParams::PerfCounters_Lines; |
79b544e6 | 11812 | else if (aFlag == "points") aParam = Graphic3d_RenderingParams::PerfCounters_Points; |
11813 | else if (aFlag == "geommem" | |
11814 | || aFlag == "texturemem" | |
11815 | || aFlag == "framemem") aParam = Graphic3d_RenderingParams::PerfCounters_EstimMem; | |
11816 | else if (aFlag == "elapsedframe" | |
11817 | || aFlag == "cpuframeaverage" | |
11818 | || aFlag == "cpupickingaverage" | |
11819 | || aFlag == "cpucullingaverage" | |
11820 | || aFlag == "cpudynaverage" | |
11821 | || aFlag == "cpuframemax" | |
11822 | || aFlag == "cpupickingmax" | |
11823 | || aFlag == "cpucullingmax" | |
11824 | || aFlag == "cpudynmax") aParam = Graphic3d_RenderingParams::PerfCounters_FrameTime; | |
11825 | else | |
11826 | { | |
23fe70ec | 11827 | Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'"; |
79b544e6 | 11828 | continue; |
11829 | } | |
11830 | ||
11831 | aRenderParams = Graphic3d_RenderingParams::PerfCounters (aRenderParams | aParam); | |
11832 | } | |
11833 | } | |
11834 | ||
11835 | if (aRenderParams != Graphic3d_RenderingParams::PerfCounters_NONE) | |
11836 | { | |
11837 | aView->ChangeRenderingParams().CollectedStats = | |
11838 | Graphic3d_RenderingParams::PerfCounters (aView->RenderingParams().CollectedStats | aRenderParams); | |
11839 | ||
11840 | if (toRedraw) | |
11841 | { | |
11842 | aView->ChangeRenderingParams().StatsUpdateInterval = -1; | |
11843 | aView->Redraw(); | |
11844 | aView->ChangeRenderingParams().StatsUpdateInterval = aPrevUpdInterval; | |
11845 | } | |
11846 | ||
11847 | TColStd_IndexedDataMapOfStringString aDict; | |
11848 | aView->StatisticInformation (aDict); | |
11849 | ||
11850 | aView->ChangeRenderingParams().CollectedStats = aPrevCounters; | |
11851 | ||
11852 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
11853 | { | |
11854 | Standard_CString anArg(theArgVec[anArgIter]); | |
11855 | TCollection_AsciiString aFlag(anArg); | |
11856 | aFlag.LowerCase(); | |
11857 | if (aFlag == "fps") | |
11858 | { | |
11859 | theDI << searchInfo (aDict, "FPS") << " "; | |
11860 | } | |
11861 | else if (aFlag == "cpu") | |
11862 | { | |
11863 | theDI << searchInfo (aDict, "CPU FPS") << " "; | |
11864 | } | |
11865 | else if (aFlag == "alllayers") | |
11866 | { | |
11867 | theDI << searchInfo (aDict, "Layers") << " "; | |
11868 | } | |
11869 | else if (aFlag == "layers") | |
11870 | { | |
11871 | theDI << searchInfo (aDict, "Rendered layers") << " "; | |
11872 | } | |
a2803f37 | 11873 | else if (aFlag == "allstructs" |
11874 | || aFlag == "allstructures") | |
79b544e6 | 11875 | { |
11876 | theDI << searchInfo (aDict, "Structs") << " "; | |
11877 | } | |
a2803f37 | 11878 | else if (aFlag == "structs" |
11879 | || aFlag == "structures") | |
79b544e6 | 11880 | { |
a2803f37 | 11881 | TCollection_AsciiString aRend = searchInfo (aDict, "Rendered structs"); |
11882 | if (aRend.IsEmpty()) // all structures rendered | |
11883 | { | |
11884 | aRend = searchInfo (aDict, "Structs"); | |
11885 | } | |
11886 | theDI << aRend << " "; | |
79b544e6 | 11887 | } |
11888 | else if (aFlag == "groups") | |
11889 | { | |
11890 | theDI << searchInfo (aDict, "Rendered groups") << " "; | |
11891 | } | |
11892 | else if (aFlag == "allarrays") | |
11893 | { | |
11894 | theDI << searchInfo (aDict, "Rendered arrays") << " "; | |
11895 | } | |
11896 | else if (aFlag == "fillarrays") | |
11897 | { | |
11898 | theDI << searchInfo (aDict, "Rendered [fill] arrays") << " "; | |
11899 | } | |
11900 | else if (aFlag == "linearrays") | |
11901 | { | |
11902 | theDI << searchInfo (aDict, "Rendered [line] arrays") << " "; | |
11903 | } | |
11904 | else if (aFlag == "pointarrays") | |
11905 | { | |
11906 | theDI << searchInfo (aDict, "Rendered [point] arrays") << " "; | |
11907 | } | |
11908 | else if (aFlag == "textarrays") | |
11909 | { | |
11910 | theDI << searchInfo (aDict, "Rendered [text] arrays") << " "; | |
11911 | } | |
11912 | else if (aFlag == "triangles") | |
11913 | { | |
11914 | theDI << searchInfo (aDict, "Rendered triangles") << " "; | |
11915 | } | |
11916 | else if (aFlag == "points") | |
11917 | { | |
11918 | theDI << searchInfo (aDict, "Rendered points") << " "; | |
11919 | } | |
11920 | else if (aFlag == "geommem") | |
11921 | { | |
11922 | theDI << searchInfo (aDict, "GPU Memory [geometry]") << " "; | |
11923 | } | |
11924 | else if (aFlag == "texturemem") | |
11925 | { | |
11926 | theDI << searchInfo (aDict, "GPU Memory [textures]") << " "; | |
11927 | } | |
11928 | else if (aFlag == "framemem") | |
11929 | { | |
11930 | theDI << searchInfo (aDict, "GPU Memory [frames]") << " "; | |
11931 | } | |
11932 | else if (aFlag == "elapsedframe") | |
11933 | { | |
11934 | theDI << searchInfo (aDict, "Elapsed Frame (average)") << " "; | |
11935 | } | |
11936 | else if (aFlag == "cpuframe_average") | |
11937 | { | |
11938 | theDI << searchInfo (aDict, "CPU Frame (average)") << " "; | |
11939 | } | |
11940 | else if (aFlag == "cpupicking_average") | |
11941 | { | |
11942 | theDI << searchInfo (aDict, "CPU Picking (average)") << " "; | |
11943 | } | |
11944 | else if (aFlag == "cpuculling_average") | |
11945 | { | |
11946 | theDI << searchInfo (aDict, "CPU Culling (average)") << " "; | |
11947 | } | |
11948 | else if (aFlag == "cpudyn_average") | |
11949 | { | |
11950 | theDI << searchInfo (aDict, "CPU Dynamics (average)") << " "; | |
11951 | } | |
11952 | else if (aFlag == "cpuframe_max") | |
11953 | { | |
11954 | theDI << searchInfo (aDict, "CPU Frame (max)") << " "; | |
11955 | } | |
11956 | else if (aFlag == "cpupicking_max") | |
11957 | { | |
11958 | theDI << searchInfo (aDict, "CPU Picking (max)") << " "; | |
11959 | } | |
11960 | else if (aFlag == "cpuculling_max") | |
11961 | { | |
11962 | theDI << searchInfo (aDict, "CPU Culling (max)") << " "; | |
11963 | } | |
11964 | else if (aFlag == "cpudyn_max") | |
11965 | { | |
11966 | theDI << searchInfo (aDict, "CPU Dynamics (max)") << " "; | |
11967 | } | |
11968 | } | |
11969 | } | |
11970 | else | |
11971 | { | |
11972 | if (toRedraw) | |
11973 | { | |
11974 | aView->ChangeRenderingParams().StatsUpdateInterval = -1; | |
11975 | aView->Redraw(); | |
11976 | aView->ChangeRenderingParams().StatsUpdateInterval = aPrevUpdInterval; | |
11977 | } | |
11978 | theDI << "Statistic info:\n" << aView->StatisticInformation(); | |
11979 | } | |
11980 | return 0; | |
11981 | } | |
11982 | ||
0717ddc1 | 11983 | //======================================================================= |
11984 | //function : VXRotate | |
11985 | //purpose : | |
11986 | //======================================================================= | |
11987 | static Standard_Integer VXRotate (Draw_Interpretor& di, | |
11988 | Standard_Integer argc, | |
11989 | const char ** argv) | |
11990 | { | |
11991 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
11992 | if (aContext.IsNull()) | |
11993 | { | |
586db386 | 11994 | di << argv[0] << "ERROR : use 'vinit' command before \n"; |
0717ddc1 | 11995 | return 1; |
11996 | } | |
8693dfd0 | 11997 | |
0717ddc1 | 11998 | if (argc != 3) |
11999 | { | |
586db386 | 12000 | di << "ERROR : Usage : " << argv[0] << " name angle\n"; |
0717ddc1 | 12001 | return 1; |
12002 | } | |
12003 | ||
12004 | TCollection_AsciiString aName (argv[1]); | |
12005 | Standard_Real anAngle = Draw::Atof (argv[2]); | |
12006 | ||
12007 | // find object | |
12008 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); | |
12009 | Handle(AIS_InteractiveObject) anIObj; | |
8f521168 | 12010 | if (!aMap.Find2 (aName, anIObj)) |
0717ddc1 | 12011 | { |
586db386 | 12012 | di << "Use 'vdisplay' before\n"; |
0717ddc1 | 12013 | return 1; |
12014 | } | |
0717ddc1 | 12015 | |
8f521168 | 12016 | gp_Trsf aTransform; |
12017 | aTransform.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Vec (1.0, 0.0, 0.0)), anAngle); | |
12018 | aTransform.SetTranslationPart (anIObj->LocalTransformation().TranslationPart()); | |
0717ddc1 | 12019 | |
8f521168 | 12020 | aContext->SetLocation (anIObj, aTransform); |
12021 | aContext->UpdateCurrentViewer(); | |
0717ddc1 | 12022 | return 0; |
12023 | } | |
12024 | ||
ff6122e0 | 12025 | namespace |
12026 | { | |
12027 | //! Structure for setting AIS_Manipulator::SetPart() property. | |
12028 | struct ManipAxisModeOnOff | |
12029 | { | |
12030 | Standard_Integer Axis; | |
12031 | AIS_ManipulatorMode Mode; | |
12032 | Standard_Boolean ToEnable; | |
12033 | ||
12034 | ManipAxisModeOnOff() : Axis (-1), Mode (AIS_MM_None), ToEnable (false) {} | |
12035 | }; | |
12036 | ||
12037 | enum ManipAjustPosition | |
12038 | { | |
12039 | ManipAjustPosition_Off, | |
12040 | ManipAjustPosition_Center, | |
12041 | ManipAjustPosition_Location, | |
12042 | ManipAjustPosition_ShapeLocation, | |
12043 | }; | |
12044 | } | |
12045 | ||
625e1958 | 12046 | //=============================================================================================== |
12047 | //function : VManipulator | |
12048 | //purpose : | |
12049 | //=============================================================================================== | |
12050 | static int VManipulator (Draw_Interpretor& theDi, | |
12051 | Standard_Integer theArgsNb, | |
12052 | const char** theArgVec) | |
12053 | { | |
bbf3fcde | 12054 | Handle(V3d_View) aCurrentView = ViewerTest::CurrentView(); |
625e1958 | 12055 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); |
bbf3fcde | 12056 | if (aCurrentView.IsNull() |
625e1958 | 12057 | || aViewer.IsNull()) |
12058 | { | |
23fe70ec | 12059 | Message::SendFail ("Error: no active viewer"); |
625e1958 | 12060 | return 1; |
12061 | } | |
12062 | ||
12063 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView()); | |
12064 | Standard_Integer anArgIter = 1; | |
ff6122e0 | 12065 | Handle(AIS_Manipulator) aManipulator; |
12066 | ViewerTest_DoubleMapOfInteractiveAndName& aMapAIS = GetMapOfAIS(); | |
12067 | TCollection_AsciiString aName; | |
12068 | // parameters | |
12069 | Standard_Integer toAutoActivate = -1, toFollowTranslation = -1, toFollowRotation = -1, toFollowDragging = -1, isZoomable = -1; | |
12070 | Standard_Real aGap = -1.0, aSize = -1.0; | |
12071 | NCollection_Sequence<ManipAxisModeOnOff> aParts; | |
12072 | gp_XYZ aLocation (RealLast(), RealLast(), RealLast()), aVDir, anXDir; | |
12073 | // | |
12074 | bool toDetach = false; | |
12075 | AIS_Manipulator::OptionsForAttach anAttachOptions; | |
12076 | Handle(AIS_InteractiveObject) anAttachObject; | |
12077 | Handle(V3d_View) aViewAffinity; | |
12078 | ManipAjustPosition anAttachPos = ManipAjustPosition_Off; | |
12079 | // | |
12080 | Graphic3d_Vec2i aMousePosFrom(IntegerLast(), IntegerLast()); | |
12081 | Graphic3d_Vec2i aMousePosTo (IntegerLast(), IntegerLast()); | |
12082 | Standard_Integer toStopMouseTransform = -1; | |
12083 | // explicit transformation | |
12084 | gp_Trsf aTrsf; | |
12085 | gp_XYZ aTmpXYZ; | |
12086 | Standard_Real aTmpReal = 0.0; | |
12087 | gp_XYZ aRotPnt, aRotAxis; | |
625e1958 | 12088 | for (; anArgIter < theArgsNb; ++anArgIter) |
12089 | { | |
ff6122e0 | 12090 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
12091 | anArg.LowerCase(); | |
12092 | if (anUpdateTool.parseRedrawMode (anArg)) | |
12093 | { | |
12094 | continue; | |
12095 | } | |
12096 | else if (anArg == "-help") | |
12097 | { | |
12098 | theDi.PrintHelp (theArgVec[0]); | |
12099 | return 0; | |
12100 | } | |
12101 | // | |
12102 | else if (anArg == "-autoactivate" | |
12103 | || anArg == "-noautoactivate") | |
12104 | { | |
12105 | toAutoActivate = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; | |
12106 | } | |
12107 | else if (anArg == "-followtranslation" | |
12108 | || anArg == "-nofollowtranslation") | |
12109 | { | |
12110 | toFollowTranslation = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; | |
12111 | } | |
12112 | else if (anArg == "-followrotation" | |
12113 | || anArg == "-nofollowrotation") | |
12114 | { | |
12115 | toFollowRotation = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; | |
12116 | } | |
12117 | else if (anArg == "-followdragging" | |
12118 | || anArg == "-nofollowdragging") | |
12119 | { | |
12120 | toFollowDragging = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; | |
12121 | } | |
12122 | else if (anArg == "-gap" | |
12123 | && anArgIter + 1 < theArgsNb | |
12124 | && Draw::ParseReal (theArgVec[anArgIter + 1], aGap) | |
12125 | && aGap >= 0.0) | |
12126 | { | |
12127 | ++anArgIter; | |
12128 | } | |
12129 | else if (anArg == "-size" | |
12130 | && anArgIter + 1 < theArgsNb | |
12131 | && Draw::ParseReal (theArgVec[anArgIter + 1], aSize) | |
12132 | && aSize > 0.0) | |
12133 | { | |
12134 | ++anArgIter; | |
12135 | } | |
12136 | else if ((anArg == "-part" && anArgIter + 3 < theArgsNb) | |
12137 | || (anArg == "-parts" && anArgIter + 2 < theArgsNb)) | |
12138 | { | |
12139 | ManipAxisModeOnOff aPart; | |
12140 | Standard_Integer aMode = 0; | |
12141 | if (anArg == "-part") | |
12142 | { | |
12143 | if (!Draw::ParseInteger (theArgVec[++anArgIter], aPart.Axis) | |
12144 | || aPart.Axis < 0 || aPart.Axis > 3) | |
12145 | { | |
12146 | Message::SendFail() << "Syntax error: -part axis '" << theArgVec[anArgIter] << "' is out of range [1, 3]"; | |
12147 | return 1; | |
12148 | } | |
12149 | } | |
12150 | if (!Draw::ParseInteger (theArgVec[++anArgIter], aMode) | |
12151 | || aMode < 1 || aMode > 4) | |
12152 | { | |
12153 | Message::SendFail() << "Syntax error: -part mode '" << theArgVec[anArgIter] << "' is out of range [1, 4]"; | |
12154 | return 1; | |
12155 | } | |
12156 | if (!Draw::ParseOnOff (theArgVec[++anArgIter], aPart.ToEnable)) | |
12157 | { | |
12158 | Message::SendFail() << "Syntax error: -part value on/off '" << theArgVec[anArgIter] << "' is incorrect"; | |
12159 | return 1; | |
12160 | } | |
12161 | aPart.Mode = static_cast<AIS_ManipulatorMode> (aMode); | |
12162 | aParts.Append (aPart); | |
12163 | } | |
12164 | else if (anArg == "-pos" | |
12165 | && anArgIter + 3 < theArgsNb | |
12166 | && parseXYZ (theArgVec + anArgIter + 1, aLocation)) | |
12167 | { | |
12168 | anArgIter += 3; | |
12169 | if (anArgIter + 3 < theArgsNb | |
12170 | && parseXYZ (theArgVec + anArgIter + 1, aVDir) | |
12171 | && aVDir.Modulus() > Precision::Confusion()) | |
12172 | { | |
12173 | anArgIter += 3; | |
12174 | } | |
12175 | if (anArgIter + 3 < theArgsNb | |
12176 | && parseXYZ (theArgVec + anArgIter + 1, anXDir) | |
12177 | && anXDir.Modulus() > Precision::Confusion()) | |
12178 | { | |
12179 | anArgIter += 3; | |
12180 | } | |
12181 | } | |
12182 | else if (anArg == "-zoomable" | |
12183 | || anArg == "-notzoomable") | |
12184 | { | |
12185 | isZoomable = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; | |
12186 | } | |
12187 | // | |
12188 | else if (anArg == "-adjustposition" | |
12189 | || anArg == "-noadjustposition") | |
12190 | { | |
12191 | anAttachPos = ManipAjustPosition_Center; | |
12192 | if (anArgIter + 1 < theArgsNb) | |
12193 | { | |
12194 | TCollection_AsciiString aPosName (theArgVec[++anArgIter]); | |
12195 | aPosName.LowerCase(); | |
12196 | if (aPosName == "0") | |
12197 | { | |
12198 | anAttachPos = ManipAjustPosition_Off; | |
12199 | } | |
12200 | else if (aPosName == "1" | |
12201 | || aPosName == "center") | |
12202 | { | |
12203 | anAttachPos = ManipAjustPosition_Center; | |
12204 | } | |
12205 | else if (aPosName == "transformation" | |
12206 | || aPosName == "trsf" | |
12207 | || aPosName == "location" | |
12208 | || aPosName == "loc") | |
12209 | { | |
12210 | anAttachPos = ManipAjustPosition_Location; | |
12211 | } | |
12212 | else if (aPosName == "shapelocation" | |
12213 | || aPosName == "shapeloc") | |
12214 | { | |
12215 | anAttachPos = ManipAjustPosition_ShapeLocation; | |
12216 | } | |
12217 | else | |
12218 | { | |
12219 | --anArgIter; | |
12220 | } | |
12221 | } | |
12222 | anAttachOptions.SetAdjustPosition (anAttachPos == ManipAjustPosition_Center); | |
12223 | } | |
12224 | else if (anArg == "-adjustsize" | |
12225 | || anArg == "-noadjustsize") | |
12226 | { | |
12227 | anAttachOptions.SetAdjustSize (Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0); | |
12228 | } | |
12229 | else if (anArg == "-enablemodes" | |
12230 | || anArg == "-enablemodes") | |
12231 | { | |
12232 | anAttachOptions.SetEnableModes (Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0); | |
12233 | } | |
12234 | // | |
12235 | else if (anArg == "-starttransform" | |
12236 | && anArgIter + 2 < theArgsNb | |
12237 | && Draw::ParseInteger (theArgVec[anArgIter + 1], aMousePosFrom.x()) | |
12238 | && Draw::ParseInteger (theArgVec[anArgIter + 2], aMousePosFrom.y())) | |
12239 | { | |
12240 | anArgIter += 2; | |
12241 | } | |
12242 | else if (anArg == "-transform" | |
12243 | && anArgIter + 2 < theArgsNb | |
12244 | && Draw::ParseInteger (theArgVec[anArgIter + 1], aMousePosTo.x()) | |
12245 | && Draw::ParseInteger (theArgVec[anArgIter + 2], aMousePosTo.y())) | |
12246 | { | |
12247 | anArgIter += 2; | |
12248 | } | |
12249 | else if (anArg == "-stoptransform") | |
12250 | { | |
12251 | toStopMouseTransform = 1; | |
12252 | if (anArgIter + 1 < theArgsNb | |
12253 | && TCollection_AsciiString::IsSameString (theArgVec[anArgIter + 1], "abort", false)) | |
12254 | { | |
12255 | ++anArgIter; | |
12256 | toStopMouseTransform = 0; | |
12257 | } | |
12258 | } | |
12259 | // | |
12260 | else if (anArg == "-move" | |
12261 | && anArgIter + 3 < theArgsNb | |
12262 | && parseXYZ (theArgVec + anArgIter + 1, aTmpXYZ)) | |
12263 | { | |
12264 | anArgIter += 3; | |
12265 | aTrsf.SetTranslationPart (aTmpXYZ); | |
12266 | } | |
12267 | else if (anArg == "-scale" | |
12268 | && anArgIter + 1 < theArgsNb | |
12269 | && Draw::ParseReal (theArgVec[anArgIter + 1], aTmpReal)) | |
12270 | { | |
12271 | ++anArgIter; | |
12272 | aTrsf.SetScale (gp_Pnt(), aTmpReal); | |
12273 | } | |
12274 | else if (anArg == "-rotate" | |
12275 | && anArgIter + 7 < theArgsNb | |
12276 | && parseXYZ (theArgVec + anArgIter + 1, aRotPnt) | |
12277 | && parseXYZ (theArgVec + anArgIter + 4, aRotAxis) | |
12278 | && Draw::ParseReal (theArgVec[anArgIter + 7], aTmpReal)) | |
12279 | { | |
12280 | anArgIter += 7; | |
12281 | aTrsf.SetRotation (gp_Ax1 (gp_Pnt (aRotPnt), gp_Dir (aRotAxis)), aTmpReal); | |
12282 | } | |
12283 | // | |
12284 | else if (anArg == "-detach") | |
12285 | { | |
12286 | toDetach = true; | |
12287 | } | |
12288 | else if (anArg == "-attach" | |
12289 | && anArgIter + 1 < theArgsNb) | |
12290 | { | |
12291 | TCollection_AsciiString anObjName (theArgVec[++anArgIter]); | |
12292 | if (!aMapAIS.Find2 (anObjName, anAttachObject)) | |
12293 | { | |
12294 | Message::SendFail() << "Syntax error: AIS object '" << anObjName << "' does not exist"; | |
12295 | return 1; | |
12296 | } | |
625e1958 | 12297 | |
ff6122e0 | 12298 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (aMapAIS); anIter.More(); anIter.Next()) |
12299 | { | |
12300 | Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (anIter.Key1()); | |
12301 | if (!aManip.IsNull() | |
12302 | && aManip->IsAttached() | |
12303 | && aManip->Object() == anAttachObject) | |
12304 | { | |
12305 | Message::SendFail() << "Syntax error: AIS object '" << anObjName << "' already has manipulator"; | |
12306 | return 1; | |
12307 | } | |
12308 | } | |
12309 | } | |
12310 | else if (anArg == "-view" | |
12311 | && anArgIter + 1 < theArgsNb | |
12312 | && aViewAffinity.IsNull()) | |
12313 | { | |
12314 | TCollection_AsciiString aViewString (theArgVec[++anArgIter]); | |
12315 | if (aViewString == "active") | |
12316 | { | |
12317 | aViewAffinity = ViewerTest::CurrentView(); | |
12318 | } | |
12319 | else // Check view name | |
12320 | { | |
12321 | ViewerTest_Names aViewNames (aViewString); | |
12322 | if (!ViewerTest_myViews.IsBound1 (aViewNames.GetViewName())) | |
12323 | { | |
12324 | Message::SendFail() << "Syntax error: wrong view name '" << aViewString << "'"; | |
12325 | return 1; | |
12326 | } | |
12327 | aViewAffinity = ViewerTest_myViews.Find1 (aViewNames.GetViewName()); | |
12328 | if (aViewAffinity.IsNull()) | |
12329 | { | |
12330 | Message::SendFail() << "Syntax error: cannot find view with name '" << aViewString << "'"; | |
12331 | return 1; | |
12332 | } | |
12333 | } | |
12334 | } | |
12335 | else if (aName.IsEmpty()) | |
12336 | { | |
12337 | aName = theArgVec[anArgIter]; | |
12338 | if (!aMapAIS.IsBound2 (aName)) | |
12339 | { | |
12340 | aManipulator = new AIS_Manipulator(); | |
12341 | aManipulator->SetModeActivationOnDetection (true); | |
12342 | aMapAIS.Bind (aManipulator, aName); | |
12343 | } | |
12344 | else | |
12345 | { | |
12346 | aManipulator = Handle(AIS_Manipulator)::DownCast (aMapAIS.Find2 (aName)); | |
12347 | if (aManipulator.IsNull()) | |
12348 | { | |
12349 | Message::SendFail() << "Syntax error: \"" << aName << "\" is not an AIS manipulator"; | |
12350 | return 1; | |
12351 | } | |
12352 | } | |
12353 | } | |
12354 | else | |
12355 | { | |
12356 | theDi << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'"; | |
12357 | } | |
625e1958 | 12358 | } |
12359 | ||
625e1958 | 12360 | if (aName.IsEmpty()) |
12361 | { | |
23fe70ec | 12362 | Message::SendFail ("Syntax error: please specify AIS manipulator's name as the first argument"); |
625e1958 | 12363 | return 1; |
12364 | } | |
ff6122e0 | 12365 | if (!toDetach |
12366 | && aManipulator.IsNull()) | |
625e1958 | 12367 | { |
8b037fe4 | 12368 | aManipulator = new AIS_Manipulator(); |
49582f9d | 12369 | aManipulator->SetModeActivationOnDetection (true); |
625e1958 | 12370 | aMapAIS.Bind (aManipulator, aName); |
12371 | } | |
625e1958 | 12372 | |
12373 | // ----------------------------------------- | |
12374 | // change properties of manipulator instance | |
12375 | // ----------------------------------------- | |
12376 | ||
ff6122e0 | 12377 | if (toAutoActivate != -1) |
625e1958 | 12378 | { |
ff6122e0 | 12379 | aManipulator->SetModeActivationOnDetection (toAutoActivate == 1); |
625e1958 | 12380 | } |
ff6122e0 | 12381 | if (toFollowTranslation != -1) |
625e1958 | 12382 | { |
ff6122e0 | 12383 | aManipulator->ChangeTransformBehavior().SetFollowTranslation (toFollowTranslation == 1); |
625e1958 | 12384 | } |
ff6122e0 | 12385 | if (toFollowRotation != -1) |
625e1958 | 12386 | { |
ff6122e0 | 12387 | aManipulator->ChangeTransformBehavior().SetFollowRotation (toFollowRotation == 1); |
625e1958 | 12388 | } |
ff6122e0 | 12389 | if (toFollowDragging != -1) |
f522ce50 | 12390 | { |
ff6122e0 | 12391 | aManipulator->ChangeTransformBehavior().SetFollowDragging (toFollowDragging == 1); |
f522ce50 | 12392 | } |
ff6122e0 | 12393 | if (aGap >= 0.0f) |
625e1958 | 12394 | { |
ff6122e0 | 12395 | aManipulator->SetGap ((float )aGap); |
625e1958 | 12396 | } |
ff6122e0 | 12397 | |
12398 | for (NCollection_Sequence<ManipAxisModeOnOff>::Iterator aPartIter (aParts); aPartIter.More(); aPartIter.Next()) | |
625e1958 | 12399 | { |
ff6122e0 | 12400 | const ManipAxisModeOnOff& aPart = aPartIter.Value(); |
12401 | if (aPart.Axis == -1) | |
625e1958 | 12402 | { |
ff6122e0 | 12403 | aManipulator->SetPart (aPart.Mode, aPart.ToEnable); |
625e1958 | 12404 | } |
ff6122e0 | 12405 | else |
84b904bc | 12406 | { |
ff6122e0 | 12407 | aManipulator->SetPart (aPart.Axis, aPart.Mode, aPart.ToEnable); |
84b904bc | 12408 | } |
84b904bc | 12409 | } |
625e1958 | 12410 | |
ff6122e0 | 12411 | if (aSize > 0.0) |
625e1958 | 12412 | { |
ff6122e0 | 12413 | aManipulator->SetSize ((float )aSize); |
625e1958 | 12414 | } |
ff6122e0 | 12415 | if (isZoomable != -1) |
625e1958 | 12416 | { |
ff6122e0 | 12417 | aManipulator->SetZoomPersistence (isZoomable == 0); |
625e1958 | 12418 | |
12419 | if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator)) | |
12420 | { | |
12421 | ViewerTest::GetAISContext()->Remove (aManipulator, Standard_False); | |
12422 | ViewerTest::GetAISContext()->Display (aManipulator, Standard_False); | |
12423 | } | |
12424 | } | |
12425 | ||
ff6122e0 | 12426 | // ---------------------------------- |
12427 | // detach existing manipulator object | |
12428 | // ---------------------------------- | |
12429 | ||
12430 | if (toDetach) | |
12431 | { | |
12432 | aManipulator->Detach(); | |
12433 | aMapAIS.UnBind2 (aName); | |
12434 | ViewerTest::GetAISContext()->Remove (aManipulator, false); | |
12435 | } | |
12436 | ||
625e1958 | 12437 | // --------------------------------------------------- |
12438 | // attach, detach or access manipulator from an object | |
12439 | // --------------------------------------------------- | |
12440 | ||
ff6122e0 | 12441 | if (!anAttachObject.IsNull()) |
625e1958 | 12442 | { |
ff6122e0 | 12443 | aManipulator->Attach (anAttachObject, anAttachOptions); |
12444 | } | |
12445 | if (!aViewAffinity.IsNull()) | |
12446 | { | |
12447 | for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews); | |
8b037fe4 | 12448 | anIter.More(); anIter.Next()) |
625e1958 | 12449 | { |
ff6122e0 | 12450 | ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Value(), false); |
625e1958 | 12451 | } |
ff6122e0 | 12452 | ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, aViewAffinity, true); |
12453 | } | |
625e1958 | 12454 | |
ff6122e0 | 12455 | if (anAttachPos != ManipAjustPosition_Off |
12456 | && aManipulator->IsAttached() | |
12457 | && (anAttachObject.IsNull() || anAttachPos != ManipAjustPosition_Center)) | |
12458 | { | |
12459 | gp_Ax2 aPosition = gp::XOY(); | |
12460 | const gp_Trsf aBaseTrsf = aManipulator->Object()->LocalTransformation(); | |
12461 | switch (anAttachPos) | |
bbf3fcde | 12462 | { |
ff6122e0 | 12463 | case ManipAjustPosition_Off: |
bbf3fcde | 12464 | { |
ff6122e0 | 12465 | break; |
bbf3fcde | 12466 | } |
ff6122e0 | 12467 | case ManipAjustPosition_Location: |
bbf3fcde | 12468 | { |
ff6122e0 | 12469 | aPosition = gp::XOY().Transformed (aBaseTrsf); |
12470 | break; | |
bbf3fcde | 12471 | } |
ff6122e0 | 12472 | case ManipAjustPosition_ShapeLocation: |
bbf3fcde | 12473 | { |
ff6122e0 | 12474 | if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aManipulator->Object())) |
bbf3fcde | 12475 | { |
ff6122e0 | 12476 | aPosition = gp::XOY().Transformed (aBaseTrsf * aShapePrs->Shape().Location()); |
bbf3fcde | 12477 | } |
ff6122e0 | 12478 | else |
bbf3fcde | 12479 | { |
ff6122e0 | 12480 | Message::SendFail() << "Syntax error: manipulator is not attached to shape"; |
bbf3fcde | 12481 | return 1; |
12482 | } | |
ff6122e0 | 12483 | break; |
bbf3fcde | 12484 | } |
ff6122e0 | 12485 | case ManipAjustPosition_Center: |
bbf3fcde | 12486 | { |
ff6122e0 | 12487 | Bnd_Box aBox; |
12488 | for (AIS_ManipulatorObjectSequence::Iterator anObjIter (*aManipulator->Objects()); anObjIter.More(); anObjIter.Next()) | |
12489 | { | |
12490 | Bnd_Box anObjBox; | |
12491 | anObjIter.Value()->BoundingBox (anObjBox); | |
12492 | aBox.Add (anObjBox); | |
12493 | } | |
12494 | aBox = aBox.FinitePart(); | |
12495 | if (!aBox.IsVoid()) | |
12496 | { | |
12497 | const gp_Pnt aCenter = (aBox.CornerMin().XYZ() + aBox.CornerMax().XYZ()) * 0.5; | |
12498 | aPosition.SetLocation (aCenter); | |
12499 | } | |
12500 | break; | |
bbf3fcde | 12501 | } |
bbf3fcde | 12502 | } |
ff6122e0 | 12503 | aManipulator->SetPosition (aPosition); |
12504 | } | |
12505 | if (!Precision::IsInfinite (aLocation.X())) | |
12506 | { | |
12507 | if (aVDir.Modulus() <= Precision::Confusion()) | |
12508 | { | |
12509 | aVDir = aManipulator->Position().Direction().XYZ(); | |
12510 | } | |
12511 | if (anXDir.Modulus() <= Precision::Confusion()) | |
12512 | { | |
12513 | anXDir = aManipulator->Position().XDirection().XYZ(); | |
12514 | } | |
12515 | aManipulator->SetPosition (gp_Ax2 (gp_Pnt (aLocation), gp_Dir (aVDir), gp_Dir (anXDir))); | |
625e1958 | 12516 | } |
12517 | ||
12518 | // -------------------------------------- | |
12519 | // apply transformation using manipulator | |
12520 | // -------------------------------------- | |
12521 | ||
ff6122e0 | 12522 | if (aMousePosFrom.x() != IntegerLast()) |
625e1958 | 12523 | { |
ff6122e0 | 12524 | aManipulator->StartTransform (aMousePosFrom.x(), aMousePosFrom.y(), ViewerTest::CurrentView()); |
625e1958 | 12525 | } |
ff6122e0 | 12526 | if (aMousePosTo.x() != IntegerLast()) |
625e1958 | 12527 | { |
ff6122e0 | 12528 | aManipulator->Transform (aMousePosTo.x(), aMousePosTo.y(), ViewerTest::CurrentView()); |
625e1958 | 12529 | } |
ff6122e0 | 12530 | if (toStopMouseTransform != -1) |
625e1958 | 12531 | { |
ff6122e0 | 12532 | aManipulator->StopTransform (toStopMouseTransform == 1); |
625e1958 | 12533 | } |
12534 | ||
ff6122e0 | 12535 | if (aTrsf.Form() != gp_Identity) |
625e1958 | 12536 | { |
ff6122e0 | 12537 | aManipulator->Transform (aTrsf); |
625e1958 | 12538 | } |
12539 | ||
ff6122e0 | 12540 | if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator)) |
625e1958 | 12541 | { |
ff6122e0 | 12542 | ViewerTest::GetAISContext()->Redisplay (aManipulator, true); |
625e1958 | 12543 | } |
625e1958 | 12544 | return 0; |
12545 | } | |
12546 | ||
8e5fb5ea | 12547 | //=============================================================================================== |
12548 | //function : VSelectionProperties | |
12549 | //purpose : | |
12550 | //=============================================================================================== | |
12551 | static int VSelectionProperties (Draw_Interpretor& theDi, | |
12552 | Standard_Integer theArgsNb, | |
12553 | const char** theArgVec) | |
12554 | { | |
12555 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); | |
12556 | if (aCtx.IsNull()) | |
12557 | { | |
23fe70ec | 12558 | Message::SendFail ("Error: no active viewer"); |
8e5fb5ea | 12559 | return 1; |
12560 | } | |
12561 | ||
be3d8cbc | 12562 | if (TCollection_AsciiString (theArgVec[0]) == "vhighlightselected") |
12563 | { | |
12564 | // handle obsolete alias | |
12565 | bool toEnable = true; | |
12566 | if (theArgsNb < 2) | |
12567 | { | |
12568 | theDi << (aCtx->ToHilightSelected() ? "on" : "off"); | |
12569 | return 0; | |
12570 | } | |
12571 | else if (theArgsNb != 2 | |
dae2a922 | 12572 | || !Draw::ParseOnOff (theArgVec[1], toEnable)) |
be3d8cbc | 12573 | { |
23fe70ec | 12574 | Message::SendFail ("Syntax error: wrong number of parameters"); |
be3d8cbc | 12575 | return 1; |
12576 | } | |
12577 | if (toEnable != aCtx->ToHilightSelected()) | |
12578 | { | |
12579 | aCtx->ClearDetected(); | |
12580 | aCtx->SetToHilightSelected (toEnable); | |
12581 | } | |
12582 | return 0; | |
12583 | } | |
12584 | ||
f838dac4 | 12585 | Standard_Boolean toPrint = theArgsNb == 1; |
12586 | Standard_Boolean toRedraw = Standard_False; | |
12587 | Standard_Integer anArgIter = 1; | |
12588 | Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None; | |
12589 | if (anArgIter < theArgsNb) | |
12590 | { | |
12591 | TCollection_AsciiString anArgFirst (theArgVec[anArgIter]); | |
12592 | anArgFirst.LowerCase(); | |
12593 | ++anArgIter; | |
12594 | if (anArgFirst == "dynhighlight" | |
12595 | || anArgFirst == "dynhilight" | |
12596 | || anArgFirst == "dynamichighlight" | |
12597 | || anArgFirst == "dynamichilight") | |
12598 | { | |
12599 | aType = Prs3d_TypeOfHighlight_Dynamic; | |
12600 | } | |
12601 | else if (anArgFirst == "localdynhighlight" | |
12602 | || anArgFirst == "localdynhilight" | |
12603 | || anArgFirst == "localdynamichighlight" | |
12604 | || anArgFirst == "localdynamichilight") | |
12605 | { | |
12606 | aType = Prs3d_TypeOfHighlight_LocalDynamic; | |
12607 | } | |
12608 | else if (anArgFirst == "selhighlight" | |
12609 | || anArgFirst == "selhilight" | |
12610 | || anArgFirst == "selectedhighlight" | |
12611 | || anArgFirst == "selectedhilight") | |
12612 | { | |
12613 | aType = Prs3d_TypeOfHighlight_Selected; | |
12614 | } | |
12615 | else if (anArgFirst == "localselhighlight" | |
12616 | || anArgFirst == "localselhilight" | |
12617 | || anArgFirst == "localselectedhighlight" | |
12618 | || anArgFirst == "localselectedhilight") | |
12619 | { | |
12620 | aType = Prs3d_TypeOfHighlight_LocalSelected; | |
12621 | } | |
12622 | else | |
12623 | { | |
12624 | --anArgIter; | |
12625 | } | |
12626 | } | |
12627 | for (; anArgIter < theArgsNb; ++anArgIter) | |
12628 | { | |
12629 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
12630 | anArg.LowerCase(); | |
12631 | if (anArg == "-help") | |
12632 | { | |
12633 | theDi.PrintHelp (theArgVec[0]); | |
12634 | return 0; | |
12635 | } | |
12636 | else if (anArg == "-print") | |
12637 | { | |
12638 | toPrint = Standard_True; | |
12639 | } | |
12640 | else if (anArg == "-autoactivate") | |
12641 | { | |
12642 | Standard_Boolean toEnable = Standard_True; | |
12643 | if (anArgIter + 1 < theArgsNb | |
dae2a922 | 12644 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
f838dac4 | 12645 | { |
12646 | ++anArgIter; | |
12647 | } | |
12648 | aCtx->SetAutoActivateSelection (toEnable); | |
12649 | } | |
be3d8cbc | 12650 | else if (anArg == "-automatichighlight" |
12651 | || anArg == "-automatichilight" | |
12652 | || anArg == "-autohighlight" | |
12653 | || anArg == "-autohilight") | |
12654 | { | |
12655 | Standard_Boolean toEnable = Standard_True; | |
12656 | if (anArgIter + 1 < theArgsNb | |
dae2a922 | 12657 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
be3d8cbc | 12658 | { |
12659 | ++anArgIter; | |
12660 | } | |
12661 | aCtx->ClearSelected (false); | |
12662 | aCtx->ClearDetected(); | |
12663 | aCtx->SetAutomaticHilight (toEnable); | |
12664 | toRedraw = true; | |
12665 | } | |
12666 | else if (anArg == "-highlightselected" | |
12667 | || anArg == "-hilightselected") | |
12668 | { | |
12669 | Standard_Boolean toEnable = Standard_True; | |
12670 | if (anArgIter + 1 < theArgsNb | |
dae2a922 | 12671 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) |
be3d8cbc | 12672 | { |
12673 | ++anArgIter; | |
12674 | } | |
12675 | aCtx->ClearDetected(); | |
12676 | aCtx->SetToHilightSelected (toEnable); | |
12677 | toRedraw = true; | |
12678 | } | |
14c4193d | 12679 | else if (anArg == "-pickstrategy" |
12680 | || anArg == "-pickingstrategy") | |
12681 | { | |
12682 | if (++anArgIter >= theArgsNb) | |
12683 | { | |
23fe70ec | 12684 | Message::SendFail ("Syntax error: type of highlighting is undefined"); |
14c4193d | 12685 | return 1; |
12686 | } | |
12687 | ||
12688 | SelectMgr_PickingStrategy aStrategy = SelectMgr_PickingStrategy_FirstAcceptable; | |
12689 | TCollection_AsciiString aVal (theArgVec[anArgIter]); | |
12690 | aVal.LowerCase(); | |
12691 | if (aVal == "first" | |
12692 | || aVal == "firstaccepted" | |
12693 | || aVal == "firstacceptable") | |
12694 | { | |
12695 | aStrategy = SelectMgr_PickingStrategy_FirstAcceptable; | |
12696 | } | |
12697 | else if (aVal == "topmost" | |
12698 | || aVal == "onlyTopmost") | |
12699 | { | |
12700 | aStrategy = SelectMgr_PickingStrategy_OnlyTopmost; | |
12701 | } | |
12702 | else | |
12703 | { | |
23fe70ec | 12704 | Message::SendFail() << "Syntax error: unknown picking strategy '" << aVal << "'"; |
14c4193d | 12705 | return 1; |
12706 | } | |
12707 | ||
12708 | aCtx->SetPickingStrategy (aStrategy); | |
12709 | } | |
f838dac4 | 12710 | else if (anArg == "-pixtol" |
12711 | && anArgIter + 1 < theArgsNb) | |
12712 | { | |
12713 | aCtx->SetPixelTolerance (Draw::Atoi (theArgVec[++anArgIter])); | |
12714 | } | |
8c36926a | 12715 | else if (anArg == "-preferclosest") |
12716 | { | |
12717 | bool toPreferClosest = true; | |
12718 | if (anArgIter + 1 < theArgsNb | |
12719 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toPreferClosest)) | |
12720 | { | |
12721 | ++anArgIter; | |
12722 | } | |
12723 | aCtx->MainSelector()->SetPickClosest (toPreferClosest); | |
12724 | } | |
12725 | else if ((anArg == "-depthtol" | |
12726 | || anArg == "-depthtolerance") | |
12727 | && anArgIter + 1 < theArgsNb) | |
12728 | { | |
12729 | TCollection_AsciiString aTolType (theArgVec[++anArgIter]); | |
12730 | aTolType.LowerCase(); | |
12731 | if (aTolType == "uniform") | |
12732 | { | |
12733 | if (anArgIter + 1 >= theArgsNb) | |
12734 | { | |
12735 | Message::SendFail() << "Syntax error: wrong number of arguments"; | |
12736 | return 1; | |
12737 | } | |
12738 | aCtx->MainSelector()->SetDepthTolerance (SelectMgr_TypeOfDepthTolerance_Uniform, | |
12739 | Draw::Atof (theArgVec[++anArgIter])); | |
12740 | } | |
12741 | else if (aTolType == "uniformpx") | |
12742 | { | |
12743 | if (anArgIter + 1 >= theArgsNb) | |
12744 | { | |
12745 | Message::SendFail() << "Syntax error: wrong number of arguments"; | |
12746 | return 1; | |
12747 | } | |
12748 | aCtx->MainSelector()->SetDepthTolerance (SelectMgr_TypeOfDepthTolerance_UniformPixels, | |
12749 | Draw::Atof (theArgVec[++anArgIter])); | |
12750 | } | |
12751 | else if (aTolType == "sensfactor") | |
12752 | { | |
12753 | aCtx->MainSelector()->SetDepthTolerance (SelectMgr_TypeOfDepthTolerance_SensitivityFactor, 0.0); | |
12754 | } | |
12755 | else | |
12756 | { | |
12757 | Message::SendFail() << "Syntax error at '" << aTolType << "'"; | |
12758 | return 1; | |
12759 | } | |
12760 | } | |
f838dac4 | 12761 | else if ((anArg == "-mode" |
12762 | || anArg == "-dispmode") | |
12763 | && anArgIter + 1 < theArgsNb) | |
12764 | { | |
12765 | if (aType == Prs3d_TypeOfHighlight_None) | |
12766 | { | |
23fe70ec | 12767 | Message::SendFail ("Syntax error: type of highlighting is undefined"); |
f838dac4 | 12768 | return 1; |
12769 | } | |
8e5fb5ea | 12770 | |
f838dac4 | 12771 | const Standard_Integer aDispMode = Draw::Atoi (theArgVec[++anArgIter]); |
12772 | const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); | |
12773 | aStyle->SetDisplayMode (aDispMode); | |
12774 | toRedraw = Standard_True; | |
12775 | } | |
12776 | else if (anArg == "-layer" | |
12777 | && anArgIter + 1 < theArgsNb) | |
12778 | { | |
12779 | if (aType == Prs3d_TypeOfHighlight_None) | |
12780 | { | |
23fe70ec | 12781 | Message::SendFail ("Syntax error: type of highlighting is undefined"); |
f838dac4 | 12782 | return 1; |
12783 | } | |
8e5fb5ea | 12784 | |
55c8f0f7 BB |
12785 | ++anArgIter; |
12786 | Graphic3d_ZLayerId aNewLayer = Graphic3d_ZLayerId_UNKNOWN; | |
12787 | if (!ViewerTest::ParseZLayer (theArgVec[anArgIter], aNewLayer)) | |
f838dac4 | 12788 | { |
23fe70ec | 12789 | Message::SendFail() << "Syntax error at " << theArgVec[anArgIter]; |
55c8f0f7 | 12790 | return 1; |
f838dac4 | 12791 | } |
8e5fb5ea | 12792 | |
f838dac4 | 12793 | const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); |
12794 | aStyle->SetZLayer (aNewLayer); | |
12795 | toRedraw = Standard_True; | |
12796 | } | |
12797 | else if (anArg == "-hicolor" | |
12798 | || anArg == "-selcolor" | |
12799 | || anArg == "-color") | |
12800 | { | |
12801 | if (anArg.StartsWith ("-hi")) | |
12802 | { | |
12803 | aType = Prs3d_TypeOfHighlight_Dynamic; | |
12804 | } | |
12805 | else if (anArg.StartsWith ("-sel")) | |
12806 | { | |
12807 | aType = Prs3d_TypeOfHighlight_Selected; | |
12808 | } | |
12809 | else if (aType == Prs3d_TypeOfHighlight_None) | |
12810 | { | |
23fe70ec | 12811 | Message::SendFail ("Syntax error: type of highlighting is undefined"); |
f838dac4 | 12812 | return 1; |
12813 | } | |
8e5fb5ea | 12814 | |
f838dac4 | 12815 | Quantity_Color aColor; |
dae2a922 | 12816 | Standard_Integer aNbParsed = Draw::ParseColor (theArgsNb - anArgIter - 1, |
12817 | theArgVec + anArgIter + 1, | |
12818 | aColor); | |
f838dac4 | 12819 | if (aNbParsed == 0) |
12820 | { | |
23fe70ec | 12821 | Message::SendFail ("Syntax error: need more arguments"); |
f838dac4 | 12822 | return 1; |
12823 | } | |
12824 | anArgIter += aNbParsed; | |
8e5fb5ea | 12825 | |
f838dac4 | 12826 | const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); |
12827 | aStyle->SetColor (aColor); | |
12828 | toRedraw = Standard_True; | |
12829 | } | |
12830 | else if ((anArg == "-transp" | |
12831 | || anArg == "-transparency" | |
12832 | || anArg == "-hitransp" | |
12833 | || anArg == "-seltransp" | |
12834 | || anArg == "-hitransplocal" | |
12835 | || anArg == "-seltransplocal") | |
12836 | && anArgIter + 1 < theArgsNb) | |
12837 | { | |
12838 | if (anArg.StartsWith ("-hi")) | |
12839 | { | |
12840 | aType = Prs3d_TypeOfHighlight_Dynamic; | |
12841 | } | |
12842 | else if (anArg.StartsWith ("-sel")) | |
12843 | { | |
12844 | aType = Prs3d_TypeOfHighlight_Selected; | |
12845 | } | |
12846 | else if (aType == Prs3d_TypeOfHighlight_None) | |
12847 | { | |
23fe70ec | 12848 | Message::SendFail ("Syntax error: type of highlighting is undefined"); |
f838dac4 | 12849 | return 1; |
12850 | } | |
8e5fb5ea | 12851 | |
f838dac4 | 12852 | const Standard_Real aTransp = Draw::Atof (theArgVec[++anArgIter]); |
12853 | const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); | |
12854 | aStyle->SetTransparency ((Standard_ShortReal )aTransp); | |
12855 | toRedraw = Standard_True; | |
12856 | } | |
12857 | else if ((anArg == "-mat" | |
12858 | || anArg == "-material") | |
12859 | && anArgIter + 1 < theArgsNb) | |
12860 | { | |
12861 | if (aType == Prs3d_TypeOfHighlight_None) | |
12862 | { | |
23fe70ec | 12863 | Message::SendFail ("Syntax error: type of highlighting is undefined"); |
f838dac4 | 12864 | return 1; |
12865 | } | |
8e5fb5ea | 12866 | |
f838dac4 | 12867 | const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); |
12868 | Graphic3d_NameOfMaterial aMatName = Graphic3d_MaterialAspect::MaterialFromName (theArgVec[anArgIter + 1]); | |
a966542b | 12869 | if (aMatName != Graphic3d_NameOfMaterial_DEFAULT) |
f838dac4 | 12870 | { |
12871 | ++anArgIter; | |
12872 | Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d(); | |
12873 | *anAspect = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect(); | |
12874 | Graphic3d_MaterialAspect aMat (aMatName); | |
12875 | aMat.SetColor (aStyle->Color()); | |
12876 | aMat.SetTransparency (aStyle->Transparency()); | |
12877 | anAspect->SetFrontMaterial (aMat); | |
12878 | anAspect->SetInteriorColor (aStyle->Color()); | |
12879 | aStyle->SetBasicFillAreaAspect (anAspect); | |
12880 | } | |
12881 | else | |
12882 | { | |
12883 | aStyle->SetBasicFillAreaAspect (Handle(Graphic3d_AspectFillArea3d)()); | |
12884 | } | |
12885 | toRedraw = Standard_True; | |
12886 | } | |
12887 | else | |
12888 | { | |
23fe70ec | 12889 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
8c36926a | 12890 | return 1; |
f838dac4 | 12891 | } |
8e5fb5ea | 12892 | } |
12893 | ||
f838dac4 | 12894 | if (toPrint) |
8e5fb5ea | 12895 | { |
f838dac4 | 12896 | const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle(); |
12897 | const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle(); | |
8e5fb5ea | 12898 | theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n"; |
be3d8cbc | 12899 | theDi << "Auto-highlight : " << (aCtx->AutomaticHilight() ? "On" : "Off") << "\n"; |
12900 | theDi << "Highlight selected : " << (aCtx->ToHilightSelected() ? "On" : "Off") << "\n"; | |
8e5fb5ea | 12901 | theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n"; |
f838dac4 | 12902 | theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n"; |
12903 | theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n"; | |
12904 | theDi << "Selection transparency : " << aSelStyle->Transparency() << "\n"; | |
12905 | theDi << "Dynamic highlight transparency : " << aHiStyle->Transparency() << "\n"; | |
12906 | theDi << "Selection mode : " << aSelStyle->DisplayMode() << "\n"; | |
12907 | theDi << "Dynamic highlight mode : " << aHiStyle->DisplayMode() << "\n"; | |
12908 | theDi << "Selection layer : " << aSelStyle->ZLayer() << "\n"; | |
12909 | theDi << "Dynamic layer : " << aHiStyle->ZLayer() << "\n"; | |
8e5fb5ea | 12910 | } |
12911 | ||
12912 | if (aCtx->NbSelected() != 0 && toRedraw) | |
12913 | { | |
12914 | aCtx->HilightSelected (Standard_True); | |
12915 | } | |
12916 | ||
12917 | return 0; | |
12918 | } | |
12919 | ||
decdee7d | 12920 | //=============================================================================================== |
12921 | //function : VDumpSelectionImage | |
12922 | //purpose : | |
12923 | //=============================================================================================== | |
12924 | static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/, | |
12925 | Standard_Integer theArgsNb, | |
12926 | const char** theArgVec) | |
12927 | { | |
decdee7d | 12928 | const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext(); |
b40cdc2b | 12929 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); |
decdee7d | 12930 | if (aContext.IsNull()) |
12931 | { | |
23fe70ec | 12932 | Message::SendFail ("Error: no active viewer"); |
decdee7d | 12933 | return 1; |
12934 | } | |
12935 | ||
12936 | TCollection_AsciiString aFile; | |
12937 | StdSelect_TypeOfSelectionImage aType = StdSelect_TypeOfSelectionImage_NormalizedDepth; | |
b40cdc2b | 12938 | Handle(Graphic3d_Camera) aCustomCam; |
dc858f4c | 12939 | Image_Format anImgFormat = Image_Format_BGR; |
decdee7d | 12940 | Standard_Integer aPickedIndex = 1; |
12941 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
12942 | { | |
12943 | TCollection_AsciiString aParam (theArgVec[anArgIter]); | |
12944 | aParam.LowerCase(); | |
12945 | if (aParam == "-type") | |
12946 | { | |
12947 | if (++anArgIter >= theArgsNb) | |
12948 | { | |
df23a355 | 12949 | Message::SendFail ("Syntax error: wrong number parameters of flag '-type'"); |
decdee7d | 12950 | return 1; |
12951 | } | |
12952 | ||
12953 | TCollection_AsciiString aValue (theArgVec[anArgIter]); | |
12954 | aValue.LowerCase(); | |
12955 | if (aValue == "depth" | |
12956 | || aValue == "normdepth" | |
12957 | || aValue == "normalizeddepth") | |
12958 | { | |
12959 | aType = StdSelect_TypeOfSelectionImage_NormalizedDepth; | |
dc858f4c | 12960 | anImgFormat = Image_Format_GrayF; |
decdee7d | 12961 | } |
df23a355 | 12962 | else if (aValue == "depthinverted" |
12963 | || aValue == "normdepthinverted" | |
12964 | || aValue == "normalizeddepthinverted" | |
12965 | || aValue == "inverted") | |
decdee7d | 12966 | { |
12967 | aType = StdSelect_TypeOfSelectionImage_NormalizedDepthInverted; | |
dc858f4c | 12968 | anImgFormat = Image_Format_GrayF; |
decdee7d | 12969 | } |
12970 | else if (aValue == "unnormdepth" | |
12971 | || aValue == "unnormalizeddepth") | |
12972 | { | |
12973 | aType = StdSelect_TypeOfSelectionImage_UnnormalizedDepth; | |
dc858f4c | 12974 | anImgFormat = Image_Format_GrayF; |
decdee7d | 12975 | } |
12976 | else if (aValue == "objectcolor" | |
12977 | || aValue == "object" | |
12978 | || aValue == "color") | |
12979 | { | |
12980 | aType = StdSelect_TypeOfSelectionImage_ColoredDetectedObject; | |
12981 | } | |
12982 | else if (aValue == "entitycolor" | |
12983 | || aValue == "entity") | |
12984 | { | |
12985 | aType = StdSelect_TypeOfSelectionImage_ColoredEntity; | |
12986 | } | |
9dd8af26 | 12987 | else if (aValue == "entitytypecolor" |
12988 | || aValue == "entitytype") | |
12989 | { | |
12990 | aType = StdSelect_TypeOfSelectionImage_ColoredEntityType; | |
12991 | } | |
decdee7d | 12992 | else if (aValue == "ownercolor" |
12993 | || aValue == "owner") | |
12994 | { | |
12995 | aType = StdSelect_TypeOfSelectionImage_ColoredOwner; | |
12996 | } | |
12997 | else if (aValue == "selectionmodecolor" | |
12998 | || aValue == "selectionmode" | |
12999 | || aValue == "selmodecolor" | |
13000 | || aValue == "selmode") | |
13001 | { | |
13002 | aType = StdSelect_TypeOfSelectionImage_ColoredSelectionMode; | |
13003 | } | |
114e7a90 | 13004 | else if (aValue == "surfnormal" |
13005 | || aValue == "surfacenormal" | |
13006 | || aValue == "normal") | |
13007 | { | |
13008 | aType = StdSelect_TypeOfSelectionImage_SurfaceNormal; | |
13009 | } | |
df23a355 | 13010 | else |
13011 | { | |
13012 | Message::SendFail() << "Syntax error: unknown type '" << aValue << "'"; | |
13013 | return 1; | |
13014 | } | |
decdee7d | 13015 | } |
13016 | else if (aParam == "-picked" | |
13017 | || aParam == "-pickeddepth" | |
13018 | || aParam == "-pickedindex") | |
13019 | { | |
13020 | if (++anArgIter >= theArgsNb) | |
13021 | { | |
23fe70ec | 13022 | Message::SendFail() << "Syntax error: wrong number parameters at '" << aParam << "'"; |
decdee7d | 13023 | return 1; |
13024 | } | |
13025 | ||
13026 | aPickedIndex = Draw::Atoi (theArgVec[anArgIter]); | |
13027 | } | |
b40cdc2b | 13028 | else if (anArgIter + 1 < theArgsNb |
13029 | && aParam == "-xrpose") | |
13030 | { | |
13031 | TCollection_AsciiString anXRArg (theArgVec[++anArgIter]); | |
13032 | anXRArg.LowerCase(); | |
13033 | if (anXRArg == "base") | |
13034 | { | |
13035 | aCustomCam = aView->View()->BaseXRCamera(); | |
13036 | } | |
13037 | else if (anXRArg == "head") | |
13038 | { | |
13039 | aCustomCam = aView->View()->PosedXRCamera(); | |
13040 | } | |
13041 | else | |
13042 | { | |
13043 | Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'"; | |
13044 | return 1; | |
13045 | } | |
13046 | if (aCustomCam.IsNull()) | |
13047 | { | |
13048 | Message::SendFail() << "Error: undefined XR pose"; | |
13049 | return 0; | |
13050 | } | |
13051 | } | |
decdee7d | 13052 | else if (aFile.IsEmpty()) |
13053 | { | |
13054 | aFile = theArgVec[anArgIter]; | |
13055 | } | |
13056 | else | |
13057 | { | |
23fe70ec | 13058 | Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'"; |
decdee7d | 13059 | return 1; |
13060 | } | |
13061 | } | |
13062 | if (aFile.IsEmpty()) | |
13063 | { | |
23fe70ec | 13064 | Message::SendFail ("Syntax error: image file name is missing"); |
decdee7d | 13065 | return 1; |
13066 | } | |
13067 | ||
decdee7d | 13068 | Standard_Integer aWidth = 0, aHeight = 0; |
13069 | aView->Window()->Size (aWidth, aHeight); | |
13070 | ||
13071 | Image_AlienPixMap aPixMap; | |
13072 | if (!aPixMap.InitZero (anImgFormat, aWidth, aHeight)) | |
13073 | { | |
23fe70ec | 13074 | Message::SendFail ("Error: can't allocate image"); |
decdee7d | 13075 | return 1; |
13076 | } | |
b40cdc2b | 13077 | |
13078 | const bool wasImmUpdate = aView->SetImmediateUpdate (false); | |
13079 | Handle(Graphic3d_Camera) aCamBack = aView->Camera(); | |
13080 | if (!aCustomCam.IsNull()) | |
13081 | { | |
13082 | aView->SetCamera (aCustomCam); | |
13083 | } | |
decdee7d | 13084 | if (!aContext->MainSelector()->ToPixMap (aPixMap, aView, aType, aPickedIndex)) |
13085 | { | |
23fe70ec | 13086 | Message::SendFail ("Error: can't generate selection image"); |
decdee7d | 13087 | return 1; |
13088 | } | |
b40cdc2b | 13089 | if (!aCustomCam.IsNull()) |
13090 | { | |
13091 | aView->SetCamera (aCamBack); | |
13092 | } | |
13093 | aView->SetImmediateUpdate (wasImmUpdate); | |
13094 | ||
decdee7d | 13095 | if (!aPixMap.Save (aFile)) |
13096 | { | |
23fe70ec | 13097 | Message::SendFail ("Error: can't save selection image"); |
decdee7d | 13098 | return 0; |
13099 | } | |
13100 | return 0; | |
13101 | } | |
13102 | ||
2108d9a2 | 13103 | //=============================================================================================== |
13104 | //function : VViewCube | |
13105 | //purpose : | |
13106 | //=============================================================================================== | |
13107 | static int VViewCube (Draw_Interpretor& , | |
13108 | Standard_Integer theNbArgs, | |
13109 | const char** theArgVec) | |
13110 | { | |
13111 | const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext(); | |
13112 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); | |
13113 | if (aContext.IsNull() || aView.IsNull()) | |
13114 | { | |
23fe70ec | 13115 | Message::SendFail ("Error: no active viewer"); |
2108d9a2 | 13116 | return 1; |
13117 | } | |
13118 | else if (theNbArgs < 2) | |
13119 | { | |
23fe70ec | 13120 | Message::SendFail ("Syntax error: wrong number arguments"); |
2108d9a2 | 13121 | return 1; |
13122 | } | |
13123 | ||
13124 | Handle(AIS_ViewCube) aViewCube; | |
13125 | ViewerTest_AutoUpdater anUpdateTool (aContext, aView); | |
13126 | Quantity_Color aColorRgb; | |
13127 | TCollection_AsciiString aName; | |
13128 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
13129 | { | |
13130 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
13131 | anArg.LowerCase(); | |
13132 | if (anUpdateTool.parseRedrawMode (anArg)) | |
13133 | { | |
13134 | // | |
13135 | } | |
13136 | else if (aViewCube.IsNull()) | |
13137 | { | |
13138 | aName = theArgVec[anArgIter]; | |
13139 | if (aName.StartsWith ("-")) | |
13140 | { | |
23fe70ec | 13141 | Message::SendFail ("Syntax error: object name should be specified"); |
2108d9a2 | 13142 | return 1; |
13143 | } | |
13144 | Handle(AIS_InteractiveObject) aPrs; | |
13145 | GetMapOfAIS().Find2 (aName, aPrs); | |
13146 | aViewCube = Handle(AIS_ViewCube)::DownCast (aPrs); | |
13147 | if (aViewCube.IsNull()) | |
13148 | { | |
13149 | aViewCube = new AIS_ViewCube(); | |
13150 | aViewCube->SetBoxColor (Quantity_NOC_GRAY50); | |
13151 | aViewCube->SetViewAnimation (ViewerTest::CurrentEventManager()->ViewAnimation()); | |
13152 | aViewCube->SetFixedAnimationLoop (false); | |
13153 | } | |
13154 | } | |
13155 | else if (anArg == "-reset") | |
13156 | { | |
13157 | aViewCube->ResetStyles(); | |
13158 | } | |
13159 | else if (anArg == "-color" | |
13160 | || anArg == "-boxcolor" | |
13161 | || anArg == "-boxsidecolor" | |
13162 | || anArg == "-sidecolor" | |
13163 | || anArg == "-boxedgecolor" | |
13164 | || anArg == "-edgecolor" | |
13165 | || anArg == "-boxcornercolor" | |
13166 | || anArg == "-cornercolor" | |
13167 | || anArg == "-innercolor" | |
0aeb8984 | 13168 | || anArg == "-textcolor" |
13169 | || anArg == "-xaxistextcolor" | |
13170 | || anArg == "-yaxistextcolor" | |
13171 | || anArg == "-zaxistextcolor") | |
2108d9a2 | 13172 | { |
dae2a922 | 13173 | Standard_Integer aNbParsed = Draw::ParseColor (theNbArgs - anArgIter - 1, |
13174 | theArgVec + anArgIter + 1, | |
13175 | aColorRgb); | |
2108d9a2 | 13176 | if (aNbParsed == 0) |
13177 | { | |
23fe70ec | 13178 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
2108d9a2 | 13179 | return 1; |
13180 | } | |
13181 | anArgIter += aNbParsed; | |
13182 | if (anArg == "-boxcolor") | |
13183 | { | |
13184 | aViewCube->SetBoxColor (aColorRgb); | |
13185 | } | |
13186 | else if (anArg == "-boxsidecolor" | |
13187 | || anArg == "-sidecolor") | |
13188 | { | |
13189 | aViewCube->BoxSideStyle()->SetColor (aColorRgb); | |
13190 | aViewCube->SynchronizeAspects(); | |
13191 | } | |
13192 | else if (anArg == "-boxedgecolor" | |
13193 | || anArg == "-edgecolor") | |
13194 | { | |
13195 | aViewCube->BoxEdgeStyle()->SetColor (aColorRgb); | |
13196 | aViewCube->SynchronizeAspects(); | |
13197 | } | |
13198 | else if (anArg == "-boxcornercolor" | |
13199 | || anArg == "-cornercolor") | |
13200 | { | |
13201 | aViewCube->BoxCornerStyle()->SetColor (aColorRgb); | |
13202 | aViewCube->SynchronizeAspects(); | |
13203 | } | |
13204 | else if (anArg == "-innercolor") | |
13205 | { | |
13206 | aViewCube->SetInnerColor (aColorRgb); | |
13207 | } | |
13208 | else if (anArg == "-textcolor") | |
13209 | { | |
13210 | aViewCube->SetTextColor (aColorRgb); | |
13211 | } | |
0aeb8984 | 13212 | else if (anArg == "-xaxistextcolor" |
13213 | || anArg == "-yaxistextcolor" | |
13214 | || anArg == "-zaxistextcolor") | |
13215 | { | |
13216 | Prs3d_DatumParts aDatum = anArg.Value (2) == 'x' | |
13217 | ? Prs3d_DatumParts_XAxis | |
13218 | : (anArg.Value (2) == 'y' | |
13219 | ? Prs3d_DatumParts_YAxis | |
13220 | : Prs3d_DatumParts_ZAxis); | |
13221 | aViewCube->Attributes()->SetOwnDatumAspects(); | |
13222 | aViewCube->Attributes()->DatumAspect()->TextAspect (aDatum)->SetColor (aColorRgb); | |
13223 | } | |
2108d9a2 | 13224 | else |
13225 | { | |
13226 | aViewCube->SetColor (aColorRgb); | |
13227 | } | |
13228 | } | |
13229 | else if (anArgIter + 1 < theNbArgs | |
13230 | && (anArg == "-transparency" | |
13231 | || anArg == "-boxtransparency")) | |
13232 | { | |
13233 | const Standard_Real aValue = Draw::Atof (theArgVec[++anArgIter]); | |
13234 | if (aValue < 0.0 || aValue > 1.0) | |
13235 | { | |
23fe70ec | 13236 | Message::SendFail() << "Syntax error: invalid transparency value " << theArgVec[anArgIter]; |
2108d9a2 | 13237 | return 1; |
13238 | } | |
13239 | ||
13240 | if (anArg == "-boxtransparency") | |
13241 | { | |
13242 | aViewCube->SetBoxTransparency (aValue); | |
13243 | } | |
13244 | else | |
13245 | { | |
13246 | aViewCube->SetTransparency (aValue); | |
13247 | } | |
13248 | } | |
13249 | else if (anArg == "-axes" | |
13250 | || anArg == "-edges" | |
13251 | || anArg == "-vertices" | |
13252 | || anArg == "-vertexes" | |
13253 | || anArg == "-fixedanimation") | |
13254 | { | |
13255 | bool toShow = true; | |
13256 | if (anArgIter + 1 < theNbArgs | |
dae2a922 | 13257 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toShow)) |
2108d9a2 | 13258 | { |
13259 | ++anArgIter; | |
13260 | } | |
13261 | if (anArg == "-fixedanimation") | |
13262 | { | |
13263 | aViewCube->SetFixedAnimationLoop (toShow); | |
13264 | } | |
13265 | else if (anArg == "-axes") | |
13266 | { | |
13267 | aViewCube->SetDrawAxes (toShow); | |
13268 | } | |
13269 | else if (anArg == "-edges") | |
13270 | { | |
13271 | aViewCube->SetDrawEdges (toShow); | |
13272 | } | |
13273 | else | |
13274 | { | |
13275 | aViewCube->SetDrawVertices (toShow); | |
13276 | } | |
13277 | } | |
13278 | else if (anArg == "-yup" | |
13279 | || anArg == "-zup") | |
13280 | { | |
13281 | bool isOn = true; | |
13282 | if (anArgIter + 1 < theNbArgs | |
dae2a922 | 13283 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], isOn)) |
2108d9a2 | 13284 | { |
13285 | ++anArgIter; | |
13286 | } | |
13287 | if (anArg == "-yup") | |
13288 | { | |
13289 | aViewCube->SetYup (isOn); | |
13290 | } | |
13291 | else | |
13292 | { | |
13293 | aViewCube->SetYup (!isOn); | |
13294 | } | |
13295 | } | |
13296 | else if (anArgIter + 1 < theNbArgs | |
13297 | && anArg == "-font") | |
13298 | { | |
13299 | aViewCube->SetFont (theArgVec[++anArgIter]); | |
13300 | } | |
13301 | else if (anArgIter + 1 < theNbArgs | |
13302 | && anArg == "-fontheight") | |
13303 | { | |
13304 | aViewCube->SetFontHeight (Draw::Atof (theArgVec[++anArgIter])); | |
13305 | } | |
13306 | else if (anArgIter + 1 < theNbArgs | |
13307 | && (anArg == "-size" | |
13308 | || anArg == "-boxsize")) | |
13309 | { | |
13310 | aViewCube->SetSize (Draw::Atof (theArgVec[++anArgIter]), | |
13311 | anArg != "-boxsize"); | |
13312 | } | |
13313 | else if (anArgIter + 1 < theNbArgs | |
13314 | && (anArg == "-boxfacet" | |
13315 | || anArg == "-boxfacetextension" | |
13316 | || anArg == "-facetextension" | |
13317 | || anArg == "-extension")) | |
13318 | { | |
13319 | aViewCube->SetBoxFacetExtension (Draw::Atof (theArgVec[++anArgIter])); | |
13320 | } | |
13321 | else if (anArgIter + 1 < theNbArgs | |
13322 | && (anArg == "-boxedgegap" | |
13323 | || anArg == "-edgegap")) | |
13324 | { | |
13325 | aViewCube->SetBoxEdgeGap (Draw::Atof (theArgVec[++anArgIter])); | |
13326 | } | |
13327 | else if (anArgIter + 1 < theNbArgs | |
13328 | && (anArg == "-boxedgeminsize" | |
13329 | || anArg == "-edgeminsize")) | |
13330 | { | |
13331 | aViewCube->SetBoxEdgeMinSize (Draw::Atof (theArgVec[++anArgIter])); | |
13332 | } | |
13333 | else if (anArgIter + 1 < theNbArgs | |
13334 | && (anArg == "-boxcornerminsize" | |
13335 | || anArg == "-cornerminsize")) | |
13336 | { | |
13337 | aViewCube->SetBoxCornerMinSize (Draw::Atof (theArgVec[++anArgIter])); | |
13338 | } | |
13339 | else if (anArgIter + 1 < theNbArgs | |
13340 | && anArg == "-axespadding") | |
13341 | { | |
13342 | aViewCube->SetAxesPadding (Draw::Atof (theArgVec[++anArgIter])); | |
13343 | } | |
13344 | else if (anArgIter + 1 < theNbArgs | |
13345 | && anArg == "-roundradius") | |
13346 | { | |
13347 | aViewCube->SetRoundRadius (Draw::Atof (theArgVec[++anArgIter])); | |
13348 | } | |
13349 | else if (anArgIter + 1 < theNbArgs | |
13350 | && anArg == "-duration") | |
13351 | { | |
13352 | aViewCube->SetDuration (Draw::Atof (theArgVec[++anArgIter])); | |
13353 | } | |
6466cc9e | 13354 | else if (anArgIter + 1 < theNbArgs |
13355 | && anArg == "-axesradius") | |
13356 | { | |
13357 | aViewCube->SetAxesRadius (Draw::Atof (theArgVec[++anArgIter])); | |
13358 | } | |
13359 | else if (anArgIter + 1 < theNbArgs | |
13360 | && anArg == "-axesconeradius") | |
13361 | { | |
13362 | aViewCube->SetAxesConeRadius (Draw::Atof (theArgVec[++anArgIter])); | |
13363 | } | |
13364 | else if (anArgIter + 1 < theNbArgs | |
13365 | && anArg == "-axessphereradius") | |
13366 | { | |
13367 | aViewCube->SetAxesSphereRadius (Draw::Atof (theArgVec[++anArgIter])); | |
13368 | } | |
2108d9a2 | 13369 | else |
13370 | { | |
23fe70ec | 13371 | Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'"; |
2108d9a2 | 13372 | return 1; |
13373 | } | |
13374 | } | |
13375 | if (aViewCube.IsNull()) | |
13376 | { | |
23fe70ec | 13377 | Message::SendFail ("Syntax error: wrong number of arguments"); |
2108d9a2 | 13378 | return 1; |
13379 | } | |
13380 | ||
13381 | ViewerTest::Display (aName, aViewCube, false); | |
13382 | return 0; | |
13383 | } | |
13384 | ||
14b741b0 | 13385 | //=============================================================================================== |
13386 | //function : VColorConvert | |
13387 | //purpose : | |
13388 | //=============================================================================================== | |
13389 | static int VColorConvert (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec) | |
13390 | { | |
13391 | if (theNbArgs != 6) | |
13392 | { | |
13393 | std::cerr << "Error: command syntax is incorrect, see help" << std::endl; | |
13394 | return 1; | |
13395 | } | |
13396 | ||
13397 | Standard_Boolean convertFrom = (! strcasecmp (theArgVec[1], "from")); | |
13398 | if (! convertFrom && strcasecmp (theArgVec[1], "to")) | |
13399 | { | |
13400 | std::cerr << "Error: first argument must be either \"to\" or \"from\"" << std::endl; | |
13401 | return 1; | |
13402 | } | |
13403 | ||
13404 | const char* aTypeStr = theArgVec[2]; | |
13405 | Quantity_TypeOfColor aType = Quantity_TOC_RGB; | |
13406 | if (! strcasecmp (aTypeStr, "srgb")) | |
13407 | { | |
13408 | aType = Quantity_TOC_sRGB; | |
13409 | } | |
13410 | else if (! strcasecmp (aTypeStr, "hls")) | |
13411 | { | |
13412 | aType = Quantity_TOC_HLS; | |
13413 | } | |
13414 | else if (! strcasecmp (aTypeStr, "lab")) | |
13415 | { | |
13416 | aType = Quantity_TOC_CIELab; | |
13417 | } | |
13418 | else if (! strcasecmp (aTypeStr, "lch")) | |
13419 | { | |
13420 | aType = Quantity_TOC_CIELch; | |
13421 | } | |
13422 | else | |
13423 | { | |
13424 | std::cerr << "Error: unknown colorspace type: " << aTypeStr << std::endl; | |
13425 | return 1; | |
13426 | } | |
13427 | ||
13428 | double aC1 = Draw::Atof (theArgVec[3]); | |
13429 | double aC2 = Draw::Atof (theArgVec[4]); | |
13430 | double aC3 = Draw::Atof (theArgVec[5]); | |
13431 | ||
13432 | Quantity_Color aColor (aC1, aC2, aC3, convertFrom ? aType : Quantity_TOC_RGB); | |
13433 | aColor.Values (aC1, aC2, aC3, convertFrom ? Quantity_TOC_RGB : aType); | |
13434 | ||
13435 | // print values with 6 decimal digits | |
13436 | char buffer[1024]; | |
13437 | Sprintf (buffer, "%.6f %.6f %.6f", aC1, aC2, aC3); | |
13438 | theDI << buffer; | |
13439 | ||
13440 | return 0; | |
13441 | } | |
13442 | ||
13443 | //=============================================================================================== | |
13444 | //function : VColorDiff | |
13445 | //purpose : | |
13446 | //=============================================================================================== | |
13447 | static int VColorDiff (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec) | |
13448 | { | |
13449 | if (theNbArgs != 7) | |
13450 | { | |
13451 | std::cerr << "Error: command syntax is incorrect, see help" << std::endl; | |
13452 | return 1; | |
13453 | } | |
13454 | ||
13455 | double aR1 = Draw::Atof (theArgVec[1]); | |
13456 | double aG1 = Draw::Atof (theArgVec[2]); | |
13457 | double aB1 = Draw::Atof (theArgVec[3]); | |
13458 | double aR2 = Draw::Atof (theArgVec[4]); | |
13459 | double aG2 = Draw::Atof (theArgVec[5]); | |
13460 | double aB2 = Draw::Atof (theArgVec[6]); | |
13461 | ||
13462 | Quantity_Color aColor1 (aR1, aG1, aB1, Quantity_TOC_RGB); | |
13463 | Quantity_Color aColor2 (aR2, aG2, aB2, Quantity_TOC_RGB); | |
13464 | ||
13465 | theDI << aColor1.DeltaE2000 (aColor2); | |
13466 | ||
13467 | return 0; | |
13468 | } | |
13469 | ||
6a2fb7a1 | 13470 | //=============================================================================================== |
4551e1be | 13471 | //function : VSelBvhBuild |
6a2fb7a1 | 13472 | //purpose : |
13473 | //=============================================================================================== | |
13474 | static int VSelBvhBuild (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs, const char** theArgVec) | |
13475 | { | |
13476 | const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
13477 | if (aCtx.IsNull()) | |
13478 | { | |
13479 | Message::SendFail ("Error: no active viewer"); | |
13480 | return 1; | |
13481 | } | |
13482 | ||
13483 | if (theNbArgs < 2) | |
13484 | { | |
13485 | Message::SendFail ("Error: command syntax is incorrect, see help"); | |
13486 | return 1; | |
13487 | } | |
13488 | ||
13489 | Standard_Integer toEnable = -1; | |
13490 | Standard_Integer aThreadsNb = -1; | |
13491 | Standard_Boolean toWait = Standard_False; | |
13492 | ||
13493 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
13494 | { | |
13495 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
13496 | anArg.LowerCase(); | |
13497 | ||
13498 | if (anArg == "-nbthreads" | |
13499 | && anArgIter + 1 < theNbArgs) | |
13500 | { | |
13501 | aThreadsNb = Draw::Atoi (theArgVec[++anArgIter]); | |
13502 | if (aThreadsNb < 1) | |
13503 | { | |
13504 | aThreadsNb = Max (1, OSD_Parallel::NbLogicalProcessors() - 1); | |
13505 | } | |
13506 | } | |
13507 | else if (anArg == "-wait") | |
13508 | { | |
13509 | toWait = Standard_True; | |
13510 | } | |
13511 | else if (toEnable == -1) | |
13512 | { | |
13513 | Standard_Boolean toEnableValue = Standard_True; | |
13514 | if (Draw::ParseOnOff (anArg.ToCString(), toEnableValue)) | |
13515 | { | |
13516 | toEnable = toEnableValue ? 1 : 0; | |
13517 | } | |
13518 | else | |
13519 | { | |
13520 | Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'"; | |
13521 | return 1; | |
13522 | } | |
13523 | } | |
13524 | else | |
13525 | { | |
13526 | Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'"; | |
13527 | return 1; | |
13528 | } | |
13529 | } | |
13530 | ||
13531 | if (aThreadsNb == -1) | |
13532 | { | |
13533 | aThreadsNb = 1; | |
13534 | } | |
13535 | if (toEnable != -1) | |
13536 | { | |
13537 | aCtx->MainSelector()->SetToPrebuildBVH (toEnable == 1, aThreadsNb); | |
13538 | } | |
13539 | if (toWait) | |
13540 | { | |
13541 | aCtx->MainSelector()->WaitForBVHBuild(); | |
13542 | } | |
13543 | ||
13544 | return 0; | |
13545 | } | |
13546 | ||
a6049685 | 13547 | //======================================================================= |
13548 | //function : ViewerTest_ExitProc | |
13549 | //purpose : | |
13550 | //======================================================================= | |
13551 | static void ViewerTest_ExitProc (ClientData ) | |
13552 | { | |
13553 | NCollection_List<TCollection_AsciiString> aViewList; | |
13554 | for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews); | |
13555 | anIter.More(); anIter.Next()) | |
13556 | { | |
13557 | aViewList.Append (anIter.Key1()); | |
13558 | } | |
13559 | ||
13560 | for (NCollection_List<TCollection_AsciiString>::Iterator anIter (aViewList); | |
13561 | anIter.More(); anIter.Next()) | |
13562 | { | |
13563 | ViewerTest::RemoveView (anIter.Value(), true); | |
13564 | } | |
13565 | } | |
13566 | ||
7fd59977 | 13567 | //======================================================================= |
13568 | //function : ViewerCommands | |
13569 | //purpose : | |
13570 | //======================================================================= | |
13571 | ||
13572 | void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) | |
13573 | { | |
a6049685 | 13574 | static bool TheIsInitialized = false; |
13575 | if (TheIsInitialized) | |
13576 | { | |
13577 | return; | |
13578 | } | |
13579 | ||
13580 | TheIsInitialized = true; | |
13581 | // define destruction callback to destroy views in a well-defined order | |
13582 | Tcl_CreateExitHandler (ViewerTest_ExitProc, 0); | |
7fd59977 | 13583 | |
13584 | const char *group = "ZeViewer"; | |
b8db9379 | 13585 | theCommands.Add("vdriver", |
13586 | "vdriver [-list] [-default DriverName] [-load DriverName]" | |
13587 | "\n\t\t: Manages active graphic driver factory." | |
13588 | "\n\t\t: Prints current active driver when called without arguments." | |
13589 | "\n\t\t: Makes specified driver active when ActiveName argument is specified." | |
13590 | "\n\t\t: -list print registered factories" | |
13591 | "\n\t\t: -default define which factory should be used by default (to be used by next vinit call)" | |
13592 | "\n\t\t: -load try loading factory plugin and set it as default one", | |
13593 | __FILE__, VDriver, group); | |
18d715bd | 13594 | theCommands.Add("vinit", |
fd3f6bd0 | 13595 | "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]" |
72ed0644 | 13596 | "\n\t\t: [-exitOnClose] [-closeOnEscape] [-cloneActive] [-virtual {on|off}=off] [-2d_mode {on|off}=off]" |
b69e576a | 13597 | #if defined(HAVE_XLIB) |
fd3f6bd0 | 13598 | "\n\t\t: [-display displayName]" |
13599 | #endif | |
13600 | "\n\t\t: Creates new View window with specified name viewName." | |
13601 | "\n\t\t: By default the new view is created in the viewer and in" | |
13602 | "\n\t\t: graphic driver shared with active view." | |
13603 | "\n\t\t: -name {driverName/viewerName/viewName | viewerName/viewName | viewName}" | |
13604 | "\n\t\t: If driverName isn't specified the driver will be shared with active view." | |
13605 | "\n\t\t: If viewerName isn't specified the viewer will be shared with active view." | |
b69e576a | 13606 | #if defined(HAVE_XLIB) |
fd3f6bd0 | 13607 | "\n\t\t: -display HostName.DisplayNumber[:ScreenNumber]" |
13608 | "\n\t\t: Display name will be used within creation of graphic driver, when specified." | |
18d715bd | 13609 | #endif |
fd3f6bd0 | 13610 | "\n\t\t: -left, -top pixel position of left top corner of the window." |
4551e1be | 13611 | "\n\t\t: -width, -height width and height of window respectively." |
72ed0644 | 13612 | "\n\t\t: -cloneActive flag to copy camera and dimensions of active view." |
fd3f6bd0 | 13613 | "\n\t\t: -exitOnClose when specified, closing the view will exit application." |
13614 | "\n\t\t: -closeOnEscape when specified, view will be closed on pressing Escape." | |
72ed0644 | 13615 | "\n\t\t: -virtual create an offscreen window within interactive session" |
2e93433e | 13616 | "\n\t\t: -2d_mode when on, view will not react on rotate scene events" |
fd3f6bd0 | 13617 | "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.", |
7fd59977 | 13618 | __FILE__,VInit,group); |
18d715bd | 13619 | theCommands.Add("vclose" , |
d0cc1cb7 | 13620 | "[view_id [keep_context=0|1]]\n" |
18d715bd | 13621 | "or vclose ALL - to remove all created views\n" |
13622 | " - removes view(viewer window) defined by its view_id.\n" | |
13623 | " - keep_context: by default 0; if 1 and the last view is deleted" | |
13624 | " the current context is not removed.", | |
13625 | __FILE__,VClose,group); | |
13626 | theCommands.Add("vactivate" , | |
e084dbbc | 13627 | "vactivate view_id [-noUpdate]" |
18d715bd | 13628 | " - activates view(viewer window) defined by its view_id", |
13629 | __FILE__,VActivate,group); | |
13630 | theCommands.Add("vviewlist", | |
13631 | "vviewlist [format={tree, long}]" | |
13632 | " - prints current list of views per viewer and graphic_driver ID shared between viewers" | |
13633 | " - format: format of result output, if tree the output is a tree view;" | |
13634 | "otherwise it's a list of full view names. By default format = tree", | |
13635 | __FILE__,VViewList,group); | |
7fd59977 | 13636 | theCommands.Add("vhelp" , |
13637 | "vhelp : display help on the viewer commands", | |
13638 | __FILE__,VHelp,group); | |
fc552d84 | 13639 | theCommands.Add("vviewproj", |
13640 | "vviewproj [top|bottom|left|right|front|back|axoLeft|axoRight]" | |
13641 | "\n\t\t: [+-X+-Y+-Z] [-Zup|-Yup] [-frame +-X+-Y]" | |
13642 | "\n\t\t: Setup view direction" | |
13643 | "\n\t\t: -Yup use Y-up convention instead of Zup (which is default)." | |
13644 | "\n\t\t: +-X+-Y+-Z define direction as combination of DX, DY and DZ;" | |
13645 | "\n\t\t: for example '+Z' will show front of the model," | |
13646 | "\n\t\t: '-X-Y+Z' will define left axonometrical view." | |
13647 | "\n\t\t: -frame define camera Up and Right directions (regardless Up convention);" | |
13648 | "\n\t\t: for example '+X+Z' will show front of the model with Z-up." | |
13649 | __FILE__,VViewProj,group); | |
7fd59977 | 13650 | theCommands.Add("vtop" , |
27af3052 | 13651 | "vtop or <T> : Top view. Orientation +X+Y" , |
fc552d84 | 13652 | __FILE__,VViewProj,group); |
44b8f2d6 | 13653 | theCommands.Add("vbottom" , |
27af3052 | 13654 | "vbottom : Bottom view. Orientation +X-Y" , |
fc552d84 | 13655 | __FILE__,VViewProj,group); |
44b8f2d6 | 13656 | theCommands.Add("vleft" , |
27af3052 | 13657 | "vleft : Left view. Orientation -Y+Z" , |
fc552d84 | 13658 | __FILE__,VViewProj,group); |
44b8f2d6 | 13659 | theCommands.Add("vright" , |
27af3052 | 13660 | "vright : Right view. Orientation +Y+Z" , |
fc552d84 | 13661 | __FILE__,VViewProj,group); |
7fd59977 | 13662 | theCommands.Add("vaxo" , |
27af3052 | 13663 | " vaxo or <A> : Axonometric view. Orientation +X-Y+Z", |
fc552d84 | 13664 | __FILE__,VViewProj,group); |
44b8f2d6 | 13665 | theCommands.Add("vfront" , |
27af3052 | 13666 | "vfront : Front view. Orientation +X+Z" , |
fc552d84 | 13667 | __FILE__,VViewProj,group); |
44b8f2d6 | 13668 | theCommands.Add("vback" , |
27af3052 | 13669 | "vback : Back view. Orientation -X+Z" , |
fc552d84 | 13670 | __FILE__,VViewProj,group); |
7fd59977 | 13671 | theCommands.Add("vpick" , |
13672 | "vpick : vpick X Y Z [shape subshape] ( all variables as string )", | |
13673 | VPick,group); | |
1beb58d7 | 13674 | theCommands.Add("vfit", |
13675 | "vfit or <F> [-selected] [-noupdate]" | |
b586500b | 13676 | "\n\t\t: [-selected] fits the scene according to bounding box of currently selected objects", |
7fd59977 | 13677 | __FILE__,VFit,group); |
6262a303 | 13678 | theCommands.Add ("vfitarea", |
13679 | "vfitarea x1 y1 x2 y2" | |
13680 | "\n\t\t: vfitarea x1 y1 z1 x2 y2 z2" | |
13681 | "\n\t\t: Fit view to show area located between two points" | |
13682 | "\n\t\t: given in world 2D or 3D corrdinates.", | |
13683 | __FILE__, VFitArea, group); | |
197ac94e | 13684 | theCommands.Add ("vzfit", "vzfit [scale]\n" |
13685 | " Matches Z near, Z far view volume planes to the displayed objects.\n" | |
13686 | " \"scale\" - specifies factor to scale computed z range.\n", | |
13687 | __FILE__, VZFit, group); | |
7fd59977 | 13688 | theCommands.Add("vrepaint", |
8693dfd0 | 13689 | "vrepaint [-immediate] [-continuous FPS]" |
13690 | "\n\t\t: force redraw of active View" | |
13691 | "\n\t\t: -immediate flag performs redraw of immediate layers only;" | |
13692 | "\n\t\t: -continuous activates/deactivates continuous redraw of active View," | |
13693 | "\n\t\t: 0 means no continuous rendering," | |
13694 | "\n\t\t: -1 means non-stop redraws," | |
13695 | "\n\t\t: >0 specifies target framerate,", | |
7fd59977 | 13696 | __FILE__,VRepaint,group); |
13697 | theCommands.Add("vclear", | |
faea8b40 | 13698 | "vclear : vclear" |
13699 | "\n\t\t: remove all the object from the viewer", | |
7fd59977 | 13700 | __FILE__,VClear,group); |
c585f731 | 13701 | theCommands.Add ("vbackground", |
13702 | "vbackground [-color Color [-default]]" | |
13703 | "\n\t\t: [-gradient Color1 Color2 [-default]" | |
9af0d66b | 13704 | "\n\t\t: [-gradientMode {NONE|HORIZONTAL|VERTICAL|DIAG1|DIAG2|CORNER1|CORNER2|CORNER3|ELLIPTICAL}]=VERT]" |
c585f731 | 13705 | "\n\t\t: [-imageFile ImageFile [-imageMode {CENTERED|TILED|STRETCH|NONE}]=CENTERED [-srgb {0|1}]=1]" |
3e9cb806 | 13706 | "\n\t\t: [-cubemap CubemapFile1 [CubeMapFiles2-5] [-order TilesIndexes1-6] [-invertedz]=0]" |
13707 | "\n\t\t: [-pbrEnv {ibl|noibl|keep}]" | |
c585f731 | 13708 | "\n\t\t: Changes background or some background settings." |
13709 | "\n\t\t: -color sets background color" | |
13710 | "\n\t\t: -gradient sets background gradient starting and ending colors" | |
13711 | "\n\t\t: -gradientMode sets gradient fill method" | |
13712 | "\n\t\t: -default sets background default gradient or color" | |
13713 | "\n\t\t: -imageFile sets filename of image used as background" | |
13714 | "\n\t\t: -imageMode sets image fill type" | |
13715 | "\n\t\t: -cubemap sets environment cubemap as background" | |
13716 | "\n\t\t: -invertedz sets inversion of Z axis for background cubemap rendering; FALSE when unspecified" | |
3e9cb806 | 13717 | "\n\t\t: -pbrEnv sets on/off Image Based Lighting (IBL) from background cubemap for PBR" |
c585f731 | 13718 | "\n\t\t: -srgb prefer sRGB texture format when applicable; TRUE when unspecified" |
13719 | "\n\t\t: -order defines order of tiles in one image cubemap" | |
13720 | "\n\t\t: TileIndexi defubes an index in range [0, 5] for i tile of one image packed cubemap" | |
13721 | "\n\t\t: (has no effect in case of multi-image cubemaps)", | |
293211ae | 13722 | __FILE__, |
c585f731 | 13723 | VBackground, |
293211ae | 13724 | group); |
13725 | theCommands.Add ("vsetbg", | |
293211ae | 13726 | "\n\t\t: Alias for 'vbackground -imageFile ImageFile [-imageMode FillType]'.", |
13727 | __FILE__, | |
c585f731 | 13728 | VBackground, |
293211ae | 13729 | group); |
13730 | theCommands.Add ("vsetbgmode", | |
293211ae | 13731 | "\n\t\t: Alias for 'vbackground -imageMode FillType'.", |
13732 | __FILE__, | |
c585f731 | 13733 | VBackground, |
293211ae | 13734 | group); |
13735 | theCommands.Add ("vsetgradientbg", | |
293211ae | 13736 | "\n\t\t: Alias for 'vbackground -gradient Color1 Color2 -gradientMode FillMethod'.", |
13737 | __FILE__, | |
c585f731 | 13738 | VBackground, |
293211ae | 13739 | group); |
13740 | theCommands.Add ("vsetgrbgmode", | |
293211ae | 13741 | "\n\t\t: Alias for 'vbackground -gradientMode FillMethod'.", |
13742 | __FILE__, | |
c585f731 | 13743 | VBackground, |
293211ae | 13744 | group); |
13745 | theCommands.Add ("vsetcolorbg", | |
293211ae | 13746 | "\n\t\t: Alias for 'vbackground -color Color'.", |
13747 | __FILE__, | |
c585f731 | 13748 | VBackground, |
293211ae | 13749 | group); |
13750 | theCommands.Add ("vsetdefaultbg", | |
c585f731 | 13751 | "\n\t\t: Alias for 'vbackground -default -gradient Color1 Color2 [-gradientMode FillMethod]'" |
13752 | "\n\t\t: and for 'vbackground -default -color Color'.", | |
293211ae | 13753 | __FILE__, |
c585f731 | 13754 | VBackground, |
293211ae | 13755 | group); |
7fd59977 | 13756 | theCommands.Add("vscale", |
13757 | "vscale : vscale X Y Z", | |
13758 | __FILE__,VScale,group); | |
13759 | theCommands.Add("vzbufftrihedron", | |
536d98e2 | 13760 | "vzbufftrihedron [{-on|-off}=-on] [-type {wireframe|zbuffer}=zbuffer]" |
13761 | "\n\t\t: [-position center|left_lower|left_upper|right_lower|right_upper]" | |
13762 | "\n\t\t: [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]" | |
13763 | "\n\t\t: [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]" | |
13764 | "\n\t\t: [-nbfacets value=12] [-colorLabels color=WHITE]" | |
0aeb8984 | 13765 | "\n\t\t: [-colorLabelX color] [-colorLabelY color] [-colorLabelZ color]" |
536d98e2 | 13766 | "\n\t\t: Displays a trihedron", |
13767 | __FILE__,VZBuffTrihedron,group); | |
7fd59977 | 13768 | theCommands.Add("vrotate", |
4af098ba | 13769 | "vrotate [[-mouseStart X Y] [-mouseMove X Y]]|[AX AY AZ [X Y Z]]" |
13770 | "\n : Option -mouseStart starts rotation according to the mouse position" | |
13771 | "\n : Option -mouseMove continues rotation with angle computed" | |
13772 | "\n : from last and new mouse position." | |
13773 | "\n : vrotate AX AY AZ [X Y Z]", | |
7fd59977 | 13774 | __FILE__,VRotate,group); |
13775 | theCommands.Add("vzoom", | |
13776 | "vzoom : vzoom coef", | |
13777 | __FILE__,VZoom,group); | |
13778 | theCommands.Add("vpan", | |
13779 | "vpan : vpan dx dy", | |
13780 | __FILE__,VPan,group); | |
7fd59977 | 13781 | theCommands.Add("vcolorscale", |
4b3d6eb1 | 13782 | "vcolorscale name [-noupdate|-update] [-demo]" |
13783 | "\n\t\t: [-range RangeMin=0 RangeMax=1 NbIntervals=10]" | |
13784 | "\n\t\t: [-font HeightFont=20]" | |
13785 | "\n\t\t: [-logarithmic {on|off}=off] [-reversed {on|off}=off]" | |
13786 | "\n\t\t: [-smoothTransition {on|off}=off]" | |
13787 | "\n\t\t: [-hueRange MinAngle=230 MaxAngle=0]" | |
13788 | "\n\t\t: [-colorRange MinColor=BLUE1 MaxColor=RED]" | |
13789 | "\n\t\t: [-textpos {left|right|center|none}=right]" | |
13790 | "\n\t\t: [-labelAtBorder {on|off}=on]" | |
13791 | "\n\t\t: [-colors Color1 Color2 ...] [-color Index Color]" | |
13792 | "\n\t\t: [-labels Label1 Label2 ...] [-label Index Label]" | |
13793 | "\n\t\t: [-freeLabels NbOfLabels Label1 Label2 ...]" | |
13794 | "\n\t\t: [-xy Left=0 Bottom=0]" | |
14b741b0 | 13795 | "\n\t\t: [-uniform lightness hue_from hue_to]" |
4b3d6eb1 | 13796 | "\n\t\t: -demo - displays a color scale with demonstratio values" |
13797 | "\n\t\t: -colors - set colors for all intervals" | |
13798 | "\n\t\t: -color - set color for specific interval" | |
14b741b0 | 13799 | "\n\t\t: -uniform - generate colors with the same lightness" |
4b3d6eb1 | 13800 | "\n\t\t: -textpos - horizontal label position relative to color scale bar" |
13801 | "\n\t\t: -labelAtBorder - vertical label position relative to color interval;" | |
13802 | "\n\t\t: at border means the value inbetween neighbor intervals," | |
13803 | "\n\t\t: at center means the center value within current interval" | |
13804 | "\n\t\t: -labels - set labels for all intervals" | |
13805 | "\n\t\t: -freeLabels - same as -labels but does not require" | |
13806 | "\n\t\t: matching the number of intervals" | |
13807 | "\n\t\t: -label - set label for specific interval" | |
13808 | "\n\t\t: -title - set title" | |
13809 | "\n\t\t: -reversed - setup smooth color transition between intervals" | |
13810 | "\n\t\t: -smoothTransition - swap colorscale direction" | |
14b741b0 | 13811 | "\n\t\t: -hueRange - set hue angles corresponding to minimum and maximum values", |
4b3d6eb1 | 13812 | __FILE__, VColorScale, group); |
7fd59977 | 13813 | theCommands.Add("vgraduatedtrihedron", |
a79f67f8 | 13814 | "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n" |
13815 | "\t[-namefont Name] [-valuesfont Name]\n" | |
13816 | "\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n" | |
13817 | "\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]" | |
13818 | "\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n" | |
13819 | "\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n" | |
13820 | "\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]" | |
13821 | "\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n" | |
13822 | "\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n" | |
13823 | "\t[-xticks Number] [-yticks Number] [-zticks Number]\n" | |
13824 | "\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n" | |
536d98e2 | 13825 | "\t[-drawgrid on/off] [-drawaxes on/off]\n" |
a79f67f8 | 13826 | " - Displays or erases graduated trihedron" |
13827 | " - xname, yname, zname - names of axes, default: X, Y, Z\n" | |
13828 | " - namefont - font of axes names. Default: Arial\n" | |
13829 | " - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n" | |
13830 | " - xnamecolor, ynamecolor, znamecolor - colors of axes names\n" | |
13831 | " - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n" | |
13832 | " - valuesfont - font of axes values. Default: Arial\n" | |
13833 | " - xcolor, ycolor, zcolor - color of axis and values\n" | |
13834 | " - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n" | |
13835 | " - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n", | |
7fd59977 | 13836 | __FILE__,VGraduatedTrihedron,group); |
3bffef55 | 13837 | theCommands.Add("vtile" , |
13838 | "vtile [-totalSize W H] [-lowerLeft X Y] [-upperLeft X Y] [-tileSize W H]" | |
13839 | "\n\t\t: Setup view to draw a tile (a part of virtual bigger viewport)." | |
13840 | "\n\t\t: -totalSize the size of virtual bigger viewport" | |
13841 | "\n\t\t: -tileSize tile size (the view size will be used if omitted)" | |
13842 | "\n\t\t: -lowerLeft tile offset as lower left corner" | |
13843 | "\n\t\t: -upperLeft tile offset as upper left corner", | |
13844 | __FILE__, VTile, group); | |
59f45b7c | 13845 | theCommands.Add("vzlayer", |
7c3ef2f7 | 13846 | "vzlayer [layerId]" |
1c728f2d | 13847 | "\n\t\t: [-add|-delete|-get|-settings] [-insertBefore AnotherLayer] [-insertAfter AnotherLayer]" |
4ecf34cc | 13848 | "\n\t\t: [-origin X Y Z] [-cullDist Distance] [-cullSize Size]" |
7c3ef2f7 | 13849 | "\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]" |
1c728f2d | 13850 | "\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv|rayTracing}]" |
7c3ef2f7 | 13851 | "\n\t\t: ZLayer list management:" |
13852 | "\n\t\t: -add add new z layer to viewer and print its id" | |
1c728f2d | 13853 | "\n\t\t: -insertBefore add new z layer and insert it before existing one" |
13854 | "\n\t\t: -insertAfter add new z layer and insert it after existing one" | |
7c3ef2f7 | 13855 | "\n\t\t: -delete delete z layer" |
13856 | "\n\t\t: -get print sequence of z layers" | |
13857 | "\n\t\t: -settings print status of z layer settings" | |
13858 | "\n\t\t: -disable disables given setting" | |
13859 | "\n\t\t: -enable enables given setting", | |
59f45b7c | 13860 | __FILE__,VZLayer,group); |
20637bd2 | 13861 | theCommands.Add("vlayerline", |
13862 | "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]", | |
13863 | __FILE__,VLayerLine,group); | |
79931835 | 13864 | theCommands.Add("vgrid", |
13865 | "vgrid [off] [-type {rect|circ}] [-mode {line|point}] [-origin X Y] [-rotAngle Angle] [-zoffset DZ]" | |
13866 | "\n\t\t: [-step X Y] [-size DX DY]" | |
13867 | "\n\t\t: [-step StepRadius NbDivisions] [-radius Radius]", | |
2bd4c032 | 13868 | __FILE__, VGrid, group); |
c40b7d58 | 13869 | theCommands.Add ("vpriviledgedplane", |
13870 | "vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]" | |
13871 | "\n\t\t: Ox, Oy, Oz - plane origin" | |
13872 | "\n\t\t: Nx, Ny, Nz - plane normal direction" | |
13873 | "\n\t\t: Xx, Xy, Xz - plane x-reference axis direction" | |
13874 | "\n\t\t: Sets or prints viewer's priviledged plane geometry.", | |
13875 | __FILE__, VPriviledgedPlane, group); | |
f25b82d6 | 13876 | theCommands.Add ("vconvert", |
13877 | "vconvert v [Mode={window|view}]" | |
13878 | "\n\t\t: vconvert x y [Mode={window|view|grid|ray}]" | |
13879 | "\n\t\t: vconvert x y z [Mode={window|grid}]" | |
13880 | "\n\t\t: window - convert to window coordinates, pixels" | |
13881 | "\n\t\t: view - convert to view projection plane" | |
13882 | "\n\t\t: grid - convert to model coordinates, given on grid" | |
4551e1be | 13883 | "\n\t\t: ray - convert projection ray to model coordinates" |
f25b82d6 | 13884 | "\n\t\t: - vconvert v window : convert view to window;" |
13885 | "\n\t\t: - vconvert v view : convert window to view;" | |
13886 | "\n\t\t: - vconvert x y window : convert view to window;" | |
13887 | "\n\t\t: - vconvert x y view : convert window to view;" | |
13888 | "\n\t\t: - vconvert x y : convert window to model;" | |
13889 | "\n\t\t: - vconvert x y grid : convert window to model using grid;" | |
13890 | "\n\t\t: - vconvert x y ray : convert window projection line to model;" | |
13891 | "\n\t\t: - vconvert x y z window : convert model to window;" | |
13892 | "\n\t\t: - vconvert x y z grid : convert view to model using grid;" | |
13893 | "\n\t\t: Converts the given coordinates to window/view/model space.", | |
13894 | __FILE__, VConvert, group); | |
208e6839 | 13895 | theCommands.Add ("vfps", |
e084dbbc | 13896 | "vfps [framesNb=100] [-duration seconds] : estimate average frame rate for active view", |
208e6839 | 13897 | __FILE__, VFps, group); |
b5ac8292 | 13898 | theCommands.Add ("vstereo", |
f978241f | 13899 | "vstereo [0|1] [-mode Mode] [-reverse {0|1}]" |
b40cdc2b | 13900 | "\n\t\t: [-mirrorComposer] [-hmdfov2d AngleDegrees] [-unitFactor MetersFactor]" |
f978241f | 13901 | "\n\t\t: [-anaglyph Filter]" |
b40cdc2b | 13902 | "\n\t\t: Control stereo output mode." |
13903 | "\n\t\t: When -mirrorComposer is specified, VR rendered frame will be mirrored in window (debug)." | |
13904 | "\n\t\t: Parameter -unitFactor specifies meters scale factor for mapping VR input." | |
13905 | "\n\t\t: Available modes for -mode:" | |
f978241f | 13906 | "\n\t\t: quadBuffer - OpenGL QuadBuffer stereo," |
13907 | "\n\t\t: requires driver support." | |
13908 | "\n\t\t: Should be called BEFORE vinit!" | |
13909 | "\n\t\t: anaglyph - Anaglyph glasses" | |
13910 | "\n\t\t: rowInterlaced - row-interlaced display" | |
13911 | "\n\t\t: columnInterlaced - column-interlaced display" | |
13912 | "\n\t\t: chessBoard - chess-board output" | |
13913 | "\n\t\t: sideBySide - horizontal pair" | |
13914 | "\n\t\t: overUnder - vertical pair" | |
b40cdc2b | 13915 | "\n\t\t: openVR - OpenVR (HMD)" |
f978241f | 13916 | "\n\t\t: Available Anaglyph filters for -anaglyph:" |
13917 | "\n\t\t: redCyan, redCyanSimple, yellowBlue, yellowBlueSimple," | |
13918 | "\n\t\t: greenMagentaSimple", | |
b5ac8292 | 13919 | __FILE__, VStereo, group); |
f0430952 | 13920 | theCommands.Add ("vmemgpu", |
13921 | "vmemgpu [f]: print system-dependent GPU memory information if available;" | |
13922 | " with f option returns free memory in bytes", | |
13923 | __FILE__, VMemGpu, group); | |
85e096c3 | 13924 | theCommands.Add ("vreadpixel", |
ba00aab7 | 13925 | "vreadpixel xPixel yPixel [{rgb|rgba|sRGB|sRGBa|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]" |
85e096c3 | 13926 | " : Read pixel value for active view", |
13927 | __FILE__, VReadPixel, group); | |
692613e5 | 13928 | theCommands.Add("diffimage", |
fd3f6bd0 | 13929 | "diffimage imageFile1 imageFile2 [diffImageFile]" |
13930 | "\n\t\t: [-toleranceOfColor {0..1}=0] [-blackWhite {on|off}=off] [-borderFilter {on|off}=off]" | |
13931 | "\n\t\t: [-display viewName prsName1 prsName2 prsNameDiff] [-exitOnClose] [-closeOnEscape]" | |
13932 | "\n\t\t: Compare two images by content and generate difference image." | |
13933 | "\n\t\t: When -exitOnClose is specified, closing the view will exit application." | |
13934 | "\n\t\t: When -closeOnEscape is specified, view will be closed on pressing Escape.", | |
692613e5 | 13935 | __FILE__, VDiffImage, group); |
4754e164 | 13936 | theCommands.Add ("vselect", |
e76471b5 | 13937 | "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [-replace|-replaceextra|-xor|-add|-remove]\n" |
4754e164 | 13938 | "- emulates different types of selection:\n" |
13939 | "- 1) single click selection\n" | |
13940 | "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n" | |
13941 | "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n" | |
a24a7821 | 13942 | "- 4) -allowoverlap manages overlap and inclusion detection in rectangular and polygonal selection.\n" |
13943 | " If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined \n" | |
13944 | " rectangle or polygon will be detected, otherwise algorithm will chose only fully included sensitives.\n" | |
13945 | " Default behavior is to detect only full inclusion. (partial inclusion - overlap - is not allowed by default)\n" | |
e76471b5 | 13946 | "- 5) selection scheme replace, replaceextra, xor, add or remove (replace by default)", |
4754e164 | 13947 | __FILE__, VSelect, group); |
13948 | theCommands.Add ("vmoveto", | |
8a590580 | 13949 | "vmoveto [x y] [-reset]" |
13950 | "\n\t\t: Emulates cursor movement to pixel position (x,y)." | |
13951 | "\n\t\t: -reset resets current highlighting", | |
4754e164 | 13952 | __FILE__, VMoveTo, group); |
0461e7fd | 13953 | theCommands.Add ("vselaxis", |
13954 | "vselaxis x y z dx dy dz [-onlyTop 0|1] [-display Name] [-showNormal 0|1]" | |
13955 | "\n\t\t: Provides intersection by given axis and print result intersection points" | |
13956 | "\n\t\t: -onlyTop switches On/Off mode to find only top point or all" | |
13957 | "\n\t\t: -display Name displays intersecting axis and result intersection points for debug goals" | |
13958 | "\n\t\t: -showNormal adds displaying of normal in intersection point or not", | |
13959 | __FILE__, VSelectByAxis, group); | |
1beb58d7 | 13960 | theCommands.Add ("vviewparams", |
13961 | "vviewparams [-args] [-scale [s]]" | |
13962 | "\n\t\t: [-eye [x y z]] [-at [x y z]] [-up [x y z]]" | |
13963 | "\n\t\t: [-proj [x y z]] [-center x y] [-size sx]" | |
13964 | "\n\t\t: Manage current view parameters or prints all" | |
13965 | "\n\t\t: current values when called without argument." | |
13966 | "\n\t\t: -scale [s] prints or sets viewport relative scale" | |
13967 | "\n\t\t: -eye [x y z] prints or sets eye location" | |
13968 | "\n\t\t: -at [x y z] prints or sets center of look" | |
13969 | "\n\t\t: -up [x y z] prints or sets direction of up vector" | |
13970 | "\n\t\t: -proj [x y z] prints or sets direction of look" | |
13971 | "\n\t\t: -center x y sets location of center of the screen in pixels" | |
13972 | "\n\t\t: -size [sx] prints viewport projection width and height sizes" | |
13973 | "\n\t\t: or changes the size of its maximum dimension" | |
13974 | "\n\t\t: -args prints vviewparams arguments for restoring current view", | |
197ac94e | 13975 | __FILE__, VViewParams, group); |
1beb58d7 | 13976 | |
2e93433e | 13977 | theCommands.Add("v2dmode", |
13978 | "v2dmode [-name viewName] [-mode {-on|-off}=-on]" | |
13979 | "\n\t\t: name - name of existing view, if not defined, the active view is changed" | |
13980 | "\n\t\t: mode - switches On/Off rotation mode" | |
13981 | "\n\t\t: Set 2D mode of the active viewer manipulating. The following mouse and key actions are disabled:" | |
13982 | "\n\t\t: - rotation of the view by 3rd mouse button with Ctrl active" | |
13983 | "\n\t\t: - set view projection using key buttons: A/D/T/B/L/R for AXO, Reset, Top, Bottom, Left, Right" | |
13984 | "\n\t\t: View camera position might be changed only by commands.", | |
13985 | __FILE__, V2DMode, group); | |
13986 | ||
1beb58d7 | 13987 | theCommands.Add("vanimation", "Alias for vanim", |
13988 | __FILE__, VAnimation, group); | |
13989 | ||
13990 | theCommands.Add("vanim", | |
13991 | "List existing animations:" | |
13992 | "\n\t\t: vanim" | |
13993 | "\n\t\t: Animation playback:" | |
8f709595 | 13994 | "\n\t\t: vanim name {-play|-resume|-pause|-stop} [playFrom [playDuration]]" |
13995 | "\n\t\t: [-speed Coeff] [-freeLook] [-noPauseOnClick] [-lockLoop]" | |
1beb58d7 | 13996 | "\n\t\t: -speed playback speed (1.0 is normal speed)" |
13997 | "\n\t\t: -freeLook skip camera animations" | |
8f709595 | 13998 | "\n\t\t: -noPauseOnClick do not pause animation on mouse click" |
1beb58d7 | 13999 | "\n\t\t: -lockLoop disable any interactions" |
14000 | "\n\t\t:" | |
14001 | "\n\t\t: Animation definition:" | |
14002 | "\n\t\t: vanim Name/sub/name [-clear] [-delete]" | |
14003 | "\n\t\t: [start TimeSec] [duration TimeSec]" | |
14004 | "\n\t\t:" | |
14005 | "\n\t\t: Animation name defined in path-style (anim/name or anim.name)" | |
14006 | "\n\t\t: specifies nested animations." | |
14007 | "\n\t\t: There is no syntax to explicitly add new animation," | |
14008 | "\n\t\t: and all non-existing animations within the name will be" | |
14009 | "\n\t\t: implicitly created on first use (including parents)." | |
14010 | "\n\t\t:" | |
14011 | "\n\t\t: Each animation might define the SINGLE action (see below)," | |
14012 | "\n\t\t: like camera transition, object transformation or custom callback." | |
14013 | "\n\t\t: Child animations can be used for defining concurrent actions." | |
14014 | "\n\t\t:" | |
14015 | "\n\t\t: Camera animation:" | |
14016 | "\n\t\t: vanim name -view [-eye1 X Y Z] [-eye2 X Y Z]" | |
14017 | "\n\t\t: [-at1 X Y Z] [-at2 X Y Z]" | |
14018 | "\n\t\t: [-up1 X Y Z] [-up2 X Y Z]" | |
14019 | "\n\t\t: [-scale1 Scale] [-scale2 Scale]" | |
14020 | "\n\t\t: -eyeX camera Eye positions pair (start and end)" | |
14021 | "\n\t\t: -atX camera Center positions pair" | |
14022 | "\n\t\t: -upX camera Up directions pair" | |
14023 | "\n\t\t: -scaleX camera Scale factors pair" | |
14024 | "\n\t\t: Object animation:" | |
14025 | "\n\t\t: vanim name -object [-loc1 X Y Z] [-loc2 X Y Z]" | |
14026 | "\n\t\t: [-rot1 QX QY QZ QW] [-rot2 QX QY QZ QW]" | |
14027 | "\n\t\t: [-scale1 Scale] [-scale2 Scale]" | |
14028 | "\n\t\t: -locX object Location points pair (translation)" | |
14029 | "\n\t\t: -rotX object Orientations pair (quaternions)" | |
14030 | "\n\t\t: -scaleX object Scale factors pair (quaternions)" | |
14031 | "\n\t\t: Custom callback:" | |
14032 | "\n\t\t: vanim name -invoke \"Command Arg1 Arg2 %Pts %LocalPts %Normalized ArgN\"" | |
14033 | "\n\t\t: %Pts overall animation presentation timestamp" | |
14034 | "\n\t\t: %LocalPts local animation timestamp" | |
14035 | "\n\t\t: %Normalized local animation normalized value in range 0..1" | |
08f8a185 | 14036 | "\n\t\t:" |
14037 | "\n\t\t: Video recording:" | |
14038 | "\n\t\t: vanim name -record FileName [Width Height] [-fps FrameRate=24]" | |
14039 | "\n\t\t: [-format Format] [-vcodec Codec] [-pix_fmt PixelFormat]" | |
14040 | "\n\t\t: [-crf Value] [-preset Preset]" | |
14041 | "\n\t\t: -fps video framerate" | |
14042 | "\n\t\t: -format file format, container (matroska, etc.)" | |
14043 | "\n\t\t: -vcodec video codec identifier (ffv1, mjpeg, etc.)" | |
14044 | "\n\t\t: -pix_fmt image pixel format (yuv420p, rgb24, etc.)" | |
14045 | "\n\t\t: -crf constant rate factor (specific to codec)" | |
8f709595 | 14046 | "\n\t\t: -preset codec parameters preset (specific to codec)", |
1beb58d7 | 14047 | __FILE__, VAnimation, group); |
14048 | ||
4754e164 | 14049 | theCommands.Add("vchangeselected", |
dc3fe572 | 14050 | "vchangeselected shape" |
4754e164 | 14051 | "- adds to shape to selection or remove one from it", |
14052 | __FILE__, VChangeSelected, group); | |
4754e164 | 14053 | theCommands.Add ("vnbselected", |
faea8b40 | 14054 | "vnbselected" |
14055 | "\n\t\t: Returns number of selected objects", __FILE__, VNbSelected, group); | |
6b62b2da | 14056 | theCommands.Add ("vcamera", |
30a1b24e | 14057 | "vcamera [PrsName] [-ortho] [-projtype]" |
6b62b2da | 14058 | "\n\t\t: [-persp]" |
14059 | "\n\t\t: [-fovy [Angle]] [-distance [Distance]]" | |
14060 | "\n\t\t: [-stereo] [-leftEye] [-rightEye]" | |
14061 | "\n\t\t: [-iod [Distance]] [-iodType [absolute|relative]]" | |
14062 | "\n\t\t: [-zfocus [Value]] [-zfocusType [absolute|relative]]" | |
b40cdc2b | 14063 | "\n\t\t: [-fov2d [Angle]] [-lockZup {0|1}]" |
14064 | "\n\t\t: [-xrPose base|head=base]" | |
30a1b24e | 14065 | "\n\t\t: Manages camera parameters." |
4551e1be | 14066 | "\n\t\t: Displays frustum when presentation name PrsName is specified." |
6b62b2da | 14067 | "\n\t\t: Prints current value when option called without argument." |
14068 | "\n\t\t: Orthographic camera:" | |
14069 | "\n\t\t: -ortho activate orthographic projection" | |
14070 | "\n\t\t: Perspective camera:" | |
14071 | "\n\t\t: -persp activate perspective projection (mono)" | |
14072 | "\n\t\t: -fovy field of view in y axis, in degrees" | |
b40cdc2b | 14073 | "\n\t\t: -fov2d field of view limit for 2d on-screen elements" |
6b62b2da | 14074 | "\n\t\t: -distance distance of eye from camera center" |
b40cdc2b | 14075 | "\n\t\t: -lockZup lock Z up (tunrtable mode)" |
6b62b2da | 14076 | "\n\t\t: Stereoscopic camera:" |
14077 | "\n\t\t: -stereo perspective projection (stereo)" | |
14078 | "\n\t\t: -leftEye perspective projection (left eye)" | |
14079 | "\n\t\t: -rightEye perspective projection (right eye)" | |
14080 | "\n\t\t: -iod intraocular distance value" | |
14081 | "\n\t\t: -iodType distance type, absolute or relative" | |
14082 | "\n\t\t: -zfocus stereographic focus value" | |
14083 | "\n\t\t: -zfocusType focus type, absolute or relative", | |
14084 | __FILE__, VCamera, group); | |
b5ac8292 | 14085 | theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n" |
197ac94e | 14086 | "- vautozfit [on={1|0}] [scale]\n" |
14087 | " Prints or changes parameters of automatic z-fit mode:\n" | |
14088 | " \"on\" - turns automatic z-fit on or off\n" | |
14089 | " \"scale\" - specifies factor to scale computed z range.\n", | |
14090 | __FILE__, VAutoZFit, group); | |
b5ac8292 | 14091 | theCommands.Add ("vzrange", "command to manually access znear and zfar values\n" |
14092 | " vzrange - without parameters shows current values\n" | |
14093 | " vzrange [znear] [zfar] - applies provided values to view", | |
14094 | __FILE__,VZRange, group); | |
4754e164 | 14095 | theCommands.Add("vsetviewsize", |
14096 | "vsetviewsize size", | |
14097 | __FILE__,VSetViewSize,group); | |
14098 | theCommands.Add("vmoveview", | |
14099 | "vmoveview Dx Dy Dz [Start = 1|0]", | |
14100 | __FILE__,VMoveView,group); | |
14101 | theCommands.Add("vtranslateview", | |
14102 | "vtranslateview Dx Dy Dz [Start = 1|0)]", | |
14103 | __FILE__,VTranslateView,group); | |
14104 | theCommands.Add("vturnview", | |
14105 | "vturnview Ax Ay Az [Start = 1|0]", | |
14106 | __FILE__,VTurnView,group); | |
269294d6 | 14107 | theCommands.Add("vtextureenv", |
14108 | "Enables or disables environment mapping in the 3D view, loading the texture from the given standard " | |
14109 | "or user-defined file and optionally applying texture mapping parameters\n" | |
14110 | " Usage:\n" | |
14111 | " vtextureenv off - disables environment mapping\n" | |
14112 | " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n" | |
14113 | " std_texture = (0..7)\n" | |
14114 | " rep = {clamp|repeat}\n" | |
14115 | " mod = {decal|modulate}\n" | |
14116 | " flt = {nearest|bilinear|trilinear}\n" | |
14117 | " ss, st - scale factors for s and t texture coordinates\n" | |
14118 | " ts, tt - translation for s and t texture coordinates\n" | |
14119 | " rot - texture rotation angle in degrees", | |
14120 | __FILE__, VTextureEnv, group); | |
1eeef710 | 14121 | theCommands.Add("vhlr", |
14122 | "vhlr {on|off} [-showHidden={1|0}] [-algoType={algo|polyAlgo}] [-noupdate]" | |
14123 | "\n\t\t: Hidden Line Removal algorithm." | |
14124 | "\n\t\t: -showHidden if set ON, hidden lines are drawn as dotted ones" | |
14125 | "\n\t\t: -algoType type of HLR algorithm.\n", | |
0a768f56 | 14126 | __FILE__,VHLR,group); |
1eeef710 | 14127 | theCommands.Add("vhlrtype", |
14128 | "vhlrtype {algo|polyAlgo} [shape_1 ... shape_n] [-noupdate]" | |
14129 | "\n\t\t: Changes the type of HLR algorithm using for shapes:" | |
14130 | "\n\t\t: 'algo' - exact HLR algorithm is applied" | |
14131 | "\n\t\t: 'polyAlgo' - polygonal HLR algorithm is applied" | |
14132 | "\n\t\t: If shapes are not given - option is applied to all shapes in the view", | |
0a768f56 | 14133 | __FILE__,VHLRType,group); |
3e05329c | 14134 | theCommands.Add("vclipplane", |
14135 | "vclipplane planeName [{0|1}]" | |
25c35042 | 14136 | "\n\t\t: [-equation1 A B C D]" |
14137 | "\n\t\t: [-equation2 A B C D]" | |
14138 | "\n\t\t: [-boxInterior MinX MinY MinZ MaxX MaxY MaxZ]" | |
32ca7711 | 14139 | "\n\t\t: [-set|-unset|-setOverrideGlobal [objects|views]]" |
3e05329c | 14140 | "\n\t\t: [-maxPlanes]" |
14141 | "\n\t\t: [-capping {0|1}]" | |
1b661a81 | 14142 | "\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]" |
3e05329c | 14143 | "\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]" |
14144 | "\n\t\t: [-texRotate Angle]" | |
14145 | "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]" | |
14146 | "\n\t\t: [-useObjShader {0|1}]" | |
14147 | "\n\t\t: Clipping planes management:" | |
14148 | "\n\t\t: -maxPlanes print plane limit for view" | |
14149 | "\n\t\t: -delete delete plane with given name" | |
14150 | "\n\t\t: {off|on|0|1} turn clipping on/off" | |
14151 | "\n\t\t: -set|-unset set/unset plane for Object or View list;" | |
14152 | "\n\t\t: applied to active View when list is omitted" | |
14153 | "\n\t\t: -equation A B C D change plane equation" | |
14154 | "\n\t\t: -clone SourcePlane NewPlane clone the plane definition." | |
14155 | "\n\t\t: Capping options:" | |
14156 | "\n\t\t: -capping {off|on|0|1} turn capping on/off" | |
14157 | "\n\t\t: -color R G B set capping color" | |
1b661a81 | 14158 | "\n\t\t: -transparency Value set capping transparency 0..1" |
3e05329c | 14159 | "\n\t\t: -texName Texture set capping texture" |
14160 | "\n\t\t: -texScale SX SY set capping tex scale" | |
14161 | "\n\t\t: -texOrigin TX TY set capping tex origin" | |
14162 | "\n\t\t: -texRotate Angle set capping tex rotation" | |
14163 | "\n\t\t: -hatch {on|off|ID} set capping hatching mask" | |
14164 | "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object" | |
14165 | "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object" | |
14166 | "\n\t\t: -useObjShader {off|on|0|1} use shader program of object", | |
14167 | __FILE__, VClipPlane, group); | |
392ac980 | 14168 | theCommands.Add("vdefaults", |
4c513386 | 14169 | "vdefaults [-absDefl value]" |
14170 | "\n\t\t: [-devCoeff value]" | |
14171 | "\n\t\t: [-angDefl value]" | |
14172 | "\n\t\t: [-autoTriang {off/on | 0/1}]" | |
14173 | , __FILE__, VDefaults, group); | |
12381341 | 14174 | theCommands.Add("vlight", |
06d40093 | 14175 | "vlight [lightName] [-noupdate]" |
14176 | "\n\t\t: [-clear|-defaults] [-layer Id] [-local|-global] [-disable|-enable]" | |
14177 | "\n\t\t: [-type {ambient|directional|spotlight|positional}] [-name value]" | |
14178 | "\n\t\t: [-position X Y Z] [-direction X Y Z] [-color colorName] [-intensity value]" | |
14179 | "\n\t\t: [-headlight 0|1] [-castShadows 0|1]" | |
14180 | "\n\t\t: [-range value] [-constAttenuation value] [-linearAttenuation value]" | |
14181 | "\n\t\t: [-spotExponent value] [-spotAngle angleDeg]" | |
14182 | "\n\t\t: [-smoothAngle value] [-smoothRadius value]" | |
14183 | "\n\t\t: [-display] [-showName 1|0] [-showRange 1|0] [-prsZoomable 1|0] [-prsSize Value]" | |
a3b2aaef | 14184 | "\n\t\t: [-arcSize Value]" |
06d40093 | 14185 | "\n\t\t: Command manages light sources. Without arguments shows list of lights." |
14186 | "\n\t\t: Arguments affecting the list of defined/active lights:" | |
14187 | "\n\t\t: -clear remove all light sources" | |
14188 | "\n\t\t: -defaults defines two standard light sources" | |
14189 | "\n\t\t: -reset resets light source parameters to default values" | |
14190 | "\n\t\t: -type sets type of light source" | |
14191 | "\n\t\t: -name sets new name to light source" | |
14192 | "\n\t\t: -global assigns light source to all views (default state)" | |
14193 | "\n\t\t: -local assigns light source to active view" | |
14194 | "\n\t\t: -zlayer assigns light source to specified Z-Layer" | |
14195 | "\n\t\t: Ambient light parameters:" | |
14196 | "\n\t\t: -color sets (normalized) light color" | |
14197 | "\n\t\t: -intensity sets intensity of light source, 1.0 by default;" | |
14198 | "\n\t\t: affects also environment cubemap intensity" | |
14199 | "\n\t\t: Point light parameters:" | |
14200 | "\n\t\t: -color sets (normalized) light color" | |
14201 | "\n\t\t: -intensity sets PBR intensity" | |
14202 | "\n\t\t: -range sets clamping distance" | |
14203 | "\n\t\t: -constAtten (obsolete) sets constant attenuation factor" | |
14204 | "\n\t\t: -linearAtten (obsolete) sets linear attenuation factor" | |
14205 | "\n\t\t: -smoothRadius sets PBR smoothing radius" | |
14206 | "\n\t\t: Directional light parameters:" | |
14207 | "\n\t\t: -color sets (normalized) light color" | |
14208 | "\n\t\t: -intensity sets PBR intensity" | |
14209 | "\n\t\t: -direction sets direction" | |
14210 | "\n\t\t: -headlight sets headlight flag" | |
14211 | "\n\t\t: -castShadows enables/disables shadow casting" | |
14212 | "\n\t\t: -smoothAngle sets PBR smoothing angle (in degrees) within 0..90 range" | |
14213 | "\n\t\t: Spot light parameters:" | |
14214 | "\n\t\t: -color sets (normalized) light color" | |
14215 | "\n\t\t: -intensity sets PBR intensity" | |
14216 | "\n\t\t: -range sets clamping distance" | |
14217 | "\n\t\t: -position sets position" | |
14218 | "\n\t\t: -direction sets direction" | |
14219 | "\n\t\t: -spotAngle sets spotlight angle" | |
14220 | "\n\t\t: -spotExp sets spotlight exponenta" | |
14221 | "\n\t\t: -headlight sets headlight flag" | |
14222 | "\n\t\t: -constAtten (obsolete) sets constant attenuation factor" | |
14223 | "\n\t\t: -linearAtten (obsolete) sets linear attenuation factor" | |
14224 | "\n\t\t: Light presentation parameters:" | |
14225 | "\n\t\t: -display adds light source presentation" | |
14226 | "\n\t\t: -showName shows/hides the name of light source; 1 by default" | |
14227 | "\n\t\t: -showRange shows/hides the range of spot/positional light source; 1 by default" | |
14228 | "\n\t\t: -prsZoomable makes light presentation zoomable/non-zoomable" | |
a3b2aaef | 14229 | "\n\t\t: -prsDraggable makes light presentation draggable/non-draggable" |
06d40093 | 14230 | "\n\t\t: -prsSize sets light presentation size" |
a3b2aaef | 14231 | "\n\t\t: -arcSize sets arc presentation size(in pixels) for rotation directional light source; 25 by default" |
06d40093 | 14232 | "\n\t\t: Examples:" |
14233 | "\n\t\t: vlight redlight -type POSITIONAL -headlight 1 -pos 0 1 1 -color RED" | |
14234 | "\n\t\t: vlight redlight -delete", | |
12381341 | 14235 | __FILE__, VLight, group); |
67312b79 | 14236 | theCommands.Add("vpbrenv", |
14237 | "vpbrenv -clear|-generate" | |
14238 | "\n\t\t: Clears or generates PBR environment map of active view." | |
14239 | "\n\t\t: -clear clears PBR environment (fills by white color)" | |
14240 | "\n\t\t: -generate generates PBR environment from current background cubemap", | |
14241 | __FILE__, VPBREnvironment, group); | |
6b62b2da | 14242 | theCommands.Add("vraytrace", |
14243 | "vraytrace [0|1]" | |
189f85a3 | 14244 | "\n\t\t: Turns on/off ray-tracing renderer." |
6b62b2da | 14245 | "\n\t\t: 'vraytrace 0' alias for 'vrenderparams -raster'." |
14246 | "\n\t\t: 'vraytrace 1' alias for 'vrenderparams -rayTrace'.", | |
14247 | __FILE__, VRenderParams, group); | |
bc8c79bb | 14248 | theCommands.Add("vrenderparams", |
4c7a3fae | 14249 | "\n\t\t: Manages rendering parameters, affecting visual appearance, quality and performance." |
14250 | "\n\t\t: Should be applied taking into account GPU hardware capabilities and performance." | |
14251 | "\n\t\t: Common parameters:" | |
14252 | "\n\t\t: vrenderparams [-raster] [-shadingModel {unlit|facet|gouraud|phong|pbr|pbr_facet}=gouraud]" | |
d37aef5c | 14253 | "\n\t\t: [-msaa 0..8=0] [-rendScale scale=1]" |
14254 | "\n\t\t: [-resolution value=72] [-fontHinting {off|normal|light}=off]" | |
14255 | "\n\t\t: [-fontAutoHinting {auto|force|disallow}=auto]" | |
c123c310 | 14256 | "\n\t\t: [-oit {off|weight|peel}] [-oit weighted [depthFactor=0.0]] [-oit peeling [nbLayers=4]]" |
d84e8669 | 14257 | "\n\t\t: [-shadows {on|off}=on] [-shadowMapResolution value=1024] [-shadowMapBias value=0.005]" |
4c7a3fae | 14258 | "\n\t\t: [-depthPrePass {on|off}=off] [-alphaToCoverage {on|off}=on]" |
14259 | "\n\t\t: [-frustumCulling {on|off|noupdate}=on] [-lineFeather width=1.0]" | |
14260 | "\n\t\t: [-sync {default|views}] [-reset]" | |
14261 | "\n\t\t: -raster Disables GPU ray-tracing." | |
14262 | "\n\t\t: -shadingModel Controls shading model." | |
14263 | "\n\t\t: -msaa Specifies number of samples for MSAA." | |
14264 | "\n\t\t: -rendScale Rendering resolution scale factor (supersampling, alternative to MSAA)." | |
14265 | "\n\t\t: -resolution Sets new pixels density (PPI) used as text scaling factor." | |
d37aef5c | 14266 | "\n\t\t: -fontHinting Enables/disables font hinting for better readability on low-resolution screens." |
14267 | "\n\t\t: -fontAutoHinting Manages font autohinting." | |
4c7a3fae | 14268 | "\n\t\t: -lineFeather Sets line feather factor while displaying mesh edges." |
14269 | "\n\t\t: -alphaToCoverage Enables/disables alpha to coverage (needs MSAA)." | |
14270 | "\n\t\t: -oit Enables/disables order-independent transparency (OIT) rendering;" | |
c123c310 | 14271 | "\n\t\t: off unordered transparency (but opaque objects implicitly draw first);" |
14272 | "\n\t\t: weighted weight OIT is managed by depth weight factor 0.0..1.0;" | |
14273 | "\n\t\t: peeling depth peeling OIT is managed by number of peeling layers." | |
d84e8669 | 14274 | "\n\t\t: -shadows Enables/disables shadows rendering." |
14275 | "\n\t\t: -shadowMapResolution Shadow texture map resolution." | |
14276 | "\n\t\t: -shadowMapBias Shadow map bias." | |
4c7a3fae | 14277 | "\n\t\t: -depthPrePass Enables/disables depth pre-pass." |
14278 | "\n\t\t: -frustumCulling Enables/disables objects frustum clipping or" | |
14279 | "\n\t\t: sets state to check structures culled previously." | |
14280 | "\n\t\t: -sync Sets active View parameters as Viewer defaults / to other Views." | |
14281 | "\n\t\t: -reset Resets active View parameters to Viewer defaults." | |
14282 | "\n\t\t: Diagnostic output (on-screen overlay):" | |
14283 | "\n\t\t: vrenderparams [-perfCounters none|fps|cpu|layers|structures|groups|arrays|triangles|points" | |
14284 | "\n\t\t: |gpuMem|frameTime|basic|extended|full|nofps|skipImmediate]" | |
14285 | "\n\t\t: [-perfUpdateInterval nbSeconds=1] [-perfChart nbFrames=1] [-perfChartMax seconds=0.1]" | |
14286 | "\n\t\t: -perfCounters Show/hide performance counters (flags can be combined)." | |
14287 | "\n\t\t: -perfUpdateInterval Performance counters update interval." | |
14288 | "\n\t\t: -perfChart Show frame timers chart limited by specified number of frames." | |
14289 | "\n\t\t: -perfChartMax Maximum time in seconds with the chart." | |
14290 | "\n\t\t: Ray-Tracing options:" | |
d84e8669 | 14291 | "\n\t\t: vrenderparams [-rayTrace] [-rayDepth {0..10}=3] [-reflections {on|off}=off]" |
4c7a3fae | 14292 | "\n\t\t: [-fsaa {on|off}=off] [-gleam {on|off}=off] [-env {on|off}=off]" |
14293 | "\n\t\t: [-gi {on|off}=off] [-brng {on|off}=off]" | |
14294 | "\n\t\t: [-iss {on|off}=off] [-tileSize {1..4096}=32] [-nbTiles {64..1024}=256]" | |
14295 | "\n\t\t: [-ignoreNormalMap {on|off}=off] [-twoSide {on|off}=off]" | |
14296 | "\n\t\t: [-maxRad {value>0}=30.0]" | |
14297 | "\n\t\t: [-aperture {value>=0}=0.0] [-focal {value>=0.0}=1.0]" | |
14298 | "\n\t\t: [-exposure value=0.0] [-whitePoint value=1.0] [-toneMapping {disabled|filmic}=disabled]" | |
14299 | "\n\t\t: -rayTrace Enables GPU ray-tracing." | |
14300 | "\n\t\t: -rayDepth Defines maximum ray-tracing depth." | |
4c7a3fae | 14301 | "\n\t\t: -reflections Enables/disables specular reflections." |
14302 | "\n\t\t: -fsaa Enables/disables adaptive anti-aliasing." | |
14303 | "\n\t\t: -gleam Enables/disables transparency shadow effects." | |
14304 | "\n\t\t: -gi Enables/disables global illumination effects (Path-Tracing)." | |
14305 | "\n\t\t: -env Enables/disables environment map background." | |
14306 | "\n\t\t: -ignoreNormalMap Enables/disables normal map ignoring during path tracing." | |
14307 | "\n\t\t: -twoSide Enables/disables two-sided BSDF models (PT mode)." | |
14308 | "\n\t\t: -iss Enables/disables adaptive screen sampling (PT mode)." | |
14309 | "\n\t\t: -maxRad Value used for clamping radiance estimation (PT mode)." | |
14310 | "\n\t\t: -tileSize Specifies size of screen tiles in ISS mode (32 by default)." | |
14311 | "\n\t\t: -nbTiles Specifies number of screen tiles per Redraw in ISS mode (256 by default)." | |
14312 | "\n\t\t: -aperture Aperture size of perspective camera for depth-of-field effect (0 disables DOF)." | |
14313 | "\n\t\t: -focal Focal distance of perspective camera for depth-of-field effect." | |
14314 | "\n\t\t: -exposure Exposure value for tone mapping (0.0 value disables the effect)." | |
14315 | "\n\t\t: -whitePoint White point value for filmic tone mapping." | |
14316 | "\n\t\t: -toneMapping Tone mapping mode (disabled, filmic)." | |
14317 | "\n\t\t: PBR environment baking parameters (advanced/debug):" | |
14318 | "\n\t\t: vrenderparams [-pbrEnvPow2size {power>0}=9] [-pbrEnvSMLN {levels>1}=6] [-pbrEnvBP {0..1}=0.99]" | |
14319 | "\n\t\t: [-pbrEnvBDSN {samples>0}=1024] [-pbrEnvBSSN {samples>0}=256]" | |
14320 | "\n\t\t: -pbrEnvPow2size Controls size of IBL maps (real size can be calculates as 2^pbrenvpow2size)." | |
14321 | "\n\t\t: -pbrEnvSMLN Controls number of mipmap levels used in specular IBL map." | |
14322 | "\n\t\t: -pbrEnvBDSN Controls number of samples in Monte-Carlo integration during" | |
14323 | "\n\t\t: diffuse IBL map's sherical harmonics calculation." | |
14324 | "\n\t\t: -pbrEnvBSSN Controls maximum number of samples per mipmap level" | |
14325 | "\n\t\t: in Monte-Carlo integration during specular IBL maps generation." | |
14326 | "\n\t\t: -pbrEnvBP Controls strength of samples number reducing" | |
14327 | "\n\t\t: during specular IBL maps generation (1 disables reducing)." | |
14328 | "\n\t\t: Debug options:" | |
14329 | "\n\t\t: vrenderparams [-issd {on|off}=off] [-rebuildGlsl on|off]" | |
14330 | "\n\t\t: -issd Shows screen sampling distribution in ISS mode." | |
14331 | "\n\t\t: -rebuildGlsl Rebuild Ray-Tracing GLSL programs (for debugging)." | |
14332 | "\n\t\t: -brng Enables/disables blocked RNG (fast coherent PT).", | |
bc8c79bb | 14333 | __FILE__, VRenderParams, group); |
79b544e6 | 14334 | theCommands.Add("vstatprofiler", |
14335 | "\n vstatprofiler [fps|cpu|allLayers|layers|allstructures|structures|groups" | |
14336 | "\n |allArrays|fillArrays|lineArrays|pointArrays|textArrays" | |
a2803f37 | 14337 | "\n |triangles|points|geomMem|textureMem|frameMem" |
79b544e6 | 14338 | "\n |elapsedFrame|cpuFrameAverage|cpuPickingAverage|cpuCullingAverage|cpuDynAverage" |
14339 | "\n |cpuFrameMax|cpuPickingMax|cpuCullingMax|cpuDynMax]" | |
14340 | "\n [-noredraw]" | |
14341 | "\n\t\t: Prints rendering statistics." | |
14342 | "\n\t\t: If there are some parameters - print corresponding statistic counters values," | |
14343 | "\n\t\t: else - print all performance counters set previously." | |
14344 | "\n\t\t: '-noredraw' Flag to avoid additional redraw call and use already collected values.\n", | |
14345 | __FILE__, VStatProfiler, group); | |
49e1a5c7 | 14346 | theCommands.Add ("vplace", |
14347 | "vplace dx dy" | |
14348 | "\n\t\t: Places the point (in pixels) at the center of the window", | |
14349 | __FILE__, VPlace, group); | |
0717ddc1 | 14350 | theCommands.Add("vxrotate", |
14351 | "vxrotate", | |
14352 | __FILE__,VXRotate,group); | |
14353 | ||
625e1958 | 14354 | theCommands.Add("vmanipulator", |
14355 | "\n vmanipulator Name [-attach AISObject | -detach | ...]" | |
14356 | "\n tool to create and manage AIS manipulators." | |
14357 | "\n Options: " | |
14358 | "\n '-attach AISObject' attach manipulator to AISObject" | |
ff6122e0 | 14359 | "\n '-adjustPosition {0|center|location|shapeLocation}' adjust position when attaching" |
625e1958 | 14360 | "\n '-adjustSize {0|1}' adjust size when attaching" |
14361 | "\n '-enableModes {0|1}' enable modes when attaching" | |
bbf3fcde | 14362 | "\n '-view {active | [name of view]}' display manipulator only in defined view," |
14363 | "\n by default it is displayed in all views of the current viewer" | |
625e1958 | 14364 | "\n '-detach' detach manipulator" |
14365 | "\n '-startTransform mouse_x mouse_y' - invoke start of transformation" | |
14366 | "\n '-transform mouse_x mouse_y' - invoke transformation" | |
14367 | "\n '-stopTransform [abort]' - invoke stop of transformation" | |
14368 | "\n '-move x y z' - move attached object" | |
14369 | "\n '-rotate x y z dx dy dz angle' - rotate attached object" | |
14370 | "\n '-scale factor' - scale attached object" | |
14371 | "\n '-autoActivate {0|1}' - set activation on detection" | |
14372 | "\n '-followTranslation {0|1}' - set following translation transform" | |
14373 | "\n '-followRotation {0|1}' - set following rotation transform" | |
f522ce50 | 14374 | "\n '-followDragging {0|1}' - set following dragging transform" |
625e1958 | 14375 | "\n '-gap value' - set gap between sub-parts" |
14376 | "\n '-part axis mode {0|1}' - set visual part" | |
84b904bc | 14377 | "\n '-parts axis mode {0|1}' - set visual part" |
625e1958 | 14378 | "\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator" |
14379 | "\n '-size value' - set size of manipulator" | |
14380 | "\n '-zoomable {0|1}' - set zoom persistence", | |
14381 | __FILE__, VManipulator, group); | |
14382 | ||
8e5fb5ea | 14383 | theCommands.Add("vselprops", |
f838dac4 | 14384 | "\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]" |
8e5fb5ea | 14385 | "\n Customizes selection and dynamic highlight parameters for the whole interactive context:" |
14386 | "\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode" | |
be3d8cbc | 14387 | "\n -autoHighlight {0|1} : disables|enables automatic highlighting in 3D Viewer" |
14388 | "\n -highlightSelected {0|1}: disables|enables highlighting of detected object in selected state" | |
14c4193d | 14389 | "\n -pickStrategy {first|topmost} : defines picking strategy" |
14390 | "\n 'first' to pick first acceptable (default)" | |
14391 | "\n 'topmost' to pick only topmost (and nothing, if topmost is rejected by filters)" | |
8e5fb5ea | 14392 | "\n -pixTol value : sets up pixel tolerance" |
8c36926a | 14393 | "\n -depthTol {uniform|uniformpx} value : sets tolerance for sorting results by depth" |
14394 | "\n -depthTol {sensfactor} : use sensitive factor for sorting results by depth" | |
14395 | "\n -preferClosest {0|1} : sets if depth should take precedence over priority while sorting results" | |
f838dac4 | 14396 | "\n -dispMode dispMode : sets display mode for highlighting" |
14397 | "\n -layer ZLayer : sets ZLayer for highlighting" | |
14398 | "\n -color {name|r g b} : sets highlight color" | |
14399 | "\n -transp value : sets transparency coefficient for highlight" | |
14400 | "\n -material material : sets highlight material" | |
8e5fb5ea | 14401 | "\n -print : prints current state of all mentioned parameters", |
14402 | __FILE__, VSelectionProperties, group); | |
be3d8cbc | 14403 | theCommands.Add ("vhighlightselected", |
14404 | "vhighlightselected [0|1]: alias for vselprops -highlightSelected.\n", | |
14405 | __FILE__, VSelectionProperties, group); | |
8e5fb5ea | 14406 | |
decdee7d | 14407 | theCommands.Add ("vseldump", |
9dd8af26 | 14408 | "vseldump file -type {depth|unnormDepth|object|owner|selMode|entity|entityType|surfNormal}=depth -pickedIndex Index=1" |
b40cdc2b | 14409 | "\n\t\t: [-xrPose base|head=base]" |
decdee7d | 14410 | "\n\t\t: Generate an image based on detection results:" |
14411 | "\n\t\t: depth normalized depth values" | |
14412 | "\n\t\t: unnormDepth unnormalized depth values" | |
14413 | "\n\t\t: object color of detected object" | |
14414 | "\n\t\t: owner color of detected owner" | |
14415 | "\n\t\t: selMode color of selection mode" | |
9dd8af26 | 14416 | "\n\t\t: entity color of detected entity" |
14417 | "\n\t\t: entityType color of detected entity type" | |
114e7a90 | 14418 | "\n\t\t: surfNormal normal direction values", |
decdee7d | 14419 | __FILE__, VDumpSelectionImage, group); |
293211ae | 14420 | |
2108d9a2 | 14421 | theCommands.Add ("vviewcube", |
14422 | "vviewcube name" | |
14423 | "\n\t\t: Displays interactive view manipualtion object." | |
14424 | "\n\t\t: Options: " | |
14425 | "\n\t\t: -reset reset geomertical and visual attributes'" | |
14426 | "\n\t\t: -size Size adapted size of View Cube" | |
14427 | "\n\t\t: -boxSize Size box size" | |
0aeb8984 | 14428 | "\n\t\t: -axes {0|1} show/hide axes (trihedron)" |
2108d9a2 | 14429 | "\n\t\t: -edges {0|1} show/hide edges of View Cube" |
14430 | "\n\t\t: -vertices {0|1} show/hide vertices of View Cube" | |
14431 | "\n\t\t: -Yup {0|1} -Zup {0|1} set Y-up or Z-up view orientation" | |
14432 | "\n\t\t: -color Color color of View Cube" | |
14433 | "\n\t\t: -boxColor Color box color" | |
14434 | "\n\t\t: -boxSideColor Color box sides color" | |
14435 | "\n\t\t: -boxEdgeColor Color box edges color" | |
14436 | "\n\t\t: -boxCornerColor Color box corner color" | |
14437 | "\n\t\t: -textColor Color color of side text of view cube" | |
14438 | "\n\t\t: -innerColor Color inner box color" | |
14439 | "\n\t\t: -transparency Value transparency of object within [0, 1] range" | |
14440 | "\n\t\t: -boxTransparency Value transparency of box within [0, 1] range" | |
0aeb8984 | 14441 | "\n\t\t: -xAxisTextColor Color color of X axis label" |
14442 | "\n\t\t: -yAxisTextColor Color color of Y axis label" | |
14443 | "\n\t\t: -zAxisTextColor Color color of Z axis label" | |
2108d9a2 | 14444 | "\n\t\t: -font Name font name" |
14445 | "\n\t\t: -fontHeight Value font height" | |
14446 | "\n\t\t: -boxFacetExtension Value box facet extension" | |
14447 | "\n\t\t: -boxEdgeGap Value gap between box edges and box sides" | |
14448 | "\n\t\t: -boxEdgeMinSize Value minimal box edge size" | |
14449 | "\n\t\t: -boxCornerMinSize Value minimal box corner size" | |
14450 | "\n\t\t: -axesPadding Value padding between box and arrows" | |
14451 | "\n\t\t: -roundRadius Value relative radius of corners of sides within [0.0, 0.5] range" | |
6466cc9e | 14452 | "\n\t\t: -axesRadius Value radius of axes of the trihedron" |
14453 | "\n\t\t: -axesConeRadius Value radius of the cone (arrow) of the trihedron" | |
14454 | "\n\t\t: -axesSphereRadius Value radius of the sphere (central point) of trihedron" | |
2108d9a2 | 14455 | "\n\t\t: -fixedanimation {0|1} uninterruptible animation loop" |
14456 | "\n\t\t: -duration Seconds animation duration in seconds", | |
14457 | __FILE__, VViewCube, group); | |
14458 | ||
14b741b0 | 14459 | theCommands.Add("vcolorconvert" , |
14460 | "vcolorconvert {from|to} type C1 C2 C2" | |
14461 | "\n\t\t: vcolorconvert from type C1 C2 C2: Converts color from specified color space to linear RGB" | |
14462 | "\n\t\t: vcolorconvert to type R G B: Converts linear RGB color to specified color space" | |
14463 | "\n\t\t: type can be sRGB, HLS, Lab, or Lch", | |
14464 | __FILE__,VColorConvert,group); | |
14465 | theCommands.Add("vcolordiff" , | |
14466 | "vcolordiff R1 G1 B1 R2 G2 B2: returns CIEDE2000 color difference between two RGB colors", | |
14467 | __FILE__,VColorDiff,group); | |
6a2fb7a1 | 14468 | theCommands.Add("vselbvhbuild", |
14469 | "vselbvhbuild [{0|1}] [-nbThreads value] [-wait]" | |
14470 | "\n\t\t: Turns on/off prebuilding of BVH within background thread(s)" | |
14471 | "\n\t\t: -nbThreads number of threads, 1 by default; if < 1 then used (NbLogicalProcessors - 1)" | |
14472 | "\n\t\t: -wait waits for building all of BVH", | |
14473 | __FILE__,VSelBvhBuild,group); | |
2108d9a2 | 14474 | } |