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