Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-07-23 |
2 | // Created by: Henri JEANNIN | |
3 | // Copyright (c) 1997-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. | |
7fd59977 | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
b311480e | 16 | |
7fd59977 | 17 | #include <Standard_Stream.hxx> |
18 | ||
19 | #include <ViewerTest.hxx> | |
189f85a3 | 20 | #include <ViewerTest_CmdParser.hxx> |
1a96d253 | 21 | #include <ViewerTest_AutoUpdater.hxx> |
4e18052b | 22 | |
3a4a3962 | 23 | #include <Draw.hxx> |
7fd59977 | 24 | #include <TopTools_HArray1OfShape.hxx> |
900f7229 | 25 | #include <TColStd_HSequenceOfAsciiString.hxx> |
b6d587e3 | 26 | #include <TColStd_MapOfTransient.hxx> |
7fd59977 | 27 | #include <TopExp_Explorer.hxx> |
28 | #include <BRepAdaptor_Curve.hxx> | |
29 | #include <StdSelect_ShapeTypeFilter.hxx> | |
ad3217cd | 30 | #include <AIS_ColoredShape.hxx> |
7fd59977 | 31 | #include <AIS_InteractiveObject.hxx> |
32 | #include <AIS_Trihedron.hxx> | |
33 | #include <AIS_Axis.hxx> | |
7fd59977 | 34 | #include <AIS_SignatureFilter.hxx> |
35 | #include <AIS_ListOfInteractive.hxx> | |
99c56d44 | 36 | #include <Aspect_InteriorStyle.hxx> |
34db9c00 | 37 | #include <Aspect_Window.hxx> |
1a96d253 | 38 | #include <Aspect_XRSession.hxx> |
99c56d44 | 39 | #include <Graphic3d_AspectFillArea3d.hxx> |
1c88cbaf | 40 | #include <Graphic3d_AspectLine3d.hxx> |
a1954302 | 41 | #include <Graphic3d_CStructure.hxx> |
633084b8 | 42 | #include <Graphic3d_Texture2D.hxx> |
43 | #include <Graphic3d_Texture3D.hxx> | |
cc8cbabe | 44 | #include <Graphic3d_GraphicDriver.hxx> |
98e6c6d1 | 45 | #include <Graphic3d_MediaTextureSet.hxx> |
692613e5 | 46 | #include <Image_AlienPixMap.hxx> |
23fe70ec | 47 | #include <Message.hxx> |
a6dee93d | 48 | #include <OSD_File.hxx> |
6262338c | 49 | #include <Prs3d_Drawer.hxx> |
99c56d44 | 50 | #include <Prs3d_ShadingAspect.hxx> |
1c88cbaf | 51 | #include <Prs3d_IsoAspect.hxx> |
6262338c | 52 | #include <Prs3d_PointAspect.hxx> |
1a96d253 | 53 | #include <PrsDim_Relation.hxx> |
8e7c8ccf | 54 | #include <Select3D_SensitiveWire.hxx> |
8b9a309b | 55 | #include <Select3D_SensitivePrimitiveArray.hxx> |
73dc2d3a | 56 | #include <Select3D_SensitiveTriangulation.hxx> |
8e7c8ccf | 57 | #include <SelectMgr_EntityOwner.hxx> |
58 | #include <StdSelect_BRepOwner.hxx> | |
59 | #include <StdSelect_ViewerSelector3d.hxx> | |
cb78155f | 60 | #include <TopTools_MapOfShape.hxx> |
1a96d253 | 61 | #include <V3d_Viewer.hxx> |
7fd59977 | 62 | |
7fd59977 | 63 | #include <stdio.h> |
7fd59977 | 64 | |
65 | #include <Draw_Interpretor.hxx> | |
66 | #include <TCollection_AsciiString.hxx> | |
67 | #include <Draw_PluginMacro.hxx> | |
7fd59977 | 68 | |
7fd59977 | 69 | extern int ViewerMainLoop(Standard_Integer argc, const char** argv); |
70 | ||
7fd59977 | 71 | #include <Quantity_Color.hxx> |
72 | #include <Quantity_NameOfColor.hxx> | |
73 | ||
74 | #include <Graphic3d_NameOfMaterial.hxx> | |
75 | ||
6262338c | 76 | #define DEFAULT_COLOR Quantity_NOC_GOLDENROD |
77 | #define DEFAULT_FREEBOUNDARY_COLOR Quantity_NOC_GREEN | |
a966542b | 78 | #define DEFAULT_MATERIAL Graphic3d_NameOfMaterial_Brass |
7fd59977 | 79 | |
792c785c | 80 | //======================================================================= |
f9b30c0d | 81 | // function : GetColorFromName |
82 | // purpose : get the Quantity_NameOfColor from a string | |
792c785c | 83 | //======================================================================= |
7fd59977 | 84 | |
792c785c | 85 | Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName) |
86 | { | |
8316c618 | 87 | Quantity_NameOfColor aColor = DEFAULT_COLOR; |
88 | Quantity_Color::ColorFromName (theName, aColor); | |
89 | return aColor; | |
7fd59977 | 90 | } |
91 | ||
536d98e2 | 92 | //======================================================================= |
dae2a922 | 93 | // function : ParseColor |
f9b30c0d | 94 | // purpose : |
536d98e2 | 95 | //======================================================================= |
dae2a922 | 96 | Standard_Integer ViewerTest::ParseColor (const Standard_Integer theArgNb, |
f9b30c0d | 97 | const char* const* const theArgVec, |
dae2a922 | 98 | Quantity_ColorRGBA& theColor) |
536d98e2 | 99 | { |
dae2a922 | 100 | return Draw::ParseColor (theArgNb, theArgVec, theColor); |
101 | } | |
102 | ||
103 | //======================================================================= | |
104 | // function : ParseColor | |
105 | // purpose : | |
106 | //======================================================================= | |
107 | Standard_Integer ViewerTest::ParseColor (const Standard_Integer theArgNb, | |
108 | const char* const* const theArgVec, | |
109 | Quantity_Color& theColor) | |
110 | { | |
111 | return Draw::ParseColor (theArgNb, theArgVec, theColor); | |
536d98e2 | 112 | } |
113 | ||
a5565a3c | 114 | //======================================================================= |
115 | //function : ParseOnOff | |
116 | //purpose : | |
117 | //======================================================================= | |
118 | Standard_Boolean ViewerTest::ParseOnOff (Standard_CString theArg, | |
119 | Standard_Boolean& theIsOn) | |
120 | { | |
dae2a922 | 121 | return Draw::ParseOnOff (theArg, theIsOn); |
a5565a3c | 122 | } |
123 | ||
404c8936 | 124 | //======================================================================= |
125 | //function : GetSelectedShapes | |
126 | //purpose : | |
127 | //======================================================================= | |
128 | void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes) | |
129 | { | |
130 | for (GetAISContext()->InitSelected(); GetAISContext()->MoreSelected(); GetAISContext()->NextSelected()) | |
131 | { | |
132 | TopoDS_Shape aShape = GetAISContext()->SelectedShape(); | |
133 | if (!aShape.IsNull()) | |
134 | { | |
135 | theSelectedShapes.Append (aShape); | |
136 | } | |
137 | } | |
138 | } | |
139 | ||
3a4a3962 | 140 | //======================================================================= |
141 | //function : ParseLineType | |
142 | //purpose : | |
143 | //======================================================================= | |
3f1675c9 | 144 | Standard_Boolean ViewerTest::ParseLineType (Standard_CString theArg, |
145 | Aspect_TypeOfLine& theType, | |
146 | uint16_t& thePattern) | |
3a4a3962 | 147 | { |
148 | TCollection_AsciiString aTypeStr (theArg); | |
149 | aTypeStr.LowerCase(); | |
3f1675c9 | 150 | if (aTypeStr == "empty" |
151 | || aTypeStr == "-1") | |
3a4a3962 | 152 | { |
153 | theType = Aspect_TOL_EMPTY; | |
3f1675c9 | 154 | thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType); |
3a4a3962 | 155 | } |
3f1675c9 | 156 | else if (aTypeStr == "solid" |
157 | || aTypeStr == "0") | |
3a4a3962 | 158 | { |
159 | theType = Aspect_TOL_SOLID; | |
3f1675c9 | 160 | thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType); |
3a4a3962 | 161 | } |
3f1675c9 | 162 | else if (aTypeStr == "dot" |
163 | || aTypeStr == "2") | |
3a4a3962 | 164 | { |
165 | theType = Aspect_TOL_DOT; | |
3f1675c9 | 166 | thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType); |
3a4a3962 | 167 | } |
3f1675c9 | 168 | else if (aTypeStr == "dash" |
169 | || aTypeStr == "1") | |
3a4a3962 | 170 | { |
171 | theType = Aspect_TOL_DASH; | |
3f1675c9 | 172 | thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType); |
3a4a3962 | 173 | } |
3f1675c9 | 174 | else if (aTypeStr == "dotdash" |
175 | || aTypeStr == "3") | |
3a4a3962 | 176 | { |
177 | theType = Aspect_TOL_DOTDASH; | |
3f1675c9 | 178 | thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType); |
3a4a3962 | 179 | } |
3f1675c9 | 180 | else |
3a4a3962 | 181 | { |
3f1675c9 | 182 | if (aTypeStr.StartsWith ("0x")) |
183 | { | |
184 | aTypeStr = aTypeStr.SubString (3, aTypeStr.Length()); | |
185 | } | |
186 | ||
187 | if (aTypeStr.Length() != 4 | |
188 | || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (1))) | |
189 | || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (2))) | |
190 | || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (3))) | |
191 | || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (4)))) | |
3a4a3962 | 192 | { |
193 | return Standard_False; | |
194 | } | |
3f1675c9 | 195 | |
196 | std::stringstream aStream; | |
197 | aStream << std::setbase (16) << aTypeStr.ToCString(); | |
198 | if (aStream.fail()) | |
199 | { | |
200 | return Standard_False; | |
201 | } | |
202 | ||
203 | Standard_Integer aNumber = -1; | |
204 | aStream >> aNumber; | |
205 | if (aStream.fail()) | |
206 | { | |
207 | return Standard_False; | |
208 | } | |
209 | ||
210 | thePattern = (uint16_t )aNumber; | |
211 | theType = Graphic3d_Aspects::DefaultLineTypeForPattern (thePattern); | |
2a332745 | 212 | } |
3a4a3962 | 213 | return Standard_True; |
214 | } | |
215 | ||
33cc703b | 216 | //======================================================================= |
217 | //function : ParseMarkerType | |
218 | //purpose : | |
219 | //======================================================================= | |
220 | Standard_Boolean ViewerTest::ParseMarkerType (Standard_CString theArg, | |
221 | Aspect_TypeOfMarker& theType, | |
222 | Handle(Image_PixMap)& theImage) | |
223 | { | |
224 | theImage.Nullify(); | |
225 | TCollection_AsciiString aTypeStr (theArg); | |
226 | aTypeStr.LowerCase(); | |
227 | if (aTypeStr == "empty") | |
228 | { | |
229 | theType = Aspect_TOM_EMPTY; | |
230 | } | |
231 | else if (aTypeStr == "point" | |
232 | || aTypeStr == "dot" | |
233 | || aTypeStr == ".") | |
234 | { | |
235 | theType = Aspect_TOM_POINT; | |
236 | } | |
237 | else if (aTypeStr == "plus" | |
238 | || aTypeStr == "+") | |
239 | { | |
240 | theType = Aspect_TOM_PLUS; | |
241 | } | |
242 | else if (aTypeStr == "star" | |
243 | || aTypeStr == "*") | |
244 | { | |
245 | theType = Aspect_TOM_STAR; | |
246 | } | |
247 | else if (aTypeStr == "cross" | |
248 | || aTypeStr == "x") | |
249 | { | |
250 | theType = Aspect_TOM_X; | |
251 | } | |
252 | else if (aTypeStr == "circle" | |
253 | || aTypeStr == "o") | |
254 | { | |
255 | theType = Aspect_TOM_O; | |
256 | } | |
257 | else if (aTypeStr == "pointincircle") | |
258 | { | |
259 | theType = Aspect_TOM_O_POINT; | |
260 | } | |
261 | else if (aTypeStr == "plusincircle") | |
262 | { | |
263 | theType = Aspect_TOM_O_PLUS; | |
264 | } | |
265 | else if (aTypeStr == "starincircle") | |
266 | { | |
267 | theType = Aspect_TOM_O_STAR; | |
268 | } | |
269 | else if (aTypeStr == "crossincircle" | |
270 | || aTypeStr == "xcircle") | |
271 | { | |
272 | theType = Aspect_TOM_O_X; | |
273 | } | |
274 | else if (aTypeStr == "ring1") | |
275 | { | |
276 | theType = Aspect_TOM_RING1; | |
277 | } | |
278 | else if (aTypeStr == "ring2") | |
279 | { | |
280 | theType = Aspect_TOM_RING2; | |
281 | } | |
282 | else if (aTypeStr == "ring" | |
283 | || aTypeStr == "ring3") | |
284 | { | |
285 | theType = Aspect_TOM_RING3; | |
286 | } | |
287 | else if (aTypeStr == "ball") | |
288 | { | |
289 | theType = Aspect_TOM_BALL; | |
290 | } | |
291 | else if (aTypeStr.IsIntegerValue()) | |
292 | { | |
293 | const int aTypeInt = aTypeStr.IntegerValue(); | |
294 | if (aTypeInt < -1 || aTypeInt >= Aspect_TOM_USERDEFINED) | |
295 | { | |
296 | return Standard_False; | |
297 | } | |
298 | theType = (Aspect_TypeOfMarker )aTypeInt; | |
299 | } | |
300 | else | |
301 | { | |
302 | theType = Aspect_TOM_USERDEFINED; | |
303 | Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap(); | |
304 | if (!anImage->Load (theArg)) | |
305 | { | |
306 | return Standard_False; | |
307 | } | |
308 | if (anImage->Format() == Image_Format_Gray) | |
309 | { | |
310 | anImage->SetFormat (Image_Format_Alpha); | |
311 | } | |
312 | else if (anImage->Format() == Image_Format_GrayF) | |
313 | { | |
314 | anImage->SetFormat (Image_Format_AlphaF); | |
315 | } | |
316 | theImage = anImage; | |
317 | } | |
318 | return Standard_True; | |
319 | } | |
320 | ||
dc89236f | 321 | //======================================================================= |
322 | //function : ParseShadingModel | |
323 | //purpose : | |
324 | //======================================================================= | |
325 | Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString theArg, | |
326 | Graphic3d_TypeOfShadingModel& theModel) | |
327 | { | |
328 | TCollection_AsciiString aTypeStr (theArg); | |
329 | aTypeStr.LowerCase(); | |
330 | if (aTypeStr == "unlit" | |
331 | || aTypeStr == "color" | |
332 | || aTypeStr == "none") | |
333 | { | |
13b36bb1 | 334 | theModel = Graphic3d_TypeOfShadingModel_Unlit; |
dc89236f | 335 | } |
336 | else if (aTypeStr == "flat" | |
337 | || aTypeStr == "facet") | |
338 | { | |
13b36bb1 | 339 | theModel = Graphic3d_TypeOfShadingModel_PhongFacet; |
dc89236f | 340 | } |
341 | else if (aTypeStr == "gouraud" | |
342 | || aTypeStr == "vertex" | |
343 | || aTypeStr == "vert") | |
344 | { | |
13b36bb1 | 345 | theModel = Graphic3d_TypeOfShadingModel_Gouraud; |
dc89236f | 346 | } |
347 | else if (aTypeStr == "phong" | |
348 | || aTypeStr == "fragment" | |
349 | || aTypeStr == "frag" | |
350 | || aTypeStr == "pixel") | |
351 | { | |
13b36bb1 | 352 | theModel = Graphic3d_TypeOfShadingModel_Phong; |
dc89236f | 353 | } |
67312b79 | 354 | else if (aTypeStr == "pbr") |
355 | { | |
13b36bb1 | 356 | theModel = Graphic3d_TypeOfShadingModel_Pbr; |
67312b79 | 357 | } |
358 | else if (aTypeStr == "pbr_facet") | |
359 | { | |
13b36bb1 | 360 | theModel = Graphic3d_TypeOfShadingModel_PbrFacet; |
67312b79 | 361 | } |
dc89236f | 362 | else if (aTypeStr == "default" |
363 | || aTypeStr == "def") | |
364 | { | |
13b36bb1 | 365 | theModel = Graphic3d_TypeOfShadingModel_DEFAULT; |
dc89236f | 366 | } |
367 | else if (aTypeStr.IsIntegerValue()) | |
368 | { | |
369 | const int aTypeInt = aTypeStr.IntegerValue(); | |
13b36bb1 | 370 | if (aTypeInt <= Graphic3d_TypeOfShadingModel_DEFAULT || aTypeInt >= Graphic3d_TypeOfShadingModel_NB) |
dc89236f | 371 | { |
372 | return Standard_False; | |
373 | } | |
374 | theModel = (Graphic3d_TypeOfShadingModel)aTypeInt; | |
375 | } | |
376 | else | |
377 | { | |
378 | return Standard_False; | |
379 | } | |
380 | return Standard_True; | |
381 | } | |
382 | ||
55c8f0f7 BB |
383 | //======================================================================= |
384 | //function : parseZLayer | |
385 | //purpose : | |
386 | //======================================================================= | |
387 | Standard_Boolean ViewerTest::parseZLayer (Standard_CString theArg, | |
388 | Standard_Boolean theToAllowInteger, | |
389 | Graphic3d_ZLayerId& theLayer) | |
390 | { | |
391 | TCollection_AsciiString aName (theArg); | |
392 | aName.LowerCase(); | |
393 | if (aName == "default" | |
394 | || aName == "def") | |
395 | { | |
396 | theLayer = Graphic3d_ZLayerId_Default; | |
397 | } | |
398 | else if (aName == "top") | |
399 | { | |
400 | theLayer = Graphic3d_ZLayerId_Top; | |
401 | } | |
402 | else if (aName == "topmost") | |
403 | { | |
404 | theLayer = Graphic3d_ZLayerId_Topmost; | |
405 | } | |
406 | else if (aName == "overlay" | |
407 | || aName == "toposd") | |
408 | { | |
409 | theLayer = Graphic3d_ZLayerId_TopOSD; | |
410 | } | |
411 | else if (aName == "underlay" | |
412 | || aName == "botosd") | |
413 | { | |
414 | theLayer = Graphic3d_ZLayerId_BotOSD; | |
415 | } | |
416 | else if (aName == "undefined") | |
417 | { | |
418 | theLayer = Graphic3d_ZLayerId_UNKNOWN; | |
419 | } | |
420 | else if (!GetAISContext().IsNull()) | |
421 | { | |
422 | const Handle(V3d_Viewer)& aViewer = ViewerTest::GetAISContext()->CurrentViewer(); | |
423 | TColStd_SequenceOfInteger aLayers; | |
424 | aViewer->GetAllZLayers (aLayers); | |
425 | for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next()) | |
426 | { | |
427 | Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value()); | |
428 | if (TCollection_AsciiString::IsSameString (aSettings.Name(), aName, Standard_False)) | |
429 | { | |
430 | theLayer = aLayeriter.Value(); | |
431 | return true; | |
432 | } | |
433 | } | |
434 | ||
435 | if (!theToAllowInteger | |
436 | || !aName.IsIntegerValue()) | |
437 | { | |
438 | return false; | |
439 | } | |
440 | Graphic3d_ZLayerId aLayer = aName.IntegerValue(); | |
441 | if (aLayer == Graphic3d_ZLayerId_UNKNOWN | |
442 | || std::find (aLayers.begin(), aLayers.end(), aLayer) != aLayers.end()) | |
443 | { | |
444 | theLayer = aLayer; | |
445 | return true; | |
446 | } | |
447 | return false; | |
448 | } | |
449 | return true; | |
450 | } | |
451 | ||
7fd59977 | 452 | //======================================================================= |
453 | //function : GetTypeNames | |
454 | //purpose : | |
455 | //======================================================================= | |
456 | static const char** GetTypeNames() | |
457 | { | |
458 | static const char* names[14] = {"Point","Axis","Trihedron","PlaneTrihedron", "Line","Circle","Plane", | |
459 | "Shape","ConnectedShape","MultiConn.Shape", | |
460 | "ConnectedInter.","MultiConn.", | |
461 | "Constraint","Dimension"}; | |
462 | static const char** ThePointer = names; | |
463 | return ThePointer; | |
464 | } | |
465 | ||
466 | //======================================================================= | |
467 | //function : GetTypeAndSignfromString | |
468 | //purpose : | |
469 | //======================================================================= | |
82b856b8 | 470 | static void GetTypeAndSignfromString (const char* theName, |
471 | AIS_KindOfInteractive& theType, | |
472 | Standard_Integer& theSign) | |
7fd59977 | 473 | { |
82b856b8 | 474 | const char** aFullNames = GetTypeNames(); |
475 | Standard_Integer anIndex = -1; | |
476 | for (Standard_Integer i = 0; i <= 13 && anIndex == -1; ++i) | |
477 | { | |
478 | if (strcasecmp (theName, aFullNames[i]) == 0) | |
479 | { | |
480 | anIndex = i; | |
481 | } | |
482 | } | |
7fd59977 | 483 | |
82b856b8 | 484 | if (anIndex ==-1) |
485 | { | |
486 | theType = AIS_KindOfInteractive_None; | |
487 | theSign = -1; | |
7fd59977 | 488 | return; |
489 | } | |
490 | ||
82b856b8 | 491 | if (anIndex <= 6) |
492 | { | |
493 | theType = AIS_KindOfInteractive_Datum; | |
494 | theSign = anIndex+1; | |
7fd59977 | 495 | } |
82b856b8 | 496 | else if (anIndex <= 9) |
497 | { | |
498 | theType = AIS_KindOfInteractive_Shape; | |
499 | theSign = anIndex - 7; | |
7fd59977 | 500 | } |
82b856b8 | 501 | else if (anIndex <= 11) |
502 | { | |
503 | theType = AIS_KindOfInteractive_Object; | |
504 | theSign = anIndex - 10; | |
7fd59977 | 505 | } |
82b856b8 | 506 | else |
507 | { | |
508 | theType = AIS_KindOfInteractive_Relation; | |
509 | theSign = anIndex - 12; | |
7fd59977 | 510 | } |
7fd59977 | 511 | } |
512 | ||
7fd59977 | 513 | #include <string.h> |
7fd59977 | 514 | #include <Draw_Appli.hxx> |
515 | #include <DBRep.hxx> | |
516 | ||
517 | ||
7fd59977 | 518 | #include <V3d_View.hxx> |
7fd59977 | 519 | |
520 | #include <AIS_InteractiveContext.hxx> | |
521 | #include <AIS_Shape.hxx> | |
7fd59977 | 522 | #include <AIS_DisplayMode.hxx> |
7fd59977 | 523 | #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx> |
524 | #include <ViewerTest_EventManager.hxx> | |
525 | ||
7fd59977 | 526 | #include <BRep_Builder.hxx> |
527 | #include <TopAbs_ShapeEnum.hxx> | |
528 | ||
7fd59977 | 529 | #include <BRep_Tool.hxx> |
530 | ||
531 | ||
532 | #include <Draw_Window.hxx> | |
7fd59977 | 533 | #include <TopTools_ListOfShape.hxx> |
7fd59977 | 534 | |
7fd59977 | 535 | //============================================================================== |
536 | // VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES | |
537 | //============================================================================== | |
538 | Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(){ | |
539 | static ViewerTest_DoubleMapOfInteractiveAndName TheMap; | |
540 | return TheMap; | |
541 | } | |
542 | ||
29e2c6d2 | 543 | //======================================================================= |
544 | //function : Display | |
545 | //purpose : | |
546 | //======================================================================= | |
547 | Standard_Boolean ViewerTest::Display (const TCollection_AsciiString& theName, | |
548 | const Handle(AIS_InteractiveObject)& theObject, | |
549 | const Standard_Boolean theToUpdate, | |
550 | const Standard_Boolean theReplaceIfExists) | |
9558a876 A |
551 | { |
552 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); | |
29e2c6d2 | 553 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
554 | if (aCtx.IsNull()) | |
9558a876 | 555 | { |
23fe70ec | 556 | Message::SendFail ("Error: AIS context is not available."); |
9558a876 A |
557 | return Standard_False; |
558 | } | |
559 | ||
560 | if (aMap.IsBound2 (theName)) | |
561 | { | |
562 | if (!theReplaceIfExists) | |
563 | { | |
23fe70ec | 564 | Message::SendFail() << "Error: other interactive object has been already registered with name: " << theName << ".\n" |
565 | << "Please use another name."; | |
9558a876 A |
566 | return Standard_False; |
567 | } | |
568 | ||
8f521168 | 569 | if (Handle(AIS_InteractiveObject) anOldObj = aMap.Find2 (theName)) |
29e2c6d2 | 570 | { |
1beb58d7 | 571 | aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate); |
29e2c6d2 | 572 | } |
9558a876 A |
573 | aMap.UnBind2 (theName); |
574 | } | |
575 | ||
29e2c6d2 | 576 | if (theObject.IsNull()) |
208e6839 | 577 | { |
29e2c6d2 | 578 | // object with specified name has been already unbound |
208e6839 | 579 | return Standard_True; |
580 | } | |
581 | ||
29e2c6d2 | 582 | // unbind AIS object if it was bound with another name |
583 | aMap.UnBind1 (theObject); | |
9558a876 A |
584 | |
585 | // can be registered without rebinding | |
29e2c6d2 | 586 | aMap.Bind (theObject, theName); |
587 | aCtx->Display (theObject, theToUpdate); | |
9558a876 A |
588 | return Standard_True; |
589 | } | |
590 | ||
29e2c6d2 | 591 | //! Alias for ViewerTest::Display(), compatibility with old code. |
592 | Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName, | |
593 | const Handle(AIS_InteractiveObject)& theObject, | |
594 | Standard_Boolean theReplaceIfExists = Standard_True) | |
595 | { | |
596 | return ViewerTest::Display (theName, theObject, Standard_True, theReplaceIfExists); | |
597 | } | |
598 | ||
49582f9d | 599 | static NCollection_List<Handle(ViewerTest_EventManager)> theEventMgrs; |
7fd59977 | 600 | |
24de79c3 | 601 | static Handle(V3d_View)& a3DView() |
602 | { | |
7fd59977 | 603 | static Handle(V3d_View) Viou; |
604 | return Viou; | |
605 | } | |
606 | ||
24de79c3 | 607 | |
7fd59977 | 608 | Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext(){ |
609 | static Handle(AIS_InteractiveContext) aContext; | |
610 | return aContext; | |
611 | } | |
612 | ||
24de79c3 | 613 | const Handle(V3d_View)& ViewerTest::CurrentView() |
7fd59977 | 614 | { |
615 | return a3DView(); | |
616 | } | |
617 | void ViewerTest::CurrentView(const Handle(V3d_View)& V) | |
618 | { | |
619 | a3DView() = V; | |
620 | } | |
621 | ||
24de79c3 | 622 | const Handle(AIS_InteractiveContext)& ViewerTest::GetAISContext() |
7fd59977 | 623 | { |
624 | return TheAISContext(); | |
625 | } | |
626 | ||
627 | void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx) | |
628 | { | |
629 | TheAISContext() = aCtx; | |
630 | ViewerTest::ResetEventManager(); | |
631 | } | |
632 | ||
633 | Handle(V3d_Viewer) ViewerTest::GetViewerFromContext() | |
634 | { | |
4952a30a | 635 | return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)(); |
7fd59977 | 636 | } |
637 | ||
638 | Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext() | |
639 | { | |
4952a30a | 640 | return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)(); |
7fd59977 | 641 | } |
642 | ||
643 | ||
644 | void ViewerTest::SetEventManager(const Handle(ViewerTest_EventManager)& EM){ | |
645 | theEventMgrs.Prepend(EM); | |
646 | } | |
647 | ||
648 | void ViewerTest::UnsetEventManager() | |
649 | { | |
650 | theEventMgrs.RemoveFirst(); | |
651 | } | |
652 | ||
653 | ||
654 | void ViewerTest::ResetEventManager() | |
655 | { | |
49582f9d | 656 | theEventMgrs.Clear(); |
657 | theEventMgrs.Prepend (new ViewerTest_EventManager (ViewerTest::CurrentView(), ViewerTest::GetAISContext())); | |
7fd59977 | 658 | } |
659 | ||
660 | Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager() | |
661 | { | |
49582f9d | 662 | return !theEventMgrs.IsEmpty() |
663 | ? theEventMgrs.First() | |
664 | : Handle(ViewerTest_EventManager)(); | |
7fd59977 | 665 | } |
666 | ||
7fd59977 | 667 | //======================================================================= |
34db9c00 | 668 | //function : Get Context and active view |
7fd59977 | 669 | //purpose : |
670 | //======================================================================= | |
34db9c00 | 671 | static Standard_Boolean getCtxAndView (Handle(AIS_InteractiveContext)& theCtx, |
672 | Handle(V3d_View)& theView) | |
7fd59977 | 673 | { |
34db9c00 | 674 | theCtx = ViewerTest::GetAISContext(); |
675 | theView = ViewerTest::CurrentView(); | |
676 | if (theCtx.IsNull() | |
677 | || theView.IsNull()) | |
7fd59977 | 678 | { |
23fe70ec | 679 | Message::SendFail ("Error: cannot find an active view!"); |
34db9c00 | 680 | return Standard_False; |
7fd59977 | 681 | } |
34db9c00 | 682 | return Standard_True; |
7fd59977 | 683 | } |
684 | ||
7fd59977 | 685 | //============================================================================== |
686 | //function : Clear | |
687 | //purpose : Remove all the object from the viewer | |
688 | //============================================================================== | |
689 | void ViewerTest::Clear() | |
690 | { | |
851dacdb | 691 | if (a3DView().IsNull()) |
692 | { | |
693 | return; | |
694 | } | |
695 | ||
696 | NCollection_Sequence<Handle(AIS_InteractiveObject)> aListRemoved; | |
697 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); anObjIter.More(); anObjIter.Next()) | |
698 | { | |
b2fedee6 | 699 | const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key1(); |
851dacdb | 700 | if (anObj->GetContext() != TheAISContext()) |
701 | { | |
702 | continue; | |
7fd59977 | 703 | } |
851dacdb | 704 | |
23fe70ec | 705 | Message::SendInfo() << "Remove " << anObjIter.Key2(); |
851dacdb | 706 | TheAISContext()->Remove (anObj, Standard_False); |
707 | aListRemoved.Append (anObj); | |
708 | } | |
709 | ||
710 | TheAISContext()->RebuildSelectionStructs(); | |
711 | TheAISContext()->UpdateCurrentViewer(); | |
712 | if (aListRemoved.Size() == GetMapOfAIS().Extent()) | |
713 | { | |
7fd59977 | 714 | GetMapOfAIS().Clear(); |
715 | } | |
851dacdb | 716 | else |
717 | { | |
718 | for (NCollection_Sequence<Handle(AIS_InteractiveObject)>::Iterator anObjIter (aListRemoved); anObjIter.More(); anObjIter.Next()) | |
719 | { | |
720 | GetMapOfAIS().UnBind1 (anObjIter.Value()); | |
721 | } | |
722 | } | |
7fd59977 | 723 | } |
724 | ||
1c88cbaf | 725 | //============================================================================== |
726 | //function : CopyIsoAspect | |
727 | //purpose : Returns copy Prs3d_IsoAspect with new number of isolines. | |
728 | //============================================================================== | |
729 | static Handle(Prs3d_IsoAspect) CopyIsoAspect | |
730 | (const Handle(Prs3d_IsoAspect) &theIsoAspect, | |
731 | const Standard_Integer theNbIsos) | |
732 | { | |
b6472664 | 733 | Quantity_Color aColor = theIsoAspect->Aspect()->Color(); |
734 | Aspect_TypeOfLine aType = theIsoAspect->Aspect()->Type(); | |
735 | Standard_Real aWidth = theIsoAspect->Aspect()->Width(); | |
1c88cbaf | 736 | |
737 | Handle(Prs3d_IsoAspect) aResult = | |
738 | new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos); | |
739 | ||
740 | return aResult; | |
741 | } | |
742 | ||
743 | //============================================================================== | |
744 | //function : visos | |
745 | //purpose : Returns or sets the number of U- and V- isos and isIsoOnPlane flag | |
746 | //Draw arg : [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)] | |
747 | //============================================================================== | |
748 | static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
749 | { | |
750 | if (TheAISContext().IsNull()) { | |
751 | di << argv[0] << " Call 'vinit' before!\n"; | |
752 | return 1; | |
753 | } | |
754 | ||
755 | if (argc <= 1) { | |
756 | di << "Current number of isos : " << | |
757 | TheAISContext()->IsoNumber(AIS_TOI_IsoU) << " " << | |
758 | TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n"; | |
759 | di << "IsoOnPlane mode is " << | |
760 | (TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n"; | |
5ad8c033 | 761 | di << "IsoOnTriangulation mode is " << |
762 | (TheAISContext()->IsoOnTriangulation() ? "ON" : "OFF") << "\n"; | |
1c88cbaf | 763 | return 0; |
764 | } | |
765 | ||
766 | Standard_Integer aLastInd = argc - 1; | |
767 | Standard_Boolean isChanged = Standard_False; | |
1d47d8d0 | 768 | Standard_Integer aNbUIsos = 0; |
769 | Standard_Integer aNbVIsos = 0; | |
1c88cbaf | 770 | |
771 | if (aLastInd >= 3) { | |
772 | Standard_Boolean isIsoOnPlane = Standard_False; | |
773 | ||
774 | if (strcmp(argv[aLastInd], "1") == 0) { | |
775 | isIsoOnPlane = Standard_True; | |
776 | isChanged = Standard_True; | |
777 | } else if (strcmp(argv[aLastInd], "0") == 0) { | |
778 | isIsoOnPlane = Standard_False; | |
779 | isChanged = Standard_True; | |
780 | } | |
781 | ||
782 | if (isChanged) { | |
783 | aNbVIsos = Draw::Atoi(argv[aLastInd - 1]); | |
784 | aNbUIsos = Draw::Atoi(argv[aLastInd - 2]); | |
785 | aLastInd -= 3; | |
786 | ||
787 | di << "New number of isos : " << aNbUIsos << " " << aNbVIsos << "\n"; | |
788 | di << "New IsoOnPlane mode is " << (isIsoOnPlane ? "ON" : "OFF") << "\n"; | |
789 | ||
790 | TheAISContext()->IsoOnPlane(isIsoOnPlane); | |
791 | ||
792 | if (aLastInd == 0) { | |
793 | // If there are no shapes provided set the default numbers. | |
794 | TheAISContext()->SetIsoNumber(aNbUIsos, AIS_TOI_IsoU); | |
795 | TheAISContext()->SetIsoNumber(aNbVIsos, AIS_TOI_IsoV); | |
796 | } | |
797 | } | |
798 | } | |
799 | ||
800 | Standard_Integer i; | |
801 | ||
8f521168 | 802 | for (i = 1; i <= aLastInd; i++) |
803 | { | |
1c88cbaf | 804 | TCollection_AsciiString name(argv[i]); |
8f521168 | 805 | Handle(AIS_InteractiveObject) aShape; |
806 | GetMapOfAIS().Find2(name, aShape); | |
807 | if (aShape.IsNull()) | |
808 | { | |
23fe70ec | 809 | Message::SendFail() << "Syntax error: object '" << name << "' is not found"; |
8f521168 | 810 | return 1; |
811 | } | |
812 | ||
813 | Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes(); | |
814 | Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect(); | |
815 | Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect(); | |
816 | if (isChanged) | |
817 | { | |
818 | CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos)); | |
819 | CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos)); | |
820 | TheAISContext()->SetLocalAttributes (aShape, CurDrawer, Standard_False); | |
821 | TheAISContext()->Redisplay (aShape, Standard_False); | |
822 | } | |
823 | else | |
824 | { | |
825 | di << "Number of isos for " << argv[i] << " : " | |
826 | << aUIso->Number() << " " << aVIso->Number() << "\n"; | |
1c88cbaf | 827 | } |
828 | } | |
829 | ||
830 | if (isChanged) { | |
831 | TheAISContext()->UpdateCurrentViewer(); | |
832 | } | |
833 | ||
834 | return 0; | |
835 | } | |
836 | ||
34db9c00 | 837 | static Standard_Integer VDispSensi (Draw_Interpretor& , |
838 | Standard_Integer theArgNb, | |
839 | Standard_CString* ) | |
7fd59977 | 840 | { |
34db9c00 | 841 | if (theArgNb > 1) |
842 | { | |
23fe70ec | 843 | Message::SendFail ("Error: wrong syntax!"); |
34db9c00 | 844 | return 1; |
845 | } | |
846 | ||
847 | Handle(AIS_InteractiveContext) aCtx; | |
848 | Handle(V3d_View) aView; | |
849 | if (!getCtxAndView (aCtx, aView)) | |
850 | { | |
851 | return 1; | |
852 | } | |
853 | ||
854 | aCtx->DisplayActiveSensitive (aView); | |
7fd59977 | 855 | return 0; |
856 | ||
857 | } | |
34db9c00 | 858 | |
859 | static Standard_Integer VClearSensi (Draw_Interpretor& , | |
860 | Standard_Integer theArgNb, | |
861 | Standard_CString* ) | |
7fd59977 | 862 | { |
34db9c00 | 863 | if (theArgNb > 1) |
864 | { | |
23fe70ec | 865 | Message::SendFail ("Error: wrong syntax!"); |
34db9c00 | 866 | return 1; |
867 | } | |
868 | ||
869 | Handle(AIS_InteractiveContext) aCtx; | |
870 | Handle(V3d_View) aView; | |
871 | if (!getCtxAndView (aCtx, aView)) | |
872 | { | |
873 | return 1; | |
874 | } | |
875 | aCtx->ClearActiveSensitive (aView); | |
7fd59977 | 876 | return 0; |
877 | } | |
878 | ||
879 | //============================================================================== | |
519d35d8 | 880 | //function : VDir |
7fd59977 | 881 | //purpose : To list the displayed object with their attributes |
7fd59977 | 882 | //============================================================================== |
519d35d8 | 883 | static int VDir (Draw_Interpretor& theDI, |
ab1f4580 | 884 | Standard_Integer theNbArgs, |
885 | const char** theArgVec) | |
519d35d8 | 886 | { |
ab1f4580 | 887 | TCollection_AsciiString aMatch; |
888 | Standard_Boolean toFormat = Standard_False; | |
889 | for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) | |
519d35d8 | 890 | { |
ab1f4580 | 891 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); |
892 | anArgCase.LowerCase(); | |
893 | if (anArgCase == "-list" | |
894 | || anArgCase == "-format") | |
895 | { | |
896 | toFormat = Standard_True; | |
897 | } | |
898 | else if (aMatch.IsEmpty()) | |
899 | { | |
900 | aMatch = theArgVec[anArgIter]; | |
901 | } | |
902 | else | |
903 | { | |
23fe70ec | 904 | Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'"; |
ab1f4580 | 905 | return 1; |
906 | } | |
907 | } | |
908 | ||
909 | TCollection_AsciiString aRes; | |
910 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next()) | |
911 | { | |
912 | if (!aMatch.IsEmpty()) | |
913 | { | |
914 | const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aMatch + "' '" + anIter.Key2() + "'"; | |
915 | if (theDI.Eval (aCheck.ToCString()) == 0 | |
916 | && *theDI.Result() != '1') | |
917 | { | |
918 | continue; | |
919 | } | |
920 | } | |
921 | ||
922 | if (toFormat) | |
923 | { | |
924 | aRes += TCollection_AsciiString("\t") + anIter.Key2() + "\n"; | |
925 | } | |
926 | else | |
927 | { | |
928 | aRes += anIter.Key2() + " "; | |
929 | } | |
519d35d8 | 930 | } |
ab1f4580 | 931 | theDI.Reset(); |
932 | theDI << aRes; | |
7fd59977 | 933 | return 0; |
934 | } | |
935 | ||
f978241f | 936 | //! Auxiliary enumeration |
937 | enum ViewerTest_StereoPair | |
938 | { | |
939 | ViewerTest_SP_Single, | |
940 | ViewerTest_SP_SideBySide, | |
941 | ViewerTest_SP_OverUnder | |
942 | }; | |
943 | ||
7fd59977 | 944 | //============================================================================== |
945 | //function : VDump | |
946 | //purpose : To dump the active view snapshot to image file | |
7fd59977 | 947 | //============================================================================== |
34db9c00 | 948 | static Standard_Integer VDump (Draw_Interpretor& theDI, |
949 | Standard_Integer theArgNb, | |
950 | Standard_CString* theArgVec) | |
7fd59977 | 951 | { |
b40cdc2b | 952 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
34db9c00 | 953 | if (theArgNb < 2) |
7fd59977 | 954 | { |
23fe70ec | 955 | Message::SendFail ("Error: wrong number of arguments! Image file name should be specified at least."); |
7fd59977 | 956 | return 1; |
957 | } | |
b40cdc2b | 958 | if (aView.IsNull()) |
959 | { | |
960 | Message::SendFail() << "Error: cannot find an active view!"; | |
961 | return 1; | |
962 | } | |
7fd59977 | 963 | |
34db9c00 | 964 | Standard_Integer anArgIter = 1; |
965 | Standard_CString aFilePath = theArgVec[anArgIter++]; | |
f978241f | 966 | ViewerTest_StereoPair aStereoPair = ViewerTest_SP_Single; |
3bffef55 | 967 | V3d_ImageDumpOptions aParams; |
b40cdc2b | 968 | Handle(Graphic3d_Camera) aCustomCam; |
3bffef55 | 969 | aParams.BufferType = Graphic3d_BT_RGB; |
970 | aParams.StereoOptions = V3d_SDO_MONO; | |
34db9c00 | 971 | for (; anArgIter < theArgNb; ++anArgIter) |
7fd59977 | 972 | { |
34db9c00 | 973 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
974 | anArg.LowerCase(); | |
f978241f | 975 | if (anArg == "-buffer") |
7fd59977 | 976 | { |
f978241f | 977 | if (++anArgIter >= theArgNb) |
978 | { | |
23fe70ec | 979 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
f978241f | 980 | return 1; |
981 | } | |
982 | ||
983 | TCollection_AsciiString aBufArg (theArgVec[anArgIter]); | |
984 | aBufArg.LowerCase(); | |
985 | if (aBufArg == "rgba") | |
986 | { | |
3bffef55 | 987 | aParams.BufferType = Graphic3d_BT_RGBA; |
f978241f | 988 | } |
989 | else if (aBufArg == "rgb") | |
990 | { | |
3bffef55 | 991 | aParams.BufferType = Graphic3d_BT_RGB; |
f978241f | 992 | } |
4eff0c04 | 993 | else if (aBufArg == "red") |
994 | { | |
995 | aParams.BufferType = Graphic3d_BT_Red; | |
996 | } | |
f978241f | 997 | else if (aBufArg == "depth") |
998 | { | |
3bffef55 | 999 | aParams.BufferType = Graphic3d_BT_Depth; |
f978241f | 1000 | } |
1001 | else | |
1002 | { | |
23fe70ec | 1003 | Message::SendFail() << "Error: unknown buffer '" << aBufArg << "'"; |
f978241f | 1004 | return 1; |
1005 | } | |
7fd59977 | 1006 | } |
b40cdc2b | 1007 | else if (anArgIter + 1 < theArgNb |
1008 | && anArg == "-xrpose") | |
1009 | { | |
1010 | TCollection_AsciiString anXRArg (theArgVec[++anArgIter]); | |
1011 | anXRArg.LowerCase(); | |
1012 | if (anXRArg == "base") | |
1013 | { | |
1014 | aCustomCam = aView->View()->BaseXRCamera(); | |
1015 | } | |
1016 | else if (anXRArg == "head") | |
1017 | { | |
1018 | aCustomCam = aView->View()->PosedXRCamera(); | |
1019 | } | |
1020 | else if (anXRArg == "handleft" | |
1021 | || anXRArg == "handright") | |
1022 | { | |
1023 | if (aView->View()->IsActiveXR()) | |
1024 | { | |
1025 | aCustomCam = new Graphic3d_Camera(); | |
1026 | aView->View()->ComputeXRPosedCameraFromBase (*aCustomCam, anXRArg == "handleft" | |
1027 | ? aView->View()->XRSession()->LeftHandPose() | |
1028 | : aView->View()->XRSession()->RightHandPose()); | |
1029 | } | |
1030 | } | |
1031 | else | |
1032 | { | |
1033 | Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'"; | |
1034 | return 1; | |
1035 | } | |
1036 | if (aCustomCam.IsNull()) | |
1037 | { | |
1038 | Message::SendFail() << "Error: undefined XR pose"; | |
1039 | return 0; | |
1040 | } | |
1041 | } | |
f978241f | 1042 | else if (anArg == "-stereo") |
7fd59977 | 1043 | { |
f978241f | 1044 | if (++anArgIter >= theArgNb) |
1045 | { | |
23fe70ec | 1046 | Message::SendFail() << "Error: wrong syntax at '" << anArg << "'"; |
f978241f | 1047 | return 1; |
1048 | } | |
1049 | ||
1050 | TCollection_AsciiString aStereoArg (theArgVec[anArgIter]); | |
1051 | aStereoArg.LowerCase(); | |
1052 | if (aStereoArg == "l" | |
1053 | || aStereoArg == "left") | |
1054 | { | |
3bffef55 | 1055 | aParams.StereoOptions = V3d_SDO_LEFT_EYE; |
f978241f | 1056 | } |
1057 | else if (aStereoArg == "r" | |
1058 | || aStereoArg == "right") | |
1059 | { | |
3bffef55 | 1060 | aParams.StereoOptions = V3d_SDO_RIGHT_EYE; |
f978241f | 1061 | } |
1062 | else if (aStereoArg == "mono") | |
1063 | { | |
3bffef55 | 1064 | aParams.StereoOptions = V3d_SDO_MONO; |
f978241f | 1065 | } |
1066 | else if (aStereoArg == "blended" | |
1067 | || aStereoArg == "blend" | |
1068 | || aStereoArg == "stereo") | |
1069 | { | |
3bffef55 | 1070 | aParams.StereoOptions = V3d_SDO_BLENDED; |
f978241f | 1071 | } |
1072 | else if (aStereoArg == "sbs" | |
1073 | || aStereoArg == "sidebyside") | |
1074 | { | |
1075 | aStereoPair = ViewerTest_SP_SideBySide; | |
1076 | } | |
1077 | else if (aStereoArg == "ou" | |
1078 | || aStereoArg == "overunder") | |
1079 | { | |
1080 | aStereoPair = ViewerTest_SP_OverUnder; | |
1081 | } | |
1082 | else | |
1083 | { | |
23fe70ec | 1084 | Message::SendFail() << "Error: unknown stereo format '" << aStereoArg << "'"; |
f978241f | 1085 | return 1; |
1086 | } | |
7fd59977 | 1087 | } |
f978241f | 1088 | else if (anArg == "-rgba" |
1089 | || anArg == "rgba") | |
34db9c00 | 1090 | { |
3bffef55 | 1091 | aParams.BufferType = Graphic3d_BT_RGBA; |
34db9c00 | 1092 | } |
f978241f | 1093 | else if (anArg == "-rgb" |
1094 | || anArg == "rgb") | |
34db9c00 | 1095 | { |
3bffef55 | 1096 | aParams.BufferType = Graphic3d_BT_RGB; |
34db9c00 | 1097 | } |
4eff0c04 | 1098 | else if (anArg == "-red" |
1099 | || anArg == "red") | |
1100 | { | |
1101 | aParams.BufferType = Graphic3d_BT_Red; | |
1102 | } | |
f978241f | 1103 | else if (anArg == "-depth" |
1104 | || anArg == "depth") | |
34db9c00 | 1105 | { |
3bffef55 | 1106 | aParams.BufferType = Graphic3d_BT_Depth; |
34db9c00 | 1107 | } |
f978241f | 1108 | else if (anArg == "-width" |
1109 | || anArg == "width" | |
1110 | || anArg == "sizex") | |
34db9c00 | 1111 | { |
3bffef55 | 1112 | if (aParams.Width != 0) |
34db9c00 | 1113 | { |
23fe70ec | 1114 | Message::SendFail() << "Error: wrong syntax at " << theArgVec[anArgIter]; |
34db9c00 | 1115 | return 1; |
1116 | } | |
1117 | else if (++anArgIter >= theArgNb) | |
1118 | { | |
23fe70ec | 1119 | Message::SendFail() << "Error: integer value is expected right after 'width'"; |
34db9c00 | 1120 | return 1; |
1121 | } | |
3bffef55 | 1122 | aParams.Width = Draw::Atoi (theArgVec[anArgIter]); |
34db9c00 | 1123 | } |
f978241f | 1124 | else if (anArg == "-height" |
1125 | || anArg == "height" | |
1126 | || anArg == "-sizey") | |
34db9c00 | 1127 | { |
3bffef55 | 1128 | if (aParams.Height != 0) |
34db9c00 | 1129 | { |
23fe70ec | 1130 | Message::SendFail() << "Error: wrong syntax at " << theArgVec[anArgIter]; |
34db9c00 | 1131 | return 1; |
1132 | } | |
34db9c00 | 1133 | else if (++anArgIter >= theArgNb) |
1134 | { | |
23fe70ec | 1135 | Message::SendFail() << "Error: integer value is expected right after 'height'"; |
34db9c00 | 1136 | return 1; |
1137 | } | |
3bffef55 | 1138 | aParams.Height = Draw::Atoi (theArgVec[anArgIter]); |
1139 | } | |
1140 | else if (anArg == "-tile" | |
1141 | || anArg == "-tilesize") | |
1142 | { | |
1143 | if (++anArgIter >= theArgNb) | |
1144 | { | |
23fe70ec | 1145 | Message::SendFail() << "Error: integer value is expected right after 'tileSize'"; |
3bffef55 | 1146 | return 1; |
1147 | } | |
1148 | aParams.TileSize = Draw::Atoi (theArgVec[anArgIter]); | |
34db9c00 | 1149 | } |
1150 | else | |
1151 | { | |
23fe70ec | 1152 | Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'"; |
34db9c00 | 1153 | return 1; |
1154 | } | |
7fd59977 | 1155 | } |
3bffef55 | 1156 | if ((aParams.Width <= 0 && aParams.Height > 0) |
1157 | || (aParams.Width > 0 && aParams.Height <= 0)) | |
7fd59977 | 1158 | { |
23fe70ec | 1159 | Message::SendFail() << "Error: dimensions " << aParams.Width << "x" << aParams.Height << " are incorrect"; |
85e096c3 | 1160 | return 1; |
1161 | } | |
1162 | ||
3bffef55 | 1163 | if (aParams.Width <= 0 || aParams.Height <= 0) |
b5ac8292 | 1164 | { |
3bffef55 | 1165 | aView->Window()->Size (aParams.Width, aParams.Height); |
f978241f | 1166 | } |
1167 | ||
1168 | Image_AlienPixMap aPixMap; | |
dc858f4c | 1169 | Image_Format aFormat = Image_Format_UNKNOWN; |
3bffef55 | 1170 | switch (aParams.BufferType) |
f978241f | 1171 | { |
38d90bb3 | 1172 | case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break; |
1173 | case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break; | |
1174 | case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break; | |
1175 | case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break; | |
4eff0c04 | 1176 | case Graphic3d_BT_Red: aFormat = Image_Format_Gray; break; |
f978241f | 1177 | } |
1178 | ||
b40cdc2b | 1179 | const bool wasImmUpdate = aView->SetImmediateUpdate (false); |
1180 | Handle(Graphic3d_Camera) aCamBack = aView->Camera(); | |
1181 | if (!aCustomCam.IsNull()) | |
1182 | { | |
1183 | aView->SetCamera (aCustomCam); | |
1184 | } | |
f978241f | 1185 | switch (aStereoPair) |
1186 | { | |
1187 | case ViewerTest_SP_Single: | |
b5ac8292 | 1188 | { |
3bffef55 | 1189 | if (!aView->ToPixMap (aPixMap, aParams)) |
f978241f | 1190 | { |
1191 | theDI << "Fail: view dump failed!\n"; | |
1192 | return 0; | |
1193 | } | |
3bffef55 | 1194 | else if (aPixMap.SizeX() != Standard_Size(aParams.Width) |
1195 | || aPixMap.SizeY() != Standard_Size(aParams.Height)) | |
f978241f | 1196 | { |
1197 | theDI << "Fail: dumped dimensions " << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY() | |
3bffef55 | 1198 | << " are lesser than requested " << aParams.Width << "x" << aParams.Height << "\n"; |
f978241f | 1199 | } |
1200 | break; | |
b5ac8292 | 1201 | } |
f978241f | 1202 | case ViewerTest_SP_SideBySide: |
b5ac8292 | 1203 | { |
3bffef55 | 1204 | if (!aPixMap.InitZero (aFormat, aParams.Width * 2, aParams.Height)) |
f978241f | 1205 | { |
1206 | theDI << "Fail: not enough memory for image allocation!\n"; | |
1207 | return 0; | |
1208 | } | |
1209 | ||
1210 | Image_PixMap aPixMapL, aPixMapR; | |
1211 | aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(), | |
3bffef55 | 1212 | aParams.Width, aParams.Height, aPixMap.SizeRowBytes()); |
1213 | aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizePixelBytes() * aParams.Width, | |
1214 | aParams.Width, aParams.Height, aPixMap.SizeRowBytes()); | |
1215 | ||
1216 | aParams.StereoOptions = V3d_SDO_LEFT_EYE; | |
1217 | Standard_Boolean isOk = aView->ToPixMap (aPixMapL, aParams); | |
1218 | aParams.StereoOptions = V3d_SDO_RIGHT_EYE; | |
1219 | isOk = isOk && aView->ToPixMap (aPixMapR, aParams); | |
1220 | if (!isOk) | |
34db9c00 | 1221 | { |
1222 | theDI << "Fail: view dump failed!\n"; | |
f978241f | 1223 | return 0; |
34db9c00 | 1224 | } |
f978241f | 1225 | break; |
b5ac8292 | 1226 | } |
f978241f | 1227 | case ViewerTest_SP_OverUnder: |
1228 | { | |
3bffef55 | 1229 | if (!aPixMap.InitZero (aFormat, aParams.Width, aParams.Height * 2)) |
f978241f | 1230 | { |
1231 | theDI << "Fail: not enough memory for image allocation!\n"; | |
1232 | return 0; | |
1233 | } | |
b5ac8292 | 1234 | |
f978241f | 1235 | Image_PixMap aPixMapL, aPixMapR; |
f9f740d6 | 1236 | aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(), |
3bffef55 | 1237 | aParams.Width, aParams.Height, aPixMap.SizeRowBytes()); |
f9f740d6 | 1238 | aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height, |
3bffef55 | 1239 | aParams.Width, aParams.Height, aPixMap.SizeRowBytes()); |
1240 | ||
1241 | aParams.StereoOptions = V3d_SDO_LEFT_EYE; | |
1242 | Standard_Boolean isOk = aView->ToPixMap (aPixMapL, aParams); | |
1243 | aParams.StereoOptions = V3d_SDO_RIGHT_EYE; | |
1244 | isOk = isOk && aView->ToPixMap (aPixMapR, aParams); | |
1245 | if (!isOk) | |
f978241f | 1246 | { |
1247 | theDI << "Fail: view dump failed!\n"; | |
1248 | return 0; | |
1249 | } | |
1250 | break; | |
1251 | } | |
7fd59977 | 1252 | } |
b40cdc2b | 1253 | if (!aCustomCam.IsNull()) |
1254 | { | |
1255 | aView->SetCamera (aCamBack); | |
1256 | } | |
1257 | aView->SetImmediateUpdate (wasImmUpdate); | |
85e096c3 | 1258 | |
34db9c00 | 1259 | if (!aPixMap.Save (aFilePath)) |
85e096c3 | 1260 | { |
34db9c00 | 1261 | theDI << "Fail: image can not be saved!\n"; |
85e096c3 | 1262 | } |
1263 | return 0; | |
7fd59977 | 1264 | } |
1265 | ||
dde68833 | 1266 | enum TypeOfDispOperation |
7fd59977 | 1267 | { |
dde68833 | 1268 | TypeOfDispOperation_SetDispMode, |
1269 | TypeOfDispOperation_UnsetDispMode | |
1270 | }; | |
7fd59977 | 1271 | |
dde68833 | 1272 | //! Displays,Erase... |
1273 | static void VwrTst_DispErase (const Handle(AIS_InteractiveObject)& thePrs, | |
1274 | const Standard_Integer theMode, | |
1275 | const TypeOfDispOperation theType, | |
1276 | const Standard_Boolean theToUpdate) | |
1277 | { | |
1278 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
1279 | switch (theType) | |
1280 | { | |
1281 | case TypeOfDispOperation_SetDispMode: | |
1282 | { | |
1283 | if (!thePrs.IsNull()) | |
1284 | { | |
1285 | aCtx->SetDisplayMode (thePrs, theMode, theToUpdate); | |
1286 | } | |
1287 | else | |
1288 | { | |
1289 | aCtx->SetDisplayMode ((AIS_DisplayMode )theMode, theToUpdate); | |
1290 | } | |
1291 | break; | |
1292 | } | |
1293 | case TypeOfDispOperation_UnsetDispMode: | |
1294 | { | |
1295 | if (!thePrs.IsNull()) | |
1296 | { | |
1297 | aCtx->UnsetDisplayMode (thePrs, theToUpdate); | |
1298 | } | |
1299 | else | |
1300 | { | |
1301 | aCtx->SetDisplayMode (AIS_WireFrame, theToUpdate); | |
1302 | } | |
1303 | break; | |
1304 | } | |
7fd59977 | 1305 | } |
7fd59977 | 1306 | } |
1307 | ||
1308 | //======================================================================= | |
1309 | //function : | |
1310 | //purpose : | |
1311 | //======================================================================= | |
1312 | static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv) | |
1313 | { | |
dde68833 | 1314 | if (argc < 1 |
1315 | || argc > 3) | |
1316 | { | |
23fe70ec | 1317 | Message::SendFail() << "Syntax error: wrong number of arguments"; |
7fd59977 | 1318 | return 1; |
dde68833 | 1319 | } |
7fd59977 | 1320 | |
dde68833 | 1321 | TypeOfDispOperation aType = TCollection_AsciiString (argv[0]) == "vunsetdispmode" |
1322 | ? TypeOfDispOperation_UnsetDispMode | |
1323 | : TypeOfDispOperation_SetDispMode; | |
1324 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
f41fd243 | 1325 | if (aCtx.IsNull()) |
1326 | { | |
1327 | Message::SendFail ("Error: no active viewer"); | |
1328 | return 1; | |
1329 | } | |
1330 | ||
dde68833 | 1331 | if (aType == TypeOfDispOperation_UnsetDispMode) |
1332 | { | |
1333 | if (argc == 1) | |
1334 | { | |
1335 | if (aCtx->NbSelected() == 0) | |
1336 | { | |
1337 | VwrTst_DispErase (Handle(AIS_InteractiveObject)(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False); | |
1338 | } | |
1339 | else | |
1340 | { | |
1341 | for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) | |
1342 | { | |
1343 | VwrTst_DispErase (aCtx->SelectedInteractive(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False); | |
1344 | } | |
7fd59977 | 1345 | } |
dde68833 | 1346 | aCtx->UpdateCurrentViewer(); |
7fd59977 | 1347 | } |
dde68833 | 1348 | else |
1349 | { | |
1350 | TCollection_AsciiString aName = argv[1]; | |
8f521168 | 1351 | Handle(AIS_InteractiveObject) aPrs; |
1352 | if (GetMapOfAIS().Find2 (aName, aPrs) | |
1353 | && !aPrs.IsNull()) | |
dde68833 | 1354 | { |
8f521168 | 1355 | VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True); |
7fd59977 | 1356 | } |
1357 | } | |
1358 | } | |
dde68833 | 1359 | else if (argc == 2) |
1360 | { | |
1361 | Standard_Integer aDispMode = Draw::Atoi (argv[1]); | |
1362 | if (aCtx->NbSelected() == 0 | |
1363 | && aType == TypeOfDispOperation_SetDispMode) | |
1364 | { | |
1365 | VwrTst_DispErase (Handle(AIS_InteractiveObject)(), aDispMode, TypeOfDispOperation_SetDispMode, Standard_True); | |
7fd59977 | 1366 | } |
dde68833 | 1367 | for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) |
1368 | { | |
1369 | VwrTst_DispErase (aCtx->SelectedInteractive(), aDispMode, aType, Standard_False); | |
7fd59977 | 1370 | } |
dde68833 | 1371 | aCtx->UpdateCurrentViewer(); |
7fd59977 | 1372 | } |
dde68833 | 1373 | else |
1374 | { | |
1375 | Handle(AIS_InteractiveObject) aPrs; | |
1376 | TCollection_AsciiString aName (argv[1]); | |
8f521168 | 1377 | if (GetMapOfAIS().Find2 (aName, aPrs) |
1378 | && !aPrs.IsNull()) | |
dde68833 | 1379 | { |
1380 | VwrTst_DispErase (aPrs, Draw::Atoi(argv[2]), aType, Standard_True); | |
1381 | } | |
7fd59977 | 1382 | } |
1383 | return 0; | |
1384 | } | |
1385 | ||
1386 | ||
1387 | //======================================================================= | |
1388 | //function : | |
1389 | //purpose : | |
1390 | //======================================================================= | |
1391 | static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1392 | { | |
1393 | if(argc==1) return 1; | |
91322f44 | 1394 | Standard_Integer On = Draw::Atoi(argv[1]); |
7fd59977 | 1395 | const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext(); |
f41fd243 | 1396 | if (Ctx.IsNull()) |
1397 | { | |
1398 | Message::SendFail ("Error: no active viewer"); | |
1399 | return 1; | |
1400 | } | |
7fd59977 | 1401 | |
c3282ec1 | 1402 | if(argc==2) |
1403 | { | |
1404 | TCollection_AsciiString isOnOff = On == 1 ? "on" : "off"; | |
1405 | di << "Sub intensite is turned " << isOnOff << " for " << Ctx->NbSelected() << "objects\n"; | |
1406 | for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected()) | |
1407 | { | |
1408 | if(On==1) | |
1409 | { | |
1410 | Ctx->SubIntensityOn (Ctx->SelectedInteractive(), Standard_False); | |
7fd59977 | 1411 | } |
c3282ec1 | 1412 | else |
1413 | { | |
1414 | Ctx->SubIntensityOff (Ctx->SelectedInteractive(), Standard_False); | |
7fd59977 | 1415 | } |
1416 | } | |
c3282ec1 | 1417 | |
7fd59977 | 1418 | Ctx->UpdateCurrentViewer(); |
1419 | } | |
1420 | else { | |
1421 | Handle(AIS_InteractiveObject) IO; | |
1422 | TCollection_AsciiString name = argv[2]; | |
8f521168 | 1423 | if (GetMapOfAIS().Find2 (name, IO) |
1424 | && !IO.IsNull()) | |
1425 | { | |
1426 | if(On==1) | |
1427 | Ctx->SubIntensityOn(IO, Standard_True); | |
1428 | else | |
1429 | Ctx->SubIntensityOff(IO, Standard_True); | |
7fd59977 | 1430 | } |
1431 | else return 1; | |
1432 | } | |
1433 | return 0; | |
7fd59977 | 1434 | } |
7fd59977 | 1435 | |
ad3217cd | 1436 | //! Auxiliary class to iterate presentations from different collections. |
1437 | class ViewTest_PrsIter | |
1438 | { | |
1439 | public: | |
7fd59977 | 1440 | |
ad3217cd | 1441 | //! Create and initialize iterator object. |
1442 | ViewTest_PrsIter (const TCollection_AsciiString& theName) | |
1443 | : mySource (IterSource_All) | |
1444 | { | |
1445 | NCollection_Sequence<TCollection_AsciiString> aNames; | |
1446 | if (!theName.IsEmpty()) | |
1447 | aNames.Append (theName); | |
1448 | Init (aNames); | |
7fd59977 | 1449 | } |
ad3217cd | 1450 | |
1451 | //! Create and initialize iterator object. | |
1452 | ViewTest_PrsIter (const NCollection_Sequence<TCollection_AsciiString>& theNames) | |
1453 | : mySource (IterSource_All) | |
1454 | { | |
1455 | Init (theNames); | |
7fd59977 | 1456 | } |
1457 | ||
ad3217cd | 1458 | //! Initialize the iterator. |
1459 | void Init (const NCollection_Sequence<TCollection_AsciiString>& theNames) | |
1460 | { | |
1461 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
1462 | mySeq = theNames; | |
1463 | mySelIter.Nullify(); | |
1464 | myCurrent.Nullify(); | |
1465 | myCurrentTrs.Nullify(); | |
1466 | if (!mySeq.IsEmpty()) | |
1467 | { | |
1468 | mySource = IterSource_List; | |
1469 | mySeqIter = NCollection_Sequence<TCollection_AsciiString>::Iterator (mySeq); | |
7fd59977 | 1470 | } |
c3282ec1 | 1471 | else if (aCtx->NbSelected() > 0) |
ad3217cd | 1472 | { |
1473 | mySource = IterSource_Selected; | |
1474 | mySelIter = aCtx; | |
c3282ec1 | 1475 | mySelIter->InitSelected(); |
ad3217cd | 1476 | } |
1477 | else | |
1478 | { | |
1479 | mySource = IterSource_All; | |
1480 | myMapIter.Initialize (GetMapOfAIS()); | |
1481 | } | |
1482 | initCurrent(); | |
1483 | } | |
7fd59977 | 1484 | |
ad3217cd | 1485 | const TCollection_AsciiString& CurrentName() const |
1486 | { | |
1487 | return myCurrentName; | |
1488 | } | |
7fd59977 | 1489 | |
ad3217cd | 1490 | const Handle(AIS_InteractiveObject)& Current() const |
1491 | { | |
1492 | return myCurrent; | |
1493 | } | |
7fd59977 | 1494 | |
ad3217cd | 1495 | const Handle(Standard_Transient)& CurrentTrs() const |
1496 | { | |
1497 | return myCurrentTrs; | |
1498 | } | |
1499 | ||
1500 | //! @return true if iterator points to valid object within collection | |
1501 | Standard_Boolean More() const | |
1502 | { | |
1503 | switch (mySource) | |
1504 | { | |
1505 | case IterSource_All: return myMapIter.More(); | |
1506 | case IterSource_List: return mySeqIter.More(); | |
c3282ec1 | 1507 | case IterSource_Selected: return mySelIter->MoreSelected(); |
ad3217cd | 1508 | } |
1509 | return Standard_False; | |
1510 | } | |
1511 | ||
1512 | //! Go to the next item. | |
1513 | void Next() | |
1514 | { | |
1515 | myCurrentName.Clear(); | |
1516 | myCurrentTrs.Nullify(); | |
1517 | myCurrent.Nullify(); | |
1518 | switch (mySource) | |
1519 | { | |
1520 | case IterSource_All: | |
1521 | { | |
1522 | myMapIter.Next(); | |
1523 | break; | |
1524 | } | |
1525 | case IterSource_List: | |
1526 | { | |
1527 | mySeqIter.Next(); | |
1528 | break; | |
1529 | } | |
1530 | case IterSource_Selected: | |
1531 | { | |
c3282ec1 | 1532 | mySelIter->NextSelected(); |
ad3217cd | 1533 | break; |
7fd59977 | 1534 | } |
1535 | } | |
ad3217cd | 1536 | initCurrent(); |
1537 | } | |
7fd59977 | 1538 | |
ad3217cd | 1539 | private: |
7fd59977 | 1540 | |
ad3217cd | 1541 | void initCurrent() |
1542 | { | |
1543 | switch (mySource) | |
1544 | { | |
1545 | case IterSource_All: | |
7fd59977 | 1546 | { |
ad3217cd | 1547 | if (myMapIter.More()) |
1548 | { | |
1549 | myCurrentName = myMapIter.Key2(); | |
1550 | myCurrentTrs = myMapIter.Key1(); | |
1551 | myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs); | |
eafb234b | 1552 | } |
ad3217cd | 1553 | break; |
1554 | } | |
1555 | case IterSource_List: | |
1556 | { | |
1557 | if (mySeqIter.More()) | |
1558 | { | |
1559 | if (!GetMapOfAIS().IsBound2 (mySeqIter.Value())) | |
1560 | { | |
23fe70ec | 1561 | Message::SendFail() << "Error: object " << mySeqIter.Value() << " is not displayed!"; |
ad3217cd | 1562 | return; |
1563 | } | |
1564 | myCurrentName = mySeqIter.Value(); | |
1565 | myCurrentTrs = GetMapOfAIS().Find2 (mySeqIter.Value()); | |
1566 | myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs); | |
1567 | } | |
1568 | break; | |
1569 | } | |
1570 | case IterSource_Selected: | |
1571 | { | |
c3282ec1 | 1572 | if (mySelIter->MoreSelected()) |
ad3217cd | 1573 | { |
c3282ec1 | 1574 | myCurrentName = GetMapOfAIS().Find1 (mySelIter->SelectedInteractive()); |
1575 | myCurrent = mySelIter->SelectedInteractive(); | |
ad3217cd | 1576 | } |
1577 | break; | |
7fd59977 | 1578 | } |
7fd59977 | 1579 | } |
1580 | } | |
ad3217cd | 1581 | |
1582 | private: | |
1583 | ||
1584 | enum IterSource | |
1585 | { | |
1586 | IterSource_All, | |
1587 | IterSource_List, | |
1588 | IterSource_Selected | |
1589 | }; | |
1590 | ||
1591 | private: | |
1592 | ||
1593 | Handle(AIS_InteractiveContext) mySelIter; //!< iterator for current (selected) objects (IterSource_Selected) | |
1594 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName myMapIter; //!< iterator for map of all objects (IterSource_All) | |
1595 | NCollection_Sequence<TCollection_AsciiString> mySeq; | |
1596 | NCollection_Sequence<TCollection_AsciiString>::Iterator mySeqIter; | |
1597 | ||
1598 | TCollection_AsciiString myCurrentName;//!< current item name | |
1599 | Handle(Standard_Transient) myCurrentTrs; //!< current item (as transient object) | |
1600 | Handle(AIS_InteractiveObject) myCurrent; //!< current item | |
1601 | ||
1602 | IterSource mySource; //!< iterated collection | |
1603 | ||
1604 | }; | |
7fd59977 | 1605 | |
2a332745 | 1606 | //! Parse interior style name. |
1607 | static bool parseInteriorStyle (const TCollection_AsciiString& theArg, | |
1608 | Aspect_InteriorStyle& theStyle) | |
7fd59977 | 1609 | { |
2a332745 | 1610 | TCollection_AsciiString anArg (theArg); |
1611 | anArg.LowerCase(); | |
1612 | if (anArg == "empty") | |
ad3217cd | 1613 | { |
2a332745 | 1614 | theStyle = Aspect_IS_EMPTY; |
ad3217cd | 1615 | } |
2a332745 | 1616 | else if (anArg == "hollow") |
ad3217cd | 1617 | { |
2a332745 | 1618 | theStyle = Aspect_IS_HOLLOW; |
ad3217cd | 1619 | } |
2a332745 | 1620 | else if (anArg == "solid") |
ad3217cd | 1621 | { |
2a332745 | 1622 | theStyle = Aspect_IS_SOLID; |
ad3217cd | 1623 | } |
2a332745 | 1624 | else if (anArg == "hatch") |
ad3217cd | 1625 | { |
2a332745 | 1626 | theStyle = Aspect_IS_HATCH; |
ad3217cd | 1627 | } |
2a332745 | 1628 | else if (anArg == "hiddenline" |
1629 | || anArg == "hidden-line" | |
1630 | || anArg == "hidden_line") | |
ad3217cd | 1631 | { |
2a332745 | 1632 | theStyle = Aspect_IS_HIDDENLINE; |
ad3217cd | 1633 | } |
2a332745 | 1634 | else if (anArg == "point") |
ad3217cd | 1635 | { |
2a332745 | 1636 | theStyle = Aspect_IS_POINT; |
ad3217cd | 1637 | } |
2a332745 | 1638 | else if (theArg.IsIntegerValue()) |
ad3217cd | 1639 | { |
2a332745 | 1640 | const Standard_Integer anIntStyle = theArg.IntegerValue(); |
1641 | if (anIntStyle < Aspect_IS_EMPTY || anIntStyle > Aspect_IS_POINT) | |
ec7c343f | 1642 | { |
2a332745 | 1643 | return false; |
ec7c343f | 1644 | } |
2a332745 | 1645 | theStyle = (Aspect_InteriorStyle)anIntStyle; |
7fd59977 | 1646 | } |
2a332745 | 1647 | else |
ad3217cd | 1648 | { |
2a332745 | 1649 | return false; |
ad3217cd | 1650 | } |
2a332745 | 1651 | return true; |
ad3217cd | 1652 | } |
7fd59977 | 1653 | |
ad3217cd | 1654 | //! Auxiliary structure for VAspects |
1655 | struct ViewerTest_AspectsChangeSet | |
1656 | { | |
dc89236f | 1657 | Standard_Integer ToSetVisibility; |
1658 | Standard_Integer Visibility; | |
5bffb882 | 1659 | |
dc89236f | 1660 | Standard_Integer ToSetColor; |
1661 | Quantity_Color Color; | |
6b9b7e3c | 1662 | Standard_Integer ToSetBackFaceColor; |
1663 | Quantity_Color BackFaceColor; | |
ad3217cd | 1664 | |
dc89236f | 1665 | Standard_Integer ToSetLineWidth; |
1666 | Standard_Real LineWidth; | |
ad3217cd | 1667 | |
dc89236f | 1668 | Standard_Integer ToSetTypeOfLine; |
3f1675c9 | 1669 | uint16_t StippleLinePattern; |
e0b24437 | 1670 | uint16_t StippleLineFactor; |
ac116c22 | 1671 | |
dc89236f | 1672 | Standard_Integer ToSetTypeOfMarker; |
1673 | Aspect_TypeOfMarker TypeOfMarker; | |
1674 | Handle(Image_PixMap) MarkerImage; | |
33cc703b | 1675 | |
dc89236f | 1676 | Standard_Integer ToSetMarkerSize; |
1677 | Standard_Real MarkerSize; | |
33cc703b | 1678 | |
dc89236f | 1679 | Standard_Integer ToSetTransparency; |
1680 | Standard_Real Transparency; | |
ad3217cd | 1681 | |
c40eb6b9 | 1682 | Standard_Integer ToSetAlphaMode; |
1683 | Graphic3d_AlphaMode AlphaMode; | |
1684 | Standard_ShortReal AlphaCutoff; | |
1685 | ||
9db675b3 | 1686 | Standard_Integer ToSetFaceCulling; |
1687 | Graphic3d_TypeOfBackfacingModel FaceCulling; | |
1688 | ||
dc89236f | 1689 | Standard_Integer ToSetMaterial; |
1690 | Graphic3d_NameOfMaterial Material; | |
1691 | TCollection_AsciiString MatName; | |
ad3217cd | 1692 | |
1693 | NCollection_Sequence<TopoDS_Shape> SubShapes; | |
1694 | ||
dc89236f | 1695 | Standard_Integer ToSetShowFreeBoundary; |
1696 | Standard_Integer ToSetFreeBoundaryWidth; | |
1697 | Standard_Real FreeBoundaryWidth; | |
1698 | Standard_Integer ToSetFreeBoundaryColor; | |
1699 | Quantity_Color FreeBoundaryColor; | |
6262338c | 1700 | |
dc89236f | 1701 | Standard_Integer ToEnableIsoOnTriangulation; |
5ad8c033 | 1702 | |
0493ffd0 | 1703 | Standard_Integer ToSetFaceBoundaryDraw; |
1704 | Standard_Integer ToSetFaceBoundaryUpperContinuity; | |
1705 | GeomAbs_Shape FaceBoundaryUpperContinuity; | |
1706 | ||
1707 | Standard_Integer ToSetFaceBoundaryColor; | |
1708 | Quantity_Color FaceBoundaryColor; | |
1709 | ||
1710 | Standard_Integer ToSetFaceBoundaryWidth; | |
1711 | Standard_Real FaceBoundaryWidth; | |
1712 | ||
1713 | Standard_Integer ToSetTypeOfFaceBoundaryLine; | |
1714 | Aspect_TypeOfLine TypeOfFaceBoundaryLine; | |
1715 | ||
dc89236f | 1716 | Standard_Integer ToSetMaxParamValue; |
1717 | Standard_Real MaxParamValue; | |
5ad8c033 | 1718 | |
dc89236f | 1719 | Standard_Integer ToSetSensitivity; |
1720 | Standard_Integer SelectionMode; | |
1721 | Standard_Integer Sensitivity; | |
8a1170ad | 1722 | |
dc89236f | 1723 | Standard_Integer ToSetHatch; |
1724 | Standard_Integer StdHatchStyle; | |
1725 | TCollection_AsciiString PathToHatchPattern; | |
1726 | ||
1727 | Standard_Integer ToSetShadingModel; | |
1728 | Graphic3d_TypeOfShadingModel ShadingModel; | |
1729 | TCollection_AsciiString ShadingModelName; | |
640d5fe2 | 1730 | |
2a332745 | 1731 | Standard_Integer ToSetInterior; |
1732 | Aspect_InteriorStyle InteriorStyle; | |
1733 | ||
6ef0d6f1 | 1734 | Standard_Integer ToSetDrawSilhouette; |
1735 | ||
2a332745 | 1736 | Standard_Integer ToSetDrawEdges; |
1737 | Standard_Integer ToSetQuadEdges; | |
1738 | ||
1739 | Standard_Integer ToSetEdgeColor; | |
1740 | Quantity_ColorRGBA EdgeColor; | |
1741 | ||
1742 | Standard_Integer ToSetEdgeWidth; | |
1743 | Standard_Real EdgeWidth; | |
1744 | ||
1745 | Standard_Integer ToSetTypeOfEdge; | |
1746 | Aspect_TypeOfLine TypeOfEdge; | |
1747 | ||
ad3217cd | 1748 | //! Empty constructor |
1749 | ViewerTest_AspectsChangeSet() | |
5bffb882 | 1750 | : ToSetVisibility (0), |
1751 | Visibility (1), | |
1752 | ToSetColor (0), | |
ad3217cd | 1753 | Color (DEFAULT_COLOR), |
6b9b7e3c | 1754 | ToSetBackFaceColor(0), |
1755 | BackFaceColor (DEFAULT_COLOR), | |
ad3217cd | 1756 | ToSetLineWidth (0), |
1757 | LineWidth (1.0), | |
ac116c22 | 1758 | ToSetTypeOfLine (0), |
3f1675c9 | 1759 | StippleLinePattern(0xFFFF), |
e0b24437 | 1760 | StippleLineFactor (1), |
33cc703b | 1761 | ToSetTypeOfMarker (0), |
1762 | TypeOfMarker (Aspect_TOM_PLUS), | |
1763 | ToSetMarkerSize (0), | |
1764 | MarkerSize (1.0), | |
ad3217cd | 1765 | ToSetTransparency (0), |
1766 | Transparency (0.0), | |
c40eb6b9 | 1767 | ToSetAlphaMode (0), |
1768 | AlphaMode (Graphic3d_AlphaMode_BlendAuto), | |
1769 | AlphaCutoff (0.5f), | |
9db675b3 | 1770 | ToSetFaceCulling (0), |
1771 | FaceCulling (Graphic3d_TypeOfBackfacingModel_Auto), | |
ad3217cd | 1772 | ToSetMaterial (0), |
a966542b | 1773 | Material (Graphic3d_NameOfMaterial_DEFAULT), |
5ad8c033 | 1774 | ToSetShowFreeBoundary (0), |
1775 | ToSetFreeBoundaryWidth (0), | |
1776 | FreeBoundaryWidth (1.0), | |
1777 | ToSetFreeBoundaryColor (0), | |
1778 | FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR), | |
0493ffd0 | 1779 | ToEnableIsoOnTriangulation (0), |
1780 | // | |
1781 | ToSetFaceBoundaryDraw (0), | |
1782 | ToSetFaceBoundaryUpperContinuity (0), | |
1783 | FaceBoundaryUpperContinuity(GeomAbs_CN), | |
1784 | ToSetFaceBoundaryColor (0), | |
1785 | FaceBoundaryColor (Quantity_NOC_BLACK), | |
1786 | ToSetFaceBoundaryWidth (0), | |
1787 | FaceBoundaryWidth (1.0f), | |
1788 | ToSetTypeOfFaceBoundaryLine(0), | |
1789 | TypeOfFaceBoundaryLine (Aspect_TOL_SOLID), | |
1790 | // | |
dc89236f | 1791 | ToSetMaxParamValue (0), |
1792 | MaxParamValue (500000), | |
1793 | ToSetSensitivity (0), | |
1794 | SelectionMode (-1), | |
1795 | Sensitivity (-1), | |
1796 | ToSetHatch (0), | |
1797 | StdHatchStyle (-1), | |
1798 | ToSetShadingModel (0), | |
13b36bb1 | 1799 | ShadingModel (Graphic3d_TypeOfShadingModel_DEFAULT), |
2a332745 | 1800 | ToSetInterior (0), |
1801 | InteriorStyle (Aspect_IS_SOLID), | |
6ef0d6f1 | 1802 | ToSetDrawSilhouette (0), |
2a332745 | 1803 | ToSetDrawEdges (0), |
1804 | ToSetQuadEdges (0), | |
1805 | ToSetEdgeColor (0), | |
1806 | ToSetEdgeWidth (0), | |
1807 | EdgeWidth (1.0), | |
1808 | ToSetTypeOfEdge (0), | |
1809 | TypeOfEdge (Aspect_TOL_SOLID) | |
640d5fe2 | 1810 | {} |
ad3217cd | 1811 | |
1812 | //! @return true if no changes have been requested | |
1813 | Standard_Boolean IsEmpty() const | |
1814 | { | |
6262338c | 1815 | return ToSetVisibility == 0 |
1816 | && ToSetLineWidth == 0 | |
1817 | && ToSetTransparency == 0 | |
c40eb6b9 | 1818 | && ToSetAlphaMode == 0 |
9db675b3 | 1819 | && ToSetFaceCulling == 0 |
6262338c | 1820 | && ToSetColor == 0 |
6b9b7e3c | 1821 | && ToSetBackFaceColor == 0 |
6262338c | 1822 | && ToSetMaterial == 0 |
1823 | && ToSetShowFreeBoundary == 0 | |
1824 | && ToSetFreeBoundaryColor == 0 | |
5ad8c033 | 1825 | && ToSetFreeBoundaryWidth == 0 |
0493ffd0 | 1826 | && ToEnableIsoOnTriangulation == 0 |
1827 | && ToSetFaceBoundaryDraw == 0 | |
1828 | && ToSetFaceBoundaryUpperContinuity == 0 | |
1829 | && ToSetFaceBoundaryColor == 0 | |
1830 | && ToSetFaceBoundaryWidth == 0 | |
1831 | && ToSetTypeOfFaceBoundaryLine == 0 | |
8a1170ad | 1832 | && ToSetMaxParamValue == 0 |
640d5fe2 | 1833 | && ToSetSensitivity == 0 |
dc89236f | 1834 | && ToSetHatch == 0 |
2a332745 | 1835 | && ToSetShadingModel == 0 |
1836 | && ToSetInterior == 0 | |
6ef0d6f1 | 1837 | && ToSetDrawSilhouette == 0 |
2a332745 | 1838 | && ToSetDrawEdges == 0 |
1839 | && ToSetQuadEdges == 0 | |
1840 | && ToSetEdgeColor == 0 | |
1841 | && ToSetEdgeWidth == 0 | |
1842 | && ToSetTypeOfEdge == 0; | |
ad3217cd | 1843 | } |
1844 | ||
1845 | //! @return true if properties are valid | |
c1197a15 | 1846 | Standard_Boolean Validate() const |
ad3217cd | 1847 | { |
1848 | Standard_Boolean isOk = Standard_True; | |
5bffb882 | 1849 | if (Visibility != 0 && Visibility != 1) |
1850 | { | |
23fe70ec | 1851 | Message::SendFail() << "Error: the visibility should be equal to 0 or 1 (0 - invisible; 1 - visible) (specified " << Visibility << ")"; |
5bffb882 | 1852 | isOk = Standard_False; |
1853 | } | |
ad3217cd | 1854 | if (LineWidth <= 0.0 |
1855 | || LineWidth > 10.0) | |
1856 | { | |
23fe70ec | 1857 | Message::SendFail() << "Error: the width should be within [1; 10] range (specified " << LineWidth << ")"; |
ad3217cd | 1858 | isOk = Standard_False; |
7fd59977 | 1859 | } |
ad3217cd | 1860 | if (Transparency < 0.0 |
1861 | || Transparency > 1.0) | |
1862 | { | |
23fe70ec | 1863 | Message::SendFail() << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")"; |
ad3217cd | 1864 | isOk = Standard_False; |
1865 | } | |
c40eb6b9 | 1866 | if (ToSetAlphaMode == 1 |
1867 | && (AlphaCutoff <= 0.0f || AlphaCutoff >= 1.0f)) | |
1868 | { | |
23fe70ec | 1869 | Message::SendFail() << "Error: alpha cutoff value should be within (0; 1) range (specified " << AlphaCutoff << ")"; |
c40eb6b9 | 1870 | isOk = Standard_False; |
1871 | } | |
6262338c | 1872 | if (FreeBoundaryWidth <= 0.0 |
1873 | || FreeBoundaryWidth > 10.0) | |
1874 | { | |
23fe70ec | 1875 | Message::SendFail() << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")"; |
6262338c | 1876 | isOk = Standard_False; |
1877 | } | |
5ad8c033 | 1878 | if (MaxParamValue < 0.0) |
1879 | { | |
23fe70ec | 1880 | Message::SendFail() << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")"; |
5ad8c033 | 1881 | isOk = Standard_False; |
1882 | } | |
0038de11 | 1883 | if (Sensitivity < 0 && ToSetSensitivity) |
8a1170ad | 1884 | { |
0038de11 | 1885 | Message::SendFail() << "Error: sensitivity parameter value should not be negative (specified " << Sensitivity << ")"; |
8a1170ad | 1886 | isOk = Standard_False; |
1887 | } | |
640d5fe2 | 1888 | if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "") |
1889 | { | |
23fe70ec | 1890 | Message::SendFail ("Error: hatch style must be specified"); |
640d5fe2 | 1891 | isOk = Standard_False; |
1892 | } | |
dc89236f | 1893 | if (ToSetShadingModel == 1 |
13b36bb1 | 1894 | && (ShadingModel < Graphic3d_TypeOfShadingModel_DEFAULT || ShadingModel > Graphic3d_TypeOfShadingModel_PbrFacet)) |
dc89236f | 1895 | { |
23fe70ec | 1896 | Message::SendFail() << "Error: unknown shading model " << ShadingModelName << "."; |
dc89236f | 1897 | isOk = Standard_False; |
1898 | } | |
ad3217cd | 1899 | return isOk; |
7fd59977 | 1900 | } |
7fd59977 | 1901 | |
2a332745 | 1902 | //! Apply aspects to specified drawer. |
1903 | bool Apply (const Handle(Prs3d_Drawer)& theDrawer) | |
1904 | { | |
1905 | bool toRecompute = false; | |
1906 | const Handle(Prs3d_Drawer)& aDefDrawer = ViewerTest::GetAISContext()->DefaultDrawer(); | |
1907 | if (ToSetShowFreeBoundary != 0) | |
1908 | { | |
1909 | theDrawer->SetFreeBoundaryDraw (ToSetShowFreeBoundary == 1); | |
1910 | toRecompute = true; | |
1911 | } | |
1912 | if (ToSetFreeBoundaryWidth != 0) | |
1913 | { | |
1914 | if (ToSetFreeBoundaryWidth != -1 | |
1915 | || theDrawer->HasOwnFreeBoundaryAspect()) | |
1916 | { | |
1917 | if (!theDrawer->HasOwnFreeBoundaryAspect()) | |
1918 | { | |
1919 | Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0); | |
1920 | *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect(); | |
1921 | theDrawer->SetFreeBoundaryAspect (aBoundaryAspect); | |
1922 | toRecompute = true; | |
1923 | } | |
1924 | theDrawer->FreeBoundaryAspect()->SetWidth (FreeBoundaryWidth); | |
1925 | } | |
1926 | } | |
1927 | if (ToSetFreeBoundaryColor != 0) | |
1928 | { | |
1929 | Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0); | |
1930 | *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect(); | |
1931 | aBoundaryAspect->SetColor (FreeBoundaryColor); | |
1932 | theDrawer->SetFreeBoundaryAspect (aBoundaryAspect); | |
1933 | toRecompute = true; | |
1934 | } | |
1935 | if (ToSetTypeOfLine != 0) | |
1936 | { | |
1937 | if (ToSetTypeOfLine != -1 | |
1938 | || theDrawer->HasOwnLineAspect() | |
1939 | || theDrawer->HasOwnWireAspect() | |
1940 | || theDrawer->HasOwnFreeBoundaryAspect() | |
1941 | || theDrawer->HasOwnUnFreeBoundaryAspect() | |
1942 | || theDrawer->HasOwnSeenLineAspect()) | |
1943 | { | |
1944 | toRecompute = theDrawer->SetOwnLineAspects() || toRecompute; | |
3f1675c9 | 1945 | theDrawer->LineAspect()->Aspect()->SetLinePattern (StippleLinePattern); |
e0b24437 | 1946 | theDrawer->LineAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor); |
3f1675c9 | 1947 | theDrawer->WireAspect()->Aspect()->SetLinePattern (StippleLinePattern); |
e0b24437 | 1948 | theDrawer->WireAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor); |
3f1675c9 | 1949 | theDrawer->FreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern); |
e0b24437 | 1950 | theDrawer->FreeBoundaryAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor); |
3f1675c9 | 1951 | theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern); |
e0b24437 | 1952 | theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor); |
3f1675c9 | 1953 | theDrawer->SeenLineAspect()->Aspect()->SetLinePattern (StippleLinePattern); |
e0b24437 | 1954 | theDrawer->SeenLineAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor); |
2a332745 | 1955 | } |
1956 | } | |
1957 | if (ToSetTypeOfMarker != 0) | |
1958 | { | |
1959 | if (ToSetTypeOfMarker != -1 | |
1960 | || theDrawer->HasOwnPointAspect()) | |
1961 | { | |
1962 | toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute; | |
1963 | theDrawer->PointAspect()->SetTypeOfMarker (TypeOfMarker); | |
1964 | theDrawer->PointAspect()->Aspect()->SetMarkerImage (MarkerImage.IsNull() ? Handle(Graphic3d_MarkerImage)() : new Graphic3d_MarkerImage (MarkerImage)); | |
1965 | } | |
1966 | } | |
1967 | if (ToSetMarkerSize != 0) | |
1968 | { | |
1969 | if (ToSetMarkerSize != -1 | |
1970 | || theDrawer->HasOwnPointAspect()) | |
1971 | { | |
1972 | toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute; | |
1973 | theDrawer->PointAspect()->SetScale (MarkerSize); | |
1974 | toRecompute = true; | |
1975 | } | |
1976 | } | |
1977 | if (ToSetMaxParamValue != 0) | |
1978 | { | |
1979 | if (ToSetMaxParamValue != -1 | |
1980 | || theDrawer->HasOwnMaximalParameterValue()) | |
1981 | { | |
1982 | theDrawer->SetMaximalParameterValue (MaxParamValue); | |
1983 | toRecompute = true; | |
1984 | } | |
1985 | } | |
0493ffd0 | 1986 | if (ToSetFaceBoundaryDraw != 0) |
1987 | { | |
1988 | if (ToSetFaceBoundaryDraw != -1 | |
1989 | || theDrawer->HasOwnFaceBoundaryDraw()) | |
1990 | { | |
1991 | toRecompute = true; | |
1992 | theDrawer->SetFaceBoundaryDraw (ToSetFaceBoundaryDraw == 1); | |
1993 | } | |
1994 | } | |
1995 | if (ToSetFaceBoundaryUpperContinuity != 0) | |
1996 | { | |
1997 | if (ToSetFaceBoundaryUpperContinuity != -1 | |
1998 | || theDrawer->HasOwnFaceBoundaryUpperContinuity()) | |
1999 | { | |
2000 | toRecompute = true; | |
2001 | if (ToSetFaceBoundaryUpperContinuity == -1) | |
2002 | { | |
2003 | theDrawer->UnsetFaceBoundaryUpperContinuity(); | |
2004 | } | |
2005 | else | |
2006 | { | |
2007 | theDrawer->SetFaceBoundaryUpperContinuity (FaceBoundaryUpperContinuity); | |
2008 | } | |
2009 | } | |
2010 | } | |
2011 | if (ToSetFaceBoundaryColor != 0) | |
2012 | { | |
2013 | if (ToSetFaceBoundaryColor != -1 | |
2014 | || theDrawer->HasOwnFaceBoundaryAspect()) | |
2015 | { | |
2016 | if (ToSetFaceBoundaryColor == -1) | |
2017 | { | |
2018 | toRecompute = true; | |
2019 | theDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)()); | |
2020 | } | |
2021 | else | |
2022 | { | |
2023 | toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute; | |
2024 | theDrawer->FaceBoundaryAspect()->SetColor (FaceBoundaryColor); | |
2025 | } | |
2026 | } | |
2027 | } | |
2028 | if (ToSetFaceBoundaryWidth != 0) | |
2029 | { | |
2030 | if (ToSetFaceBoundaryWidth != -1 | |
2031 | || theDrawer->HasOwnFaceBoundaryAspect()) | |
2032 | { | |
2033 | toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute; | |
2034 | theDrawer->FaceBoundaryAspect()->SetWidth (FaceBoundaryWidth); | |
2035 | } | |
2036 | } | |
2037 | if (ToSetTypeOfFaceBoundaryLine != 0) | |
2038 | { | |
2039 | if (ToSetTypeOfFaceBoundaryLine != -1 | |
2040 | || theDrawer->HasOwnFaceBoundaryAspect()) | |
2041 | { | |
2042 | toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute; | |
2043 | theDrawer->FaceBoundaryAspect()->SetTypeOfLine (TypeOfFaceBoundaryLine); | |
2044 | } | |
2045 | } | |
2a332745 | 2046 | if (ToSetShadingModel != 0) |
2047 | { | |
2048 | if (ToSetShadingModel != -1 | |
2049 | || theDrawer->HasOwnShadingAspect()) | |
2050 | { | |
2051 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2052 | theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel); | |
2053 | } | |
2054 | } | |
6b9b7e3c | 2055 | if (ToSetBackFaceColor != 0) |
2056 | { | |
2057 | if (ToSetBackFaceColor != -1 | |
2058 | || theDrawer->HasOwnShadingAspect()) | |
2059 | { | |
2060 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2061 | theDrawer->ShadingAspect()->SetColor (BackFaceColor, Aspect_TOFM_BACK_SIDE); | |
2062 | } | |
2063 | } | |
2a332745 | 2064 | if (ToSetAlphaMode != 0) |
2065 | { | |
2066 | if (ToSetAlphaMode != -1 | |
2067 | || theDrawer->HasOwnShadingAspect()) | |
2068 | { | |
2069 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2070 | theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff); | |
2071 | } | |
2072 | } | |
9db675b3 | 2073 | if (ToSetFaceCulling != 0) |
2074 | { | |
2075 | if (ToSetFaceCulling != -1 | |
2076 | || theDrawer->HasOwnShadingAspect()) | |
2077 | { | |
2078 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2079 | theDrawer->ShadingAspect()->Aspect()->SetFaceCulling (FaceCulling); | |
2080 | } | |
2081 | } | |
2a332745 | 2082 | if (ToSetHatch != 0) |
2083 | { | |
2084 | if (ToSetHatch != -1 | |
2085 | || theDrawer->HasOwnShadingAspect()) | |
2086 | { | |
2087 | theDrawer->SetupOwnShadingAspect (aDefDrawer); | |
2088 | Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect(); | |
2089 | if (ToSetHatch == -1) | |
2090 | { | |
2091 | anAsp->SetInteriorStyle (Aspect_IS_SOLID); | |
2092 | } | |
2093 | else | |
2094 | { | |
2095 | anAsp->SetInteriorStyle (Aspect_IS_HATCH); | |
2096 | if (!PathToHatchPattern.IsEmpty()) | |
2097 | { | |
2098 | Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap(); | |
2099 | if (anImage->Load (TCollection_AsciiString (PathToHatchPattern.ToCString()))) | |
2100 | { | |
2101 | anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage)); | |
2102 | } | |
2103 | else | |
2104 | { | |
23fe70ec | 2105 | Message::SendFail() << "Error: cannot load the following image: " << PathToHatchPattern; |
2a332745 | 2106 | } |
2107 | } | |
2108 | else if (StdHatchStyle != -1) | |
2109 | { | |
2110 | anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)StdHatchStyle)); | |
2111 | } | |
2112 | } | |
2113 | toRecompute = true; | |
2114 | } | |
2115 | } | |
2116 | if (ToSetInterior != 0) | |
2117 | { | |
2118 | if (ToSetInterior != -1 | |
2119 | || theDrawer->HasOwnShadingAspect()) | |
2120 | { | |
2121 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2122 | theDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (InteriorStyle); | |
2123 | if (InteriorStyle == Aspect_IS_HATCH | |
2124 | && theDrawer->ShadingAspect()->Aspect()->HatchStyle().IsNull()) | |
2125 | { | |
2126 | theDrawer->ShadingAspect()->Aspect()->SetHatchStyle (Aspect_HS_VERTICAL); | |
2127 | } | |
2128 | } | |
2129 | } | |
6ef0d6f1 | 2130 | if (ToSetDrawSilhouette != 0) |
2131 | { | |
2132 | if (ToSetDrawSilhouette != -1 | |
2133 | || theDrawer->HasOwnShadingAspect()) | |
2134 | { | |
2135 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2136 | theDrawer->ShadingAspect()->Aspect()->SetDrawSilhouette (ToSetDrawSilhouette == 1); | |
2137 | } | |
2138 | } | |
2a332745 | 2139 | if (ToSetDrawEdges != 0) |
2140 | { | |
2141 | if (ToSetDrawEdges != -1 | |
2142 | || theDrawer->HasOwnShadingAspect()) | |
2143 | { | |
2144 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2145 | theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetDrawEdges == 1); | |
2146 | } | |
2147 | } | |
2148 | if (ToSetQuadEdges != 0) | |
2149 | { | |
2150 | if (ToSetQuadEdges != -1 | |
2151 | || theDrawer->HasOwnShadingAspect()) | |
2152 | { | |
2153 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2154 | theDrawer->ShadingAspect()->Aspect()->SetSkipFirstEdge (ToSetQuadEdges == 1); | |
2155 | } | |
2156 | } | |
2157 | if (ToSetEdgeWidth != 0) | |
2158 | { | |
2159 | if (ToSetEdgeWidth != -1 | |
2160 | || theDrawer->HasOwnShadingAspect()) | |
2161 | { | |
2162 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2163 | theDrawer->ShadingAspect()->Aspect()->SetEdgeWidth (EdgeWidth); | |
2164 | } | |
2165 | } | |
2166 | if (ToSetTypeOfEdge != 0) | |
2167 | { | |
2168 | if (ToSetTypeOfEdge != -1 | |
2169 | || theDrawer->HasOwnShadingAspect()) | |
2170 | { | |
2171 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2172 | theDrawer->ShadingAspect()->Aspect()->SetEdgeLineType (TypeOfEdge); | |
2173 | if (ToSetInterior == 0) | |
2174 | { | |
2175 | theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetTypeOfEdge == 1 | |
2176 | && TypeOfEdge != Aspect_TOL_EMPTY); | |
2177 | } | |
2178 | } | |
2179 | } | |
2180 | if (ToSetEdgeColor != 0) | |
2181 | { | |
2182 | if (ToSetEdgeColor != -1 | |
2183 | || theDrawer->HasOwnShadingAspect()) | |
2184 | { | |
2185 | toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute; | |
2186 | if (ToSetEdgeColor == -1) | |
2187 | { | |
2188 | theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (theDrawer->ShadingAspect()->Aspect()->InteriorColor()); | |
2189 | } | |
2190 | else | |
2191 | { | |
2192 | theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (EdgeColor); | |
2193 | } | |
2194 | } | |
2195 | } | |
2196 | return toRecompute; | |
2197 | } | |
ad3217cd | 2198 | }; |
7fd59977 | 2199 | |
2200 | //============================================================================== | |
ad3217cd | 2201 | //function : VAspects |
2202 | //purpose : | |
7fd59977 | 2203 | //============================================================================== |
0904aa63 | 2204 | static Standard_Integer VAspects (Draw_Interpretor& theDI, |
ad3217cd | 2205 | Standard_Integer theArgNb, |
2206 | const char** theArgVec) | |
7fd59977 | 2207 | { |
ad3217cd | 2208 | TCollection_AsciiString aCmdName (theArgVec[0]); |
2209 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); | |
4e18052b | 2210 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
ad3217cd | 2211 | if (aCtx.IsNull()) |
2212 | { | |
23fe70ec | 2213 | Message::SendFail ("Error: no active view!"); |
ad3217cd | 2214 | return 1; |
2215 | } | |
7fd59977 | 2216 | |
4e18052b | 2217 | Standard_Integer anArgIter = 1; |
6262338c | 2218 | Standard_Boolean isDefaults = Standard_False; |
ad3217cd | 2219 | NCollection_Sequence<TCollection_AsciiString> aNames; |
2220 | for (; anArgIter < theArgNb; ++anArgIter) | |
2221 | { | |
2222 | TCollection_AsciiString anArg = theArgVec[anArgIter]; | |
4e18052b | 2223 | if (anUpdateTool.parseRedrawMode (anArg)) |
ad3217cd | 2224 | { |
2225 | continue; | |
2226 | } | |
2227 | else if (!anArg.IsEmpty() | |
2228 | && anArg.Value (1) != '-') | |
2229 | { | |
2230 | aNames.Append (anArg); | |
2231 | } | |
2232 | else | |
2233 | { | |
6262338c | 2234 | if (anArg == "-defaults") |
2235 | { | |
2236 | isDefaults = Standard_True; | |
2237 | ++anArgIter; | |
2238 | } | |
ad3217cd | 2239 | break; |
2240 | } | |
2241 | } | |
2242 | ||
6262338c | 2243 | if (!aNames.IsEmpty() && isDefaults) |
2244 | { | |
23fe70ec | 2245 | Message::SendFail ("Error: wrong syntax. If -defaults is used there should not be any objects' names!"); |
6262338c | 2246 | return 1; |
2247 | } | |
2248 | ||
ad3217cd | 2249 | NCollection_Sequence<ViewerTest_AspectsChangeSet> aChanges; |
2250 | aChanges.Append (ViewerTest_AspectsChangeSet()); | |
2251 | ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast(); | |
7fd59977 | 2252 | |
ad3217cd | 2253 | // parse syntax of legacy commands |
2a332745 | 2254 | bool toParseAliasArgs = false; |
0904aa63 | 2255 | Standard_Boolean toDump = 0; |
2256 | Standard_Boolean toCompactDump = 0; | |
2257 | Standard_Integer aDumpDepth = -1; | |
ad3217cd | 2258 | if (aCmdName == "vsetwidth") |
2259 | { | |
2260 | if (aNames.IsEmpty() | |
d45edf24 | 2261 | || !aNames.Last().IsRealValue (Standard_True)) |
ad3217cd | 2262 | { |
23fe70ec | 2263 | Message::SendFail ("Error: not enough arguments!"); |
ad3217cd | 2264 | return 1; |
2265 | } | |
2266 | aChangeSet->ToSetLineWidth = 1; | |
2267 | aChangeSet->LineWidth = aNames.Last().RealValue(); | |
2268 | aNames.Remove (aNames.Length()); | |
7fd59977 | 2269 | } |
ad3217cd | 2270 | else if (aCmdName == "vunsetwidth") |
2271 | { | |
2272 | aChangeSet->ToSetLineWidth = -1; | |
2273 | } | |
2274 | else if (aCmdName == "vsetcolor") | |
2275 | { | |
2276 | if (aNames.IsEmpty()) | |
2277 | { | |
23fe70ec | 2278 | Message::SendFail ("Error: not enough arguments!"); |
ad3217cd | 2279 | return 1; |
2280 | } | |
2281 | aChangeSet->ToSetColor = 1; | |
8316c618 | 2282 | |
2283 | Quantity_NameOfColor aColor = Quantity_NOC_BLACK; | |
2284 | Standard_Boolean isOk = Standard_False; | |
2285 | if (Quantity_Color::ColorFromName (aNames.Last().ToCString(), aColor)) | |
2286 | { | |
2287 | aChangeSet->Color = aColor; | |
2288 | aNames.Remove (aNames.Length()); | |
9196ea9d | 2289 | isOk = Standard_True; |
2290 | } | |
2291 | else if (Quantity_Color::ColorFromHex (aNames.Last().ToCString(), aChangeSet->Color)) | |
2292 | { | |
2293 | aNames.Remove (aNames.Length()); | |
8316c618 | 2294 | isOk = Standard_True; |
2295 | } | |
2296 | else if (aNames.Length() >= 3) | |
2297 | { | |
2a332745 | 2298 | const char* anArgVec[3] = |
8316c618 | 2299 | { |
2a332745 | 2300 | aNames.Value (aNames.Upper() - 2).ToCString(), |
2301 | aNames.Value (aNames.Upper() - 1).ToCString(), | |
2302 | aNames.Value (aNames.Upper() - 0).ToCString(), | |
8316c618 | 2303 | }; |
2a332745 | 2304 | |
dae2a922 | 2305 | Standard_Integer aNbParsed = Draw::ParseColor (3, anArgVec, aChangeSet->Color); |
2a332745 | 2306 | isOk = aNbParsed == 3; |
2307 | aNames.Remove (aNames.Length()); | |
2308 | aNames.Remove (aNames.Length()); | |
2309 | aNames.Remove (aNames.Length()); | |
8316c618 | 2310 | } |
2311 | if (!isOk) | |
2312 | { | |
23fe70ec | 2313 | Message::SendFail ("Error: not enough arguments!"); |
8316c618 | 2314 | return 1; |
2315 | } | |
ad3217cd | 2316 | } |
2317 | else if (aCmdName == "vunsetcolor") | |
2318 | { | |
2319 | aChangeSet->ToSetColor = -1; | |
2320 | } | |
2321 | else if (aCmdName == "vsettransparency") | |
2322 | { | |
2323 | if (aNames.IsEmpty() | |
d45edf24 | 2324 | || !aNames.Last().IsRealValue (Standard_True)) |
ad3217cd | 2325 | { |
23fe70ec | 2326 | Message::SendFail ("Error: not enough arguments!"); |
ad3217cd | 2327 | return 1; |
2328 | } | |
2329 | aChangeSet->ToSetTransparency = 1; | |
2330 | aChangeSet->Transparency = aNames.Last().RealValue(); | |
2331 | aNames.Remove (aNames.Length()); | |
2332 | } | |
2333 | else if (aCmdName == "vunsettransparency") | |
2334 | { | |
2335 | aChangeSet->ToSetTransparency = -1; | |
2336 | } | |
2337 | else if (aCmdName == "vsetmaterial") | |
2338 | { | |
2339 | if (aNames.IsEmpty()) | |
2340 | { | |
23fe70ec | 2341 | Message::SendFail ("Error: not enough arguments!"); |
ad3217cd | 2342 | return 1; |
2343 | } | |
2344 | aChangeSet->ToSetMaterial = 1; | |
61168418 | 2345 | aChangeSet->MatName = aNames.Last(); |
ad3217cd | 2346 | aNames.Remove (aNames.Length()); |
61168418 | 2347 | if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString(), aChangeSet->Material)) |
2348 | { | |
23fe70ec | 2349 | Message::SendFail() << "Syntax error: unknown material '" << aChangeSet->MatName << "'."; |
61168418 | 2350 | return 1; |
2351 | } | |
ad3217cd | 2352 | } |
2353 | else if (aCmdName == "vunsetmaterial") | |
2354 | { | |
2355 | aChangeSet->ToSetMaterial = -1; | |
2356 | } | |
2a332745 | 2357 | else if (aCmdName == "vsetinteriorstyle") |
2358 | { | |
2359 | if (aNames.IsEmpty() | |
d45edf24 | 2360 | || !aNames.Last().IsRealValue (Standard_True)) |
2a332745 | 2361 | { |
23fe70ec | 2362 | Message::SendFail ("Error: not enough arguments!"); |
2a332745 | 2363 | return 1; |
2364 | } | |
2365 | aChangeSet->ToSetInterior = 1; | |
2366 | if (!parseInteriorStyle (aNames.Last(), aChangeSet->InteriorStyle)) | |
2367 | { | |
23fe70ec | 2368 | Message::SendFail() << "Error: wrong syntax at " << aNames.Last(); |
2a332745 | 2369 | return 1; |
2370 | } | |
2371 | aNames.Remove (aNames.Length()); | |
2372 | } | |
2373 | else if (aCmdName == "vsetedgetype") | |
2374 | { | |
2375 | aChangeSet->ToSetDrawEdges = 1; | |
2376 | toParseAliasArgs = true; | |
2377 | } | |
2378 | else if (aCmdName == "vunsetedgetype") | |
2379 | { | |
2380 | aChangeSet->ToSetDrawEdges = -1; | |
2381 | aChangeSet->ToSetEdgeColor = -1; | |
2382 | aChangeSet->ToSetTypeOfEdge = -1; | |
2383 | aChangeSet->TypeOfEdge = Aspect_TOL_SOLID; | |
2384 | } | |
0493ffd0 | 2385 | else if (aCmdName == "vshowfaceboundary") |
2386 | { | |
2387 | aChangeSet->ToSetFaceBoundaryDraw = 1; | |
2388 | toParseAliasArgs = true; | |
2389 | if (aNames.Size() >= 2 | |
2390 | && aNames.Value (2).IsIntegerValue()) | |
2391 | { | |
2392 | if (aNames.Size() == 7) | |
2393 | { | |
2394 | if (ViewerTest::ParseLineType (aNames.Value (7).ToCString(), aChangeSet->TypeOfFaceBoundaryLine)) | |
2395 | { | |
2396 | aChangeSet->ToSetTypeOfFaceBoundaryLine = 1; | |
2397 | aNames.Remove (7); | |
2398 | } | |
2399 | } | |
2400 | if (aNames.Size() == 6 | |
d45edf24 | 2401 | && aNames.Value (6).IsRealValue (Standard_True)) |
0493ffd0 | 2402 | { |
2403 | aChangeSet->ToSetFaceBoundaryWidth = 1; | |
2404 | aChangeSet->FaceBoundaryWidth = aNames.Value (6).RealValue(); | |
2405 | aNames.Remove (6); | |
2406 | } | |
2407 | if (aNames.Size() == 5 | |
2408 | && aNames.Value (3).IsIntegerValue() | |
2409 | && aNames.Value (4).IsIntegerValue() | |
2410 | && aNames.Value (5).IsIntegerValue()) | |
2411 | { | |
2412 | aChangeSet->ToSetFaceBoundaryColor = 1; | |
2413 | aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0, | |
2414 | aNames.Value (4).IntegerValue() / 255.0, | |
2415 | aNames.Value (5).IntegerValue() / 255.0, | |
ba00aab7 | 2416 | Quantity_TOC_sRGB); |
0493ffd0 | 2417 | aNames.Remove (5); |
2418 | aNames.Remove (4); | |
2419 | aNames.Remove (3); | |
2420 | } | |
2421 | if (aNames.Size() == 2) | |
2422 | { | |
2423 | toParseAliasArgs = false; | |
2424 | aChangeSet->ToSetFaceBoundaryDraw = aNames.Value (2).IntegerValue() == 1 ? 1 : -1; | |
2425 | aNames.Remove (2); | |
2426 | } | |
2427 | } | |
2428 | } | |
ad3217cd | 2429 | else if (anArgIter >= theArgNb) |
2430 | { | |
23fe70ec | 2431 | Message::SendFail ("Error: not enough arguments!"); |
ad3217cd | 2432 | return 1; |
7fd59977 | 2433 | } |
2434 | ||
2a332745 | 2435 | if (!aChangeSet->IsEmpty() |
2436 | && !toParseAliasArgs) | |
ad3217cd | 2437 | { |
2438 | anArgIter = theArgNb; | |
2439 | } | |
2440 | for (; anArgIter < theArgNb; ++anArgIter) | |
2441 | { | |
2442 | TCollection_AsciiString anArg = theArgVec[anArgIter]; | |
2443 | anArg.LowerCase(); | |
2444 | if (anArg == "-setwidth" | |
2a332745 | 2445 | || anArg == "-width" |
2446 | || anArg == "-setlinewidth" | |
2447 | || anArg == "-linewidth" | |
2448 | || anArg == "-setedgewidth" | |
2449 | || anArg == "-setedgeswidth" | |
2450 | || anArg == "-edgewidth" | |
0493ffd0 | 2451 | || anArg == "-edgeswidth" |
2452 | || anArg == "-setfaceboundarywidth" | |
2453 | || anArg == "-setboundarywidth" | |
2454 | || anArg == "-faceboundarywidth" | |
2455 | || anArg == "-boundarywidth") | |
ad3217cd | 2456 | { |
2457 | if (++anArgIter >= theArgNb) | |
2458 | { | |
23fe70ec | 2459 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ad3217cd | 2460 | return 1; |
2461 | } | |
0493ffd0 | 2462 | |
2463 | const Standard_Real aWidth = Draw::Atof (theArgVec[anArgIter]); | |
2a332745 | 2464 | if (anArg == "-setedgewidth" |
2465 | || anArg == "-setedgeswidth" | |
2466 | || anArg == "-edgewidth" | |
2467 | || anArg == "-edgeswidth" | |
2468 | || aCmdName == "vsetedgetype") | |
2469 | { | |
2470 | aChangeSet->ToSetEdgeWidth = 1; | |
0493ffd0 | 2471 | aChangeSet->EdgeWidth = aWidth; |
2472 | } | |
2473 | else if (anArg == "-setfaceboundarywidth" | |
2474 | || anArg == "-setboundarywidth" | |
2475 | || anArg == "-faceboundarywidth" | |
2476 | || anArg == "-boundarywidth" | |
2477 | || aCmdName == "vshowfaceboundary") | |
2478 | { | |
2479 | aChangeSet->ToSetFaceBoundaryWidth = 1; | |
2480 | aChangeSet->FaceBoundaryWidth = aWidth; | |
2a332745 | 2481 | } |
2482 | else | |
2483 | { | |
2484 | aChangeSet->ToSetLineWidth = 1; | |
0493ffd0 | 2485 | aChangeSet->LineWidth = aWidth; |
2a332745 | 2486 | } |
7fd59977 | 2487 | } |
ad3217cd | 2488 | else if (anArg == "-unsetwidth" |
2a332745 | 2489 | || anArg == "-unsetlinewidth" |
2490 | || anArg == "-unsetedgewidth") | |
ad3217cd | 2491 | { |
2a332745 | 2492 | if (anArg == "-unsetedgewidth") |
2493 | { | |
2494 | aChangeSet->ToSetEdgeWidth = -1; | |
2495 | aChangeSet->EdgeWidth = 1.0; | |
2496 | } | |
2497 | else | |
2498 | { | |
2499 | aChangeSet->ToSetLineWidth = -1; | |
2500 | aChangeSet->LineWidth = 1.0; | |
2501 | } | |
ad3217cd | 2502 | } |
2503 | else if (anArg == "-settransp" | |
2a332745 | 2504 | || anArg == "-settransparency" |
2505 | || anArg == "-transparency" | |
2506 | || anArg == "-transp") | |
ad3217cd | 2507 | { |
2508 | if (++anArgIter >= theArgNb) | |
2509 | { | |
23fe70ec | 2510 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ad3217cd | 2511 | return 1; |
2512 | } | |
2513 | aChangeSet->ToSetTransparency = 1; | |
2514 | aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]); | |
2515 | if (aChangeSet->Transparency >= 0.0 | |
2516 | && aChangeSet->Transparency <= Precision::Confusion()) | |
2517 | { | |
2518 | aChangeSet->ToSetTransparency = -1; | |
2519 | aChangeSet->Transparency = 0.0; | |
eafb234b | 2520 | } |
7fd59977 | 2521 | } |
2a332745 | 2522 | else if (anArg == "-setalphamode" |
2523 | || anArg == "-alphamode") | |
c40eb6b9 | 2524 | { |
2525 | if (++anArgIter >= theArgNb) | |
2526 | { | |
23fe70ec | 2527 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
c40eb6b9 | 2528 | return 1; |
2529 | } | |
2530 | aChangeSet->ToSetAlphaMode = 1; | |
2531 | aChangeSet->AlphaCutoff = 0.5f; | |
2532 | { | |
2533 | TCollection_AsciiString aParam (theArgVec[anArgIter]); | |
2534 | aParam.LowerCase(); | |
2535 | if (aParam == "opaque") | |
2536 | { | |
2537 | aChangeSet->AlphaMode = Graphic3d_AlphaMode_Opaque; | |
2538 | } | |
2539 | else if (aParam == "mask") | |
2540 | { | |
2541 | aChangeSet->AlphaMode = Graphic3d_AlphaMode_Mask; | |
2542 | } | |
2543 | else if (aParam == "blend") | |
2544 | { | |
2545 | aChangeSet->AlphaMode = Graphic3d_AlphaMode_Blend; | |
2546 | } | |
33425a46 | 2547 | else if (aParam == "maskblend" |
2548 | || aParam == "blendmask") | |
2549 | { | |
2550 | aChangeSet->AlphaMode = Graphic3d_AlphaMode_MaskBlend; | |
2551 | } | |
c40eb6b9 | 2552 | else if (aParam == "blendauto" |
2553 | || aParam == "auto") | |
2554 | { | |
2555 | aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto; | |
2556 | } | |
2557 | else | |
2558 | { | |
23fe70ec | 2559 | Message::SendFail() << "Error: wrong syntax at " << aParam; |
c40eb6b9 | 2560 | return 1; |
2561 | } | |
2562 | } | |
2563 | ||
2564 | if (anArgIter + 1 < theArgNb | |
2565 | && theArgVec[anArgIter + 1][0] != '-') | |
2566 | { | |
2567 | TCollection_AsciiString aParam2 (theArgVec[anArgIter + 1]); | |
d45edf24 | 2568 | if (aParam2.IsRealValue (Standard_True)) |
c40eb6b9 | 2569 | { |
2570 | aChangeSet->AlphaCutoff = (float )aParam2.RealValue(); | |
2571 | ++anArgIter; | |
2572 | } | |
2573 | } | |
2574 | } | |
9db675b3 | 2575 | else if (anArg == "-setfaceculling" |
2576 | || anArg == "-faceculling") | |
2577 | { | |
2578 | if (++anArgIter >= theArgNb) | |
2579 | { | |
2580 | Message::SendFail() << "Error: wrong syntax at " << anArg; | |
2581 | return 1; | |
2582 | } | |
2583 | ||
2584 | aChangeSet->ToSetFaceCulling = 1; | |
2585 | { | |
2586 | TCollection_AsciiString aParam (theArgVec[anArgIter]); | |
2587 | aParam.LowerCase(); | |
2588 | if (aParam == "auto") | |
2589 | { | |
2590 | aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_Auto; | |
2591 | } | |
2592 | else if (aParam == "backculled" | |
2593 | || aParam == "backcull" | |
2594 | || aParam == "back") | |
2595 | { | |
2596 | aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_BackCulled; | |
2597 | } | |
2598 | else if (aParam == "frontculled" | |
2599 | || aParam == "frontcull" | |
2600 | || aParam == "front") | |
2601 | { | |
2602 | aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_FrontCulled; | |
2603 | } | |
2604 | else if (aParam == "doublesided" | |
2605 | || aParam == "off") | |
2606 | { | |
2607 | aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_DoubleSided; | |
2608 | } | |
2609 | else | |
2610 | { | |
2611 | Message::SendFail() << "Error: wrong syntax at '" << aParam << "'"; | |
2612 | return 1; | |
2613 | } | |
2614 | } | |
2615 | } | |
5bffb882 | 2616 | else if (anArg == "-setvis" |
2a332745 | 2617 | || anArg == "-setvisibility" |
2618 | || anArg == "-visibility") | |
5bffb882 | 2619 | { |
2620 | if (++anArgIter >= theArgNb) | |
2621 | { | |
23fe70ec | 2622 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
5bffb882 | 2623 | return 1; |
2624 | } | |
2625 | ||
2626 | aChangeSet->ToSetVisibility = 1; | |
2627 | aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]); | |
2628 | } | |
2a332745 | 2629 | else if (anArg == "-setalpha" |
2630 | || anArg == "-alpha") | |
ad3217cd | 2631 | { |
2632 | if (++anArgIter >= theArgNb) | |
7fd59977 | 2633 | { |
23fe70ec | 2634 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ad3217cd | 2635 | return 1; |
2636 | } | |
2637 | aChangeSet->ToSetTransparency = 1; | |
2638 | aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]); | |
2639 | if (aChangeSet->Transparency < 0.0 | |
2640 | || aChangeSet->Transparency > 1.0) | |
2641 | { | |
23fe70ec | 2642 | Message::SendFail() << "Error: the transparency should be within [0; 1] range (specified " << aChangeSet->Transparency << ")"; |
ad3217cd | 2643 | return 1; |
2644 | } | |
2645 | aChangeSet->Transparency = 1.0 - aChangeSet->Transparency; | |
2646 | if (aChangeSet->Transparency >= 0.0 | |
2647 | && aChangeSet->Transparency <= Precision::Confusion()) | |
2648 | { | |
2649 | aChangeSet->ToSetTransparency = -1; | |
2650 | aChangeSet->Transparency = 0.0; | |
7fd59977 | 2651 | } |
7fd59977 | 2652 | } |
ad3217cd | 2653 | else if (anArg == "-unsettransp" |
0ae61cf3 | 2654 | || anArg == "-unsettransparency" |
ad3217cd | 2655 | || anArg == "-unsetalpha" |
2656 | || anArg == "-opaque") | |
2657 | { | |
2658 | aChangeSet->ToSetTransparency = -1; | |
2659 | aChangeSet->Transparency = 0.0; | |
2660 | } | |
2a332745 | 2661 | else if (anArg == "-setcolor" |
0493ffd0 | 2662 | || anArg == "-color" |
6b9b7e3c | 2663 | || anArg == "-setbackfacecolor" |
2664 | || anArg == "-backfacecolor" | |
2665 | || anArg == "-setbackcolor" | |
2666 | || anArg == "-backcolor" | |
0493ffd0 | 2667 | || anArg == "-setfaceboundarycolor" |
2668 | || anArg == "-setboundarycolor" | |
2669 | || anArg == "-faceboundarycolor" | |
2670 | || anArg == "-boundarycolor") | |
ad3217cd | 2671 | { |
2a332745 | 2672 | Quantity_Color aColor; |
dae2a922 | 2673 | Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1, |
2674 | theArgVec + anArgIter + 1, | |
2675 | aColor); | |
2a332745 | 2676 | if (aNbParsed == 0) |
ad3217cd | 2677 | { |
23fe70ec | 2678 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
2a332745 | 2679 | return 1; |
8316c618 | 2680 | } |
2a332745 | 2681 | anArgIter += aNbParsed; |
2682 | if (aCmdName == "vsetedgetype") | |
8316c618 | 2683 | { |
2a332745 | 2684 | aChangeSet->ToSetEdgeColor = 1; |
2685 | aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor); | |
2686 | } | |
0493ffd0 | 2687 | else if (aCmdName == "vshowfaceboundary" |
2688 | || anArg == "-setfaceboundarycolor" | |
2689 | || anArg == "-setboundarycolor" | |
2690 | || anArg == "-faceboundarycolor" | |
2691 | || anArg == "-boundarycolor") | |
2692 | { | |
2693 | aChangeSet->ToSetFaceBoundaryColor = 1; | |
2694 | aChangeSet->FaceBoundaryColor = aColor; | |
2695 | } | |
6b9b7e3c | 2696 | else if (anArg == "-setbackfacecolor" |
2697 | || anArg == "-backfacecolor" | |
2698 | || anArg == "-setbackcolor" | |
2699 | || anArg == "-backcolor") | |
2700 | { | |
2701 | aChangeSet->ToSetBackFaceColor = 1; | |
2702 | aChangeSet->BackFaceColor = aColor; | |
2703 | } | |
2a332745 | 2704 | else |
2705 | { | |
2706 | aChangeSet->ToSetColor = 1; | |
2707 | aChangeSet->Color = aColor; | |
7fd59977 | 2708 | } |
7fd59977 | 2709 | } |
2a332745 | 2710 | else if (anArg == "-setlinetype" |
2711 | || anArg == "-linetype" | |
2712 | || anArg == "-setedgetype" | |
2713 | || anArg == "-setedgestype" | |
2714 | || anArg == "-edgetype" | |
2715 | || anArg == "-edgestype" | |
0493ffd0 | 2716 | || anArg == "-setfaceboundarystyle" |
2717 | || anArg == "-faceboundarystyle" | |
2718 | || anArg == "-boundarystyle" | |
2719 | || anArg == "-setfaceboundarytype" | |
2720 | || anArg == "-faceboundarytype" | |
2721 | || anArg == "-setboundarytype" | |
2722 | || anArg == "-boundarytype" | |
2a332745 | 2723 | || anArg == "-type") |
ac116c22 | 2724 | { |
2725 | if (++anArgIter >= theArgNb) | |
2726 | { | |
23fe70ec | 2727 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ac116c22 | 2728 | return 1; |
2729 | } | |
2a332745 | 2730 | Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY; |
3f1675c9 | 2731 | uint16_t aLinePattern = 0xFFFF; |
2732 | if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType, aLinePattern)) | |
ac116c22 | 2733 | { |
23fe70ec | 2734 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ac116c22 | 2735 | return 1; |
2736 | } | |
3f1675c9 | 2737 | |
2a332745 | 2738 | if (anArg == "-setedgetype" |
2739 | || anArg == "-setedgestype" | |
2740 | || anArg == "-edgetype" | |
2741 | || anArg == "-edgestype" | |
2742 | || aCmdName == "vsetedgetype") | |
2743 | { | |
3f1675c9 | 2744 | aChangeSet->TypeOfEdge = Graphic3d_Aspects::DefaultLineTypeForPattern (aLinePattern); |
2a332745 | 2745 | aChangeSet->ToSetTypeOfEdge = 1; |
2746 | } | |
0493ffd0 | 2747 | else if (anArg == "-setfaceboundarystyle" |
2748 | || anArg == "-faceboundarystyle" | |
2749 | || anArg == "-boundarystyle" | |
2750 | || anArg == "-setfaceboundarytype" | |
2751 | || anArg == "-faceboundarytype" | |
2752 | || anArg == "-setboundarytype" | |
2753 | || anArg == "-boundarytype" | |
2754 | || aCmdName == "vshowfaceboundary") | |
2755 | { | |
3f1675c9 | 2756 | aChangeSet->TypeOfFaceBoundaryLine = Graphic3d_Aspects::DefaultLineTypeForPattern (aLinePattern); |
0493ffd0 | 2757 | aChangeSet->ToSetTypeOfFaceBoundaryLine = 1; |
2758 | } | |
2a332745 | 2759 | else |
2760 | { | |
3f1675c9 | 2761 | aChangeSet->StippleLinePattern = aLinePattern; |
2a332745 | 2762 | aChangeSet->ToSetTypeOfLine = 1; |
2763 | } | |
ac116c22 | 2764 | } |
2a332745 | 2765 | else if (anArg == "-unsetlinetype" |
2766 | || anArg == "-unsetedgetype" | |
2767 | || anArg == "-unsetedgestype") | |
ac116c22 | 2768 | { |
2a332745 | 2769 | if (anArg == "-unsetedgetype" |
2770 | || anArg == "-unsetedgestype") | |
2771 | { | |
2772 | aChangeSet->ToSetTypeOfEdge = -1; | |
2773 | } | |
2774 | else | |
2775 | { | |
2776 | aChangeSet->ToSetTypeOfLine = -1; | |
2777 | } | |
ac116c22 | 2778 | } |
e0b24437 | 2779 | else if (anArg == "-setstipplelinefactor" |
2780 | || anArg == "-setstipplefactor" | |
2781 | || anArg == "-setlinefactor" | |
2782 | || anArg == "-stipplelinefactor" | |
2783 | || anArg == "-stipplefactor" | |
2784 | || anArg == "-linefactor") | |
2785 | { | |
2786 | if (aChangeSet->ToSetTypeOfLine == -1) | |
2787 | { | |
2788 | Message::SendFail() << "Error: -setStippleLineFactor requires -setLineType"; | |
2789 | return 1; | |
2790 | } | |
2791 | if (++anArgIter >= theArgNb) | |
2792 | { | |
2793 | Message::SendFail() << "Error: wrong syntax at " << anArg; | |
2794 | return 1; | |
2795 | } | |
2796 | aChangeSet->StippleLineFactor = (uint16_t )Draw::Atoi (theArgVec[anArgIter]); | |
2797 | } | |
33cc703b | 2798 | else if (anArg == "-setmarkertype" |
2a332745 | 2799 | || anArg == "-markertype" |
2800 | || anArg == "-setpointtype" | |
2801 | || anArg == "-pointtype") | |
33cc703b | 2802 | { |
2803 | if (++anArgIter >= theArgNb) | |
2804 | { | |
23fe70ec | 2805 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
33cc703b | 2806 | return 1; |
2807 | } | |
2808 | if (!ViewerTest::ParseMarkerType (theArgVec[anArgIter], aChangeSet->TypeOfMarker, aChangeSet->MarkerImage)) | |
2809 | { | |
23fe70ec | 2810 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
33cc703b | 2811 | return 1; |
2812 | } | |
2813 | ||
2814 | aChangeSet->ToSetTypeOfMarker = 1; | |
2815 | } | |
2816 | else if (anArg == "-unsetmarkertype" | |
2817 | || anArg == "-unsetpointtype") | |
2818 | { | |
2819 | aChangeSet->ToSetTypeOfMarker = -1; | |
2820 | } | |
2821 | else if (anArg == "-setmarkersize" | |
2a332745 | 2822 | || anArg == "-markersize" |
2823 | || anArg == "-setpointsize" | |
2824 | || anArg == "-pointsize") | |
33cc703b | 2825 | { |
2826 | if (++anArgIter >= theArgNb) | |
2827 | { | |
23fe70ec | 2828 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
33cc703b | 2829 | return 1; |
2830 | } | |
2831 | aChangeSet->ToSetMarkerSize = 1; | |
2832 | aChangeSet->MarkerSize = Draw::Atof (theArgVec[anArgIter]); | |
2833 | } | |
2834 | else if (anArg == "-unsetmarkersize" | |
2835 | || anArg == "-unsetpointsize") | |
2836 | { | |
2837 | aChangeSet->ToSetMarkerSize = -1; | |
2838 | aChangeSet->MarkerSize = 1.0; | |
2839 | } | |
ad3217cd | 2840 | else if (anArg == "-unsetcolor") |
2841 | { | |
2842 | aChangeSet->ToSetColor = -1; | |
2843 | aChangeSet->Color = DEFAULT_COLOR; | |
2844 | } | |
2845 | else if (anArg == "-setmat" | |
2a332745 | 2846 | || anArg == "-mat" |
2847 | || anArg == "-setmaterial" | |
2848 | || anArg == "-material") | |
ad3217cd | 2849 | { |
2850 | if (++anArgIter >= theArgNb) | |
2851 | { | |
23fe70ec | 2852 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ad3217cd | 2853 | return 1; |
2854 | } | |
2855 | aChangeSet->ToSetMaterial = 1; | |
61168418 | 2856 | aChangeSet->MatName = theArgVec[anArgIter]; |
2857 | if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString(), aChangeSet->Material)) | |
2858 | { | |
23fe70ec | 2859 | Message::SendFail() << "Syntax error: unknown material '" << aChangeSet->MatName << "'."; |
61168418 | 2860 | return 1; |
2861 | } | |
ad3217cd | 2862 | } |
2863 | else if (anArg == "-unsetmat" | |
2864 | || anArg == "-unsetmaterial") | |
2865 | { | |
2866 | aChangeSet->ToSetMaterial = -1; | |
a966542b | 2867 | aChangeSet->Material = Graphic3d_NameOfMaterial_DEFAULT; |
ad3217cd | 2868 | } |
2869 | else if (anArg == "-subshape" | |
2870 | || anArg == "-subshapes") | |
2871 | { | |
6262338c | 2872 | if (isDefaults) |
2873 | { | |
23fe70ec | 2874 | Message::SendFail() << "Error: wrong syntax. -subshapes can not be used together with -defaults call!"; |
6262338c | 2875 | return 1; |
2876 | } | |
2877 | ||
ad3217cd | 2878 | if (aNames.IsEmpty()) |
2879 | { | |
23fe70ec | 2880 | Message::SendFail() << "Error: main objects should specified explicitly when -subshapes is used!"; |
ad3217cd | 2881 | return 1; |
2882 | } | |
7fd59977 | 2883 | |
ad3217cd | 2884 | aChanges.Append (ViewerTest_AspectsChangeSet()); |
2885 | aChangeSet = &aChanges.ChangeLast(); | |
7fd59977 | 2886 | |
ad3217cd | 2887 | for (++anArgIter; anArgIter < theArgNb; ++anArgIter) |
2888 | { | |
2889 | Standard_CString aSubShapeName = theArgVec[anArgIter]; | |
2890 | if (*aSubShapeName == '-') | |
2891 | { | |
2892 | --anArgIter; | |
2893 | break; | |
2894 | } | |
7fd59977 | 2895 | |
ad3217cd | 2896 | TopoDS_Shape aSubShape = DBRep::Get (aSubShapeName); |
2897 | if (aSubShape.IsNull()) | |
2898 | { | |
23fe70ec | 2899 | Message::SendFail() << "Error: shape " << aSubShapeName << " doesn't found!"; |
ad3217cd | 2900 | return 1; |
2901 | } | |
2902 | aChangeSet->SubShapes.Append (aSubShape); | |
2903 | } | |
7fd59977 | 2904 | |
ad3217cd | 2905 | if (aChangeSet->SubShapes.IsEmpty()) |
2906 | { | |
23fe70ec | 2907 | Message::SendFail() << "Error: empty list is specified after -subshapes!"; |
ad3217cd | 2908 | return 1; |
2909 | } | |
2910 | } | |
2a332745 | 2911 | else if (anArg == "-setfreeboundary" |
2912 | || anArg == "-freeboundary" | |
2913 | || anArg == "-setfb" | |
6262338c | 2914 | || anArg == "-fb") |
2915 | { | |
0493ffd0 | 2916 | bool toEnable = true; |
dae2a922 | 2917 | if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable)) |
6262338c | 2918 | { |
23fe70ec | 2919 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
6262338c | 2920 | return 1; |
2921 | } | |
0493ffd0 | 2922 | ++anArgIter; |
2923 | aChangeSet->ToSetShowFreeBoundary = toEnable ? 1 : -1; | |
6262338c | 2924 | } |
2925 | else if (anArg == "-setfreeboundarywidth" | |
2a332745 | 2926 | || anArg == "-freeboundarywidth" |
2927 | || anArg == "-setfbwidth" | |
2928 | || anArg == "-fbwidth") | |
6262338c | 2929 | { |
2930 | if (++anArgIter >= theArgNb) | |
2931 | { | |
23fe70ec | 2932 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
6262338c | 2933 | return 1; |
2934 | } | |
2935 | aChangeSet->ToSetFreeBoundaryWidth = 1; | |
2936 | aChangeSet->FreeBoundaryWidth = Draw::Atof (theArgVec[anArgIter]); | |
2937 | } | |
2938 | else if (anArg == "-unsetfreeboundarywidth" | |
2939 | || anArg == "-unsetfbwidth") | |
2940 | { | |
2941 | aChangeSet->ToSetFreeBoundaryWidth = -1; | |
2942 | aChangeSet->FreeBoundaryWidth = 1.0; | |
2943 | } | |
2944 | else if (anArg == "-setfreeboundarycolor" | |
2a332745 | 2945 | || anArg == "-freeboundarycolor" |
2946 | || anArg == "-setfbcolor" | |
2947 | || anArg == "-fbcolor") | |
6262338c | 2948 | { |
dae2a922 | 2949 | Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1, |
2950 | theArgVec + anArgIter + 1, | |
2951 | aChangeSet->FreeBoundaryColor); | |
2a332745 | 2952 | if (aNbParsed == 0) |
6262338c | 2953 | { |
23fe70ec | 2954 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
2a332745 | 2955 | return 1; |
6262338c | 2956 | } |
2a332745 | 2957 | anArgIter += aNbParsed; |
6262338c | 2958 | aChangeSet->ToSetFreeBoundaryColor = 1; |
6262338c | 2959 | } |
2960 | else if (anArg == "-unsetfreeboundarycolor" | |
2961 | || anArg == "-unsetfbcolor") | |
2962 | { | |
2963 | aChangeSet->ToSetFreeBoundaryColor = -1; | |
2964 | aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR; | |
2965 | } | |
2a332745 | 2966 | else if (anArg == "-setisoontriangulation" |
2967 | || anArg == "-isoontriangulation" | |
2968 | || anArg == "-setisoontriang" | |
5ad8c033 | 2969 | || anArg == "-isoontriang") |
2970 | { | |
0493ffd0 | 2971 | bool toEnable = true; |
dae2a922 | 2972 | if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable)) |
5ad8c033 | 2973 | { |
23fe70ec | 2974 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
5ad8c033 | 2975 | return 1; |
2976 | } | |
0493ffd0 | 2977 | ++anArgIter; |
2978 | aChangeSet->ToEnableIsoOnTriangulation = toEnable ? 1 : -1; | |
2979 | } | |
2980 | else if (anArg == "-setfaceboundarydraw" | |
2981 | || anArg == "-setdrawfaceboundary" | |
2982 | || anArg == "-setdrawfaceboundaries" | |
2983 | || anArg == "-setshowfaceboundary" | |
2984 | || anArg == "-setshowfaceboundaries" | |
2985 | || anArg == "-setdrawfaceedges" | |
2986 | || anArg == "-faceboundarydraw" | |
2987 | || anArg == "-drawfaceboundary" | |
2988 | || anArg == "-drawfaceboundaries" | |
2989 | || anArg == "-showfaceboundary" | |
2990 | || anArg == "-showfaceboundaries" | |
2991 | || anArg == "-drawfaceedges" | |
2992 | || anArg == "-faceboundary" | |
2993 | || anArg == "-faceboundaries" | |
2994 | || anArg == "-faceedges") | |
2995 | { | |
2996 | bool toEnable = true; | |
dae2a922 | 2997 | if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable)) |
0493ffd0 | 2998 | { |
23fe70ec | 2999 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
0493ffd0 | 3000 | return 1; |
3001 | } | |
3002 | ++anArgIter; | |
3003 | aChangeSet->ToSetFaceBoundaryDraw = toEnable ? 1 : -1; | |
3004 | } | |
3005 | else if (anArg == "-unsetfaceboundary" | |
3006 | || anArg == "-unsetboundary") | |
3007 | { | |
3008 | aChangeSet->ToSetFaceBoundaryDraw = -1; | |
3009 | aChangeSet->ToSetFaceBoundaryColor = -1; | |
3010 | } | |
3011 | else if (anArg == "-setmostcontinuity" | |
3012 | || anArg == "-mostcontinuity") | |
3013 | { | |
3014 | TCollection_AsciiString aClassArg (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : ""); | |
3015 | aClassArg.LowerCase(); | |
3016 | GeomAbs_Shape aClass = GeomAbs_CN; | |
3017 | if (aClassArg == "c0" | |
3018 | || aClassArg == "0") | |
5ad8c033 | 3019 | { |
0493ffd0 | 3020 | aClass = GeomAbs_C0; |
5ad8c033 | 3021 | } |
9f9490e1 | 3022 | else if (aClassArg == "g1") |
3023 | { | |
3024 | aClass = GeomAbs_G1; | |
3025 | } | |
0493ffd0 | 3026 | else if (aClassArg == "c1" |
3027 | || aClassArg == "1") | |
5ad8c033 | 3028 | { |
0493ffd0 | 3029 | aClass = GeomAbs_C1; |
3030 | } | |
9f9490e1 | 3031 | else if (aClassArg == "g2") |
3032 | { | |
3033 | aClass = GeomAbs_G2; | |
3034 | } | |
0493ffd0 | 3035 | else if (aClassArg == "c2" |
3036 | || aClassArg == "2") | |
3037 | { | |
3038 | aClass = GeomAbs_C2; | |
3039 | } | |
3040 | else if (aClassArg == "c3" | |
3041 | || aClassArg == "3") | |
3042 | { | |
3043 | aClass = GeomAbs_C3; | |
3044 | } | |
3045 | else if (aClassArg == "cn" | |
3046 | || aClassArg == "n") | |
3047 | { | |
3048 | aClass = GeomAbs_CN; | |
5ad8c033 | 3049 | } |
3050 | else | |
3051 | { | |
23fe70ec | 3052 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
5ad8c033 | 3053 | return 1; |
3054 | } | |
0493ffd0 | 3055 | |
3056 | ++anArgIter; | |
3057 | aChangeSet->ToSetFaceBoundaryUpperContinuity = 1; | |
3058 | aChangeSet->FaceBoundaryUpperContinuity = aClass; | |
5ad8c033 | 3059 | } |
2a332745 | 3060 | else if (anArg == "-setmaxparamvalue" |
3061 | || anArg == "-maxparamvalue") | |
5ad8c033 | 3062 | { |
3063 | if (++anArgIter >= theArgNb) | |
3064 | { | |
23fe70ec | 3065 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
5ad8c033 | 3066 | return 1; |
3067 | } | |
3068 | aChangeSet->ToSetMaxParamValue = 1; | |
3069 | aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]); | |
3070 | } | |
2a332745 | 3071 | else if (anArg == "-setsensitivity" |
3072 | || anArg == "-sensitivity") | |
8a1170ad | 3073 | { |
3074 | if (isDefaults) | |
3075 | { | |
23fe70ec | 3076 | Message::SendFail() << "Error: wrong syntax. -setSensitivity can not be used together with -defaults call!"; |
8a1170ad | 3077 | return 1; |
3078 | } | |
3079 | ||
3080 | if (aNames.IsEmpty()) | |
3081 | { | |
23fe70ec | 3082 | Message::SendFail() << "Error: object and selection mode should specified explicitly when -setSensitivity is used!"; |
8a1170ad | 3083 | return 1; |
3084 | } | |
3085 | ||
3086 | if (anArgIter + 2 >= theArgNb) | |
3087 | { | |
23fe70ec | 3088 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
8a1170ad | 3089 | return 1; |
3090 | } | |
3091 | aChangeSet->ToSetSensitivity = 1; | |
3092 | aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]); | |
3093 | aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]); | |
3094 | } | |
2a332745 | 3095 | else if (anArg == "-sethatch" |
3096 | || anArg == "-hatch") | |
640d5fe2 | 3097 | { |
3098 | if (isDefaults) | |
3099 | { | |
23fe70ec | 3100 | Message::SendFail() << "Error: wrong syntax. -setHatch can not be used together with -defaults call!"; |
640d5fe2 | 3101 | return 1; |
3102 | } | |
3103 | ||
3104 | if (aNames.IsEmpty()) | |
3105 | { | |
23fe70ec | 3106 | Message::SendFail() << "Error: object should be specified explicitly when -setHatch is used!"; |
640d5fe2 | 3107 | return 1; |
3108 | } | |
3109 | ||
3110 | aChangeSet->ToSetHatch = 1; | |
eadea5ea | 3111 | TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]); |
3112 | if (anArgHatch.Length() <= 2) | |
640d5fe2 | 3113 | { |
ec7c343f | 3114 | const Standard_Integer anIntStyle = Draw::Atoi (anArgHatch.ToCString()); |
3115 | if (anIntStyle < 0 | |
3116 | || anIntStyle >= Aspect_HS_NB) | |
3117 | { | |
23fe70ec | 3118 | Message::SendFail() << "Error: hatch style is out of range [0, " << (Aspect_HS_NB - 1) << "]!"; |
ec7c343f | 3119 | return 1; |
3120 | } | |
3121 | aChangeSet->StdHatchStyle = anIntStyle; | |
640d5fe2 | 3122 | } |
3123 | else | |
3124 | { | |
eadea5ea | 3125 | aChangeSet->PathToHatchPattern = anArgHatch; |
640d5fe2 | 3126 | } |
3127 | } | |
2a332745 | 3128 | else if (anArg == "-setshadingmodel" |
3129 | || anArg == "-setshading" | |
3130 | || anArg == "-shadingmodel" | |
3131 | || anArg == "-shading") | |
dc89236f | 3132 | { |
3133 | if (++anArgIter >= theArgNb) | |
3134 | { | |
23fe70ec | 3135 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
dc89236f | 3136 | return 1; |
3137 | } | |
3138 | aChangeSet->ToSetShadingModel = 1; | |
3139 | aChangeSet->ShadingModelName = theArgVec[anArgIter]; | |
3140 | if (!ViewerTest::ParseShadingModel (theArgVec[anArgIter], aChangeSet->ShadingModel)) | |
3141 | { | |
23fe70ec | 3142 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
dc89236f | 3143 | return 1; |
3144 | } | |
3145 | } | |
3146 | else if (anArg == "-unsetshadingmodel") | |
3147 | { | |
3148 | aChangeSet->ToSetShadingModel = -1; | |
13b36bb1 | 3149 | aChangeSet->ShadingModel = Graphic3d_TypeOfShadingModel_DEFAULT; |
dc89236f | 3150 | } |
2a332745 | 3151 | else if (anArg == "-setinterior" |
3152 | || anArg == "-setinteriorstyle" | |
3153 | || anArg == "-interior" | |
3154 | || anArg == "-interiorstyle") | |
3155 | { | |
3156 | if (++anArgIter >= theArgNb) | |
3157 | { | |
23fe70ec | 3158 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
2a332745 | 3159 | return 1; |
3160 | } | |
3161 | aChangeSet->ToSetInterior = 1; | |
3162 | if (!parseInteriorStyle (theArgVec[anArgIter], aChangeSet->InteriorStyle)) | |
3163 | { | |
23fe70ec | 3164 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
2a332745 | 3165 | return 1; |
3166 | } | |
3167 | } | |
3168 | else if (anArg == "-unsetinterior") | |
3169 | { | |
3170 | aChangeSet->ToSetInterior = -1; | |
3171 | aChangeSet->InteriorStyle = Aspect_IS_SOLID; | |
3172 | } | |
6ef0d6f1 | 3173 | else if (anArg == "-setdrawoutline" |
3174 | || anArg == "-setdrawsilhouette" | |
3175 | || anArg == "-setoutline" | |
3176 | || anArg == "-setsilhouette" | |
3177 | || anArg == "-outline" | |
3178 | || anArg == "-outlined" | |
91836c86 | 3179 | || anArg == "-drawsilhouette" |
6ef0d6f1 | 3180 | || anArg == "-silhouette") |
3181 | { | |
3182 | bool toDrawOutline = true; | |
3183 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 3184 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toDrawOutline)) |
6ef0d6f1 | 3185 | { |
3186 | ++anArgIter; | |
3187 | } | |
3188 | aChangeSet->ToSetDrawSilhouette = toDrawOutline ? 1 : -1; | |
3189 | } | |
2a332745 | 3190 | else if (anArg == "-setdrawedges" |
3191 | || anArg == "-setdrawedge" | |
3192 | || anArg == "-drawedges" | |
3193 | || anArg == "-drawedge" | |
3194 | || anArg == "-edges") | |
3195 | { | |
3196 | bool toDrawEdges = true; | |
3197 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 3198 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges)) |
2a332745 | 3199 | { |
3200 | ++anArgIter; | |
3201 | } | |
3202 | aChangeSet->ToSetDrawEdges = toDrawEdges ? 1 : -1; | |
3203 | } | |
3204 | else if (anArg == "-setquadedges" | |
3205 | || anArg == "-setquads" | |
3206 | || anArg == "-quads" | |
3207 | || anArg == "-skipfirstedge") | |
3208 | { | |
3209 | bool isQuadMode = true; | |
3210 | if (anArgIter + 1 < theArgNb | |
dae2a922 | 3211 | && Draw::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode)) |
2a332745 | 3212 | { |
3213 | ++anArgIter; | |
3214 | } | |
3215 | aChangeSet->ToSetQuadEdges = isQuadMode ? 1 : -1; | |
3216 | } | |
3217 | else if (anArg == "-setedgecolor" | |
3218 | || anArg == "-setedgescolor" | |
3219 | || anArg == "-edgecolor" | |
3220 | || anArg == "-edgescolor") | |
3221 | { | |
dae2a922 | 3222 | Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1, |
3223 | theArgVec + anArgIter + 1, | |
3224 | aChangeSet->EdgeColor); | |
2a332745 | 3225 | if (aNbParsed == 0) |
3226 | { | |
23fe70ec | 3227 | Message::SendFail() << "Syntax error at '" << anArg << "'"; |
2a332745 | 3228 | return 1; |
3229 | } | |
3230 | anArgIter += aNbParsed; | |
3231 | aChangeSet->ToSetEdgeColor = 1; | |
3232 | } | |
3233 | else if (anArg == "-unset") | |
3234 | { | |
3235 | aChangeSet->ToSetVisibility = 1; | |
3236 | aChangeSet->Visibility = 1; | |
3237 | aChangeSet->ToSetLineWidth = -1; | |
3238 | aChangeSet->LineWidth = 1.0; | |
3239 | aChangeSet->ToSetTypeOfLine = -1; | |
3f1675c9 | 3240 | aChangeSet->StippleLinePattern = 0xFFFF; |
e0b24437 | 3241 | aChangeSet->StippleLineFactor = 1; |
2a332745 | 3242 | aChangeSet->ToSetTypeOfMarker = -1; |
3243 | aChangeSet->TypeOfMarker = Aspect_TOM_PLUS; | |
3244 | aChangeSet->ToSetMarkerSize = -1; | |
3245 | aChangeSet->MarkerSize = 1.0; | |
3246 | aChangeSet->ToSetTransparency = -1; | |
3247 | aChangeSet->Transparency = 0.0; | |
3248 | aChangeSet->ToSetAlphaMode = -1; | |
3249 | aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto; | |
3250 | aChangeSet->AlphaCutoff = 0.5f; | |
9db675b3 | 3251 | aChangeSet->ToSetFaceCulling = -1; |
3252 | aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_Auto; | |
2a332745 | 3253 | aChangeSet->ToSetColor = -1; |
3254 | aChangeSet->Color = DEFAULT_COLOR; | |
6b9b7e3c | 3255 | //aChangeSet->ToSetBackFaceColor = -1; // should be reset by ToSetColor |
3256 | //aChangeSet->BackFaceColor = DEFAULT_COLOR; | |
2a332745 | 3257 | aChangeSet->ToSetMaterial = -1; |
a966542b | 3258 | aChangeSet->Material = Graphic3d_NameOfMaterial_DEFAULT; |
2a332745 | 3259 | aChangeSet->ToSetShowFreeBoundary = -1; |
3260 | aChangeSet->ToSetFreeBoundaryColor = -1; | |
3261 | aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR; | |
3262 | aChangeSet->ToSetFreeBoundaryWidth = -1; | |
3263 | aChangeSet->FreeBoundaryWidth = 1.0; | |
0493ffd0 | 3264 | aChangeSet->ToEnableIsoOnTriangulation = -1; |
3265 | // | |
3266 | aChangeSet->ToSetFaceBoundaryDraw = -1; | |
3267 | aChangeSet->ToSetFaceBoundaryUpperContinuity = -1; | |
3268 | aChangeSet->FaceBoundaryUpperContinuity = GeomAbs_CN; | |
3269 | aChangeSet->ToSetFaceBoundaryColor = -1; | |
3270 | aChangeSet->FaceBoundaryColor = Quantity_NOC_BLACK; | |
3271 | aChangeSet->ToSetFaceBoundaryWidth = -1; | |
3272 | aChangeSet->FaceBoundaryWidth = 1.0f; | |
3273 | aChangeSet->ToSetTypeOfFaceBoundaryLine = -1; | |
3274 | aChangeSet->TypeOfFaceBoundaryLine = Aspect_TOL_SOLID; | |
3275 | // | |
2a332745 | 3276 | aChangeSet->ToSetHatch = -1; |
3277 | aChangeSet->StdHatchStyle = -1; | |
3278 | aChangeSet->PathToHatchPattern.Clear(); | |
3279 | aChangeSet->ToSetShadingModel = -1; | |
13b36bb1 | 3280 | aChangeSet->ShadingModel = Graphic3d_TypeOfShadingModel_DEFAULT; |
2a332745 | 3281 | aChangeSet->ToSetInterior = -1; |
3282 | aChangeSet->InteriorStyle = Aspect_IS_SOLID; | |
6ef0d6f1 | 3283 | aChangeSet->ToSetDrawSilhouette = -1; |
2a332745 | 3284 | aChangeSet->ToSetDrawEdges = -1; |
3285 | aChangeSet->ToSetQuadEdges = -1; | |
3286 | aChangeSet->ToSetEdgeColor = -1; | |
3287 | aChangeSet->EdgeColor = Quantity_ColorRGBA (DEFAULT_COLOR); | |
3288 | aChangeSet->ToSetEdgeWidth = -1; | |
3289 | aChangeSet->EdgeWidth = 1.0; | |
3290 | aChangeSet->ToSetTypeOfEdge = -1; | |
3291 | aChangeSet->TypeOfEdge = Aspect_TOL_SOLID; | |
3292 | } | |
0904aa63 | 3293 | else if (anArg == "-dumpjson") |
3294 | { | |
3295 | toDump = Standard_True; | |
3296 | } | |
3297 | else if (anArg == "-dumpcompact") | |
3298 | { | |
3299 | toCompactDump = Standard_False; | |
dae2a922 | 3300 | if (++anArgIter >= theArgNb && Draw::ParseOnOff (theArgVec[anArgIter + 1], toCompactDump)) |
0904aa63 | 3301 | ++anArgIter; |
3302 | } | |
3303 | else if (anArg == "-dumpdepth") | |
3304 | { | |
3305 | if (++anArgIter >= theArgNb) | |
3306 | { | |
23fe70ec | 3307 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
0904aa63 | 3308 | return 1; |
3309 | } | |
3310 | aDumpDepth = Draw::Atoi (theArgVec[anArgIter]); | |
3311 | } | |
7fd59977 | 3312 | else |
ad3217cd | 3313 | { |
23fe70ec | 3314 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
ad3217cd | 3315 | return 1; |
3316 | } | |
7fd59977 | 3317 | } |
99c56d44 | 3318 | |
ad3217cd | 3319 | for (NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges); |
3320 | aChangesIter.More(); aChangesIter.Next()) | |
3321 | { | |
c1197a15 | 3322 | if (!aChangesIter.Value().Validate()) |
ad3217cd | 3323 | { |
3324 | return 1; | |
3325 | } | |
99c56d44 | 3326 | } |
99c56d44 | 3327 | |
6262338c | 3328 | // special case for -defaults parameter. |
3329 | // all changed values will be set to DefaultDrawer. | |
3330 | if (isDefaults) | |
3331 | { | |
3332 | const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer(); | |
2a332745 | 3333 | aChangeSet->Apply (aDrawer); |
6262338c | 3334 | if (aChangeSet->ToSetLineWidth != 0) |
3335 | { | |
3336 | aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth); | |
3337 | aDrawer->WireAspect()->SetWidth (aChangeSet->LineWidth); | |
3338 | aDrawer->UnFreeBoundaryAspect()->SetWidth (aChangeSet->LineWidth); | |
3339 | aDrawer->SeenLineAspect()->SetWidth (aChangeSet->LineWidth); | |
3340 | } | |
3341 | if (aChangeSet->ToSetColor != 0) | |
3342 | { | |
3343 | aDrawer->ShadingAspect()->SetColor (aChangeSet->Color); | |
3344 | aDrawer->LineAspect()->SetColor (aChangeSet->Color); | |
3345 | aDrawer->UnFreeBoundaryAspect()->SetColor (aChangeSet->Color); | |
3346 | aDrawer->SeenLineAspect()->SetColor (aChangeSet->Color); | |
3347 | aDrawer->WireAspect()->SetColor (aChangeSet->Color); | |
3348 | aDrawer->PointAspect()->SetColor (aChangeSet->Color); | |
3349 | } | |
3350 | if (aChangeSet->ToSetTransparency != 0) | |
3351 | { | |
3352 | aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency); | |
3353 | } | |
3354 | if (aChangeSet->ToSetMaterial != 0) | |
3355 | { | |
3356 | aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material); | |
3357 | } | |
0493ffd0 | 3358 | if (aChangeSet->ToEnableIsoOnTriangulation != 0) |
5ad8c033 | 3359 | { |
3360 | aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1); | |
3361 | } | |
6262338c | 3362 | |
3363 | // redisplay all objects in context | |
3364 | for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next()) | |
3365 | { | |
b2fedee6 | 3366 | const Handle(AIS_InteractiveObject)& aPrs = aPrsIter.Current(); |
6262338c | 3367 | if (!aPrs.IsNull()) |
3368 | { | |
3369 | aCtx->Redisplay (aPrs, Standard_False); | |
3370 | } | |
3371 | } | |
0904aa63 | 3372 | if (toDump) |
3373 | { | |
3374 | Standard_SStream aStream; | |
3375 | aDrawer->DumpJson (aStream, aDumpDepth); | |
3376 | ||
3377 | if (toCompactDump) | |
3378 | theDI << Standard_Dump::Text (aStream); | |
3379 | else | |
3380 | theDI << Standard_Dump::FormatJson (aStream); | |
3381 | } | |
6262338c | 3382 | return 0; |
3383 | } | |
3384 | ||
ad3217cd | 3385 | for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next()) |
3386 | { | |
25c35042 | 3387 | const TCollection_AsciiString& aName = aPrsIter.CurrentName(); |
3388 | Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current(); | |
3389 | if (aPrs.IsNull()) | |
3390 | { | |
3391 | return 1; | |
3392 | } | |
3393 | ||
6262338c | 3394 | Handle(Prs3d_Drawer) aDrawer = aPrs->Attributes(); |
ad3217cd | 3395 | Handle(AIS_ColoredShape) aColoredPrs; |
3396 | Standard_Boolean toDisplay = Standard_False; | |
6262338c | 3397 | Standard_Boolean toRedisplay = Standard_False; |
5bffb882 | 3398 | if (aChanges.Length() > 1 || aChangeSet->ToSetVisibility == 1) |
ad3217cd | 3399 | { |
3400 | Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs); | |
3401 | if (aShapePrs.IsNull()) | |
3402 | { | |
23fe70ec | 3403 | Message::SendFail() << "Error: an object " << aName << " is not an AIS_Shape presentation!"; |
ad3217cd | 3404 | return 1; |
3405 | } | |
3406 | aColoredPrs = Handle(AIS_ColoredShape)::DownCast (aShapePrs); | |
3407 | if (aColoredPrs.IsNull()) | |
3408 | { | |
3409 | aColoredPrs = new AIS_ColoredShape (aShapePrs); | |
3e05329c | 3410 | if (aShapePrs->HasDisplayMode()) |
3411 | { | |
3412 | aColoredPrs->SetDisplayMode (aShapePrs->DisplayMode()); | |
3413 | } | |
3414 | aColoredPrs->SetLocalTransformation (aShapePrs->LocalTransformation()); | |
ad3217cd | 3415 | aCtx->Remove (aShapePrs, Standard_False); |
3416 | GetMapOfAIS().UnBind2 (aName); | |
3417 | GetMapOfAIS().Bind (aColoredPrs, aName); | |
3418 | toDisplay = Standard_True; | |
3419 | aShapePrs = aColoredPrs; | |
3420 | aPrs = aColoredPrs; | |
3421 | } | |
3422 | } | |
99c56d44 | 3423 | |
ad3217cd | 3424 | if (!aPrs.IsNull()) |
3425 | { | |
3426 | NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges); | |
3427 | aChangeSet = &aChangesIter.ChangeValue(); | |
5bffb882 | 3428 | if (aChangeSet->ToSetVisibility == 1) |
3429 | { | |
3430 | Handle(AIS_ColoredDrawer) aColDrawer = aColoredPrs->CustomAspects (aColoredPrs->Shape()); | |
3431 | aColDrawer->SetHidden (aChangeSet->Visibility == 0); | |
3432 | } | |
3433 | else if (aChangeSet->ToSetMaterial == 1) | |
ad3217cd | 3434 | { |
3435 | aCtx->SetMaterial (aPrs, aChangeSet->Material, Standard_False); | |
3436 | } | |
3437 | else if (aChangeSet->ToSetMaterial == -1) | |
3438 | { | |
3439 | aCtx->UnsetMaterial (aPrs, Standard_False); | |
3440 | } | |
3441 | if (aChangeSet->ToSetColor == 1) | |
3442 | { | |
3443 | aCtx->SetColor (aPrs, aChangeSet->Color, Standard_False); | |
3444 | } | |
3445 | else if (aChangeSet->ToSetColor == -1) | |
3446 | { | |
3447 | aCtx->UnsetColor (aPrs, Standard_False); | |
3448 | } | |
3449 | if (aChangeSet->ToSetTransparency == 1) | |
3450 | { | |
3451 | aCtx->SetTransparency (aPrs, aChangeSet->Transparency, Standard_False); | |
3452 | } | |
3453 | else if (aChangeSet->ToSetTransparency == -1) | |
3454 | { | |
3455 | aCtx->UnsetTransparency (aPrs, Standard_False); | |
3456 | } | |
3457 | if (aChangeSet->ToSetLineWidth == 1) | |
3458 | { | |
3459 | aCtx->SetWidth (aPrs, aChangeSet->LineWidth, Standard_False); | |
3460 | } | |
3461 | else if (aChangeSet->ToSetLineWidth == -1) | |
3462 | { | |
3463 | aCtx->UnsetWidth (aPrs, Standard_False); | |
3464 | } | |
0493ffd0 | 3465 | else if (aChangeSet->ToEnableIsoOnTriangulation != 0) |
5ad8c033 | 3466 | { |
3467 | aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs); | |
3468 | toRedisplay = Standard_True; | |
3469 | } | |
8a1170ad | 3470 | else if (aChangeSet->ToSetSensitivity != 0) |
3471 | { | |
3472 | aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity); | |
3473 | } | |
6262338c | 3474 | if (!aDrawer.IsNull()) |
3475 | { | |
2a332745 | 3476 | toRedisplay = aChangeSet->Apply (aDrawer) || toRedisplay; |
6262338c | 3477 | } |
99c56d44 | 3478 | |
ad3217cd | 3479 | for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next()) |
3480 | { | |
3481 | aChangeSet = &aChangesIter.ChangeValue(); | |
3482 | for (NCollection_Sequence<TopoDS_Shape>::Iterator aSubShapeIter (aChangeSet->SubShapes); | |
3483 | aSubShapeIter.More(); aSubShapeIter.Next()) | |
3484 | { | |
3485 | const TopoDS_Shape& aSubShape = aSubShapeIter.Value(); | |
2a332745 | 3486 | if (!aChangeSet->IsEmpty()) |
3487 | { | |
3488 | Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape); | |
3489 | aChangeSet->Apply (aCurColDrawer); | |
3490 | } | |
5bffb882 | 3491 | if (aChangeSet->ToSetVisibility == 1) |
3492 | { | |
3493 | Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape); | |
3494 | aCurColDrawer->SetHidden (aChangeSet->Visibility == 0); | |
3495 | } | |
ad3217cd | 3496 | if (aChangeSet->ToSetColor == 1) |
3497 | { | |
3498 | aColoredPrs->SetCustomColor (aSubShape, aChangeSet->Color); | |
3499 | } | |
c1197a15 | 3500 | if (aChangeSet->ToSetTransparency == 1) |
3501 | { | |
3502 | aColoredPrs->SetCustomTransparency (aSubShape, aChangeSet->Transparency); | |
3503 | } | |
ad3217cd | 3504 | if (aChangeSet->ToSetLineWidth == 1) |
3505 | { | |
3506 | aColoredPrs->SetCustomWidth (aSubShape, aChangeSet->LineWidth); | |
3507 | } | |
3508 | if (aChangeSet->ToSetColor == -1 | |
3509 | || aChangeSet->ToSetLineWidth == -1) | |
3510 | { | |
3511 | aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True); | |
3512 | } | |
8a1170ad | 3513 | if (aChangeSet->ToSetSensitivity != 0) |
3514 | { | |
3515 | aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity); | |
3516 | } | |
ad3217cd | 3517 | } |
3518 | } | |
3519 | if (toDisplay) | |
3520 | { | |
3521 | aCtx->Display (aPrs, Standard_False); | |
3522 | } | |
6262338c | 3523 | if (toRedisplay) |
3524 | { | |
3525 | aCtx->Redisplay (aPrs, Standard_False); | |
3526 | } | |
ad3217cd | 3527 | else if (!aColoredPrs.IsNull()) |
3528 | { | |
36132a2e | 3529 | aCtx->Redisplay (aColoredPrs, Standard_False); |
ad3217cd | 3530 | } |
2a332745 | 3531 | else |
3532 | { | |
3533 | aPrs->SynchronizeAspects(); | |
3534 | } | |
0904aa63 | 3535 | |
3536 | if (toDump) | |
3537 | { | |
3538 | Standard_SStream aStream; | |
3539 | aDrawer->DumpJson (aStream); | |
3540 | ||
3541 | theDI << aName << ": \n"; | |
3542 | theDI << Standard_Dump::FormatJson (aStream); | |
3543 | theDI << "\n"; | |
3544 | } | |
99c56d44 | 3545 | } |
ad3217cd | 3546 | } |
99c56d44 | 3547 | return 0; |
3548 | } | |
3549 | ||
7fd59977 | 3550 | //============================================================================== |
3551 | //function : VDonly2 | |
3552 | //author : ege | |
3553 | //purpose : Display only a selected or named object | |
519d35d8 | 3554 | // if there is no selected or named object s, nothing is done |
7fd59977 | 3555 | //============================================================================== |
519d35d8 | 3556 | static int VDonly2 (Draw_Interpretor& , |
3557 | Standard_Integer theArgNb, | |
3558 | const char** theArgVec) | |
7fd59977 | 3559 | { |
519d35d8 | 3560 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
4e18052b | 3561 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
519d35d8 | 3562 | if (aCtx.IsNull()) |
3563 | { | |
23fe70ec | 3564 | Message::SendFail ("Error: no active view!"); |
7fd59977 | 3565 | return 1; |
519d35d8 | 3566 | } |
7fd59977 | 3567 | |
519d35d8 | 3568 | Standard_Integer anArgIter = 1; |
3569 | for (; anArgIter < theArgNb; ++anArgIter) | |
3570 | { | |
4e18052b | 3571 | if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter])) |
519d35d8 | 3572 | { |
3573 | break; | |
3574 | } | |
3575 | } | |
7fd59977 | 3576 | |
519d35d8 | 3577 | NCollection_Map<Handle(Standard_Transient)> aDispSet; |
3578 | if (anArgIter >= theArgNb) | |
3579 | { | |
3580 | // display only selected objects | |
c3282ec1 | 3581 | if (aCtx->NbSelected() < 1) |
519d35d8 | 3582 | { |
3583 | return 0; | |
7fd59977 | 3584 | } |
3585 | ||
c3282ec1 | 3586 | for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) |
519d35d8 | 3587 | { |
c3282ec1 | 3588 | aDispSet.Add (aCtx->SelectedInteractive()); |
519d35d8 | 3589 | } |
3590 | } | |
3591 | else | |
3592 | { | |
3593 | // display only specified objects | |
3594 | for (; anArgIter < theArgNb; ++anArgIter) | |
3595 | { | |
3596 | TCollection_AsciiString aName = theArgVec[anArgIter]; | |
8f521168 | 3597 | Handle(AIS_InteractiveObject) aShape; |
3598 | if (GetMapOfAIS().Find2 (aName, aShape) | |
3599 | && !aShape.IsNull()) | |
519d35d8 | 3600 | { |
8f521168 | 3601 | aCtx->Display (aShape, Standard_False); |
3602 | aDispSet.Add (aShape); | |
7fd59977 | 3603 | } |
3604 | } | |
7fd59977 | 3605 | } |
519d35d8 | 3606 | |
3607 | // weed out other objects | |
3608 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next()) | |
3609 | { | |
3610 | if (aDispSet.Contains (anIter.Key1())) | |
3611 | { | |
3612 | continue; | |
3613 | } | |
3614 | ||
b2fedee6 | 3615 | if (const Handle(AIS_InteractiveObject)& aShape = anIter.Key1()) |
519d35d8 | 3616 | { |
519d35d8 | 3617 | aCtx->Erase (aShape, Standard_False); |
3618 | } | |
519d35d8 | 3619 | } |
7fd59977 | 3620 | return 0; |
3621 | } | |
3622 | ||
eef7fc64 | 3623 | //============================================================================== |
3624 | //function : VRemove | |
3625 | //purpose : Removes selected or named objects. | |
3626 | // If there is no selected or named objects, | |
3627 | // all objects in the viewer can be removed with argument -all. | |
3628 | // If -context is in arguments, the object is not deleted from the map of | |
3629 | // objects (deleted only from the current context). | |
3630 | //============================================================================== | |
3631 | int VRemove (Draw_Interpretor& theDI, | |
519d35d8 | 3632 | Standard_Integer theArgNb, |
3633 | const char** theArgVec) | |
eef7fc64 | 3634 | { |
4e18052b | 3635 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
3636 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); | |
3637 | if (aCtx.IsNull()) | |
eef7fc64 | 3638 | { |
23fe70ec | 3639 | Message::SendFail ("Error: no active view!"); |
eef7fc64 | 3640 | return 1; |
3641 | } | |
3642 | ||
4e18052b | 3643 | Standard_Boolean isContextOnly = Standard_False; |
3644 | Standard_Boolean toRemoveAll = Standard_False; | |
3645 | Standard_Boolean toPrintInfo = Standard_True; | |
ab1f4580 | 3646 | Standard_Boolean toFailOnError = Standard_True; |
519d35d8 | 3647 | |
3648 | Standard_Integer anArgIter = 1; | |
3649 | for (; anArgIter < theArgNb; ++anArgIter) | |
3650 | { | |
3651 | TCollection_AsciiString anArg = theArgVec[anArgIter]; | |
3652 | anArg.LowerCase(); | |
3653 | if (anArg == "-context") | |
3654 | { | |
3655 | isContextOnly = Standard_True; | |
3656 | } | |
3657 | else if (anArg == "-all") | |
3658 | { | |
3659 | toRemoveAll = Standard_True; | |
3660 | } | |
b7cd4ba7 | 3661 | else if (anArg == "-noinfo") |
3662 | { | |
3663 | toPrintInfo = Standard_False; | |
3664 | } | |
ab1f4580 | 3665 | else if (anArg == "-noerror" |
3666 | || anArg == "-nofail") | |
3667 | { | |
3668 | toFailOnError = Standard_False; | |
3669 | } | |
b6d587e3 | 3670 | else if (anUpdateTool.parseRedrawMode (anArg)) |
3671 | { | |
3672 | continue; | |
3673 | } | |
3674 | else | |
519d35d8 | 3675 | { |
3676 | break; | |
3677 | } | |
3678 | } | |
3679 | if (toRemoveAll | |
3680 | && anArgIter < theArgNb) | |
3681 | { | |
23fe70ec | 3682 | Message::SendFail ("Error: wrong syntax!"); |
b6d587e3 | 3683 | return 1; |
3684 | } | |
3685 | ||
eef7fc64 | 3686 | NCollection_List<TCollection_AsciiString> anIONameList; |
519d35d8 | 3687 | if (toRemoveAll) |
eef7fc64 | 3688 | { |
3689 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); | |
3690 | anIter.More(); anIter.Next()) | |
3691 | { | |
3692 | anIONameList.Append (anIter.Key2()); | |
3693 | } | |
3694 | } | |
519d35d8 | 3695 | else if (anArgIter < theArgNb) // removed objects names are in argument list |
eef7fc64 | 3696 | { |
519d35d8 | 3697 | for (; anArgIter < theArgNb; ++anArgIter) |
eef7fc64 | 3698 | { |
ab1f4580 | 3699 | const TCollection_AsciiString aName (theArgVec[anArgIter]); |
3700 | if (aName.Search ("*") != -1) | |
eef7fc64 | 3701 | { |
ab1f4580 | 3702 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next()) |
3703 | { | |
3704 | if (aPrsIter.Key1()->GetContext() != aCtx) | |
3705 | { | |
3706 | continue; | |
3707 | } | |
3708 | const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'"; | |
3709 | if (theDI.Eval (aCheck.ToCString()) == 0 | |
3710 | && *theDI.Result() == '1') | |
3711 | { | |
3712 | anIONameList.Append (aPrsIter.Key2()); | |
3713 | } | |
3714 | } | |
3715 | theDI.Reset(); | |
eef7fc64 | 3716 | continue; |
3717 | } | |
3718 | ||
ab1f4580 | 3719 | Handle(AIS_InteractiveObject) anIO; |
3720 | if (!GetMapOfAIS().Find2 (aName, anIO)) | |
eef7fc64 | 3721 | { |
ab1f4580 | 3722 | if (toFailOnError) |
3723 | { | |
23fe70ec | 3724 | Message::SendFail() << "Syntax error: '" << aName << "' was not bound to some object."; |
ab1f4580 | 3725 | return 1; |
3726 | } | |
3727 | } | |
3728 | else if (anIO->GetContext() != aCtx) | |
3729 | { | |
3730 | if (toFailOnError) | |
3731 | { | |
23fe70ec | 3732 | Message::SendFail() << "Syntax error: '" << aName << "' was not displayed in current context.\n" |
3733 | << "Please activate view with this object displayed and try again."; | |
ab1f4580 | 3734 | return 1; |
3735 | } | |
3736 | } | |
3737 | else | |
3738 | { | |
3739 | anIONameList.Append (aName); | |
eef7fc64 | 3740 | } |
eef7fc64 | 3741 | } |
3742 | } | |
c3282ec1 | 3743 | else if (aCtx->NbSelected() > 0) |
eef7fc64 | 3744 | { |
3745 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); | |
3746 | anIter.More(); anIter.Next()) | |
3747 | { | |
8f521168 | 3748 | if (!aCtx->IsSelected (anIter.Key1())) |
eef7fc64 | 3749 | { |
eef7fc64 | 3750 | continue; |
3751 | } | |
3752 | ||
d09dda09 | 3753 | anIONameList.Append (anIter.Key2()); |
3754 | continue; | |
eef7fc64 | 3755 | } |
3756 | } | |
3757 | ||
3758 | // Unbind all removed objects from the map of displayed IO. | |
3759 | for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList); | |
3760 | anIter.More(); anIter.Next()) | |
3761 | { | |
8f521168 | 3762 | const Handle(AIS_InteractiveObject) anIO = GetMapOfAIS().Find2 (anIter.Value()); |
d09dda09 | 3763 | aCtx->Remove (anIO, Standard_False); |
3764 | if (toPrintInfo) | |
519d35d8 | 3765 | { |
ab1f4580 | 3766 | theDI << anIter.Value() << " "; |
519d35d8 | 3767 | } |
519d35d8 | 3768 | if (!isContextOnly) |
3769 | { | |
3770 | GetMapOfAIS().UnBind2 (anIter.Value()); | |
3771 | } | |
3772 | } | |
eef7fc64 | 3773 | return 0; |
3774 | } | |
3775 | ||
7fd59977 | 3776 | //============================================================================== |
b514beda | 3777 | //function : VErase |
3778 | //purpose : Erase some selected or named objects | |
7fd59977 | 3779 | // if there is no selected or named objects, the whole viewer is erased |
7fd59977 | 3780 | //============================================================================== |
b514beda | 3781 | int VErase (Draw_Interpretor& theDI, |
3782 | Standard_Integer theArgNb, | |
3783 | const char** theArgVec) | |
7fd59977 | 3784 | { |
a1954302 | 3785 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
3786 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); | |
3787 | ViewerTest_AutoUpdater anUpdateTool (aCtx, aView); | |
4e18052b | 3788 | if (aCtx.IsNull()) |
b514beda | 3789 | { |
23fe70ec | 3790 | Message::SendFail ("Error: no active view!"); |
7fd59977 | 3791 | return 1; |
b514beda | 3792 | } |
519d35d8 | 3793 | |
519d35d8 | 3794 | const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall"; |
3795 | ||
3796 | Standard_Integer anArgIter = 1; | |
a272ed94 | 3797 | Standard_Boolean toEraseInView = Standard_False; |
ab1f4580 | 3798 | Standard_Boolean toFailOnError = Standard_True; |
b6d587e3 | 3799 | TColStd_SequenceOfAsciiString aNamesOfEraseIO; |
519d35d8 | 3800 | for (; anArgIter < theArgNb; ++anArgIter) |
3801 | { | |
b6d587e3 | 3802 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); |
3803 | anArgCase.LowerCase(); | |
3804 | if (anUpdateTool.parseRedrawMode (anArgCase)) | |
519d35d8 | 3805 | { |
b6d587e3 | 3806 | continue; |
3807 | } | |
a272ed94 | 3808 | else if (anArgCase == "-view" |
3809 | || anArgCase == "-inview") | |
3810 | { | |
3811 | toEraseInView = Standard_True; | |
3812 | } | |
ab1f4580 | 3813 | else if (anArgCase == "-noerror" |
3814 | || anArgCase == "-nofail") | |
3815 | { | |
3816 | toFailOnError = Standard_False; | |
3817 | } | |
b6d587e3 | 3818 | else |
3819 | { | |
3820 | aNamesOfEraseIO.Append (theArgVec[anArgIter]); | |
519d35d8 | 3821 | } |
3822 | } | |
3823 | ||
b6d587e3 | 3824 | if (!aNamesOfEraseIO.IsEmpty() && toEraseAll) |
b514beda | 3825 | { |
23fe70ec | 3826 | Message::SendFail() << "Error: wrong syntax, " << theArgVec[0] << " too much arguments."; |
b6d587e3 | 3827 | return 1; |
3828 | } | |
7fd59977 | 3829 | |
b6d587e3 | 3830 | if (!aNamesOfEraseIO.IsEmpty()) |
3831 | { | |
3832 | // Erase named objects | |
ab1f4580 | 3833 | NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString> aPrsList; |
3834 | for (TColStd_SequenceOfAsciiString::Iterator anIter (aNamesOfEraseIO); anIter.More(); anIter.Next()) | |
b514beda | 3835 | { |
ab1f4580 | 3836 | const TCollection_AsciiString& aName = anIter.Value(); |
3837 | if (aName.Search ("*") != -1) | |
b514beda | 3838 | { |
ab1f4580 | 3839 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next()) |
3840 | { | |
3841 | const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'"; | |
3842 | if (theDI.Eval (aCheck.ToCString()) == 0 | |
3843 | && *theDI.Result() == '1') | |
3844 | { | |
3845 | aPrsList.Add (aPrsIter.Key1(), aPrsIter.Key2()); | |
3846 | } | |
3847 | } | |
3848 | theDI.Reset(); | |
b514beda | 3849 | } |
ab1f4580 | 3850 | else |
b514beda | 3851 | { |
ab1f4580 | 3852 | Handle(AIS_InteractiveObject) anIO; |
3853 | if (!GetMapOfAIS().Find2 (aName, anIO)) | |
a272ed94 | 3854 | { |
ab1f4580 | 3855 | if (toFailOnError) |
3856 | { | |
23fe70ec | 3857 | Message::SendFail() << "Syntax error: '" << aName << "' is not found"; |
ab1f4580 | 3858 | return 1; |
3859 | } | |
a272ed94 | 3860 | } |
3861 | else | |
3862 | { | |
ab1f4580 | 3863 | aPrsList.Add (anIO, aName); |
a272ed94 | 3864 | } |
b514beda | 3865 | } |
7fd59977 | 3866 | } |
ab1f4580 | 3867 | |
3868 | for (NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString>::Iterator anIter (aPrsList); anIter.More(); anIter.Next()) | |
3869 | { | |
3870 | theDI << anIter.Value() << " "; | |
3871 | if (toEraseInView) | |
3872 | { | |
3873 | aCtx->SetViewAffinity (anIter.Key(), aView, Standard_False); | |
3874 | } | |
3875 | else | |
3876 | { | |
3877 | aCtx->Erase (anIter.Key(), Standard_False); | |
3878 | } | |
3879 | } | |
7fd59977 | 3880 | } |
c3282ec1 | 3881 | else if (!toEraseAll && aCtx->NbSelected() > 0) |
b514beda | 3882 | { |
b6d587e3 | 3883 | // Erase selected objects |
b514beda | 3884 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
3885 | anIter.More(); anIter.Next()) | |
3886 | { | |
b2fedee6 | 3887 | const Handle(AIS_InteractiveObject)& anIO = anIter.Key1(); |
b514beda | 3888 | if (!anIO.IsNull() |
c3282ec1 | 3889 | && aCtx->IsSelected (anIO)) |
b514beda | 3890 | { |
8f521168 | 3891 | theDI << anIter.Key2() << " "; |
a272ed94 | 3892 | if (toEraseInView) |
3893 | { | |
3894 | aCtx->SetViewAffinity (anIO, aView, Standard_False); | |
3895 | } | |
7fd59977 | 3896 | } |
3897 | } | |
671b6fe0 | 3898 | |
3899 | if (!toEraseInView) | |
3900 | { | |
3901 | aCtx->EraseSelected (Standard_False); | |
3902 | } | |
b514beda | 3903 | } |
519d35d8 | 3904 | else |
b514beda | 3905 | { |
b6d587e3 | 3906 | // Erase all objects |
519d35d8 | 3907 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
3908 | anIter.More(); anIter.Next()) | |
b514beda | 3909 | { |
b2fedee6 | 3910 | const Handle(AIS_InteractiveObject)& anIO = anIter.Key1(); |
519d35d8 | 3911 | if (!anIO.IsNull()) |
3912 | { | |
a272ed94 | 3913 | if (toEraseInView) |
3914 | { | |
3915 | aCtx->SetViewAffinity (anIO, aView, Standard_False); | |
3916 | } | |
3917 | else | |
3918 | { | |
3919 | aCtx->Erase (anIO, Standard_False); | |
3920 | } | |
519d35d8 | 3921 | } |
7fd59977 | 3922 | } |
7fd59977 | 3923 | } |
b6d587e3 | 3924 | |
7fd59977 | 3925 | return 0; |
3926 | } | |
3927 | ||
7fd59977 | 3928 | //============================================================================== |
3929 | //function : VDisplayAll | |
7fd59977 | 3930 | //purpose : Display all the objects of the Map |
7fd59977 | 3931 | //============================================================================== |
519d35d8 | 3932 | static int VDisplayAll (Draw_Interpretor& , |
3933 | Standard_Integer theArgNb, | |
3934 | const char** theArgVec) | |
7fd59977 | 3935 | |
3936 | { | |
4e18052b | 3937 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
3938 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); | |
3939 | if (aCtx.IsNull()) | |
519d35d8 | 3940 | { |
23fe70ec | 3941 | Message::SendFail ("Error: no active view!"); |
519d35d8 | 3942 | return 1; |
3943 | } | |
3944 | ||
519d35d8 | 3945 | Standard_Integer anArgIter = 1; |
3946 | for (; anArgIter < theArgNb; ++anArgIter) | |
3947 | { | |
b6d587e3 | 3948 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); |
3949 | anArgCase.LowerCase(); | |
68dcee02 | 3950 | if (anUpdateTool.parseRedrawMode (anArgCase)) |
b6d587e3 | 3951 | { |
3952 | continue; | |
3953 | } | |
3954 | else | |
519d35d8 | 3955 | { |
3956 | break; | |
7fd59977 | 3957 | } |
519d35d8 | 3958 | } |
3959 | if (anArgIter < theArgNb) | |
3960 | { | |
23fe70ec | 3961 | Message::SendFail() << theArgVec[0] << "Error: wrong syntax"; |
519d35d8 | 3962 | return 1; |
3963 | } | |
3964 | ||
519d35d8 | 3965 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
3966 | anIter.More(); anIter.Next()) | |
3967 | { | |
8f521168 | 3968 | aCtx->Erase (anIter.Key1(), Standard_False); |
519d35d8 | 3969 | } |
3970 | ||
3971 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); | |
3972 | anIter.More(); anIter.Next()) | |
3973 | { | |
8f521168 | 3974 | aCtx->Display (anIter.Key1(), Standard_False); |
7fd59977 | 3975 | } |
3976 | return 0; | |
3977 | } | |
3978 | ||
8e5fb5ea | 3979 | //! Auxiliary method to check if presentation exists |
3980 | inline Standard_Integer checkMode (const Handle(AIS_InteractiveContext)& theCtx, | |
3981 | const Handle(AIS_InteractiveObject)& theIO, | |
3982 | const Standard_Integer theMode) | |
c2a388f8 | 3983 | { |
8e5fb5ea | 3984 | if (theIO.IsNull() || theCtx.IsNull()) |
c2a388f8 | 3985 | { |
8e5fb5ea | 3986 | return -1; |
c2a388f8 | 3987 | } |
3988 | ||
3989 | if (theMode != -1) | |
3990 | { | |
3991 | if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode)) | |
3992 | { | |
8e5fb5ea | 3993 | return theMode; |
c2a388f8 | 3994 | } |
3995 | } | |
3996 | else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode())) | |
3997 | { | |
8e5fb5ea | 3998 | return theIO->DisplayMode(); |
c2a388f8 | 3999 | } |
4000 | else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode())) | |
4001 | { | |
8e5fb5ea | 4002 | return theCtx->DisplayMode(); |
c2a388f8 | 4003 | } |
8e5fb5ea | 4004 | |
4005 | return -1; | |
c2a388f8 | 4006 | } |
4007 | ||
4008 | enum ViewerTest_BndAction | |
4009 | { | |
4010 | BndAction_Hide, | |
4011 | BndAction_Show, | |
4012 | BndAction_Print | |
4013 | }; | |
4014 | ||
4015 | //! Auxiliary method to print bounding box of presentation | |
8e5fb5ea | 4016 | inline void bndPresentation (Draw_Interpretor& theDI, |
4017 | const Handle(PrsMgr_PresentationManager)& theMgr, | |
4018 | const Handle(AIS_InteractiveObject)& theObj, | |
4019 | const Standard_Integer theDispMode, | |
4020 | const TCollection_AsciiString& theName, | |
4021 | const ViewerTest_BndAction theAction, | |
f838dac4 | 4022 | const Handle(Prs3d_Drawer)& theStyle) |
c2a388f8 | 4023 | { |
4024 | switch (theAction) | |
4025 | { | |
4026 | case BndAction_Hide: | |
4027 | { | |
f838dac4 | 4028 | theMgr->Unhighlight (theObj); |
c2a388f8 | 4029 | break; |
4030 | } | |
4031 | case BndAction_Show: | |
4032 | { | |
8e5fb5ea | 4033 | theMgr->Color (theObj, theStyle, theDispMode); |
c2a388f8 | 4034 | break; |
4035 | } | |
4036 | case BndAction_Print: | |
4037 | { | |
8e5fb5ea | 4038 | Bnd_Box aBox; |
4039 | for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next()) | |
4040 | { | |
7dd7c146 | 4041 | if (aPrsIter.Value()->Mode() != theDispMode) |
8e5fb5ea | 4042 | continue; |
4043 | ||
7dd7c146 | 4044 | aBox = aPrsIter.Value()->MinMaxValues(); |
8e5fb5ea | 4045 | } |
ed063270 | 4046 | gp_Pnt aMin = aBox.CornerMin(); |
4047 | gp_Pnt aMax = aBox.CornerMax(); | |
c2a388f8 | 4048 | theDI << theName << "\n" |
ed063270 | 4049 | << aMin.X() << " " << aMin.Y() << " " << aMin.Z() << " " |
4050 | << aMax.X() << " " << aMax.Y() << " " << aMax.Z() << "\n"; | |
c2a388f8 | 4051 | break; |
4052 | } | |
4053 | } | |
4054 | } | |
4055 | ||
4056 | //============================================================================== | |
4057 | //function : VBounding | |
4058 | //purpose : | |
4059 | //============================================================================== | |
4060 | int VBounding (Draw_Interpretor& theDI, | |
4061 | Standard_Integer theArgNb, | |
4062 | const char** theArgVec) | |
4063 | { | |
4064 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
4e18052b | 4065 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
c2a388f8 | 4066 | if (aCtx.IsNull()) |
4067 | { | |
23fe70ec | 4068 | Message::SendFail ("Error: no active view!"); |
c2a388f8 | 4069 | return 1; |
4070 | } | |
4071 | ||
4e18052b | 4072 | ViewerTest_BndAction anAction = BndAction_Show; |
4073 | Standard_Integer aMode = -1; | |
c2a388f8 | 4074 | |
f838dac4 | 4075 | Handle(Prs3d_Drawer) aStyle; |
8e5fb5ea | 4076 | |
c2a388f8 | 4077 | Standard_Integer anArgIter = 1; |
4078 | for (; anArgIter < theArgNb; ++anArgIter) | |
4079 | { | |
4080 | TCollection_AsciiString anArg (theArgVec[anArgIter]); | |
4081 | anArg.LowerCase(); | |
4082 | if (anArg == "-print") | |
4083 | { | |
4084 | anAction = BndAction_Print; | |
4085 | } | |
4086 | else if (anArg == "-show") | |
4087 | { | |
4088 | anAction = BndAction_Show; | |
4089 | } | |
4090 | else if (anArg == "-hide") | |
4091 | { | |
4092 | anAction = BndAction_Hide; | |
4093 | } | |
4094 | else if (anArg == "-mode") | |
4095 | { | |
4096 | if (++anArgIter >= theArgNb) | |
4097 | { | |
23fe70ec | 4098 | Message::SendFail() << "Error: wrong syntax at " << anArg; |
c2a388f8 | 4099 | return 1; |
4100 | } | |
4101 | aMode = Draw::Atoi (theArgVec[anArgIter]); | |
4102 | } | |
4e18052b | 4103 | else if (!anUpdateTool.parseRedrawMode (anArg)) |
c2a388f8 | 4104 | { |
4105 | break; | |
4106 | } | |
4107 | } | |
4108 | ||
8e5fb5ea | 4109 | if (anAction == BndAction_Show) |
f838dac4 | 4110 | { |
4111 | aStyle = new Prs3d_Drawer(); | |
4112 | aStyle->SetMethod (Aspect_TOHM_BOUNDBOX); | |
4113 | aStyle->SetColor (Quantity_NOC_GRAY99); | |
4114 | } | |
8e5fb5ea | 4115 | |
4116 | Standard_Integer aHighlightedMode = -1; | |
c2a388f8 | 4117 | if (anArgIter < theArgNb) |
4118 | { | |
4119 | // has a list of names | |
4120 | for (; anArgIter < theArgNb; ++anArgIter) | |
4121 | { | |
4122 | TCollection_AsciiString aName = theArgVec[anArgIter]; | |
8f521168 | 4123 | Handle(AIS_InteractiveObject) anIO; |
4124 | if (!GetMapOfAIS().Find2 (aName, anIO)) | |
c2a388f8 | 4125 | { |
23fe70ec | 4126 | Message::SendFail() << "Error: presentation " << aName << " does not exist"; |
c2a388f8 | 4127 | return 1; |
4128 | } | |
4129 | ||
8e5fb5ea | 4130 | aHighlightedMode = checkMode (aCtx, anIO, aMode); |
4131 | if (aHighlightedMode == -1) | |
c2a388f8 | 4132 | { |
23fe70ec | 4133 | Message::SendFail() << "Error: object " << aName << " has no presentation with mode " << aMode; |
c2a388f8 | 4134 | return 1; |
4135 | } | |
8e5fb5ea | 4136 | bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle); |
c2a388f8 | 4137 | } |
4138 | } | |
c3282ec1 | 4139 | else if (aCtx->NbSelected() > 0) |
c2a388f8 | 4140 | { |
4141 | // remove all currently selected objects | |
c3282ec1 | 4142 | for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) |
c2a388f8 | 4143 | { |
c3282ec1 | 4144 | Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive(); |
8e5fb5ea | 4145 | aHighlightedMode = checkMode (aCtx, anIO, aMode); |
4146 | if (aHighlightedMode != -1) | |
c2a388f8 | 4147 | { |
8e5fb5ea | 4148 | bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, |
4149 | GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle); | |
c2a388f8 | 4150 | } |
4151 | } | |
4152 | } | |
4153 | else | |
4154 | { | |
4155 | // all objects | |
4156 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); | |
4157 | anIter.More(); anIter.Next()) | |
4158 | { | |
b2fedee6 | 4159 | const Handle(AIS_InteractiveObject)& anIO = anIter.Key1(); |
8e5fb5ea | 4160 | aHighlightedMode = checkMode (aCtx, anIO, aMode); |
4161 | if (aHighlightedMode != -1) | |
c2a388f8 | 4162 | { |
8e5fb5ea | 4163 | bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle); |
c2a388f8 | 4164 | } |
4165 | } | |
4166 | } | |
c2a388f8 | 4167 | return 0; |
4168 | } | |
4169 | ||
d399d3c3 | 4170 | //============================================================================== |
4171 | //function : VTexture | |
4172 | //purpose : | |
4173 | //============================================================================== | |
a6dee93d | 4174 | Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) |
7fd59977 | 4175 | { |
a6dee93d | 4176 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
4177 | if (aCtx.IsNull()) | |
4178 | { | |
23fe70ec | 4179 | Message::SendFail() << "Error: no active view!"; |
a6dee93d | 4180 | return 1; |
4181 | } | |
4182 | ||
633084b8 | 4183 | int toModulate = -1, toSetSRgb = -1; |
4184 | bool toSetFilter = false, toSetAniso = false, toSetTrsfAngle = false, toSetTrsfTrans = false, toSetTrsfScale = false; | |
a6dee93d | 4185 | Standard_ShortReal aTrsfRotAngle = 0.0f; |
4186 | Graphic3d_Vec2 aTrsfTrans (0.0f, 0.0f); | |
4187 | Graphic3d_Vec2 aTrsfScale (1.0f, 1.0f); | |
4188 | Graphic3d_TypeOfTextureFilter aFilter = Graphic3d_TOTF_NEAREST; | |
4189 | Graphic3d_LevelOfTextureAnisotropy anAnisoFilter = Graphic3d_LOTA_OFF; | |
4190 | ||
c84c2ef7 | 4191 | Handle(AIS_InteractiveObject) aTexturedIO; |
4192 | Handle(AIS_Shape) aTexturedShape; | |
cc8cbabe | 4193 | Handle(Graphic3d_TextureSet) aTextureSetOld; |
633084b8 | 4194 | NCollection_Vector<Handle(Graphic3d_TextureMap)> aTextureVecNew; |
4195 | bool toSetGenRepeat = false, toSetGenScale = false, toSetGenOrigin = false, toSetImage = false, toComputeUV = false; | |
a6dee93d | 4196 | |
4197 | const TCollection_AsciiString aCommandName (theArgVec[0]); | |
4198 | bool toSetDefaults = aCommandName == "vtexdefault"; | |
7fd59977 | 4199 | |
a6dee93d | 4200 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
4201 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) | |
d399d3c3 | 4202 | { |
a6dee93d | 4203 | const TCollection_AsciiString aName = theArgVec[anArgIter]; |
4204 | TCollection_AsciiString aNameCase = aName; | |
4205 | aNameCase.LowerCase(); | |
4206 | if (anUpdateTool.parseRedrawMode (aName)) | |
7fd59977 | 4207 | { |
a6dee93d | 4208 | continue; |
7fd59977 | 4209 | } |
a6dee93d | 4210 | else if (aTexturedIO.IsNull()) |
d399d3c3 | 4211 | { |
a6dee93d | 4212 | const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfIO = GetMapOfAIS(); |
4213 | if (aMapOfIO.IsBound2 (aName)) | |
d399d3c3 | 4214 | { |
c84c2ef7 | 4215 | aTexturedIO = aMapOfIO.Find2 (aName); |
4216 | aTexturedShape = Handle(AIS_Shape)::DownCast (aTexturedIO); | |
d399d3c3 | 4217 | } |
a6dee93d | 4218 | if (aTexturedIO.IsNull()) |
d399d3c3 | 4219 | { |
23fe70ec | 4220 | Message::SendFail() << "Syntax error: shape " << aName << " does not exists in the viewer."; |
a6dee93d | 4221 | return 1; |
d399d3c3 | 4222 | } |
4223 | ||
a6dee93d | 4224 | if (aTexturedIO->Attributes()->HasOwnShadingAspect()) |
4225 | { | |
cc8cbabe | 4226 | aTextureSetOld = aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureSet(); |
a6dee93d | 4227 | } |
d399d3c3 | 4228 | } |
c84c2ef7 | 4229 | else if (!aTexturedShape.IsNull() |
4230 | && (aNameCase == "-scale" | |
4231 | || aNameCase == "-setscale" | |
4232 | || aCommandName == "vtexscale")) | |
7fd59977 | 4233 | { |
a6dee93d | 4234 | if (aCommandName != "vtexscale") |
4235 | { | |
4236 | ++anArgIter; | |
4237 | } | |
4238 | if (anArgIter < theArgsNb) | |
4239 | { | |
4240 | TCollection_AsciiString aValU (theArgVec[anArgIter]); | |
4241 | TCollection_AsciiString aValUCase = aValU; | |
4242 | aValUCase.LowerCase(); | |
4243 | toSetGenScale = true; | |
4244 | if (aValUCase == "off") | |
4245 | { | |
c84c2ef7 | 4246 | aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0)); |
a6dee93d | 4247 | continue; |
4248 | } | |
4249 | else if (anArgIter + 1 < theArgsNb) | |
4250 | { | |
4251 | TCollection_AsciiString aValV (theArgVec[anArgIter + 1]); | |
d45edf24 | 4252 | if (aValU.IsRealValue (Standard_True) |
4253 | && aValV.IsRealValue (Standard_True)) | |
a6dee93d | 4254 | { |
c84c2ef7 | 4255 | aTexturedShape->SetTextureScaleUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue())); |
a6dee93d | 4256 | ++anArgIter; |
4257 | continue; | |
4258 | } | |
4259 | } | |
4260 | } | |
23fe70ec | 4261 | Message::SendFail() << "Syntax error: unexpected argument '" << aName << "'"; |
31160f80 | 4262 | return 1; |
7fd59977 | 4263 | } |
c84c2ef7 | 4264 | else if (!aTexturedShape.IsNull() |
4265 | && (aNameCase == "-origin" | |
4266 | || aNameCase == "-setorigin" | |
4267 | || aCommandName == "vtexorigin")) | |
d399d3c3 | 4268 | { |
a6dee93d | 4269 | if (aCommandName != "vtexorigin") |
4270 | { | |
4271 | ++anArgIter; | |
4272 | } | |
4273 | if (anArgIter < theArgsNb) | |
4274 | { | |
4275 | TCollection_AsciiString aValU (theArgVec[anArgIter]); | |
4276 | TCollection_AsciiString aValUCase = aValU; | |
4277 | aValUCase.LowerCase(); | |
4278 | toSetGenOrigin = true; | |
4279 | if (aValUCase == "off") | |
4280 | { | |
c84c2ef7 | 4281 | aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0)); |
a6dee93d | 4282 | continue; |
4283 | } | |
4284 | else if (anArgIter + 1 < theArgsNb) | |
4285 | { | |
4286 | TCollection_AsciiString aValV (theArgVec[anArgIter + 1]); | |
d45edf24 | 4287 | if (aValU.IsRealValue (Standard_True) |
4288 | && aValV.IsRealValue (Standard_True)) | |
a6dee93d | 4289 | { |
c84c2ef7 | 4290 | aTexturedShape->SetTextureOriginUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue())); |
a6dee93d | 4291 | ++anArgIter; |
4292 | continue; | |
4293 | } | |
4294 | } | |
4295 | } | |
23fe70ec | 4296 | Message::SendFail() << "Syntax error: unexpected argument '" << aName << "'"; |
a6dee93d | 4297 | return 1; |
d399d3c3 | 4298 | } |
c84c2ef7 | 4299 | else if (!aTexturedShape.IsNull() |
4300 | && (aNameCase == "-repeat" | |
4301 | || aNameCase == "-setrepeat" | |
4302 | || aCommandName == "vtexrepeat")) | |
d399d3c3 | 4303 | { |
a6dee93d | 4304 | if (aCommandName != "vtexrepeat") |
4305 | { | |
4306 | ++anArgIter; | |
4307 | } | |
4308 | if (anArgIter < theArgsNb) | |
4309 | { | |
4310 | TCollection_AsciiString aValU (theArgVec[anArgIter]); | |
4311 | TCollection_AsciiString aValUCase = aValU; | |
4312 | aValUCase.LowerCase(); | |
4313 | toSetGenRepeat = true; | |
4314 | if (aValUCase == "off") | |
4315 | { | |
c84c2ef7 | 4316 | aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0)); |
a6dee93d | 4317 | continue; |
4318 | } | |
4319 | else if (anArgIter + 1 < theArgsNb) | |
4320 | { | |
4321 | TCollection_AsciiString aValV (theArgVec[anArgIter + 1]); | |
d45edf24 | 4322 | if (aValU.IsRealValue (Standard_True) |
4323 | && aValV.IsRealValue (Standard_True)) | |
a6dee93d | 4324 | { |
c84c2ef7 | 4325 | aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue())); |
a6dee93d | 4326 | ++anArgIter; |
4327 | continue; | |
4328 | } | |
4329 | } | |
4330 | } | |
23fe70ec | 4331 | Message::SendFail() << "Syntax error: unexpected argument '" << aName << "'"; |
a6dee93d | 4332 | return 1; |
d399d3c3 | 4333 | } |
c585f731 | 4334 | else if (aNameCase == "-modulate" |
4335 | || aNameCase == "-nomodulate") | |
d399d3c3 | 4336 | { |
c585f731 | 4337 | toModulate = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; |
4338 | } | |
4339 | else if (aNameCase == "-srgb" | |
4340 | || aNameCase == "-nosrgb") | |
4341 | { | |
4342 | toSetSRgb = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIter) ? 1 : 0; | |
d399d3c3 | 4343 | } |
a6dee93d | 4344 | else if ((aNameCase == "-setfilter" |
4345 | || aNameCase == "-filter") | |
4346 | && anArgIter + 1 < theArgsNb) | |
d399d3c3 | 4347 | { |
a6dee93d | 4348 | TCollection_AsciiString aValue (theArgVec[anArgIter + 1]); |
4349 | aValue.LowerCase(); | |
4350 | ++anArgIter; | |
4351 | toSetFilter = true; | |
4352 | if (aValue == "nearest") | |
4353 | { | |
4354 | aFilter = Graphic3d_TOTF_NEAREST; | |
4355 | } | |
4356 | else if (aValue == "bilinear") | |
4357 | { | |
4358 | aFilter = Graphic3d_TOTF_BILINEAR; | |
4359 | } | |
4360 | else if (aValue == "trilinear") | |
4361 | { | |
4362 | aFilter = Graphic3d_TOTF_TRILINEAR; | |
4363 | } | |
4364 | else | |
4365 | { | |
23fe70ec | 4366 | Message::SendFail() << "Syntax error: unexpected argument '" << aValue << "'"; |
a6dee93d | 4367 | return 1; |
4368 | } | |
d399d3c3 | 4369 | } |
a6dee93d | 4370 | else if ((aNameCase == "-setaniso" |
4371 | || aNameCase == "-setanisofilter" | |
4372 | || aNameCase == "-aniso" | |
4373 | || aNameCase == "-anisofilter") | |
4374 | && anArgIter + 1 < theArgsNb) | |
d399d3c3 | 4375 | { |
a6dee93d | 4376 | TCollection_AsciiString aValue (theArgVec[anArgIter + 1]); |
4377 | aValue.LowerCase(); | |
4378 | ++anArgIter; | |
4379 | toSetAniso = true; | |
4380 | if (aValue == "off") | |
4381 | { | |
4382 | anAnisoFilter = Graphic3d_LOTA_OFF; | |
4383 | } | |
4384 | else if (aValue == "fast") | |
4385 | { | |
4386 | anAnisoFilter = Graphic3d_LOTA_FAST; | |
4387 | } | |
4388 | else if (aValue == "middle") | |
4389 | { | |
4390 | anAnisoFilter = Graphic3d_LOTA_MIDDLE; | |
4391 | } | |
4392 | else if (aValue == "quality" | |
4393 | || aValue == "high") | |
4394 | { | |
4395 | anAnisoFilter = Graphic3d_LOTA_QUALITY; | |
4396 | } | |
4397 | else | |
4398 | { | |
23fe70ec | 4399 | Message::SendFail() << "Syntax error: unexpected argument '" << aValue << "'"; |
a6dee93d | 4400 | return 1; |
4401 | } | |
d399d3c3 | 4402 | } |
a6dee93d | 4403 | else if ((aNameCase == "-rotateangle" |
4404 | || aNameCase == "-rotangle" | |
4405 | || aNameCase == "-rotate" | |
4406 | || aNameCase == "-angle" | |
4407 | || aNameCase == "-trsfangle") | |
4408 | && anArgIter + 1 < theArgsNb) | |
7fd59977 | 4409 | { |
a6dee93d | 4410 | aTrsfRotAngle = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1])); |
4411 | toSetTrsfAngle = true; | |
4412 | ++anArgIter; | |
7fd59977 | 4413 | } |
a6dee93d | 4414 | else if ((aNameCase == "-trsftrans" |
4415 | || aNameCase == "-trsftranslate" | |
4416 | || aNameCase == "-translate" | |
4417 | || aNameCase == "-translation") | |
4418 | && anArgIter + 2 < theArgsNb) | |
d399d3c3 | 4419 | { |
a6dee93d | 4420 | aTrsfTrans.x() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1])); |
4421 | aTrsfTrans.y() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 2])); | |
4422 | toSetTrsfTrans = true; | |
4423 | anArgIter += 2; | |
d399d3c3 | 4424 | } |
a6dee93d | 4425 | else if ((aNameCase == "-trsfscale") |
4426 | && anArgIter + 2 < theArgsNb) | |
d399d3c3 | 4427 | { |
a6dee93d | 4428 | aTrsfScale.x() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 1])); |
4429 | aTrsfScale.y() = Standard_ShortReal (Draw::Atof (theArgVec[anArgIter + 2])); | |
4430 | toSetTrsfScale = true; | |
4431 | anArgIter += 2; | |
d399d3c3 | 4432 | } |
a6dee93d | 4433 | else if (aNameCase == "-default" |
4434 | || aNameCase == "-defaults") | |
16420da1 | 4435 | { |
a6dee93d | 4436 | toSetDefaults = true; |
16420da1 | 4437 | } |
98e6c6d1 | 4438 | else if ((aNameCase == "-video") |
4439 | && anArgIter + 1 < theArgsNb) | |
4440 | { | |
4441 | const TCollection_AsciiString anInput (theArgVec[++anArgIter]); | |
4442 | Handle(Graphic3d_MediaTextureSet) aMedia = Handle(Graphic3d_MediaTextureSet)::DownCast (aTextureSetOld); | |
4443 | if (aMedia.IsNull()) | |
4444 | { | |
4445 | aMedia = new Graphic3d_MediaTextureSet(); | |
4446 | } | |
4447 | if (aMedia->Input() != anInput) | |
4448 | { | |
4449 | aMedia->OpenInput (anInput, false); | |
4450 | } | |
4451 | else | |
4452 | { | |
4453 | if (aMedia->SwapFrames() | |
4454 | && !aCtx->CurrentViewer()->ZLayerSettings (aTexturedIO->ZLayer()).IsImmediate()) | |
4455 | { | |
4456 | ViewerTest::CurrentView()->Invalidate(); | |
4457 | } | |
4458 | } | |
4459 | if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer()) | |
4460 | && aTexturedShape.IsNull()) | |
4461 | { | |
4462 | aTexturedIO->SetToUpdate(); | |
4463 | } | |
4464 | ||
4465 | toComputeUV = aTextureSetOld.IsNull(); | |
4466 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (true); | |
4467 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (aMedia); | |
4468 | aTextureSetOld.Nullify(); | |
4469 | } | |
633084b8 | 4470 | else if (aCommandName == "vtexture" |
4471 | && aTextureVecNew.IsEmpty() | |
4472 | && aNameCase == "-3d") | |
4473 | { | |
4474 | TColStd_SequenceOfAsciiString aSlicesSeq; | |
4475 | for (; anArgIter + 1 < theArgsNb; ++anArgIter) | |
4476 | { | |
4477 | TCollection_AsciiString aSlicePath (theArgVec[anArgIter + 1]); | |
4478 | if (aSlicePath.StartsWith ("-")) | |
4479 | { | |
4480 | break; | |
4481 | } | |
4482 | ||
4483 | aSlicesSeq.Append (aSlicePath); | |
4484 | } | |
4485 | ||
4486 | if (aSlicesSeq.Size() < 2) | |
4487 | { | |
4488 | Message::SendFail() << "Syntax error at '" << aNameCase << "'"; | |
4489 | return 1; | |
4490 | } | |
4491 | NCollection_Array1<TCollection_AsciiString> aSlices; | |
4492 | aSlices.Resize (0, aSlicesSeq.Size() - 1, false); | |
4493 | Standard_Integer aSliceIndex = 0; | |
4494 | for (const TCollection_AsciiString& aSliceIter : aSlicesSeq) | |
4495 | { | |
4496 | aSlices[aSliceIndex++] = aSliceIter; | |
4497 | } | |
4498 | ||
4499 | toSetImage = true; | |
4500 | aTextureVecNew.SetValue (0, new Graphic3d_Texture3D (aSlices)); | |
4501 | } | |
cc8cbabe | 4502 | else if (aCommandName == "vtexture" |
4503 | && (aTextureVecNew.IsEmpty() | |
4504 | || aNameCase.StartsWith ("-tex"))) | |
7fd59977 | 4505 | { |
cc8cbabe | 4506 | Standard_Integer aTexIndex = 0; |
4507 | TCollection_AsciiString aTexName = aName; | |
4508 | if (aNameCase.StartsWith ("-tex")) | |
4509 | { | |
4510 | if (anArgIter + 1 >= theArgsNb | |
4511 | || aNameCase.Length() < 5) | |
4512 | { | |
23fe70ec | 4513 | Message::SendFail() << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'"; |
cc8cbabe | 4514 | return 1; |
4515 | } | |
4516 | ||
4517 | TCollection_AsciiString aTexIndexStr = aNameCase.SubString (5, aNameCase.Length()); | |
4518 | if (!aTexIndexStr.IsIntegerValue()) | |
4519 | { | |
23fe70ec | 4520 | Message::SendFail() << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'"; |
cc8cbabe | 4521 | return 1; |
4522 | } | |
4523 | ||
4524 | aTexIndex = aTexIndexStr.IntegerValue(); | |
4525 | aTexName = theArgVec[anArgIter + 1]; | |
4526 | ++anArgIter; | |
4527 | } | |
4528 | if (aTexIndex >= Graphic3d_TextureUnit_NB | |
4529 | || aTexIndex >= aCtx->CurrentViewer()->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxCombinedTextureUnits)) | |
4530 | { | |
23fe70ec | 4531 | Message::SendFail ("Error: too many textures specified"); |
cc8cbabe | 4532 | return 1; |
4533 | } | |
4534 | ||
a6dee93d | 4535 | toSetImage = true; |
cc8cbabe | 4536 | if (aTexName.IsIntegerValue()) |
d399d3c3 | 4537 | { |
cc8cbabe | 4538 | const Standard_Integer aValue = aTexName.IntegerValue(); |
a6dee93d | 4539 | if (aValue < 0 || aValue >= Graphic3d_Texture2D::NumberOfTextures()) |
4540 | { | |
23fe70ec | 4541 | Message::SendFail() << "Syntax error: texture with ID " << aValue << " is undefined!"; |
a6dee93d | 4542 | return 1; |
4543 | } | |
633084b8 | 4544 | aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2D (Graphic3d_NameOfTexture2D (aValue))); |
d399d3c3 | 4545 | } |
cc8cbabe | 4546 | else if (aTexName == "?") |
d399d3c3 | 4547 | { |
a6dee93d | 4548 | const TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder(); |
7fd59977 | 4549 | |
586db386 | 4550 | theDi << "\n Files in current directory : \n\n"; |
d399d3c3 | 4551 | theDi.Eval ("glob -nocomplain *"); |
7fd59977 | 4552 | |
d399d3c3 | 4553 | TCollection_AsciiString aCmnd ("glob -nocomplain "); |
4554 | aCmnd += aTextureFolder; | |
4555 | aCmnd += "/* "; | |
7fd59977 | 4556 | |
a6dee93d | 4557 | theDi << "Files in " << aTextureFolder << " : \n\n"; |
d399d3c3 | 4558 | theDi.Eval (aCmnd.ToCString()); |
4559 | return 0; | |
4560 | } | |
cc8cbabe | 4561 | else if (aTexName != "off") |
d399d3c3 | 4562 | { |
cc8cbabe | 4563 | if (!OSD_File (aTexName).Exists()) |
a6dee93d | 4564 | { |
23fe70ec | 4565 | Message::SendFail() << "Syntax error: non-existing image file has been specified '" << aTexName << "'."; |
a6dee93d | 4566 | return 1; |
4567 | } | |
633084b8 | 4568 | aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2D (aTexName)); |
cc8cbabe | 4569 | } |
4570 | else | |
4571 | { | |
633084b8 | 4572 | aTextureVecNew.SetValue (aTexIndex, Handle(Graphic3d_TextureMap)()); |
d399d3c3 | 4573 | } |
7373e19f | 4574 | |
4575 | if (aTextureVecNew.Value (aTexIndex)) | |
4576 | { | |
4577 | aTextureVecNew.ChangeValue(aTexIndex)->GetParams()->SetTextureUnit((Graphic3d_TextureUnit)aTexIndex); | |
4578 | } | |
cc8cbabe | 4579 | } |
4580 | else | |
4581 | { | |
23fe70ec | 4582 | Message::SendFail() << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'"; |
cc8cbabe | 4583 | return 1; |
4584 | } | |
4585 | } | |
7fd59977 | 4586 | |
cc8cbabe | 4587 | if (toSetImage) |
4588 | { | |
4589 | // check if new image set is equal to already set one | |
4590 | Standard_Integer aNbChanged = 0; | |
4591 | Handle(Graphic3d_TextureSet) aTextureSetNew; | |
4592 | if (!aTextureVecNew.IsEmpty()) | |
4593 | { | |
4594 | aNbChanged = aTextureVecNew.Size(); | |
4595 | aTextureSetNew = new Graphic3d_TextureSet (aTextureVecNew.Size()); | |
4596 | for (Standard_Integer aTexIter = 0; aTexIter < aTextureSetNew->Size(); ++aTexIter) | |
d399d3c3 | 4597 | { |
633084b8 | 4598 | Handle(Graphic3d_TextureMap)& aTextureNew = aTextureVecNew.ChangeValue (aTexIter); |
cc8cbabe | 4599 | Handle(Graphic3d_TextureRoot) aTextureOld; |
4600 | if (!aTextureSetOld.IsNull() | |
4601 | && aTexIter < aTextureSetOld->Size()) | |
4602 | { | |
4603 | aTextureOld = aTextureSetOld->Value (aTexIter); | |
4604 | } | |
4605 | ||
4606 | if (!aTextureOld.IsNull() | |
4607 | && !aTextureNew.IsNull()) | |
a6dee93d | 4608 | { |
4609 | *aTextureNew->GetParams() = *aTextureOld->GetParams(); | |
633084b8 | 4610 | |
4611 | Handle(Graphic3d_Texture2D) aTex2dNew = Handle(Graphic3d_Texture2D)::DownCast (aTextureNew); | |
4612 | Handle(Graphic3d_Texture2D) aTex2dOld = Handle(Graphic3d_Texture2D)::DownCast (aTextureOld); | |
4613 | if (!aTex2dOld.IsNull() | |
4614 | && !aTex2dNew.IsNull()) | |
a6dee93d | 4615 | { |
4616 | TCollection_AsciiString aFilePathOld, aFilePathNew; | |
4617 | aTextureOld->Path().SystemName (aFilePathOld); | |
4618 | aTextureNew->Path().SystemName (aFilePathNew); | |
633084b8 | 4619 | if (aTex2dNew->Name() == aTex2dOld->Name() |
a6dee93d | 4620 | && aFilePathOld == aFilePathNew |
633084b8 | 4621 | && (!aFilePathNew.IsEmpty() || aTex2dNew->Name() != Graphic3d_NOT_2D_UNKNOWN)) |
a6dee93d | 4622 | { |
cc8cbabe | 4623 | --aNbChanged; |
633084b8 | 4624 | aTextureNew = aTex2dOld; |
a6dee93d | 4625 | } |
4626 | } | |
4627 | } | |
cc8cbabe | 4628 | aTextureSetNew->SetValue (aTexIter, aTextureNew); |
d399d3c3 | 4629 | } |
4630 | } | |
cc8cbabe | 4631 | if (aNbChanged == 0 |
4632 | && ((aTextureSetOld.IsNull() && aTextureSetNew.IsNull()) | |
4633 | || (aTextureSetOld->Size() == aTextureSetNew->Size()))) | |
a6dee93d | 4634 | { |
cc8cbabe | 4635 | aTextureSetNew = aTextureSetOld; |
4636 | } | |
4637 | ||
2a332745 | 4638 | if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer()) |
4639 | && aTexturedShape.IsNull()) | |
cc8cbabe | 4640 | { |
2a332745 | 4641 | aTexturedIO->SetToUpdate(); |
a6dee93d | 4642 | } |
cc8cbabe | 4643 | |
4644 | toComputeUV = !aTextureSetNew.IsNull() && aTextureSetOld.IsNull(); | |
4645 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (!aTextureSetNew.IsNull()); | |
4646 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (aTextureSetNew); | |
4647 | aTextureSetOld.Nullify(); | |
a6dee93d | 4648 | } |
7fd59977 | 4649 | |
a6dee93d | 4650 | if (toSetDefaults) |
4651 | { | |
4652 | if (toModulate != -1) | |
d399d3c3 | 4653 | { |
a6dee93d | 4654 | toModulate = 1; |
7fd59977 | 4655 | } |
a6dee93d | 4656 | if (!toSetFilter) |
4657 | { | |
4658 | toSetFilter = true; | |
4659 | aFilter = Graphic3d_TOTF_BILINEAR; | |
4660 | } | |
4661 | if (!toSetAniso) | |
4662 | { | |
4663 | toSetAniso = true; | |
4664 | anAnisoFilter = Graphic3d_LOTA_OFF; | |
4665 | } | |
4666 | if (!toSetTrsfAngle) | |
4667 | { | |
4668 | toSetTrsfAngle = true; | |
4669 | aTrsfRotAngle = 0.0f; | |
4670 | } | |
4671 | if (!toSetTrsfTrans) | |
4672 | { | |
4673 | toSetTrsfTrans = true; | |
4674 | aTrsfTrans = Graphic3d_Vec2 (0.0f, 0.0f); | |
4675 | } | |
4676 | if (!toSetTrsfScale) | |
4677 | { | |
4678 | toSetTrsfScale = true; | |
4679 | aTrsfScale = Graphic3d_Vec2 (1.0f, 1.0f); | |
4680 | } | |
4681 | } | |
7fd59977 | 4682 | |
a6dee93d | 4683 | if (aCommandName == "vtexture" |
4684 | && theArgsNb == 2) | |
4685 | { | |
cc8cbabe | 4686 | if (!aTextureSetOld.IsNull()) |
7fd59977 | 4687 | { |
cc8cbabe | 4688 | //toComputeUV = true; // we can keep UV vertex attributes |
a6dee93d | 4689 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOff(); |
cc8cbabe | 4690 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (Handle(Graphic3d_TextureSet)()); |
4691 | aTextureSetOld.Nullify(); | |
7fd59977 | 4692 | } |
d399d3c3 | 4693 | } |
4694 | ||
a6dee93d | 4695 | if (aTexturedIO->Attributes()->HasOwnShadingAspect() |
4696 | && !aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap().IsNull()) | |
d399d3c3 | 4697 | { |
a6dee93d | 4698 | if (toModulate != -1) |
4699 | { | |
4700 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetModulate (toModulate == 1); | |
4701 | } | |
c585f731 | 4702 | if (toSetSRgb != -1) |
4703 | { | |
4704 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->SetColorMap (toSetSRgb == 1); | |
4705 | } | |
a6dee93d | 4706 | if (toSetTrsfAngle) |
4707 | { | |
4708 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetRotation (aTrsfRotAngle); // takes degrees | |
4709 | } | |
4710 | if (toSetTrsfTrans) | |
4711 | { | |
4712 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetTranslation (aTrsfTrans); | |
4713 | } | |
4714 | if (toSetTrsfScale) | |
4715 | { | |
4716 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetScale (aTrsfScale); | |
4717 | } | |
4718 | if (toSetFilter) | |
4719 | { | |
4720 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetFilter (aFilter); | |
4721 | } | |
4722 | if (toSetAniso) | |
4723 | { | |
4724 | aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureMap()->GetParams()->SetAnisoFilter (anAnisoFilter); | |
4725 | } | |
d399d3c3 | 4726 | } |
a6dee93d | 4727 | |
4728 | // set default values if requested | |
4729 | if (!toSetGenRepeat | |
4730 | && (aCommandName == "vtexrepeat" | |
4731 | || toSetDefaults)) | |
4732 | { | |
c84c2ef7 | 4733 | if (!aTexturedShape.IsNull()) |
4734 | { | |
4735 | aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0)); | |
4736 | } | |
a6dee93d | 4737 | toSetGenRepeat = true; |
4738 | } | |
4739 | if (!toSetGenOrigin | |
4740 | && (aCommandName == "vtexorigin" | |
4741 | || toSetDefaults)) | |
4742 | { | |
c84c2ef7 | 4743 | if (!aTexturedShape.IsNull()) |
4744 | { | |
4745 | aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0)); | |
4746 | } | |
a6dee93d | 4747 | toSetGenOrigin = true; |
4748 | } | |
4749 | if (!toSetGenScale | |
4750 | && (aCommandName == "vtexscale" | |
4751 | || toSetDefaults)) | |
d399d3c3 | 4752 | { |
c84c2ef7 | 4753 | if (!aTexturedShape.IsNull()) |
4754 | { | |
4755 | aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0)); | |
4756 | } | |
a6dee93d | 4757 | toSetGenScale = true; |
d399d3c3 | 4758 | } |
4759 | ||
cc8cbabe | 4760 | if (toSetGenRepeat || toSetGenOrigin || toSetGenScale || toComputeUV) |
a6dee93d | 4761 | { |
c84c2ef7 | 4762 | if (!aTexturedShape.IsNull()) |
a6dee93d | 4763 | { |
c84c2ef7 | 4764 | aTexturedShape->SetToUpdate (AIS_Shaded); |
4765 | if (toSetImage) | |
a6dee93d | 4766 | { |
c84c2ef7 | 4767 | if ((aTexturedIO->HasDisplayMode() && aTexturedIO->DisplayMode() != AIS_Shaded) |
4768 | || aCtx->DisplayMode() != AIS_Shaded) | |
4769 | { | |
4770 | aCtx->SetDisplayMode (aTexturedIO, AIS_Shaded, false); | |
4771 | } | |
a6dee93d | 4772 | } |
4773 | } | |
4774 | } | |
4775 | aCtx->Display (aTexturedIO, false); | |
4776 | aTexturedIO->SynchronizeAspects(); | |
31160f80 | 4777 | return 0; |
7fd59977 | 4778 | } |
4779 | ||
af65fb19 | 4780 | //! Auxiliary method to parse transformation persistence flags |
4781 | inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString, | |
778cd667 | 4782 | Graphic3d_TransModeFlags& theFlags) |
af65fb19 | 4783 | { |
778cd667 | 4784 | if (theFlagString == "zoom") |
af65fb19 | 4785 | { |
778cd667 | 4786 | theFlags = Graphic3d_TMF_ZoomPers; |
af65fb19 | 4787 | } |
4788 | else if (theFlagString == "rotate") | |
4789 | { | |
778cd667 | 4790 | theFlags = Graphic3d_TMF_RotatePers; |
af65fb19 | 4791 | } |
778cd667 | 4792 | else if (theFlagString == "zoomrotate") |
af65fb19 | 4793 | { |
778cd667 | 4794 | theFlags = Graphic3d_TMF_ZoomRotatePers; |
af65fb19 | 4795 | } |
778cd667 | 4796 | else if (theFlagString == "trihedron" |
4797 | || theFlagString == "triedron") | |
af65fb19 | 4798 | { |
778cd667 | 4799 | theFlags = Graphic3d_TMF_TriedronPers; |
af65fb19 | 4800 | } |
4801 | else if (theFlagString == "none") | |
4802 | { | |
4803 | theFlags = Graphic3d_TMF_None; | |
4804 | } | |
4805 | else | |
4806 | { | |
4807 | return Standard_False; | |
4808 | } | |
4809 | ||
4810 | return Standard_True; | |
4811 | } | |
4812 | ||
879768fb | 4813 | // ============================================================================= |
4814 | // function : ParseCorner | |
4815 | // purpose : | |
4816 | // ============================================================================= | |
4817 | Standard_Boolean ViewerTest::ParseCorner (Standard_CString theArg, | |
4818 | Aspect_TypeOfTriedronPosition& theCorner) | |
778cd667 | 4819 | { |
879768fb | 4820 | TCollection_AsciiString aString (theArg); |
778cd667 | 4821 | aString.LowerCase(); |
4822 | if (aString == "center") | |
4823 | { | |
4824 | theCorner = Aspect_TOTP_CENTER; | |
4825 | } | |
4826 | else if (aString == "top" | |
4827 | || aString == "upper") | |
4828 | { | |
4829 | theCorner = Aspect_TOTP_TOP; | |
4830 | } | |
4831 | else if (aString == "bottom" | |
4832 | || aString == "lower") | |
4833 | { | |
4834 | theCorner = Aspect_TOTP_BOTTOM; | |
4835 | } | |
4836 | else if (aString == "left") | |
4837 | { | |
4838 | theCorner = Aspect_TOTP_LEFT; | |
4839 | } | |
4840 | else if (aString == "right") | |
4841 | { | |
4842 | theCorner = Aspect_TOTP_RIGHT; | |
4843 | } | |
4844 | else if (aString == "topleft" | |
4845 | || aString == "leftupper" | |
879768fb | 4846 | || aString == "upperleft" |
4847 | || aString == "left_upper" | |
4848 | || aString == "upper_left") | |
778cd667 | 4849 | { |
4850 | theCorner = Aspect_TOTP_LEFT_UPPER; | |
4851 | } | |
4852 | else if (aString == "bottomleft" | |
4853 | || aString == "leftlower" | |
879768fb | 4854 | || aString == "lowerleft" |
4855 | || aString == "left_lower" | |
4856 | || aString == "lower_left") | |
778cd667 | 4857 | { |
4858 | theCorner = Aspect_TOTP_LEFT_LOWER; | |
4859 | } | |
4860 | else if (aString == "topright" | |
4861 | || aString == "rightupper" | |
879768fb | 4862 | || aString == "upperright" |
4863 | || aString == "right_upper" | |
4864 | || aString == "upper_right") | |
778cd667 | 4865 | { |
4866 | theCorner = Aspect_TOTP_RIGHT_UPPER; | |
4867 | } | |
4868 | else if (aString == "bottomright" | |
4869 | || aString == "lowerright" | |
879768fb | 4870 | || aString == "rightlower" |
4871 | || aString == "right_lower" | |
4872 | || aString == "lower_right") | |
778cd667 | 4873 | { |
4874 | theCorner = Aspect_TOTP_RIGHT_LOWER; | |
4875 | } | |
4876 | else | |
4877 | { | |
4878 | return Standard_False; | |
4879 | } | |
4880 | ||
4881 | return Standard_True; | |
4882 | } | |
4883 | ||
7fd59977 | 4884 | //============================================================================== |
4885 | //function : VDisplay2 | |
4886 | //author : ege | |
4887 | //purpose : Display an object from its name | |
7fd59977 | 4888 | //============================================================================== |
519d35d8 | 4889 | static int VDisplay2 (Draw_Interpretor& theDI, |
4890 | Standard_Integer theArgNb, | |
4891 | const char** theArgVec) | |
7fd59977 | 4892 | { |
519d35d8 | 4893 | if (theArgNb < 2) |
4894 | { | |
23fe70ec | 4895 | Message::SendFail ("Syntax error: wrong number of arguments."); |
519d35d8 | 4896 | return 1; |
4897 | } | |
ab1f4580 | 4898 | if (theArgNb == 2 |
4899 | && TCollection_AsciiString (theArgVec[1]) == "*") | |
4900 | { | |
4901 | // alias | |
4902 | return VDisplayAll (theDI, 1, theArgVec); | |
4903 | } | |
b6d587e3 | 4904 | |
4905 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
4906 | if (aCtx.IsNull()) | |
519d35d8 | 4907 | { |
7fd59977 | 4908 | ViewerTest::ViewerInit(); |
4e18052b | 4909 | aCtx = ViewerTest::GetAISContext(); |
7fd59977 | 4910 | } |
4911 | ||
b6d587e3 | 4912 | // Parse input arguments |
4e18052b | 4913 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
a1954302 | 4914 | Standard_Integer isMutable = -1; |
4915 | Graphic3d_ZLayerId aZLayer = Graphic3d_ZLayerId_UNKNOWN; | |
a1954302 | 4916 | Standard_Boolean toReDisplay = Standard_False; |
af65fb19 | 4917 | Standard_Integer isSelectable = -1; |
4918 | Standard_Integer anObjDispMode = -2; | |
4919 | Standard_Integer anObjHighMode = -2; | |
4920 | Standard_Boolean toSetTrsfPers = Standard_False; | |
e816dce3 | 4921 | Standard_Boolean toEcho = Standard_True; |
005caf39 | 4922 | Standard_Integer isAutoTriang = -1; |
778cd667 | 4923 | Handle(Graphic3d_TransformPers) aTrsfPers; |
b6d587e3 | 4924 | TColStd_SequenceOfAsciiString aNamesOfDisplayIO; |
a1954302 | 4925 | AIS_DisplayStatus aDispStatus = AIS_DS_None; |
a272ed94 | 4926 | Standard_Integer toDisplayInView = Standard_False; |
519d35d8 | 4927 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
4928 | { | |
b7cd4ba7 | 4929 | const TCollection_AsciiString aName = theArgVec[anArgIter]; |
4930 | TCollection_AsciiString aNameCase = aName; | |
4931 | aNameCase.LowerCase(); | |
4e18052b | 4932 | if (anUpdateTool.parseRedrawMode (aName)) |
519d35d8 | 4933 | { |
4934 | continue; | |
4935 | } | |
b7cd4ba7 | 4936 | else if (aNameCase == "-mutable") |
4937 | { | |
4938 | isMutable = 1; | |
b7cd4ba7 | 4939 | } |
a1954302 | 4940 | else if (aNameCase == "-neutral") |
4941 | { | |
4942 | aDispStatus = AIS_DS_Displayed; | |
4943 | } | |
4944 | else if (aNameCase == "-immediate" | |
4945 | || aNameCase == "-top") | |
4946 | { | |
4947 | aZLayer = Graphic3d_ZLayerId_Top; | |
4948 | } | |
4949 | else if (aNameCase == "-topmost") | |
4950 | { | |
4951 | aZLayer = Graphic3d_ZLayerId_Topmost; | |
4952 | } | |
4953 | else if (aNameCase == "-osd" | |
af65fb19 | 4954 | || aNameCase == "-toposd" |
4955 | || aNameCase == "-overlay") | |
a1954302 | 4956 | { |
4957 | aZLayer = Graphic3d_ZLayerId_TopOSD; | |
4958 | } | |
af65fb19 | 4959 | else if (aNameCase == "-botosd" |
4960 | || aNameCase == "-underlay") | |
4961 | { | |
4962 | aZLayer = Graphic3d_ZLayerId_BotOSD; | |
4963 | } | |
4964 | else if (aNameCase == "-select" | |
4965 | || aNameCase == "-selectable") | |
4966 | { | |
4967 | isSelectable = 1; | |
4968 | } | |
4969 | else if (aNameCase == "-noselect" | |
4970 | || aNameCase == "-noselection") | |
4971 | { | |
4972 | isSelectable = 0; | |
4973 | } | |
4974 | else if (aNameCase == "-dispmode" | |
4975 | || aNameCase == "-displaymode") | |
4976 | { | |
4977 | if (++anArgIter >= theArgNb) | |
4978 | { | |
23fe70ec | 4979 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; |
af65fb19 | 4980 | return 1; |
4981 | } | |
4982 | ||
4983 | anObjDispMode = Draw::Atoi (theArgVec [anArgIter]); | |
4984 | } | |
ab1f4580 | 4985 | else if (aNameCase == "-himode" |
4986 | || aNameCase == "-highmode" | |
af65fb19 | 4987 | || aNameCase == "-highlightmode") |
4988 | { | |
4989 | if (++anArgIter >= theArgNb) | |
4990 | { | |
23fe70ec | 4991 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; |
af65fb19 | 4992 | return 1; |
4993 | } | |
4994 | ||
4995 | anObjHighMode = Draw::Atoi (theArgVec [anArgIter]); | |
4996 | } | |
4997 | else if (aNameCase == "-3d") | |
4998 | { | |
4999 | toSetTrsfPers = Standard_True; | |
778cd667 | 5000 | aTrsfPers.Nullify(); |
af65fb19 | 5001 | } |
778cd667 | 5002 | else if (aNameCase == "-2d" |
5003 | || aNameCase == "-trihedron" | |
5004 | || aNameCase == "-triedron") | |
af65fb19 | 5005 | { |
5006 | toSetTrsfPers = Standard_True; | |
778cd667 | 5007 | aTrsfPers = new Graphic3d_TransformPers (aNameCase == "-2d" ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER); |
5008 | ||
5009 | if (anArgIter + 1 < theArgNb) | |
5010 | { | |
5011 | Aspect_TypeOfTriedronPosition aCorner = Aspect_TOTP_CENTER; | |
879768fb | 5012 | if (ViewerTest::ParseCorner (theArgVec[anArgIter + 1], aCorner)) |
778cd667 | 5013 | { |
5014 | ++anArgIter; | |
5015 | aTrsfPers->SetCorner2d (aCorner); | |
5016 | ||
5017 | if (anArgIter + 2 < theArgNb) | |
5018 | { | |
5019 | TCollection_AsciiString anX (theArgVec[anArgIter + 1]); | |
5020 | TCollection_AsciiString anY (theArgVec[anArgIter + 2]); | |
5021 | if (anX.IsIntegerValue() | |
5022 | && anY.IsIntegerValue()) | |
5023 | { | |
5024 | anArgIter += 2; | |
5025 | aTrsfPers->SetOffset2d (Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue())); | |
5026 | } | |
5027 | } | |
5028 | } | |
5029 | } | |
af65fb19 | 5030 | } |
af65fb19 | 5031 | else if (aNameCase == "-trsfpers" |
5032 | || aNameCase == "-pers") | |
5033 | { | |
778cd667 | 5034 | if (++anArgIter >= theArgNb |
5035 | || !aTrsfPers.IsNull()) | |
af65fb19 | 5036 | { |
23fe70ec | 5037 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; |
af65fb19 | 5038 | return 1; |
5039 | } | |
5040 | ||
5041 | toSetTrsfPers = Standard_True; | |
778cd667 | 5042 | Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None; |
af65fb19 | 5043 | TCollection_AsciiString aPersFlags (theArgVec [anArgIter]); |
5044 | aPersFlags.LowerCase(); | |
778cd667 | 5045 | if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags)) |
af65fb19 | 5046 | { |
23fe70ec | 5047 | Message::SendFail() << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << "."; |
778cd667 | 5048 | return 1; |
5049 | } | |
af65fb19 | 5050 | |
778cd667 | 5051 | if (aTrsfPersFlags == Graphic3d_TMF_TriedronPers) |
5052 | { | |
5053 | aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER); | |
5054 | } | |
5055 | else if (aTrsfPersFlags != Graphic3d_TMF_None) | |
5056 | { | |
5057 | aTrsfPers = new Graphic3d_TransformPers (aTrsfPersFlags, gp_Pnt()); | |
af65fb19 | 5058 | } |
5059 | } | |
5060 | else if (aNameCase == "-trsfperspos" | |
5061 | || aNameCase == "-perspos") | |
5062 | { | |
778cd667 | 5063 | if (anArgIter + 2 >= theArgNb |
5064 | || aTrsfPers.IsNull()) | |
af65fb19 | 5065 | { |
23fe70ec | 5066 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; |
af65fb19 | 5067 | return 1; |
5068 | } | |
5069 | ||
5070 | TCollection_AsciiString aX (theArgVec[++anArgIter]); | |
5071 | TCollection_AsciiString aY (theArgVec[++anArgIter]); | |
5072 | TCollection_AsciiString aZ = "0"; | |
d45edf24 | 5073 | if (!aX.IsRealValue (Standard_True) |
5074 | || !aY.IsRealValue (Standard_True)) | |
af65fb19 | 5075 | { |
23fe70ec | 5076 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; |
af65fb19 | 5077 | return 1; |
5078 | } | |
5079 | if (anArgIter + 1 < theArgNb) | |
5080 | { | |
5081 | TCollection_AsciiString aTemp = theArgVec[anArgIter + 1]; | |
d45edf24 | 5082 | if (aTemp.IsRealValue (Standard_True)) |
af65fb19 | 5083 | { |
5084 | aZ = aTemp; | |
5085 | ++anArgIter; | |
5086 | } | |
5087 | } | |
778cd667 | 5088 | |
778cd667 | 5089 | if (aTrsfPers->IsZoomOrRotate()) |
5090 | { | |
f4e7c307 | 5091 | aTrsfPers->SetAnchorPoint (gp_Pnt (aX.RealValue(), aY.RealValue(), aZ.RealValue())); |
778cd667 | 5092 | } |
5093 | else if (aTrsfPers->IsTrihedronOr2d()) | |
5094 | { | |
f4e7c307 | 5095 | Standard_Integer aCorner = Aspect_TOTP_CENTER; |
5096 | if (aX.RealValue() > 0.0) { aCorner |= Aspect_TOTP_RIGHT; } | |
5097 | else if (aX.RealValue() < 0.0) { aCorner |= Aspect_TOTP_LEFT; } | |
5098 | if (aY.RealValue() > 0.0) { aCorner |= Aspect_TOTP_TOP; } | |
5099 | else if (aY.RealValue() < 0.0) { aCorner |= Aspect_TOTP_BOTTOM; } | |
5100 | aTrsfPers = new Graphic3d_TransformPers (aTrsfPers->Mode(), Aspect_TypeOfTriedronPosition (aCorner), Graphic3d_Vec2i (aZ.IntegerValue())); | |
778cd667 | 5101 | } |
af65fb19 | 5102 | } |
f035e071 | 5103 | else if (aNameCase == "-trsfPersOrtho") |
5104 | { | |
5105 | if (aTrsfPers.IsNull()) | |
5106 | { | |
5107 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; | |
5108 | return 1; | |
5109 | } | |
5110 | ||
5111 | toSetTrsfPers = Standard_True; | |
5112 | if (aTrsfPers->IsZoomOrRotate()) | |
5113 | { | |
5114 | aTrsfPers = new Graphic3d_TransformPers (aTrsfPers->Mode() | Graphic3d_TMF_OrthoPers, aTrsfPers->AnchorPoint()); | |
5115 | } | |
5116 | else if (aTrsfPers->IsTrihedronOr2d()) | |
5117 | { | |
5118 | aTrsfPers = new Graphic3d_TransformPers (aTrsfPers->Mode() | Graphic3d_TMF_OrthoPers, aTrsfPers->Corner2d(), aTrsfPers->Offset2d()); | |
5119 | } | |
5120 | } | |
55c8f0f7 BB |
5121 | else if (aNameCase == "-layer" |
5122 | || aNameCase == "-zlayer") | |
a1954302 | 5123 | { |
55c8f0f7 BB |
5124 | ++anArgIter; |
5125 | if (anArgIter >= theArgNb | |
5126 | || !ViewerTest::ParseZLayer (theArgVec[anArgIter], aZLayer) | |
5127 | || aZLayer == Graphic3d_ZLayerId_UNKNOWN) | |
a1954302 | 5128 | { |
23fe70ec | 5129 | Message::SendFail() << "Error: wrong syntax at " << aName << "."; |
a1954302 | 5130 | return 1; |
5131 | } | |
a1954302 | 5132 | } |
a272ed94 | 5133 | else if (aNameCase == "-view" |
5134 | || aNameCase == "-inview") | |
5135 | { | |
5136 | toDisplayInView = Standard_True; | |
5137 | } | |
a1954302 | 5138 | else if (aNameCase == "-redisplay") |
5139 | { | |
5140 | toReDisplay = Standard_True; | |
5141 | } | |
005caf39 | 5142 | else if (aNameCase == "-autotr" |
5143 | || aNameCase == "-autotrian" | |
5144 | || aNameCase == "-autotriang" | |
5145 | || aNameCase == "-autotriangulation" | |
5146 | || aNameCase == "-noautotr" | |
5147 | || aNameCase == "-noautotrian" | |
5148 | || aNameCase == "-noautotriang" | |
5149 | || aNameCase == "-noautotriangulation") | |
5150 | { | |
5151 | isAutoTriang = Draw::ParseOnOffNoIterator (theArgNb, theArgVec, anArgIter) ? 1 : 0; | |
5152 | } | |
6194ee76 | 5153 | else if (aNameCase == "-erased" |
5154 | || aNameCase == "-load") | |
5155 | { | |
5156 | aDispStatus = AIS_DS_Erased; | |
5157 | } | |
e816dce3 | 5158 | else if (aNameCase == "-noecho") |
5159 | { | |
5160 | toEcho = false; | |
5161 | } | |
b6d587e3 | 5162 | else |
5163 | { | |
5164 | aNamesOfDisplayIO.Append (aName); | |
5165 | } | |
5166 | } | |
5167 | ||
5168 | if (aNamesOfDisplayIO.IsEmpty()) | |
5169 | { | |
23fe70ec | 5170 | Message::SendFail ("Syntax error: wrong number of arguments."); |
b6d587e3 | 5171 | return 1; |
5172 | } | |
5173 | ||
b6d587e3 | 5174 | // Display interactive objects |
5175 | for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter) | |
5176 | { | |
1c8fc6be | 5177 | const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value (anIter); |
8f521168 | 5178 | Handle(AIS_InteractiveObject) aShape; |
5179 | if (!GetMapOfAIS().Find2 (aName, aShape)) | |
519d35d8 | 5180 | { |
5181 | // create the AIS_Shape from a name | |
1c8fc6be | 5182 | TopoDS_Shape aDrawShape = DBRep::GetExisting (aName); |
5183 | if (!aDrawShape.IsNull()) | |
519d35d8 | 5184 | { |
1c8fc6be | 5185 | aShape = new AIS_Shape (aDrawShape); |
b7cd4ba7 | 5186 | if (isMutable != -1) |
5187 | { | |
5188 | aShape->SetMutable (isMutable == 1); | |
5189 | } | |
a1954302 | 5190 | if (aZLayer != Graphic3d_ZLayerId_UNKNOWN) |
5191 | { | |
5192 | aShape->SetZLayer (aZLayer); | |
5193 | } | |
005caf39 | 5194 | if (isAutoTriang != -1) |
5195 | { | |
5196 | aShape->Attributes()->SetAutoTriangulation (isAutoTriang == 1); | |
5197 | } | |
af65fb19 | 5198 | if (toSetTrsfPers) |
5199 | { | |
778cd667 | 5200 | aCtx->SetTransformPersistence (aShape, aTrsfPers); |
af65fb19 | 5201 | } |
5202 | if (anObjDispMode != -2) | |
5203 | { | |
ab1f4580 | 5204 | if (anObjDispMode == -1) |
5205 | { | |
5206 | aShape->UnsetDisplayMode(); | |
5207 | } | |
5208 | if (!aShape->AcceptDisplayMode (anObjDispMode)) | |
5209 | { | |
23fe70ec | 5210 | Message::SendFail() << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjDispMode << " display mode"; |
ab1f4580 | 5211 | return 1; |
5212 | } | |
5213 | else | |
5214 | { | |
5215 | aShape->SetDisplayMode (anObjDispMode); | |
5216 | } | |
af65fb19 | 5217 | } |
5218 | if (anObjHighMode != -2) | |
5219 | { | |
ab1f4580 | 5220 | if (anObjHighMode != -1 |
5221 | && !aShape->AcceptDisplayMode (anObjHighMode)) | |
5222 | { | |
23fe70ec | 5223 | Message::SendFail() << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjHighMode << " display mode"; |
ab1f4580 | 5224 | return 1; |
5225 | } | |
af65fb19 | 5226 | aShape->SetHilightMode (anObjHighMode); |
5227 | } | |
a1954302 | 5228 | |
68dcee02 | 5229 | GetMapOfAIS().Bind (aShape, aName); |
a1954302 | 5230 | Standard_Integer aDispMode = aShape->HasDisplayMode() |
5231 | ? aShape->DisplayMode() | |
5232 | : (aShape->AcceptDisplayMode (aCtx->DisplayMode()) | |
5233 | ? aCtx->DisplayMode() | |
5234 | : 0); | |
af65fb19 | 5235 | Standard_Integer aSelMode = -1; |
825aa485 | 5236 | if (isSelectable == 1 || (isSelectable == -1 && aCtx->GetAutoActivateSelection())) |
af65fb19 | 5237 | { |
c3282ec1 | 5238 | aSelMode = aShape->GlobalSelectionMode(); |
af65fb19 | 5239 | } |
a1954302 | 5240 | |
68dcee02 | 5241 | aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aDispStatus); |
a272ed94 | 5242 | if (toDisplayInView) |
5243 | { | |
6a24c6de | 5244 | for (V3d_ListOfViewIterator aViewIter (aCtx->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next()) |
a272ed94 | 5245 | { |
6a24c6de | 5246 | aCtx->SetViewAffinity (aShape, aViewIter.Value(), Standard_False); |
a272ed94 | 5247 | } |
5248 | aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True); | |
5249 | } | |
519d35d8 | 5250 | } |
af65fb19 | 5251 | else |
5252 | { | |
23fe70ec | 5253 | Message::SendFail() << "Error: object with name '" << aName << "' does not exist!"; |
af65fb19 | 5254 | } |
519d35d8 | 5255 | continue; |
5256 | } | |
7fd59977 | 5257 | |
d09dda09 | 5258 | if (isMutable != -1) |
519d35d8 | 5259 | { |
d09dda09 | 5260 | aShape->SetMutable (isMutable == 1); |
5261 | } | |
5262 | if (aZLayer != Graphic3d_ZLayerId_UNKNOWN) | |
5263 | { | |
5264 | aShape->SetZLayer (aZLayer); | |
5265 | } | |
005caf39 | 5266 | if (isAutoTriang != -1) |
5267 | { | |
5268 | aShape->Attributes()->SetAutoTriangulation (isAutoTriang == 1); | |
5269 | } | |
d09dda09 | 5270 | if (toSetTrsfPers) |
5271 | { | |
778cd667 | 5272 | aCtx->SetTransformPersistence (aShape, aTrsfPers); |
d09dda09 | 5273 | } |
5274 | if (anObjDispMode != -2) | |
5275 | { | |
5276 | aShape->SetDisplayMode (anObjDispMode); | |
5277 | } | |
5278 | if (anObjHighMode != -2) | |
5279 | { | |
5280 | aShape->SetHilightMode (anObjHighMode); | |
5281 | } | |
5282 | Standard_Integer aDispMode = aShape->HasDisplayMode() | |
5283 | ? aShape->DisplayMode() | |
5284 | : (aShape->AcceptDisplayMode (aCtx->DisplayMode()) | |
5285 | ? aCtx->DisplayMode() | |
5286 | : 0); | |
5287 | Standard_Integer aSelMode = -1; | |
825aa485 | 5288 | if (isSelectable == 1 || (isSelectable == -1 && aCtx->GetAutoActivateSelection())) |
d09dda09 | 5289 | { |
c3282ec1 | 5290 | aSelMode = aShape->GlobalSelectionMode(); |
d09dda09 | 5291 | } |
5292 | ||
82b856b8 | 5293 | if (aShape->Type() == AIS_KindOfInteractive_Datum) |
d09dda09 | 5294 | { |
5295 | aCtx->Display (aShape, Standard_False); | |
5296 | } | |
5297 | else | |
5298 | { | |
e816dce3 | 5299 | if (toEcho) |
5300 | { | |
5301 | theDI << "Display " << aName << "\n"; | |
5302 | } | |
d09dda09 | 5303 | |
5304 | // update the Shape in the AIS_Shape | |
1c8fc6be | 5305 | TopoDS_Shape aNewShape = DBRep::GetExisting (aName); |
d09dda09 | 5306 | Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape); |
5307 | if (!aShapePrs.IsNull()) | |
af65fb19 | 5308 | { |
d09dda09 | 5309 | if (!aShapePrs->Shape().IsEqual (aNewShape)) |
5310 | { | |
5311 | toReDisplay = Standard_True; | |
5312 | } | |
5313 | aShapePrs->Set (aNewShape); | |
af65fb19 | 5314 | } |
d09dda09 | 5315 | if (toReDisplay) |
af65fb19 | 5316 | { |
d09dda09 | 5317 | aCtx->Redisplay (aShape, Standard_False); |
af65fb19 | 5318 | } |
b7cd4ba7 | 5319 | |
d09dda09 | 5320 | if (aSelMode == -1) |
519d35d8 | 5321 | { |
0577ae8c | 5322 | aCtx->Erase (aShape, Standard_False); |
519d35d8 | 5323 | } |
68dcee02 | 5324 | aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aDispStatus); |
d09dda09 | 5325 | if (toDisplayInView) |
519d35d8 | 5326 | { |
d09dda09 | 5327 | aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True); |
7fd59977 | 5328 | } |
5329 | } | |
7fd59977 | 5330 | } |
b6d587e3 | 5331 | |
7fd59977 | 5332 | return 0; |
5333 | } | |
5334 | ||
bc001a40 | 5335 | //======================================================================= |
5336 | //function : VNbDisplayed | |
5337 | //purpose : Returns number of displayed objects | |
5338 | //======================================================================= | |
5339 | static Standard_Integer VNbDisplayed (Draw_Interpretor& theDi, | |
5340 | Standard_Integer theArgsNb, | |
5341 | const char** theArgVec) | |
5342 | { | |
5343 | if(theArgsNb != 1) | |
5344 | { | |
5345 | theDi << "Usage : " << theArgVec[0] << "\n"; | |
5346 | return 1; | |
5347 | } | |
5348 | ||
5349 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); | |
5350 | if (aContextAIS.IsNull()) | |
5351 | { | |
23fe70ec | 5352 | Message::SendFail ("Syntax error: AIS context is not available."); |
bc001a40 | 5353 | return 1; |
5354 | } | |
5355 | ||
5356 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
5357 | if(aContext.IsNull()) | |
5358 | { | |
5359 | theDi << "use 'vinit' command before " << theArgVec[0] << "\n"; | |
5360 | return 1; | |
5361 | } | |
5362 | ||
5363 | AIS_ListOfInteractive aListOfIO; | |
68dcee02 | 5364 | aContextAIS->DisplayedObjects (aListOfIO); |
bc001a40 | 5365 | |
5366 | theDi << aListOfIO.Extent() << "\n"; | |
5367 | return 0; | |
5368 | } | |
5369 | ||
f3889691 | 5370 | //=============================================================================================== |
5371 | //function : VUpdate | |
5372 | //purpose : | |
5373 | //=============================================================================================== | |
5374 | static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec) | |
5375 | { | |
5376 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); | |
5377 | if (aContextAIS.IsNull()) | |
5378 | { | |
23fe70ec | 5379 | Message::SendFail ("Syntax error: AIS context is not available."); |
f3889691 | 5380 | return 1; |
5381 | } | |
5382 | ||
5383 | if (theArgsNb < 2) | |
5384 | { | |
23fe70ec | 5385 | Message::SendFail ("Syntax error: insufficient arguments. Type help for more information."); |
f3889691 | 5386 | return 1; |
5387 | } | |
5388 | ||
f3889691 | 5389 | AIS_ListOfInteractive aListOfIO; |
f3889691 | 5390 | for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) |
5391 | { | |
5392 | TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]); | |
5393 | ||
5394 | Handle(AIS_InteractiveObject) anAISObj; | |
8f521168 | 5395 | GetMapOfAIS().Find2 (aName, anAISObj); |
f3889691 | 5396 | if (anAISObj.IsNull()) |
5397 | { | |
23fe70ec | 5398 | Message::SendFail() << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\"."; |
f3889691 | 5399 | return 1; |
5400 | } | |
5401 | ||
5402 | aListOfIO.Append (anAISObj); | |
5403 | } | |
5404 | ||
5405 | AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); | |
5406 | for (; anIOIt.More(); anIOIt.Next()) | |
5407 | { | |
5408 | aContextAIS->Update (anIOIt.Value(), Standard_False); | |
5409 | } | |
5410 | ||
5411 | aContextAIS->UpdateCurrentViewer(); | |
5412 | ||
5413 | return 0; | |
5414 | } | |
5415 | ||
7fd59977 | 5416 | //============================================================================== |
5417 | //function : VShading | |
5418 | //purpose : Sharpen or roughten the quality of the shading | |
5419 | //Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg | |
5420 | //============================================================================== | |
5cbef0fe S |
5421 | static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv) |
5422 | { | |
7fd59977 | 5423 | Standard_Real myDevCoef; |
5424 | Handle(AIS_InteractiveObject) TheAisIO; | |
5425 | ||
5426 | // Verifications | |
5cbef0fe | 5427 | const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0); |
7fd59977 | 5428 | if (argc < 3) { |
5429 | myDevCoef = 0.0008; | |
5430 | } else { | |
91322f44 | 5431 | myDevCoef =Draw::Atof(argv[2]); |
7fd59977 | 5432 | } |
5433 | ||
7fd59977 | 5434 | TCollection_AsciiString name=argv[1]; |
8f521168 | 5435 | GetMapOfAIS().Find2(name, TheAisIO); |
7fd59977 | 5436 | if (TheAisIO.IsNull()) |
1c8fc6be | 5437 | { |
5438 | TopoDS_Shape aDrawShape = DBRep::GetExisting (name); | |
5439 | if (!aDrawShape.IsNull()) | |
5440 | { | |
5441 | TheAisIO = new AIS_Shape (aDrawShape); | |
5442 | } | |
5443 | } | |
7fd59977 | 5444 | |
5cbef0fe | 5445 | if (HaveToSet) |
7fd59977 | 5446 | TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True); |
5cbef0fe | 5447 | else |
7fd59977 | 5448 | TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True); |
5449 | ||
0577ae8c | 5450 | TheAISContext()->Redisplay (TheAisIO, Standard_True); |
7fd59977 | 5451 | return 0; |
5452 | } | |
7fd59977 | 5453 | |
cb78155f | 5454 | //! Auxiliary method to print Interactive Object information |
5455 | static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected, | |
8f521168 | 5456 | const Handle(AIS_InteractiveObject)& theObj, |
cb78155f | 5457 | Draw_Interpretor& theDI) |
5458 | { | |
8f521168 | 5459 | if (theObj.IsNull()) |
cb78155f | 5460 | { |
8f521168 | 5461 | theDI << "NULL presentation\n"; |
cb78155f | 5462 | return; |
5463 | } | |
7fd59977 | 5464 | |
8f521168 | 5465 | theDI << (TheAISContext()->IsDisplayed (theObj) ? "Displayed" : "Hidden ") |
5466 | << (TheAISContext()->IsSelected (theObj) ? " Selected" : " ") | |
5467 | << (theDetected.Contains (theObj) ? " Detected" : " ") | |
cb78155f | 5468 | << " Type: "; |
82b856b8 | 5469 | if (theObj->Type() == AIS_KindOfInteractive_Datum) |
cb78155f | 5470 | { |
5471 | // AIS_Datum | |
8f521168 | 5472 | if (theObj->Signature() == 3) { theDI << " AIS_Trihedron"; } |
5473 | else if (theObj->Signature() == 2) { theDI << " AIS_Axis"; } | |
5474 | else if (theObj->Signature() == 6) { theDI << " AIS_Circle"; } | |
5475 | else if (theObj->Signature() == 5) { theDI << " AIS_Line"; } | |
5476 | else if (theObj->Signature() == 7) { theDI << " AIS_Plane"; } | |
5477 | else if (theObj->Signature() == 1) { theDI << " AIS_Point"; } | |
5478 | else if (theObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; } | |
7fd59977 | 5479 | } |
5480 | // AIS_Shape | |
82b856b8 | 5481 | else if (theObj->Type() == AIS_KindOfInteractive_Shape |
8f521168 | 5482 | && theObj->Signature() == 0) |
cb78155f | 5483 | { |
5484 | theDI << " AIS_Shape"; | |
7fd59977 | 5485 | } |
82b856b8 | 5486 | else if (theObj->Type() == AIS_KindOfInteractive_Relation) |
cb78155f | 5487 | { |
4551e1be | 5488 | // PrsDim_Dimension and AIS_Relation |
787ff240 | 5489 | Handle(PrsDim_Relation) aRelation = Handle(PrsDim_Relation)::DownCast (theObj); |
cb78155f | 5490 | switch (aRelation->KindOfDimension()) |
5491 | { | |
787ff240 | 5492 | case PrsDim_KOD_PLANEANGLE: theDI << " PrsDim_AngleDimension"; break; |
5493 | case PrsDim_KOD_LENGTH: theDI << " PrsDim_Chamf2/3dDimension/PrsDim_LengthDimension"; break; | |
5494 | case PrsDim_KOD_DIAMETER: theDI << " PrsDim_DiameterDimension"; break; | |
5495 | case PrsDim_KOD_ELLIPSERADIUS: theDI << " PrsDim_EllipseRadiusDimension"; break; | |
5496 | //case PrsDim_KOD_FILLETRADIUS: theDI << " PrsDim_FilletRadiusDimension "; break; | |
5497 | case PrsDim_KOD_OFFSET: theDI << " PrsDim_OffsetDimension"; break; | |
5498 | case PrsDim_KOD_RADIUS: theDI << " PrsDim_RadiusDimension"; break; | |
cb78155f | 5499 | default: theDI << " UNKNOWN dimension"; break; |
5500 | } | |
5501 | } | |
5502 | else | |
5503 | { | |
5504 | theDI << " UserPrs"; | |
5505 | } | |
8f521168 | 5506 | theDI << " (" << theObj->DynamicType()->Name() << ")"; |
7fd59977 | 5507 | } |
5508 | ||
cb78155f | 5509 | //! Print information about locally selected sub-shapes |
23963a92 | 5510 | template <typename T> |
5511 | static void printLocalSelectionInfo (const T& theContext, Draw_Interpretor& theDI) | |
cb78155f | 5512 | { |
a9dde4a3 | 5513 | const Standard_Boolean isGlobalCtx = (theContext->DynamicType() == STANDARD_TYPE(AIS_InteractiveContext)); |
cb78155f | 5514 | TCollection_AsciiString aPrevName; |
23963a92 | 5515 | for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) |
cb78155f | 5516 | { |
23963a92 | 5517 | const Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (theContext->SelectedInteractive()); |
5518 | const Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner(); | |
5519 | if (aShapeIO.IsNull() || anOwner.IsNull()) | |
5520 | continue; | |
5521 | if (isGlobalCtx) | |
5522 | { | |
5523 | if (anOwner == aShapeIO->GlobalSelOwner()) | |
5524 | continue; | |
5525 | } | |
5526 | const TopoDS_Shape aSubShape = theContext->SelectedShape(); | |
cb78155f | 5527 | if (aSubShape.IsNull() |
5528 | || aShapeIO.IsNull() | |
5529 | || !GetMapOfAIS().IsBound1 (aShapeIO)) | |
5530 | { | |
5531 | continue; | |
5532 | } | |
5533 | ||
5534 | const TCollection_AsciiString aParentName = GetMapOfAIS().Find1 (aShapeIO); | |
5535 | TopTools_MapOfShape aFilter; | |
5536 | Standard_Integer aNumber = 0; | |
5537 | const TopoDS_Shape aShape = aShapeIO->Shape(); | |
5538 | for (TopExp_Explorer anIter (aShape, aSubShape.ShapeType()); | |
5539 | anIter.More(); anIter.Next()) | |
5540 | { | |
5541 | if (!aFilter.Add (anIter.Current())) | |
5542 | { | |
5543 | continue; // filter duplicates | |
5544 | } | |
5545 | ||
5546 | ++aNumber; | |
5547 | if (!anIter.Current().IsSame (aSubShape)) | |
5548 | { | |
5549 | continue; | |
5550 | } | |
5551 | ||
5552 | Standard_CString aShapeName = NULL; | |
5553 | switch (aSubShape.ShapeType()) | |
5554 | { | |
5555 | case TopAbs_COMPOUND: aShapeName = " Compound"; break; | |
5556 | case TopAbs_COMPSOLID: aShapeName = "CompSolid"; break; | |
5557 | case TopAbs_SOLID: aShapeName = " Solid"; break; | |
5558 | case TopAbs_SHELL: aShapeName = " Shell"; break; | |
5559 | case TopAbs_FACE: aShapeName = " Face"; break; | |
5560 | case TopAbs_WIRE: aShapeName = " Wire"; break; | |
5561 | case TopAbs_EDGE: aShapeName = " Edge"; break; | |
5562 | case TopAbs_VERTEX: aShapeName = " Vertex"; break; | |
5563 | default: | |
5564 | case TopAbs_SHAPE: aShapeName = " Shape"; break; | |
5565 | } | |
5566 | ||
5567 | if (aParentName != aPrevName) | |
5568 | { | |
5569 | theDI << "Locally selected sub-shapes within " << aParentName << ":\n"; | |
5570 | aPrevName = aParentName; | |
5571 | } | |
5572 | theDI << " " << aShapeName << " #" << aNumber << "\n"; | |
5573 | break; | |
5574 | } | |
5575 | } | |
5576 | } | |
7fd59977 | 5577 | |
5578 | //============================================================================== | |
5579 | //function : VState | |
5580 | //purpose : | |
7fd59977 | 5581 | //============================================================================== |
cb78155f | 5582 | static Standard_Integer VState (Draw_Interpretor& theDI, |
5583 | Standard_Integer theArgNb, | |
5584 | Standard_CString* theArgVec) | |
7fd59977 | 5585 | { |
cb78155f | 5586 | Handle(AIS_InteractiveContext) aCtx = TheAISContext(); |
5587 | if (aCtx.IsNull()) | |
5588 | { | |
23fe70ec | 5589 | Message::SendFail ("Error: No opened viewer!"); |
cb78155f | 5590 | return 1; |
7fd59977 | 5591 | } |
cb78155f | 5592 | |
51023771 | 5593 | Standard_Boolean toPrintEntities = Standard_False; |
5594 | Standard_Boolean toCheckSelected = Standard_False; | |
5595 | ||
5596 | for (Standard_Integer anArgIdx = 1; anArgIdx < theArgNb; ++anArgIdx) | |
5597 | { | |
5598 | TCollection_AsciiString anOption (theArgVec[anArgIdx]); | |
5599 | anOption.LowerCase(); | |
5600 | if (anOption == "-detectedentities" | |
5601 | || anOption == "-entities") | |
5602 | { | |
5603 | toPrintEntities = Standard_True; | |
5604 | } | |
5605 | else if (anOption == "-hasselected") | |
5606 | { | |
5607 | toCheckSelected = Standard_True; | |
5608 | } | |
5609 | } | |
5610 | ||
5611 | if (toCheckSelected) | |
5612 | { | |
5613 | aCtx->InitSelected(); | |
5614 | TCollection_AsciiString hasSelected (static_cast<Standard_Integer> (aCtx->HasSelectedShape())); | |
5615 | theDI << "Check if context has selected shape: " << hasSelected << "\n"; | |
5616 | ||
5617 | return 0; | |
5618 | } | |
5619 | ||
5620 | if (toPrintEntities) | |
8e7c8ccf | 5621 | { |
5622 | theDI << "Detected entities:\n"; | |
68dcee02 | 5623 | Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->MainSelector(); |
5624 | ||
7479f643 | 5625 | SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager(); |
aa75c0cf | 5626 | for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter) |
8e7c8ccf | 5627 | { |
0ef04197 | 5628 | const SelectMgr_SortCriterion& aPickData = aSelector->PickedData (aPickIter); |
5629 | const Handle(Select3D_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter); | |
5630 | const Handle(SelectMgr_EntityOwner)& anOwner = anEntity->OwnerId(); | |
5631 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); | |
ab1f4580 | 5632 | |
5633 | TCollection_AsciiString aName; | |
5634 | GetMapOfAIS().Find1 (anObj, aName); | |
8e7c8ccf | 5635 | aName.LeftJustify (20, ' '); |
5636 | char anInfoStr[512]; | |
2615c2d7 | 5637 | if (aPickData.Normal.SquareModulus() > ShortRealEpsilon()) |
5638 | { | |
5639 | Sprintf (anInfoStr, | |
5640 | " Depth: %g Distance: %g Point: %g %g %g Normal: %g %g %g", | |
5641 | aPickData.Depth, | |
5642 | aPickData.MinDist, | |
5643 | aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z(), | |
5644 | aPickData.Normal.x(), aPickData.Normal.y(), aPickData.Normal.z()); | |
5645 | } | |
5646 | else | |
5647 | { | |
5648 | Sprintf (anInfoStr, | |
5649 | " Depth: %g Distance: %g Point: %g %g %g", | |
5650 | aPickData.Depth, | |
5651 | aPickData.MinDist, | |
5652 | aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z()); | |
5653 | } | |
8e7c8ccf | 5654 | theDI << " " << aName |
5655 | << anInfoStr | |
5656 | << " (" << anEntity->DynamicType()->Name() << ")" | |
5657 | << "\n"; | |
5658 | ||
73dc2d3a | 5659 | if (Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner)) |
8e7c8ccf | 5660 | { |
5661 | theDI << " Detected Shape: " | |
5662 | << aBRepOwner->Shape().TShape()->DynamicType()->Name() | |
5663 | << "\n"; | |
5664 | } | |
5665 | ||
73dc2d3a | 5666 | if (Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast (anEntity)) |
8e7c8ccf | 5667 | { |
5668 | Handle(Select3D_SensitiveEntity) aSen = aWire->GetLastDetected(); | |
5669 | theDI << " Detected Child: " | |
5670 | << aSen->DynamicType()->Name() | |
5671 | << "\n"; | |
5672 | } | |
73dc2d3a | 5673 | else if (Handle(Select3D_SensitivePrimitiveArray) aPrimArr = Handle(Select3D_SensitivePrimitiveArray)::DownCast (anEntity)) |
8b9a309b | 5674 | { |
5675 | theDI << " Detected Element: " | |
5676 | << aPrimArr->LastDetectedElement() | |
5677 | << "\n"; | |
5678 | } | |
73dc2d3a | 5679 | else if (Handle(Select3D_SensitiveTriangulation) aTriSens = Handle(Select3D_SensitiveTriangulation)::DownCast (anEntity)) |
5680 | { | |
5681 | theDI << " Detected Triangle: " | |
5682 | << aTriSens->LastDetectedTriangleIndex() | |
5683 | << "\n"; | |
5684 | } | |
8e7c8ccf | 5685 | } |
5686 | return 0; | |
5687 | } | |
5688 | ||
cb78155f | 5689 | NCollection_Map<Handle(AIS_InteractiveObject)> aDetected; |
5690 | for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected()) | |
5691 | { | |
68dcee02 | 5692 | aDetected.Add (Handle(AIS_InteractiveObject)::DownCast (aCtx->DetectedCurrentOwner()->Selectable())); |
cb78155f | 5693 | } |
5694 | ||
5695 | const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*'); | |
5696 | if (theArgNb >= 2 | |
5697 | && !toShowAll) | |
5698 | { | |
5699 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) | |
7fd59977 | 5700 | { |
cb78155f | 5701 | const TCollection_AsciiString anObjName = theArgVec[anArgIter]; |
8f521168 | 5702 | Handle(AIS_InteractiveObject) anObj; |
5703 | if (!GetMapOfAIS().Find2 (anObjName, anObj)) | |
cb78155f | 5704 | { |
5705 | theDI << anObjName << " doesn't exist!\n"; | |
5706 | continue; | |
7fd59977 | 5707 | } |
5708 | ||
cb78155f | 5709 | TCollection_AsciiString aName = anObjName; |
5710 | aName.LeftJustify (20, ' '); | |
5711 | theDI << " " << aName << " "; | |
8f521168 | 5712 | objInfo (aDetected, anObj, theDI); |
cb78155f | 5713 | theDI << "\n"; |
7fd59977 | 5714 | } |
cb78155f | 5715 | return 0; |
7fd59977 | 5716 | } |
cb78155f | 5717 | |
68dcee02 | 5718 | if (aCtx->NbSelected() > 0 && !toShowAll) |
cb78155f | 5719 | { |
23963a92 | 5720 | NCollection_DataMap<Handle(SelectMgr_EntityOwner), TopoDS_Shape> anOwnerShapeMap; |
c3282ec1 | 5721 | for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) |
cb78155f | 5722 | { |
23963a92 | 5723 | const Handle(SelectMgr_EntityOwner) anOwner = aCtx->SelectedOwner(); |
5724 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); | |
5725 | // handle whole object selection | |
5726 | if (anOwner == anObj->GlobalSelOwner()) | |
5727 | { | |
ab1f4580 | 5728 | TCollection_AsciiString aName; |
5729 | GetMapOfAIS().Find1 (anObj, aName); | |
23963a92 | 5730 | aName.LeftJustify (20, ' '); |
5731 | theDI << aName << " "; | |
5732 | objInfo (aDetected, anObj, theDI); | |
5733 | theDI << "\n"; | |
5734 | } | |
7fd59977 | 5735 | } |
23963a92 | 5736 | |
5737 | // process selected sub-shapes | |
5738 | printLocalSelectionInfo (aCtx, theDI); | |
5739 | ||
cb78155f | 5740 | return 0; |
7fd59977 | 5741 | } |
5742 | ||
cb78155f | 5743 | theDI << "Neutral-point state:\n"; |
5744 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); | |
5745 | anObjIter.More(); anObjIter.Next()) | |
5746 | { | |
8f521168 | 5747 | if (anObjIter.Key1().IsNull()) |
cb78155f | 5748 | { |
5749 | continue; | |
5750 | } | |
5751 | ||
5752 | TCollection_AsciiString aName = anObjIter.Key2(); | |
5753 | aName.LeftJustify (20, ' '); | |
5754 | theDI << " " << aName << " "; | |
8f521168 | 5755 | objInfo (aDetected, anObjIter.Key1(), theDI); |
cb78155f | 5756 | theDI << "\n"; |
5757 | } | |
23963a92 | 5758 | printLocalSelectionInfo (aCtx, theDI); |
7fd59977 | 5759 | return 0; |
5760 | } | |
5761 | ||
7fd59977 | 5762 | //======================================================================= |
5763 | //function : PickShape | |
5764 | //purpose : First Activate the rightmode + Put Filters to be able to | |
5765 | // pick objets that are of type <TheType>... | |
5766 | //======================================================================= | |
5767 | ||
8c088c52 | 5768 | TopoDS_Shape ViewerTest::PickShape (const TopAbs_ShapeEnum theShapeType, |
5769 | const Standard_Integer theMaxPick) | |
7fd59977 | 5770 | { |
8c088c52 | 5771 | Handle(TopTools_HArray1OfShape) aResArray = new TopTools_HArray1OfShape (1, 1); |
5772 | PickShapes (theShapeType, aResArray, theMaxPick); | |
5773 | return aResArray->First(); | |
7fd59977 | 5774 | } |
5775 | ||
7fd59977 | 5776 | //======================================================================= |
5777 | //function : PickShapes | |
5778 | //purpose : | |
5779 | //======================================================================= | |
8c088c52 | 5780 | Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType, |
5781 | Handle(TopTools_HArray1OfShape)& theResArray, | |
5782 | const Standard_Integer theMaxPick) | |
7fd59977 | 5783 | { |
8c088c52 | 5784 | const Standard_Integer aNbToReach = theResArray->Length(); |
5785 | if (aNbToReach > 1) | |
5786 | { | |
23fe70ec | 5787 | Message::SendWarning ("WARNING : Pick with Shift+ MB1 for Selection of more than 1 object"); |
8c088c52 | 5788 | } |
7fd59977 | 5789 | |
5790 | // step 1: prepare the data | |
8c088c52 | 5791 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
f41fd243 | 5792 | if (aCtx.IsNull()) |
5793 | { | |
5794 | Message::SendFail ("Error: no active viewer"); | |
5795 | return Standard_False; | |
5796 | } | |
5797 | ||
8c088c52 | 5798 | aCtx->RemoveFilters(); |
5799 | AIS_ListOfInteractive aDispObjects; | |
5800 | aCtx->DisplayedObjects (aDispObjects); | |
5801 | if (theShapeType == TopAbs_SHAPE) | |
5802 | { | |
82b856b8 | 5803 | aCtx->AddFilter (new AIS_TypeFilter (AIS_KindOfInteractive_Shape)); |
7fd59977 | 5804 | } |
8c088c52 | 5805 | else |
5806 | { | |
5807 | aCtx->AddFilter (new StdSelect_ShapeTypeFilter (theShapeType)); | |
5808 | } | |
5809 | ||
5810 | const Standard_Integer aSelMode = AIS_Shape::SelectionMode (theShapeType); | |
5811 | for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next()) | |
5812 | { | |
5813 | if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value())) | |
5814 | { | |
5815 | aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single); | |
5816 | } | |
7fd59977 | 5817 | } |
5818 | ||
5819 | // step 2 : wait for the selection... | |
8c088c52 | 5820 | Standard_Integer aNbPickGood = 0, aNbPickFail = 0; |
7fd59977 | 5821 | Standard_Integer argccc = 5; |
8c088c52 | 5822 | const char *bufff[] = { "A", "B", "C", "D", "E" }; |
5823 | const char **argvvv = (const char** )bufff; | |
5824 | for (; aNbPickGood < aNbToReach && aNbPickFail <= theMaxPick; ) | |
5825 | { | |
5826 | while (ViewerMainLoop (argccc, argvvv)) {} | |
5827 | Standard_Integer aNbStored = aCtx->NbSelected(); | |
5828 | if (aNbStored != aNbPickGood) | |
5829 | { | |
5830 | aNbPickGood = aNbStored; | |
5831 | } | |
7fd59977 | 5832 | else |
8c088c52 | 5833 | { |
5834 | ++aNbPickFail; | |
5835 | } | |
23fe70ec | 5836 | Message::SendInfo() << "NbPicked = " << aNbPickGood << " | Nb Pick Fail :" << aNbPickFail; |
7fd59977 | 5837 | } |
5838 | ||
5839 | // step3 get result. | |
8c088c52 | 5840 | if (aNbPickFail >= aNbToReach) |
5841 | { | |
76363522 | 5842 | return Standard_False; |
8c088c52 | 5843 | } |
7fd59977 | 5844 | |
8c088c52 | 5845 | Standard_Integer anIndex = theResArray->Lower(); |
5846 | for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected(), ++anIndex) | |
5847 | { | |
5848 | if (aCtx->HasSelectedShape()) | |
5849 | { | |
5850 | theResArray->SetValue (anIndex, aCtx->SelectedShape()); | |
5851 | } | |
5852 | else | |
5853 | { | |
5854 | Handle(AIS_InteractiveObject) IO = aCtx->SelectedInteractive(); | |
5855 | theResArray->SetValue (anIndex, Handle(AIS_Shape)::DownCast (IO)->Shape()); | |
7fd59977 | 5856 | } |
5857 | } | |
5858 | ||
8c088c52 | 5859 | aCtx->RemoveFilters(); |
5860 | if (theShapeType != TopAbs_SHAPE) | |
5861 | { | |
5862 | for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next()) | |
5863 | { | |
5864 | if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value())) | |
5865 | { | |
5866 | aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single); | |
5867 | } | |
5868 | } | |
5869 | } | |
7fd59977 | 5870 | return Standard_True; |
5871 | } | |
5872 | ||
7fd59977 | 5873 | //======================================================================= |
5874 | //function : VPickShape | |
5875 | //purpose : | |
5876 | //======================================================================= | |
5877 | static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
5878 | { | |
8c088c52 | 5879 | TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE; |
5880 | if (argc != 1) | |
5881 | { | |
5882 | TCollection_AsciiString aShapeArg (argv[1]); | |
5883 | aShapeArg.LowerCase(); | |
5884 | aShapeType = TopAbs_COMPOUND; | |
5885 | if (aShapeArg == "v" | |
5886 | || aShapeArg == "vertex") aShapeType = TopAbs_VERTEX; | |
5887 | else if (aShapeArg == "e" | |
5888 | || aShapeArg == "edge") aShapeType = TopAbs_EDGE; | |
5889 | else if (aShapeArg == "w" | |
5890 | || aShapeArg == "wire") aShapeType = TopAbs_WIRE; | |
5891 | else if (aShapeArg == "f" | |
5892 | || aShapeArg == "face") aShapeType = TopAbs_FACE; | |
5893 | else if (aShapeArg == "shape") aShapeType = TopAbs_SHAPE; | |
5894 | else if (aShapeArg == "shell") aShapeType = TopAbs_SHELL; | |
5895 | else if (aShapeArg == "solid") aShapeType = TopAbs_SOLID; | |
5896 | else | |
5897 | { | |
23fe70ec | 5898 | Message::SendFail() << "Syntax error at '" << argv[1] << "'"; |
8c088c52 | 5899 | return 1; |
5900 | } | |
7fd59977 | 5901 | } |
5902 | ||
8c088c52 | 5903 | static Standard_Integer THE_NB_SHAPES_OF_TYPE[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
5904 | static const TCollection_AsciiString THE_NAME_TYPE[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"}; | |
7fd59977 | 5905 | |
8c088c52 | 5906 | const Standard_Integer aNbToPick = argc > 2 ? argc - 2 : 1; |
5907 | if (aNbToPick == 1) | |
5908 | { | |
5909 | TopoDS_Shape aPickedShape = ViewerTest::PickShape (aShapeType); | |
5910 | if (aPickedShape.IsNull()) | |
5911 | { | |
7fd59977 | 5912 | return 1; |
7fd59977 | 5913 | } |
7fd59977 | 5914 | |
8c088c52 | 5915 | TCollection_AsciiString aName; |
5916 | if (argc > 2) | |
5917 | { | |
5918 | aName = argv[2]; | |
5919 | } | |
5920 | else | |
5921 | { | |
5922 | const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)]; | |
5923 | aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex; | |
7fd59977 | 5924 | } |
7fd59977 | 5925 | |
8c088c52 | 5926 | DBRep::Set (aName.ToCString(), aPickedShape); |
5927 | Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape); | |
5928 | ViewerTest::Display (aName, aShapePrs, false, true); | |
5929 | di << "Name of picked shape: " << aName <<"\n"; | |
7fd59977 | 5930 | } |
8c088c52 | 5931 | else |
5932 | { | |
5933 | TCollection_AsciiString aName (argv[2]); | |
5934 | aName.LowerCase(); | |
5935 | const Standard_Boolean isAutoNaming = aName == "."; | |
5936 | Handle(TopTools_HArray1OfShape) aPickedArray = new TopTools_HArray1OfShape (1, aNbToPick); | |
5937 | if (ViewerTest::PickShapes (aShapeType, aPickedArray)) | |
5938 | { | |
5939 | for (Standard_Integer aPickedIter = aPickedArray->Lower(); aPickedIter <= aPickedArray->Upper(); ++aPickedIter) | |
5940 | { | |
5941 | TopoDS_Shape aPickedShape = aPickedArray->Value (aPickedIter); | |
5942 | aName.Clear(); | |
5943 | if (!aPickedShape.IsNull() | |
5944 | && isAutoNaming) | |
5945 | { | |
5946 | const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)]; | |
5947 | aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex; | |
5948 | } | |
5949 | else | |
5950 | { | |
5951 | aName = argv[1 + aPickedIter]; | |
5952 | } | |
7fd59977 | 5953 | |
8c088c52 | 5954 | DBRep::Set (aName.ToCString(), aPickedShape); |
5955 | Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape); | |
5956 | di << "Display of picked shape #" << aPickedIter << " - name: " << aName <<"\n"; | |
5957 | ViewerTest::Display (aName, aShapePrs, false, true); | |
5958 | } | |
7fd59977 | 5959 | } |
5960 | } | |
8c088c52 | 5961 | TheAISContext()->UpdateCurrentViewer(); |
7fd59977 | 5962 | return 0; |
7fd59977 | 5963 | } |
7fd59977 | 5964 | |
4d901cde | 5965 | //======================================================================= |
d2e60688 | 5966 | //function : VSelFilter |
4d901cde | 5967 | //purpose : |
5968 | //======================================================================= | |
d2e60688 | 5969 | static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc, |
4d901cde | 5970 | const char** theArgv) |
5971 | { | |
4d901cde | 5972 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
5973 | if (aContext.IsNull()) | |
5974 | { | |
23fe70ec | 5975 | Message::SendFail ("Error: AIS context is not available."); |
4d901cde | 5976 | return 1; |
5977 | } | |
5978 | ||
d2e60688 | 5979 | for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter) |
5980 | { | |
5981 | TCollection_AsciiString anArg (theArgv[anArgIter]); | |
5982 | anArg.LowerCase(); | |
5983 | if (anArg == "-clear") | |
5984 | { | |
5985 | aContext->RemoveFilters(); | |
4d901cde | 5986 | } |
897aeb20 | 5987 | else if (anArg == "-contextfilter" && anArgIter + 1 < theArgc) |
5988 | { | |
5989 | TCollection_AsciiString aVal (theArgv[++anArgIter]); | |
5990 | aVal.LowerCase(); | |
5991 | if (aVal == "and") | |
5992 | { | |
5993 | aContext->SetFilterType (SelectMgr_FilterType_AND); | |
5994 | } | |
5995 | else if (aVal == "or") | |
5996 | { | |
5997 | aContext->SetFilterType (SelectMgr_FilterType_OR); | |
5998 | } | |
5999 | else | |
6000 | { | |
6001 | Message::SendFail() << "Syntax error: wrong command attribute value '" << aVal << "'"; | |
6002 | return 1; | |
6003 | } | |
6004 | } | |
d2e60688 | 6005 | else if (anArg == "-type" |
6006 | && anArgIter + 1 < theArgc) | |
6007 | { | |
6008 | TCollection_AsciiString aVal (theArgv[++anArgIter]); | |
6009 | TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND; | |
6010 | if (!TopAbs::ShapeTypeFromString (aVal.ToCString(), aShapeType)) | |
6011 | { | |
23fe70ec | 6012 | Message::SendFail() << "Syntax error: wrong command attribute value '" << aVal << "'"; |
d2e60688 | 6013 | return 1; |
6014 | } | |
4d901cde | 6015 | |
d2e60688 | 6016 | Handle(SelectMgr_Filter) aFilter; |
6017 | if (aShapeType == TopAbs_SHAPE) | |
6018 | { | |
82b856b8 | 6019 | aFilter = new AIS_TypeFilter (AIS_KindOfInteractive_Shape); |
d2e60688 | 6020 | } |
6021 | else | |
6022 | { | |
6023 | aFilter = new StdSelect_ShapeTypeFilter (aShapeType); | |
6024 | } | |
6025 | aContext->AddFilter (aFilter); | |
4d901cde | 6026 | } |
897aeb20 | 6027 | else if (anArg == "-secondtype" |
6028 | && anArgIter + 1 < theArgc) | |
6029 | { | |
6030 | TCollection_AsciiString aVal (theArgv[++anArgIter]); | |
6031 | TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND; | |
6032 | if (!TopAbs::ShapeTypeFromString (aVal.ToCString(), aShapeType)) | |
6033 | { | |
6034 | Message::SendFail() << "Syntax error: wrong command attribute value '" << aVal << "'"; | |
6035 | return 1; | |
6036 | } | |
6037 | ||
6038 | Handle(SelectMgr_Filter) aFilter; | |
6039 | if (aShapeType == TopAbs_SHAPE) | |
6040 | { | |
82b856b8 | 6041 | aFilter = new AIS_TypeFilter (AIS_KindOfInteractive_Shape); |
897aeb20 | 6042 | } |
6043 | else | |
6044 | { | |
6045 | aFilter = new StdSelect_ShapeTypeFilter (aShapeType); | |
6046 | } | |
6047 | aContext->AddFilter (aFilter); | |
6048 | } | |
d2e60688 | 6049 | else |
6050 | { | |
23fe70ec | 6051 | Message::SendFail() << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'"; |
d2e60688 | 6052 | return 1; |
4d901cde | 6053 | } |
6054 | } | |
6055 | return 0; | |
6056 | } | |
6057 | ||
d8110103 | 6058 | //======================================================================= |
6059 | //function : VPickSelected | |
6060 | //purpose : | |
6061 | //======================================================================= | |
6062 | static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgs) | |
6063 | { | |
6064 | static Standard_Integer aCount = 0; | |
6065 | TCollection_AsciiString aName = "PickedShape_"; | |
6066 | ||
6067 | if (theArgNb > 1) | |
6068 | { | |
6069 | aName = theArgs[1]; | |
6070 | } | |
6071 | else | |
6072 | { | |
6073 | aName = aName + aCount++ + "_"; | |
6074 | } | |
6075 | ||
6076 | Standard_Integer anIdx = 0; | |
6077 | for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected(), ++anIdx) | |
6078 | { | |
6079 | TopoDS_Shape aShape; | |
6080 | if (TheAISContext()->HasSelectedShape()) | |
6081 | { | |
6082 | aShape = TheAISContext()->SelectedShape(); | |
6083 | } | |
6084 | else | |
6085 | { | |
6086 | Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive(); | |
c5f3a425 | 6087 | aShape = Handle(AIS_Shape)::DownCast (IO)->Shape(); |
d8110103 | 6088 | } |
6089 | ||
6090 | TCollection_AsciiString aCurrentName = aName; | |
6091 | if (anIdx > 0) | |
6092 | { | |
6093 | aCurrentName += anIdx; | |
6094 | } | |
6095 | ||
6096 | DBRep::Set ((aCurrentName).ToCString(), aShape); | |
6097 | ||
6098 | Handle(AIS_Shape) aNewShape = new AIS_Shape (aShape); | |
6099 | GetMapOfAIS().Bind (aNewShape, aCurrentName); | |
0577ae8c | 6100 | TheAISContext()->Display (aNewShape, Standard_False); |
d8110103 | 6101 | } |
6102 | ||
0577ae8c | 6103 | TheAISContext()->UpdateCurrentViewer(); |
6104 | ||
d8110103 | 6105 | return 0; |
6106 | } | |
6107 | ||
7fd59977 | 6108 | //======================================================================= |
6109 | //function : list of known objects | |
6110 | //purpose : | |
6111 | //======================================================================= | |
6112 | static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** ) | |
6113 | { | |
6114 | // 1234567890 12345678901234567 123456789 | |
6115 | TCollection_AsciiString Colum [3]={"Standard Types","Type Of Object","Signature"}; | |
6116 | TCollection_AsciiString BlankLine(64,'_'); | |
6117 | Standard_Integer i ; | |
6118 | ||
6119 | di<<"/n"<<BlankLine.ToCString()<<"\n"; | |
6120 | ||
6121 | for( i =0;i<=2;i++) | |
6122 | Colum[i].Center(20,' '); | |
6123 | for(i=0;i<=2;i++) | |
6124 | di<<"|"<<Colum[i].ToCString(); | |
586db386 | 6125 | di<<"|\n"; |
7fd59977 | 6126 | |
6127 | di<<BlankLine.ToCString()<<"\n"; | |
6128 | ||
6129 | // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"}; | |
6130 | const char ** names = GetTypeNames(); | |
6131 | ||
6132 | TCollection_AsciiString curstring; | |
6133 | TCollection_AsciiString curcolum[3]; | |
6134 | ||
6135 | ||
6136 | // les objets de type Datum.. | |
6137 | curcolum[1]+="Datum"; | |
6138 | for(i =0;i<=6;i++){ | |
6139 | curcolum[0].Clear(); | |
6140 | curcolum[0] += names[i]; | |
6141 | ||
6142 | curcolum[2].Clear(); | |
6143 | curcolum[2]+=TCollection_AsciiString(i+1); | |
6144 | ||
6145 | for(Standard_Integer j =0;j<=2;j++){ | |
6146 | curcolum[j].Center(20,' '); | |
6147 | di<<"|"<<curcolum[j].ToCString(); | |
6148 | } | |
586db386 | 6149 | di<<"|\n"; |
7fd59977 | 6150 | } |
6151 | di<<BlankLine.ToCString()<<"\n"; | |
6152 | ||
6153 | // les objets de type shape | |
6154 | curcolum[1].Clear(); | |
6155 | curcolum[1]+="Shape"; | |
6156 | curcolum[1].Center(20,' '); | |
6157 | ||
6158 | for(i=0;i<=2;i++){ | |
6159 | curcolum[0].Clear(); | |
6160 | curcolum[0] += names[7+i]; | |
6161 | curcolum[2].Clear(); | |
6162 | curcolum[2]+=TCollection_AsciiString(i); | |
6163 | ||
6164 | for(Standard_Integer j =0;j<=2;j++){ | |
6165 | curcolum[j].Center(20,' '); | |
6166 | di<<"|"<<curcolum[j].ToCString(); | |
6167 | } | |
586db386 | 6168 | di<<"|\n"; |
7fd59977 | 6169 | } |
6170 | di<<BlankLine.ToCString()<<"\n"; | |
6171 | // les IO de type objet... | |
6172 | curcolum[1].Clear(); | |
6173 | curcolum[1]+="Object"; | |
6174 | curcolum[1].Center(20,' '); | |
6175 | for(i=0;i<=1;i++){ | |
6176 | curcolum[0].Clear(); | |
6177 | curcolum[0] += names[10+i]; | |
6178 | curcolum[2].Clear(); | |
6179 | curcolum[2]+=TCollection_AsciiString(i); | |
6180 | ||
6181 | for(Standard_Integer j =0;j<=2;j++){ | |
6182 | curcolum[j].Center(20,' '); | |
6183 | di<<"|"<<curcolum[j].ToCString(); | |
6184 | } | |
586db386 | 6185 | di<<"|\n"; |
7fd59977 | 6186 | } |
6187 | di<<BlankLine.ToCString()<<"\n"; | |
6188 | // les contraintes et dimensions. | |
6189 | // pour l'instant on separe juste contraintes et dimensions... | |
6190 | // plus tard, on detaillera toutes les sortes... | |
6191 | curcolum[1].Clear(); | |
6192 | curcolum[1]+="Relation"; | |
6193 | curcolum[1].Center(20,' '); | |
6194 | for(i=0;i<=1;i++){ | |
6195 | curcolum[0].Clear(); | |
6196 | curcolum[0] += names[12+i]; | |
6197 | curcolum[2].Clear(); | |
6198 | curcolum[2]+=TCollection_AsciiString(i); | |
6199 | ||
6200 | for(Standard_Integer j =0;j<=2;j++){ | |
6201 | curcolum[j].Center(20,' '); | |
6202 | di<<"|"<<curcolum[j].ToCString(); | |
6203 | } | |
586db386 | 6204 | di<<"|\n"; |
7fd59977 | 6205 | } |
6206 | di<<BlankLine.ToCString()<<"\n"; | |
6207 | ||
6208 | ||
6209 | return 0; | |
6210 | } | |
6211 | ||
6212 | ||
6213 | static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv) | |
6214 | { | |
4952a30a | 6215 | if(argc!=2) return 1; |
7fd59977 | 6216 | |
6217 | AIS_KindOfInteractive TheType; | |
6218 | Standard_Integer TheSign(-1); | |
6219 | GetTypeAndSignfromString(argv[1],TheType,TheSign); | |
6220 | ||
6221 | ||
6222 | AIS_ListOfInteractive LIO; | |
6223 | ||
6224 | // en attendant l'amelioration ais pour les dimensions... | |
6225 | // | |
6226 | Standard_Integer dimension_status(-1); | |
82b856b8 | 6227 | if (TheType==AIS_KindOfInteractive_Relation) |
6228 | { | |
6229 | dimension_status = TheSign == 1 ? 1 : 0; | |
6230 | TheSign = -1; | |
7fd59977 | 6231 | } |
6232 | ||
6233 | TheAISContext()->DisplayedObjects(TheType,TheSign,LIO); | |
6234 | Handle(AIS_InteractiveObject) curio; | |
6235 | for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ | |
6236 | curio = it.Value(); | |
6237 | ||
6238 | if(dimension_status == -1) | |
6239 | TheAISContext()->Erase(curio,Standard_False); | |
6240 | else { | |
787ff240 | 6241 | PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension(); |
6242 | if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)|| | |
6243 | (dimension_status==1 && KOD != PrsDim_KOD_NONE)) | |
7fd59977 | 6244 | TheAISContext()->Erase(curio,Standard_False); |
6245 | } | |
6246 | } | |
6247 | TheAISContext()->UpdateCurrentViewer(); | |
6248 | return 0; | |
6249 | } | |
6250 | static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char** argv) | |
6251 | { | |
6252 | if(argc!=2) return 1; | |
6253 | ||
6254 | AIS_KindOfInteractive TheType; | |
6255 | Standard_Integer TheSign(-1); | |
6256 | GetTypeAndSignfromString(argv[1],TheType,TheSign); | |
6257 | ||
6258 | // en attendant l'amelioration ais pour les dimensions... | |
6259 | // | |
6260 | Standard_Integer dimension_status(-1); | |
82b856b8 | 6261 | if (TheType==AIS_KindOfInteractive_Relation) |
6262 | { | |
6263 | dimension_status = TheSign == 1 ? 1 : 0; | |
6264 | TheSign = -1; | |
7fd59977 | 6265 | } |
6266 | ||
6267 | AIS_ListOfInteractive LIO; | |
6268 | TheAISContext()->ObjectsInside(LIO,TheType,TheSign); | |
6269 | Handle(AIS_InteractiveObject) curio; | |
6270 | for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ | |
6271 | curio = it.Value(); | |
6272 | if(dimension_status == -1) | |
6273 | TheAISContext()->Display(curio,Standard_False); | |
6274 | else { | |
787ff240 | 6275 | PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension(); |
6276 | if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)|| | |
6277 | (dimension_status==1 && KOD != PrsDim_KOD_NONE)) | |
7fd59977 | 6278 | TheAISContext()->Display(curio,Standard_False); |
6279 | } | |
6280 | ||
6281 | } | |
6282 | ||
6283 | TheAISContext()->UpdateCurrentViewer(); | |
6284 | return 0; | |
6285 | } | |
6286 | ||
189f85a3 | 6287 | //=============================================================================================== |
6288 | //function : VBsdf | |
6289 | //purpose : | |
6290 | //=============================================================================================== | |
05aa616d | 6291 | static int VBsdf (Draw_Interpretor& theDI, |
189f85a3 | 6292 | Standard_Integer theArgsNb, |
6293 | const char** theArgVec) | |
6294 | { | |
6295 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
6296 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); | |
6297 | if (aView.IsNull() | |
6298 | || aViewer.IsNull()) | |
6299 | { | |
23fe70ec | 6300 | Message::SendFail ("Error: No active viewer!"); |
189f85a3 | 6301 | return 1; |
6302 | } | |
6303 | ||
6304 | ViewerTest_CmdParser aCmd; | |
6305 | ||
293211ae | 6306 | aCmd.SetDescription ("Adjusts parameters of material BSDF:"); |
189f85a3 | 6307 | |
05aa616d | 6308 | aCmd.AddOption ("print|echo|p", "Prints BSDF"); |
189f85a3 | 6309 | |
05aa616d | 6310 | aCmd.AddOption ("noupdate|update", "Suppresses viewer redraw call"); |
189f85a3 | 6311 | |
05aa616d | 6312 | aCmd.AddOption ("kc", "Weight of coat specular/glossy BRDF"); |
6313 | aCmd.AddOption ("kd", "Weight of base diffuse BRDF"); | |
6314 | aCmd.AddOption ("ks", "Weight of base specular/glossy BRDF"); | |
6315 | aCmd.AddOption ("kt", "Weight of base specular/glossy BTDF"); | |
6316 | aCmd.AddOption ("le", "Radiance emitted by surface"); | |
189f85a3 | 6317 | |
05aa616d | 6318 | aCmd.AddOption ("coatFresnel|cf", "Fresnel reflectance of coat layer. Allowed formats: Constant R, Schlick R G B, Dielectric N, Conductor N K"); |
6319 | aCmd.AddOption ("baseFresnel|bf", "Fresnel reflectance of base layer. Allowed formats: Constant R, Schlick R G B, Dielectric N, Conductor N K"); | |
6320 | ||
6321 | aCmd.AddOption ("coatRoughness|cr", "Roughness of coat glossy BRDF"); | |
6322 | aCmd.AddOption ("baseRoughness|br", "Roughness of base glossy BRDF"); | |
6323 | ||
6324 | aCmd.AddOption ("absorpCoeff|af", "Absorption coeff of base transmission BTDF"); | |
6325 | aCmd.AddOption ("absorpColor|ac", "Absorption color of base transmission BTDF"); | |
6326 | ||
6327 | aCmd.AddOption ("normalize|n", "Normalizes BSDF to ensure energy conservation"); | |
189f85a3 | 6328 | |
6329 | aCmd.Parse (theArgsNb, theArgVec); | |
6330 | ||
6331 | if (aCmd.HasOption ("help")) | |
6332 | { | |
05aa616d | 6333 | theDI.PrintHelp (theArgVec[0]); |
189f85a3 | 6334 | return 0; |
6335 | } | |
6336 | ||
05aa616d | 6337 | // check viewer update mode |
6338 | ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView()); | |
05aa616d | 6339 | for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter) |
6340 | { | |
6341 | if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter])) | |
6342 | { | |
6343 | break; | |
6344 | } | |
6345 | } | |
6346 | ||
189f85a3 | 6347 | // find object |
293211ae | 6348 | TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str()); |
8f521168 | 6349 | Handle(AIS_InteractiveObject) anIObj; |
6350 | if (!GetMapOfAIS().Find2 (aName, anIObj)) | |
189f85a3 | 6351 | { |
23fe70ec | 6352 | Message::SendFail ("Error: no active viewer"); |
189f85a3 | 6353 | return 1; |
6354 | } | |
6355 | ||
189f85a3 | 6356 | Graphic3d_MaterialAspect aMaterial = anIObj->Attributes()->ShadingAspect()->Material(); |
6357 | Graphic3d_BSDF aBSDF = aMaterial.BSDF(); | |
6358 | ||
6359 | if (aCmd.HasOption ("print")) | |
6360 | { | |
05aa616d | 6361 | theDI << "\n" |
6362 | << "Kc: " << aBSDF.Kc.r() << ", " << aBSDF.Kc.g() << ", " << aBSDF.Kc.b() << "\n" | |
189f85a3 | 6363 | << "Kd: " << aBSDF.Kd.r() << ", " << aBSDF.Kd.g() << ", " << aBSDF.Kd.b() << "\n" |
189f85a3 | 6364 | << "Ks: " << aBSDF.Ks.r() << ", " << aBSDF.Ks.g() << ", " << aBSDF.Ks.b() << "\n" |
05aa616d | 6365 | << "Kt: " << aBSDF.Kt.r() << ", " << aBSDF.Kt.g() << ", " << aBSDF.Kt.b() << "\n" |
6366 | << "Le: " << aBSDF.Le.r() << ", " << aBSDF.Le.g() << ", " << aBSDF.Le.b() << "\n"; | |
189f85a3 | 6367 | |
05aa616d | 6368 | for (int aLayerID = 0; aLayerID < 2; ++aLayerID) |
189f85a3 | 6369 | { |
05aa616d | 6370 | const Graphic3d_Vec4 aFresnel = aLayerID < 1 ? aBSDF.FresnelCoat.Serialize() |
6371 | : aBSDF.FresnelBase.Serialize(); | |
189f85a3 | 6372 | |
05aa616d | 6373 | theDI << (aLayerID < 1 ? "Coat Fresnel: " |
6374 | : "Base Fresnel: "); | |
6375 | ||
6376 | if (aFresnel.x() >= 0.f) | |
6377 | { | |
6378 | theDI << "Schlick " << "R = " << aFresnel.r() << ", " | |
6379 | << "G = " << aFresnel.g() << ", " | |
6380 | << "B = " << aFresnel.b() << "\n"; | |
6381 | } | |
6382 | else if (aFresnel.x() >= -1.5f) | |
6383 | { | |
6384 | theDI << "Constant " << aFresnel.z() << "\n"; | |
6385 | } | |
6386 | else if (aFresnel.x() >= -2.5f) | |
6387 | { | |
6388 | theDI << "Conductor " << "N = " << aFresnel.y() << ", " | |
6389 | << "K = " << aFresnel.z() << "\n"; | |
6390 | } | |
6391 | else | |
6392 | { | |
6393 | theDI << "Dielectric " << "N = " << aFresnel.y() << "\n"; | |
6394 | } | |
6395 | } | |
189f85a3 | 6396 | |
05aa616d | 6397 | theDI << "Coat roughness: " << aBSDF.Kc.w() << "\n" |
6398 | << "Base roughness: " << aBSDF.Ks.w() << "\n" | |
6399 | << "Absorption coeff: " << aBSDF.Absorption.w() << "\n" | |
6400 | << "Absorption color: " << aBSDF.Absorption.r() << ", " | |
6401 | << aBSDF.Absorption.g() << ", " | |
6402 | << aBSDF.Absorption.b() << "\n"; | |
189f85a3 | 6403 | |
6404 | return 0; | |
6405 | } | |
6406 | ||
05aa616d | 6407 | if (aCmd.HasOption ("coatRoughness", 1, Standard_True)) |
6408 | { | |
6409 | aBSDF.Kc.w() = aCmd.ArgFloat ("coatRoughness"); | |
6410 | } | |
6411 | ||
6412 | if (aCmd.HasOption ("baseRoughness", 1, Standard_True)) | |
189f85a3 | 6413 | { |
05aa616d | 6414 | aBSDF.Ks.w () = aCmd.ArgFloat ("baseRoughness"); |
189f85a3 | 6415 | } |
6416 | ||
6417 | if (aCmd.HasOption ("absorpCoeff", 1, Standard_True)) | |
6418 | { | |
05aa616d | 6419 | aBSDF.Absorption.w() = aCmd.ArgFloat ("absorpCoeff"); |
189f85a3 | 6420 | } |
6421 | ||
6422 | if (aCmd.HasOption ("absorpColor", 3, Standard_True)) | |
6423 | { | |
05aa616d | 6424 | const Graphic3d_Vec3 aRGB = aCmd.ArgVec3f ("absorpColor"); |
6425 | ||
6426 | aBSDF.Absorption.r() = aRGB.r(); | |
6427 | aBSDF.Absorption.g() = aRGB.g(); | |
6428 | aBSDF.Absorption.b() = aRGB.b(); | |
6429 | } | |
6430 | ||
6431 | if (aCmd.HasOption ("kc", 3) || aCmd.HasOption ("kc", 1, Standard_True)) | |
6432 | { | |
6433 | Graphic3d_Vec3 aKc; | |
6434 | ||
6435 | if (aCmd.HasOption ("kc", 3)) | |
6436 | { | |
6437 | aKc = aCmd.ArgVec3f ("kc"); | |
6438 | } | |
6439 | else | |
6440 | { | |
6441 | aKc = Graphic3d_Vec3 (aCmd.ArgFloat ("kc")); | |
6442 | } | |
6443 | ||
6444 | aBSDF.Kc.r() = aKc.r(); | |
6445 | aBSDF.Kc.g() = aKc.g(); | |
6446 | aBSDF.Kc.b() = aKc.b(); | |
189f85a3 | 6447 | } |
6448 | ||
6449 | if (aCmd.HasOption ("kd", 3)) | |
6450 | { | |
6451 | aBSDF.Kd = aCmd.ArgVec3f ("kd"); | |
6452 | } | |
6453 | else if (aCmd.HasOption ("kd", 1, Standard_True)) | |
6454 | { | |
6455 | aBSDF.Kd = Graphic3d_Vec3 (aCmd.ArgFloat ("kd")); | |
6456 | } | |
6457 | ||
05aa616d | 6458 | if (aCmd.HasOption ("ks", 3) || aCmd.HasOption ("ks", 1, Standard_True)) |
189f85a3 | 6459 | { |
05aa616d | 6460 | Graphic3d_Vec3 aKs; |
6461 | ||
6462 | if (aCmd.HasOption ("ks", 3)) | |
6463 | { | |
6464 | aKs = aCmd.ArgVec3f ("ks"); | |
6465 | } | |
6466 | else | |
6467 | { | |
6468 | aKs = Graphic3d_Vec3 (aCmd.ArgFloat ("ks")); | |
6469 | } | |
6470 | ||
6471 | aBSDF.Ks.r() = aKs.r(); | |
6472 | aBSDF.Ks.g() = aKs.g(); | |
6473 | aBSDF.Ks.b() = aKs.b(); | |
189f85a3 | 6474 | } |
6475 | ||
6476 | if (aCmd.HasOption ("kt", 3)) | |
6477 | { | |
6478 | aBSDF.Kt = aCmd.ArgVec3f ("kt"); | |
6479 | } | |
6480 | else if (aCmd.HasOption ("kt", 1, Standard_True)) | |
6481 | { | |
6482 | aBSDF.Kt = Graphic3d_Vec3 (aCmd.ArgFloat ("kt")); | |
6483 | } | |
6484 | ||
189f85a3 | 6485 | if (aCmd.HasOption ("le", 3)) |
6486 | { | |
6487 | aBSDF.Le = aCmd.ArgVec3f ("le"); | |
6488 | } | |
6489 | else if (aCmd.HasOption ("le", 1, Standard_True)) | |
6490 | { | |
6491 | aBSDF.Le = Graphic3d_Vec3 (aCmd.ArgFloat ("le")); | |
6492 | } | |
6493 | ||
6494 | const std::string aFresnelErrorMessage = | |
05aa616d | 6495 | "Error! Wrong Fresnel type. Allowed types are: Constant F, Schlick R G B, Dielectric N, Conductor N K\n"; |
189f85a3 | 6496 | |
05aa616d | 6497 | for (int aLayerID = 0; aLayerID < 2; ++aLayerID) |
189f85a3 | 6498 | { |
05aa616d | 6499 | const std::string aFresnel = aLayerID < 1 ? "baseFresnel" |
6500 | : "coatFresnel"; | |
189f85a3 | 6501 | |
05aa616d | 6502 | if (aCmd.HasOption (aFresnel, 4)) // Schlick: type R G B |
189f85a3 | 6503 | { |
05aa616d | 6504 | std::string aFresnelType = aCmd.Arg (aFresnel, 0); |
d6cda17a | 6505 | std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase); |
189f85a3 | 6506 | |
05aa616d | 6507 | if (aFresnelType == "schlick") |
6508 | { | |
6509 | Graphic3d_Vec3 aRGB (static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str())), | |
6510 | static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 2).c_str())), | |
6511 | static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 3).c_str()))); | |
189f85a3 | 6512 | |
05aa616d | 6513 | aRGB.r() = std::min (std::max (aRGB.r(), 0.f), 1.f); |
6514 | aRGB.g() = std::min (std::max (aRGB.g(), 0.f), 1.f); | |
6515 | aRGB.b() = std::min (std::max (aRGB.b(), 0.f), 1.f); | |
6516 | ||
6517 | (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateSchlick (aRGB); | |
6518 | } | |
6519 | else | |
6520 | { | |
6521 | theDI << aFresnelErrorMessage.c_str() << "\n"; | |
6522 | } | |
189f85a3 | 6523 | } |
05aa616d | 6524 | else if (aCmd.HasOption (aFresnel, 3)) // Conductor: type N K |
189f85a3 | 6525 | { |
05aa616d | 6526 | std::string aFresnelType = aCmd.Arg (aFresnel, 0); |
d6cda17a | 6527 | std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase); |
05aa616d | 6528 | |
6529 | if (aFresnelType == "conductor") | |
6530 | { | |
6531 | const float aN = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str())); | |
6532 | const float aK = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 2).c_str())); | |
6533 | ||
6534 | (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateConductor (aN, aK); | |
6535 | } | |
6536 | else | |
6537 | { | |
6538 | theDI << aFresnelErrorMessage.c_str() << "\n"; | |
6539 | } | |
189f85a3 | 6540 | } |
05aa616d | 6541 | else if (aCmd.HasOption (aFresnel, 2)) // Dielectric or Constant: type N|C |
189f85a3 | 6542 | { |
05aa616d | 6543 | std::string aFresnelType = aCmd.Arg (aFresnel, 0); |
d6cda17a | 6544 | std::transform (aFresnelType.begin (), aFresnelType.end (), aFresnelType.begin (), ::LowerCase); |
05aa616d | 6545 | |
6546 | if (aFresnelType == "constant") | |
6547 | { | |
6548 | const float aR = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str())); | |
6549 | ||
6550 | (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateConstant (aR); | |
6551 | } | |
6552 | else if (aFresnelType == "dielectric") | |
6553 | { | |
6554 | const float aN = static_cast<float> (Draw::Atof (aCmd.Arg (aFresnel, 1).c_str())); | |
6555 | ||
6556 | (aLayerID < 1 ? aBSDF.FresnelBase : aBSDF.FresnelCoat) = Graphic3d_Fresnel::CreateDielectric (aN); | |
6557 | } | |
6558 | else | |
6559 | { | |
6560 | theDI << aFresnelErrorMessage.c_str() << "\n"; | |
6561 | } | |
189f85a3 | 6562 | } |
6563 | } | |
6564 | ||
6565 | if (aCmd.HasOption ("normalize")) | |
6566 | { | |
6567 | aBSDF.Normalize(); | |
6568 | } | |
6569 | ||
6570 | aMaterial.SetBSDF (aBSDF); | |
6571 | anIObj->SetMaterial (aMaterial); | |
6572 | ||
189f85a3 | 6573 | return 0; |
6574 | } | |
6575 | ||
f751596e | 6576 | //============================================================================== |
6577 | //function : VLoadSelection | |
6578 | //purpose : Adds given objects to map of AIS and loads selection primitives for them | |
6579 | //============================================================================== | |
6580 | static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/, | |
6581 | Standard_Integer theArgNb, | |
6582 | const char** theArgVec) | |
6583 | { | |
6584 | if (theArgNb < 2) | |
6585 | { | |
23fe70ec | 6586 | Message::SendFail ("Syntax error: wrong number of arguments."); |
f751596e | 6587 | return 1; |
6588 | } | |
6589 | ||
6590 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
6591 | if (aCtx.IsNull()) | |
6592 | { | |
6593 | ViewerTest::ViewerInit(); | |
6594 | aCtx = ViewerTest::GetAISContext(); | |
6595 | } | |
6596 | ||
6597 | // Parse input arguments | |
f751596e | 6598 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
6599 | { | |
68dcee02 | 6600 | const TCollection_AsciiString aName = theArgVec[anArgIter]; |
5b111128 | 6601 | Handle(AIS_InteractiveObject) aShape; |
8f521168 | 6602 | if (!GetMapOfAIS().Find2 (aName, aShape)) |
6603 | { | |
1c8fc6be | 6604 | TopoDS_Shape aDrawShape = DBRep::GetExisting (aName); |
6605 | if (!aDrawShape.IsNull()) | |
f751596e | 6606 | { |
1c8fc6be | 6607 | aShape = new AIS_Shape (aDrawShape); |
f751596e | 6608 | GetMapOfAIS().Bind (aShape, aName); |
6609 | } | |
f751596e | 6610 | } |
1c8fc6be | 6611 | if (aShape.IsNull()) |
6612 | { | |
23fe70ec | 6613 | Message::SendFail() << "Syntax error: presentation '" << aName << "' not found"; |
1c8fc6be | 6614 | return 1; |
6615 | } | |
f751596e | 6616 | |
1c8fc6be | 6617 | aCtx->Load (aShape, -1); |
6618 | aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True); | |
6619 | } | |
f751596e | 6620 | return 0; |
6621 | } | |
6622 | ||
7fd59977 | 6623 | //============================================================================== |
6624 | //function : ViewerTest::Commands | |
6625 | //purpose : Add all the viewer command in the Draw_Interpretor | |
6626 | //============================================================================== | |
6627 | ||
6628 | void ViewerTest::Commands(Draw_Interpretor& theCommands) | |
6629 | { | |
6630 | ViewerTest::ViewerCommands(theCommands); | |
6631 | ViewerTest::RelationCommands(theCommands); | |
6632 | ViewerTest::ObjectCommands(theCommands); | |
6633 | ViewerTest::FilletCommands(theCommands); | |
3946774d | 6634 | ViewerTest::OpenGlCommands(theCommands); |
7fd59977 | 6635 | |
44f6e8d5 | 6636 | const char* aGroup = "AIS Viewer"; |
6637 | const char* aFileName = __FILE__; | |
6638 | auto addCmd = [&](const char* theName, Draw_Interpretor::CommandFunction theFunc, const char* theHelp) | |
6639 | { | |
6640 | theCommands.Add (theName, theHelp, aFileName, theFunc, aGroup); | |
6641 | }; | |
7fd59977 | 6642 | |
6643 | // display | |
44f6e8d5 | 6644 | addCmd ("visos", visos, /* [visos] */ R"( |
6645 | visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)] | |
6646 | If last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane. | |
6647 | )" /* [visos] */); | |
6648 | ||
6649 | addCmd ("vdisplay", VDisplay2, /* [vdisplay] */ R"( | |
6650 | vdisplay [-noupdate|-update] [-mutable] [-neutral] | |
f035e071 | 6651 | [-trsfPers {zoom|rotate|zoomRotate|trihedron|none}=none] |
44f6e8d5 | 6652 | [-trsfPersPos X Y [Z]] [-3d] |
6653 | [-2d|-trihedron [{top|bottom|left|right|topLeft | |
6654 | |topRight|bottomLeft|bottomRight} | |
6655 | [offsetX offsetY]]] | |
f035e071 | 6656 | [-trsfPersOrtho] |
44f6e8d5 | 6657 | [-dispMode mode] [-highMode mode] |
6658 | [-layer index] [-top|-topmost|-overlay|-underlay] | |
6659 | [-redisplay] [-erased] | |
6660 | [-noecho] [-autoTriangulation {0|1}] | |
6661 | name1 [name2] ... [name n] | |
6662 | Displays named objects. | |
f035e071 | 6663 | -noupdate Suppresses viewer redraw call. |
6664 | -mutable Enables optimizations for mutable objects. | |
6665 | -neutral Draws objects in main viewer. | |
6666 | -erased Loads the object into context, but does not display it. | |
6667 | -layer Sets z-layer for objects. | |
6668 | Alternatively -overlay|-underlay|-top|-topmost | |
6669 | options can be used for the default z-layers. | |
6670 | -top Draws object on top of main presentations | |
6671 | but below topmost. | |
6672 | -topmost Draws in overlay for 3D presentations. | |
6673 | with independent Depth. | |
6674 | -overlay Draws objects in overlay for 2D presentations. | |
6675 | (On-Screen-Display) | |
6676 | -underlay Draws objects in underlay for 2D presentations. | |
6677 | (On-Screen-Display) | |
44f6e8d5 | 6678 | -selectable|-noselect Controls selection of objects. |
f035e071 | 6679 | -trsfPers Sets a transform persistence flags. |
6680 | -trsfPersPos Sets an anchor point for transform persistence. | |
6681 | -2d Displays object in screen coordinates. | |
6682 | (DY looks up) | |
6683 | -trsfPersOrtho Set orthographic transform persistence. | |
6684 | (Objects shown with orthographic projection) | |
6685 | -dispmode Sets display mode for objects. | |
6686 | -highmode Sets hilight mode for objects. | |
6687 | -redisplay Recomputes presentation of objects. | |
6688 | -noecho Avoid printing of command results. | |
6689 | -autoTriang Enable/disable auto-triangulation for displayed shape. | |
44f6e8d5 | 6690 | )" /* [vdisplay] */); |
6691 | ||
6692 | addCmd ("vnbdisplayed", VNbDisplayed, /* [vnbdisplayed] */ R"( | |
6693 | vnbdisplayed : Returns number of displayed objects | |
6694 | )" /* [vnbdisplayed] */); | |
6695 | ||
6696 | addCmd ("vupdate", VUpdate, /* [vupdate] */ R"( | |
6697 | vupdate name1 [name2] ... [name n] | |
6698 | Updates named objects in interactive context | |
6699 | )" /* [vupdate] */); | |
6700 | ||
6701 | addCmd ("verase", VErase, /* [verase] */ R"( | |
6702 | verase [-noupdate|-update] [name1] ... [name n] [-noerror] | |
6703 | Erases selected or named objects. | |
6704 | If there are no selected or named objects the whole viewer is erased. | |
6705 | Option -noerror prevents exception on non-existing objects. | |
6706 | )" /* [verase] */); | |
6707 | ||
6708 | addCmd ("vremove", VRemove, /* [vremove] */ R"( | |
6709 | vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n] [-noerror] | |
6710 | or vremove [-context] -all to remove all objects | |
6711 | Removes selected or named objects. | |
6712 | -context do not delete object from the map of objects and names; | |
6713 | -noupdate suppresses viewer redraw call; | |
6714 | -noinfo suppresses displaying the list of removed objects; | |
6715 | -noerror prevents exception on non-existing objects. | |
6716 | )" /* [vremove] */); | |
6717 | ||
6718 | addCmd ("vdonly", VDonly2, /* [vdonly] */ R"( | |
6719 | vdonly [-noupdate|-update] [name1] ... [name n] | |
6720 | Displays only selected or named objects. | |
6721 | )" /* [vdonly] */); | |
6722 | ||
6723 | addCmd ("vdisplayall", VDisplayAll, /* [vdisplayall] */ R"( | |
6724 | vdisplayall : Displays all erased interactive objects (see vdir and vstate). | |
6725 | )" /* [vdisplayall] */); | |
6726 | ||
6727 | addCmd ("veraseall", VErase, /* [veraseall] */ R"( | |
6728 | veraseall : Erases all objects displayed in the viewer. | |
6729 | )" /* [veraseall] */); | |
6730 | ||
6731 | addCmd ("verasetype", VEraseType, /* [verasetype] */ R"( | |
6732 | verasetype <Type> | |
6733 | Erase all the displayed objects of one given kind (see vtypes). | |
6734 | The following types are possible: | |
6735 | Point, Axis, Trihedron, PlaneTrihedron, Line, Circle, Plane, Shape, | |
6736 | ConnectedShape, MultiConn.Shape, ConnectedInter., MultiConn., Constraint and Dimension. | |
6737 | )" /* [verasetype] */); | |
6738 | ||
6739 | addCmd ("vbounding", VBounding, /* [vbounding] */ R"( | |
6740 | vbounding [-noupdate|-update] [-mode] name1 [name2 [...]] | |
6741 | [-print] [-hide] | |
6742 | Temporarily display bounding box of specified Interactive Objects, | |
6743 | or print it to console if -print is specified. | |
6744 | Already displayed box might be hidden by -hide option. | |
6745 | )" /* [vbounding] */); | |
6746 | ||
6747 | addCmd ("vdisplaytype", VDisplayType, /* [vdisplaytype] */ R"( | |
6748 | vdisplaytype <Type> <Signature> | |
6749 | Display all the objects of one given kind (see vtypes) which are stored the interactive context. | |
6750 | The following types are possible: | |
6751 | Point, Axis, Trihedron, PlaneTrihedron, Line, Circle, Plane, Shape, | |
6752 | ConnectedShape, MultiConn.Shape, ConnectedInter., MultiConn., Constraint and Dimension. | |
6753 | )" /* [vdisplaytype] */); | |
6754 | ||
6755 | addCmd ("vsetdispmode", VDispMode, /* [vsetdispmode] */ R"( | |
6756 | vsetdispmode [name] mode(1,2,..) | |
6757 | Sets display mode for all, selected or named objects. | |
6758 | In case of a shape presentation, 0 defines WireFrame, and 1 defines Shading display modes. | |
6759 | )" /* [vsetdispmode] */); | |
6760 | ||
6761 | addCmd ("vunsetdispmode", VDispMode, /* [vunsetdispmode] */ R"( | |
6762 | vunsetdispmode [name] | |
6763 | Unsets custom display mode for selected or named objects. | |
6764 | )" /* [vunsetdispmode] */); | |
6765 | ||
6766 | addCmd ("vdir", VDir, /* [vdir] */ R"( | |
6767 | vdir [mask] [-list] | |
6768 | Lists all objects displayed in 3D viewer | |
6769 | mask - name filter like prefix* | |
6770 | -list - format list with new-line per name; OFF by default | |
6771 | )" /* [vdir] */); | |
6772 | ||
6773 | addCmd ("vdump", VDump, /* [vdump] */ R"( | |
6774 | vdump <filename>.png [-width Width -height Height] | |
6775 | [-buffer rgb|rgba|depth=rgb] | |
6776 | [-stereo mono|left|right|blend|sideBySide|overUnder=mono] | |
6777 | [-xrPose base|head|handLeft|handRight=base] | |
6778 | [-tileSize Size=0] | |
6779 | Dumps content of the active view into image file. | |
6780 | )" /* [vdump] */); | |
6781 | ||
6782 | addCmd ("vsub", VSubInt, /* [vsub] */ R"( | |
6783 | vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects | |
6784 | )" /* [vsub] */); | |
6785 | ||
6786 | addCmd ("vaspects", VAspects, /* [vaspects] */ R"( | |
6787 | vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults] [-subshapes subname1 [subname2 [...]]] | |
6788 | [-visibility {0|1}] | |
6789 | [-color {ColorName | R G B}] [-unsetColor] | |
9db675b3 | 6790 | [-backfaceColor Color] [-faceCulling {auto|back|front|doublesided}] |
44f6e8d5 | 6791 | [-material MatName] [-unsetMaterial] |
6792 | [-transparency Transp] [-unsetTransparency] | |
6793 | [-width LineWidth] [-unsetWidth] | |
6794 | [-lineType {solid|dash|dot|dotDash|0xHexPattern} [-stippleFactor factor]] | |
6795 | [-unsetLineType] | |
6796 | [-markerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}] | |
6797 | [-unsetMarkerType] | |
6798 | [-markerSize Scale] [-unsetMarkerSize] | |
6799 | [-freeBoundary {0|1}] | |
6800 | [-freeBoundaryWidth Width] [-unsetFreeBoundaryWidth] | |
6801 | [-freeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor] | |
6802 | [-isoOnTriangulation 0|1] | |
6803 | [-maxParamValue {value}] | |
6804 | [-sensitivity {selection_mode} {value}] | |
6805 | [-shadingModel {unlit|flat|gouraud|phong|pbr|pbr_facet}] | |
6806 | [-unsetShadingModel] | |
6807 | [-interior {solid|hatch|hidenline|point}] [-setHatch HatchStyle] | |
6808 | [-unsetInterior] | |
6809 | [-faceBoundaryDraw {0|1}] [-mostContinuity {c0|g1|c1|g2|c2|c3|cn}] | |
6810 | [-faceBoundaryWidth LineWidth] [-faceBoundaryColor R G B] [-faceBoundaryType LineType] | |
6811 | [-drawEdges {0|1}] [-edgeType LineType] [-edgeColor R G B] [-quadEdges {0|1}] | |
6812 | [-drawSilhouette {0|1}] | |
6813 | [-alphaMode {opaque|mask|blend|maskblend|blendauto} [alphaCutOff=0.5]] | |
6814 | [-dumpJson] [-dumpCompact {0|1}] [-dumpDepth depth] | |
6815 | Manage presentation properties of all, selected or named objects. | |
6816 | When -subshapes is specified than following properties will be assigned to specified sub-shapes. | |
6817 | When -defaults is specified than presentation properties will be | |
6818 | assigned to all objects that have not their own specified properties | |
6819 | and to all objects to be displayed in the future. | |
6820 | If -defaults is used there should not be any objects' names nor -subshapes specifier. | |
6821 | See also vlistcolors and vlistmaterials to list named colors and materials | |
6822 | accepted by arguments -material and -color | |
6823 | )" /* [vaspects] */); | |
6824 | ||
6825 | addCmd ("vsetcolor", VAspects, /* [vsetcolor] */ R"( | |
6826 | vsetcolor [-noupdate|-update] [name] ColorName | |
6827 | Sets color for all, selected or named objects. | |
6828 | Alias for vaspects -setcolor [name] ColorName. | |
6829 | )" /* [vsetcolor] */); | |
6830 | ||
6831 | addCmd ("vunsetcolor", VAspects, /* [vunsetcolor] */ R"( | |
6832 | vunsetcolor [-noupdate|-update] [name] | |
6833 | Resets color for all, selected or named objects. | |
6834 | Alias for vaspects -unsetcolor [name]. | |
6835 | )" /* [vunsetcolor] */); | |
6836 | ||
6837 | addCmd ("vsettransparency", VAspects, /* [vsettransparency] */ R"( | |
6838 | vsettransparency [-noupdate|-update] [name] Coefficient | |
6839 | Sets transparency for all, selected or named objects. | |
6840 | The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent). | |
6841 | Alias for vaspects -settransp [name] Coefficient. | |
6842 | )" /* [vsettransparency] */); | |
6843 | ||
6844 | addCmd ("vunsettransparency", VAspects, /* [vunsettransparency] */ R"( | |
6845 | vunsettransparency [-noupdate|-update] [name] | |
6846 | Resets transparency for all, selected or named objects. | |
6847 | Alias for vaspects -unsettransp [name]. | |
6848 | )" /* [vunsettransparency] */); | |
6849 | ||
6850 | addCmd ("vsetmaterial", VAspects, /* [vsetmaterial] */ R"( | |
6851 | vsetmaterial [-noupdate|-update] [name] MaterialName | |
6852 | n\t\t: Alias for vaspects -setmaterial [name] MaterialName. | |
6853 | )" /* [vsetmaterial] */); | |
6854 | ||
6855 | addCmd ("vunsetmaterial", VAspects, /* [vunsetmaterial] */ R"( | |
6856 | vunsetmaterial [-noupdate|-update] [name] | |
6857 | Alias for vaspects -unsetmaterial [name]. | |
6858 | )" /* [vunsetmaterial] */); | |
6859 | ||
6860 | addCmd ("vsetwidth", VAspects, /* [vsetwidth] */ R"( | |
6861 | vsetwidth [-noupdate|-update] [name] width(0->10) | |
6862 | Alias for vaspects -setwidth [name] width. | |
6863 | )" /* [vsetwidth] */); | |
6864 | ||
6865 | addCmd ("vunsetwidth", VAspects, /* [vunsetwidth] */ R"( | |
6866 | vunsetwidth [-noupdate|-update] [name] | |
6867 | Alias for vaspects -unsetwidth [name]. | |
6868 | )" /* [vunsetwidth] */); | |
6869 | ||
6870 | addCmd ("vsetinteriorstyle", VAspects, /* [vsetinteriorstyle] */ R"( | |
6871 | vsetinteriorstyle [-noupdate|-update] [name] Style | |
6872 | Alias for vaspects -setInterior [name] Style. | |
6873 | )" /* [vsetinteriorstyle] */); | |
6874 | ||
6875 | addCmd ("vsetedgetype", VAspects, /* [vsetedgetype] */ R"( | |
6876 | vsetedgetype [name] [-type {solid, dash, dot}] [-color R G B] [-width value] | |
6877 | Alias for vaspects [name] -setEdgeType Type. | |
6878 | )" /* [vsetedgetype] */); | |
6879 | ||
6880 | addCmd ("vunsetedgetype", VAspects, /* [vunsetedgetype] */ R"( | |
6881 | vunsetedgetype [name] : Alias for vaspects [name] -unsetEdgeType. | |
6882 | )" /* [vunsetedgetype] */); | |
6883 | ||
6884 | addCmd ("vshowfaceboundary", VAspects, /* [vshowfaceboundary] */ R"( | |
6885 | vshowfaceboundary [name]: Alias for vaspects [name] -setFaceBoundaryDraw on. | |
6886 | )" /* [vshowfaceboundary] */); | |
6887 | ||
6888 | addCmd ("vsensdis", VDispSensi, /* [vsensdis] */ R"( | |
6889 | vsensdis : Display active entities | |
6890 | (sensitive entities of one of the standard types corresponding to active selection modes). | |
6891 | Standard entity types are those defined in Select3D package: | |
6892 | - sensitive box, face, curve, segment, circle, point, triangulation, triangle. | |
6893 | Custom (application-defined) sensitive entity types are not processed by this command. | |
6894 | )" /* [vsensdis] */); | |
6895 | ||
6896 | addCmd ("vsensera", VClearSensi, /* [vsensera] */ R"( | |
6897 | vsensera : erase active entities | |
6898 | )" /* [vsensera] */); | |
6899 | ||
6900 | addCmd ("vsetshading", VShading, /* [vsetshading] */ R"( | |
6901 | vsetshading name Quality(default=0.0008) | |
6902 | Sets deflection coefficient that defines the quality of the shape representation in the shading mode. | |
6903 | )" /* [vsetshading] */); | |
6904 | ||
6905 | addCmd ("vunsetshading", VShading, /* [vunsetshading] */ R"( | |
6906 | vunsetshading name | |
6907 | Sets default deflection coefficient (0.0008) that defines the quality of the shape representation in the shading mode. | |
6908 | )" /* [vunsetshading] */); | |
6909 | ||
6910 | addCmd ("vtexture", VTexture, /* [vtexture] */ R"( | |
6911 | vtexture [-noupdate|-update] name [ImageFile|IdOfTexture|off] | |
6912 | [-tex0 Image0] [-tex1 Image1] [...] | |
633084b8 | 6913 | [-3d Image0 Image1 ... ImageN] |
44f6e8d5 | 6914 | [-origin {u v|off}] [-scale {u v|off}] [-repeat {u v|off}] |
6915 | [-trsfTrans du dv] [-trsfScale su sv] [-trsfAngle Angle] | |
6916 | [-modulate {on|off}] [-srgb {on|off}]=on | |
6917 | [-setFilter {nearest|bilinear|trilinear}] | |
6918 | [-setAnisoFilter {off|low|middle|quality}] | |
6919 | [-default] | |
6920 | The texture can be specified by filepath | |
6921 | or as ID (0<=IdOfTexture<=20) specifying one of the predefined textures. | |
6922 | The options are: | |
6923 | -scale Setup texture scaling for generating coordinates; (1, 1) by default | |
6924 | -origin Setup texture origin for generating coordinates; (0, 0) by default | |
6925 | -repeat Setup texture repeat for generating coordinates; (1, 1) by default | |
6926 | -modulate Enable or disable texture color modulation | |
6927 | -srgb Prefer sRGB texture format when applicable; TRUE by default | |
6928 | -trsfAngle Setup dynamic texture coordinates transformation - rotation angle | |
6929 | -trsfTrans Setup dynamic texture coordinates transformation - translation vector | |
6930 | -trsfScale Setup dynamic texture coordinates transformation - scale vector | |
6931 | -setFilter Setup texture filter | |
6932 | -setAnisoFilter Setup anisotropic filter for texture with mip-levels | |
6933 | -default Sets texture mapping default parameters | |
633084b8 | 6934 | -3d Load 3D texture from the list of 2D image files |
44f6e8d5 | 6935 | )" /* [vtexture] */); |
6936 | ||
6937 | addCmd ("vtexscale", VTexture, /* [vtexscale] */ R"( | |
6938 | vtexscale name ScaleU ScaleV | |
6939 | Alias for vtexture name -setScale ScaleU ScaleV. | |
6940 | )" /* [vtexscale] */); | |
6941 | ||
6942 | addCmd ("vtexorigin", VTexture, /* [vtexorigin] */ R"( | |
6943 | vtexorigin name OriginU OriginV | |
6944 | Alias for vtexture name -setOrigin OriginU OriginV. | |
6945 | )" /* [vtexorigin] */); | |
6946 | ||
6947 | addCmd ("vtexrepeat", VTexture, /* [vtexrepeat] */ R"( | |
6948 | vtexrepeat name RepeatU RepeatV | |
6949 | Alias for vtexture name -setRepeat RepeatU RepeatV. | |
6950 | )" /* [vtexrepeat] */); | |
6951 | ||
6952 | addCmd ("vtexdefault", VTexture, /* [vtexdefault] */ R"( | |
6953 | vtexdefault name : Alias for vtexture name -default. | |
6954 | )" /* [vtexdefault] */); | |
6955 | ||
6956 | addCmd ("vstate", VState, /* [vstate] */ R"( | |
6957 | vstate [-entities] [-hasSelected] [name1] ... [nameN] | |
6958 | Reports show/hidden state for selected or named objects. | |
6959 | -entities prints low-level information about detected entities; | |
6960 | -hasSelected prints 1 if context has selected shape and 0 otherwise. | |
6961 | )" /* [vstate] */); | |
6962 | ||
6963 | addCmd ("vpickshapes", VPickShape, /* [vpickshapes] */ R"( | |
6964 | vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .] | |
6965 | Hold Ctrl and pick object by clicking Left mouse button. | |
6966 | Hold also Shift for multiple selection. | |
6967 | )" /* [vpickshapes] */); | |
6968 | ||
6969 | addCmd ("vtypes", VIOTypes, /* [vtypes] */ R"( | |
6970 | vtypes : list of known types and signatures in AIS. | |
6971 | To be Used in vpickobject command for selection with filters. | |
6972 | )" /* [vtypes] */); | |
6973 | ||
6974 | addCmd ("vselfilter", VSelFilter, /* [vselfilter] */ R"( | |
6975 | vselfilter [-contextfilter {AND|OR}] | |
6976 | [-type {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] | |
6977 | [-secondtype {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] | |
6978 | [-clear] | |
6979 | Sets selection shape type filter in context or remove all filters. | |
6980 | -contextfilter to define a selection filter for two or more types of entity, | |
6981 | use value AND (OR by default). | |
6982 | -type set type of selection filter; filters are applied with Or combination. | |
6983 | -clear remove all filters in context. | |
6984 | )" /* [vselfilter] */); | |
6985 | ||
6986 | addCmd ("vpickselected", VPickSelected, /* [vpickselected] */ R"( | |
6987 | vpickselected [name]: extract selected shape. | |
6988 | )" /* [vpickselected] */); | |
6989 | ||
6990 | addCmd ("vloadselection", VLoadSelection, /* [vloadselection] */ R"( | |
6991 | vloadselection [-context] [name1] ... [nameN] | |
6992 | Allows to load selection primitives for the shapes with names given without displaying them. | |
6993 | )" /* [vloadselection] */); | |
6994 | ||
6995 | addCmd ("vbsdf", VBsdf, /* [vbsdf] */ R"( | |
6996 | vbsdf [name] [options] | |
6997 | nAdjusts parameters of material BSDF: | |
6998 | -help shows this message | |
6999 | -print print BSDF | |
7000 | -kd weight of the Lambertian BRDF | |
7001 | -kr weight of the reflection BRDF | |
7002 | -kt weight of the transmission BTDF | |
7003 | -ks weight of the glossy Blinn BRDF | |
7004 | -le self-emitted radiance | |
7005 | -fresnel Fresnel coefficients; Allowed fresnel formats are: Constant x, | |
7006 | Schlick x y z, Dielectric x, Conductor x y | |
7007 | -roughness roughness of material (Blinn's exponent) | |
7008 | -absorpcoeff absorption coefficient (only for transparent material) | |
7009 | -absorpcolor absorption color (only for transparent material) | |
7010 | -normalize normalize BSDF coefficients | |
7011 | )" /* [vbsdf] */); | |
7fd59977 | 7012 | } |
7013 | ||
1d7ca641 | 7014 | //============================================================================== |
7015 | //function : splitParameter | |
197ac94e | 7016 | //purpose : Split parameter string to parameter name and parameter value |
1d7ca641 | 7017 | //============================================================================== |
7018 | Standard_Boolean ViewerTest::SplitParameter (const TCollection_AsciiString& theString, | |
7019 | TCollection_AsciiString& theName, | |
7020 | TCollection_AsciiString& theValue) | |
7021 | { | |
7022 | Standard_Integer aParamNameEnd = theString.FirstLocationInSet ("=", 1, theString.Length()); | |
7023 | ||
7024 | if (aParamNameEnd == 0) | |
7025 | { | |
7026 | return Standard_False; | |
7027 | } | |
7028 | ||
7029 | TCollection_AsciiString aString (theString); | |
7030 | if (aParamNameEnd != 0) | |
7031 | { | |
7032 | theValue = aString.Split (aParamNameEnd); | |
7033 | aString.Split (aString.Length() - 1); | |
7034 | theName = aString; | |
7035 | } | |
7fd59977 | 7036 | |
1d7ca641 | 7037 | return Standard_True; |
7038 | } | |
7fd59977 | 7039 | |
7fd59977 | 7040 | //============================================================================== |
7041 | // ViewerTest::Factory | |
7042 | //============================================================================== | |
7043 | void ViewerTest::Factory(Draw_Interpretor& theDI) | |
7044 | { | |
7045 | // definition of Viewer Command | |
128cc8df | 7046 | ViewerTest::Commands(theDI); |
128cc8df | 7047 | |
0797d9d3 | 7048 | #ifdef OCCT_DEBUG |
586db386 | 7049 | theDI << "Draw Plugin : OCC V2d & V3d commands are loaded\n"; |
7fd59977 | 7050 | #endif |
7051 | } | |
7052 | ||
7053 | // Declare entry point PLUGINFACTORY | |
7054 | DPLUGIN(ViewerTest) |