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