| 1 | // Created on: 1997-07-23 |
| 2 | // Created by: Henri JEANNIN |
| 3 | // Copyright (c) 1997-1999 Matra Datavision |
| 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 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 |
| 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. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | // Modified by Eric Gouthiere [sep-oct 98] -> add commands for display... |
| 18 | // Modified by Robert Coublanc [nov 16-17-18 1998] |
| 19 | // -split ViewerTest.cxx into 3 files : ViewerTest.cxx, |
| 20 | // ViewerTest_ObjectCommands.cxx |
| 21 | // ViewerTest_RelationCommands.cxx |
| 22 | // -add Functions and commands for interactive selection of shapes and objects |
| 23 | // in AIS Viewers. (PickShape(s), PickObject(s), |
| 24 | |
| 25 | #include <Standard_Stream.hxx> |
| 26 | |
| 27 | #include <ViewerTest.hxx> |
| 28 | #include <ViewerTest_CmdParser.hxx> |
| 29 | |
| 30 | #include <TopLoc_Location.hxx> |
| 31 | #include <TopTools_HArray1OfShape.hxx> |
| 32 | #include <TColStd_HArray1OfTransient.hxx> |
| 33 | #include <TColStd_SequenceOfAsciiString.hxx> |
| 34 | #include <TColStd_HSequenceOfAsciiString.hxx> |
| 35 | #include <TColStd_MapOfTransient.hxx> |
| 36 | #include <OSD_Timer.hxx> |
| 37 | #include <Geom_Axis2Placement.hxx> |
| 38 | #include <Geom_Axis1Placement.hxx> |
| 39 | #include <gp_Trsf.hxx> |
| 40 | #include <TopExp_Explorer.hxx> |
| 41 | #include <BRepAdaptor_Curve.hxx> |
| 42 | #include <StdSelect_ShapeTypeFilter.hxx> |
| 43 | #include <AIS.hxx> |
| 44 | #include <AIS_ColoredShape.hxx> |
| 45 | #include <AIS_InteractiveObject.hxx> |
| 46 | #include <AIS_Trihedron.hxx> |
| 47 | #include <AIS_Axis.hxx> |
| 48 | #include <AIS_Relation.hxx> |
| 49 | #include <AIS_TypeFilter.hxx> |
| 50 | #include <AIS_SignatureFilter.hxx> |
| 51 | #include <AIS_LocalContext.hxx> |
| 52 | #include <AIS_ListOfInteractive.hxx> |
| 53 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
| 54 | #include <Aspect_InteriorStyle.hxx> |
| 55 | #include <Aspect_Window.hxx> |
| 56 | #include <Graphic3d_AspectFillArea3d.hxx> |
| 57 | #include <Graphic3d_AspectLine3d.hxx> |
| 58 | #include <Graphic3d_CStructure.hxx> |
| 59 | #include <Graphic3d_TextureRoot.hxx> |
| 60 | #include <Image_AlienPixMap.hxx> |
| 61 | #include <Prs3d_Drawer.hxx> |
| 62 | #include <Prs3d_ShadingAspect.hxx> |
| 63 | #include <Prs3d_IsoAspect.hxx> |
| 64 | #include <Prs3d_PointAspect.hxx> |
| 65 | #include <Select3D_SensitiveWire.hxx> |
| 66 | #include <SelectMgr_EntityOwner.hxx> |
| 67 | #include <StdSelect_BRepOwner.hxx> |
| 68 | #include <StdSelect_ViewerSelector3d.hxx> |
| 69 | #include <TopTools_MapOfShape.hxx> |
| 70 | #include <ViewerTest_AutoUpdater.hxx> |
| 71 | |
| 72 | #include <stdio.h> |
| 73 | |
| 74 | #include <Draw_Interpretor.hxx> |
| 75 | #include <TCollection_AsciiString.hxx> |
| 76 | #include <Draw_PluginMacro.hxx> |
| 77 | |
| 78 | // avoid warnings on 'extern "C"' functions returning C++ classes |
| 79 | #ifdef WNT |
| 80 | #define _CRT_SECURE_NO_DEPRECATE |
| 81 | #pragma warning(4:4190) |
| 82 | #pragma warning (disable:4996) |
| 83 | #endif |
| 84 | |
| 85 | extern int ViewerMainLoop(Standard_Integer argc, const char** argv); |
| 86 | |
| 87 | #include <Quantity_Color.hxx> |
| 88 | #include <Quantity_NameOfColor.hxx> |
| 89 | |
| 90 | #include <Graphic3d_NameOfMaterial.hxx> |
| 91 | |
| 92 | #define DEFAULT_COLOR Quantity_NOC_GOLDENROD |
| 93 | #define DEFAULT_FREEBOUNDARY_COLOR Quantity_NOC_GREEN |
| 94 | #define DEFAULT_MATERIAL Graphic3d_NOM_BRASS |
| 95 | |
| 96 | //======================================================================= |
| 97 | //function : GetColorFromName |
| 98 | //purpose : get the Quantity_NameOfColor from a string |
| 99 | //======================================================================= |
| 100 | |
| 101 | Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName) |
| 102 | { |
| 103 | Quantity_NameOfColor aColor = DEFAULT_COLOR; |
| 104 | Quantity_Color::ColorFromName (theName, aColor); |
| 105 | return aColor; |
| 106 | } |
| 107 | |
| 108 | //======================================================================= |
| 109 | //function : ParseColor |
| 110 | //purpose : |
| 111 | //======================================================================= |
| 112 | |
| 113 | Standard_Integer ViewerTest::ParseColor (Standard_Integer theArgNb, |
| 114 | const char** theArgVec, |
| 115 | Quantity_Color& theColor) |
| 116 | { |
| 117 | Quantity_NameOfColor aColor = Quantity_NOC_BLACK; |
| 118 | if (theArgNb >= 1 |
| 119 | && Quantity_Color::ColorFromName (theArgVec[0], aColor)) |
| 120 | { |
| 121 | theColor = aColor; |
| 122 | return 1; |
| 123 | } |
| 124 | else if (theArgNb >= 3) |
| 125 | { |
| 126 | const TCollection_AsciiString anRgbStr[3] = |
| 127 | { |
| 128 | theArgVec[0], |
| 129 | theArgVec[1], |
| 130 | theArgVec[2] |
| 131 | }; |
| 132 | if (!anRgbStr[0].IsRealValue() |
| 133 | || !anRgbStr[1].IsRealValue() |
| 134 | || !anRgbStr[2].IsRealValue()) |
| 135 | { |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | Graphic3d_Vec4d anRgb; |
| 140 | anRgb.x() = anRgbStr[0].RealValue(); |
| 141 | anRgb.y() = anRgbStr[1].RealValue(); |
| 142 | anRgb.z() = anRgbStr[2].RealValue(); |
| 143 | if (anRgb.x() < 0.0 || anRgb.x() > 1.0 |
| 144 | || anRgb.y() < 0.0 || anRgb.y() > 1.0 |
| 145 | || anRgb.z() < 0.0 || anRgb.z() > 1.0) |
| 146 | { |
| 147 | std::cout << "Error: RGB color values should be within range 0..1!\n"; |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | theColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB); |
| 152 | return 3; |
| 153 | } |
| 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | //======================================================================= |
| 159 | //function : GetTypeNames |
| 160 | //purpose : |
| 161 | //======================================================================= |
| 162 | static const char** GetTypeNames() |
| 163 | { |
| 164 | static const char* names[14] = {"Point","Axis","Trihedron","PlaneTrihedron", "Line","Circle","Plane", |
| 165 | "Shape","ConnectedShape","MultiConn.Shape", |
| 166 | "ConnectedInter.","MultiConn.", |
| 167 | "Constraint","Dimension"}; |
| 168 | static const char** ThePointer = names; |
| 169 | return ThePointer; |
| 170 | } |
| 171 | |
| 172 | //======================================================================= |
| 173 | //function : GetTypeAndSignfromString |
| 174 | //purpose : |
| 175 | //======================================================================= |
| 176 | void GetTypeAndSignfromString (const char* name,AIS_KindOfInteractive& TheType,Standard_Integer& TheSign) |
| 177 | { |
| 178 | const char ** thefullnames = GetTypeNames(); |
| 179 | Standard_Integer index(-1); |
| 180 | |
| 181 | for(Standard_Integer i=0;i<=13 && index==-1;i++) |
| 182 | if(!strcasecmp(name,thefullnames[i])) |
| 183 | index = i; |
| 184 | |
| 185 | if(index ==-1){ |
| 186 | TheType = AIS_KOI_None; |
| 187 | TheSign = -1; |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | if(index<=6){ |
| 192 | TheType = AIS_KOI_Datum; |
| 193 | TheSign = index+1; |
| 194 | } |
| 195 | else if (index <=9){ |
| 196 | TheType = AIS_KOI_Shape; |
| 197 | TheSign = index-7; |
| 198 | } |
| 199 | else if(index<=11){ |
| 200 | TheType = AIS_KOI_Object; |
| 201 | TheSign = index-10; |
| 202 | } |
| 203 | else{ |
| 204 | TheType = AIS_KOI_Relation; |
| 205 | TheSign = index-12; |
| 206 | } |
| 207 | |
| 208 | } |
| 209 | |
| 210 | |
| 211 | |
| 212 | #include <string.h> |
| 213 | #include <Draw_Interpretor.hxx> |
| 214 | #include <Draw.hxx> |
| 215 | #include <Draw_Appli.hxx> |
| 216 | #include <DBRep.hxx> |
| 217 | |
| 218 | |
| 219 | #include <TCollection_AsciiString.hxx> |
| 220 | #include <V3d_Viewer.hxx> |
| 221 | #include <V3d_View.hxx> |
| 222 | #include <V3d.hxx> |
| 223 | |
| 224 | #include <AIS_InteractiveContext.hxx> |
| 225 | #include <AIS_Shape.hxx> |
| 226 | #include <AIS_TexturedShape.hxx> |
| 227 | #include <AIS_DisplayMode.hxx> |
| 228 | #include <TColStd_MapOfInteger.hxx> |
| 229 | #include <AIS_MapOfInteractive.hxx> |
| 230 | #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx> |
| 231 | #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx> |
| 232 | #include <ViewerTest_EventManager.hxx> |
| 233 | |
| 234 | #include <TopoDS_Solid.hxx> |
| 235 | #include <BRepTools.hxx> |
| 236 | #include <BRep_Builder.hxx> |
| 237 | #include <TopAbs_ShapeEnum.hxx> |
| 238 | |
| 239 | #include <TopoDS.hxx> |
| 240 | #include <BRep_Tool.hxx> |
| 241 | |
| 242 | |
| 243 | #include <Draw_Window.hxx> |
| 244 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
| 245 | #include <AIS_ListOfInteractive.hxx> |
| 246 | #include <AIS_DisplayMode.hxx> |
| 247 | #include <TopTools_ListOfShape.hxx> |
| 248 | #include <BRepOffsetAPI_MakeThickSolid.hxx> |
| 249 | #include <BRepOffset.hxx> |
| 250 | |
| 251 | //============================================================================== |
| 252 | // VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES |
| 253 | //============================================================================== |
| 254 | Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(){ |
| 255 | static ViewerTest_DoubleMapOfInteractiveAndName TheMap; |
| 256 | return TheMap; |
| 257 | } |
| 258 | |
| 259 | //======================================================================= |
| 260 | //function : Display |
| 261 | //purpose : |
| 262 | //======================================================================= |
| 263 | Standard_Boolean ViewerTest::Display (const TCollection_AsciiString& theName, |
| 264 | const Handle(AIS_InteractiveObject)& theObject, |
| 265 | const Standard_Boolean theToUpdate, |
| 266 | const Standard_Boolean theReplaceIfExists) |
| 267 | { |
| 268 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); |
| 269 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
| 270 | if (aCtx.IsNull()) |
| 271 | { |
| 272 | std::cout << "Error: AIS context is not available.\n"; |
| 273 | return Standard_False; |
| 274 | } |
| 275 | |
| 276 | if (aMap.IsBound2 (theName)) |
| 277 | { |
| 278 | if (!theReplaceIfExists) |
| 279 | { |
| 280 | std::cout << "Error: other interactive object has been already registered with name: " << theName << ".\n" |
| 281 | << "Please use another name.\n"; |
| 282 | return Standard_False; |
| 283 | } |
| 284 | |
| 285 | Handle(AIS_InteractiveObject) anOldObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName)); |
| 286 | if (!anOldObj.IsNull()) |
| 287 | { |
| 288 | aCtx->Remove (anOldObj, Standard_True); |
| 289 | } |
| 290 | aMap.UnBind2 (theName); |
| 291 | } |
| 292 | |
| 293 | if (theObject.IsNull()) |
| 294 | { |
| 295 | // object with specified name has been already unbound |
| 296 | return Standard_True; |
| 297 | } |
| 298 | |
| 299 | // unbind AIS object if it was bound with another name |
| 300 | aMap.UnBind1 (theObject); |
| 301 | |
| 302 | // can be registered without rebinding |
| 303 | aMap.Bind (theObject, theName); |
| 304 | aCtx->Display (theObject, theToUpdate); |
| 305 | return Standard_True; |
| 306 | } |
| 307 | |
| 308 | //! Alias for ViewerTest::Display(), compatibility with old code. |
| 309 | Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName, |
| 310 | const Handle(AIS_InteractiveObject)& theObject, |
| 311 | Standard_Boolean theReplaceIfExists = Standard_True) |
| 312 | { |
| 313 | return ViewerTest::Display (theName, theObject, Standard_True, theReplaceIfExists); |
| 314 | } |
| 315 | |
| 316 | static TColStd_MapOfInteger theactivatedmodes(8); |
| 317 | static TColStd_ListOfTransient theEventMgrs; |
| 318 | |
| 319 | static void VwrTst_InitEventMgr(const Handle(V3d_View)& aView, |
| 320 | const Handle(AIS_InteractiveContext)& Ctx) |
| 321 | { |
| 322 | theEventMgrs.Clear(); |
| 323 | theEventMgrs.Prepend(new ViewerTest_EventManager(aView, Ctx)); |
| 324 | } |
| 325 | |
| 326 | static Handle(V3d_View)& a3DView() |
| 327 | { |
| 328 | static Handle(V3d_View) Viou; |
| 329 | return Viou; |
| 330 | } |
| 331 | |
| 332 | |
| 333 | Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext(){ |
| 334 | static Handle(AIS_InteractiveContext) aContext; |
| 335 | return aContext; |
| 336 | } |
| 337 | |
| 338 | const Handle(V3d_View)& ViewerTest::CurrentView() |
| 339 | { |
| 340 | return a3DView(); |
| 341 | } |
| 342 | void ViewerTest::CurrentView(const Handle(V3d_View)& V) |
| 343 | { |
| 344 | a3DView() = V; |
| 345 | } |
| 346 | |
| 347 | const Handle(AIS_InteractiveContext)& ViewerTest::GetAISContext() |
| 348 | { |
| 349 | return TheAISContext(); |
| 350 | } |
| 351 | |
| 352 | void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx) |
| 353 | { |
| 354 | TheAISContext() = aCtx; |
| 355 | ViewerTest::ResetEventManager(); |
| 356 | } |
| 357 | |
| 358 | Handle(V3d_Viewer) ViewerTest::GetViewerFromContext() |
| 359 | { |
| 360 | return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)(); |
| 361 | } |
| 362 | |
| 363 | Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext() |
| 364 | { |
| 365 | return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)(); |
| 366 | } |
| 367 | |
| 368 | |
| 369 | void ViewerTest::SetEventManager(const Handle(ViewerTest_EventManager)& EM){ |
| 370 | theEventMgrs.Prepend(EM); |
| 371 | } |
| 372 | |
| 373 | void ViewerTest::UnsetEventManager() |
| 374 | { |
| 375 | theEventMgrs.RemoveFirst(); |
| 376 | } |
| 377 | |
| 378 | |
| 379 | void ViewerTest::ResetEventManager() |
| 380 | { |
| 381 | const Handle(V3d_View) aView = ViewerTest::CurrentView(); |
| 382 | VwrTst_InitEventMgr(aView, ViewerTest::GetAISContext()); |
| 383 | } |
| 384 | |
| 385 | Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager() |
| 386 | { |
| 387 | Handle(ViewerTest_EventManager) EM; |
| 388 | if(theEventMgrs.IsEmpty()) return EM; |
| 389 | Handle(Standard_Transient) Tr = theEventMgrs.First(); |
| 390 | EM = Handle(ViewerTest_EventManager)::DownCast (Tr); |
| 391 | return EM; |
| 392 | } |
| 393 | |
| 394 | //======================================================================= |
| 395 | //function : Get Context and active view |
| 396 | //purpose : |
| 397 | //======================================================================= |
| 398 | static Standard_Boolean getCtxAndView (Handle(AIS_InteractiveContext)& theCtx, |
| 399 | Handle(V3d_View)& theView) |
| 400 | { |
| 401 | theCtx = ViewerTest::GetAISContext(); |
| 402 | theView = ViewerTest::CurrentView(); |
| 403 | if (theCtx.IsNull() |
| 404 | || theView.IsNull()) |
| 405 | { |
| 406 | std::cout << "Error: cannot find an active view!\n"; |
| 407 | return Standard_False; |
| 408 | } |
| 409 | return Standard_True; |
| 410 | } |
| 411 | |
| 412 | //============================================================================== |
| 413 | //function : GetShapeFromName |
| 414 | //purpose : Compute an Shape from a draw variable or a file name |
| 415 | //============================================================================== |
| 416 | |
| 417 | static TopoDS_Shape GetShapeFromName(const char* name) |
| 418 | { |
| 419 | TopoDS_Shape S = DBRep::Get(name); |
| 420 | |
| 421 | if ( S.IsNull() ) { |
| 422 | BRep_Builder aBuilder; |
| 423 | BRepTools::Read( S, name, aBuilder); |
| 424 | } |
| 425 | |
| 426 | return S; |
| 427 | } |
| 428 | |
| 429 | //============================================================================== |
| 430 | //function : GetAISShapeFromName |
| 431 | //purpose : Compute an AIS_Shape from a draw variable or a file name |
| 432 | //============================================================================== |
| 433 | Handle(AIS_Shape) GetAISShapeFromName(const char* name) |
| 434 | { |
| 435 | Handle(AIS_Shape) retsh; |
| 436 | |
| 437 | if(GetMapOfAIS().IsBound2(name)){ |
| 438 | const Handle(AIS_InteractiveObject) IO = |
| 439 | Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
| 440 | if (!IO.IsNull()) { |
| 441 | if(IO->Type()==AIS_KOI_Shape) { |
| 442 | if(IO->Signature()==0){ |
| 443 | retsh = Handle(AIS_Shape)::DownCast (IO); |
| 444 | } |
| 445 | else |
| 446 | cout << "an Object which is not an AIS_Shape " |
| 447 | "already has this name!!!"<<endl; |
| 448 | } |
| 449 | } |
| 450 | return retsh; |
| 451 | } |
| 452 | |
| 453 | |
| 454 | TopoDS_Shape S = GetShapeFromName(name); |
| 455 | if ( !S.IsNull() ) { |
| 456 | retsh = new AIS_Shape(S); |
| 457 | } |
| 458 | return retsh; |
| 459 | } |
| 460 | |
| 461 | |
| 462 | //============================================================================== |
| 463 | //function : Clear |
| 464 | //purpose : Remove all the object from the viewer |
| 465 | //============================================================================== |
| 466 | void ViewerTest::Clear() |
| 467 | { |
| 468 | if ( !a3DView().IsNull() ) { |
| 469 | if (TheAISContext()->HasOpenedContext()) |
| 470 | TheAISContext()->CloseLocalContext(); |
| 471 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS()); |
| 472 | while ( it.More() ) { |
| 473 | cout << "Remove " << it.Key2() << endl; |
| 474 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (it.Key1()); |
| 475 | TheAISContext()->Remove(anObj,Standard_False); |
| 476 | it.Next(); |
| 477 | } |
| 478 | TheAISContext()->RebuildSelectionStructs(); |
| 479 | TheAISContext()->UpdateCurrentViewer(); |
| 480 | GetMapOfAIS().Clear(); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | //============================================================================== |
| 485 | //function : StandardModesActivation |
| 486 | //purpose : Activate a selection mode, vertex, edge, wire ..., in a local |
| 487 | // Context |
| 488 | //============================================================================== |
| 489 | void ViewerTest::StandardModeActivation(const Standard_Integer mode ) |
| 490 | { |
| 491 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
| 492 | if(mode==0) { |
| 493 | if (TheAISContext()->HasOpenedContext()) |
| 494 | aContext->CloseLocalContext(); |
| 495 | } else { |
| 496 | |
| 497 | if(!aContext->HasOpenedContext()) { |
| 498 | // To unhilight the preselected object |
| 499 | aContext->UnhilightCurrents(Standard_False); |
| 500 | // Open a local Context in order to be able to select subshape from |
| 501 | // the selected shape if any or for all if there is no selection |
| 502 | if (!aContext->FirstCurrentObject().IsNull()){ |
| 503 | aContext->OpenLocalContext(Standard_False); |
| 504 | |
| 505 | for(aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent()){ |
| 506 | aContext->Load( aContext->Current(),-1,Standard_True); |
| 507 | } |
| 508 | } |
| 509 | else |
| 510 | aContext->OpenLocalContext(); |
| 511 | } |
| 512 | |
| 513 | const char *cmode="???"; |
| 514 | |
| 515 | switch (mode) { |
| 516 | case 0: cmode = "Shape"; break; |
| 517 | case 1: cmode = "Vertex"; break; |
| 518 | case 2: cmode = "Edge"; break; |
| 519 | case 3: cmode = "Wire"; break; |
| 520 | case 4: cmode = "Face"; break; |
| 521 | case 5: cmode = "Shell"; break; |
| 522 | case 6: cmode = "Solid"; break; |
| 523 | case 7: cmode = "Compsolid"; break; |
| 524 | case 8: cmode = "Compound"; break; |
| 525 | } |
| 526 | |
| 527 | if(theactivatedmodes.Contains(mode)) |
| 528 | { // Desactivate |
| 529 | aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode)); |
| 530 | theactivatedmodes.Remove(mode); |
| 531 | cout<<"Mode "<< cmode <<" OFF"<<endl; |
| 532 | } |
| 533 | else |
| 534 | { // Activate |
| 535 | aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode)); |
| 536 | theactivatedmodes.Add(mode); |
| 537 | cout<<"Mode "<< cmode << " ON" << endl; |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | //============================================================================== |
| 543 | //function : CopyIsoAspect |
| 544 | //purpose : Returns copy Prs3d_IsoAspect with new number of isolines. |
| 545 | //============================================================================== |
| 546 | static Handle(Prs3d_IsoAspect) CopyIsoAspect |
| 547 | (const Handle(Prs3d_IsoAspect) &theIsoAspect, |
| 548 | const Standard_Integer theNbIsos) |
| 549 | { |
| 550 | Quantity_Color aColor; |
| 551 | Aspect_TypeOfLine aType; |
| 552 | Standard_Real aWidth; |
| 553 | |
| 554 | theIsoAspect->Aspect()->Values(aColor, aType, aWidth); |
| 555 | |
| 556 | Handle(Prs3d_IsoAspect) aResult = |
| 557 | new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos); |
| 558 | |
| 559 | return aResult; |
| 560 | } |
| 561 | |
| 562 | //============================================================================== |
| 563 | //function : visos |
| 564 | //purpose : Returns or sets the number of U- and V- isos and isIsoOnPlane flag |
| 565 | //Draw arg : [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)] |
| 566 | //============================================================================== |
| 567 | static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
| 568 | { |
| 569 | if (TheAISContext().IsNull()) { |
| 570 | di << argv[0] << " Call 'vinit' before!\n"; |
| 571 | return 1; |
| 572 | } |
| 573 | |
| 574 | if (argc <= 1) { |
| 575 | di << "Current number of isos : " << |
| 576 | TheAISContext()->IsoNumber(AIS_TOI_IsoU) << " " << |
| 577 | TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n"; |
| 578 | di << "IsoOnPlane mode is " << |
| 579 | (TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n"; |
| 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | Standard_Integer aLastInd = argc - 1; |
| 585 | Standard_Boolean isChanged = Standard_False; |
| 586 | Standard_Integer aNbUIsos = 0; |
| 587 | Standard_Integer aNbVIsos = 0; |
| 588 | |
| 589 | if (aLastInd >= 3) { |
| 590 | Standard_Boolean isIsoOnPlane = Standard_False; |
| 591 | |
| 592 | if (strcmp(argv[aLastInd], "1") == 0) { |
| 593 | isIsoOnPlane = Standard_True; |
| 594 | isChanged = Standard_True; |
| 595 | } else if (strcmp(argv[aLastInd], "0") == 0) { |
| 596 | isIsoOnPlane = Standard_False; |
| 597 | isChanged = Standard_True; |
| 598 | } |
| 599 | |
| 600 | if (isChanged) { |
| 601 | aNbVIsos = Draw::Atoi(argv[aLastInd - 1]); |
| 602 | aNbUIsos = Draw::Atoi(argv[aLastInd - 2]); |
| 603 | aLastInd -= 3; |
| 604 | |
| 605 | di << "New number of isos : " << aNbUIsos << " " << aNbVIsos << "\n"; |
| 606 | di << "New IsoOnPlane mode is " << (isIsoOnPlane ? "ON" : "OFF") << "\n"; |
| 607 | |
| 608 | TheAISContext()->IsoOnPlane(isIsoOnPlane); |
| 609 | |
| 610 | if (aLastInd == 0) { |
| 611 | // If there are no shapes provided set the default numbers. |
| 612 | TheAISContext()->SetIsoNumber(aNbUIsos, AIS_TOI_IsoU); |
| 613 | TheAISContext()->SetIsoNumber(aNbVIsos, AIS_TOI_IsoV); |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | Standard_Integer i; |
| 619 | |
| 620 | for (i = 1; i <= aLastInd; i++) { |
| 621 | TCollection_AsciiString name(argv[i]); |
| 622 | Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name); |
| 623 | |
| 624 | if (IsBound) { |
| 625 | const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name); |
| 626 | if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) { |
| 627 | const Handle(AIS_InteractiveObject) aShape = |
| 628 | Handle(AIS_InteractiveObject)::DownCast (anObj); |
| 629 | Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes(); |
| 630 | Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect(); |
| 631 | Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect(); |
| 632 | |
| 633 | if (isChanged) { |
| 634 | CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos)); |
| 635 | CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos)); |
| 636 | TheAISContext()->SetLocalAttributes |
| 637 | (aShape, CurDrawer, Standard_False); |
| 638 | TheAISContext()->Redisplay(aShape); |
| 639 | } else { |
| 640 | di << "Number of isos for " << argv[i] << " : " |
| 641 | << aUIso->Number() << " " << aVIso->Number() << "\n"; |
| 642 | } |
| 643 | } else { |
| 644 | di << argv[i] << ": Not an AIS interactive object!\n"; |
| 645 | } |
| 646 | } else { |
| 647 | di << argv[i] << ": Use 'vdisplay' before\n"; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | if (isChanged) { |
| 652 | TheAISContext()->UpdateCurrentViewer(); |
| 653 | } |
| 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | static Standard_Integer VDispSensi (Draw_Interpretor& , |
| 659 | Standard_Integer theArgNb, |
| 660 | Standard_CString* ) |
| 661 | { |
| 662 | if (theArgNb > 1) |
| 663 | { |
| 664 | std::cout << "Error: wrong syntax!\n"; |
| 665 | return 1; |
| 666 | } |
| 667 | |
| 668 | Handle(AIS_InteractiveContext) aCtx; |
| 669 | Handle(V3d_View) aView; |
| 670 | if (!getCtxAndView (aCtx, aView)) |
| 671 | { |
| 672 | return 1; |
| 673 | } |
| 674 | |
| 675 | aCtx->DisplayActiveSensitive (aView); |
| 676 | return 0; |
| 677 | |
| 678 | } |
| 679 | |
| 680 | static Standard_Integer VClearSensi (Draw_Interpretor& , |
| 681 | Standard_Integer theArgNb, |
| 682 | Standard_CString* ) |
| 683 | { |
| 684 | if (theArgNb > 1) |
| 685 | { |
| 686 | std::cout << "Error: wrong syntax!\n"; |
| 687 | return 1; |
| 688 | } |
| 689 | |
| 690 | Handle(AIS_InteractiveContext) aCtx; |
| 691 | Handle(V3d_View) aView; |
| 692 | if (!getCtxAndView (aCtx, aView)) |
| 693 | { |
| 694 | return 1; |
| 695 | } |
| 696 | aCtx->ClearActiveSensitive (aView); |
| 697 | return 0; |
| 698 | } |
| 699 | |
| 700 | //============================================================================== |
| 701 | //function : VDir |
| 702 | //purpose : To list the displayed object with their attributes |
| 703 | //============================================================================== |
| 704 | static int VDir (Draw_Interpretor& theDI, |
| 705 | Standard_Integer , |
| 706 | const char** ) |
| 707 | { |
| 708 | if (!a3DView().IsNull()) |
| 709 | { |
| 710 | return 0; |
| 711 | } |
| 712 | |
| 713 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 714 | anIter.More(); anIter.Next()) |
| 715 | { |
| 716 | theDI << "\t" << anIter.Key2().ToCString() << "\n"; |
| 717 | } |
| 718 | return 0; |
| 719 | } |
| 720 | |
| 721 | //============================================================================== |
| 722 | //function : VSelPrecision |
| 723 | //purpose : To set the selection tolerance value |
| 724 | //Draw arg : Selection tolerance value (real value determining the width and |
| 725 | // height of selecting frustum bases). Without arguments the function |
| 726 | // just prints current tolerance. |
| 727 | //============================================================================== |
| 728 | static int VSelPrecision(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
| 729 | { |
| 730 | if( argc > 2 ) |
| 731 | { |
| 732 | di << "Wrong parameters! Must be: " << argv[0] << " [-unset] [tolerance]\n"; |
| 733 | return 1; |
| 734 | } |
| 735 | |
| 736 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
| 737 | if( aContext.IsNull() ) |
| 738 | return 1; |
| 739 | |
| 740 | if( argc == 1 ) |
| 741 | { |
| 742 | Standard_Real aPixelTolerance = aContext->PixelTolerance(); |
| 743 | di << "Pixel tolerance : " << aPixelTolerance << "\n"; |
| 744 | } |
| 745 | else if (argc == 2) |
| 746 | { |
| 747 | TCollection_AsciiString anArg = TCollection_AsciiString (argv[1]); |
| 748 | anArg.LowerCase(); |
| 749 | if (anArg == "-unset") |
| 750 | { |
| 751 | aContext->SetPixelTolerance (-1.0); |
| 752 | } |
| 753 | else |
| 754 | { |
| 755 | aContext->SetPixelTolerance (anArg.RealValue()); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | return 0; |
| 760 | } |
| 761 | |
| 762 | //! Auxiliary enumeration |
| 763 | enum ViewerTest_StereoPair |
| 764 | { |
| 765 | ViewerTest_SP_Single, |
| 766 | ViewerTest_SP_SideBySide, |
| 767 | ViewerTest_SP_OverUnder |
| 768 | }; |
| 769 | |
| 770 | //============================================================================== |
| 771 | //function : VDump |
| 772 | //purpose : To dump the active view snapshot to image file |
| 773 | //============================================================================== |
| 774 | static Standard_Integer VDump (Draw_Interpretor& theDI, |
| 775 | Standard_Integer theArgNb, |
| 776 | Standard_CString* theArgVec) |
| 777 | { |
| 778 | if (theArgNb < 2) |
| 779 | { |
| 780 | std::cout << "Error: wrong number of arguments! Image file name should be specified at least.\n"; |
| 781 | return 1; |
| 782 | } |
| 783 | |
| 784 | Standard_Integer anArgIter = 1; |
| 785 | Standard_CString aFilePath = theArgVec[anArgIter++]; |
| 786 | Graphic3d_BufferType aBufferType = Graphic3d_BT_RGB; |
| 787 | V3d_StereoDumpOptions aStereoOpts = V3d_SDO_MONO; |
| 788 | ViewerTest_StereoPair aStereoPair = ViewerTest_SP_Single; |
| 789 | Standard_Integer aWidth = 0; |
| 790 | Standard_Integer aHeight = 0; |
| 791 | for (; anArgIter < theArgNb; ++anArgIter) |
| 792 | { |
| 793 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
| 794 | anArg.LowerCase(); |
| 795 | if (anArg == "-buffer") |
| 796 | { |
| 797 | if (++anArgIter >= theArgNb) |
| 798 | { |
| 799 | std::cout << "Error: wrong syntax at '" << anArg << "'\n"; |
| 800 | return 1; |
| 801 | } |
| 802 | |
| 803 | TCollection_AsciiString aBufArg (theArgVec[anArgIter]); |
| 804 | aBufArg.LowerCase(); |
| 805 | if (aBufArg == "rgba") |
| 806 | { |
| 807 | aBufferType = Graphic3d_BT_RGBA; |
| 808 | } |
| 809 | else if (aBufArg == "rgb") |
| 810 | { |
| 811 | aBufferType = Graphic3d_BT_RGB; |
| 812 | } |
| 813 | else if (aBufArg == "depth") |
| 814 | { |
| 815 | aBufferType = Graphic3d_BT_Depth; |
| 816 | } |
| 817 | else |
| 818 | { |
| 819 | std::cout << "Error: unknown buffer '" << aBufArg << "'\n"; |
| 820 | return 1; |
| 821 | } |
| 822 | } |
| 823 | else if (anArg == "-stereo") |
| 824 | { |
| 825 | if (++anArgIter >= theArgNb) |
| 826 | { |
| 827 | std::cout << "Error: wrong syntax at '" << anArg << "'\n"; |
| 828 | return 1; |
| 829 | } |
| 830 | |
| 831 | TCollection_AsciiString aStereoArg (theArgVec[anArgIter]); |
| 832 | aStereoArg.LowerCase(); |
| 833 | if (aStereoArg == "l" |
| 834 | || aStereoArg == "left") |
| 835 | { |
| 836 | aStereoOpts = V3d_SDO_LEFT_EYE; |
| 837 | } |
| 838 | else if (aStereoArg == "r" |
| 839 | || aStereoArg == "right") |
| 840 | { |
| 841 | aStereoOpts = V3d_SDO_RIGHT_EYE; |
| 842 | } |
| 843 | else if (aStereoArg == "mono") |
| 844 | { |
| 845 | aStereoOpts = V3d_SDO_MONO; |
| 846 | } |
| 847 | else if (aStereoArg == "blended" |
| 848 | || aStereoArg == "blend" |
| 849 | || aStereoArg == "stereo") |
| 850 | { |
| 851 | aStereoOpts = V3d_SDO_BLENDED; |
| 852 | } |
| 853 | else if (aStereoArg == "sbs" |
| 854 | || aStereoArg == "sidebyside") |
| 855 | { |
| 856 | aStereoPair = ViewerTest_SP_SideBySide; |
| 857 | } |
| 858 | else if (aStereoArg == "ou" |
| 859 | || aStereoArg == "overunder") |
| 860 | { |
| 861 | aStereoPair = ViewerTest_SP_OverUnder; |
| 862 | } |
| 863 | else |
| 864 | { |
| 865 | std::cout << "Error: unknown stereo format '" << aStereoArg << "'\n"; |
| 866 | return 1; |
| 867 | } |
| 868 | } |
| 869 | else if (anArg == "-rgba" |
| 870 | || anArg == "rgba") |
| 871 | { |
| 872 | aBufferType = Graphic3d_BT_RGBA; |
| 873 | } |
| 874 | else if (anArg == "-rgb" |
| 875 | || anArg == "rgb") |
| 876 | { |
| 877 | aBufferType = Graphic3d_BT_RGB; |
| 878 | } |
| 879 | else if (anArg == "-depth" |
| 880 | || anArg == "depth") |
| 881 | { |
| 882 | aBufferType = Graphic3d_BT_Depth; |
| 883 | } |
| 884 | |
| 885 | else if (anArg == "-width" |
| 886 | || anArg == "width" |
| 887 | || anArg == "sizex") |
| 888 | { |
| 889 | if (aWidth != 0) |
| 890 | { |
| 891 | std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n"; |
| 892 | return 1; |
| 893 | } |
| 894 | else if (++anArgIter >= theArgNb) |
| 895 | { |
| 896 | std::cout << "Error: integer value is expected right after 'width'\n"; |
| 897 | return 1; |
| 898 | } |
| 899 | aWidth = Draw::Atoi (theArgVec[anArgIter]); |
| 900 | } |
| 901 | else if (anArg == "-height" |
| 902 | || anArg == "height" |
| 903 | || anArg == "-sizey") |
| 904 | { |
| 905 | if (aHeight != 0) |
| 906 | { |
| 907 | std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n"; |
| 908 | return 1; |
| 909 | } |
| 910 | else if (++anArgIter >= theArgNb) |
| 911 | { |
| 912 | std::cout << "Error: integer value is expected right after 'height'\n"; |
| 913 | return 1; |
| 914 | } |
| 915 | aHeight = Draw::Atoi (theArgVec[anArgIter]); |
| 916 | } |
| 917 | else |
| 918 | { |
| 919 | std::cout << "Error: unknown argument '" << theArgVec[anArgIter] << "'\n"; |
| 920 | return 1; |
| 921 | } |
| 922 | } |
| 923 | if ((aWidth <= 0 && aHeight > 0) |
| 924 | || (aWidth > 0 && aHeight <= 0)) |
| 925 | { |
| 926 | std::cout << "Error: dimensions " << aWidth << "x" << aHeight << " are incorrect\n"; |
| 927 | return 1; |
| 928 | } |
| 929 | |
| 930 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
| 931 | if (aView.IsNull()) |
| 932 | { |
| 933 | std::cout << "Error: cannot find an active view!\n"; |
| 934 | return 1; |
| 935 | } |
| 936 | |
| 937 | if (aWidth <= 0 || aHeight <= 0) |
| 938 | { |
| 939 | aView->Window()->Size (aWidth, aHeight); |
| 940 | } |
| 941 | |
| 942 | Image_AlienPixMap aPixMap; |
| 943 | |
| 944 | bool isBigEndian = Image_PixMap::IsBigEndianHost(); |
| 945 | Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN; |
| 946 | switch (aBufferType) |
| 947 | { |
| 948 | case Graphic3d_BT_RGB: aFormat = isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; break; |
| 949 | case Graphic3d_BT_RGBA: aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break; |
| 950 | case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break; |
| 951 | } |
| 952 | |
| 953 | switch (aStereoPair) |
| 954 | { |
| 955 | case ViewerTest_SP_Single: |
| 956 | { |
| 957 | if (!aView->ToPixMap (aPixMap, aWidth, aHeight, aBufferType, Standard_True, aStereoOpts)) |
| 958 | { |
| 959 | theDI << "Fail: view dump failed!\n"; |
| 960 | return 0; |
| 961 | } |
| 962 | else if (aPixMap.SizeX() != Standard_Size(aWidth) |
| 963 | || aPixMap.SizeY() != Standard_Size(aHeight)) |
| 964 | { |
| 965 | theDI << "Fail: dumped dimensions " << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY() |
| 966 | << " are lesser than requested " << aWidth << "x" << aHeight << "\n"; |
| 967 | } |
| 968 | break; |
| 969 | } |
| 970 | case ViewerTest_SP_SideBySide: |
| 971 | { |
| 972 | if (!aPixMap.InitZero (aFormat, aWidth * 2, aHeight)) |
| 973 | { |
| 974 | theDI << "Fail: not enough memory for image allocation!\n"; |
| 975 | return 0; |
| 976 | } |
| 977 | |
| 978 | Image_PixMap aPixMapL, aPixMapR; |
| 979 | aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(), |
| 980 | aWidth, aHeight, aPixMap.SizeRowBytes()); |
| 981 | aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizePixelBytes() * aWidth, |
| 982 | aWidth, aHeight, aPixMap.SizeRowBytes()); |
| 983 | if (!aView->ToPixMap (aPixMapL, aWidth, aHeight, aBufferType, Standard_True, V3d_SDO_LEFT_EYE) |
| 984 | || !aView->ToPixMap (aPixMapR, aWidth, aHeight, aBufferType, Standard_True, V3d_SDO_RIGHT_EYE) |
| 985 | ) |
| 986 | { |
| 987 | theDI << "Fail: view dump failed!\n"; |
| 988 | return 0; |
| 989 | } |
| 990 | break; |
| 991 | } |
| 992 | case ViewerTest_SP_OverUnder: |
| 993 | { |
| 994 | if (!aPixMap.InitZero (aFormat, aWidth, aHeight * 2)) |
| 995 | { |
| 996 | theDI << "Fail: not enough memory for image allocation!\n"; |
| 997 | return 0; |
| 998 | } |
| 999 | |
| 1000 | Image_PixMap aPixMapL, aPixMapR; |
| 1001 | aPixMapL.InitWrapper (aFormat, aPixMap.ChangeData(), |
| 1002 | aWidth, aHeight, aPixMap.SizeRowBytes()); |
| 1003 | aPixMapR.InitWrapper (aFormat, aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aHeight, |
| 1004 | aWidth, aHeight, aPixMap.SizeRowBytes()); |
| 1005 | if (!aView->ToPixMap (aPixMapL, aWidth, aHeight, aBufferType, Standard_True, V3d_SDO_LEFT_EYE) |
| 1006 | || !aView->ToPixMap (aPixMapR, aWidth, aHeight, aBufferType, Standard_True, V3d_SDO_RIGHT_EYE)) |
| 1007 | { |
| 1008 | theDI << "Fail: view dump failed!\n"; |
| 1009 | return 0; |
| 1010 | } |
| 1011 | break; |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | if (!aPixMap.Save (aFilePath)) |
| 1016 | { |
| 1017 | theDI << "Fail: image can not be saved!\n"; |
| 1018 | } |
| 1019 | return 0; |
| 1020 | } |
| 1021 | |
| 1022 | //============================================================================== |
| 1023 | //function : Displays,Erase... |
| 1024 | //purpose : |
| 1025 | //Draw arg : |
| 1026 | //============================================================================== |
| 1027 | static int VwrTst_DispErase(const Handle(AIS_InteractiveObject)& IO, |
| 1028 | const Standard_Integer Mode, |
| 1029 | const Standard_Integer TypeOfOperation, |
| 1030 | const Standard_Boolean Upd) |
| 1031 | { |
| 1032 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
| 1033 | |
| 1034 | switch(TypeOfOperation){ |
| 1035 | case 1: |
| 1036 | Ctx->Display(IO,Mode,Upd); |
| 1037 | break; |
| 1038 | case 2:{ |
| 1039 | Ctx->Erase(IO,Upd); |
| 1040 | break; |
| 1041 | } |
| 1042 | case 3:{ |
| 1043 | if(IO.IsNull()) |
| 1044 | Ctx->SetDisplayMode((AIS_DisplayMode)Mode,Upd); |
| 1045 | else |
| 1046 | Ctx->SetDisplayMode(IO,Mode,Upd); |
| 1047 | break; |
| 1048 | } |
| 1049 | case 4:{ |
| 1050 | if(IO.IsNull()) |
| 1051 | Ctx->SetDisplayMode(0,Upd); |
| 1052 | else |
| 1053 | Ctx->UnsetDisplayMode(IO,Upd); |
| 1054 | break; |
| 1055 | } |
| 1056 | } |
| 1057 | return 0; |
| 1058 | } |
| 1059 | |
| 1060 | //======================================================================= |
| 1061 | //function : |
| 1062 | //purpose : |
| 1063 | //======================================================================= |
| 1064 | static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv) |
| 1065 | { |
| 1066 | |
| 1067 | TCollection_AsciiString name; |
| 1068 | if(argc>3) |
| 1069 | return 1; |
| 1070 | // display others presentations |
| 1071 | Standard_Integer TypeOfOperation = (strcasecmp(argv[0],"vdispmode")==0)? 1: |
| 1072 | (strcasecmp(argv[0],"verasemode")==0) ? 2 : |
| 1073 | (strcasecmp(argv[0],"vsetdispmode")==0) ? 3 : |
| 1074 | (strcasecmp(argv[0],"vunsetdispmode")==0) ? 4 : -1; |
| 1075 | |
| 1076 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
| 1077 | |
| 1078 | //unset displaymode.. comportement particulier... |
| 1079 | if(TypeOfOperation==4){ |
| 1080 | if(argc==1){ |
| 1081 | if(Ctx->NbCurrents()==0 || |
| 1082 | Ctx->NbSelected()==0){ |
| 1083 | Handle(AIS_InteractiveObject) IO; |
| 1084 | VwrTst_DispErase(IO,-1,4,Standard_False); |
| 1085 | } |
| 1086 | else if(!Ctx->HasOpenedContext()){ |
| 1087 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) |
| 1088 | VwrTst_DispErase(Ctx->Current(),-1,4,Standard_False); |
| 1089 | } |
| 1090 | else{ |
| 1091 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) |
| 1092 | VwrTst_DispErase(Ctx->Interactive(),-1,4,Standard_False);} |
| 1093 | Ctx->UpdateCurrentViewer(); |
| 1094 | } |
| 1095 | else{ |
| 1096 | Handle(AIS_InteractiveObject) IO; |
| 1097 | name = argv[1]; |
| 1098 | if(GetMapOfAIS().IsBound2(name)){ |
| 1099 | IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
| 1100 | if (!IO.IsNull()) |
| 1101 | VwrTst_DispErase(IO,-1,4,Standard_True); |
| 1102 | } |
| 1103 | } |
| 1104 | } |
| 1105 | else if(argc==2){ |
| 1106 | Standard_Integer Dmode = Draw::Atoi(argv[1]); |
| 1107 | if(Ctx->NbCurrents()==0 && TypeOfOperation==3){ |
| 1108 | Handle(AIS_InteractiveObject) IO; |
| 1109 | VwrTst_DispErase(IO,Dmode,TypeOfOperation,Standard_True); |
| 1110 | } |
| 1111 | if(!Ctx->HasOpenedContext()){ |
| 1112 | // set/unset display mode sur le Contexte... |
| 1113 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){ |
| 1114 | VwrTst_DispErase(Ctx->Current(),Dmode,TypeOfOperation,Standard_False); |
| 1115 | } |
| 1116 | Ctx->UpdateCurrentViewer(); |
| 1117 | } |
| 1118 | else{ |
| 1119 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) |
| 1120 | Ctx->Display(Ctx->Interactive(),Dmode); |
| 1121 | } |
| 1122 | } |
| 1123 | else{ |
| 1124 | Handle(AIS_InteractiveObject) IO; |
| 1125 | name = argv[1]; |
| 1126 | if(GetMapOfAIS().IsBound2(name)) |
| 1127 | IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
| 1128 | if (!IO.IsNull()) |
| 1129 | VwrTst_DispErase(IO,Draw::Atoi(argv[2]),TypeOfOperation,Standard_True); |
| 1130 | } |
| 1131 | return 0; |
| 1132 | } |
| 1133 | |
| 1134 | |
| 1135 | //======================================================================= |
| 1136 | //function : |
| 1137 | //purpose : |
| 1138 | //======================================================================= |
| 1139 | static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
| 1140 | { |
| 1141 | if(argc==1) return 1; |
| 1142 | Standard_Integer On = Draw::Atoi(argv[1]); |
| 1143 | const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext(); |
| 1144 | |
| 1145 | if(argc==2){ |
| 1146 | |
| 1147 | if(!Ctx->HasOpenedContext()){ |
| 1148 | di<<"sub intensite "; |
| 1149 | if(On==1) di<<"On"; |
| 1150 | else di<<"Off"; |
| 1151 | di<<" pour "<<Ctx->NbCurrents()<<" objets"<<"\n"; |
| 1152 | for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){ |
| 1153 | if(On==1){ |
| 1154 | Ctx->SubIntensityOn(Ctx->Current(),Standard_False);} |
| 1155 | else{ |
| 1156 | di <<"passage dans off"<<"\n"; |
| 1157 | Ctx->SubIntensityOff(Ctx->Current(),Standard_False); |
| 1158 | } |
| 1159 | } |
| 1160 | } |
| 1161 | else{ |
| 1162 | for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){ |
| 1163 | if(On==1){ |
| 1164 | Ctx->SubIntensityOn(Ctx->Interactive(),Standard_False);} |
| 1165 | else{ |
| 1166 | Ctx->SubIntensityOff(Ctx->Interactive(),Standard_False);} |
| 1167 | } |
| 1168 | } |
| 1169 | Ctx->UpdateCurrentViewer(); |
| 1170 | } |
| 1171 | else { |
| 1172 | Handle(AIS_InteractiveObject) IO; |
| 1173 | TCollection_AsciiString name = argv[2]; |
| 1174 | if(GetMapOfAIS().IsBound2(name)){ |
| 1175 | IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
| 1176 | if (!IO.IsNull()) { |
| 1177 | if(On==1) |
| 1178 | Ctx->SubIntensityOn(IO); |
| 1179 | else |
| 1180 | Ctx->SubIntensityOff(IO); |
| 1181 | } |
| 1182 | } |
| 1183 | else return 1; |
| 1184 | } |
| 1185 | return 0; |
| 1186 | } |
| 1187 | |
| 1188 | //! Auxiliary class to iterate presentations from different collections. |
| 1189 | class ViewTest_PrsIter |
| 1190 | { |
| 1191 | public: |
| 1192 | |
| 1193 | //! Create and initialize iterator object. |
| 1194 | ViewTest_PrsIter (const TCollection_AsciiString& theName) |
| 1195 | : mySource (IterSource_All) |
| 1196 | { |
| 1197 | NCollection_Sequence<TCollection_AsciiString> aNames; |
| 1198 | if (!theName.IsEmpty()) |
| 1199 | aNames.Append (theName); |
| 1200 | Init (aNames); |
| 1201 | } |
| 1202 | |
| 1203 | //! Create and initialize iterator object. |
| 1204 | ViewTest_PrsIter (const NCollection_Sequence<TCollection_AsciiString>& theNames) |
| 1205 | : mySource (IterSource_All) |
| 1206 | { |
| 1207 | Init (theNames); |
| 1208 | } |
| 1209 | |
| 1210 | //! Initialize the iterator. |
| 1211 | void Init (const NCollection_Sequence<TCollection_AsciiString>& theNames) |
| 1212 | { |
| 1213 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
| 1214 | mySeq = theNames; |
| 1215 | mySelIter.Nullify(); |
| 1216 | myCurrent.Nullify(); |
| 1217 | myCurrentTrs.Nullify(); |
| 1218 | if (!mySeq.IsEmpty()) |
| 1219 | { |
| 1220 | mySource = IterSource_List; |
| 1221 | mySeqIter = NCollection_Sequence<TCollection_AsciiString>::Iterator (mySeq); |
| 1222 | } |
| 1223 | else if (aCtx->NbCurrents() > 0) |
| 1224 | { |
| 1225 | mySource = IterSource_Selected; |
| 1226 | mySelIter = aCtx; |
| 1227 | mySelIter->InitCurrent(); |
| 1228 | } |
| 1229 | else |
| 1230 | { |
| 1231 | mySource = IterSource_All; |
| 1232 | myMapIter.Initialize (GetMapOfAIS()); |
| 1233 | } |
| 1234 | initCurrent(); |
| 1235 | } |
| 1236 | |
| 1237 | const TCollection_AsciiString& CurrentName() const |
| 1238 | { |
| 1239 | return myCurrentName; |
| 1240 | } |
| 1241 | |
| 1242 | const Handle(AIS_InteractiveObject)& Current() const |
| 1243 | { |
| 1244 | return myCurrent; |
| 1245 | } |
| 1246 | |
| 1247 | const Handle(Standard_Transient)& CurrentTrs() const |
| 1248 | { |
| 1249 | return myCurrentTrs; |
| 1250 | } |
| 1251 | |
| 1252 | //! @return true if iterator points to valid object within collection |
| 1253 | Standard_Boolean More() const |
| 1254 | { |
| 1255 | switch (mySource) |
| 1256 | { |
| 1257 | case IterSource_All: return myMapIter.More(); |
| 1258 | case IterSource_List: return mySeqIter.More(); |
| 1259 | case IterSource_Selected: return mySelIter->MoreCurrent(); |
| 1260 | } |
| 1261 | return Standard_False; |
| 1262 | } |
| 1263 | |
| 1264 | //! Go to the next item. |
| 1265 | void Next() |
| 1266 | { |
| 1267 | myCurrentName.Clear(); |
| 1268 | myCurrentTrs.Nullify(); |
| 1269 | myCurrent.Nullify(); |
| 1270 | switch (mySource) |
| 1271 | { |
| 1272 | case IterSource_All: |
| 1273 | { |
| 1274 | myMapIter.Next(); |
| 1275 | break; |
| 1276 | } |
| 1277 | case IterSource_List: |
| 1278 | { |
| 1279 | mySeqIter.Next(); |
| 1280 | break; |
| 1281 | } |
| 1282 | case IterSource_Selected: |
| 1283 | { |
| 1284 | mySelIter->NextCurrent(); |
| 1285 | break; |
| 1286 | } |
| 1287 | } |
| 1288 | initCurrent(); |
| 1289 | } |
| 1290 | |
| 1291 | private: |
| 1292 | |
| 1293 | void initCurrent() |
| 1294 | { |
| 1295 | switch (mySource) |
| 1296 | { |
| 1297 | case IterSource_All: |
| 1298 | { |
| 1299 | if (myMapIter.More()) |
| 1300 | { |
| 1301 | myCurrentName = myMapIter.Key2(); |
| 1302 | myCurrentTrs = myMapIter.Key1(); |
| 1303 | myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs); |
| 1304 | } |
| 1305 | break; |
| 1306 | } |
| 1307 | case IterSource_List: |
| 1308 | { |
| 1309 | if (mySeqIter.More()) |
| 1310 | { |
| 1311 | if (!GetMapOfAIS().IsBound2 (mySeqIter.Value())) |
| 1312 | { |
| 1313 | std::cout << "Error: object " << mySeqIter.Value() << " is not displayed!\n"; |
| 1314 | return; |
| 1315 | } |
| 1316 | myCurrentName = mySeqIter.Value(); |
| 1317 | myCurrentTrs = GetMapOfAIS().Find2 (mySeqIter.Value()); |
| 1318 | myCurrent = Handle(AIS_InteractiveObject)::DownCast (myCurrentTrs); |
| 1319 | } |
| 1320 | break; |
| 1321 | } |
| 1322 | case IterSource_Selected: |
| 1323 | { |
| 1324 | if (mySelIter->MoreCurrent()) |
| 1325 | { |
| 1326 | myCurrentName = GetMapOfAIS().Find1 (mySelIter->Current()); |
| 1327 | myCurrent = mySelIter->Current(); |
| 1328 | } |
| 1329 | break; |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | private: |
| 1335 | |
| 1336 | enum IterSource |
| 1337 | { |
| 1338 | IterSource_All, |
| 1339 | IterSource_List, |
| 1340 | IterSource_Selected |
| 1341 | }; |
| 1342 | |
| 1343 | private: |
| 1344 | |
| 1345 | Handle(AIS_InteractiveContext) mySelIter; //!< iterator for current (selected) objects (IterSource_Selected) |
| 1346 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName myMapIter; //!< iterator for map of all objects (IterSource_All) |
| 1347 | NCollection_Sequence<TCollection_AsciiString> mySeq; |
| 1348 | NCollection_Sequence<TCollection_AsciiString>::Iterator mySeqIter; |
| 1349 | |
| 1350 | TCollection_AsciiString myCurrentName;//!< current item name |
| 1351 | Handle(Standard_Transient) myCurrentTrs; //!< current item (as transient object) |
| 1352 | Handle(AIS_InteractiveObject) myCurrent; //!< current item |
| 1353 | |
| 1354 | IterSource mySource; //!< iterated collection |
| 1355 | |
| 1356 | }; |
| 1357 | |
| 1358 | //============================================================================== |
| 1359 | //function : VInteriorStyle |
| 1360 | //purpose : sets interior style of the a selected or named or displayed shape |
| 1361 | //============================================================================== |
| 1362 | static int VSetInteriorStyle (Draw_Interpretor& theDI, |
| 1363 | Standard_Integer theArgNb, |
| 1364 | const char** theArgVec) |
| 1365 | { |
| 1366 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
| 1367 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 1368 | if (aCtx.IsNull()) |
| 1369 | { |
| 1370 | std::cerr << "Error: no active view!\n"; |
| 1371 | return 1; |
| 1372 | } |
| 1373 | |
| 1374 | Standard_Integer anArgIter = 1; |
| 1375 | for (; anArgIter < theArgNb; ++anArgIter) |
| 1376 | { |
| 1377 | if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter])) |
| 1378 | { |
| 1379 | break; |
| 1380 | } |
| 1381 | } |
| 1382 | TCollection_AsciiString aName; |
| 1383 | if (theArgNb - anArgIter == 2) |
| 1384 | { |
| 1385 | aName = theArgVec[anArgIter++]; |
| 1386 | } |
| 1387 | else if (theArgNb - anArgIter != 1) |
| 1388 | { |
| 1389 | std::cout << "Error: wrong number of arguments! See usage:\n"; |
| 1390 | theDI.PrintHelp (theArgVec[0]); |
| 1391 | return 1; |
| 1392 | } |
| 1393 | Standard_Integer anInterStyle = Aspect_IS_SOLID; |
| 1394 | TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]); |
| 1395 | aStyleArg.LowerCase(); |
| 1396 | if (aStyleArg == "empty") |
| 1397 | { |
| 1398 | anInterStyle = 0; |
| 1399 | } |
| 1400 | else if (aStyleArg == "hollow") |
| 1401 | { |
| 1402 | anInterStyle = 1; |
| 1403 | } |
| 1404 | else if (aStyleArg == "hatch") |
| 1405 | { |
| 1406 | anInterStyle = 2; |
| 1407 | } |
| 1408 | else if (aStyleArg == "solid") |
| 1409 | { |
| 1410 | anInterStyle = 3; |
| 1411 | } |
| 1412 | else if (aStyleArg == "hiddenline") |
| 1413 | { |
| 1414 | anInterStyle = 4; |
| 1415 | } |
| 1416 | else |
| 1417 | { |
| 1418 | anInterStyle = aStyleArg.IntegerValue(); |
| 1419 | } |
| 1420 | if (anInterStyle < Aspect_IS_EMPTY |
| 1421 | || anInterStyle > Aspect_IS_HIDDENLINE) |
| 1422 | { |
| 1423 | std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), " |
| 1424 | << Aspect_IS_HIDDENLINE << " (Aspect_IS_HIDDENLINE)]\n"; |
| 1425 | return 1; |
| 1426 | } |
| 1427 | |
| 1428 | if (!aName.IsEmpty() |
| 1429 | && !GetMapOfAIS().IsBound2 (aName)) |
| 1430 | { |
| 1431 | std::cout << "Error: object " << aName << " is not displayed!\n"; |
| 1432 | return 1; |
| 1433 | } |
| 1434 | |
| 1435 | if (aCtx->HasOpenedContext()) |
| 1436 | { |
| 1437 | aCtx->CloseLocalContext(); |
| 1438 | } |
| 1439 | for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next()) |
| 1440 | { |
| 1441 | const Handle(AIS_InteractiveObject)& anIO = anIter.Current(); |
| 1442 | if (!anIO.IsNull()) |
| 1443 | { |
| 1444 | const Handle(Prs3d_Drawer)& aDrawer = anIO->Attributes(); |
| 1445 | Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect(); |
| 1446 | Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect(); |
| 1447 | aFillAspect->SetInteriorStyle ((Aspect_InteriorStyle )anInterStyle); |
| 1448 | aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True); |
| 1449 | } |
| 1450 | } |
| 1451 | return 0; |
| 1452 | } |
| 1453 | |
| 1454 | //! Auxiliary structure for VAspects |
| 1455 | struct ViewerTest_AspectsChangeSet |
| 1456 | { |
| 1457 | Standard_Integer ToSetVisibility; |
| 1458 | Standard_Integer Visibility; |
| 1459 | |
| 1460 | Standard_Integer ToSetColor; |
| 1461 | Quantity_Color Color; |
| 1462 | |
| 1463 | Standard_Integer ToSetLineWidth; |
| 1464 | Standard_Real LineWidth; |
| 1465 | |
| 1466 | Standard_Integer ToSetTypeOfLine; |
| 1467 | Aspect_TypeOfLine TypeOfLine; |
| 1468 | |
| 1469 | Standard_Integer ToSetTransparency; |
| 1470 | Standard_Real Transparency; |
| 1471 | |
| 1472 | Standard_Integer ToSetMaterial; |
| 1473 | Graphic3d_NameOfMaterial Material; |
| 1474 | TCollection_AsciiString MatName; |
| 1475 | |
| 1476 | NCollection_Sequence<TopoDS_Shape> SubShapes; |
| 1477 | |
| 1478 | Standard_Integer ToSetShowFreeBoundary; |
| 1479 | Standard_Integer ToSetFreeBoundaryWidth; |
| 1480 | Standard_Real FreeBoundaryWidth; |
| 1481 | Standard_Integer ToSetFreeBoundaryColor; |
| 1482 | Quantity_Color FreeBoundaryColor; |
| 1483 | |
| 1484 | //! Empty constructor |
| 1485 | ViewerTest_AspectsChangeSet() |
| 1486 | : ToSetVisibility (0), |
| 1487 | Visibility (1), |
| 1488 | ToSetColor (0), |
| 1489 | Color (DEFAULT_COLOR), |
| 1490 | ToSetLineWidth (0), |
| 1491 | LineWidth (1.0), |
| 1492 | ToSetTypeOfLine (0), |
| 1493 | TypeOfLine (Aspect_TOL_SOLID), |
| 1494 | ToSetTransparency (0), |
| 1495 | Transparency (0.0), |
| 1496 | ToSetMaterial (0), |
| 1497 | Material (Graphic3d_NOM_DEFAULT), |
| 1498 | ToSetShowFreeBoundary (0), |
| 1499 | ToSetFreeBoundaryWidth (0), |
| 1500 | FreeBoundaryWidth (1.0), |
| 1501 | ToSetFreeBoundaryColor (0), |
| 1502 | FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR) {} |
| 1503 | |
| 1504 | //! @return true if no changes have been requested |
| 1505 | Standard_Boolean IsEmpty() const |
| 1506 | { |
| 1507 | return ToSetVisibility == 0 |
| 1508 | && ToSetLineWidth == 0 |
| 1509 | && ToSetTransparency == 0 |
| 1510 | && ToSetColor == 0 |
| 1511 | && ToSetMaterial == 0 |
| 1512 | && ToSetShowFreeBoundary == 0 |
| 1513 | && ToSetFreeBoundaryColor == 0 |
| 1514 | && ToSetFreeBoundaryWidth == 0; |
| 1515 | } |
| 1516 | |
| 1517 | //! @return true if properties are valid |
| 1518 | Standard_Boolean Validate (const Standard_Boolean theIsSubPart) const |
| 1519 | { |
| 1520 | Standard_Boolean isOk = Standard_True; |
| 1521 | if (Visibility != 0 && Visibility != 1) |
| 1522 | { |
| 1523 | std::cout << "Error: the visibility should be equal to 0 or 1 (0 - invisible; 1 - visible) (specified " << Visibility << ")\n"; |
| 1524 | isOk = Standard_False; |
| 1525 | } |
| 1526 | if (LineWidth <= 0.0 |
| 1527 | || LineWidth > 10.0) |
| 1528 | { |
| 1529 | std::cout << "Error: the width should be within [1; 10] range (specified " << LineWidth << ")\n"; |
| 1530 | isOk = Standard_False; |
| 1531 | } |
| 1532 | if (Transparency < 0.0 |
| 1533 | || Transparency > 1.0) |
| 1534 | { |
| 1535 | std::cout << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")\n"; |
| 1536 | isOk = Standard_False; |
| 1537 | } |
| 1538 | if (theIsSubPart |
| 1539 | && ToSetTransparency) |
| 1540 | { |
| 1541 | std::cout << "Error: the transparency can not be defined for sub-part of object!\n"; |
| 1542 | isOk = Standard_False; |
| 1543 | } |
| 1544 | if (ToSetMaterial == 1 |
| 1545 | && Material == Graphic3d_NOM_DEFAULT) |
| 1546 | { |
| 1547 | std::cout << "Error: unknown material " << MatName << ".\n"; |
| 1548 | isOk = Standard_False; |
| 1549 | } |
| 1550 | if (FreeBoundaryWidth <= 0.0 |
| 1551 | || FreeBoundaryWidth > 10.0) |
| 1552 | { |
| 1553 | std::cout << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")\n"; |
| 1554 | isOk = Standard_False; |
| 1555 | } |
| 1556 | return isOk; |
| 1557 | } |
| 1558 | |
| 1559 | }; |
| 1560 | |
| 1561 | //============================================================================== |
| 1562 | //function : VAspects |
| 1563 | //purpose : |
| 1564 | //============================================================================== |
| 1565 | static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, |
| 1566 | Standard_Integer theArgNb, |
| 1567 | const char** theArgVec) |
| 1568 | { |
| 1569 | TCollection_AsciiString aCmdName (theArgVec[0]); |
| 1570 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
| 1571 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 1572 | if (aCtx.IsNull()) |
| 1573 | { |
| 1574 | std::cerr << "Error: no active view!\n"; |
| 1575 | return 1; |
| 1576 | } |
| 1577 | |
| 1578 | Standard_Integer anArgIter = 1; |
| 1579 | Standard_Boolean isDefaults = Standard_False; |
| 1580 | NCollection_Sequence<TCollection_AsciiString> aNames; |
| 1581 | for (; anArgIter < theArgNb; ++anArgIter) |
| 1582 | { |
| 1583 | TCollection_AsciiString anArg = theArgVec[anArgIter]; |
| 1584 | if (anUpdateTool.parseRedrawMode (anArg)) |
| 1585 | { |
| 1586 | continue; |
| 1587 | } |
| 1588 | else if (!anArg.IsEmpty() |
| 1589 | && anArg.Value (1) != '-') |
| 1590 | { |
| 1591 | aNames.Append (anArg); |
| 1592 | } |
| 1593 | else |
| 1594 | { |
| 1595 | if (anArg == "-defaults") |
| 1596 | { |
| 1597 | isDefaults = Standard_True; |
| 1598 | ++anArgIter; |
| 1599 | } |
| 1600 | break; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | if (!aNames.IsEmpty() && isDefaults) |
| 1605 | { |
| 1606 | std::cout << "Error: wrong syntax. If -defaults is used there should not be any objects' names!\n"; |
| 1607 | return 1; |
| 1608 | } |
| 1609 | |
| 1610 | NCollection_Sequence<ViewerTest_AspectsChangeSet> aChanges; |
| 1611 | aChanges.Append (ViewerTest_AspectsChangeSet()); |
| 1612 | ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast(); |
| 1613 | |
| 1614 | // parse syntax of legacy commands |
| 1615 | if (aCmdName == "vsetwidth") |
| 1616 | { |
| 1617 | if (aNames.IsEmpty() |
| 1618 | || !aNames.Last().IsRealValue()) |
| 1619 | { |
| 1620 | std::cout << "Error: not enough arguments!\n"; |
| 1621 | return 1; |
| 1622 | } |
| 1623 | aChangeSet->ToSetLineWidth = 1; |
| 1624 | aChangeSet->LineWidth = aNames.Last().RealValue(); |
| 1625 | aNames.Remove (aNames.Length()); |
| 1626 | } |
| 1627 | else if (aCmdName == "vunsetwidth") |
| 1628 | { |
| 1629 | aChangeSet->ToSetLineWidth = -1; |
| 1630 | } |
| 1631 | else if (aCmdName == "vsetcolor") |
| 1632 | { |
| 1633 | if (aNames.IsEmpty()) |
| 1634 | { |
| 1635 | std::cout << "Error: not enough arguments!\n"; |
| 1636 | return 1; |
| 1637 | } |
| 1638 | aChangeSet->ToSetColor = 1; |
| 1639 | |
| 1640 | Quantity_NameOfColor aColor = Quantity_NOC_BLACK; |
| 1641 | Standard_Boolean isOk = Standard_False; |
| 1642 | if (Quantity_Color::ColorFromName (aNames.Last().ToCString(), aColor)) |
| 1643 | { |
| 1644 | aChangeSet->Color = aColor; |
| 1645 | aNames.Remove (aNames.Length()); |
| 1646 | isOk = Standard_True; |
| 1647 | } |
| 1648 | else if (aNames.Length() >= 3) |
| 1649 | { |
| 1650 | const TCollection_AsciiString anRgbStr[3] = |
| 1651 | { |
| 1652 | aNames.Value (aNames.Upper() - 2), |
| 1653 | aNames.Value (aNames.Upper() - 1), |
| 1654 | aNames.Value (aNames.Upper() - 0) |
| 1655 | }; |
| 1656 | isOk = anRgbStr[0].IsRealValue() |
| 1657 | && anRgbStr[1].IsRealValue() |
| 1658 | && anRgbStr[2].IsRealValue(); |
| 1659 | if (isOk) |
| 1660 | { |
| 1661 | Graphic3d_Vec4d anRgb; |
| 1662 | anRgb.x() = anRgbStr[0].RealValue(); |
| 1663 | anRgb.y() = anRgbStr[1].RealValue(); |
| 1664 | anRgb.z() = anRgbStr[2].RealValue(); |
| 1665 | if (anRgb.x() < 0.0 || anRgb.x() > 1.0 |
| 1666 | || anRgb.y() < 0.0 || anRgb.y() > 1.0 |
| 1667 | || anRgb.z() < 0.0 || anRgb.z() > 1.0) |
| 1668 | { |
| 1669 | std::cout << "Error: RGB color values should be within range 0..1!\n"; |
| 1670 | return 1; |
| 1671 | } |
| 1672 | aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB); |
| 1673 | aNames.Remove (aNames.Length()); |
| 1674 | aNames.Remove (aNames.Length()); |
| 1675 | aNames.Remove (aNames.Length()); |
| 1676 | } |
| 1677 | } |
| 1678 | if (!isOk) |
| 1679 | { |
| 1680 | std::cout << "Error: not enough arguments!\n"; |
| 1681 | return 1; |
| 1682 | } |
| 1683 | } |
| 1684 | else if (aCmdName == "vunsetcolor") |
| 1685 | { |
| 1686 | aChangeSet->ToSetColor = -1; |
| 1687 | } |
| 1688 | else if (aCmdName == "vsettransparency") |
| 1689 | { |
| 1690 | if (aNames.IsEmpty() |
| 1691 | || !aNames.Last().IsRealValue()) |
| 1692 | { |
| 1693 | std::cout << "Error: not enough arguments!\n"; |
| 1694 | return 1; |
| 1695 | } |
| 1696 | aChangeSet->ToSetTransparency = 1; |
| 1697 | aChangeSet->Transparency = aNames.Last().RealValue(); |
| 1698 | aNames.Remove (aNames.Length()); |
| 1699 | } |
| 1700 | else if (aCmdName == "vunsettransparency") |
| 1701 | { |
| 1702 | aChangeSet->ToSetTransparency = -1; |
| 1703 | } |
| 1704 | else if (aCmdName == "vsetmaterial") |
| 1705 | { |
| 1706 | if (aNames.IsEmpty()) |
| 1707 | { |
| 1708 | std::cout << "Error: not enough arguments!\n"; |
| 1709 | return 1; |
| 1710 | } |
| 1711 | aChangeSet->ToSetMaterial = 1; |
| 1712 | aChangeSet->MatName = aNames.Last(); |
| 1713 | aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString()); |
| 1714 | aNames.Remove (aNames.Length()); |
| 1715 | } |
| 1716 | else if (aCmdName == "vunsetmaterial") |
| 1717 | { |
| 1718 | aChangeSet->ToSetMaterial = -1; |
| 1719 | } |
| 1720 | else if (anArgIter >= theArgNb) |
| 1721 | { |
| 1722 | std::cout << "Error: not enough arguments!\n"; |
| 1723 | return 1; |
| 1724 | } |
| 1725 | |
| 1726 | if (!aChangeSet->IsEmpty()) |
| 1727 | { |
| 1728 | anArgIter = theArgNb; |
| 1729 | } |
| 1730 | for (; anArgIter < theArgNb; ++anArgIter) |
| 1731 | { |
| 1732 | TCollection_AsciiString anArg = theArgVec[anArgIter]; |
| 1733 | anArg.LowerCase(); |
| 1734 | if (anArg == "-setwidth" |
| 1735 | || anArg == "-setlinewidth") |
| 1736 | { |
| 1737 | if (++anArgIter >= theArgNb) |
| 1738 | { |
| 1739 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1740 | return 1; |
| 1741 | } |
| 1742 | aChangeSet->ToSetLineWidth = 1; |
| 1743 | aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]); |
| 1744 | } |
| 1745 | else if (anArg == "-unsetwidth" |
| 1746 | || anArg == "-unsetlinewidth") |
| 1747 | { |
| 1748 | aChangeSet->ToSetLineWidth = -1; |
| 1749 | aChangeSet->LineWidth = 1.0; |
| 1750 | } |
| 1751 | else if (anArg == "-settransp" |
| 1752 | || anArg == "-settransparency") |
| 1753 | { |
| 1754 | if (++anArgIter >= theArgNb) |
| 1755 | { |
| 1756 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1757 | return 1; |
| 1758 | } |
| 1759 | aChangeSet->ToSetTransparency = 1; |
| 1760 | aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]); |
| 1761 | if (aChangeSet->Transparency >= 0.0 |
| 1762 | && aChangeSet->Transparency <= Precision::Confusion()) |
| 1763 | { |
| 1764 | aChangeSet->ToSetTransparency = -1; |
| 1765 | aChangeSet->Transparency = 0.0; |
| 1766 | } |
| 1767 | } |
| 1768 | else if (anArg == "-setvis" |
| 1769 | || anArg == "-setvisibility") |
| 1770 | { |
| 1771 | if (++anArgIter >= theArgNb) |
| 1772 | { |
| 1773 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1774 | return 1; |
| 1775 | } |
| 1776 | |
| 1777 | aChangeSet->ToSetVisibility = 1; |
| 1778 | aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]); |
| 1779 | } |
| 1780 | else if (anArg == "-setalpha") |
| 1781 | { |
| 1782 | if (++anArgIter >= theArgNb) |
| 1783 | { |
| 1784 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1785 | return 1; |
| 1786 | } |
| 1787 | aChangeSet->ToSetTransparency = 1; |
| 1788 | aChangeSet->Transparency = Draw::Atof (theArgVec[anArgIter]); |
| 1789 | if (aChangeSet->Transparency < 0.0 |
| 1790 | || aChangeSet->Transparency > 1.0) |
| 1791 | { |
| 1792 | std::cout << "Error: the transparency should be within [0; 1] range (specified " << aChangeSet->Transparency << ")\n"; |
| 1793 | return 1; |
| 1794 | } |
| 1795 | aChangeSet->Transparency = 1.0 - aChangeSet->Transparency; |
| 1796 | if (aChangeSet->Transparency >= 0.0 |
| 1797 | && aChangeSet->Transparency <= Precision::Confusion()) |
| 1798 | { |
| 1799 | aChangeSet->ToSetTransparency = -1; |
| 1800 | aChangeSet->Transparency = 0.0; |
| 1801 | } |
| 1802 | } |
| 1803 | else if (anArg == "-unsettransp" |
| 1804 | || anArg == "-unsettransparency" |
| 1805 | || anArg == "-unsetalpha" |
| 1806 | || anArg == "-opaque") |
| 1807 | { |
| 1808 | aChangeSet->ToSetTransparency = -1; |
| 1809 | aChangeSet->Transparency = 0.0; |
| 1810 | } |
| 1811 | else if (anArg == "-setcolor") |
| 1812 | { |
| 1813 | Standard_Integer aNbComps = 0; |
| 1814 | Standard_Integer aCompIter = anArgIter + 1; |
| 1815 | for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps) |
| 1816 | { |
| 1817 | if (theArgVec[aCompIter][0] == '-') |
| 1818 | { |
| 1819 | break; |
| 1820 | } |
| 1821 | } |
| 1822 | switch (aNbComps) |
| 1823 | { |
| 1824 | case 1: |
| 1825 | { |
| 1826 | Quantity_NameOfColor aColor = Quantity_NOC_BLACK; |
| 1827 | Standard_CString aName = theArgVec[anArgIter + 1]; |
| 1828 | if (!Quantity_Color::ColorFromName (aName, aColor)) |
| 1829 | { |
| 1830 | std::cout << "Error: unknown color name '" << aName << "'\n"; |
| 1831 | return 1; |
| 1832 | } |
| 1833 | aChangeSet->Color = aColor; |
| 1834 | break; |
| 1835 | } |
| 1836 | case 3: |
| 1837 | { |
| 1838 | Graphic3d_Vec3d anRgb; |
| 1839 | anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]); |
| 1840 | anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]); |
| 1841 | anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]); |
| 1842 | if (anRgb.x() < 0.0 || anRgb.x() > 1.0 |
| 1843 | || anRgb.y() < 0.0 || anRgb.y() > 1.0 |
| 1844 | || anRgb.z() < 0.0 || anRgb.z() > 1.0) |
| 1845 | { |
| 1846 | std::cout << "Error: RGB color values should be within range 0..1!\n"; |
| 1847 | return 1; |
| 1848 | } |
| 1849 | aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB); |
| 1850 | break; |
| 1851 | } |
| 1852 | default: |
| 1853 | { |
| 1854 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1855 | return 1; |
| 1856 | } |
| 1857 | } |
| 1858 | aChangeSet->ToSetColor = 1; |
| 1859 | anArgIter += aNbComps; |
| 1860 | } |
| 1861 | else if (anArg == "-setlinetype") |
| 1862 | { |
| 1863 | if (++anArgIter >= theArgNb) |
| 1864 | { |
| 1865 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1866 | return 1; |
| 1867 | } |
| 1868 | |
| 1869 | TCollection_AsciiString aValue (theArgVec[anArgIter]); |
| 1870 | aValue.LowerCase(); |
| 1871 | |
| 1872 | if (aValue.IsEqual ("solid")) |
| 1873 | { |
| 1874 | aChangeSet->TypeOfLine = Aspect_TOL_SOLID; |
| 1875 | } |
| 1876 | else if (aValue.IsEqual ("dot")) |
| 1877 | { |
| 1878 | aChangeSet->TypeOfLine = Aspect_TOL_DOT; |
| 1879 | } |
| 1880 | else if (aValue.IsEqual ("dash")) |
| 1881 | { |
| 1882 | aChangeSet->TypeOfLine = Aspect_TOL_DASH; |
| 1883 | } |
| 1884 | else if (aValue.IsEqual ("dotdash")) |
| 1885 | { |
| 1886 | aChangeSet->TypeOfLine = Aspect_TOL_DOTDASH; |
| 1887 | } |
| 1888 | else |
| 1889 | { |
| 1890 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1891 | return 1; |
| 1892 | } |
| 1893 | |
| 1894 | aChangeSet->ToSetTypeOfLine = 1; |
| 1895 | } |
| 1896 | else if (anArg == "-unsetlinetype") |
| 1897 | { |
| 1898 | aChangeSet->ToSetTypeOfLine = -1; |
| 1899 | } |
| 1900 | else if (anArg == "-unsetcolor") |
| 1901 | { |
| 1902 | aChangeSet->ToSetColor = -1; |
| 1903 | aChangeSet->Color = DEFAULT_COLOR; |
| 1904 | } |
| 1905 | else if (anArg == "-setmat" |
| 1906 | || anArg == "-setmaterial") |
| 1907 | { |
| 1908 | if (++anArgIter >= theArgNb) |
| 1909 | { |
| 1910 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1911 | return 1; |
| 1912 | } |
| 1913 | aChangeSet->ToSetMaterial = 1; |
| 1914 | aChangeSet->MatName = theArgVec[anArgIter]; |
| 1915 | aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString()); |
| 1916 | } |
| 1917 | else if (anArg == "-unsetmat" |
| 1918 | || anArg == "-unsetmaterial") |
| 1919 | { |
| 1920 | aChangeSet->ToSetMaterial = -1; |
| 1921 | aChangeSet->Material = Graphic3d_NOM_DEFAULT; |
| 1922 | } |
| 1923 | else if (anArg == "-subshape" |
| 1924 | || anArg == "-subshapes") |
| 1925 | { |
| 1926 | if (isDefaults) |
| 1927 | { |
| 1928 | std::cout << "Error: wrong syntax. -subshapes can not be used together with -defaults call!\n"; |
| 1929 | return 1; |
| 1930 | } |
| 1931 | |
| 1932 | if (aNames.IsEmpty()) |
| 1933 | { |
| 1934 | std::cout << "Error: main objects should specified explicitly when -subshapes is used!\n"; |
| 1935 | return 1; |
| 1936 | } |
| 1937 | |
| 1938 | aChanges.Append (ViewerTest_AspectsChangeSet()); |
| 1939 | aChangeSet = &aChanges.ChangeLast(); |
| 1940 | |
| 1941 | for (++anArgIter; anArgIter < theArgNb; ++anArgIter) |
| 1942 | { |
| 1943 | Standard_CString aSubShapeName = theArgVec[anArgIter]; |
| 1944 | if (*aSubShapeName == '-') |
| 1945 | { |
| 1946 | --anArgIter; |
| 1947 | break; |
| 1948 | } |
| 1949 | |
| 1950 | TopoDS_Shape aSubShape = DBRep::Get (aSubShapeName); |
| 1951 | if (aSubShape.IsNull()) |
| 1952 | { |
| 1953 | std::cerr << "Error: shape " << aSubShapeName << " doesn't found!\n"; |
| 1954 | return 1; |
| 1955 | } |
| 1956 | aChangeSet->SubShapes.Append (aSubShape); |
| 1957 | } |
| 1958 | |
| 1959 | if (aChangeSet->SubShapes.IsEmpty()) |
| 1960 | { |
| 1961 | std::cerr << "Error: empty list is specified after -subshapes!\n"; |
| 1962 | return 1; |
| 1963 | } |
| 1964 | } |
| 1965 | else if (anArg == "-freeboundary" |
| 1966 | || anArg == "-fb") |
| 1967 | { |
| 1968 | if (++anArgIter >= theArgNb) |
| 1969 | { |
| 1970 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1971 | return 1; |
| 1972 | } |
| 1973 | TCollection_AsciiString aValue (theArgVec[anArgIter]); |
| 1974 | aValue.LowerCase(); |
| 1975 | if (aValue == "on" |
| 1976 | || aValue == "1") |
| 1977 | { |
| 1978 | aChangeSet->ToSetShowFreeBoundary = 1; |
| 1979 | } |
| 1980 | else if (aValue == "off" |
| 1981 | || aValue == "0") |
| 1982 | { |
| 1983 | aChangeSet->ToSetShowFreeBoundary = -1; |
| 1984 | } |
| 1985 | else |
| 1986 | { |
| 1987 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1988 | return 1; |
| 1989 | } |
| 1990 | } |
| 1991 | else if (anArg == "-setfreeboundarywidth" |
| 1992 | || anArg == "-setfbwidth") |
| 1993 | { |
| 1994 | if (++anArgIter >= theArgNb) |
| 1995 | { |
| 1996 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 1997 | return 1; |
| 1998 | } |
| 1999 | aChangeSet->ToSetFreeBoundaryWidth = 1; |
| 2000 | aChangeSet->FreeBoundaryWidth = Draw::Atof (theArgVec[anArgIter]); |
| 2001 | } |
| 2002 | else if (anArg == "-unsetfreeboundarywidth" |
| 2003 | || anArg == "-unsetfbwidth") |
| 2004 | { |
| 2005 | aChangeSet->ToSetFreeBoundaryWidth = -1; |
| 2006 | aChangeSet->FreeBoundaryWidth = 1.0; |
| 2007 | } |
| 2008 | else if (anArg == "-setfreeboundarycolor" |
| 2009 | || anArg == "-setfbcolor") |
| 2010 | { |
| 2011 | Standard_Integer aNbComps = 0; |
| 2012 | Standard_Integer aCompIter = anArgIter + 1; |
| 2013 | for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps) |
| 2014 | { |
| 2015 | if (theArgVec[aCompIter][0] == '-') |
| 2016 | { |
| 2017 | break; |
| 2018 | } |
| 2019 | } |
| 2020 | switch (aNbComps) |
| 2021 | { |
| 2022 | case 1: |
| 2023 | { |
| 2024 | Quantity_NameOfColor aColor = Quantity_NOC_BLACK; |
| 2025 | Standard_CString aName = theArgVec[anArgIter + 1]; |
| 2026 | if (!Quantity_Color::ColorFromName (aName, aColor)) |
| 2027 | { |
| 2028 | std::cout << "Error: unknown free boundary color name '" << aName << "'\n"; |
| 2029 | return 1; |
| 2030 | } |
| 2031 | aChangeSet->FreeBoundaryColor = aColor; |
| 2032 | break; |
| 2033 | } |
| 2034 | case 3: |
| 2035 | { |
| 2036 | Graphic3d_Vec3d anRgb; |
| 2037 | anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]); |
| 2038 | anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]); |
| 2039 | anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]); |
| 2040 | if (anRgb.x() < 0.0 || anRgb.x() > 1.0 |
| 2041 | || anRgb.y() < 0.0 || anRgb.y() > 1.0 |
| 2042 | || anRgb.z() < 0.0 || anRgb.z() > 1.0) |
| 2043 | { |
| 2044 | std::cout << "Error: free boundary RGB color values should be within range 0..1!\n"; |
| 2045 | return 1; |
| 2046 | } |
| 2047 | aChangeSet->FreeBoundaryColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB); |
| 2048 | break; |
| 2049 | } |
| 2050 | default: |
| 2051 | { |
| 2052 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 2053 | return 1; |
| 2054 | } |
| 2055 | } |
| 2056 | aChangeSet->ToSetFreeBoundaryColor = 1; |
| 2057 | anArgIter += aNbComps; |
| 2058 | } |
| 2059 | else if (anArg == "-unsetfreeboundarycolor" |
| 2060 | || anArg == "-unsetfbcolor") |
| 2061 | { |
| 2062 | aChangeSet->ToSetFreeBoundaryColor = -1; |
| 2063 | aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR; |
| 2064 | } |
| 2065 | else if (anArg == "-unset") |
| 2066 | { |
| 2067 | aChangeSet->ToSetVisibility = 1; |
| 2068 | aChangeSet->Visibility = 1; |
| 2069 | aChangeSet->ToSetLineWidth = -1; |
| 2070 | aChangeSet->LineWidth = 1.0; |
| 2071 | aChangeSet->ToSetTypeOfLine = -1; |
| 2072 | aChangeSet->TypeOfLine = Aspect_TOL_SOLID; |
| 2073 | aChangeSet->ToSetTransparency = -1; |
| 2074 | aChangeSet->Transparency = 0.0; |
| 2075 | aChangeSet->ToSetColor = -1; |
| 2076 | aChangeSet->Color = DEFAULT_COLOR; |
| 2077 | aChangeSet->ToSetMaterial = -1; |
| 2078 | aChangeSet->Material = Graphic3d_NOM_DEFAULT; |
| 2079 | aChangeSet->ToSetShowFreeBoundary = -1; |
| 2080 | aChangeSet->ToSetFreeBoundaryColor = -1; |
| 2081 | aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR; |
| 2082 | aChangeSet->ToSetFreeBoundaryWidth = -1; |
| 2083 | aChangeSet->FreeBoundaryWidth = 1.0; |
| 2084 | } |
| 2085 | else |
| 2086 | { |
| 2087 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 2088 | return 1; |
| 2089 | } |
| 2090 | } |
| 2091 | |
| 2092 | Standard_Boolean isFirst = Standard_True; |
| 2093 | for (NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges); |
| 2094 | aChangesIter.More(); aChangesIter.Next()) |
| 2095 | { |
| 2096 | if (!aChangesIter.Value().Validate (!isFirst)) |
| 2097 | { |
| 2098 | return 1; |
| 2099 | } |
| 2100 | isFirst = Standard_False; |
| 2101 | } |
| 2102 | |
| 2103 | if (aCtx->HasOpenedContext()) |
| 2104 | { |
| 2105 | aCtx->CloseLocalContext(); |
| 2106 | } |
| 2107 | |
| 2108 | // special case for -defaults parameter. |
| 2109 | // all changed values will be set to DefaultDrawer. |
| 2110 | if (isDefaults) |
| 2111 | { |
| 2112 | const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer(); |
| 2113 | |
| 2114 | if (aChangeSet->ToSetLineWidth != 0) |
| 2115 | { |
| 2116 | aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth); |
| 2117 | aDrawer->WireAspect()->SetWidth (aChangeSet->LineWidth); |
| 2118 | aDrawer->UnFreeBoundaryAspect()->SetWidth (aChangeSet->LineWidth); |
| 2119 | aDrawer->SeenLineAspect()->SetWidth (aChangeSet->LineWidth); |
| 2120 | } |
| 2121 | if (aChangeSet->ToSetColor != 0) |
| 2122 | { |
| 2123 | aDrawer->ShadingAspect()->SetColor (aChangeSet->Color); |
| 2124 | aDrawer->LineAspect()->SetColor (aChangeSet->Color); |
| 2125 | aDrawer->UnFreeBoundaryAspect()->SetColor (aChangeSet->Color); |
| 2126 | aDrawer->SeenLineAspect()->SetColor (aChangeSet->Color); |
| 2127 | aDrawer->WireAspect()->SetColor (aChangeSet->Color); |
| 2128 | aDrawer->PointAspect()->SetColor (aChangeSet->Color); |
| 2129 | } |
| 2130 | if (aChangeSet->ToSetTypeOfLine != 0) |
| 2131 | { |
| 2132 | aDrawer->LineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2133 | aDrawer->WireAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2134 | aDrawer->FreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2135 | aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2136 | aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2137 | } |
| 2138 | if (aChangeSet->ToSetTransparency != 0) |
| 2139 | { |
| 2140 | aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency); |
| 2141 | } |
| 2142 | if (aChangeSet->ToSetMaterial != 0) |
| 2143 | { |
| 2144 | aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material); |
| 2145 | } |
| 2146 | if (aChangeSet->ToSetShowFreeBoundary == 1) |
| 2147 | { |
| 2148 | aDrawer->SetFreeBoundaryDraw (Standard_True); |
| 2149 | } |
| 2150 | else if (aChangeSet->ToSetShowFreeBoundary == -1) |
| 2151 | { |
| 2152 | aDrawer->SetFreeBoundaryDraw (Standard_False); |
| 2153 | } |
| 2154 | if (aChangeSet->ToSetFreeBoundaryWidth != 0) |
| 2155 | { |
| 2156 | aDrawer->FreeBoundaryAspect()->SetWidth (aChangeSet->FreeBoundaryWidth); |
| 2157 | } |
| 2158 | if (aChangeSet->ToSetFreeBoundaryColor != 0) |
| 2159 | { |
| 2160 | aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor); |
| 2161 | } |
| 2162 | |
| 2163 | // redisplay all objects in context |
| 2164 | for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next()) |
| 2165 | { |
| 2166 | Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current(); |
| 2167 | if (!aPrs.IsNull()) |
| 2168 | { |
| 2169 | aCtx->Redisplay (aPrs, Standard_False); |
| 2170 | } |
| 2171 | } |
| 2172 | return 0; |
| 2173 | } |
| 2174 | |
| 2175 | for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next()) |
| 2176 | { |
| 2177 | const TCollection_AsciiString& aName = aPrsIter.CurrentName(); |
| 2178 | Handle(AIS_InteractiveObject) aPrs = aPrsIter.Current(); |
| 2179 | Handle(Prs3d_Drawer) aDrawer = aPrs->Attributes(); |
| 2180 | Handle(AIS_ColoredShape) aColoredPrs; |
| 2181 | Standard_Boolean toDisplay = Standard_False; |
| 2182 | Standard_Boolean toRedisplay = Standard_False; |
| 2183 | if (aChanges.Length() > 1 || aChangeSet->ToSetVisibility == 1) |
| 2184 | { |
| 2185 | Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs); |
| 2186 | if (aShapePrs.IsNull()) |
| 2187 | { |
| 2188 | std::cout << "Error: an object " << aName << " is not an AIS_Shape presentation!\n"; |
| 2189 | return 1; |
| 2190 | } |
| 2191 | aColoredPrs = Handle(AIS_ColoredShape)::DownCast (aShapePrs); |
| 2192 | if (aColoredPrs.IsNull()) |
| 2193 | { |
| 2194 | aColoredPrs = new AIS_ColoredShape (aShapePrs); |
| 2195 | aCtx->Remove (aShapePrs, Standard_False); |
| 2196 | GetMapOfAIS().UnBind2 (aName); |
| 2197 | GetMapOfAIS().Bind (aColoredPrs, aName); |
| 2198 | toDisplay = Standard_True; |
| 2199 | aShapePrs = aColoredPrs; |
| 2200 | aPrs = aColoredPrs; |
| 2201 | } |
| 2202 | } |
| 2203 | |
| 2204 | if (!aPrs.IsNull()) |
| 2205 | { |
| 2206 | NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges); |
| 2207 | aChangeSet = &aChangesIter.ChangeValue(); |
| 2208 | if (aChangeSet->ToSetVisibility == 1) |
| 2209 | { |
| 2210 | Handle(AIS_ColoredDrawer) aColDrawer = aColoredPrs->CustomAspects (aColoredPrs->Shape()); |
| 2211 | aColDrawer->SetHidden (aChangeSet->Visibility == 0); |
| 2212 | } |
| 2213 | else if (aChangeSet->ToSetMaterial == 1) |
| 2214 | { |
| 2215 | aCtx->SetMaterial (aPrs, aChangeSet->Material, Standard_False); |
| 2216 | } |
| 2217 | else if (aChangeSet->ToSetMaterial == -1) |
| 2218 | { |
| 2219 | aCtx->UnsetMaterial (aPrs, Standard_False); |
| 2220 | } |
| 2221 | if (aChangeSet->ToSetColor == 1) |
| 2222 | { |
| 2223 | aCtx->SetColor (aPrs, aChangeSet->Color, Standard_False); |
| 2224 | } |
| 2225 | else if (aChangeSet->ToSetColor == -1) |
| 2226 | { |
| 2227 | aCtx->UnsetColor (aPrs, Standard_False); |
| 2228 | } |
| 2229 | if (aChangeSet->ToSetTransparency == 1) |
| 2230 | { |
| 2231 | aCtx->SetTransparency (aPrs, aChangeSet->Transparency, Standard_False); |
| 2232 | } |
| 2233 | else if (aChangeSet->ToSetTransparency == -1) |
| 2234 | { |
| 2235 | aCtx->UnsetTransparency (aPrs, Standard_False); |
| 2236 | } |
| 2237 | if (aChangeSet->ToSetLineWidth == 1) |
| 2238 | { |
| 2239 | aCtx->SetWidth (aPrs, aChangeSet->LineWidth, Standard_False); |
| 2240 | } |
| 2241 | else if (aChangeSet->ToSetLineWidth == -1) |
| 2242 | { |
| 2243 | aCtx->UnsetWidth (aPrs, Standard_False); |
| 2244 | } |
| 2245 | if (!aDrawer.IsNull()) |
| 2246 | { |
| 2247 | if (aChangeSet->ToSetShowFreeBoundary == 1) |
| 2248 | { |
| 2249 | aDrawer->SetFreeBoundaryDraw (Standard_True); |
| 2250 | toRedisplay = Standard_True; |
| 2251 | } |
| 2252 | else if (aChangeSet->ToSetShowFreeBoundary == -1) |
| 2253 | { |
| 2254 | aDrawer->SetFreeBoundaryDraw (Standard_False); |
| 2255 | toRedisplay = Standard_True; |
| 2256 | } |
| 2257 | if (aChangeSet->ToSetFreeBoundaryWidth != 0) |
| 2258 | { |
| 2259 | Handle(Prs3d_LineAspect) aBoundaryAspect = |
| 2260 | new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0); |
| 2261 | *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect(); |
| 2262 | aBoundaryAspect->SetWidth (aChangeSet->FreeBoundaryWidth); |
| 2263 | aDrawer->SetFreeBoundaryAspect (aBoundaryAspect); |
| 2264 | toRedisplay = Standard_True; |
| 2265 | } |
| 2266 | if (aChangeSet->ToSetFreeBoundaryColor != 0) |
| 2267 | { |
| 2268 | Handle(Prs3d_LineAspect) aBoundaryAspect = |
| 2269 | new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0); |
| 2270 | *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect(); |
| 2271 | aBoundaryAspect->SetColor (aChangeSet->FreeBoundaryColor); |
| 2272 | aDrawer->SetFreeBoundaryAspect (aBoundaryAspect); |
| 2273 | toRedisplay = Standard_True; |
| 2274 | } |
| 2275 | if (aChangeSet->ToSetTypeOfLine != 0) |
| 2276 | { |
| 2277 | aDrawer->LineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2278 | aDrawer->WireAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2279 | aDrawer->FreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2280 | aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2281 | aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine); |
| 2282 | toRedisplay = Standard_True; |
| 2283 | } |
| 2284 | } |
| 2285 | |
| 2286 | for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next()) |
| 2287 | { |
| 2288 | aChangeSet = &aChangesIter.ChangeValue(); |
| 2289 | for (NCollection_Sequence<TopoDS_Shape>::Iterator aSubShapeIter (aChangeSet->SubShapes); |
| 2290 | aSubShapeIter.More(); aSubShapeIter.Next()) |
| 2291 | { |
| 2292 | const TopoDS_Shape& aSubShape = aSubShapeIter.Value(); |
| 2293 | if (aChangeSet->ToSetVisibility == 1) |
| 2294 | { |
| 2295 | Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape); |
| 2296 | aCurColDrawer->SetHidden (aChangeSet->Visibility == 0); |
| 2297 | } |
| 2298 | if (aChangeSet->ToSetColor == 1) |
| 2299 | { |
| 2300 | aColoredPrs->SetCustomColor (aSubShape, aChangeSet->Color); |
| 2301 | } |
| 2302 | if (aChangeSet->ToSetLineWidth == 1) |
| 2303 | { |
| 2304 | aColoredPrs->SetCustomWidth (aSubShape, aChangeSet->LineWidth); |
| 2305 | } |
| 2306 | if (aChangeSet->ToSetColor == -1 |
| 2307 | || aChangeSet->ToSetLineWidth == -1) |
| 2308 | { |
| 2309 | aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True); |
| 2310 | } |
| 2311 | } |
| 2312 | } |
| 2313 | if (toDisplay) |
| 2314 | { |
| 2315 | aCtx->Display (aPrs, Standard_False); |
| 2316 | } |
| 2317 | if (toRedisplay) |
| 2318 | { |
| 2319 | aCtx->Redisplay (aPrs, Standard_False); |
| 2320 | } |
| 2321 | else if (!aColoredPrs.IsNull()) |
| 2322 | { |
| 2323 | aCtx->Redisplay (aColoredPrs, Standard_False); |
| 2324 | } |
| 2325 | } |
| 2326 | } |
| 2327 | return 0; |
| 2328 | } |
| 2329 | |
| 2330 | //============================================================================== |
| 2331 | //function : VDonly2 |
| 2332 | //author : ege |
| 2333 | //purpose : Display only a selected or named object |
| 2334 | // if there is no selected or named object s, nothing is done |
| 2335 | //============================================================================== |
| 2336 | static int VDonly2 (Draw_Interpretor& , |
| 2337 | Standard_Integer theArgNb, |
| 2338 | const char** theArgVec) |
| 2339 | { |
| 2340 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
| 2341 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 2342 | if (aCtx.IsNull()) |
| 2343 | { |
| 2344 | std::cerr << "Error: no active view!\n"; |
| 2345 | return 1; |
| 2346 | } |
| 2347 | |
| 2348 | if (aCtx->HasOpenedContext()) |
| 2349 | { |
| 2350 | aCtx->CloseLocalContext(); |
| 2351 | } |
| 2352 | |
| 2353 | Standard_Integer anArgIter = 1; |
| 2354 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2355 | { |
| 2356 | if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter])) |
| 2357 | { |
| 2358 | break; |
| 2359 | } |
| 2360 | } |
| 2361 | |
| 2362 | NCollection_Map<Handle(Standard_Transient)> aDispSet; |
| 2363 | if (anArgIter >= theArgNb) |
| 2364 | { |
| 2365 | // display only selected objects |
| 2366 | if (aCtx->NbCurrents() < 1) |
| 2367 | { |
| 2368 | return 0; |
| 2369 | } |
| 2370 | |
| 2371 | for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent()) |
| 2372 | { |
| 2373 | aDispSet.Add (aCtx->Current()); |
| 2374 | } |
| 2375 | } |
| 2376 | else |
| 2377 | { |
| 2378 | // display only specified objects |
| 2379 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2380 | { |
| 2381 | TCollection_AsciiString aName = theArgVec[anArgIter]; |
| 2382 | if (GetMapOfAIS().IsBound2 (aName)) |
| 2383 | { |
| 2384 | const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)); |
| 2385 | if (!aShape.IsNull()) |
| 2386 | { |
| 2387 | aCtx->Display (aShape, Standard_False); |
| 2388 | aDispSet.Add (aShape); |
| 2389 | } |
| 2390 | } |
| 2391 | } |
| 2392 | } |
| 2393 | |
| 2394 | // weed out other objects |
| 2395 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next()) |
| 2396 | { |
| 2397 | if (aDispSet.Contains (anIter.Key1())) |
| 2398 | { |
| 2399 | continue; |
| 2400 | } |
| 2401 | |
| 2402 | const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2403 | if (aShape.IsNull()) |
| 2404 | { |
| 2405 | aCtx->Erase (aShape, Standard_False); |
| 2406 | } |
| 2407 | } |
| 2408 | return 0; |
| 2409 | } |
| 2410 | |
| 2411 | //============================================================================== |
| 2412 | //function : VRemove |
| 2413 | //purpose : Removes selected or named objects. |
| 2414 | // If there is no selected or named objects, |
| 2415 | // all objects in the viewer can be removed with argument -all. |
| 2416 | // If -context is in arguments, the object is not deleted from the map of |
| 2417 | // objects (deleted only from the current context). |
| 2418 | //============================================================================== |
| 2419 | int VRemove (Draw_Interpretor& theDI, |
| 2420 | Standard_Integer theArgNb, |
| 2421 | const char** theArgVec) |
| 2422 | { |
| 2423 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
| 2424 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 2425 | if (aCtx.IsNull()) |
| 2426 | { |
| 2427 | std::cerr << "Error: no active view!\n"; |
| 2428 | return 1; |
| 2429 | } |
| 2430 | |
| 2431 | Standard_Boolean isContextOnly = Standard_False; |
| 2432 | Standard_Boolean toRemoveAll = Standard_False; |
| 2433 | Standard_Boolean toPrintInfo = Standard_True; |
| 2434 | Standard_Boolean toRemoveLocal = Standard_False; |
| 2435 | |
| 2436 | Standard_Integer anArgIter = 1; |
| 2437 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2438 | { |
| 2439 | TCollection_AsciiString anArg = theArgVec[anArgIter]; |
| 2440 | anArg.LowerCase(); |
| 2441 | if (anArg == "-context") |
| 2442 | { |
| 2443 | isContextOnly = Standard_True; |
| 2444 | } |
| 2445 | else if (anArg == "-all") |
| 2446 | { |
| 2447 | toRemoveAll = Standard_True; |
| 2448 | } |
| 2449 | else if (anArg == "-noinfo") |
| 2450 | { |
| 2451 | toPrintInfo = Standard_False; |
| 2452 | } |
| 2453 | else if (anArg == "-local") |
| 2454 | { |
| 2455 | toRemoveLocal = Standard_True; |
| 2456 | } |
| 2457 | else if (anUpdateTool.parseRedrawMode (anArg)) |
| 2458 | { |
| 2459 | continue; |
| 2460 | } |
| 2461 | else |
| 2462 | { |
| 2463 | break; |
| 2464 | } |
| 2465 | } |
| 2466 | if (toRemoveAll |
| 2467 | && anArgIter < theArgNb) |
| 2468 | { |
| 2469 | std::cerr << "Error: wrong syntax!\n"; |
| 2470 | return 1; |
| 2471 | } |
| 2472 | |
| 2473 | if (toRemoveLocal && !aCtx->HasOpenedContext()) |
| 2474 | { |
| 2475 | std::cerr << "Error: local selection context is not open.\n"; |
| 2476 | return 1; |
| 2477 | } |
| 2478 | else if (!toRemoveLocal && aCtx->HasOpenedContext()) |
| 2479 | { |
| 2480 | aCtx->CloseAllContexts (Standard_False); |
| 2481 | } |
| 2482 | |
| 2483 | NCollection_List<TCollection_AsciiString> anIONameList; |
| 2484 | if (toRemoveAll) |
| 2485 | { |
| 2486 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2487 | anIter.More(); anIter.Next()) |
| 2488 | { |
| 2489 | anIONameList.Append (anIter.Key2()); |
| 2490 | } |
| 2491 | } |
| 2492 | else if (anArgIter < theArgNb) // removed objects names are in argument list |
| 2493 | { |
| 2494 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2495 | { |
| 2496 | TCollection_AsciiString aName = theArgVec[anArgIter]; |
| 2497 | if (!GetMapOfAIS().IsBound2 (aName)) |
| 2498 | { |
| 2499 | theDI << aName.ToCString() << " was not bound to some object.\n"; |
| 2500 | continue; |
| 2501 | } |
| 2502 | |
| 2503 | const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)); |
| 2504 | if (anIO->GetContext() != aCtx) |
| 2505 | { |
| 2506 | theDI << aName.ToCString() << " was not displayed in current context.\n"; |
| 2507 | theDI << "Please activate view with this object displayed and try again.\n"; |
| 2508 | continue; |
| 2509 | } |
| 2510 | |
| 2511 | anIONameList.Append (aName); |
| 2512 | continue; |
| 2513 | } |
| 2514 | } |
| 2515 | else if (aCtx->NbCurrents() > 0) |
| 2516 | { |
| 2517 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2518 | anIter.More(); anIter.Next()) |
| 2519 | { |
| 2520 | const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2521 | if (!aCtx->IsCurrent (anIO)) |
| 2522 | { |
| 2523 | continue; |
| 2524 | } |
| 2525 | |
| 2526 | anIONameList.Append (anIter.Key2()); |
| 2527 | continue; |
| 2528 | } |
| 2529 | } |
| 2530 | |
| 2531 | // Unbind all removed objects from the map of displayed IO. |
| 2532 | for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList); |
| 2533 | anIter.More(); anIter.Next()) |
| 2534 | { |
| 2535 | const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value())); |
| 2536 | aCtx->Remove (anIO, Standard_False); |
| 2537 | if (toPrintInfo) |
| 2538 | { |
| 2539 | theDI << anIter.Value().ToCString() << " was removed\n"; |
| 2540 | } |
| 2541 | if (!isContextOnly) |
| 2542 | { |
| 2543 | GetMapOfAIS().UnBind2 (anIter.Value()); |
| 2544 | } |
| 2545 | } |
| 2546 | |
| 2547 | // Close local context if it is empty |
| 2548 | TColStd_MapOfTransient aLocalIO; |
| 2549 | if (aCtx->HasOpenedContext() |
| 2550 | && !aCtx->LocalContext()->DisplayedObjects (aLocalIO)) |
| 2551 | { |
| 2552 | aCtx->CloseAllContexts (Standard_False); |
| 2553 | } |
| 2554 | |
| 2555 | return 0; |
| 2556 | } |
| 2557 | |
| 2558 | //============================================================================== |
| 2559 | //function : VErase |
| 2560 | //purpose : Erase some selected or named objects |
| 2561 | // if there is no selected or named objects, the whole viewer is erased |
| 2562 | //============================================================================== |
| 2563 | int VErase (Draw_Interpretor& theDI, |
| 2564 | Standard_Integer theArgNb, |
| 2565 | const char** theArgVec) |
| 2566 | { |
| 2567 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
| 2568 | const Handle(V3d_View)& aView = ViewerTest::CurrentView(); |
| 2569 | ViewerTest_AutoUpdater anUpdateTool (aCtx, aView); |
| 2570 | if (aCtx.IsNull()) |
| 2571 | { |
| 2572 | std::cerr << "Error: no active view!\n"; |
| 2573 | return 1; |
| 2574 | } |
| 2575 | |
| 2576 | const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall"; |
| 2577 | |
| 2578 | Standard_Integer anArgIter = 1; |
| 2579 | Standard_Boolean toEraseLocal = Standard_False; |
| 2580 | Standard_Boolean toEraseInView = Standard_False; |
| 2581 | TColStd_SequenceOfAsciiString aNamesOfEraseIO; |
| 2582 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2583 | { |
| 2584 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); |
| 2585 | anArgCase.LowerCase(); |
| 2586 | if (anUpdateTool.parseRedrawMode (anArgCase)) |
| 2587 | { |
| 2588 | continue; |
| 2589 | } |
| 2590 | else if (anArgCase == "-local") |
| 2591 | { |
| 2592 | toEraseLocal = Standard_True; |
| 2593 | } |
| 2594 | else if (anArgCase == "-view" |
| 2595 | || anArgCase == "-inview") |
| 2596 | { |
| 2597 | toEraseInView = Standard_True; |
| 2598 | } |
| 2599 | else |
| 2600 | { |
| 2601 | aNamesOfEraseIO.Append (theArgVec[anArgIter]); |
| 2602 | } |
| 2603 | } |
| 2604 | |
| 2605 | if (!aNamesOfEraseIO.IsEmpty() && toEraseAll) |
| 2606 | { |
| 2607 | std::cerr << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.\n"; |
| 2608 | return 1; |
| 2609 | } |
| 2610 | |
| 2611 | if (toEraseLocal && !aCtx->HasOpenedContext()) |
| 2612 | { |
| 2613 | std::cerr << "Error: local selection context is not open.\n"; |
| 2614 | return 1; |
| 2615 | } |
| 2616 | else if (!toEraseLocal && aCtx->HasOpenedContext()) |
| 2617 | { |
| 2618 | aCtx->CloseAllContexts (Standard_False); |
| 2619 | } |
| 2620 | |
| 2621 | if (!aNamesOfEraseIO.IsEmpty()) |
| 2622 | { |
| 2623 | // Erase named objects |
| 2624 | for (Standard_Integer anIter = 1; anIter <= aNamesOfEraseIO.Length(); ++anIter) |
| 2625 | { |
| 2626 | TCollection_AsciiString aName = aNamesOfEraseIO.Value (anIter); |
| 2627 | if (!GetMapOfAIS().IsBound2 (aName)) |
| 2628 | { |
| 2629 | continue; |
| 2630 | } |
| 2631 | |
| 2632 | const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName); |
| 2633 | const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anObj); |
| 2634 | theDI << aName.ToCString() << " "; |
| 2635 | if (!anIO.IsNull()) |
| 2636 | { |
| 2637 | if (toEraseInView) |
| 2638 | { |
| 2639 | aCtx->SetViewAffinity (anIO, aView, Standard_False); |
| 2640 | } |
| 2641 | else |
| 2642 | { |
| 2643 | aCtx->Erase (anIO, Standard_False); |
| 2644 | } |
| 2645 | } |
| 2646 | } |
| 2647 | } |
| 2648 | else if (!toEraseAll && aCtx->NbCurrents() > 0) |
| 2649 | { |
| 2650 | // Erase selected objects |
| 2651 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2652 | anIter.More(); anIter.Next()) |
| 2653 | { |
| 2654 | const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2655 | if (!anIO.IsNull() |
| 2656 | && aCtx->IsCurrent (anIO)) |
| 2657 | { |
| 2658 | theDI << anIter.Key2().ToCString() << " "; |
| 2659 | if (toEraseInView) |
| 2660 | { |
| 2661 | aCtx->SetViewAffinity (anIO, aView, Standard_False); |
| 2662 | } |
| 2663 | else |
| 2664 | { |
| 2665 | aCtx->Erase (anIO, Standard_False); |
| 2666 | } |
| 2667 | } |
| 2668 | } |
| 2669 | } |
| 2670 | else |
| 2671 | { |
| 2672 | // Erase all objects |
| 2673 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2674 | anIter.More(); anIter.Next()) |
| 2675 | { |
| 2676 | const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2677 | if (!anIO.IsNull()) |
| 2678 | { |
| 2679 | if (toEraseInView) |
| 2680 | { |
| 2681 | aCtx->SetViewAffinity (anIO, aView, Standard_False); |
| 2682 | } |
| 2683 | else |
| 2684 | { |
| 2685 | aCtx->Erase (anIO, Standard_False); |
| 2686 | } |
| 2687 | } |
| 2688 | } |
| 2689 | } |
| 2690 | |
| 2691 | return 0; |
| 2692 | } |
| 2693 | |
| 2694 | //============================================================================== |
| 2695 | //function : VDisplayAll |
| 2696 | //author : ege |
| 2697 | //purpose : Display all the objects of the Map |
| 2698 | //============================================================================== |
| 2699 | static int VDisplayAll (Draw_Interpretor& , |
| 2700 | Standard_Integer theArgNb, |
| 2701 | const char** theArgVec) |
| 2702 | |
| 2703 | { |
| 2704 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); |
| 2705 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 2706 | if (aCtx.IsNull()) |
| 2707 | { |
| 2708 | std::cerr << "Error: no active view!\n"; |
| 2709 | return 1; |
| 2710 | } |
| 2711 | |
| 2712 | Standard_Integer anArgIter = 1; |
| 2713 | Standard_Boolean toDisplayLocal = Standard_False; |
| 2714 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2715 | { |
| 2716 | TCollection_AsciiString anArgCase (theArgVec[anArgIter]); |
| 2717 | anArgCase.LowerCase(); |
| 2718 | if (anArgCase == "-local") |
| 2719 | { |
| 2720 | toDisplayLocal = Standard_True; |
| 2721 | } |
| 2722 | else if (anUpdateTool.parseRedrawMode (anArgCase)) |
| 2723 | { |
| 2724 | continue; |
| 2725 | } |
| 2726 | else |
| 2727 | { |
| 2728 | break; |
| 2729 | } |
| 2730 | } |
| 2731 | if (anArgIter < theArgNb) |
| 2732 | { |
| 2733 | std::cout << theArgVec[0] << "Error: wrong syntax\n"; |
| 2734 | return 1; |
| 2735 | } |
| 2736 | |
| 2737 | if (toDisplayLocal && !aCtx->HasOpenedContext()) |
| 2738 | { |
| 2739 | std::cerr << "Error: local selection context is not open.\n"; |
| 2740 | return 1; |
| 2741 | } |
| 2742 | else if (!toDisplayLocal && aCtx->HasOpenedContext()) |
| 2743 | { |
| 2744 | aCtx->CloseLocalContext (Standard_False); |
| 2745 | } |
| 2746 | |
| 2747 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2748 | anIter.More(); anIter.Next()) |
| 2749 | { |
| 2750 | const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2751 | aCtx->Erase (aShape, Standard_False); |
| 2752 | } |
| 2753 | |
| 2754 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2755 | anIter.More(); anIter.Next()) |
| 2756 | { |
| 2757 | const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2758 | aCtx->Display (aShape, Standard_False); |
| 2759 | } |
| 2760 | return 0; |
| 2761 | } |
| 2762 | |
| 2763 | //! Auxiliary method to find presentation |
| 2764 | inline Handle(PrsMgr_Presentation) findPresentation (const Handle(AIS_InteractiveContext)& theCtx, |
| 2765 | const Handle(AIS_InteractiveObject)& theIO, |
| 2766 | const Standard_Integer theMode) |
| 2767 | { |
| 2768 | if (theIO.IsNull()) |
| 2769 | { |
| 2770 | return Handle(PrsMgr_Presentation)(); |
| 2771 | } |
| 2772 | |
| 2773 | if (theMode != -1) |
| 2774 | { |
| 2775 | if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode)) |
| 2776 | { |
| 2777 | return theCtx->MainPrsMgr()->Presentation (theIO, theMode); |
| 2778 | } |
| 2779 | } |
| 2780 | else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode())) |
| 2781 | { |
| 2782 | return theCtx->MainPrsMgr()->Presentation (theIO, theIO->DisplayMode()); |
| 2783 | } |
| 2784 | else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode())) |
| 2785 | { |
| 2786 | return theCtx->MainPrsMgr()->Presentation (theIO, theCtx->DisplayMode()); |
| 2787 | } |
| 2788 | return Handle(PrsMgr_Presentation)(); |
| 2789 | } |
| 2790 | |
| 2791 | enum ViewerTest_BndAction |
| 2792 | { |
| 2793 | BndAction_Hide, |
| 2794 | BndAction_Show, |
| 2795 | BndAction_Print |
| 2796 | }; |
| 2797 | |
| 2798 | //! Auxiliary method to print bounding box of presentation |
| 2799 | inline void bndPresentation (Draw_Interpretor& theDI, |
| 2800 | const Handle(PrsMgr_Presentation)& thePrs, |
| 2801 | const TCollection_AsciiString& theName, |
| 2802 | const ViewerTest_BndAction theAction) |
| 2803 | { |
| 2804 | switch (theAction) |
| 2805 | { |
| 2806 | case BndAction_Hide: |
| 2807 | { |
| 2808 | thePrs->Presentation()->GraphicUnHighlight(); |
| 2809 | break; |
| 2810 | } |
| 2811 | case BndAction_Show: |
| 2812 | { |
| 2813 | Handle(Graphic3d_Structure) aPrs = thePrs->Presentation(); |
| 2814 | aPrs->CStructure()->HighlightColor.r = 0.988235f; |
| 2815 | aPrs->CStructure()->HighlightColor.g = 0.988235f; |
| 2816 | aPrs->CStructure()->HighlightColor.b = 0.988235f; |
| 2817 | aPrs->CStructure()->HighlightWithBndBox (aPrs, Standard_True); |
| 2818 | break; |
| 2819 | } |
| 2820 | case BndAction_Print: |
| 2821 | { |
| 2822 | Bnd_Box aBox = thePrs->Presentation()->MinMaxValues(); |
| 2823 | gp_Pnt aMin = aBox.CornerMin(); |
| 2824 | gp_Pnt aMax = aBox.CornerMax(); |
| 2825 | theDI << theName << "\n" |
| 2826 | << aMin.X() << " " << aMin.Y() << " " << aMin.Z() << " " |
| 2827 | << aMax.X() << " " << aMax.Y() << " " << aMax.Z() << "\n"; |
| 2828 | break; |
| 2829 | } |
| 2830 | } |
| 2831 | } |
| 2832 | |
| 2833 | //============================================================================== |
| 2834 | //function : VBounding |
| 2835 | //purpose : |
| 2836 | //============================================================================== |
| 2837 | int VBounding (Draw_Interpretor& theDI, |
| 2838 | Standard_Integer theArgNb, |
| 2839 | const char** theArgVec) |
| 2840 | { |
| 2841 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
| 2842 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 2843 | if (aCtx.IsNull()) |
| 2844 | { |
| 2845 | std::cout << "Error: no active view!\n"; |
| 2846 | return 1; |
| 2847 | } |
| 2848 | |
| 2849 | ViewerTest_BndAction anAction = BndAction_Show; |
| 2850 | Standard_Integer aMode = -1; |
| 2851 | |
| 2852 | Standard_Integer anArgIter = 1; |
| 2853 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2854 | { |
| 2855 | TCollection_AsciiString anArg (theArgVec[anArgIter]); |
| 2856 | anArg.LowerCase(); |
| 2857 | if (anArg == "-print") |
| 2858 | { |
| 2859 | anAction = BndAction_Print; |
| 2860 | } |
| 2861 | else if (anArg == "-show") |
| 2862 | { |
| 2863 | anAction = BndAction_Show; |
| 2864 | } |
| 2865 | else if (anArg == "-hide") |
| 2866 | { |
| 2867 | anAction = BndAction_Hide; |
| 2868 | } |
| 2869 | else if (anArg == "-mode") |
| 2870 | { |
| 2871 | if (++anArgIter >= theArgNb) |
| 2872 | { |
| 2873 | std::cout << "Error: wrong syntax at " << anArg << "\n"; |
| 2874 | return 1; |
| 2875 | } |
| 2876 | aMode = Draw::Atoi (theArgVec[anArgIter]); |
| 2877 | } |
| 2878 | else if (!anUpdateTool.parseRedrawMode (anArg)) |
| 2879 | { |
| 2880 | break; |
| 2881 | } |
| 2882 | } |
| 2883 | |
| 2884 | if (anArgIter < theArgNb) |
| 2885 | { |
| 2886 | // has a list of names |
| 2887 | for (; anArgIter < theArgNb; ++anArgIter) |
| 2888 | { |
| 2889 | TCollection_AsciiString aName = theArgVec[anArgIter]; |
| 2890 | if (!GetMapOfAIS().IsBound2 (aName)) |
| 2891 | { |
| 2892 | std::cout << "Error: presentation " << aName << " does not exist\n"; |
| 2893 | return 1; |
| 2894 | } |
| 2895 | |
| 2896 | Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)); |
| 2897 | Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); |
| 2898 | if (aPrs.IsNull()) |
| 2899 | { |
| 2900 | std::cout << "Error: presentation " << aName << " does not exist\n"; |
| 2901 | return 1; |
| 2902 | } |
| 2903 | bndPresentation (theDI, aPrs, aName, anAction); |
| 2904 | } |
| 2905 | } |
| 2906 | else if (aCtx->NbCurrents() > 0) |
| 2907 | { |
| 2908 | // remove all currently selected objects |
| 2909 | for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent()) |
| 2910 | { |
| 2911 | Handle(AIS_InteractiveObject) anIO = aCtx->Current(); |
| 2912 | Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); |
| 2913 | if (!aPrs.IsNull()) |
| 2914 | { |
| 2915 | bndPresentation (theDI, aPrs, GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction); |
| 2916 | } |
| 2917 | } |
| 2918 | } |
| 2919 | else |
| 2920 | { |
| 2921 | // all objects |
| 2922 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); |
| 2923 | anIter.More(); anIter.Next()) |
| 2924 | { |
| 2925 | Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); |
| 2926 | Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); |
| 2927 | if (!aPrs.IsNull()) |
| 2928 | { |
| 2929 | bndPresentation (theDI, aPrs, anIter.Key2(), anAction); |
| 2930 | } |
| 2931 | } |
| 2932 | } |
| 2933 | return 0; |
| 2934 | } |
| 2935 | |
| 2936 | //============================================================================== |
| 2937 | //function : VTexture |
| 2938 | //purpose : |
| 2939 | //============================================================================== |
| 2940 | Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgv) |
| 2941 | { |
| 2942 | TCollection_AsciiString aCommandName (theArgv[0]); |
| 2943 | |
| 2944 | NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs; |
| 2945 | if (aCommandName == "vtexture") |
| 2946 | { |
| 2947 | if (theArgsNb < 2) |
| 2948 | { |
| 2949 | std::cout << theArgv[0] << ": " << " invalid arguments.\n"; |
| 2950 | std::cout << "Type help for more information.\n"; |
| 2951 | return 1; |
| 2952 | } |
| 2953 | |
| 2954 | // look for options of vtexture command |
| 2955 | TCollection_AsciiString aParseKey; |
| 2956 | for (Standard_Integer anArgIt = 2; anArgIt < theArgsNb; ++anArgIt) |
| 2957 | { |
| 2958 | TCollection_AsciiString anArg (theArgv [anArgIt]); |
| 2959 | |
| 2960 | anArg.UpperCase(); |
| 2961 | if (anArg.Value (1) == '-' && !anArg.IsRealValue()) |
| 2962 | { |
| 2963 | aParseKey = anArg; |
| 2964 | aParseKey.Remove (1); |
| 2965 | aParseKey.UpperCase(); |
| 2966 | aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString); |
| 2967 | continue; |
| 2968 | } |
| 2969 | |
| 2970 | if (aParseKey.IsEmpty()) |
| 2971 | { |
| 2972 | continue; |
| 2973 | } |
| 2974 | |
| 2975 | aMapOfArgs(aParseKey)->Append (anArg); |
| 2976 | } |
| 2977 | } |
| 2978 | else if (aCommandName == "vtexscale" |
| 2979 | || aCommandName == "vtexorigin" |
| 2980 | || aCommandName == "vtexrepeat") |
| 2981 | { |
| 2982 | // scan for parameters of vtexscale, vtexorigin, vtexrepeat commands |
| 2983 | // equal to -scale, -origin, -repeat options of vtexture command |
| 2984 | if (theArgsNb < 2 || theArgsNb > 4) |
| 2985 | { |
| 2986 | std::cout << theArgv[0] << ": " << " invalid arguments.\n"; |
| 2987 | std::cout << "Type help for more information.\n"; |
| 2988 | return 1; |
| 2989 | } |
| 2990 | |
| 2991 | Handle(TColStd_HSequenceOfAsciiString) anArgs = new TColStd_HSequenceOfAsciiString; |
| 2992 | if (theArgsNb == 2) |
| 2993 | { |
| 2994 | anArgs->Append ("OFF"); |
| 2995 | } |
| 2996 | else if (theArgsNb == 4) |
| 2997 | { |
| 2998 | anArgs->Append (TCollection_AsciiString (theArgv[2])); |
| 2999 | anArgs->Append (TCollection_AsciiString (theArgv[3])); |
| 3000 | } |
| 3001 | |
| 3002 | TCollection_AsciiString anArgKey; |
| 3003 | if (aCommandName == "vtexscale") |
| 3004 | { |
| 3005 | anArgKey = "SCALE"; |
| 3006 | } |
| 3007 | else if (aCommandName == "vtexorigin") |
| 3008 | { |
| 3009 | anArgKey = "ORIGIN"; |
| 3010 | } |
| 3011 | else |
| 3012 | { |
| 3013 | anArgKey = "REPEAT"; |
| 3014 | } |
| 3015 | |
| 3016 | aMapOfArgs.Bind (anArgKey, anArgs); |
| 3017 | } |
| 3018 | else if (aCommandName == "vtexdefault") |
| 3019 | { |
| 3020 | // scan for parameters of vtexdefault command |
| 3021 | // equal to -default option of vtexture command |
| 3022 | aMapOfArgs.Bind ("DEFAULT", new TColStd_HSequenceOfAsciiString); |
| 3023 | } |
| 3024 | |
| 3025 | // Check arguments for validity |
| 3026 | NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs); |
| 3027 | for (; aMapIt.More(); aMapIt.Next()) |
| 3028 | { |
| 3029 | const TCollection_AsciiString& aKey = aMapIt.Key(); |
| 3030 | const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value(); |
| 3031 | |
| 3032 | // -scale, -origin, -repeat: one argument "off", or two real values |
| 3033 | if ((aKey.IsEqual ("SCALE") || aKey.IsEqual ("ORIGIN") || aKey.IsEqual ("REPEAT")) |
| 3034 | && ((anArgs->Length() == 1 && anArgs->Value(1) == "OFF") |
| 3035 | || (anArgs->Length() == 2 && anArgs->Value(1).IsRealValue() && anArgs->Value(2).IsRealValue()))) |
| 3036 | { |
| 3037 | continue; |
| 3038 | } |
| 3039 | |
| 3040 | // -modulate: single argument "on" / "off" |
| 3041 | if (aKey.IsEqual ("MODULATE") && anArgs->Length() == 1 && (anArgs->Value(1) == "OFF" || anArgs->Value(1) == "ON")) |
| 3042 | { |
| 3043 | continue; |
| 3044 | } |
| 3045 | |
| 3046 | // -default: no arguments |
| 3047 | if (aKey.IsEqual ("DEFAULT") && anArgs->IsEmpty()) |
| 3048 | { |
| 3049 | continue; |
| 3050 | } |
| 3051 | |
| 3052 | TCollection_AsciiString aLowerKey; |
| 3053 | aLowerKey = "-"; |
| 3054 | aLowerKey += aKey; |
| 3055 | aLowerKey.LowerCase(); |
| 3056 | std::cout << theArgv[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n"; |
| 3057 | std::cout << "Type help for more information.\n"; |
| 3058 | return 1; |
| 3059 | } |
| 3060 | |
| 3061 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); |
| 3062 | if (anAISContext.IsNull()) |
| 3063 | { |
| 3064 | std::cout << aCommandName << ": " << " please use 'vinit' command to initialize view.\n"; |
| 3065 | return 1; |
| 3066 | } |
| 3067 | |
| 3068 | Standard_Integer aPreviousMode = 0; |
| 3069 | |
| 3070 | ViewerTest::CurrentView()->SetSurfaceDetail (V3d_TEX_ALL); |
| 3071 | |
| 3072 | TCollection_AsciiString aShapeName (theArgv[1]); |
| 3073 | Handle(AIS_InteractiveObject) anIO; |
| 3074 | |
| 3075 | const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfIO = GetMapOfAIS(); |
| 3076 | if (aMapOfIO.IsBound2 (aShapeName)) |
| 3077 | { |
| 3078 | anIO = Handle(AIS_InteractiveObject)::DownCast (aMapOfIO.Find2 (aShapeName)); |
| 3079 | } |
| 3080 | |
| 3081 | if (anIO.IsNull()) |
| 3082 | { |
| 3083 | std::cout << aCommandName << ": shape " << aShapeName << " does not exists.\n"; |
| 3084 | return 1; |
| 3085 | } |
| 3086 | |
| 3087 | Handle(AIS_TexturedShape) aTexturedIO; |
| 3088 | if (anIO->IsKind (STANDARD_TYPE (AIS_TexturedShape))) |
| 3089 | { |
| 3090 | aTexturedIO = Handle(AIS_TexturedShape)::DownCast (anIO); |
| 3091 | aPreviousMode = aTexturedIO->DisplayMode(); |
| 3092 | } |
| 3093 | else |
| 3094 | { |
| 3095 | anAISContext->Remove (anIO, Standard_False); |
| 3096 | aTexturedIO = new AIS_TexturedShape (DBRep::Get (theArgv[1])); |
| 3097 | GetMapOfAIS().UnBind1 (anIO); |
| 3098 | GetMapOfAIS().UnBind2 (aShapeName); |
| 3099 | GetMapOfAIS().Bind (aTexturedIO, aShapeName); |
| 3100 | } |
| 3101 | |
| 3102 | // ------------------------------------------- |
| 3103 | // Turn texturing on/off - only for vtexture |
| 3104 | // ------------------------------------------- |
| 3105 | |
| 3106 | if (aCommandName == "vtexture") |
| 3107 | { |
| 3108 | TCollection_AsciiString aTextureArg (theArgsNb > 2 ? theArgv[2] : ""); |
| 3109 | |
| 3110 | if (aTextureArg.IsEmpty()) |
| 3111 | { |
| 3112 | std::cout << aCommandName << ": " << " Texture mapping disabled.\n"; |
| 3113 | std::cout << "To enable it, use 'vtexture NameOfShape NameOfTexture'\n" << "\n"; |
| 3114 | |
| 3115 | anAISContext->SetDisplayMode (aTexturedIO, AIS_Shaded, Standard_False); |
| 3116 | if (aPreviousMode == 3) |
| 3117 | { |
| 3118 | anAISContext->RecomputePrsOnly (aTexturedIO); |
| 3119 | } |
| 3120 | |
| 3121 | anAISContext->Display (aTexturedIO, Standard_True); |
| 3122 | return 0; |
| 3123 | } |
| 3124 | else if (aTextureArg.Value(1) != '-') // "-option" on place of texture argument |
| 3125 | { |
| 3126 | if (aTextureArg == "?") |
| 3127 | { |
| 3128 | TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder(); |
| 3129 | |
| 3130 | theDi << "\n Files in current directory : \n" << "\n"; |
| 3131 | theDi.Eval ("glob -nocomplain *"); |
| 3132 | |
| 3133 | TCollection_AsciiString aCmnd ("glob -nocomplain "); |
| 3134 | aCmnd += aTextureFolder; |
| 3135 | aCmnd += "/* "; |
| 3136 | |
| 3137 | theDi << "Files in " << aTextureFolder.ToCString() << " : \n" << "\n"; |
| 3138 | theDi.Eval (aCmnd.ToCString()); |
| 3139 | return 0; |
| 3140 | } |
| 3141 | else |
| 3142 | { |
| 3143 | aTexturedIO->SetTextureFileName (aTextureArg); |
| 3144 | } |
| 3145 | } |
| 3146 | } |
| 3147 | |
| 3148 | // ------------------------------------ |
| 3149 | // Process other options and commands |
| 3150 | // ------------------------------------ |
| 3151 | |
| 3152 | Handle(TColStd_HSequenceOfAsciiString) aValues; |
| 3153 | if (aMapOfArgs.Find ("DEFAULT", aValues)) |
| 3154 | { |
| 3155 | aTexturedIO->SetTextureRepeat (Standard_False); |
| 3156 | aTexturedIO->SetTextureOrigin (Standard_False); |
| 3157 | aTexturedIO->SetTextureScale (Standard_False); |
| 3158 | aTexturedIO->EnableTextureModulate(); |
| 3159 | } |
| 3160 | else |
| 3161 | { |
| 3162 | if (aMapOfArgs.Find ("SCALE", aValues)) |
| 3163 | { |
| 3164 | if (aValues->Value(1) != "OFF") |
| 3165 | { |
| 3166 | aTexturedIO->SetTextureScale (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue()); |
| 3167 | } |
| 3168 | else |
| 3169 | { |
| 3170 | aTexturedIO->SetTextureScale (Standard_False); |
| 3171 | } |
| 3172 | } |
| 3173 | |
| 3174 | if (aMapOfArgs.Find ("ORIGIN", aValues)) |
| 3175 | { |
| 3176 | if (aValues->Value(1) != "OFF") |
| 3177 | { |
| 3178 | aTexturedIO->SetTextureOrigin (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue()); |
| 3179 | } |
| 3180 | else |
| 3181 | { |
| 3182 | aTexturedIO->SetTextureOrigin (Standard_False); |
| 3183 | } |
| 3184 | } |
| 3185 | |
| 3186 | if (aMapOfArgs.Find ("REPEAT", aValues)) |
| 3187 | { |
| 3188 | if (aValues->Value(1) != "OFF") |
| 3189 | { |
| 3190 | aTexturedIO->SetTextureRepeat (Standard_True, aValues->Value(1).RealValue(), aValues->Value(2).RealValue()); |
| 3191 | } |
| 3192 | else |
| 3193 | { |
| 3194 | aTexturedIO->SetTextureRepeat (Standard_False); |
| 3195 | } |
| 3196 | } |
| 3197 | |
| 3198 | if (aMapOfArgs.Find ("MODULATE", aValues)) |
| 3199 | { |
| 3200 | if (aValues->Value(1) == "ON") |
| 3201 | { |
| 3202 | aTexturedIO->EnableTextureModulate(); |
| 3203 | } |
| 3204 | else |
| 3205 | { |
| 3206 | aTexturedIO->DisableTextureModulate(); |
| 3207 | } |
| 3208 | } |
| 3209 | } |
| 3210 | |
| 3211 | if (aTexturedIO->DisplayMode() == 3 || aPreviousMode == 3) |
| 3212 | { |
| 3213 | anAISContext->RecomputePrsOnly (aTexturedIO); |
| 3214 | } |
| 3215 | else |
| 3216 | { |
| 3217 | anAISContext->SetDisplayMode (aTexturedIO, 3, Standard_False); |
| 3218 | anAISContext->Display (aTexturedIO, Standard_True); |
| 3219 | anAISContext->Update (aTexturedIO,Standard_True); |
| 3220 | } |
| 3221 | |
| 3222 | return 0; |
| 3223 | } |
| 3224 | |
| 3225 | //! Auxiliary method to parse transformation persistence flags |
| 3226 | inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString, |
| 3227 | Standard_Integer& theFlags) |
| 3228 | { |
| 3229 | if (theFlagString == "pan") |
| 3230 | { |
| 3231 | theFlags |= Graphic3d_TMF_PanPers; |
| 3232 | } |
| 3233 | else if (theFlagString == "zoom") |
| 3234 | { |
| 3235 | theFlags |= Graphic3d_TMF_ZoomPers; |
| 3236 | } |
| 3237 | else if (theFlagString == "rotate") |
| 3238 | { |
| 3239 | theFlags |= Graphic3d_TMF_RotatePers; |
| 3240 | } |
| 3241 | else if (theFlagString == "trihedron") |
| 3242 | { |
| 3243 | theFlags = Graphic3d_TMF_TriedronPers; |
| 3244 | } |
| 3245 | else if (theFlagString == "full") |
| 3246 | { |
| 3247 | theFlags = Graphic3d_TMF_FullPers; |
| 3248 | } |
| 3249 | else if (theFlagString == "none") |
| 3250 | { |
| 3251 | theFlags = Graphic3d_TMF_None; |
| 3252 | } |
| 3253 | else |
| 3254 | { |
| 3255 | return Standard_False; |
| 3256 | } |
| 3257 | |
| 3258 | return Standard_True; |
| 3259 | } |
| 3260 | |
| 3261 | //============================================================================== |
| 3262 | //function : VDisplay2 |
| 3263 | //author : ege |
| 3264 | //purpose : Display an object from its name |
| 3265 | //============================================================================== |
| 3266 | static int VDisplay2 (Draw_Interpretor& theDI, |
| 3267 | Standard_Integer theArgNb, |
| 3268 | const char** theArgVec) |
| 3269 | { |
| 3270 | if (theArgNb < 2) |
| 3271 | { |
| 3272 | std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n"; |
| 3273 | return 1; |
| 3274 | } |
| 3275 | |
| 3276 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
| 3277 | if (aCtx.IsNull()) |
| 3278 | { |
| 3279 | ViewerTest::ViewerInit(); |
| 3280 | aCtx = ViewerTest::GetAISContext(); |
| 3281 | } |
| 3282 | |
| 3283 | // Parse input arguments |
| 3284 | ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView()); |
| 3285 | Standard_Integer isMutable = -1; |
| 3286 | Graphic3d_ZLayerId aZLayer = Graphic3d_ZLayerId_UNKNOWN; |
| 3287 | Standard_Boolean toDisplayLocal = Standard_False; |
| 3288 | Standard_Boolean toReDisplay = Standard_False; |
| 3289 | Standard_Integer isSelectable = -1; |
| 3290 | Standard_Integer anObjDispMode = -2; |
| 3291 | Standard_Integer anObjHighMode = -2; |
| 3292 | Standard_Boolean toSetTrsfPers = Standard_False; |
| 3293 | Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None; |
| 3294 | gp_Pnt aTPPosition; |
| 3295 | TColStd_SequenceOfAsciiString aNamesOfDisplayIO; |
| 3296 | AIS_DisplayStatus aDispStatus = AIS_DS_None; |
| 3297 | Standard_Integer toDisplayInView = Standard_False; |
| 3298 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
| 3299 | { |
| 3300 | const TCollection_AsciiString aName = theArgVec[anArgIter]; |
| 3301 | TCollection_AsciiString aNameCase = aName; |
| 3302 | aNameCase.LowerCase(); |
| 3303 | if (anUpdateTool.parseRedrawMode (aName)) |
| 3304 | { |
| 3305 | continue; |
| 3306 | } |
| 3307 | else if (aNameCase == "-mutable") |
| 3308 | { |
| 3309 | isMutable = 1; |
| 3310 | } |
| 3311 | else if (aNameCase == "-neutral") |
| 3312 | { |
| 3313 | aDispStatus = AIS_DS_Displayed; |
| 3314 | } |
| 3315 | else if (aNameCase == "-immediate" |
| 3316 | || aNameCase == "-top") |
| 3317 | { |
| 3318 | aZLayer = Graphic3d_ZLayerId_Top; |
| 3319 | } |
| 3320 | else if (aNameCase == "-topmost") |
| 3321 | { |
| 3322 | aZLayer = Graphic3d_ZLayerId_Topmost; |
| 3323 | } |
| 3324 | else if (aNameCase == "-osd" |
| 3325 | || aNameCase == "-toposd" |
| 3326 | || aNameCase == "-overlay") |
| 3327 | { |
| 3328 | aZLayer = Graphic3d_ZLayerId_TopOSD; |
| 3329 | } |
| 3330 | else if (aNameCase == "-botosd" |
| 3331 | || aNameCase == "-underlay") |
| 3332 | { |
| 3333 | aZLayer = Graphic3d_ZLayerId_BotOSD; |
| 3334 | } |
| 3335 | else if (aNameCase == "-select" |
| 3336 | || aNameCase == "-selectable") |
| 3337 | { |
| 3338 | isSelectable = 1; |
| 3339 | } |
| 3340 | else if (aNameCase == "-noselect" |
| 3341 | || aNameCase == "-noselection") |
| 3342 | { |
| 3343 | isSelectable = 0; |
| 3344 | } |
| 3345 | else if (aNameCase == "-dispmode" |
| 3346 | || aNameCase == "-displaymode") |
| 3347 | { |
| 3348 | if (++anArgIter >= theArgNb) |
| 3349 | { |
| 3350 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3351 | return 1; |
| 3352 | } |
| 3353 | |
| 3354 | anObjDispMode = Draw::Atoi (theArgVec [anArgIter]); |
| 3355 | } |
| 3356 | else if (aNameCase == "-highmode" |
| 3357 | || aNameCase == "-highlightmode") |
| 3358 | { |
| 3359 | if (++anArgIter >= theArgNb) |
| 3360 | { |
| 3361 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3362 | return 1; |
| 3363 | } |
| 3364 | |
| 3365 | anObjHighMode = Draw::Atoi (theArgVec [anArgIter]); |
| 3366 | } |
| 3367 | else if (aNameCase == "-3d") |
| 3368 | { |
| 3369 | toSetTrsfPers = Standard_True; |
| 3370 | aTrsfPersFlags = Graphic3d_TMF_None; |
| 3371 | } |
| 3372 | else if (aNameCase == "-2d") |
| 3373 | { |
| 3374 | toSetTrsfPers = Standard_True; |
| 3375 | aTrsfPersFlags = Graphic3d_TMF_2d; |
| 3376 | } |
| 3377 | else if (aNameCase == "-2dtopdown") |
| 3378 | { |
| 3379 | toSetTrsfPers = Standard_True; |
| 3380 | aTrsfPersFlags = Graphic3d_TMF_2d | Graphic3d_TMF_2d_IsTopDown; |
| 3381 | } |
| 3382 | else if (aNameCase == "-trsfpers" |
| 3383 | || aNameCase == "-pers") |
| 3384 | { |
| 3385 | if (++anArgIter >= theArgNb) |
| 3386 | { |
| 3387 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3388 | return 1; |
| 3389 | } |
| 3390 | |
| 3391 | toSetTrsfPers = Standard_True; |
| 3392 | aTrsfPersFlags = Graphic3d_TMF_None; |
| 3393 | TCollection_AsciiString aPersFlags (theArgVec [anArgIter]); |
| 3394 | aPersFlags.LowerCase(); |
| 3395 | for (Standard_Integer aParserPos = aPersFlags.Search ("|");; aParserPos = aPersFlags.Search ("|")) |
| 3396 | { |
| 3397 | if (aParserPos == -1) |
| 3398 | { |
| 3399 | if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags)) |
| 3400 | { |
| 3401 | std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n"; |
| 3402 | return 1; |
| 3403 | } |
| 3404 | break; |
| 3405 | } |
| 3406 | |
| 3407 | TCollection_AsciiString anOtherFlags = aPersFlags.Split (aParserPos - 1); |
| 3408 | if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags)) |
| 3409 | { |
| 3410 | std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n"; |
| 3411 | return 1; |
| 3412 | } |
| 3413 | aPersFlags = anOtherFlags; |
| 3414 | } |
| 3415 | } |
| 3416 | else if (aNameCase == "-trsfperspos" |
| 3417 | || aNameCase == "-perspos") |
| 3418 | { |
| 3419 | if (anArgIter + 2 >= theArgNb) |
| 3420 | { |
| 3421 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3422 | return 1; |
| 3423 | } |
| 3424 | |
| 3425 | TCollection_AsciiString aX (theArgVec[++anArgIter]); |
| 3426 | TCollection_AsciiString aY (theArgVec[++anArgIter]); |
| 3427 | TCollection_AsciiString aZ = "0"; |
| 3428 | if (!aX.IsIntegerValue() |
| 3429 | || !aY.IsIntegerValue()) |
| 3430 | { |
| 3431 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3432 | return 1; |
| 3433 | } |
| 3434 | if (anArgIter + 1 < theArgNb) |
| 3435 | { |
| 3436 | TCollection_AsciiString aTemp = theArgVec[anArgIter + 1]; |
| 3437 | if (aTemp.IsIntegerValue()) |
| 3438 | { |
| 3439 | aZ = aTemp; |
| 3440 | ++anArgIter; |
| 3441 | } |
| 3442 | } |
| 3443 | aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue()); |
| 3444 | } |
| 3445 | else if (aNameCase == "-layer") |
| 3446 | { |
| 3447 | if (++anArgIter >= theArgNb) |
| 3448 | { |
| 3449 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3450 | return 1; |
| 3451 | } |
| 3452 | |
| 3453 | TCollection_AsciiString aValue (theArgVec[anArgIter]); |
| 3454 | if (!aValue.IsIntegerValue()) |
| 3455 | { |
| 3456 | std::cerr << "Error: wrong syntax at " << aName << ".\n"; |
| 3457 | return 1; |
| 3458 | } |
| 3459 | |
| 3460 | aZLayer = aValue.IntegerValue(); |
| 3461 | } |
| 3462 | else if (aNameCase == "-view" |
| 3463 | || aNameCase == "-inview") |
| 3464 | { |
| 3465 | toDisplayInView = Standard_True; |
| 3466 | } |
| 3467 | else if (aNameCase == "-local") |
| 3468 | { |
| 3469 | aDispStatus = AIS_DS_Temporary; |
| 3470 | toDisplayLocal = Standard_True; |
| 3471 | } |
| 3472 | else if (aNameCase == "-redisplay") |
| 3473 | { |
| 3474 | toReDisplay = Standard_True; |
| 3475 | } |
| 3476 | else |
| 3477 | { |
| 3478 | aNamesOfDisplayIO.Append (aName); |
| 3479 | } |
| 3480 | } |
| 3481 | |
| 3482 | if (aNamesOfDisplayIO.IsEmpty()) |
| 3483 | { |
| 3484 | std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n"; |
| 3485 | return 1; |
| 3486 | } |
| 3487 | |
| 3488 | // Prepare context for display |
| 3489 | if (toDisplayLocal && !aCtx->HasOpenedContext()) |
| 3490 | { |
| 3491 | aCtx->OpenLocalContext (Standard_False); |
| 3492 | } |
| 3493 | else if (!toDisplayLocal && aCtx->HasOpenedContext()) |
| 3494 | { |
| 3495 | aCtx->CloseAllContexts (Standard_False); |
| 3496 | } |
| 3497 | |
| 3498 | // Display interactive objects |
| 3499 | for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter) |
| 3500 | { |
| 3501 | const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value(anIter); |
| 3502 | |
| 3503 | if (!GetMapOfAIS().IsBound2 (aName)) |
| 3504 | { |
| 3505 | // create the AIS_Shape from a name |
| 3506 | const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName (aName.ToCString()); |
| 3507 | if (!aShape.IsNull()) |
| 3508 | { |
| 3509 | if (isMutable != -1) |
| 3510 | { |
| 3511 | aShape->SetMutable (isMutable == 1); |
| 3512 | } |
| 3513 | if (aZLayer != Graphic3d_ZLayerId_UNKNOWN) |
| 3514 | { |
| 3515 | aShape->SetZLayer (aZLayer); |
| 3516 | } |
| 3517 | if (toSetTrsfPers) |
| 3518 | { |
| 3519 | aShape->SetTransformPersistence (aTrsfPersFlags, aTPPosition); |
| 3520 | } |
| 3521 | if (anObjDispMode != -2) |
| 3522 | { |
| 3523 | aShape->SetDisplayMode (anObjDispMode); |
| 3524 | } |
| 3525 | if (anObjHighMode != -2) |
| 3526 | { |
| 3527 | aShape->SetHilightMode (anObjHighMode); |
| 3528 | } |
| 3529 | if (!toDisplayLocal) |
| 3530 | GetMapOfAIS().Bind (aShape, aName); |
| 3531 | |
| 3532 | Standard_Integer aDispMode = aShape->HasDisplayMode() |
| 3533 | ? aShape->DisplayMode() |
| 3534 | : (aShape->AcceptDisplayMode (aCtx->DisplayMode()) |
| 3535 | ? aCtx->DisplayMode() |
| 3536 | : 0); |
| 3537 | Standard_Integer aSelMode = -1; |
| 3538 | if ( isSelectable == 1 |
| 3539 | || (isSelectable == -1 |
| 3540 | && aCtx->GetAutoActivateSelection() |
| 3541 | && aShape->GetTransformPersistenceMode() == 0)) |
| 3542 | { |
| 3543 | aSelMode = aShape->HasSelectionMode() ? aShape->SelectionMode() : -1; |
| 3544 | } |
| 3545 | |
| 3546 | aCtx->Display (aShape, aDispMode, aSelMode, |
| 3547 | Standard_False, aShape->AcceptShapeDecomposition(), |
| 3548 | aDispStatus); |
| 3549 | if (toDisplayInView) |
| 3550 | { |
| 3551 | for (aCtx->CurrentViewer()->InitDefinedViews(); aCtx->CurrentViewer()->MoreDefinedViews(); aCtx->CurrentViewer()->NextDefinedViews()) |
| 3552 | { |
| 3553 | aCtx->SetViewAffinity (aShape, aCtx->CurrentViewer()->DefinedView(), Standard_False); |
| 3554 | } |
| 3555 | aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True); |
| 3556 | } |
| 3557 | } |
| 3558 | else |
| 3559 | { |
| 3560 | std::cerr << "Error: object with name '" << aName << "' does not exist!\n"; |
| 3561 | } |
| 3562 | continue; |
| 3563 | } |
| 3564 | |
| 3565 | Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)); |
| 3566 | if (isMutable != -1) |
| 3567 | { |
| 3568 | aShape->SetMutable (isMutable == 1); |
| 3569 | } |
| 3570 | if (aZLayer != Graphic3d_ZLayerId_UNKNOWN) |
| 3571 | { |
| 3572 | aShape->SetZLayer (aZLayer); |
| 3573 | } |
| 3574 | if (toSetTrsfPers) |
| 3575 | { |
| 3576 | aShape->SetTransformPersistence (aTrsfPersFlags, aTPPosition); |
| 3577 | } |
| 3578 | if (anObjDispMode != -2) |
| 3579 | { |
| 3580 | aShape->SetDisplayMode (anObjDispMode); |
| 3581 | } |
| 3582 | if (anObjHighMode != -2) |
| 3583 | { |
| 3584 | aShape->SetHilightMode (anObjHighMode); |
| 3585 | } |
| 3586 | Standard_Integer aDispMode = aShape->HasDisplayMode() |
| 3587 | ? aShape->DisplayMode() |
| 3588 | : (aShape->AcceptDisplayMode (aCtx->DisplayMode()) |
| 3589 | ? aCtx->DisplayMode() |
| 3590 | : 0); |
| 3591 | Standard_Integer aSelMode = -1; |
| 3592 | if ( isSelectable == 1 |
| 3593 | || (isSelectable == -1 |
| 3594 | && aCtx->GetAutoActivateSelection() |
| 3595 | && aShape->GetTransformPersistenceMode() == 0)) |
| 3596 | { |
| 3597 | aSelMode = aShape->HasSelectionMode() ? aShape->SelectionMode() : -1; |
| 3598 | } |
| 3599 | |
| 3600 | if (aShape->Type() == AIS_KOI_Datum) |
| 3601 | { |
| 3602 | aCtx->Display (aShape, Standard_False); |
| 3603 | } |
| 3604 | else |
| 3605 | { |
| 3606 | theDI << "Display " << aName.ToCString() << "\n"; |
| 3607 | |
| 3608 | // update the Shape in the AIS_Shape |
| 3609 | TopoDS_Shape aNewShape = GetShapeFromName (aName.ToCString()); |
| 3610 | Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape); |
| 3611 | if (!aShapePrs.IsNull()) |
| 3612 | { |
| 3613 | if (!aShapePrs->Shape().IsEqual (aNewShape)) |
| 3614 | { |
| 3615 | toReDisplay = Standard_True; |
| 3616 | } |
| 3617 | aShapePrs->Set (aNewShape); |
| 3618 | } |
| 3619 | if (toReDisplay) |
| 3620 | { |
| 3621 | aCtx->Redisplay (aShape, Standard_False); |
| 3622 | } |
| 3623 | |
| 3624 | if (aSelMode == -1) |
| 3625 | { |
| 3626 | aCtx->Erase (aShape); |
| 3627 | } |
| 3628 | aCtx->Display (aShape, aDispMode, aSelMode, |
| 3629 | Standard_False, aShape->AcceptShapeDecomposition(), |
| 3630 | aDispStatus); |
| 3631 | if (toDisplayInView) |
| 3632 | { |
| 3633 | aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True); |
| 3634 | } |
| 3635 | } |
| 3636 | } |
| 3637 | |
| 3638 | return 0; |
| 3639 | } |
| 3640 | |
| 3641 | //=============================================================================================== |
| 3642 | //function : VUpdate |
| 3643 | //purpose : |
| 3644 | //=============================================================================================== |
| 3645 | static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec) |
| 3646 | { |
| 3647 | Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); |
| 3648 | if (aContextAIS.IsNull()) |
| 3649 | { |
| 3650 | std::cout << theArgVec[0] << "AIS context is not available.\n"; |
| 3651 | return 1; |
| 3652 | } |
| 3653 | |
| 3654 | if (theArgsNb < 2) |
| 3655 | { |
| 3656 | std::cout << theArgVec[0] << ": insufficient arguments. Type help for more information.\n"; |
| 3657 | return 1; |
| 3658 | } |
| 3659 | |
| 3660 | const ViewerTest_DoubleMapOfInteractiveAndName& anAISMap = GetMapOfAIS(); |
| 3661 | |
| 3662 | AIS_ListOfInteractive aListOfIO; |
| 3663 | |
| 3664 | for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) |
| 3665 | { |
| 3666 | TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]); |
| 3667 | |
| 3668 | Handle(AIS_InteractiveObject) anAISObj; |
| 3669 | if (anAISMap.IsBound2 (aName)) |
| 3670 | { |
| 3671 | anAISObj = Handle(AIS_InteractiveObject)::DownCast (anAISMap.Find2 (aName)); |
| 3672 | } |
| 3673 | |
| 3674 | if (anAISObj.IsNull()) |
| 3675 | { |
| 3676 | std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n"; |
| 3677 | return 1; |
| 3678 | } |
| 3679 | |
| 3680 | aListOfIO.Append (anAISObj); |
| 3681 | } |
| 3682 | |
| 3683 | AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); |
| 3684 | for (; anIOIt.More(); anIOIt.Next()) |
| 3685 | { |
| 3686 | aContextAIS->Update (anIOIt.Value(), Standard_False); |
| 3687 | } |
| 3688 | |
| 3689 | aContextAIS->UpdateCurrentViewer(); |
| 3690 | |
| 3691 | return 0; |
| 3692 | } |
| 3693 | |
| 3694 | //============================================================================== |
| 3695 | //function : VPerf |
| 3696 | //purpose : Test the annimation of an object along a |
| 3697 | // predifined trajectory |
| 3698 | //Draw arg : vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF) |
| 3699 | //============================================================================== |
| 3700 | |
| 3701 | static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) { |
| 3702 | |
| 3703 | OSD_Timer myTimer; |
| 3704 | if (TheAISContext()->HasOpenedContext()) |
| 3705 | TheAISContext()->CloseLocalContext(); |
| 3706 | |
| 3707 | Standard_Real Step=4*M_PI/180; |
| 3708 | Standard_Real Angle=0; |
| 3709 | |
| 3710 | Handle(AIS_InteractiveObject) aIO; |
| 3711 | if (GetMapOfAIS().IsBound2(argv[1])) |
| 3712 | aIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1])); |
| 3713 | if (aIO.IsNull()) |
| 3714 | return 1; |
| 3715 | |
| 3716 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aIO); |
| 3717 | |
| 3718 | myTimer.Start(); |
| 3719 | |
| 3720 | if (Draw::Atoi(argv[3])==1 ) { |
| 3721 | di<<" Primitives sensibles OFF"<<"\n"; |
| 3722 | TheAISContext()->Deactivate(aIO); |
| 3723 | } |
| 3724 | else { |
| 3725 | di<<" Primitives sensibles ON"<<"\n"; |
| 3726 | } |
| 3727 | // Movement par transformation |
| 3728 | if(Draw::Atoi(argv[2]) ==1) { |
| 3729 | di<<" Calcul par Transformation"<<"\n"; |
| 3730 | for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) { |
| 3731 | |
| 3732 | Angle=Step*myAngle; |
| 3733 | gp_Trsf myTransfo; |
| 3734 | myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ) ,Angle ); |
| 3735 | TheAISContext()->SetLocation(aShape,myTransfo); |
| 3736 | TheAISContext() ->UpdateCurrentViewer(); |
| 3737 | |
| 3738 | } |
| 3739 | } |
| 3740 | else { |
| 3741 | di<<" Calcul par Locations"<<"\n"; |
| 3742 | gp_Trsf myAngleTrsf; |
| 3743 | myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ), Step ); |
| 3744 | TopLoc_Location myDeltaAngle (myAngleTrsf); |
| 3745 | TopLoc_Location myTrueLoc; |
| 3746 | |
| 3747 | for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) { |
| 3748 | |
| 3749 | Angle=Step*myAngle; |
| 3750 | myTrueLoc=myTrueLoc*myDeltaAngle; |
| 3751 | TheAISContext()->SetLocation(aShape,myTrueLoc ); |
| 3752 | TheAISContext() ->UpdateCurrentViewer(); |
| 3753 | } |
| 3754 | } |
| 3755 | if (Draw::Atoi(argv[3])==1 ){ |
| 3756 | // On reactive la selection des primitives sensibles |
| 3757 | TheAISContext()->Activate(aIO,0); |
| 3758 | } |
| 3759 | a3DView() -> Redraw(); |
| 3760 | myTimer.Stop(); |
| 3761 | di<<" Temps ecoule "<<"\n"; |
| 3762 | myTimer.Show(); |
| 3763 | return 0; |
| 3764 | } |
| 3765 | |
| 3766 | |
| 3767 | //================================================================================== |
| 3768 | // Function : VAnimation |
| 3769 | //================================================================================== |
| 3770 | static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { |
| 3771 | if (argc != 5) { |
| 3772 | di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n"; |
| 3773 | return 1; |
| 3774 | } |
| 3775 | |
| 3776 | Standard_Real thread = 4; |
| 3777 | Standard_Real angleA=0; |
| 3778 | Standard_Real angleB; |
| 3779 | Standard_Real X; |
| 3780 | gp_Ax1 Ax1(gp_Pnt(0,0,0),gp_Vec(0,0,1)); |
| 3781 | |
| 3782 | BRep_Builder B; |
| 3783 | TopoDS_Shape CrankArm; |
| 3784 | TopoDS_Shape CylinderHead; |
| 3785 | TopoDS_Shape Propeller; |
| 3786 | TopoDS_Shape EngineBlock; |
| 3787 | |
| 3788 | //BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B); |
| 3789 | //BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B); |
| 3790 | //BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B); |
| 3791 | //BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B); |
| 3792 | BRepTools::Read(CrankArm,argv[1],B); |
| 3793 | BRepTools::Read(CylinderHead,argv[2],B); |
| 3794 | BRepTools::Read(Propeller,argv[3],B); |
| 3795 | BRepTools::Read(EngineBlock,argv[4],B); |
| 3796 | |
| 3797 | if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) {di<<" Syntaxe error:loading failure."<<"\n";} |
| 3798 | |
| 3799 | |
| 3800 | OSD_Timer myTimer; |
| 3801 | myTimer.Start(); |
| 3802 | |
| 3803 | Handle(AIS_Shape) myAisCylinderHead = new AIS_Shape (CylinderHead); |
| 3804 | Handle(AIS_Shape) myAisEngineBlock = new AIS_Shape (EngineBlock); |
| 3805 | Handle(AIS_Shape) myAisCrankArm = new AIS_Shape (CrankArm); |
| 3806 | Handle(AIS_Shape) myAisPropeller = new AIS_Shape (Propeller); |
| 3807 | |
| 3808 | GetMapOfAIS().Bind(myAisCylinderHead,"a"); |
| 3809 | GetMapOfAIS().Bind(myAisEngineBlock,"b"); |
| 3810 | GetMapOfAIS().Bind(myAisCrankArm,"c"); |
| 3811 | GetMapOfAIS().Bind(myAisPropeller,"d"); |
| 3812 | |
| 3813 | myAisCylinderHead->SetMutable (Standard_True); |
| 3814 | myAisEngineBlock ->SetMutable (Standard_True); |
| 3815 | myAisCrankArm ->SetMutable (Standard_True); |
| 3816 | myAisPropeller ->SetMutable (Standard_True); |
| 3817 | |
| 3818 | TheAISContext()->SetColor (myAisCylinderHead, Quantity_NOC_INDIANRED); |
| 3819 | TheAISContext()->SetColor (myAisEngineBlock, Quantity_NOC_RED); |
| 3820 | TheAISContext()->SetColor (myAisPropeller, Quantity_NOC_GREEN); |
| 3821 | |
| 3822 | TheAISContext()->Display (myAisCylinderHead, Standard_False); |
| 3823 | TheAISContext()->Display (myAisEngineBlock, Standard_False); |
| 3824 | TheAISContext()->Display (myAisCrankArm, Standard_False); |
| 3825 | TheAISContext()->Display (myAisPropeller, Standard_False); |
| 3826 | |
| 3827 | TheAISContext()->Deactivate(myAisCylinderHead); |
| 3828 | TheAISContext()->Deactivate(myAisEngineBlock ); |
| 3829 | TheAISContext()->Deactivate(myAisCrankArm ); |
| 3830 | TheAISContext()->Deactivate(myAisPropeller ); |
| 3831 | |
| 3832 | // Boucle de mouvement |
| 3833 | for (Standard_Real myAngle = 0;angleA<2*M_PI*10.175 ;myAngle++) { |
| 3834 | |
| 3835 | angleA = thread*myAngle*M_PI/180; |
| 3836 | X = Sin(angleA)*3/8; |
| 3837 | angleB = atan(X / Sqrt(-X * X + 1)); |
| 3838 | Standard_Real decal(25*0.6); |
| 3839 | |
| 3840 | |
| 3841 | //Build a transformation on the display |
| 3842 | gp_Trsf aPropellerTrsf; |
| 3843 | aPropellerTrsf.SetRotation(Ax1,angleA); |
| 3844 | TheAISContext()->SetLocation(myAisPropeller,aPropellerTrsf); |
| 3845 | |
| 3846 | gp_Ax3 base(gp_Pnt(3*decal*(1-Cos(angleA)),-3*decal*Sin(angleA),0),gp_Vec(0,0,1),gp_Vec(1,0,0)); |
| 3847 | gp_Trsf aCrankArmTrsf; |
| 3848 | aCrankArmTrsf.SetTransformation( base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB)); |
| 3849 | TheAISContext()->SetLocation(myAisCrankArm,aCrankArmTrsf); |
| 3850 | |
| 3851 | TheAISContext()->UpdateCurrentViewer(); |
| 3852 | } |
| 3853 | |
| 3854 | TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() ); |
| 3855 | TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() ); |
| 3856 | |
| 3857 | myAisCrankArm ->ResetTransformation(); |
| 3858 | myAisPropeller->ResetTransformation(); |
| 3859 | |
| 3860 | myAisCrankArm -> Set(myNewCrankArm ); |
| 3861 | myAisPropeller -> Set(myNewPropeller); |
| 3862 | |
| 3863 | TheAISContext()->Activate(myAisCylinderHead,0); |
| 3864 | TheAISContext()->Activate(myAisEngineBlock,0 ); |
| 3865 | TheAISContext()->Activate(myAisCrankArm ,0 ); |
| 3866 | TheAISContext()->Activate(myAisPropeller ,0 ); |
| 3867 | |
| 3868 | myTimer.Stop(); |
| 3869 | myTimer.Show(); |
| 3870 | myTimer.Start(); |
| 3871 | |
| 3872 | TheAISContext()->Redisplay(myAisCrankArm ,Standard_False); |
| 3873 | TheAISContext()->Redisplay(myAisPropeller,Standard_False); |
| 3874 | |
| 3875 | TheAISContext()->UpdateCurrentViewer(); |
| 3876 | a3DView()->Redraw(); |
| 3877 | |
| 3878 | myTimer.Stop(); |
| 3879 | myTimer.Show(); |
| 3880 | |
| 3881 | return 0; |
| 3882 | |
| 3883 | } |
| 3884 | |
| 3885 | //============================================================================== |
| 3886 | //function : VShading |
| 3887 | //purpose : Sharpen or roughten the quality of the shading |
| 3888 | //Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg |
| 3889 | //============================================================================== |
| 3890 | static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv) |
| 3891 | { |
| 3892 | Standard_Real myDevCoef; |
| 3893 | Handle(AIS_InteractiveObject) TheAisIO; |
| 3894 | |
| 3895 | // Verifications |
| 3896 | const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0); |
| 3897 | |
| 3898 | if (TheAISContext()->HasOpenedContext()) |
| 3899 | TheAISContext()->CloseLocalContext(); |
| 3900 | |
| 3901 | if (argc < 3) { |
| 3902 | myDevCoef = 0.0008; |
| 3903 | } else { |
| 3904 | myDevCoef =Draw::Atof(argv[2]); |
| 3905 | } |
| 3906 | |
| 3907 | TCollection_AsciiString name=argv[1]; |
| 3908 | if (GetMapOfAIS().IsBound2(name )) |
| 3909 | TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
| 3910 | if (TheAisIO.IsNull()) |
| 3911 | TheAisIO=GetAISShapeFromName((const char *)name.ToCString()); |
| 3912 | |
| 3913 | if (HaveToSet) |
| 3914 | TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True); |
| 3915 | else |
| 3916 | TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True); |
| 3917 | |
| 3918 | TheAISContext()->Redisplay(TheAisIO); |
| 3919 | return 0; |
| 3920 | } |
| 3921 | //============================================================================== |
| 3922 | //function : HaveMode |
| 3923 | //use : VActivatedModes |
| 3924 | //============================================================================== |
| 3925 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
| 3926 | |
| 3927 | Standard_Boolean HaveMode(const Handle(AIS_InteractiveObject)& TheAisIO,const Standard_Integer mode ) |
| 3928 | { |
| 3929 | TColStd_ListOfInteger List; |
| 3930 | TheAISContext()->ActivatedModes (TheAisIO,List); |
| 3931 | TColStd_ListIteratorOfListOfInteger it; |
| 3932 | Standard_Boolean Found=Standard_False; |
| 3933 | for (it.Initialize(List); it.More()&&!Found; it.Next() ){ |
| 3934 | if (it.Value()==mode ) Found=Standard_True; |
| 3935 | } |
| 3936 | return Found; |
| 3937 | } |
| 3938 | |
| 3939 | |
| 3940 | |
| 3941 | //============================================================================== |
| 3942 | //function : VActivatedMode |
| 3943 | //author : ege |
| 3944 | //purpose : permet d'attribuer a chacune des shapes un mode d'activation |
| 3945 | // (edges,vertex...)qui lui est propre et le mode de selection standard. |
| 3946 | // La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer) |
| 3947 | // Dans le cas ou on veut psser la shape en argument, la fonction n'autorise |
| 3948 | // qu'un nom et qu'un mode. |
| 3949 | //Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7) |
| 3950 | //============================================================================== |
| 3951 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
| 3952 | |
| 3953 | static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
| 3954 | |
| 3955 | { |
| 3956 | Standard_Boolean ThereIsName = Standard_False ; |
| 3957 | |
| 3958 | if(!a3DView().IsNull()){ |
| 3959 | |
| 3960 | const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0); |
| 3961 | // verification des arguments |
| 3962 | if (HaveToSet) { |
| 3963 | if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;} |
| 3964 | ThereIsName = (argc == 3); |
| 3965 | } |
| 3966 | else { |
| 3967 | // vunsetam |
| 3968 | if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;} |
| 3969 | else { |
| 3970 | di<<" R.A.Z de tous les modes de selecion"<<"\n"; |
| 3971 | di<<" Fermeture du Context local"<<"\n"; |
| 3972 | if (TheAISContext()->HasOpenedContext()) |
| 3973 | TheAISContext()->CloseLocalContext(); |
| 3974 | } |
| 3975 | } |
| 3976 | |
| 3977 | // IL n'y a aps de nom de shape passe en argument |
| 3978 | if (HaveToSet && !ThereIsName){ |
| 3979 | Standard_Integer aMode=Draw::Atoi(argv [1]); |
| 3980 | |
| 3981 | const char *cmode="???"; |
| 3982 | switch (aMode) { |
| 3983 | case 0: cmode = "Shape"; break; |
| 3984 | case 1: cmode = "Vertex"; break; |
| 3985 | case 2: cmode = "Edge"; break; |
| 3986 | case 3: cmode = "Wire"; break; |
| 3987 | case 4: cmode = "Face"; break; |
| 3988 | case 5: cmode = "Shell"; break; |
| 3989 | case 6: cmode = "Solid"; break; |
| 3990 | case 7: cmode = "Compound"; break; |
| 3991 | } |
| 3992 | |
| 3993 | if( !TheAISContext()->HasOpenedContext() ) { |
| 3994 | // il n'y a pas de Context local d'ouvert |
| 3995 | // on en ouvre un et on charge toutes les shapes displayees |
| 3996 | // on load tous les objets displayees et on Activate les objets de la liste |
| 3997 | AIS_ListOfInteractive ListOfIO; |
| 3998 | // on sauve dans une AISListOfInteractive tous les objets currents |
| 3999 | if (TheAISContext()->NbCurrents()>0 ){ |
| 4000 | TheAISContext()->UnhilightCurrents(Standard_False); |
| 4001 | |
| 4002 | for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){ |
| 4003 | ListOfIO.Append(TheAISContext()->Current() ); |
| 4004 | } |
| 4005 | } |
| 4006 | |
| 4007 | TheAISContext()->OpenLocalContext(Standard_False); |
| 4008 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName |
| 4009 | it (GetMapOfAIS()); |
| 4010 | while(it.More()){ |
| 4011 | Handle(AIS_InteractiveObject) aIO = |
| 4012 | Handle(AIS_InteractiveObject)::DownCast(it.Key1()); |
| 4013 | if (!aIO.IsNull()) |
| 4014 | TheAISContext()->Load(aIO,0,Standard_False); |
| 4015 | it.Next(); |
| 4016 | } |
| 4017 | // traitement des objets qui etaient currents dans le Contexte global |
| 4018 | if (!ListOfIO.IsEmpty() ) { |
| 4019 | // il y avait des objets currents |
| 4020 | AIS_ListIteratorOfListOfInteractive iter; |
| 4021 | for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) { |
| 4022 | Handle(AIS_InteractiveObject) aIO=iter.Value(); |
| 4023 | TheAISContext()->Activate(aIO,aMode); |
| 4024 | di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n"; |
| 4025 | } |
| 4026 | } |
| 4027 | else { |
| 4028 | // On applique le mode a tous les objets displayes |
| 4029 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName |
| 4030 | it2 (GetMapOfAIS()); |
| 4031 | while(it2.More()){ |
| 4032 | Handle(AIS_InteractiveObject) aIO = |
| 4033 | Handle(AIS_InteractiveObject)::DownCast(it2.Key1()); |
| 4034 | if (!aIO.IsNull()) { |
| 4035 | di<<" Mode: "<<cmode<<" ON pour "<<it2.Key2().ToCString() <<"\n"; |
| 4036 | TheAISContext()->Activate(aIO,aMode); |
| 4037 | } |
| 4038 | it2.Next(); |
| 4039 | } |
| 4040 | } |
| 4041 | |
| 4042 | } |
| 4043 | |
| 4044 | else { |
| 4045 | // un Context local est deja ouvert |
| 4046 | // Traitement des objets du Context local |
| 4047 | if (TheAISContext()->NbSelected()>0 ){ |
| 4048 | TheAISContext()->UnhilightSelected(Standard_False); |
| 4049 | // il y a des objets selected,on les parcourt |
| 4050 | for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){ |
| 4051 | Handle(AIS_InteractiveObject) aIO=TheAISContext()->Interactive(); |
| 4052 | |
| 4053 | |
| 4054 | if (HaveMode(aIO,aMode) ) { |
| 4055 | di<<" Mode: "<<cmode<<" OFF pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n"; |
| 4056 | TheAISContext()->Deactivate(aIO,aMode); |
| 4057 | } |
| 4058 | else{ |
| 4059 | di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n"; |
| 4060 | TheAISContext()->Activate(aIO,aMode); |
| 4061 | } |
| 4062 | |
| 4063 | } |
| 4064 | } |
| 4065 | else{ |
| 4066 | // il n'y a pas d'objets selected |
| 4067 | // tous les objets diplayes sont traites |
| 4068 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName |
| 4069 | it (GetMapOfAIS()); |
| 4070 | while(it.More()){ |
| 4071 | Handle(AIS_InteractiveObject) aIO = |
| 4072 | Handle(AIS_InteractiveObject)::DownCast(it.Key1()); |
| 4073 | if (!aIO.IsNull()) { |
| 4074 | if (HaveMode(aIO,aMode) ) { |
| 4075 | di<<" Mode: "<<cmode<<" OFF pour " |
| 4076 | <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n"; |
| 4077 | TheAISContext()->Deactivate(aIO,aMode); |
| 4078 | } |
| 4079 | else{ |
| 4080 | di<<" Mode: "<<cmode<<" ON pour" |
| 4081 | <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n"; |
| 4082 | TheAISContext()->Activate(aIO,aMode); |
| 4083 | } |
| 4084 | } |
| 4085 | it.Next(); |
| 4086 | } |
| 4087 | } |
| 4088 | } |
| 4089 | } |
| 4090 | else if (HaveToSet && ThereIsName){ |
| 4091 | Standard_Integer aMode=Draw::Atoi(argv [2]); |
| 4092 | Handle(AIS_InteractiveObject) aIO = |
| 4093 | Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1])); |
| 4094 | |
| 4095 | if (!aIO.IsNull()) { |
| 4096 | const char *cmode="???"; |
| 4097 | |
| 4098 | switch (aMode) { |
| 4099 | case 0: cmode = "Shape"; break; |
| 4100 | case 1: cmode = "Vertex"; break; |
| 4101 | case 2: cmode = "Edge"; break; |
| 4102 | case 3: cmode = "Wire"; break; |
| 4103 | case 4: cmode = "Face"; break; |
| 4104 | case 5: cmode = "Shell"; break; |
| 4105 | case 6: cmode = "Solid"; break; |
| 4106 | case 7: cmode = "Compound"; break; |
| 4107 | } |
| 4108 | |
| 4109 | if( !TheAISContext()->HasOpenedContext() ) { |
| 4110 | TheAISContext()->OpenLocalContext(Standard_False); |
| 4111 | // On charge tous les objets de la map |
| 4112 | ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS()); |
| 4113 | while(it.More()){ |
| 4114 | Handle(AIS_InteractiveObject) aShape= |
| 4115 | Handle(AIS_InteractiveObject)::DownCast(it.Key1()); |
| 4116 | if (!aShape.IsNull()) |
| 4117 | TheAISContext()->Load(aShape,0,Standard_False); |
| 4118 | it.Next(); |
| 4119 | } |
| 4120 | TheAISContext()->Activate(aIO,aMode); |
| 4121 | di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n"; |
| 4122 | } |
| 4123 | |
| 4124 | else { |
| 4125 | // un Context local est deja ouvert |
| 4126 | if (HaveMode(aIO,aMode) ) { |
| 4127 | di<<" Mode: "<<cmode<<" OFF pour "<<argv[1]<<"\n"; |
| 4128 | TheAISContext()->Deactivate(aIO,aMode); |
| 4129 | } |
| 4130 | else{ |
| 4131 | di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n"; |
| 4132 | TheAISContext()->Activate(aIO,aMode); |
| 4133 | } |
| 4134 | } |
| 4135 | } |
| 4136 | } |
| 4137 | } |
| 4138 | return 0; |
| 4139 | } |
| 4140 | |
| 4141 | //! Auxiliary method to print Interactive Object information |
| 4142 | static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected, |
| 4143 | const Handle(Standard_Transient)& theObject, |
| 4144 | Draw_Interpretor& theDI) |
| 4145 | { |
| 4146 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theObject); |
| 4147 | if (anObj.IsNull()) |
| 4148 | { |
| 4149 | theDI << theObject->DynamicType()->Name() << " is not AIS presentation\n"; |
| 4150 | return; |
| 4151 | } |
| 4152 | |
| 4153 | theDI << (TheAISContext()->IsDisplayed (anObj) ? "Displayed" : "Hidden ") |
| 4154 | << (TheAISContext()->IsSelected (anObj) ? " Selected" : " ") |
| 4155 | << (theDetected.Contains (anObj) ? " Detected" : " ") |
| 4156 | << " Type: "; |
| 4157 | if (anObj->Type() == AIS_KOI_Datum) |
| 4158 | { |
| 4159 | // AIS_Datum |
| 4160 | if (anObj->Signature() == 3) { theDI << " AIS_Trihedron"; } |
| 4161 | else if (anObj->Signature() == 2) { theDI << " AIS_Axis"; } |
| 4162 | else if (anObj->Signature() == 6) { theDI << " AIS_Circle"; } |
| 4163 | else if (anObj->Signature() == 5) { theDI << " AIS_Line"; } |
| 4164 | else if (anObj->Signature() == 7) { theDI << " AIS_Plane"; } |
| 4165 | else if (anObj->Signature() == 1) { theDI << " AIS_Point"; } |
| 4166 | else if (anObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; } |
| 4167 | } |
| 4168 | // AIS_Shape |
| 4169 | else if (anObj->Type() == AIS_KOI_Shape |
| 4170 | && anObj->Signature() == 0) |
| 4171 | { |
| 4172 | theDI << " AIS_Shape"; |
| 4173 | } |
| 4174 | else if (anObj->Type() == AIS_KOI_Relation) |
| 4175 | { |
| 4176 | // AIS_Dimention and AIS_Relation |
| 4177 | Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (anObj); |
| 4178 | switch (aRelation->KindOfDimension()) |
| 4179 | { |
| 4180 | case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break; |
| 4181 | case AIS_KOD_LENGTH: theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break; |
| 4182 | case AIS_KOD_DIAMETER: theDI << " AIS_DiameterDimension"; break; |
| 4183 | case AIS_KOD_ELLIPSERADIUS: theDI << " AIS_EllipseRadiusDimension"; break; |
| 4184 | //case AIS_KOD_FILLETRADIUS: theDI << " AIS_FilletRadiusDimension "; break; |
| 4185 | case AIS_KOD_OFFSET: theDI << " AIS_OffsetDimension"; break; |
| 4186 | case AIS_KOD_RADIUS: theDI << " AIS_RadiusDimension"; break; |
| 4187 | default: theDI << " UNKNOWN dimension"; break; |
| 4188 | } |
| 4189 | } |
| 4190 | else |
| 4191 | { |
| 4192 | theDI << " UserPrs"; |
| 4193 | } |
| 4194 | theDI << " (" << theObject->DynamicType()->Name() << ")"; |
| 4195 | } |
| 4196 | |
| 4197 | //! Print information about locally selected sub-shapes |
| 4198 | static void localCtxInfo (Draw_Interpretor& theDI) |
| 4199 | { |
| 4200 | Handle(AIS_InteractiveContext) aCtx = TheAISContext(); |
| 4201 | if (!aCtx->HasOpenedContext()) |
| 4202 | { |
| 4203 | return; |
| 4204 | } |
| 4205 | |
| 4206 | TCollection_AsciiString aPrevName; |
| 4207 | Handle(AIS_LocalContext) aCtxLoc = aCtx->LocalContext(); |
| 4208 | for (aCtxLoc->InitSelected(); aCtxLoc->MoreSelected(); aCtxLoc->NextSelected()) |
| 4209 | { |
| 4210 | const TopoDS_Shape aSubShape = aCtxLoc->SelectedShape(); |
| 4211 | const Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (aCtxLoc->SelectedInteractive()); |
| 4212 | if (aSubShape.IsNull() |
| 4213 | || aShapeIO.IsNull() |
| 4214 | || !GetMapOfAIS().IsBound1 (aShapeIO)) |
| 4215 | { |
| 4216 | continue; |
| 4217 | } |
| 4218 | |
| 4219 | const TCollection_AsciiString aParentName = GetMapOfAIS().Find1 (aShapeIO); |
| 4220 | TopTools_MapOfShape aFilter; |
| 4221 | Standard_Integer aNumber = 0; |
| 4222 | const TopoDS_Shape aShape = aShapeIO->Shape(); |
| 4223 | for (TopExp_Explorer anIter (aShape, aSubShape.ShapeType()); |
| 4224 | anIter.More(); anIter.Next()) |
| 4225 | { |
| 4226 | if (!aFilter.Add (anIter.Current())) |
| 4227 | { |
| 4228 | continue; // filter duplicates |
| 4229 | } |
| 4230 | |
| 4231 | ++aNumber; |
| 4232 | if (!anIter.Current().IsSame (aSubShape)) |
| 4233 | { |
| 4234 | continue; |
| 4235 | } |
| 4236 | |
| 4237 | Standard_CString aShapeName = NULL; |
| 4238 | switch (aSubShape.ShapeType()) |
| 4239 | { |
| 4240 | case TopAbs_COMPOUND: aShapeName = " Compound"; break; |
| 4241 | case TopAbs_COMPSOLID: aShapeName = "CompSolid"; break; |
| 4242 | case TopAbs_SOLID: aShapeName = " Solid"; break; |
| 4243 | case TopAbs_SHELL: aShapeName = " Shell"; break; |
| 4244 | case TopAbs_FACE: aShapeName = " Face"; break; |
| 4245 | case TopAbs_WIRE: aShapeName = " Wire"; break; |
| 4246 | case TopAbs_EDGE: aShapeName = " Edge"; break; |
| 4247 | case TopAbs_VERTEX: aShapeName = " Vertex"; break; |
| 4248 | default: |
| 4249 | case TopAbs_SHAPE: aShapeName = " Shape"; break; |
| 4250 | } |
| 4251 | |
| 4252 | if (aParentName != aPrevName) |
| 4253 | { |
| 4254 | theDI << "Locally selected sub-shapes within " << aParentName << ":\n"; |
| 4255 | aPrevName = aParentName; |
| 4256 | } |
| 4257 | theDI << " " << aShapeName << " #" << aNumber << "\n"; |
| 4258 | break; |
| 4259 | } |
| 4260 | } |
| 4261 | } |
| 4262 | |
| 4263 | //============================================================================== |
| 4264 | //function : VState |
| 4265 | //purpose : |
| 4266 | //============================================================================== |
| 4267 | static Standard_Integer VState (Draw_Interpretor& theDI, |
| 4268 | Standard_Integer theArgNb, |
| 4269 | Standard_CString* theArgVec) |
| 4270 | { |
| 4271 | Handle(AIS_InteractiveContext) aCtx = TheAISContext(); |
| 4272 | if (aCtx.IsNull()) |
| 4273 | { |
| 4274 | std::cerr << "Error: No opened viewer!\n"; |
| 4275 | return 1; |
| 4276 | } |
| 4277 | |
| 4278 | Standard_Boolean toPrintEntities = Standard_False; |
| 4279 | Standard_Boolean toCheckSelected = Standard_False; |
| 4280 | |
| 4281 | for (Standard_Integer anArgIdx = 1; anArgIdx < theArgNb; ++anArgIdx) |
| 4282 | { |
| 4283 | TCollection_AsciiString anOption (theArgVec[anArgIdx]); |
| 4284 | anOption.LowerCase(); |
| 4285 | if (anOption == "-detectedentities" |
| 4286 | || anOption == "-entities") |
| 4287 | { |
| 4288 | toPrintEntities = Standard_True; |
| 4289 | } |
| 4290 | else if (anOption == "-hasselected") |
| 4291 | { |
| 4292 | toCheckSelected = Standard_True; |
| 4293 | } |
| 4294 | } |
| 4295 | |
| 4296 | if (toCheckSelected) |
| 4297 | { |
| 4298 | aCtx->InitSelected(); |
| 4299 | TCollection_AsciiString hasSelected (static_cast<Standard_Integer> (aCtx->HasSelectedShape())); |
| 4300 | theDI << "Check if context has selected shape: " << hasSelected << "\n"; |
| 4301 | |
| 4302 | return 0; |
| 4303 | } |
| 4304 | |
| 4305 | if (toPrintEntities) |
| 4306 | { |
| 4307 | theDI << "Detected entities:\n"; |
| 4308 | Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector(); |
| 4309 | for (aSelector->InitDetected(); aSelector->MoreDetected(); aSelector->NextDetected()) |
| 4310 | { |
| 4311 | const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->DetectedEntity(); |
| 4312 | Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); |
| 4313 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); |
| 4314 | SelectMgr_SelectingVolumeManager aMgr = anObj->HasTransformation() ? aSelector->GetManager().Transform (anObj->InversedTransformation()) |
| 4315 | : aSelector->GetManager(); |
| 4316 | SelectBasics_PickResult aResult; |
| 4317 | anEntity->Matches (aMgr, aResult); |
| 4318 | NCollection_Vec3<Standard_Real> aDetectedPnt = aMgr.DetectedPoint (aResult.Depth()); |
| 4319 | |
| 4320 | TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj); |
| 4321 | aName.LeftJustify (20, ' '); |
| 4322 | char anInfoStr[512]; |
| 4323 | Sprintf (anInfoStr, |
| 4324 | " Depth: %+.3f Distance: %+.3f Point: %+.3f %+.3f %+.3f", |
| 4325 | aResult.Depth(), |
| 4326 | aResult.DistToGeomCenter(), |
| 4327 | aDetectedPnt.x(), aDetectedPnt.y(), aDetectedPnt.z()); |
| 4328 | theDI << " " << aName |
| 4329 | << anInfoStr |
| 4330 | << " (" << anEntity->DynamicType()->Name() << ")" |
| 4331 | << "\n"; |
| 4332 | |
| 4333 | Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner); |
| 4334 | if (!aBRepOwner.IsNull()) |
| 4335 | { |
| 4336 | theDI << " Detected Shape: " |
| 4337 | << aBRepOwner->Shape().TShape()->DynamicType()->Name() |
| 4338 | << "\n"; |
| 4339 | } |
| 4340 | |
| 4341 | Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast (anEntity); |
| 4342 | if (!aWire.IsNull()) |
| 4343 | { |
| 4344 | Handle(Select3D_SensitiveEntity) aSen = aWire->GetLastDetected(); |
| 4345 | theDI << " Detected Child: " |
| 4346 | << aSen->DynamicType()->Name() |
| 4347 | << "\n"; |
| 4348 | } |
| 4349 | } |
| 4350 | return 0; |
| 4351 | } |
| 4352 | |
| 4353 | NCollection_Map<Handle(AIS_InteractiveObject)> aDetected; |
| 4354 | for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected()) |
| 4355 | { |
| 4356 | aDetected.Add (aCtx->DetectedCurrentObject()); |
| 4357 | } |
| 4358 | |
| 4359 | const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*'); |
| 4360 | if (theArgNb >= 2 |
| 4361 | && !toShowAll) |
| 4362 | { |
| 4363 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
| 4364 | { |
| 4365 | const TCollection_AsciiString anObjName = theArgVec[anArgIter]; |
| 4366 | if (!GetMapOfAIS().IsBound2 (anObjName)) |
| 4367 | { |
| 4368 | theDI << anObjName << " doesn't exist!\n"; |
| 4369 | continue; |
| 4370 | } |
| 4371 | |
| 4372 | const Handle(Standard_Transient) anObjTrans = GetMapOfAIS().Find2 (anObjName); |
| 4373 | TCollection_AsciiString aName = anObjName; |
| 4374 | aName.LeftJustify (20, ' '); |
| 4375 | theDI << " " << aName << " "; |
| 4376 | objInfo (aDetected, anObjTrans, theDI); |
| 4377 | theDI << "\n"; |
| 4378 | } |
| 4379 | return 0; |
| 4380 | } |
| 4381 | |
| 4382 | if (aCtx->NbCurrents() > 0 |
| 4383 | && !toShowAll) |
| 4384 | { |
| 4385 | for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent()) |
| 4386 | { |
| 4387 | Handle(AIS_InteractiveObject) anObj = aCtx->Current(); |
| 4388 | TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj); |
| 4389 | aName.LeftJustify (20, ' '); |
| 4390 | theDI << aName << " "; |
| 4391 | objInfo (aDetected, anObj, theDI); |
| 4392 | theDI << "\n"; |
| 4393 | } |
| 4394 | return 0; |
| 4395 | } |
| 4396 | |
| 4397 | theDI << "Neutral-point state:\n"; |
| 4398 | for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); |
| 4399 | anObjIter.More(); anObjIter.Next()) |
| 4400 | { |
| 4401 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anObjIter.Key1()); |
| 4402 | if (anObj.IsNull()) |
| 4403 | { |
| 4404 | continue; |
| 4405 | } |
| 4406 | |
| 4407 | TCollection_AsciiString aName = anObjIter.Key2(); |
| 4408 | aName.LeftJustify (20, ' '); |
| 4409 | theDI << " " << aName << " "; |
| 4410 | objInfo (aDetected, anObj, theDI); |
| 4411 | theDI << "\n"; |
| 4412 | } |
| 4413 | localCtxInfo (theDI); |
| 4414 | return 0; |
| 4415 | } |
| 4416 | |
| 4417 | //======================================================================= |
| 4418 | //function : PickObjects |
| 4419 | //purpose : |
| 4420 | //======================================================================= |
| 4421 | Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& arr, |
| 4422 | const AIS_KindOfInteractive TheType, |
| 4423 | const Standard_Integer TheSignature, |
| 4424 | const Standard_Integer MaxPick) |
| 4425 | { |
| 4426 | Handle(AIS_InteractiveObject) IO; |
| 4427 | Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext(); |
| 4428 | |
| 4429 | // step 1: prepare the data |
| 4430 | if(curindex !=0){ |
| 4431 | Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature); |
| 4432 | TheAISContext()->AddFilter(F1); |
| 4433 | } |
| 4434 | |
| 4435 | // step 2 : wait for the selection... |
| 4436 | // Standard_Boolean IsGood (Standard_False); |
| 4437 | // Standard_Integer NbPick(0); |
| 4438 | Standard_Boolean NbPickGood (0),NbToReach(arr->Length()); |
| 4439 | Standard_Integer NbPickFail(0); |
| 4440 | Standard_Integer argccc = 5; |
| 4441 | const char *bufff[] = { "A", "B", "C","D", "E" }; |
| 4442 | const char **argvvv = (const char **) bufff; |
| 4443 | |
| 4444 | |
| 4445 | while(NbPickGood<NbToReach && NbPickFail <= MaxPick){ |
| 4446 | while(ViewerMainLoop(argccc,argvvv)){} |
| 4447 | Standard_Integer NbStored = TheAISContext()->NbSelected(); |
| 4448 | if((unsigned int ) NbStored != NbPickGood) |
| 4449 | NbPickGood= NbStored; |
| 4450 | else |
| 4451 | NbPickFail++; |
| 4452 | cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<endl; |
| 4453 | } |
| 4454 | |
| 4455 | // step3 get result. |
| 4456 | |
| 4457 | if((unsigned int ) NbPickFail >= NbToReach) return Standard_False; |
| 4458 | |
| 4459 | Standard_Integer i(0); |
| 4460 | for(TheAISContext()->InitSelected(); |
| 4461 | TheAISContext()->MoreSelected(); |
| 4462 | TheAISContext()->NextSelected()){ |
| 4463 | i++; |
| 4464 | Handle(AIS_InteractiveObject) IO2 = TheAISContext()->SelectedInteractive(); |
| 4465 | arr->SetValue(i,IO2); |
| 4466 | } |
| 4467 | |
| 4468 | |
| 4469 | if(curindex>0) |
| 4470 | TheAISContext()->CloseLocalContext(curindex); |
| 4471 | |
| 4472 | return Standard_True; |
| 4473 | } |
| 4474 | |
| 4475 | |
| 4476 | //======================================================================= |
| 4477 | //function : PickObject |
| 4478 | //purpose : |
| 4479 | //======================================================================= |
| 4480 | Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive TheType, |
| 4481 | const Standard_Integer TheSignature, |
| 4482 | const Standard_Integer MaxPick) |
| 4483 | { |
| 4484 | Handle(AIS_InteractiveObject) IO; |
| 4485 | Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext(); |
| 4486 | |
| 4487 | // step 1: prepare the data |
| 4488 | |
| 4489 | if(curindex !=0){ |
| 4490 | Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature); |
| 4491 | TheAISContext()->AddFilter(F1); |
| 4492 | } |
| 4493 | |
| 4494 | // step 2 : wait for the selection... |
| 4495 | Standard_Boolean IsGood (Standard_False); |
| 4496 | Standard_Integer NbPick(0); |
| 4497 | Standard_Integer argccc = 5; |
| 4498 | const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; |
| 4499 | const char **argvvv = (const char **) bufff; |
| 4500 | |
| 4501 | |
| 4502 | while(!IsGood && NbPick<= MaxPick){ |
| 4503 | while(ViewerMainLoop(argccc,argvvv)){} |
| 4504 | IsGood = (TheAISContext()->NbSelected()>0) ; |
| 4505 | NbPick++; |
| 4506 | cout<<"Nb Pick :"<<NbPick<<endl; |
| 4507 | } |
| 4508 | |
| 4509 | |
| 4510 | // step3 get result. |
| 4511 | if(IsGood){ |
| 4512 | TheAISContext()->InitSelected(); |
| 4513 | IO = TheAISContext()->SelectedInteractive(); |
| 4514 | } |
| 4515 | |
| 4516 | if(curindex!=0) |
| 4517 | TheAISContext()->CloseLocalContext(curindex); |
| 4518 | return IO; |
| 4519 | } |
| 4520 | |
| 4521 | //======================================================================= |
| 4522 | //function : PickShape |
| 4523 | //purpose : First Activate the rightmode + Put Filters to be able to |
| 4524 | // pick objets that are of type <TheType>... |
| 4525 | //======================================================================= |
| 4526 | |
| 4527 | TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType, |
| 4528 | const Standard_Integer MaxPick) |
| 4529 | { |
| 4530 | |
| 4531 | // step 1: prepare the data |
| 4532 | |
| 4533 | Standard_Integer curindex = TheAISContext()->OpenLocalContext(); |
| 4534 | TopoDS_Shape result; |
| 4535 | |
| 4536 | if(TheType==TopAbs_SHAPE){ |
| 4537 | Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape); |
| 4538 | TheAISContext()->AddFilter(F1); |
| 4539 | } |
| 4540 | else{ |
| 4541 | Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); |
| 4542 | TheAISContext()->AddFilter(TF); |
| 4543 | TheAISContext()->ActivateStandardMode(TheType); |
| 4544 | |
| 4545 | } |
| 4546 | |
| 4547 | |
| 4548 | // step 2 : wait for the selection... |
| 4549 | Standard_Boolean NoShape (Standard_True); |
| 4550 | Standard_Integer NbPick(0); |
| 4551 | Standard_Integer argccc = 5; |
| 4552 | const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; |
| 4553 | const char **argvvv = (const char **) bufff; |
| 4554 | |
| 4555 | |
| 4556 | while(NoShape && NbPick<= MaxPick){ |
| 4557 | while(ViewerMainLoop(argccc,argvvv)){} |
| 4558 | NoShape = (TheAISContext()->NbSelected()==0) ; |
| 4559 | NbPick++; |
| 4560 | cout<<"Nb Pick :"<<NbPick<<endl; |
| 4561 | } |
| 4562 | |
| 4563 | // step3 get result. |
| 4564 | |
| 4565 | if(!NoShape){ |
| 4566 | |
| 4567 | TheAISContext()->InitSelected(); |
| 4568 | if(TheAISContext()->HasSelectedShape()) |
| 4569 | result = TheAISContext()->SelectedShape(); |
| 4570 | else{ |
| 4571 | Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive(); |
| 4572 | result = Handle(AIS_Shape)::DownCast (IO)->Shape(); |
| 4573 | } |
| 4574 | } |
| 4575 | |
| 4576 | if(curindex>0) |
| 4577 | TheAISContext()->CloseLocalContext(curindex); |
| 4578 | |
| 4579 | return result; |
| 4580 | } |
| 4581 | |
| 4582 | |
| 4583 | //======================================================================= |
| 4584 | //function : PickShapes |
| 4585 | //purpose : |
| 4586 | //======================================================================= |
| 4587 | Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType, |
| 4588 | Handle(TopTools_HArray1OfShape)& thearr, |
| 4589 | const Standard_Integer MaxPick) |
| 4590 | { |
| 4591 | |
| 4592 | Standard_Integer Taille = thearr->Length(); |
| 4593 | if(Taille>1) |
| 4594 | cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object"<<"\n"; |
| 4595 | |
| 4596 | // step 1: prepare the data |
| 4597 | Standard_Integer curindex = TheAISContext()->OpenLocalContext(); |
| 4598 | if(TheType==TopAbs_SHAPE){ |
| 4599 | Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape); |
| 4600 | TheAISContext()->AddFilter(F1); |
| 4601 | } |
| 4602 | else{ |
| 4603 | Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); |
| 4604 | TheAISContext()->AddFilter(TF); |
| 4605 | TheAISContext()->ActivateStandardMode(TheType); |
| 4606 | |
| 4607 | } |
| 4608 | |
| 4609 | // step 2 : wait for the selection... |
| 4610 | |
| 4611 | Standard_Boolean NbPickGood (0),NbToReach(thearr->Length()); |
| 4612 | Standard_Integer NbPickFail(0); |
| 4613 | Standard_Integer argccc = 5; |
| 4614 | const char *bufff[] = { "A", "B", "C","D", "E" }; |
| 4615 | const char **argvvv = (const char **) bufff; |
| 4616 | |
| 4617 | |
| 4618 | while(NbPickGood<NbToReach && NbPickFail <= MaxPick){ |
| 4619 | while(ViewerMainLoop(argccc,argvvv)){} |
| 4620 | Standard_Integer NbStored = TheAISContext()->NbSelected(); |
| 4621 | if((unsigned int ) NbStored != NbPickGood) |
| 4622 | NbPickGood= NbStored; |
| 4623 | else |
| 4624 | NbPickFail++; |
| 4625 | cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<"\n"; |
| 4626 | } |
| 4627 | |
| 4628 | // step3 get result. |
| 4629 | |
| 4630 | if((unsigned int ) NbPickFail >= NbToReach) return Standard_False; |
| 4631 | |
| 4632 | Standard_Integer i(0); |
| 4633 | for(TheAISContext()->InitSelected();TheAISContext()->MoreSelected();TheAISContext()->NextSelected()){ |
| 4634 | i++; |
| 4635 | if(TheAISContext()->HasSelectedShape()) |
| 4636 | thearr->SetValue(i,TheAISContext()->SelectedShape()); |
| 4637 | else{ |
| 4638 | Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive(); |
| 4639 | thearr->SetValue(i,Handle(AIS_Shape)::DownCast (IO)->Shape()); |
| 4640 | } |
| 4641 | } |
| 4642 | |
| 4643 | TheAISContext()->CloseLocalContext(curindex); |
| 4644 | return Standard_True; |
| 4645 | } |
| 4646 | |
| 4647 | |
| 4648 | //======================================================================= |
| 4649 | //function : VPickShape |
| 4650 | //purpose : |
| 4651 | //======================================================================= |
| 4652 | static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
| 4653 | { |
| 4654 | TopoDS_Shape PickSh; |
| 4655 | TopAbs_ShapeEnum theType = TopAbs_COMPOUND; |
| 4656 | |
| 4657 | if(argc==1) |
| 4658 | theType = TopAbs_SHAPE; |
| 4659 | else{ |
| 4660 | if(!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX; |
| 4661 | else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE; |
| 4662 | else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE; |
| 4663 | else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE; |
| 4664 | else if(!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE; |
| 4665 | else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL; |
| 4666 | else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID; |
| 4667 | } |
| 4668 | |
| 4669 | static Standard_Integer nbOfSub[8]={0,0,0,0,0,0,0,0}; |
| 4670 | static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"}; |
| 4671 | |
| 4672 | TCollection_AsciiString name; |
| 4673 | |
| 4674 | |
| 4675 | Standard_Integer NbToPick = argc>2 ? argc-2 : 1; |
| 4676 | if(NbToPick==1){ |
| 4677 | PickSh = ViewerTest::PickShape(theType); |
| 4678 | |
| 4679 | if(PickSh.IsNull()) |
| 4680 | return 1; |
| 4681 | if(argc>2){ |
| 4682 | name += argv[2]; |
| 4683 | } |
| 4684 | else{ |
| 4685 | |
| 4686 | if(!PickSh.IsNull()){ |
| 4687 | nbOfSub[Standard_Integer(theType)]++; |
| 4688 | name += "Picked_"; |
| 4689 | name += nameType[Standard_Integer(theType)]; |
| 4690 | TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]); |
| 4691 | name +="_"; |
| 4692 | name+=indxstring; |
| 4693 | } |
| 4694 | } |
| 4695 | // si on avait une petite methode pour voir si la shape |
| 4696 | // est deja dans la Double map, ca eviterait de creer.... |
| 4697 | DBRep::Set(name.ToCString(),PickSh); |
| 4698 | |
| 4699 | Handle(AIS_Shape) newsh = new AIS_Shape(PickSh); |
| 4700 | GetMapOfAIS().Bind(newsh, name); |
| 4701 | TheAISContext()->Display(newsh); |
| 4702 | di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n"; |
| 4703 | } |
| 4704 | |
| 4705 | // Plusieurs objets a picker, vite vite vite.... |
| 4706 | // |
| 4707 | else{ |
| 4708 | Standard_Boolean autonaming = !strcasecmp(argv[2],"."); |
| 4709 | Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick); |
| 4710 | if(ViewerTest::PickShapes(theType,arr)){ |
| 4711 | for(Standard_Integer i=1;i<=NbToPick;i++){ |
| 4712 | PickSh = arr->Value(i); |
| 4713 | if(!PickSh.IsNull()){ |
| 4714 | if(autonaming){ |
| 4715 | nbOfSub[Standard_Integer(theType)]++; |
| 4716 | name.Clear(); |
| 4717 | name += "Picked_"; |
| 4718 | name += nameType[Standard_Integer(theType)]; |
| 4719 | TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]); |
| 4720 | name +="_"; |
| 4721 | name+=indxstring; |
| 4722 | } |
| 4723 | } |
| 4724 | else |
| 4725 | name = argv[1+i]; |
| 4726 | |
| 4727 | DBRep::Set(name.ToCString(),PickSh); |
| 4728 | Handle(AIS_Shape) newsh = new AIS_Shape(PickSh); |
| 4729 | GetMapOfAIS().Bind(newsh, name); |
| 4730 | di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n"; |
| 4731 | TheAISContext()->Display(newsh); |
| 4732 | |
| 4733 | } |
| 4734 | } |
| 4735 | } |
| 4736 | return 0; |
| 4737 | } |
| 4738 | |
| 4739 | //======================================================================= |
| 4740 | //function : VPickSelected |
| 4741 | //purpose : |
| 4742 | //======================================================================= |
| 4743 | static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgs) |
| 4744 | { |
| 4745 | static Standard_Integer aCount = 0; |
| 4746 | TCollection_AsciiString aName = "PickedShape_"; |
| 4747 | |
| 4748 | if (theArgNb > 1) |
| 4749 | { |
| 4750 | aName = theArgs[1]; |
| 4751 | } |
| 4752 | else |
| 4753 | { |
| 4754 | aName = aName + aCount++ + "_"; |
| 4755 | } |
| 4756 | |
| 4757 | Standard_Integer anIdx = 0; |
| 4758 | for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected(), ++anIdx) |
| 4759 | { |
| 4760 | TopoDS_Shape aShape; |
| 4761 | if (TheAISContext()->HasSelectedShape()) |
| 4762 | { |
| 4763 | aShape = TheAISContext()->SelectedShape(); |
| 4764 | } |
| 4765 | else |
| 4766 | { |
| 4767 | Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive(); |
| 4768 | aShape = Handle(AIS_Shape)::DownCast (IO)->Shape(); |
| 4769 | } |
| 4770 | |
| 4771 | TCollection_AsciiString aCurrentName = aName; |
| 4772 | if (anIdx > 0) |
| 4773 | { |
| 4774 | aCurrentName += anIdx; |
| 4775 | } |
| 4776 | |
| 4777 | DBRep::Set ((aCurrentName).ToCString(), aShape); |
| 4778 | |
| 4779 | Handle(AIS_Shape) aNewShape = new AIS_Shape (aShape); |
| 4780 | GetMapOfAIS().Bind (aNewShape, aCurrentName); |
| 4781 | TheAISContext()->Display (aNewShape); |
| 4782 | } |
| 4783 | |
| 4784 | return 0; |
| 4785 | } |
| 4786 | |
| 4787 | //======================================================================= |
| 4788 | //function : list of known objects |
| 4789 | //purpose : |
| 4790 | //======================================================================= |
| 4791 | static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** ) |
| 4792 | { |
| 4793 | // 1234567890 12345678901234567 123456789 |
| 4794 | TCollection_AsciiString Colum [3]={"Standard Types","Type Of Object","Signature"}; |
| 4795 | TCollection_AsciiString BlankLine(64,'_'); |
| 4796 | Standard_Integer i ; |
| 4797 | |
| 4798 | di<<"/n"<<BlankLine.ToCString()<<"\n"; |
| 4799 | |
| 4800 | for( i =0;i<=2;i++) |
| 4801 | Colum[i].Center(20,' '); |
| 4802 | for(i=0;i<=2;i++) |
| 4803 | di<<"|"<<Colum[i].ToCString(); |
| 4804 | di<<"|"<<"\n"; |
| 4805 | |
| 4806 | di<<BlankLine.ToCString()<<"\n"; |
| 4807 | |
| 4808 | // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"}; |
| 4809 | const char ** names = GetTypeNames(); |
| 4810 | |
| 4811 | TCollection_AsciiString curstring; |
| 4812 | TCollection_AsciiString curcolum[3]; |
| 4813 | |
| 4814 | |
| 4815 | // les objets de type Datum.. |
| 4816 | curcolum[1]+="Datum"; |
| 4817 | for(i =0;i<=6;i++){ |
| 4818 | curcolum[0].Clear(); |
| 4819 | curcolum[0] += names[i]; |
| 4820 | |
| 4821 | curcolum[2].Clear(); |
| 4822 | curcolum[2]+=TCollection_AsciiString(i+1); |
| 4823 | |
| 4824 | for(Standard_Integer j =0;j<=2;j++){ |
| 4825 | curcolum[j].Center(20,' '); |
| 4826 | di<<"|"<<curcolum[j].ToCString(); |
| 4827 | } |
| 4828 | di<<"|"<<"\n"; |
| 4829 | } |
| 4830 | di<<BlankLine.ToCString()<<"\n"; |
| 4831 | |
| 4832 | // les objets de type shape |
| 4833 | curcolum[1].Clear(); |
| 4834 | curcolum[1]+="Shape"; |
| 4835 | curcolum[1].Center(20,' '); |
| 4836 | |
| 4837 | for(i=0;i<=2;i++){ |
| 4838 | curcolum[0].Clear(); |
| 4839 | curcolum[0] += names[7+i]; |
| 4840 | curcolum[2].Clear(); |
| 4841 | curcolum[2]+=TCollection_AsciiString(i); |
| 4842 | |
| 4843 | for(Standard_Integer j =0;j<=2;j++){ |
| 4844 | curcolum[j].Center(20,' '); |
| 4845 | di<<"|"<<curcolum[j].ToCString(); |
| 4846 | } |
| 4847 | di<<"|"<<"\n"; |
| 4848 | } |
| 4849 | di<<BlankLine.ToCString()<<"\n"; |
| 4850 | // les IO de type objet... |
| 4851 | curcolum[1].Clear(); |
| 4852 | curcolum[1]+="Object"; |
| 4853 | curcolum[1].Center(20,' '); |
| 4854 | for(i=0;i<=1;i++){ |
| 4855 | curcolum[0].Clear(); |
| 4856 | curcolum[0] += names[10+i]; |
| 4857 | curcolum[2].Clear(); |
| 4858 | curcolum[2]+=TCollection_AsciiString(i); |
| 4859 | |
| 4860 | for(Standard_Integer j =0;j<=2;j++){ |
| 4861 | curcolum[j].Center(20,' '); |
| 4862 | di<<"|"<<curcolum[j].ToCString(); |
| 4863 | } |
| 4864 | di<<"|"<<"\n"; |
| 4865 | } |
| 4866 | di<<BlankLine.ToCString()<<"\n"; |
| 4867 | // les contraintes et dimensions. |
| 4868 | // pour l'instant on separe juste contraintes et dimensions... |
| 4869 | // plus tard, on detaillera toutes les sortes... |
| 4870 | curcolum[1].Clear(); |
| 4871 | curcolum[1]+="Relation"; |
| 4872 | curcolum[1].Center(20,' '); |
| 4873 | for(i=0;i<=1;i++){ |
| 4874 | curcolum[0].Clear(); |
| 4875 | curcolum[0] += names[12+i]; |
| 4876 | curcolum[2].Clear(); |
| 4877 | curcolum[2]+=TCollection_AsciiString(i); |
| 4878 | |
| 4879 | for(Standard_Integer j =0;j<=2;j++){ |
| 4880 | curcolum[j].Center(20,' '); |
| 4881 | di<<"|"<<curcolum[j].ToCString(); |
| 4882 | } |
| 4883 | di<<"|"<<"\n"; |
| 4884 | } |
| 4885 | di<<BlankLine.ToCString()<<"\n"; |
| 4886 | |
| 4887 | |
| 4888 | return 0; |
| 4889 | } |
| 4890 | |
| 4891 | |
| 4892 | static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv) |
| 4893 | { |
| 4894 | if(argc!=2) return 1; |
| 4895 | |
| 4896 | AIS_KindOfInteractive TheType; |
| 4897 | Standard_Integer TheSign(-1); |
| 4898 | GetTypeAndSignfromString(argv[1],TheType,TheSign); |
| 4899 | |
| 4900 | |
| 4901 | AIS_ListOfInteractive LIO; |
| 4902 | |
| 4903 | // en attendant l'amelioration ais pour les dimensions... |
| 4904 | // |
| 4905 | Standard_Integer dimension_status(-1); |
| 4906 | if(TheType==AIS_KOI_Relation){ |
| 4907 | dimension_status = TheSign ==1 ? 1 : 0; |
| 4908 | TheSign=-1; |
| 4909 | } |
| 4910 | |
| 4911 | TheAISContext()->DisplayedObjects(TheType,TheSign,LIO); |
| 4912 | Handle(AIS_InteractiveObject) curio; |
| 4913 | for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ |
| 4914 | curio = it.Value(); |
| 4915 | |
| 4916 | if(dimension_status == -1) |
| 4917 | TheAISContext()->Erase(curio,Standard_False); |
| 4918 | else { |
| 4919 | AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension(); |
| 4920 | if ((dimension_status==0 && KOD == AIS_KOD_NONE)|| |
| 4921 | (dimension_status==1 && KOD != AIS_KOD_NONE)) |
| 4922 | TheAISContext()->Erase(curio,Standard_False); |
| 4923 | } |
| 4924 | } |
| 4925 | TheAISContext()->UpdateCurrentViewer(); |
| 4926 | return 0; |
| 4927 | } |
| 4928 | static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char** argv) |
| 4929 | { |
| 4930 | if(argc!=2) return 1; |
| 4931 | |
| 4932 | AIS_KindOfInteractive TheType; |
| 4933 | Standard_Integer TheSign(-1); |
| 4934 | GetTypeAndSignfromString(argv[1],TheType,TheSign); |
| 4935 | |
| 4936 | // en attendant l'amelioration ais pour les dimensions... |
| 4937 | // |
| 4938 | Standard_Integer dimension_status(-1); |
| 4939 | if(TheType==AIS_KOI_Relation){ |
| 4940 | dimension_status = TheSign ==1 ? 1 : 0; |
| 4941 | TheSign=-1; |
| 4942 | } |
| 4943 | |
| 4944 | AIS_ListOfInteractive LIO; |
| 4945 | TheAISContext()->ObjectsInside(LIO,TheType,TheSign); |
| 4946 | Handle(AIS_InteractiveObject) curio; |
| 4947 | for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ |
| 4948 | curio = it.Value(); |
| 4949 | if(dimension_status == -1) |
| 4950 | TheAISContext()->Display(curio,Standard_False); |
| 4951 | else { |
| 4952 | AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension(); |
| 4953 | if ((dimension_status==0 && KOD == AIS_KOD_NONE)|| |
| 4954 | (dimension_status==1 && KOD != AIS_KOD_NONE)) |
| 4955 | TheAISContext()->Display(curio,Standard_False); |
| 4956 | } |
| 4957 | |
| 4958 | } |
| 4959 | |
| 4960 | TheAISContext()->UpdateCurrentViewer(); |
| 4961 | return 0; |
| 4962 | } |
| 4963 | |
| 4964 | static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a) |
| 4965 | { |
| 4966 | ifstream s(a[1]); |
| 4967 | BRep_Builder builder; |
| 4968 | TopoDS_Shape shape; |
| 4969 | BRepTools::Read(shape, s, builder); |
| 4970 | DBRep::Set(a[1], shape); |
| 4971 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
| 4972 | Handle(AIS_Shape) ais = new AIS_Shape(shape); |
| 4973 | Ctx->Display(ais); |
| 4974 | return 0; |
| 4975 | } |
| 4976 | |
| 4977 | //=============================================================================================== |
| 4978 | //function : VBsdf |
| 4979 | //purpose : |
| 4980 | //=============================================================================================== |
| 4981 | static int VBsdf (Draw_Interpretor& theDi, |
| 4982 | Standard_Integer theArgsNb, |
| 4983 | const char** theArgVec) |
| 4984 | { |
| 4985 | Handle(V3d_View) aView = ViewerTest::CurrentView(); |
| 4986 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); |
| 4987 | if (aView.IsNull() |
| 4988 | || aViewer.IsNull()) |
| 4989 | { |
| 4990 | std::cerr << "No active viewer!\n"; |
| 4991 | return 1; |
| 4992 | } |
| 4993 | |
| 4994 | ViewerTest_CmdParser aCmd; |
| 4995 | |
| 4996 | aCmd.AddDescription ("Adjusts parameters of material BSDF:"); |
| 4997 | aCmd.AddOption ("print|echo|p", "Print BSDF"); |
| 4998 | |
| 4999 | aCmd.AddOption ("kd", "Weight of the Lambertian BRDF"); |
| 5000 | aCmd.AddOption ("kr", "Weight of the reflection BRDF"); |
| 5001 | aCmd.AddOption ("kt", "Weight of the transmission BTDF"); |
| 5002 | aCmd.AddOption ("ks", "Weight of the glossy Blinn BRDF"); |
| 5003 | aCmd.AddOption ("le", "Self-emitted radiance"); |
| 5004 | |
| 5005 | aCmd.AddOption ("fresnel|f", "Fresnel coefficients; Allowed fresnel formats are: Constant x, Schlick x y z, Dielectric x, Conductor x y"); |
| 5006 | |
| 5007 | aCmd.AddOption ("roughness|r", "Roughness of material (Blinn's exponent)"); |
| 5008 | aCmd.AddOption ("absorpCoeff|af", "Absorption coeff (only for transparent material)"); |
| 5009 | aCmd.AddOption ("absorpColor|ac", "Absorption color (only for transparent material)"); |
| 5010 | |
| 5011 | aCmd.AddOption ("normalize|n", "Normalize BSDF coefficients"); |
| 5012 | |
| 5013 | aCmd.Parse (theArgsNb, theArgVec); |
| 5014 | |
| 5015 | if (aCmd.HasOption ("help")) |
| 5016 | { |
| 5017 | theDi.PrintHelp (theArgVec[0]); |
| 5018 | return 0; |
| 5019 | } |
| 5020 | |
| 5021 | TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str()); |
| 5022 | |
| 5023 | // find object |
| 5024 | ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); |
| 5025 | if (!aMap.IsBound2 (aName) ) |
| 5026 | { |
| 5027 | std::cerr << "Use 'vdisplay' before" << "\n"; |
| 5028 | return 1; |
| 5029 | } |
| 5030 | |
| 5031 | Handle(AIS_InteractiveObject) anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName)); |
| 5032 | Graphic3d_MaterialAspect aMaterial = anIObj->Attributes()->ShadingAspect()->Material(); |
| 5033 | Graphic3d_BSDF aBSDF = aMaterial.BSDF(); |
| 5034 | |
| 5035 | if (aCmd.HasOption ("print")) |
| 5036 | { |
| 5037 | Graphic3d_Vec4 aFresnel = aBSDF.Fresnel.Serialize(); |
| 5038 | |
| 5039 | std::cout << "\n" |
| 5040 | << "Kd: " << aBSDF.Kd.r() << ", " << aBSDF.Kd.g() << ", " << aBSDF.Kd.b() << "\n" |
| 5041 | << "Kr: " << aBSDF.Kr.r() << ", " << aBSDF.Kr.g() << ", " << aBSDF.Kr.b() << "\n" |
| 5042 | << "Kt: " << aBSDF.Kt.r() << ", " << aBSDF.Kt.g() << ", " << aBSDF.Kt.b() << "\n" |
| 5043 | << "Ks: " << aBSDF.Ks.r() << ", " << aBSDF.Ks.g() << ", " << aBSDF.Ks.b() << "\n" |
| 5044 | << "Le: " << aBSDF.Le.r() << ", " << aBSDF.Le.g() << ", " << aBSDF.Le.b() << "\n" |
| 5045 | << "Fresnel: "; |
| 5046 | |
| 5047 | if (aFresnel.x() >= 0.f) |
| 5048 | { |
| 5049 | std::cout |
| 5050 | << "|Schlick| " << aFresnel.x() << ", " << aFresnel.y() << ", " << aFresnel.z() << "\n"; |
| 5051 | } |
| 5052 | else if (aFresnel.x() >= -1.5f) |
| 5053 | { |
| 5054 | std::cout |
| 5055 | << "|Constant| " << aFresnel.z() << "\n"; |
| 5056 | } |
| 5057 | else if (aFresnel.x() >= -2.5f) |
| 5058 | { |
| 5059 | std::cout |
| 5060 | << "|Conductor| " << aFresnel.y() << ", " << aFresnel.z() << "\n"; |
| 5061 | } |
| 5062 | else |
| 5063 | { |
| 5064 | std::cout |
| 5065 | << "|Dielectric| " << aFresnel.y() << "\n"; |
| 5066 | } |
| 5067 | |
| 5068 | |
| 5069 | std::cout |
| 5070 | << "Roughness: " << aBSDF.Roughness << "\n" |
| 5071 | << "Absorption coeff: " << aBSDF.AbsorptionCoeff << "\n" |
| 5072 | << "Absorption color: " << aBSDF.AbsorptionColor.r() << ", " |
| 5073 | << aBSDF.AbsorptionColor.g() << ", " |
| 5074 | << aBSDF.AbsorptionColor.b() << "\n"; |
| 5075 | |
| 5076 | return 0; |
| 5077 | } |
| 5078 | |
| 5079 | if (aCmd.HasOption ("roughness", 1, Standard_True)) |
| 5080 | { |
| 5081 | aCmd.Arg ("roughness", 0); |
| 5082 | aBSDF.Roughness = aCmd.ArgFloat ("roughness"); |
| 5083 | } |
| 5084 | |
| 5085 | if (aCmd.HasOption ("absorpCoeff", 1, Standard_True)) |
| 5086 | { |
| 5087 | aBSDF.AbsorptionCoeff = aCmd.ArgFloat ("absorpCoeff"); |
| 5088 | } |
| 5089 | |
| 5090 | if (aCmd.HasOption ("absorpColor", 3, Standard_True)) |
| 5091 | { |
| 5092 | aBSDF.AbsorptionColor = aCmd.ArgVec3f ("absorpColor"); |
| 5093 | } |
| 5094 | |
| 5095 | if (aCmd.HasOption ("kd", 3)) |
| 5096 | { |
| 5097 | aBSDF.Kd = aCmd.ArgVec3f ("kd"); |
| 5098 | } |
| 5099 | else if (aCmd.HasOption ("kd", 1, Standard_True)) |
| 5100 | { |
| 5101 | aBSDF.Kd = Graphic3d_Vec3 (aCmd.ArgFloat ("kd")); |
| 5102 | } |
| 5103 | |
| 5104 | if (aCmd.HasOption ("kr", 3)) |
| 5105 | { |
| 5106 | aBSDF.Kr = aCmd.ArgVec3f ("kr"); |
| 5107 | } |
| 5108 | else if (aCmd.HasOption ("kr", 1, Standard_True)) |
| 5109 | { |
| 5110 | aBSDF.Kr = Graphic3d_Vec3 (aCmd.ArgFloat ("kr")); |
| 5111 | } |
| 5112 | |
| 5113 | if (aCmd.HasOption ("kt", 3)) |
| 5114 | { |
| 5115 | aBSDF.Kt = aCmd.ArgVec3f ("kt"); |
| 5116 | } |
| 5117 | else if (aCmd.HasOption ("kt", 1, Standard_True)) |
| 5118 | { |
| 5119 | aBSDF.Kt = Graphic3d_Vec3 (aCmd.ArgFloat ("kt")); |
| 5120 | } |
| 5121 | |
| 5122 | if (aCmd.HasOption ("ks", 3)) |
| 5123 | { |
| 5124 | aBSDF.Ks = aCmd.ArgVec3f ("ks"); |
| 5125 | } |
| 5126 | else if (aCmd.HasOption ("ks", 1, Standard_True)) |
| 5127 | { |
| 5128 | aBSDF.Ks = Graphic3d_Vec3 (aCmd.ArgFloat ("ks")); |
| 5129 | } |
| 5130 | |
| 5131 | if (aCmd.HasOption ("le", 3)) |
| 5132 | { |
| 5133 | aBSDF.Le = aCmd.ArgVec3f ("le"); |
| 5134 | } |
| 5135 | else if (aCmd.HasOption ("le", 1, Standard_True)) |
| 5136 | { |
| 5137 | aBSDF.Le = Graphic3d_Vec3 (aCmd.ArgFloat ("le")); |
| 5138 | } |
| 5139 | |
| 5140 | const std::string aFresnelErrorMessage = |
| 5141 | "Error! Wrong Fresnel type. Allowed types are: Constant x, Schlick x y z, Dielectric x, Conductor x y.\n"; |
| 5142 | |
| 5143 | if (aCmd.HasOption ("fresnel", 4)) // Schlick: type, x, y ,z |
| 5144 | { |
| 5145 | std::string aFresnelType = aCmd.Arg ("fresnel", 0); |
| 5146 | std::transform (aFresnelType.begin(), aFresnelType.end(), aFresnelType.begin(), ::tolower); |
| 5147 | |
| 5148 | if (aFresnelType == "schlick") |
| 5149 | { |
| 5150 | aBSDF.Fresnel = Graphic3d_Fresnel::CreateSchlick ( |
| 5151 | Graphic3d_Vec3 (static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str())), |
| 5152 | static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 2).c_str())), |
| 5153 | static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 3).c_str())))); |
| 5154 | } |
| 5155 | else |
| 5156 | { |
| 5157 | std::cout << aFresnelErrorMessage; |
| 5158 | } |
| 5159 | } |
| 5160 | else if (aCmd.HasOption ("fresnel", 3)) // Conductor: type, x, y |
| 5161 | { |
| 5162 | std::string aFresnelType = aCmd.Arg ("fresnel", 0); |
| 5163 | std::transform (aFresnelType.begin(), aFresnelType.end(), aFresnelType.begin(), ::tolower); |
| 5164 | |
| 5165 | if (aFresnelType == "conductor") |
| 5166 | { |
| 5167 | aBSDF.Fresnel = Graphic3d_Fresnel::CreateConductor ( |
| 5168 | static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str())), |
| 5169 | static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 2).c_str()))); |
| 5170 | } |
| 5171 | else |
| 5172 | { |
| 5173 | std::cout << aFresnelErrorMessage; |
| 5174 | } |
| 5175 | } |
| 5176 | else if (aCmd.HasOption ("fresnel", 2)) // Dielectric, Constant: type, x |
| 5177 | { |
| 5178 | std::string aFresnelType = aCmd.Arg ("fresnel", 0); |
| 5179 | std::transform (aFresnelType.begin(), aFresnelType.end(), aFresnelType.begin(), ::tolower); |
| 5180 | |
| 5181 | if (aFresnelType == "dielectric") |
| 5182 | { |
| 5183 | aBSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric ( |
| 5184 | static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str()))); |
| 5185 | } |
| 5186 | else if (aFresnelType == "constant") |
| 5187 | { |
| 5188 | aBSDF.Fresnel = Graphic3d_Fresnel::CreateConstant ( |
| 5189 | static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str()))); |
| 5190 | } |
| 5191 | else |
| 5192 | { |
| 5193 | std::cout << aFresnelErrorMessage; |
| 5194 | } |
| 5195 | } |
| 5196 | |
| 5197 | if (aCmd.HasOption ("normalize")) |
| 5198 | { |
| 5199 | aBSDF.Normalize(); |
| 5200 | } |
| 5201 | |
| 5202 | aMaterial.SetBSDF (aBSDF); |
| 5203 | anIObj->SetMaterial (aMaterial); |
| 5204 | |
| 5205 | aView->Redraw(); |
| 5206 | |
| 5207 | return 0; |
| 5208 | } |
| 5209 | |
| 5210 | //============================================================================== |
| 5211 | //function : VLoadSelection |
| 5212 | //purpose : Adds given objects to map of AIS and loads selection primitives for them |
| 5213 | //============================================================================== |
| 5214 | static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/, |
| 5215 | Standard_Integer theArgNb, |
| 5216 | const char** theArgVec) |
| 5217 | { |
| 5218 | if (theArgNb < 2) |
| 5219 | { |
| 5220 | std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n"; |
| 5221 | return 1; |
| 5222 | } |
| 5223 | |
| 5224 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
| 5225 | if (aCtx.IsNull()) |
| 5226 | { |
| 5227 | ViewerTest::ViewerInit(); |
| 5228 | aCtx = ViewerTest::GetAISContext(); |
| 5229 | } |
| 5230 | |
| 5231 | // Parse input arguments |
| 5232 | TColStd_SequenceOfAsciiString aNamesOfIO; |
| 5233 | Standard_Boolean isLocal = Standard_False; |
| 5234 | for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) |
| 5235 | { |
| 5236 | const TCollection_AsciiString aName = theArgVec[anArgIter]; |
| 5237 | TCollection_AsciiString aNameCase = aName; |
| 5238 | aNameCase.LowerCase(); |
| 5239 | if (aNameCase == "-local") |
| 5240 | { |
| 5241 | isLocal = Standard_True; |
| 5242 | } |
| 5243 | else |
| 5244 | { |
| 5245 | aNamesOfIO.Append (aName); |
| 5246 | } |
| 5247 | } |
| 5248 | |
| 5249 | if (aNamesOfIO.IsEmpty()) |
| 5250 | { |
| 5251 | std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n"; |
| 5252 | return 1; |
| 5253 | } |
| 5254 | |
| 5255 | // Prepare context |
| 5256 | if (isLocal && !aCtx->HasOpenedContext()) |
| 5257 | { |
| 5258 | aCtx->OpenLocalContext (Standard_False); |
| 5259 | } |
| 5260 | else if (!isLocal && aCtx->HasOpenedContext()) |
| 5261 | { |
| 5262 | aCtx->CloseAllContexts (Standard_False); |
| 5263 | } |
| 5264 | |
| 5265 | // Load selection of interactive objects |
| 5266 | for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter) |
| 5267 | { |
| 5268 | const TCollection_AsciiString& aName = aNamesOfIO.Value (anIter); |
| 5269 | |
| 5270 | const Handle(AIS_InteractiveObject)& aShape = GetMapOfAIS().IsBound2 (aName) ? |
| 5271 | Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)) : GetAISShapeFromName (aName.ToCString()); |
| 5272 | |
| 5273 | if (!aShape.IsNull()) |
| 5274 | { |
| 5275 | if (!GetMapOfAIS().IsBound2 (aName)) |
| 5276 | { |
| 5277 | GetMapOfAIS().Bind (aShape, aName); |
| 5278 | } |
| 5279 | |
| 5280 | aCtx->Load (aShape, -1, Standard_False); |
| 5281 | aCtx->Activate (aShape, aShape->SelectionMode(), Standard_True); |
| 5282 | } |
| 5283 | } |
| 5284 | |
| 5285 | return 0; |
| 5286 | } |
| 5287 | |
| 5288 | //============================================================================== |
| 5289 | //function : VAutoActivateSelection |
| 5290 | //purpose : Activates or deactivates auto computation of selection |
| 5291 | //============================================================================== |
| 5292 | static int VAutoActivateSelection (Draw_Interpretor& theDi, |
| 5293 | Standard_Integer theArgNb, |
| 5294 | const char** theArgVec) |
| 5295 | { |
| 5296 | |
| 5297 | if (theArgNb > 2) |
| 5298 | { |
| 5299 | std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n"; |
| 5300 | return 1; |
| 5301 | } |
| 5302 | |
| 5303 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); |
| 5304 | if (aCtx.IsNull()) |
| 5305 | { |
| 5306 | ViewerTest::ViewerInit(); |
| 5307 | aCtx = ViewerTest::GetAISContext(); |
| 5308 | } |
| 5309 | |
| 5310 | if (theArgNb == 1) |
| 5311 | { |
| 5312 | TCollection_AsciiString aSelActivationString; |
| 5313 | if (aCtx->GetAutoActivateSelection()) |
| 5314 | { |
| 5315 | aSelActivationString.Copy ("ON"); |
| 5316 | } |
| 5317 | else |
| 5318 | { |
| 5319 | aSelActivationString.Copy ("OFF"); |
| 5320 | } |
| 5321 | |
| 5322 | theDi << "Auto activation of selection is: " << aSelActivationString << "\n"; |
| 5323 | } |
| 5324 | else |
| 5325 | { |
| 5326 | Standard_Boolean toActivate = Draw::Atoi (theArgVec[1]); |
| 5327 | aCtx->SetAutoActivateSelection (toActivate); |
| 5328 | } |
| 5329 | |
| 5330 | return 0; |
| 5331 | } |
| 5332 | |
| 5333 | //============================================================================== |
| 5334 | //function : ViewerTest::Commands |
| 5335 | //purpose : Add all the viewer command in the Draw_Interpretor |
| 5336 | //============================================================================== |
| 5337 | |
| 5338 | void ViewerTest::Commands(Draw_Interpretor& theCommands) |
| 5339 | { |
| 5340 | ViewerTest::ViewerCommands(theCommands); |
| 5341 | ViewerTest::RelationCommands(theCommands); |
| 5342 | ViewerTest::ObjectCommands(theCommands); |
| 5343 | ViewerTest::FilletCommands(theCommands); |
| 5344 | ViewerTest::VoxelCommands(theCommands); |
| 5345 | ViewerTest::OpenGlCommands(theCommands); |
| 5346 | |
| 5347 | const char *group = "AIS_Display"; |
| 5348 | |
| 5349 | // display |
| 5350 | theCommands.Add("visos", |
| 5351 | "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n" |
| 5352 | "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n", |
| 5353 | __FILE__, visos, group); |
| 5354 | |
| 5355 | theCommands.Add("vdisplay", |
| 5356 | "vdisplay [-noupdate|-update] [-local] [-mutable] [-overlay|-underlay]" |
| 5357 | "\n\t\t: [-trsfPers flags] [-trsfPersPos X Y [Z]] [-3d|-2d|-2dTopDown]" |
| 5358 | "\n\t\t: [-dispMode mode] [-highMode mode]" |
| 5359 | "\n\t\t: name1 [name2] ... [name n]" |
| 5360 | "\n\t\t: Displays named objects." |
| 5361 | "\n\t\t: Option -local enables displaying of objects in local" |
| 5362 | "\n\t\t: selection context. Local selection context will be opened" |
| 5363 | "\n\t\t: if there is not any." |
| 5364 | "\n\t\t: -noupdate suppresses viewer redraw call." |
| 5365 | "\n\t\t: -mutable enables optimizations for mutable objects." |
| 5366 | "\n\t\t: -overlay draws objects in overlay." |
| 5367 | "\n\t\t: -underlay draws objects in underlay." |
| 5368 | "\n\t\t: -selectable|-noselect controls selection of objects." |
| 5369 | "\n\t\t: -trsfPers sets a transform persistence flags." |
| 5370 | "\n\t\t: -trsfPersPos sets an anchor point for transform persistence." |
| 5371 | "\n\t\t: -2d|-2dTopDown displays object in screen coordinates.", |
| 5372 | __FILE__, VDisplay2, group); |
| 5373 | |
| 5374 | theCommands.Add ("vupdate", |
| 5375 | "vupdate name1 [name2] ... [name n]" |
| 5376 | "\n\t\t: Updates named objects in interactive context", |
| 5377 | __FILE__, VUpdate, group); |
| 5378 | |
| 5379 | theCommands.Add("verase", |
| 5380 | "verase [-noupdate|-update] [-local] [name1] ... [name n]" |
| 5381 | "\n\t\t: Erases selected or named objects." |
| 5382 | "\n\t\t: If there are no selected or named objects the whole viewer is erased." |
| 5383 | "\n\t\t: Option -local enables erasing of selected or named objects without" |
| 5384 | "\n\t\t: closing local selection context.", |
| 5385 | __FILE__, VErase, group); |
| 5386 | |
| 5387 | theCommands.Add("vremove", |
| 5388 | "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n]" |
| 5389 | "or vremove [-context] -all to remove all objects" |
| 5390 | "\n\t\t: Removes selected or named objects." |
| 5391 | "\n\t\t If -context is in arguments, the objects are not deleted" |
| 5392 | "\n\t\t from the map of objects and names." |
| 5393 | "\n\t\t: Option -local enables removing of selected or named objects without" |
| 5394 | "\n\t\t: closing local selection context. Empty local selection context will be" |
| 5395 | "\n\t\t: closed." |
| 5396 | "\n\t\t: Option -noupdate suppresses viewer redraw call." |
| 5397 | "\n\t\t: Option -noinfo suppresses displaying the list of removed objects.", |
| 5398 | __FILE__, VRemove, group); |
| 5399 | |
| 5400 | theCommands.Add("vdonly", |
| 5401 | "vdonly [-noupdate|-update] [name1] ... [name n]" |
| 5402 | "\n\t\t: Displays only selected or named objects", |
| 5403 | __FILE__,VDonly2,group); |
| 5404 | |
| 5405 | theCommands.Add("vdisplayall", |
| 5406 | "vidsplayall [-local]" |
| 5407 | "\n\t\t: Displays all erased interactive objects (see vdir and vstate)." |
| 5408 | "\n\t\t: Option -local enables displaying of the objects in local" |
| 5409 | "\n\t\t: selection context.", |
| 5410 | __FILE__, VDisplayAll, group); |
| 5411 | |
| 5412 | theCommands.Add("veraseall", |
| 5413 | "veraseall [-local]" |
| 5414 | "\n\t\t: Erases all objects displayed in the viewer." |
| 5415 | "\n\t\t: Option -local enables erasing of the objects in local" |
| 5416 | "\n\t\t: selection context.", |
| 5417 | __FILE__, VErase, group); |
| 5418 | |
| 5419 | theCommands.Add("verasetype", |
| 5420 | "verasetype <Type>" |
| 5421 | "\n\t\t: Erase all the displayed objects of one given kind (see vtypes)", |
| 5422 | __FILE__, VEraseType, group); |
| 5423 | theCommands.Add("vbounding", |
| 5424 | "vbounding [-noupdate|-update] [-mode] name1 [name2 [...]]" |
| 5425 | "\n\t\t: [-print] [-hide]" |
| 5426 | "\n\t\t: Temporarily display bounding box of specified Interactive" |
| 5427 | "\n\t\t: Objects, or print it to console if -print is specified." |
| 5428 | "\n\t\t: Already displayed box might be hidden by -hide option.", |
| 5429 | __FILE__,VBounding,group); |
| 5430 | |
| 5431 | theCommands.Add("vdisplaytype", |
| 5432 | "vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ", |
| 5433 | __FILE__,VDisplayType,group); |
| 5434 | |
| 5435 | theCommands.Add("vdisplaymode", |
| 5436 | "vdispmode : vdispmode [name] mode(1,2,..) : no name -> on selected objects ", |
| 5437 | __FILE__,VDispMode,group); |
| 5438 | |
| 5439 | theCommands.Add("verasemode", |
| 5440 | "verasemode : verasemode [name] mode(1,2,..) : no name -> on selected objects", |
| 5441 | __FILE__,VDispMode,group); |
| 5442 | |
| 5443 | theCommands.Add("vsetdispmode", |
| 5444 | "vsetdispmode [name] mode(1,2,..)" |
| 5445 | "\n\t\t: Sets display mode for all, selected or named objects.", |
| 5446 | __FILE__,VDispMode,group); |
| 5447 | |
| 5448 | theCommands.Add("vunsetdispmode", |
| 5449 | "vunsetdispmode [name]" |
| 5450 | "\n\t\t: Unsets custom display mode for selected or named objects.", |
| 5451 | __FILE__,VDispMode,group); |
| 5452 | |
| 5453 | theCommands.Add("vdir", |
| 5454 | "Lists all objects displayed in 3D viewer", |
| 5455 | __FILE__,VDir,group); |
| 5456 | |
| 5457 | #ifdef HAVE_FREEIMAGE |
| 5458 | #define DUMP_FORMATS "{png|bmp|jpg|gif}" |
| 5459 | #else |
| 5460 | #define DUMP_FORMATS "{ppm}" |
| 5461 | #endif |
| 5462 | theCommands.Add("vdump", |
| 5463 | "vdump <filename>." DUMP_FORMATS " [-width Width -height Height]" |
| 5464 | "\n\t\t: [-buffer rgb|rgba|depth=rgb]" |
| 5465 | "\n\t\t: [-stereo mono|left|right|blend|sideBySide|overUnder=mono]" |
| 5466 | "\n\t\t: Dumps content of the active view into image file", |
| 5467 | __FILE__,VDump,group); |
| 5468 | |
| 5469 | theCommands.Add("vsub", "vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects", |
| 5470 | __FILE__,VSubInt,group); |
| 5471 | |
| 5472 | theCommands.Add("vaspects", |
| 5473 | "vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]" |
| 5474 | "\n\t\t: [-setVisibility 0|1]" |
| 5475 | "\n\t\t: [-setColor ColorName] [-setcolor R G B] [-unsetColor]" |
| 5476 | "\n\t\t: [-setMaterial MatName] [-unsetMaterial]" |
| 5477 | "\n\t\t: [-setTransparency Transp] [-unsetTransparency]" |
| 5478 | "\n\t\t: [-setWidth LineWidth] [-unsetWidth]" |
| 5479 | "\n\t\t: [-setLineType {solid|dash|dot|dotDash}] [-unsetLineType]" |
| 5480 | "\n\t\t: [-freeBoundary {off/on | 0/1}]" |
| 5481 | "\n\t\t: [-setFreeBoundaryWidth Width] [-unsetFreeBoundaryWidth]" |
| 5482 | "\n\t\t: [-setFreeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]" |
| 5483 | "\n\t\t: [-subshapes subname1 [subname2 [...]]]" |
| 5484 | "\n\t\t: Manage presentation properties of all, selected or named objects." |
| 5485 | "\n\t\t: When -subshapes is specified than following properties will be" |
| 5486 | "\n\t\t: assigned to specified sub-shapes." |
| 5487 | "\n\t\t: When -defaults is specified than presentation properties will be" |
| 5488 | "\n\t\t: assigned to all objects that have not their own specified properties" |
| 5489 | "\n\t\t: and to all objects to be displayed in the future." |
| 5490 | "\n\t\t: If -defaults is used there should not be any objects' names and -subshapes specifier.", |
| 5491 | __FILE__,VAspects,group); |
| 5492 | |
| 5493 | theCommands.Add("vsetcolor", |
| 5494 | "vsetcolor [-noupdate|-update] [name] ColorName" |
| 5495 | "\n\t\t: Sets color for all, selected or named objects." |
| 5496 | "\n\t\t: Alias for vaspects -setcolor [name] ColorName.", |
| 5497 | __FILE__,VAspects,group); |
| 5498 | |
| 5499 | theCommands.Add("vunsetcolor", |
| 5500 | "vunsetcolor [-noupdate|-update] [name]" |
| 5501 | "\n\t\t: Resets color for all, selected or named objects." |
| 5502 | "\n\t\t: Alias for vaspects -unsetcolor [name].", |
| 5503 | __FILE__,VAspects,group); |
| 5504 | |
| 5505 | theCommands.Add("vsettransparency", |
| 5506 | "vsettransparency [-noupdate|-update] [name] Coefficient" |
| 5507 | "\n\t\t: Sets transparency for all, selected or named objects." |
| 5508 | "\n\t\t: The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent)." |
| 5509 | "\n\t\t: Alias for vaspects -settransp [name] Coefficient.", |
| 5510 | __FILE__,VAspects,group); |
| 5511 | |
| 5512 | theCommands.Add("vunsettransparency", |
| 5513 | "vunsettransparency [-noupdate|-update] [name]" |
| 5514 | "\n\t\t: Resets transparency for all, selected or named objects." |
| 5515 | "\n\t\t: Alias for vaspects -unsettransp [name].", |
| 5516 | __FILE__,VAspects,group); |
| 5517 | |
| 5518 | theCommands.Add("vsetmaterial", |
| 5519 | "vsetmaterial [-noupdate|-update] [name] MaterialName" |
| 5520 | "\n\t\t: Alias for vaspects -setmaterial [name] MaterialName.", |
| 5521 | __FILE__,VAspects,group); |
| 5522 | |
| 5523 | theCommands.Add("vunsetmaterial", |
| 5524 | "vunsetmaterial [-noupdate|-update] [name]" |
| 5525 | "\n\t\t: Alias for vaspects -unsetmaterial [name].", |
| 5526 | __FILE__,VAspects,group); |
| 5527 | |
| 5528 | theCommands.Add("vsetwidth", |
| 5529 | "vsetwidth [-noupdate|-update] [name] width(0->10)" |
| 5530 | "\n\t\t: Alias for vaspects -setwidth [name] width.", |
| 5531 | __FILE__,VAspects,group); |
| 5532 | |
| 5533 | theCommands.Add("vunsetwidth", |
| 5534 | "vunsetwidth [-noupdate|-update] [name]" |
| 5535 | "\n\t\t: Alias for vaspects -unsetwidth [name] width.", |
| 5536 | __FILE__,VAspects,group); |
| 5537 | |
| 5538 | theCommands.Add("vsetinteriorstyle", |
| 5539 | "vsetinteriorstyle [-noupdate|-update] [name] style" |
| 5540 | "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.", |
| 5541 | __FILE__,VSetInteriorStyle,group); |
| 5542 | |
| 5543 | theCommands.Add("vsensdis", |
| 5544 | "vardisp : display active entities", |
| 5545 | __FILE__,VDispSensi,group); |
| 5546 | theCommands.Add("vsensera", |
| 5547 | "vardisp : erase active entities", |
| 5548 | __FILE__,VClearSensi,group); |
| 5549 | |
| 5550 | theCommands.Add("vselprecision", |
| 5551 | "vselprecision [-unset] [tolerance_value]" |
| 5552 | "\n\t\t Manages selection precision or prints current value if no parameter is passed." |
| 5553 | "\n\t\t -unset - restores default selection tolerance behavior, based on individual entity tolerance", |
| 5554 | __FILE__,VSelPrecision,group); |
| 5555 | |
| 5556 | theCommands.Add("vperf", |
| 5557 | "vperf: vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)", |
| 5558 | __FILE__,VPerf,group); |
| 5559 | |
| 5560 | theCommands.Add("vanimation", |
| 5561 | "vanimation CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile", |
| 5562 | __FILE__,VAnimation,group); |
| 5563 | |
| 5564 | theCommands.Add("vsetshading", |
| 5565 | "vsetshading : vsetshading name Quality(default=0.0008) ", |
| 5566 | __FILE__,VShading,group); |
| 5567 | |
| 5568 | theCommands.Add("vunsetshading", |
| 5569 | "vunsetshading :vunsetshading name ", |
| 5570 | __FILE__,VShading,group); |
| 5571 | |
| 5572 | theCommands.Add ("vtexture", |
| 5573 | "\n'vtexture NameOfShape [TextureFile | IdOfTexture]\n" |
| 5574 | " [-scale u v] [-scale off]\n" |
| 5575 | " [-origin u v] [-origin off]\n" |
| 5576 | " [-repeat u v] [-repeat off]\n" |
| 5577 | " [-modulate {on | off}]" |
| 5578 | " [-default]'\n" |
| 5579 | " The texture can be specified by filepath or as ID (0<=IdOfTexture<=20)\n" |
| 5580 | " specifying one of the predefined textures.\n" |
| 5581 | " The options are: \n" |
| 5582 | " -scale u v : enable texture scaling and set scale factors\n" |
| 5583 | " -scale off : disable texture scaling\n" |
| 5584 | " -origin u v : enable texture origin positioning and set the origin\n" |
| 5585 | " -origin off : disable texture origin positioning\n" |
| 5586 | " -repeat u v : enable texture repeat and set texture coordinate scaling\n" |
| 5587 | " -repeat off : disable texture repeat\n" |
| 5588 | " -modulate {on | off} : enable or disable texture modulation\n" |
| 5589 | " -default : sets texture mapping default parameters\n" |
| 5590 | "or 'vtexture NameOfShape' if you want to disable texture mapping\n" |
| 5591 | "or 'vtexture NameOfShape ?' to list available textures\n", |
| 5592 | __FILE__, VTexture, group); |
| 5593 | |
| 5594 | theCommands.Add("vtexscale", |
| 5595 | "'vtexscale NameOfShape ScaleU ScaleV' \n \ |
| 5596 | or 'vtexscale NameOfShape ScaleUV' \n \ |
| 5597 | or 'vtexscale NameOfShape' to disable scaling\n ", |
| 5598 | __FILE__,VTexture,group); |
| 5599 | |
| 5600 | theCommands.Add("vtexorigin", |
| 5601 | "'vtexorigin NameOfShape UOrigin VOrigin' \n \ |
| 5602 | or 'vtexorigin NameOfShape UVOrigin' \n \ |
| 5603 | or 'vtexorigin NameOfShape' to disable origin positioning\n ", |
| 5604 | __FILE__,VTexture,group); |
| 5605 | |
| 5606 | theCommands.Add("vtexrepeat", |
| 5607 | "'vtexrepeat NameOfShape URepeat VRepeat' \n \ |
| 5608 | or 'vtexrepeat NameOfShape UVRepeat \n \ |
| 5609 | or 'vtexrepeat NameOfShape' to disable texture repeat \n ", |
| 5610 | VTexture,group); |
| 5611 | |
| 5612 | theCommands.Add("vtexdefault", |
| 5613 | "'vtexdefault NameOfShape' to set texture mapping default parameters \n", |
| 5614 | VTexture,group); |
| 5615 | |
| 5616 | theCommands.Add("vsetam", |
| 5617 | "vsetActivatedModes: vsetam mode(1->7) ", |
| 5618 | __FILE__,VActivatedMode,group); |
| 5619 | |
| 5620 | theCommands.Add("vunsetam", |
| 5621 | "vunsetActivatedModes: vunsetam ", |
| 5622 | __FILE__,VActivatedMode,group); |
| 5623 | |
| 5624 | theCommands.Add("vstate", |
| 5625 | "vstate [-entities] [-hasSelected] [name1] ... [nameN]" |
| 5626 | "\n\t\t: Reports show/hidden state for selected or named objects" |
| 5627 | "\n\t\t: -entities - print low-level information about detected entities" |
| 5628 | "\n\t\t: -hasSelected - prints 1 if context has selected shape and 0 otherwise", |
| 5629 | __FILE__,VState,group); |
| 5630 | |
| 5631 | theCommands.Add("vpickshapes", |
| 5632 | "vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]", |
| 5633 | __FILE__,VPickShape,group); |
| 5634 | |
| 5635 | theCommands.Add("vtypes", |
| 5636 | "vtypes : list of known types and signatures in AIS - To be Used in vpickobject command for selection with filters", |
| 5637 | VIOTypes,group); |
| 5638 | |
| 5639 | theCommands.Add("vr", "vr : reading of the shape", |
| 5640 | __FILE__,vr, group); |
| 5641 | |
| 5642 | theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.", |
| 5643 | __FILE__, VPickSelected, group); |
| 5644 | |
| 5645 | theCommands.Add ("vloadselection", |
| 5646 | "vloadselection [-context] [name1] ... [nameN] : allows to load selection" |
| 5647 | "\n\t\t: primitives for the shapes with names given without displaying them." |
| 5648 | "\n\t\t: -local - open local context before selection computation", |
| 5649 | __FILE__, VLoadSelection, group); |
| 5650 | |
| 5651 | theCommands.Add ("vautoactivatesel", |
| 5652 | "vautoactivatesel [0|1] : manage or display the option to automatically" |
| 5653 | "\n\t\t: activate selection for newly displayed objects" |
| 5654 | "\n\t\t: [0|1] - turn off | on auto activation of selection", |
| 5655 | __FILE__, VAutoActivateSelection, group); |
| 5656 | |
| 5657 | theCommands.Add("vbsdf", "vbsdf [name] [options]" |
| 5658 | "\nAdjusts parameters of material BSDF:" |
| 5659 | "\n -help : Shows this message" |
| 5660 | "\n -print : Print BSDF" |
| 5661 | "\n -kd : Weight of the Lambertian BRDF" |
| 5662 | "\n -kr : Weight of the reflection BRDF" |
| 5663 | "\n -kt : Weight of the transmission BTDF" |
| 5664 | "\n -ks : Weight of the glossy Blinn BRDF" |
| 5665 | "\n -le : Self-emitted radiance" |
| 5666 | "\n -fresnel : Fresnel coefficients; Allowed fresnel formats are: Constant x," |
| 5667 | "\n Schlick x y z, Dielectric x, Conductor x y" |
| 5668 | "\n -roughness : Roughness of material (Blinn's exponent)" |
| 5669 | "\n -absorpcoeff : Absorption coefficient (only for transparent material)" |
| 5670 | "\n -absorpcolor : Absorption color (only for transparent material)" |
| 5671 | "\n -normalize : Normalize BSDF coefficients", |
| 5672 | __FILE__, VBsdf, group); |
| 5673 | |
| 5674 | } |
| 5675 | |
| 5676 | //===================================================================== |
| 5677 | //========================= for testing Draft and Rib ================= |
| 5678 | //===================================================================== |
| 5679 | #include <BRepOffsetAPI_MakeThickSolid.hxx> |
| 5680 | #include <DBRep.hxx> |
| 5681 | #include <TopoDS_Face.hxx> |
| 5682 | #include <gp_Pln.hxx> |
| 5683 | #include <AIS_KindOfSurface.hxx> |
| 5684 | #include <BRepOffsetAPI_DraftAngle.hxx> |
| 5685 | #include <Precision.hxx> |
| 5686 | #include <BRepAlgo.hxx> |
| 5687 | #include <OSD_Environment.hxx> |
| 5688 | #include <DrawTrSurf.hxx> |
| 5689 | //#include <DbgTools.hxx> |
| 5690 | //#include <FeatAlgo_MakeLinearForm.hxx> |
| 5691 | |
| 5692 | |
| 5693 | |
| 5694 | |
| 5695 | //======================================================================= |
| 5696 | //function : IsValid |
| 5697 | //purpose : |
| 5698 | //======================================================================= |
| 5699 | static Standard_Boolean IsValid(const TopTools_ListOfShape& theArgs, |
| 5700 | const TopoDS_Shape& theResult, |
| 5701 | const Standard_Boolean closedSolid, |
| 5702 | const Standard_Boolean GeomCtrl) |
| 5703 | { |
| 5704 | OSD_Environment check ("DONT_SWITCH_IS_VALID") ; |
| 5705 | TCollection_AsciiString checkValid = check.Value(); |
| 5706 | Standard_Boolean ToCheck = Standard_True; |
| 5707 | if (!checkValid.IsEmpty()) { |
| 5708 | #ifdef OCCT_DEBUG |
| 5709 | cout <<"DONT_SWITCH_IS_VALID positionnee a :"<<checkValid.ToCString()<<"\n"; |
| 5710 | #endif |
| 5711 | if ( checkValid=="true" || checkValid=="TRUE" ) { |
| 5712 | ToCheck= Standard_False; |
| 5713 | } |
| 5714 | } else { |
| 5715 | #ifdef OCCT_DEBUG |
| 5716 | cout <<"DONT_SWITCH_IS_VALID non positionne"<<"\n"; |
| 5717 | #endif |
| 5718 | } |
| 5719 | Standard_Boolean IsValid = Standard_True; |
| 5720 | if (ToCheck) |
| 5721 | IsValid = BRepAlgo::IsValid(theArgs,theResult,closedSolid,GeomCtrl) ; |
| 5722 | return IsValid; |
| 5723 | |
| 5724 | } |
| 5725 | |
| 5726 | //=============================================================================== |
| 5727 | // TDraft : test draft, uses AIS Viewer |
| 5728 | // Solid Face Plane Angle Reverse |
| 5729 | //=============================================================================== |
| 5730 | static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
| 5731 | { |
| 5732 | if (argc < 5) return 1; |
| 5733 | // argv[1] - TopoDS_Shape Solid |
| 5734 | // argv[2] - TopoDS_Shape Face |
| 5735 | // argv[3] - TopoDS_Shape Plane |
| 5736 | // argv[4] - Standard_Real Angle |
| 5737 | // argv[5] - Standard_Integer Reverse |
| 5738 | |
| 5739 | // Sprintf(prefix, argv[1]); |
| 5740 | Standard_Real anAngle = 0; |
| 5741 | Standard_Boolean Rev = Standard_False; |
| 5742 | Standard_Integer rev = 0; |
| 5743 | TopoDS_Shape Solid = GetShapeFromName(argv[1]); |
| 5744 | TopoDS_Shape face = GetShapeFromName(argv[2]); |
| 5745 | TopoDS_Face Face = TopoDS::Face(face); |
| 5746 | TopoDS_Shape Plane = GetShapeFromName(argv[3]); |
| 5747 | if (Plane.IsNull ()) { |
| 5748 | di << "TEST : Plane is NULL" << "\n"; |
| 5749 | return 1; |
| 5750 | } |
| 5751 | anAngle = Draw::Atof(argv[4]); |
| 5752 | anAngle = 2*M_PI * anAngle / 360.0; |
| 5753 | gp_Pln aPln; |
| 5754 | Handle( Geom_Surface )aSurf; |
| 5755 | AIS_KindOfSurface aSurfType; |
| 5756 | Standard_Real Offset; |
| 5757 | gp_Dir aDir; |
| 5758 | if(argc > 4) { // == 5 |
| 5759 | rev = Draw::Atoi(argv[5]); |
| 5760 | Rev = (rev)? Standard_True : Standard_False; |
| 5761 | } |
| 5762 | |
| 5763 | TopoDS_Face face2 = TopoDS::Face(Plane); |
| 5764 | if(!AIS::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset)) |
| 5765 | { |
| 5766 | di << "TEST : Can't find plane" << "\n"; |
| 5767 | return 1; |
| 5768 | } |
| 5769 | |
| 5770 | aDir = aPln.Axis().Direction(); |
| 5771 | if (!aPln.Direct()) |
| 5772 | aDir.Reverse(); |
| 5773 | if (Plane.Orientation() == TopAbs_REVERSED) |
| 5774 | aDir.Reverse(); |
| 5775 | di << "TEST : gp::Resolution() = " << gp::Resolution() << "\n"; |
| 5776 | |
| 5777 | BRepOffsetAPI_DraftAngle Draft (Solid); |
| 5778 | |
| 5779 | if(Abs(anAngle)< Precision::Angular()) { |
| 5780 | di << "TEST : NULL angle" << "\n"; |
| 5781 | return 1;} |
| 5782 | |
| 5783 | if(Rev) anAngle = - anAngle; |
| 5784 | Draft.Add (Face, aDir, anAngle, aPln); |
| 5785 | Draft.Build (); |
| 5786 | if (!Draft.IsDone()) { |
| 5787 | di << "TEST : Draft Not DONE " << "\n"; |
| 5788 | return 1; |
| 5789 | } |
| 5790 | TopTools_ListOfShape Larg; |
| 5791 | Larg.Append(Solid); |
| 5792 | if (!IsValid(Larg,Draft.Shape(),Standard_True,Standard_False)) { |
| 5793 | di << "TEST : DesignAlgo returns Not valid" << "\n"; |
| 5794 | return 1; |
| 5795 | } |
| 5796 | |
| 5797 | Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext(); |
| 5798 | Handle(AIS_Shape) ais = new AIS_Shape(Draft.Shape()); |
| 5799 | |
| 5800 | if ( !ais.IsNull() ) { |
| 5801 | ais->SetColor(DEFAULT_COLOR); |
| 5802 | ais->SetMaterial(DEFAULT_MATERIAL); |
| 5803 | // Display the AIS_Shape without redraw |
| 5804 | Ctx->Display(ais, Standard_False); |
| 5805 | |
| 5806 | const char *Name = "draft1"; |
| 5807 | Standard_Boolean IsBound = GetMapOfAIS().IsBound2(Name); |
| 5808 | if (IsBound) { |
| 5809 | Handle(AIS_InteractiveObject) an_object = |
| 5810 | Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(Name)); |
| 5811 | if (!an_object.IsNull()) { |
| 5812 | Ctx->Remove(an_object, |
| 5813 | Standard_True) ; |
| 5814 | GetMapOfAIS().UnBind2(Name) ; |
| 5815 | } |
| 5816 | } |
| 5817 | GetMapOfAIS().Bind(ais, Name); |
| 5818 | // DBRep::Set("draft", ais->Shape()); |
| 5819 | } |
| 5820 | Ctx->Display(ais, Standard_True); |
| 5821 | return 0; |
| 5822 | } |
| 5823 | |
| 5824 | //============================================================================== |
| 5825 | //function : splitParameter |
| 5826 | //purpose : Split parameter string to parameter name and parameter value |
| 5827 | //============================================================================== |
| 5828 | Standard_Boolean ViewerTest::SplitParameter (const TCollection_AsciiString& theString, |
| 5829 | TCollection_AsciiString& theName, |
| 5830 | TCollection_AsciiString& theValue) |
| 5831 | { |
| 5832 | Standard_Integer aParamNameEnd = theString.FirstLocationInSet ("=", 1, theString.Length()); |
| 5833 | |
| 5834 | if (aParamNameEnd == 0) |
| 5835 | { |
| 5836 | return Standard_False; |
| 5837 | } |
| 5838 | |
| 5839 | TCollection_AsciiString aString (theString); |
| 5840 | if (aParamNameEnd != 0) |
| 5841 | { |
| 5842 | theValue = aString.Split (aParamNameEnd); |
| 5843 | aString.Split (aString.Length() - 1); |
| 5844 | theName = aString; |
| 5845 | } |
| 5846 | |
| 5847 | return Standard_True; |
| 5848 | } |
| 5849 | |
| 5850 | //============================================================================ |
| 5851 | // MyCommands |
| 5852 | //============================================================================ |
| 5853 | void ViewerTest::MyCommands( Draw_Interpretor& theCommands) |
| 5854 | { |
| 5855 | |
| 5856 | DrawTrSurf::BasicCommands(theCommands); |
| 5857 | const char* group = "Check Features Operations commands"; |
| 5858 | |
| 5859 | theCommands.Add("Draft","Draft Solid Face Plane Angle Reverse", |
| 5860 | __FILE__, |
| 5861 | &TDraft,group); //Draft_Modification |
| 5862 | } |
| 5863 | |
| 5864 | //============================================================================== |
| 5865 | // ViewerTest::Factory |
| 5866 | //============================================================================== |
| 5867 | void ViewerTest::Factory(Draw_Interpretor& theDI) |
| 5868 | { |
| 5869 | // definition of Viewer Command |
| 5870 | ViewerTest::Commands(theDI); |
| 5871 | ViewerTest::AviCommands(theDI); |
| 5872 | |
| 5873 | #ifdef OCCT_DEBUG |
| 5874 | theDI << "Draw Plugin : OCC V2d & V3d commands are loaded" << "\n"; |
| 5875 | #endif |
| 5876 | } |
| 5877 | |
| 5878 | // Declare entry point PLUGINFACTORY |
| 5879 | DPLUGIN(ViewerTest) |