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