0024342: Create non-constant methods ChangeCoord with index parameter in classes...
[occt.git] / src / ViewerTest / ViewerTest.cxx
CommitLineData
b311480e 1// Created on: 1997-07-23
2// Created by: Henri JEANNIN
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
7fd59977 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
17// Modified by Eric Gouthiere [sep-oct 98] -> add commands for display...
7fd59977 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 <TopLoc_Location.hxx>
29#include <TopTools_HArray1OfShape.hxx>
30#include <TColStd_HArray1OfTransient.hxx>
197ac94e 31#include <TColStd_SequenceOfAsciiString.hxx>
7fd59977 32#include <OSD_Timer.hxx>
33#include <Geom_Axis2Placement.hxx>
34#include <Geom_Axis1Placement.hxx>
35#include <gp_Trsf.hxx>
36#include <TopExp_Explorer.hxx>
37#include <BRepAdaptor_Curve.hxx>
38#include <StdSelect_ShapeTypeFilter.hxx>
39#include <AIS.hxx>
99c56d44 40#include <AIS_Drawer.hxx>
7fd59977 41#include <AIS_InteractiveObject.hxx>
42#include <AIS_Trihedron.hxx>
43#include <AIS_Axis.hxx>
44#include <AIS_Relation.hxx>
45#include <AIS_TypeFilter.hxx>
46#include <AIS_SignatureFilter.hxx>
cb78155f 47#include <AIS_LocalContext.hxx>
7fd59977 48#include <AIS_ListOfInteractive.hxx>
49#include <AIS_ListIteratorOfListOfInteractive.hxx>
99c56d44 50#include <Aspect_InteriorStyle.hxx>
51#include <Graphic3d_AspectFillArea3d.hxx>
1c88cbaf 52#include <Graphic3d_AspectLine3d.hxx>
392ac980 53#include <Graphic3d_TextureRoot.hxx>
692613e5 54#include <Image_AlienPixMap.hxx>
99c56d44 55#include <Prs3d_ShadingAspect.hxx>
1c88cbaf 56#include <Prs3d_IsoAspect.hxx>
cb78155f 57#include <TopTools_MapOfShape.hxx>
7fd59977 58
59#ifdef HAVE_CONFIG_H
60# include <config.h>
61#endif
62#include <stdio.h>
63#ifdef HAVE_STRINGS_H
64# include <strings.h>
65#endif
66
67#include <Draw_Interpretor.hxx>
68#include <TCollection_AsciiString.hxx>
69#include <Draw_PluginMacro.hxx>
70#include <ViewerTest.hxx>
7fd59977 71
72// avoid warnings on 'extern "C"' functions returning C++ classes
73#ifdef WNT
74#define _CRT_SECURE_NO_DEPRECATE
75#pragma warning(4:4190)
76#pragma warning (disable:4996)
77#endif
78
79#include <NIS_InteractiveContext.hxx>
80#include <NIS_Triangulated.hxx>
81extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
82
7fd59977 83#include <Quantity_Color.hxx>
84#include <Quantity_NameOfColor.hxx>
85
86#include <Graphic3d_NameOfMaterial.hxx>
87
88#define DEFAULT_COLOR Quantity_NOC_GOLDENROD
89#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
90
792c785c 91//=======================================================================
92//function : GetColorFromName
93//purpose : get the Quantity_NameOfColor from a string
94//=======================================================================
7fd59977 95
792c785c 96Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName)
97{
98 for (Standard_Integer anIter = Quantity_NOC_BLACK; anIter <= Quantity_NOC_WHITE; ++anIter)
99 {
100 Standard_CString aColorName = Quantity_Color::StringName (Quantity_NameOfColor (anIter));
101 if (strcasecmp (theName, aColorName) == 0)
7fd59977 102 {
792c785c 103 return Quantity_NameOfColor (anIter);
7fd59977 104 }
792c785c 105 }
7fd59977 106
792c785c 107 return DEFAULT_COLOR;
7fd59977 108}
109
110//=======================================================================
111//function : GetMaterialFromName
112//purpose : get the Graphic3d_NameOfMaterial from a string
113//=======================================================================
114
115static Graphic3d_NameOfMaterial GetMaterialFromName( const char *name )
116{
117 Graphic3d_NameOfMaterial mat = DEFAULT_MATERIAL;
118
119 if ( !strcasecmp(name,"BRASS" ) ) mat = Graphic3d_NOM_BRASS;
120 else if ( !strcasecmp(name,"BRONZE" ) ) mat = Graphic3d_NOM_BRONZE;
121 else if ( !strcasecmp(name,"COPPER" ) ) mat = Graphic3d_NOM_COPPER;
122 else if ( !strcasecmp(name,"GOLD" ) ) mat = Graphic3d_NOM_GOLD;
123 else if ( !strcasecmp(name,"PEWTER" ) ) mat = Graphic3d_NOM_PEWTER;
124 else if ( !strcasecmp(name,"SILVER" ) ) mat = Graphic3d_NOM_SILVER;
125 else if ( !strcasecmp(name,"STEEL" ) ) mat = Graphic3d_NOM_STEEL;
126 else if ( !strcasecmp(name,"METALIZED" ) ) mat = Graphic3d_NOM_METALIZED;
127 else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE;
128 else if ( !strcasecmp(name,"CHROME" ) ) mat = Graphic3d_NOM_CHROME;
129 else if ( !strcasecmp(name,"ALUMINIUM" ) ) mat = Graphic3d_NOM_ALUMINIUM;
7fd59977 130 else if ( !strcasecmp(name,"NEON_PHC" ) ) mat = Graphic3d_NOM_NEON_PHC;
131 else if ( !strcasecmp(name,"NEON_GNC" ) ) mat = Graphic3d_NOM_NEON_GNC;
132 else if ( !strcasecmp(name,"PLASTER" ) ) mat = Graphic3d_NOM_PLASTER;
133 else if ( !strcasecmp(name,"SHINY_PLASTIC" ) ) mat = Graphic3d_NOM_SHINY_PLASTIC;
134 else if ( !strcasecmp(name,"SATIN" ) ) mat = Graphic3d_NOM_SATIN;
135 else if ( !strcasecmp(name,"PLASTIC" ) ) mat = Graphic3d_NOM_PLASTIC;
136 else if ( !strcasecmp(name,"OBSIDIAN" ) ) mat = Graphic3d_NOM_OBSIDIAN;
137 else if ( !strcasecmp(name,"JADE" ) ) mat = Graphic3d_NOM_JADE;
138
139 return mat;
140}
141
142//=======================================================================
143//function : GetTypeNames
144//purpose :
145//=======================================================================
146static const char** GetTypeNames()
147{
148 static const char* names[14] = {"Point","Axis","Trihedron","PlaneTrihedron", "Line","Circle","Plane",
149 "Shape","ConnectedShape","MultiConn.Shape",
150 "ConnectedInter.","MultiConn.",
151 "Constraint","Dimension"};
152 static const char** ThePointer = names;
153 return ThePointer;
154}
155
156//=======================================================================
157//function : GetTypeAndSignfromString
158//purpose :
159//=======================================================================
160void GetTypeAndSignfromString (const char* name,AIS_KindOfInteractive& TheType,Standard_Integer& TheSign)
161{
162 const char ** thefullnames = GetTypeNames();
163 Standard_Integer index(-1);
164
165 for(Standard_Integer i=0;i<=13 && index==-1;i++)
166 if(!strcasecmp(name,thefullnames[i]))
167 index = i;
168
169 if(index ==-1){
170 TheType = AIS_KOI_None;
171 TheSign = -1;
172 return;
173 }
174
175 if(index<=6){
176 TheType = AIS_KOI_Datum;
177 TheSign = index+1;
178 }
179 else if (index <=9){
180 TheType = AIS_KOI_Shape;
181 TheSign = index-7;
182 }
183 else if(index<=11){
184 TheType = AIS_KOI_Object;
185 TheSign = index-10;
186 }
187 else{
188 TheType = AIS_KOI_Relation;
189 TheSign = index-12;
190 }
191
192}
193
194
195
196#include <string.h>
197#include <Draw_Interpretor.hxx>
198#include <Draw.hxx>
199#include <Draw_Appli.hxx>
200#include <DBRep.hxx>
201
202
203#include <TCollection_AsciiString.hxx>
204#include <V3d_Viewer.hxx>
205#include <V3d_View.hxx>
206#include <V3d.hxx>
207
208#include <AIS_InteractiveContext.hxx>
209#include <AIS_Shape.hxx>
210#include <AIS_TexturedShape.hxx>
211#include <AIS_DisplayMode.hxx>
212#include <TColStd_MapOfInteger.hxx>
213#include <AIS_MapOfInteractive.hxx>
214#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
215#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
216#include <ViewerTest_EventManager.hxx>
217
218#include <TopoDS_Solid.hxx>
219#include <BRepTools.hxx>
220#include <BRep_Builder.hxx>
221#include <TopAbs_ShapeEnum.hxx>
222
223#include <TopoDS.hxx>
224#include <BRep_Tool.hxx>
225
226
227#include <Draw_Window.hxx>
228#include <AIS_ListIteratorOfListOfInteractive.hxx>
229#include <AIS_ListOfInteractive.hxx>
230#include <AIS_DisplayMode.hxx>
231#include <TopTools_ListOfShape.hxx>
232#include <BRepOffsetAPI_MakeThickSolid.hxx>
233#include <BRepOffset.hxx>
234
7fd59977 235//==============================================================================
236// VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES
237//==============================================================================
238Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(){
239 static ViewerTest_DoubleMapOfInteractiveAndName TheMap;
240 return TheMap;
241}
242
9558a876
A
243
244//==============================================================================
245//function : VDisplayAISObject
246//purpose : register interactive object in the map of AIS objects;
247// if other object with such name already registered, it will be kept
248// or replaced depending on value of <theReplaceIfExists>,
249// if "true" - the old object will be cleared from AIS context;
250// returns Standard_True if <theAISObj> registered in map;
251//==============================================================================
252Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
253 const Handle(AIS_InteractiveObject)& theAISObj,
254 Standard_Boolean theReplaceIfExists = Standard_True)
255{
256 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
257 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
258 if (aContextAIS.IsNull())
259 {
260 std::cout << "AIS context is not available.\n";
261 return Standard_False;
262 }
263
264 if (aMap.IsBound2 (theName))
265 {
266 if (!theReplaceIfExists)
267 {
268 std::cout << "Other interactive object has been already "
269 << "registered with name: " << theName << ".\n"
270 << "Please use another name.\n";
271 return Standard_False;
272 }
273
274 // stop displaying object
275 Handle(AIS_InteractiveObject) anOldObj =
276 Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
277
278 if (!anOldObj.IsNull())
279 aContextAIS->Clear (anOldObj, Standard_True);
280
281 // remove name and old object from map
282 aMap.UnBind2 (theName);
283 }
284
208e6839 285 if (theAISObj.IsNull())
286 {
287 // object with specified name already unbound
288 return Standard_True;
289 }
290
9558a876
A
291 // unbind AIS object if was bound with another name
292 aMap.UnBind1 (theAISObj);
293
294 // can be registered without rebinding
295 aMap.Bind (theAISObj, theName);
296 aContextAIS->Display (theAISObj, Standard_True);
297 return Standard_True;
298}
299
7fd59977 300static TColStd_MapOfInteger theactivatedmodes(8);
301static TColStd_ListOfTransient theEventMgrs;
302
303static void VwrTst_InitEventMgr(const Handle(NIS_View)& aView,
304 const Handle(AIS_InteractiveContext)& Ctx)
305{
306 theEventMgrs.Clear();
307 theEventMgrs.Prepend(new ViewerTest_EventManager(aView, Ctx));
308}
309
24de79c3 310static Handle(V3d_View)& a3DView()
311{
7fd59977 312 static Handle(V3d_View) Viou;
313 return Viou;
314}
315
24de79c3 316
7fd59977 317Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext(){
318 static Handle(AIS_InteractiveContext) aContext;
319 return aContext;
320}
321
24de79c3 322const Handle(V3d_View)& ViewerTest::CurrentView()
7fd59977 323{
324 return a3DView();
325}
326void ViewerTest::CurrentView(const Handle(V3d_View)& V)
327{
328 a3DView() = V;
329}
330
331Standard_EXPORT const Handle(NIS_InteractiveContext)& TheNISContext()
332{
333 static Handle(NIS_InteractiveContext) aContext;
334 if (aContext.IsNull()) {
335 aContext = new NIS_InteractiveContext;
336 aContext->SetSelectionMode (NIS_InteractiveContext::Mode_Normal);
337 }
338 return aContext;
339}
340
24de79c3 341const Handle(AIS_InteractiveContext)& ViewerTest::GetAISContext()
7fd59977 342{
343 return TheAISContext();
344}
345
346void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx)
347{
348 TheAISContext() = aCtx;
349 ViewerTest::ResetEventManager();
350}
351
352Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
353{
4952a30a 354 return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
7fd59977 355}
356
357Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
358{
4952a30a 359 return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
7fd59977 360}
361
362
363void ViewerTest::SetEventManager(const Handle(ViewerTest_EventManager)& EM){
364 theEventMgrs.Prepend(EM);
365}
366
367void ViewerTest::UnsetEventManager()
368{
369 theEventMgrs.RemoveFirst();
370}
371
372
373void ViewerTest::ResetEventManager()
374{
375 const Handle(NIS_View) aView =
376 Handle(NIS_View)::DownCast(ViewerTest::CurrentView());
377 VwrTst_InitEventMgr(aView, ViewerTest::GetAISContext());
378}
379
380Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager()
381{
382 Handle(ViewerTest_EventManager) EM;
383 if(theEventMgrs.IsEmpty()) return EM;
384 Handle(Standard_Transient) Tr = theEventMgrs.First();
385 EM = *((Handle(ViewerTest_EventManager)*)&Tr);
386 return EM;
387}
388
389
390//=======================================================================
391//function : Get Context and active viou..
392//purpose :
393//=======================================================================
394void GetCtxAndView(Handle(AIS_InteractiveContext)& Ctx,
395 Handle(V3d_View)& Viou)
396{
397 Ctx = ViewerTest::GetAISContext();
398 if (!Ctx.IsNull())
399 {
400 const Handle(V3d_Viewer)& Vwr = Ctx->CurrentViewer();
401 Vwr->InitActiveViews();
402 if(Vwr->MoreActiveViews())
403 Viou = Vwr->ActiveView();
404 }
405}
406
407
408//==============================================================================
409//function : GetShapeFromName
410//purpose : Compute an Shape from a draw variable or a file name
411//==============================================================================
412
413static TopoDS_Shape GetShapeFromName(const char* name)
414{
415 TopoDS_Shape S = DBRep::Get(name);
416
417 if ( S.IsNull() ) {
418 BRep_Builder aBuilder;
419 BRepTools::Read( S, name, aBuilder);
420 }
421
422 return S;
423}
4e18e72a 424
7fd59977 425//==============================================================================
426//function : GetAISShapeFromName
427//purpose : Compute an AIS_Shape from a draw variable or a file name
428//==============================================================================
429Handle(AIS_Shape) GetAISShapeFromName(const char* name)
430{
431 Handle(AIS_Shape) retsh;
432
433 if(GetMapOfAIS().IsBound2(name)){
434 const Handle(AIS_InteractiveObject) IO =
435 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
436 if (!IO.IsNull()) {
eafb234b 437 if(IO->Type()==AIS_KOI_Shape) {
7fd59977 438 if(IO->Signature()==0){
439 retsh = *((Handle(AIS_Shape)*)&IO);
440 }
441 else
442 cout << "an Object which is not an AIS_Shape "
443 "already has this name!!!"<<endl;
eafb234b 444 }
7fd59977 445 }
446 return retsh;
447 }
448
449
450 TopoDS_Shape S = GetShapeFromName(name);
451 if ( !S.IsNull() ) {
452 retsh = new AIS_Shape(S);
453 }
454 return retsh;
455}
456
457
458//==============================================================================
459//function : Clear
460//purpose : Remove all the object from the viewer
461//==============================================================================
462void ViewerTest::Clear()
463{
464 if ( !a3DView().IsNull() ) {
465 if (TheAISContext()->HasOpenedContext())
466 TheAISContext()->CloseLocalContext();
467 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
468 while ( it.More() ) {
469 cout << "Remove " << it.Key2() << endl;
470 if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
471 const Handle(AIS_InteractiveObject) anObj =
472 Handle(AIS_InteractiveObject)::DownCast (it.Key1());
473 TheAISContext()->Remove(anObj,Standard_False);
474 } else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
475 const Handle(NIS_InteractiveObject) anObj =
476 Handle(NIS_InteractiveObject)::DownCast (it.Key1());
ffe2bea7 477 TheNISContext()->Remove(anObj);
7fd59977 478 }
479 it.Next();
480 }
481 TheAISContext()->UpdateCurrentViewer();
ffe2bea7 482// TheNISContext()->UpdateViews();
7fd59977 483 GetMapOfAIS().Clear();
484 }
485}
486
487//==============================================================================
488//function : StandardModesActivation
489//purpose : Activate a selection mode, vertex, edge, wire ..., in a local
490// Context
491//==============================================================================
492void ViewerTest::StandardModeActivation(const Standard_Integer mode )
493{
494 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
495 if(mode==0) {
496 if (TheAISContext()->HasOpenedContext())
497 aContext->CloseLocalContext();
498 } else {
499
500 if(!aContext->HasOpenedContext()) {
501 // To unhilight the preselected object
502 aContext->UnhilightCurrents(Standard_False);
503 // Open a local Context in order to be able to select subshape from
504 // the selected shape if any or for all if there is no selection
505 if (!aContext->FirstCurrentObject().IsNull()){
506 aContext->OpenLocalContext(Standard_False);
507
508 for(aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent()){
509 aContext->Load( aContext->Current(),-1,Standard_True);
510 }
511 }
512 else
513 aContext->OpenLocalContext();
514 }
515
516 const char *cmode="???";
517
518 switch (mode) {
519 case 0: cmode = "Shape"; break;
520 case 1: cmode = "Vertex"; break;
521 case 2: cmode = "Edge"; break;
522 case 3: cmode = "Wire"; break;
523 case 4: cmode = "Face"; break;
524 case 5: cmode = "Shell"; break;
525 case 6: cmode = "Solid"; break;
4754e164 526 case 7: cmode = "Compsolid"; break;
527 case 8: cmode = "Compound"; break;
7fd59977 528 }
529
530 if(theactivatedmodes.Contains(mode))
531 { // Desactivate
532 aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
533 theactivatedmodes.Remove(mode);
534 cout<<"Mode "<< cmode <<" OFF"<<endl;
535 }
536 else
537 { // Activate
538 aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
539 theactivatedmodes.Add(mode);
540 cout<<"Mode "<< cmode << " ON" << endl;
541 }
542 }
543}
544
545//==============================================================================
1c88cbaf 546//function : CopyIsoAspect
547//purpose : Returns copy Prs3d_IsoAspect with new number of isolines.
548//==============================================================================
549static Handle(Prs3d_IsoAspect) CopyIsoAspect
550 (const Handle(Prs3d_IsoAspect) &theIsoAspect,
551 const Standard_Integer theNbIsos)
552{
553 Quantity_Color aColor;
554 Aspect_TypeOfLine aType;
555 Standard_Real aWidth;
556
557 theIsoAspect->Aspect()->Values(aColor, aType, aWidth);
558
559 Handle(Prs3d_IsoAspect) aResult =
560 new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos);
561
562 return aResult;
563}
564
565//==============================================================================
566//function : visos
567//purpose : Returns or sets the number of U- and V- isos and isIsoOnPlane flag
568//Draw arg : [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]
569//==============================================================================
570static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
571{
572 if (TheAISContext().IsNull()) {
573 di << argv[0] << " Call 'vinit' before!\n";
574 return 1;
575 }
576
577 if (argc <= 1) {
578 di << "Current number of isos : " <<
579 TheAISContext()->IsoNumber(AIS_TOI_IsoU) << " " <<
580 TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n";
581 di << "IsoOnPlane mode is " <<
582 (TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n";
583
584 return 0;
585 }
586
587 Standard_Integer aLastInd = argc - 1;
588 Standard_Boolean isChanged = Standard_False;
1d47d8d0 589 Standard_Integer aNbUIsos = 0;
590 Standard_Integer aNbVIsos = 0;
1c88cbaf 591
592 if (aLastInd >= 3) {
593 Standard_Boolean isIsoOnPlane = Standard_False;
594
595 if (strcmp(argv[aLastInd], "1") == 0) {
596 isIsoOnPlane = Standard_True;
597 isChanged = Standard_True;
598 } else if (strcmp(argv[aLastInd], "0") == 0) {
599 isIsoOnPlane = Standard_False;
600 isChanged = Standard_True;
601 }
602
603 if (isChanged) {
604 aNbVIsos = Draw::Atoi(argv[aLastInd - 1]);
605 aNbUIsos = Draw::Atoi(argv[aLastInd - 2]);
606 aLastInd -= 3;
607
608 di << "New number of isos : " << aNbUIsos << " " << aNbVIsos << "\n";
609 di << "New IsoOnPlane mode is " << (isIsoOnPlane ? "ON" : "OFF") << "\n";
610
611 TheAISContext()->IsoOnPlane(isIsoOnPlane);
612
613 if (aLastInd == 0) {
614 // If there are no shapes provided set the default numbers.
615 TheAISContext()->SetIsoNumber(aNbUIsos, AIS_TOI_IsoU);
616 TheAISContext()->SetIsoNumber(aNbVIsos, AIS_TOI_IsoV);
617 }
618 }
619 }
620
621 Standard_Integer i;
622
623 for (i = 1; i <= aLastInd; i++) {
624 TCollection_AsciiString name(argv[i]);
625 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
626
627 if (IsBound) {
628 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
629 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
630 const Handle(AIS_InteractiveObject) aShape =
631 Handle(AIS_InteractiveObject)::DownCast (anObj);
632 Handle(AIS_Drawer) CurDrawer = aShape->Attributes();
633 Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect();
634 Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect();
635
636 if (isChanged) {
637 CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos));
638 CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
639 TheAISContext()->SetLocalAttributes
640 (aShape, CurDrawer, Standard_False);
641 TheAISContext()->Redisplay(aShape);
642 } else {
643 di << "Number of isos for " << argv[i] << " : "
644 << aUIso->Number() << " " << aVIso->Number() << "\n";
645 }
646 } else {
647 di << argv[i] << ": Not an AIS interactive object!\n";
648 }
649 } else {
650 di << argv[i] << ": Use 'vdisplay' before\n";
651 }
652 }
653
654 if (isChanged) {
655 TheAISContext()->UpdateCurrentViewer();
656 }
657
658 return 0;
659}
660
661//==============================================================================
7fd59977 662//function : VDispAreas,VDispSensitive,...
663//purpose : Redraw the view
664//Draw arg : No args
665//==============================================================================
666static int VDispAreas (Draw_Interpretor& ,Standard_Integer , const char** )
667{
668
669 Handle(AIS_InteractiveContext) Ctx;
670 Handle(V3d_View) Viou;
671 GetCtxAndView(Ctx,Viou);
672 Ctx->DisplayActiveAreas(Viou);
673 return 0;
674}
675static int VClearAreas (Draw_Interpretor& ,Standard_Integer , const char** )
676{
677 Handle(AIS_InteractiveContext) Ctx;
678 Handle(V3d_View) Viou;
679 GetCtxAndView(Ctx,Viou);
680 Ctx->ClearActiveAreas(Viou);
681 return 0;
682
683}
684static int VDispSensi (Draw_Interpretor& ,Standard_Integer , const char** )
685{
686 Handle(AIS_InteractiveContext) Ctx;
687 Handle(V3d_View) Viou;
688 GetCtxAndView(Ctx,Viou);
689 Ctx->DisplayActiveSensitive(Viou);
690 return 0;
691
692}
693static int VClearSensi (Draw_Interpretor& ,Standard_Integer , const char** )
694{
695 Handle(AIS_InteractiveContext) Ctx;
696 Handle(V3d_View) Viou;
697 GetCtxAndView(Ctx,Viou);
698 Ctx->ClearActiveSensitive(Viou);
699 return 0;
700}
701
702//==============================================================================
703//function : VDebug
704//purpose : To list the displayed object with their attributes
705//Draw arg : No args
706//==============================================================================
707static int VDebug(Draw_Interpretor& di, Standard_Integer , const char** )
708{ if ( !a3DView().IsNull() ) {
709 di << "List of object in the viewer :" << "\n";
710
711 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
712
713 while ( it.More() ) {
714 di << "\t" << it.Key2().ToCString() << "\n";
715 it.Next();
716 }
717 }
718
719 return 0;
720}
721
722//==============================================================================
3c982548 723//function : VSelPrecision
724//purpose : To set the selection precision mode and tolerance value
725//Draw arg : Selection precision mode (0 for window, 1 for view) and tolerance
726// value (integer number of pixel for window mode, double value of
727// sensitivity for view mode). Without arguments the function just
728// prints the current precision mode and the corresponding tolerance.
729//==============================================================================
730static int VSelPrecision(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
731{
732 if( argc > 3 )
733 {
734 di << "Use: " << argv[0] << " [precision_mode [tolerance_value]]\n";
735 return 1;
736 }
737
738 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
739 if( aContext.IsNull() )
740 return 1;
741
742 if( argc == 1 )
743 {
744 StdSelect_SensitivityMode aMode = aContext->SensitivityMode();
745 if( aMode == StdSelect_SM_WINDOW )
746 {
747 Standard_Integer aPixelTolerance = aContext->PixelTolerance();
748 di << "Precision mode : 0 (window)\n";
749 di << "Pixel tolerance : " << aPixelTolerance << "\n";
750 }
751 else if( aMode == StdSelect_SM_VIEW )
752 {
753 Standard_Real aSensitivity = aContext->Sensitivity();
754 di << "Precision mode : 1 (view)\n";
755 di << "Sensitivity : " << aSensitivity << "\n";
756 }
757 }
758 else if( argc > 1 )
759 {
91322f44 760 StdSelect_SensitivityMode aMode = ( StdSelect_SensitivityMode )Draw::Atoi( argv[1] );
3c982548 761 aContext->SetSensitivityMode( aMode );
762 if( argc > 2 )
763 {
764 if( aMode == StdSelect_SM_WINDOW )
765 {
91322f44 766 Standard_Integer aPixelTolerance = Draw::Atoi( argv[2] );
3c982548 767 aContext->SetPixelTolerance( aPixelTolerance );
768 }
769 else if( aMode == StdSelect_SM_VIEW )
770 {
91322f44 771 Standard_Real aSensitivity = Draw::Atof( argv[2] );
3c982548 772 aContext->SetSensitivity( aSensitivity );
773 }
774 }
775 }
776 return 0;
777}
778
779//==============================================================================
7fd59977 780//function : VDump
781//purpose : To dump the active view snapshot to image file
782//Draw arg : Picture file name with extension corresponding to desired format
783//==============================================================================
784static Standard_Integer VDump (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
785{
786 if (argc < 2)
787 {
b5ac8292 788 di<<"Use: "<<argv[0]<<" <filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]\n";
7fd59977 789 return 1;
790 }
791
692613e5 792 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGB;
7fd59977 793 if (argc > 2)
794 {
29cb310a 795 const char* aBuffTypeStr = argv[2];
796 if ( strcasecmp( aBuffTypeStr, "rgb" ) == 0 ) // 4 is to compare '\0' as well
7fd59977 797 {
692613e5 798 aBufferType = Graphic3d_BT_RGB;
7fd59977 799 }
29cb310a 800 else if ( strcasecmp( aBuffTypeStr, "rgba" ) == 0 )
7fd59977 801 {
692613e5 802 aBufferType = Graphic3d_BT_RGBA;
7fd59977 803 }
29cb310a 804 else if ( strcasecmp( aBuffTypeStr, "depth" ) == 0 )
7fd59977 805 {
692613e5 806 aBufferType = Graphic3d_BT_Depth;
7fd59977 807 }
808 }
809
91322f44 810 Standard_Integer aWidth = (argc > 3) ? Draw::Atoi (argv[3]) : 0;
811 Standard_Integer aHeight = (argc > 4) ? Draw::Atoi (argv[4]) : 0;
7fd59977 812
b5ac8292 813 TCollection_AsciiString aStereoProj ((argc > 5) ? argv[5] : "");
814
7fd59977 815 Handle(AIS_InteractiveContext) IC;
816 Handle(V3d_View) view;
817 GetCtxAndView (IC, view);
85e096c3 818 if (view.IsNull())
7fd59977 819 {
85e096c3 820 di << "Cannot find an active viewer/view\n";
821 return 1;
822 }
823
824 if (aWidth <= 0 || aHeight <= 0)
825 {
826 if (!view->Dump (argv[1], aBufferType))
7fd59977 827 {
85e096c3 828 di << "Dumping failed!\n";
829 return 1;
7fd59977 830 }
85e096c3 831 return 0;
7fd59977 832 }
85e096c3 833
b5ac8292 834 V3d_StereoDumpOptions aStereoOpts = V3d_SDO_MONO;
835
836 if (!aStereoProj.IsEmpty())
837 {
838 aStereoProj.UpperCase();
839 if (aStereoProj == "L")
840 {
841 aStereoOpts = V3d_SDO_LEFT_EYE;
842 }
843
844 if (aStereoProj == "R")
845 {
846 aStereoOpts = V3d_SDO_RIGHT_EYE;
847 }
848 }
849
692613e5 850 Image_AlienPixMap aPixMap;
b5ac8292 851 if (!view->ToPixMap (aPixMap, aWidth, aHeight, aBufferType, Standard_True, aStereoOpts))
7fd59977 852 {
85e096c3 853 di << "Dumping failed!\n";
7fd59977 854 return 1;
855 }
85e096c3 856
692613e5 857 if (aPixMap.SizeX() != Standard_Size(aWidth)
858 || aPixMap.SizeY() != Standard_Size(aHeight))
85e096c3 859 {
692613e5 860 std::cout << "Warning! Dumped dimensions " << aPixMap.SizeX() << "x" << aPixMap.SizeY()
861 << " are lesser than requested " << aWidth << "x" << aHeight << "\n";
85e096c3 862 }
692613e5 863 if (!aPixMap.Save (argv[1]))
85e096c3 864 {
865 di << "Saving image failed!\n";
866 return 1;
867 }
868 return 0;
7fd59977 869}
870
871
872//==============================================================================
873//function : Displays,Erase...
874//purpose :
875//Draw arg :
876//==============================================================================
877static int VwrTst_DispErase(const Handle(AIS_InteractiveObject)& IO,
878 const Standard_Integer Mode,
879 const Standard_Integer TypeOfOperation,
880 const Standard_Boolean Upd)
881{
882 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
883
884 switch(TypeOfOperation){
885 case 1:
886 Ctx->Display(IO,Mode,Upd);
887 break;
888 case 2:{
eb4320f2 889 Ctx->Erase(IO,Upd);
7fd59977 890 break;
891 }
892 case 3:{
893 if(IO.IsNull())
894 Ctx->SetDisplayMode((AIS_DisplayMode)Mode,Upd);
895 else
896 Ctx->SetDisplayMode(IO,Mode,Upd);
897 break;
898 }
899 case 4:{
900 if(IO.IsNull())
901 Ctx->SetDisplayMode(0,Upd);
902 else
903 Ctx->UnsetDisplayMode(IO,Upd);
904 break;
905 }
906 }
907 return 0;
908}
909
910//=======================================================================
911//function :
912//purpose :
913//=======================================================================
914static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv)
915{
916
917 TCollection_AsciiString name;
918 if(argc>3)
919 return 1;
920 // display others presentations
921 Standard_Integer TypeOfOperation = (strcasecmp(argv[0],"vdispmode")==0)? 1:
922 (strcasecmp(argv[0],"verasemode")==0) ? 2 :
923 (strcasecmp(argv[0],"vsetdispmode")==0) ? 3 :
924 (strcasecmp(argv[0],"vunsetdispmode")==0) ? 4 : -1;
925
926 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
927
928 //unset displaymode.. comportement particulier...
929 if(TypeOfOperation==4){
930 if(argc==1){
931 if(Ctx->NbCurrents()==0 ||
932 Ctx->NbSelected()==0){
933 Handle(AIS_InteractiveObject) IO;
934 VwrTst_DispErase(IO,-1,4,Standard_False);
935 }
936 else if(!Ctx->HasOpenedContext()){
937 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
938 VwrTst_DispErase(Ctx->Current(),-1,4,Standard_False);
939 }
940 else{
941 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
942 VwrTst_DispErase(Ctx->Interactive(),-1,4,Standard_False);}
943 Ctx->UpdateCurrentViewer();
944 }
945 else{
946 Handle(AIS_InteractiveObject) IO;
947 name = argv[1];
948 if(GetMapOfAIS().IsBound2(name)){
949 IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
950 if (!IO.IsNull())
951 VwrTst_DispErase(IO,-1,4,Standard_True);
952 }
953 }
954 }
955 else if(argc==2){
91322f44 956 Standard_Integer Dmode = Draw::Atoi(argv[1]);
7fd59977 957 if(Ctx->NbCurrents()==0 && TypeOfOperation==3){
958 Handle(AIS_InteractiveObject) IO;
959 VwrTst_DispErase(IO,Dmode,TypeOfOperation,Standard_True);
960 }
961 if(!Ctx->HasOpenedContext()){
962 // set/unset display mode sur le Contexte...
963 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){
964 VwrTst_DispErase(Ctx->Current(),Dmode,TypeOfOperation,Standard_False);
965 }
966 Ctx->UpdateCurrentViewer();
967 }
968 else{
969 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
970 Ctx->Display(Ctx->Interactive(),Dmode);
971 }
972 }
973 else{
974 Handle(AIS_InteractiveObject) IO;
975 name = argv[1];
976 if(GetMapOfAIS().IsBound2(name))
977 IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
978 if (!IO.IsNull())
91322f44 979 VwrTst_DispErase(IO,Draw::Atoi(argv[2]),TypeOfOperation,Standard_True);
7fd59977 980 }
981 return 0;
982}
983
984
985//=======================================================================
986//function :
987//purpose :
988//=======================================================================
989static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
990{
991 if(argc==1) return 1;
91322f44 992 Standard_Integer On = Draw::Atoi(argv[1]);
7fd59977 993 const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext();
994
995 if(argc==2){
996
997 if(!Ctx->HasOpenedContext()){
998 di<<"sub intensite ";
999 if(On==1) di<<"On";
1000 else di<<"Off";
1001 di<<" pour "<<Ctx->NbCurrents()<<" objets"<<"\n";
1002 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){
1003 if(On==1){
1004 Ctx->SubIntensityOn(Ctx->Current(),Standard_False);}
1005 else{
1006 di <<"passage dans off"<<"\n";
1007 Ctx->SubIntensityOff(Ctx->Current(),Standard_False);
1008 }
1009 }
1010 }
1011 else{
1012 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){
1013 if(On==1){
1014 Ctx->SubIntensityOn(Ctx->Interactive(),Standard_False);}
1015 else{
1016 Ctx->SubIntensityOff(Ctx->Interactive(),Standard_False);}
1017 }
1018 }
1019 Ctx->UpdateCurrentViewer();
1020 }
1021 else {
1022 Handle(AIS_InteractiveObject) IO;
1023 TCollection_AsciiString name = argv[2];
1024 if(GetMapOfAIS().IsBound2(name)){
1025 IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
eafb234b 1026 if (!IO.IsNull()) {
7fd59977 1027 if(On==1)
1028 Ctx->SubIntensityOn(IO);
1029 else
1030 Ctx->SubIntensityOff(IO);
eafb234b 1031 }
7fd59977 1032 }
1033 else return 1;
1034 }
1035 return 0;
1036
1037}
1038//==============================================================================
1039//function : VColor2
1040//Author : ege
1041//purpose : change the color of a selected or named or displayed shape
1042//Draw arg : vcolor2 [name] color
1043//==============================================================================
1044static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1045{
1046
1047 Standard_Boolean ThereIsCurrent;
1048 Standard_Boolean ThereIsArgument;
1049 Standard_Boolean IsBound = Standard_False ;
7fd59977 1050
5cbef0fe 1051 const Standard_Boolean HaveToSet=(strcasecmp( argv[0],"vsetcolor") == 0);
7fd59977 1052 if (HaveToSet) {
5cbef0fe
S
1053 if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error: Give 2 or 3 arguments" << "\n"; return 1; }
1054 ThereIsArgument = (argc != 2);
7fd59977 1055 }
1056 else {
5cbef0fe
S
1057 if ( argc > 2 ) { di << argv[0] << " syntax error: Given too many arguments" << "\n"; return 1; }
1058 ThereIsArgument = (argc == 2);
7fd59977 1059 }
1060
1061 if ( !a3DView().IsNull() ) {
1062 TCollection_AsciiString name;
1063 if (ThereIsArgument) {
1064 name = argv[1];
1065 IsBound= GetMapOfAIS().IsBound2(name);
1066 }
1067 if (TheAISContext()->HasOpenedContext())
1068 TheAISContext()->CloseLocalContext();
1069
1070 // On set le Booleen There is current
1071 if (TheAISContext() -> NbCurrents() > 0 ) {ThereIsCurrent =Standard_True; }
1072 else ThereIsCurrent =Standard_False;
1073
1074 //=======================================================================
1075 // Il y a un argument
1076 //=======================================================================
1077 if ( ThereIsArgument && IsBound ) {
1078 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
1079 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1080 Handle(AIS_InteractiveObject) ashape =
1081 Handle(AIS_InteractiveObject)::DownCast (anObj);
1082#ifdef DEB
7fd59977 1083 if (HaveToSet)
792c785c 1084 di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< ViewerTest::GetColorFromName(argv[2]) << "\n";
7fd59977 1085 else
5cbef0fe 1086 di << "HaveToSet 0\n";
7fd59977 1087#endif
1088
5cbef0fe 1089 if(HaveToSet)
792c785c 1090 TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[2]) );
7fd59977 1091 else
1092 TheAISContext()->UnsetColor(ashape);
1093 } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
1094 Handle(NIS_Triangulated) ashape =
1095 Handle(NIS_Triangulated)::DownCast (anObj);
5cbef0fe 1096 if (!ashape.IsNull())
792c785c 1097 ashape->SetColor (ViewerTest::GetColorFromName(argv[2]));
7fd59977 1098 }
1099 }
1100
1101
1102 //=======================================================================
1103 // Il n'y a pas d'arguments
1104 // Mais un ou plusieurs objets on des current representation
1105 //=======================================================================
1106 if (ThereIsCurrent && !ThereIsArgument) {
1107 for (TheAISContext() -> InitCurrent() ;
1108 TheAISContext() -> MoreCurrent() ;
1109 TheAISContext() ->NextCurrent() )
1110 {
5cbef0fe 1111 const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
7fd59977 1112 if (ashape.IsNull())
1113 continue;
1114#ifdef DEB
5cbef0fe 1115 if (HaveToSet)
792c785c 1116 di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< ViewerTest::GetColorFromName(argv[2]) << "\n";
5cbef0fe
S
1117 else
1118 di << "HaveToSet 0\n";
7fd59977 1119#endif
5cbef0fe 1120 if(HaveToSet)
792c785c 1121 TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[1]),Standard_False);
5cbef0fe
S
1122 else
1123 TheAISContext()->UnsetColor(ashape,Standard_False);
7fd59977 1124 }
1125
1126 TheAISContext()->UpdateCurrentViewer();
1127 }
1128
1129 //=======================================================================
1130 // Il n'y a pas d'arguments(nom de shape) ET aucun objet courrant
1131 // on impose a tous les objets du viewer la couleur passee
1132 //=======================================================================
1133 else if (!ThereIsCurrent && !ThereIsArgument){
1134 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
1135 while ( it.More() ) {
5cbef0fe 1136 const Handle(AIS_InteractiveObject) ashape =
7fd59977 1137 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
eafb234b 1138 if (!ashape.IsNull()) {
7fd59977 1139 if(HaveToSet)
792c785c 1140 TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[1]),Standard_False);
7fd59977 1141 else
1142 TheAISContext()->UnsetColor(ashape,Standard_False);
eafb234b 1143 }
5cbef0fe 1144 it.Next();
7fd59977 1145 }
1146 TheAISContext()->UpdateCurrentViewer();
1147 }
1148 }
1149 return 0;
1150}
1151
1152//==============================================================================
1153//function : VTransparency
1154//Author : ege
1155//purpose : change the transparency of a selected or named or displayed shape
1156//Draw arg : vtransparency [name] TransparencyCoeficient
1157//==============================================================================
1158
7fd59977 1159static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
1160 const char** argv)
1161{
1162 Standard_Boolean ThereIsCurrent;
1163 Standard_Boolean ThereIsArgument;
1164 Standard_Boolean IsBound = Standard_False ;
7fd59977 1165
5cbef0fe 1166 const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsettransparency") == 0);
7fd59977 1167 if (HaveToSet) {
1168 if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
5cbef0fe 1169 ThereIsArgument = (argc != 2);
7fd59977 1170 }
1171 else{
1172 if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
5cbef0fe 1173 ThereIsArgument = (argc == 2);
7fd59977 1174 }
1175
1176 if ( !a3DView().IsNull() ) {
1177 TCollection_AsciiString name;
1178 if (ThereIsArgument) {
1179 name = argv[1];
1180 IsBound= GetMapOfAIS().IsBound2(name);
1181 }
1182 if (TheAISContext()->HasOpenedContext())
1183 TheAISContext()->CloseLocalContext();
1184
1185 if (TheAISContext() -> NbCurrents() > 0 ) {ThereIsCurrent =Standard_True; }
1186 else ThereIsCurrent = Standard_False;
1187
1188 //=======================================================================
1189 // Il y a des arguments: un nom et une couleur
1190 //=======================================================================
1191 if ( ThereIsArgument && IsBound ) {
1192 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
1193 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1194 const Handle(AIS_InteractiveObject) ashape =
1195 Handle(AIS_InteractiveObject)::DownCast(anObj);
1196 if(HaveToSet)
91322f44 1197 TheAISContext()->SetTransparency(ashape,Draw::Atof(argv[2]) );
7fd59977 1198 else
1199 TheAISContext()->UnsetTransparency(ashape);
5cbef0fe 1200 } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
7fd59977 1201 const Handle(NIS_InteractiveObject) ashape =
1202 Handle(NIS_InteractiveObject)::DownCast(anObj);
1203 if(HaveToSet)
91322f44 1204 ashape->SetTransparency(Draw::Atof(argv[2]) );
7fd59977 1205 else
1206 ashape->UnsetTransparency();
1207 }
1208 }
1209 //=======================================================================
1210 // Il n'y a pas d'arguments
1211 // Mais un ou plusieurs objets on des current representation
1212 //=======================================================================
1213 if (ThereIsCurrent && !ThereIsArgument) {
1214 for (TheAISContext() -> InitCurrent() ;
1215 TheAISContext() -> MoreCurrent() ;
1216 TheAISContext() ->NextCurrent() )
1217 {
5cbef0fe
S
1218 Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
1219 if(HaveToSet)
91322f44 1220 TheAISContext()->SetTransparency(ashape,Draw::Atof(argv[1]),Standard_False);
5cbef0fe
S
1221 else
1222 TheAISContext()->UnsetTransparency(ashape,Standard_False);
7fd59977 1223 }
1224
1225 TheAISContext()->UpdateCurrentViewer();
1226 }
1227 //=======================================================================
1228 // Il n'y a pas d'arguments ET aucun objet courrant
1229 //=======================================================================
1230 else if ( !ThereIsCurrent && !ThereIsArgument ) {
1231 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1232 it(GetMapOfAIS());
1233 while ( it.More() ) {
5cbef0fe 1234 Handle(AIS_InteractiveObject) ashape =
7fd59977 1235 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
eafb234b 1236 if (!ashape.IsNull()) {
7fd59977 1237 if(HaveToSet)
91322f44 1238 TheAISContext()->SetTransparency(ashape,Draw::Atof(argv[1]),Standard_False);
7fd59977 1239 else
1240 TheAISContext()->UnsetTransparency(ashape,Standard_False);
eafb234b 1241 }
5cbef0fe 1242 it.Next();
7fd59977 1243 }
1244 TheAISContext()->UpdateCurrentViewer();
1245 }
1246 }
1247 return 0;
1248}
1249
1250
1251//==============================================================================
1252//function : VMaterial
1253//Author : ege
1254//purpose : change the Material of a selected or named or displayed shape
1255//Draw arg : vmaterial [Name] Material
1256//==============================================================================
1257static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1258{
1259
1260 Standard_Boolean ThereIsCurrent;
1261 Standard_Boolean ThereIsName;
1262 Standard_Boolean IsBound = Standard_False ;
1263
5cbef0fe 1264 const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetmaterial") == 0);
7fd59977 1265 if (HaveToSet) {
1266 if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
5cbef0fe 1267 ThereIsName = (argc != 2);
7fd59977 1268 }
1269 else {
1270 if ( argc>2 ) { di << argv[0] << " syntax error passez au plus un argument" << "\n"; return 1; }
5cbef0fe 1271 ThereIsName = (argc == 2);
7fd59977 1272 }
1273
1274 if ( !a3DView().IsNull() ) {
1275 TCollection_AsciiString name;
1276 if (ThereIsName) {
1277 name = argv[1];
1278 IsBound= GetMapOfAIS().IsBound2(name);
1279 }
1280 if (TheAISContext()->HasOpenedContext())
1281 TheAISContext()->CloseLocalContext();
1282 if (TheAISContext() -> NbCurrents() > 0 )
1283 ThereIsCurrent =Standard_True;
1284 else
1285 ThereIsCurrent =Standard_False;
1286
1287 //=======================================================================
1288 // Ther is a name of shape and a material name
1289 //=======================================================================
1290 if ( ThereIsName && IsBound ) {
1291 Handle(AIS_InteractiveObject) ashape =
1292 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(name));
eafb234b 1293 if (!ashape.IsNull()) {
7fd59977 1294 if (HaveToSet)
5cbef0fe 1295 TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[2]));
7fd59977 1296 else
1297 TheAISContext()->UnsetMaterial(ashape);
eafb234b 1298 }
7fd59977 1299 }
1300 //=======================================================================
1301 // Il n'y a pas de nom de shape
1302 // Mais un ou plusieurs objets on des current representation
1303 //=======================================================================
1304 if (ThereIsCurrent && !ThereIsName) {
1305 for (TheAISContext() -> InitCurrent() ;
1306 TheAISContext() -> MoreCurrent() ;
1307 TheAISContext() ->NextCurrent() )
1308 {
5cbef0fe
S
1309 Handle(AIS_InteractiveObject) ashape = TheAISContext()->Current();
1310 if (HaveToSet)
1311 TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
1312 else
1313 TheAISContext()->UnsetMaterial(ashape,Standard_False);
7fd59977 1314 }
1315 TheAISContext()->UpdateCurrentViewer();
1316 }
1317
1318 //=======================================================================
1319 // Il n'y a pas de noms de shape ET aucun objet courrant
1320 // On impose a tous les objets du viewer le material passe en argument
1321 //=======================================================================
1322 else if (!ThereIsCurrent && !ThereIsName){
1323 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1324 it(GetMapOfAIS());
1325 while ( it.More() ) {
5cbef0fe 1326 Handle(AIS_InteractiveObject) ashape =
7fd59977 1327 Handle(AIS_InteractiveObject)::DownCast (it.Key1());
eafb234b 1328 if (!ashape.IsNull()) {
7fd59977 1329 if (HaveToSet)
5cbef0fe 1330 TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
7fd59977 1331 else
1332 TheAISContext()->UnsetMaterial(ashape,Standard_False);
eafb234b 1333 }
5cbef0fe 1334 it.Next();
7fd59977 1335 }
1336 TheAISContext()->UpdateCurrentViewer();
1337 }
1338 }
1339 return 0;
1340}
1341
1342
1343
1344//==============================================================================
1345//function : VWidth
1346//Author : ege
1347//purpose : change the width of the edges of a selected or named or displayed shape
1348//Draw arg : vwidth [Name] WidthValue(1->10)
1349//==============================================================================
1350static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1351{
1352
1353 Standard_Boolean ThereIsCurrent;
1354 Standard_Boolean ThereIsArgument;
1355 Standard_Boolean IsBound = Standard_False ;
1356
5cbef0fe 1357 const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetwidth") == 0);
7fd59977 1358 if (HaveToSet) {
1359 if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
5cbef0fe 1360 ThereIsArgument = (argc != 2);
7fd59977 1361 }
1362 else {
1363 if ( argc>2 ) { di << argv[0] << " syntax error passez au plus 1 argument" << "\n"; return 1; }
5cbef0fe 1364 ThereIsArgument = (argc == 2);
7fd59977 1365 }
1366 if ( !a3DView().IsNull() ) {
1367 TCollection_AsciiString name;
1368 if (ThereIsArgument) {
1369 name = argv[1];
1370 IsBound= GetMapOfAIS().IsBound2(name);
1371 }
1372 if (TheAISContext()->HasOpenedContext())
1373 TheAISContext()->CloseLocalContext();
1374
1375 if (TheAISContext() -> NbCurrents() > 0 )
1376 ThereIsCurrent =Standard_True;
1377 else
1378 ThereIsCurrent =Standard_False;
1379
1380 if ( ThereIsArgument && IsBound ) {
1381 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
1382 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1383 const Handle(AIS_InteractiveObject) ashape =
1384 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
1385 if (HaveToSet)
91322f44 1386 TheAISContext()->SetWidth ( ashape,Draw::Atof (argv[2]) );
7fd59977 1387 else
1388 TheAISContext()->UnsetWidth (ashape);
1389 } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
1390 const Handle(NIS_Triangulated) ashape =
1391 Handle(NIS_Triangulated)::DownCast(GetMapOfAIS().Find2(name));
1392 if (HaveToSet && !ashape.IsNull())
91322f44 1393 ashape->SetLineWidth ( Draw::Atof (argv[2]) );
7fd59977 1394 }
1395 }
1396
1397 //=======================================================================
1398 // Il n'y a pas d'arguments
1399 // Mais un ou plusieurs objets on des current representation
1400 //=======================================================================
1401 if (ThereIsCurrent && !ThereIsArgument) {
1402 for (TheAISContext() -> InitCurrent() ;
1403 TheAISContext() -> MoreCurrent() ;
1404 TheAISContext() ->NextCurrent() )
1405 {
5cbef0fe
S
1406 Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
1407 if (HaveToSet)
91322f44 1408 TheAISContext()->SetWidth(ashape,Draw::Atof(argv[1]),Standard_False);
5cbef0fe
S
1409 else
1410 TheAISContext()->UnsetWidth(ashape,Standard_False);
7fd59977 1411 }
1412 TheAISContext()->UpdateCurrentViewer();
1413 }
1414 //=======================================================================
1415 // Il n'y a pas d'arguments ET aucun objet courrant
1416 //=======================================================================
1417 else if (!ThereIsCurrent && !ThereIsArgument){
1418 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1419 it(GetMapOfAIS());
eafb234b 1420 while ( it.More() ) {
1421 Handle(AIS_InteractiveObject) ashape =
1422 Handle(AIS_InteractiveObject)::DownCast (it.Key1());
1423 if (!ashape.IsNull()) {
1424 if (HaveToSet)
1425 TheAISContext()->SetWidth(ashape,Draw::Atof(argv[1]),Standard_False);
1426 else
1427 TheAISContext()->UnsetWidth(ashape,Standard_False);
1428 }
1429 it.Next();
7fd59977 1430 }
1431 TheAISContext()->UpdateCurrentViewer();
1432 }
1433 }
1434 return 0;
1435}
99c56d44 1436
1437//==============================================================================
1438//function : VInteriorStyle
1439//purpose : sets interior style of the a selected or named or displayed shape
1440//Draw arg : vsetinteriorstyle [shape] style
1441//==============================================================================
1442static void SetInteriorStyle (const Handle(AIS_InteractiveObject)& theIAO,
1443 const Standard_Integer theStyle,
1444 Draw_Interpretor& di)
1445{
1446 if (theStyle < Aspect_IS_EMPTY || theStyle > Aspect_IS_HIDDENLINE) {
1447 di << "Style must be within a range [0 (Aspect_IS_EMPTY), " << Aspect_IS_HIDDENLINE <<
1448 " (Aspect_IS_HIDDENLINE)]\n";
1449 return;
1450 }
1451 const Handle(Prs3d_Drawer)& aDrawer = theIAO->Attributes();
1452 Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
1453 Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
1454 Aspect_InteriorStyle aStyle = (Aspect_InteriorStyle) (theStyle);
1455 aFillAspect->SetInteriorStyle (aStyle);
1456 TheAISContext()->RecomputePrsOnly (theIAO, Standard_False /*update*/, Standard_True /*all modes*/);
1457}
1458
1459static int VInteriorStyle (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1460{
1461 if (argc < 2 || argc > 3) {
1462 di << argv[0] << " requires 2 or 3 arguments\n";
1463 di << "Usage : " << argv[0] << " [shape] Style : Set interior style" << "\n";
1464 di << "Style must match Aspect_InteriorStyle and be one of:\n";
1465 di << " 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE\n";
1466 return 1;
1467 }
1468
1469 Standard_Boolean ThereIsCurrent;
1470 Standard_Boolean ThereIsArgument;
1471 Standard_Boolean IsBound = Standard_False ;
1472
1473 ThereIsArgument = (argc > 2);
1474 if ( !a3DView().IsNull() ) {
1475 TCollection_AsciiString name;
1476 if (ThereIsArgument) {
1477 name = argv[1];
1478 IsBound= GetMapOfAIS().IsBound2(name);
1479 }
1480 if (TheAISContext()->HasOpenedContext())
1481 TheAISContext()->CloseLocalContext();
1482
1483 if (TheAISContext() -> NbCurrents() > 0 )
1484 ThereIsCurrent =Standard_True;
1485 else
1486 ThereIsCurrent =Standard_False;
1487
1488 if ( ThereIsArgument && IsBound ) {
1489 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
1490 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1491 const Handle(AIS_InteractiveObject) ashape =
1492 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
91322f44 1493 SetInteriorStyle (ashape, Draw::Atoi (argv[2]), di);
99c56d44 1494 }
1495 }
1496 //=======================================================================
1497 // No arguments specified
1498 // But there are one or more selected objects
1499 //=======================================================================
1500 if (ThereIsCurrent && !ThereIsArgument) {
1501 for (TheAISContext() -> InitCurrent() ;
1502 TheAISContext() -> MoreCurrent() ;
1503 TheAISContext() ->NextCurrent() )
1504 {
1505 Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
91322f44 1506 SetInteriorStyle (ashape, Draw::Atoi (argv[1]), di);
99c56d44 1507 }
1508 }
1509 //=======================================================================
1510 // No arguments specified and there are no selected objects
1511 //=======================================================================
1512 else if (!ThereIsCurrent && !ThereIsArgument){
1513 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1514 it(GetMapOfAIS());
1515 while ( it.More() ) {
1516 Handle(AIS_InteractiveObject) ashape =
1517 Handle(AIS_InteractiveObject)::DownCast (it.Key1());
1518 if (!ashape.IsNull())
91322f44 1519 SetInteriorStyle (ashape, Draw::Atoi (argv[1]), di);
99c56d44 1520 it.Next();
1521 }
1522 }
1523 TheAISContext()->UpdateCurrentViewer();
1524 }
1525 return 0;
1526}
1527
7fd59977 1528//==============================================================================
1529//function : VDonly2
1530//author : ege
1531//purpose : Display only a selected or named object
1532// if there is no selected or named object s, nothing is donne
1533//Draw arg : vdonly2 [name1] ... [name n]
1534//==============================================================================
1535static int VDonly2(Draw_Interpretor& , Standard_Integer argc, const char** argv)
1536
1537{
1538 if ( a3DView().IsNull() )
1539 return 1;
1540
1541 Standard_Boolean ThereIsCurrent = TheAISContext() -> NbCurrents() > 0;
1542 Standard_Boolean ThereIsArgument= argc>1;
1543
1544 if (TheAISContext()->HasOpenedContext())
1545 TheAISContext()->CloseLocalContext();
1546
1547 //===============================================================
1548 // Il n'y a pas d'arguments mais des objets selectionnes(current)
1549 // dans le viewer
1550 //===============================================================
1551 if (!ThereIsArgument && ThereIsCurrent) {
1552
1553#ifdef DEB
1554 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1555 it (GetMapOfAIS());
1556#endif
1557 for(TheAISContext()->InitCurrent();
1558 TheAISContext()->MoreCurrent();
1559 TheAISContext()->NextCurrent()){
1560 Handle(AIS_InteractiveObject) aShape = TheAISContext()->Current();
1561 TheAISContext()->Erase(aShape,Standard_False);}
1562 }
1563 TheAISContext() ->UpdateCurrentViewer();
1564 //===============================================================
1565 // Il y a des arguments
1566 //===============================================================
1567 if (ThereIsArgument) {
1568 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1569 it (GetMapOfAIS());
1570 while ( it.More() ) {
1571 if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1572 const Handle(AIS_InteractiveObject) aShape =
1573 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
1574 TheAISContext()->Erase(aShape,Standard_False);
1575 } else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
1576 const Handle(NIS_InteractiveObject) aShape =
1577 Handle(NIS_InteractiveObject)::DownCast(it.Key1());
ffe2bea7 1578 TheNISContext()->Erase(aShape);
7fd59977 1579 }
1580 it.Next();
1581 }
1582
1583 // On display les objets passes par parametre
1584 for (int i=1; i<argc ; i++) {
1585 TCollection_AsciiString name=argv[i];
1586 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
1587 if (IsBound) {
1588 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
1589 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1590 const Handle(AIS_InteractiveObject) aShape =
1591 Handle(AIS_InteractiveObject)::DownCast (anObj);
1592 TheAISContext()->Display(aShape, Standard_False);
1593 } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
ffe2bea7 1594 Handle(NIS_InteractiveObject) aShape =
7fd59977 1595 Handle(NIS_InteractiveObject)::DownCast (anObj);
ffe2bea7 1596 TheNISContext()->Display(aShape);
7fd59977 1597 }
1598 }
1599 }
1600 TheAISContext() ->UpdateCurrentViewer();
ffe2bea7 1601// TheNISContext() ->UpdateViews();
7fd59977 1602 }
1603 return 0;
1604}
1605
1606//==============================================================================
eef7fc64 1607//function : VRemove
1608//purpose : Removes selected or named objects.
1609// If there is no selected or named objects,
1610// all objects in the viewer can be removed with argument -all.
1611// If -context is in arguments, the object is not deleted from the map of
1612// objects (deleted only from the current context).
1613//==============================================================================
1614int VRemove (Draw_Interpretor& theDI,
1615 Standard_Integer theArgNb,
1616 const char** theArgVec)
1617{
1618 if (a3DView().IsNull())
1619 {
1620 return 1;
1621 }
1622
1623 TheAISContext()->CloseAllContexts (Standard_False);
1624
1625 //Standard_Boolean isStayedInMap = Standard_False;
1626 TCollection_AsciiString aContextOnlyStr ("-context");
1627 TCollection_AsciiString aRemoveAllStr ("-all");
1628
1629 Standard_Boolean isContextOnly = (theArgNb > 1 && TCollection_AsciiString (theArgVec[1]) == aContextOnlyStr);
1630
1631 Standard_Boolean isRemoveAll = (theArgNb == 3 && TCollection_AsciiString (theArgVec[2]) == aRemoveAllStr) ||
1632 (theArgNb == 2 && TCollection_AsciiString (theArgVec[1]) == aRemoveAllStr);
1633
1634 NCollection_List<TCollection_AsciiString> anIONameList;
1635
1636 if (isRemoveAll)
1637 {
1638 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
1639 anIter.More(); anIter.Next())
1640 {
1641 anIONameList.Append (anIter.Key2());
1642 }
1643 }
1644 else if (isContextOnly ? theArgNb > 2 : theArgNb > 1) // removed objects names are in argument list
1645 {
1646 for (Standard_Integer anIt = isContextOnly ? 2 : 1; anIt < theArgNb; ++anIt)
1647 {
1648 TCollection_AsciiString aName = theArgVec[anIt];
1649
1650 if (!GetMapOfAIS().IsBound2 (aName))
1651 {
1652 theDI << aName.ToCString() << " was not bound to some object.\n";
1653 continue;
1654 }
1655
1656 const Handle(Standard_Transient)& aTransientObj = GetMapOfAIS().Find2 (aName);
1657
1658 const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aTransientObj);
1659 if (!anIO.IsNull())
1660 {
1661 if (anIO->GetContext() != TheAISContext())
1662 {
1663 theDI << aName.ToCString() << " was not displayed in current context.\n";
1664 theDI << "Please activate view with this object displayed and try again.\n";
1665 continue;
1666 }
1667
1668 anIONameList.Append (aName);
1669 continue;
1670 }
1671
1672 const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (aTransientObj);
1673 if (!aNisIO.IsNull())
1674 {
1675 anIONameList.Append (aName);
1676 }
1677 }
1678 }
1679 else if (TheAISContext()->NbCurrents() > 0
1680 || TheNISContext()->GetSelected().Extent() > 0)
1681 {
1682 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
1683 anIter.More(); anIter.Next())
1684 {
1685 const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
1686 if (!anIO.IsNull())
1687 {
1688 if (!TheAISContext()->IsCurrent (anIO))
1689 {
1690 continue;
1691 }
1692
1693 anIONameList.Append (anIter.Key2());
1694 continue;
1695 }
1696
1697 const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
1698 if (!aNisIO.IsNull())
1699 {
1700 if (!TheNISContext()->IsSelected (aNisIO))
1701 {
1702 continue;
1703 }
1704
1705 anIONameList.Append (anIter.Key2());
1706 }
1707 }
1708 }
1709
1710 // Unbind all removed objects from the map of displayed IO.
1711 for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
1712 anIter.More(); anIter.Next())
1713 {
1714 const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
1715
1716 if (!anIO.IsNull())
1717 {
1718 TheAISContext()->Remove (anIO, Standard_False);
1719 theDI << anIter.Value().ToCString() << " was removed\n";
1720 }
1721 else
1722 {
1723 const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
1724 if (!aNisIO.IsNull())
1725 {
1726 TheNISContext()->Remove (aNisIO);
1727 theDI << anIter.Value().ToCString() << " was removed\n";
1728 }
1729 }
1730
1731 if (!isContextOnly)
1732 {
1733 GetMapOfAIS().UnBind2 (anIter.Value());
1734 }
1735 }
1736
1737 TheAISContext()->UpdateCurrentViewer();
1738 return 0;
1739}
1740
1741//==============================================================================
b514beda 1742//function : VErase
1743//purpose : Erase some selected or named objects
7fd59977 1744// if there is no selected or named objects, the whole viewer is erased
7fd59977 1745//==============================================================================
b514beda 1746int VErase (Draw_Interpretor& theDI,
1747 Standard_Integer theArgNb,
1748 const char** theArgVec)
7fd59977 1749{
b514beda 1750 if (a3DView().IsNull())
1751 {
7fd59977 1752 return 1;
b514beda 1753 }
7fd59977 1754
b514beda 1755 TheAISContext()->CloseAllContexts (Standard_False);
1756 const Standard_Boolean isEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "").IsEqual ("veraseall");
1757 if (theArgNb > 1)
1758 {
1759 if (isEraseAll)
1760 {
1761 std::cerr << " Syntax error: " << theArgVec[0] << " too much arguments.\n";
1762 return 1;
7fd59977 1763 }
1764
b514beda 1765 // has a list of names
1766 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
1767 {
1768 TCollection_AsciiString aName = theArgVec[anArgIter];
1769 if (!GetMapOfAIS().IsBound2 (aName))
1770 {
1771 continue;
1772 }
7fd59977 1773
b514beda 1774 const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
1775 const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anObj);
1776 theDI << aName.ToCString() << " ";
1777 if (!anIO.IsNull())
1778 {
1779 TheAISContext()->Erase (anIO, Standard_False);
1780 }
1781 else
1782 {
1783 const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anObj);
1784 if (!aNisIO.IsNull())
1785 {
1786 TheNISContext()->Erase (aNisIO);
1787 }
7fd59977 1788 }
7fd59977 1789 }
b514beda 1790 TheAISContext()->UpdateCurrentViewer();
1791 return 0;
7fd59977 1792 }
1793
b514beda 1794 if (!isEraseAll
1795 && TheAISContext()->NbCurrents() > 0)
1796 {
1797 // remove all currently selected objects
1798 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
1799 anIter.More(); anIter.Next())
1800 {
1801 const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
1802 if (!anIO.IsNull()
1803 && TheAISContext()->IsCurrent (anIO))
1804 {
1805 theDI << anIter.Key2().ToCString() << " ";
1806 TheAISContext()->Erase (anIO, Standard_False);
7fd59977 1807 }
1808 }
7fd59977 1809
b514beda 1810 TheAISContext()->UpdateCurrentViewer();
1811 return 0;
1812 }
7fd59977 1813
b514beda 1814 // erase entire viewer
1815 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
1816 anIter.More(); anIter.Next())
1817 {
1818 const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
1819 if (!anIO.IsNull())
1820 {
1821 TheAISContext()->Erase (anIO, Standard_False);
1822 }
1823 else
1824 {
1825 const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
1826 if (!aNisIO.IsNull())
1827 {
1828 TheNISContext()->Erase (aNisIO);
1829 }
7fd59977 1830 }
7fd59977 1831 }
b514beda 1832 TheAISContext()->UpdateCurrentViewer();
7fd59977 1833 return 0;
1834}
1835
7fd59977 1836//==============================================================================
1837//function : VDisplayAll
1838//author : ege
1839//purpose : Display all the objects of the Map
1840//Draw arg : vdisplayall
1841//==============================================================================
1842static int VDisplayAll( Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1843
1844{
1845 if (! a3DView().IsNull() ) {
1846 if (argc > 1) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
1847 if (TheAISContext()->HasOpenedContext())
1848 TheAISContext()->CloseLocalContext();
1849 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
1850 it (GetMapOfAIS());
1851 while ( it.More() ) {
1852 if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1853 const Handle(AIS_InteractiveObject) aShape =
1854 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
1855 TheAISContext()->Erase(aShape,Standard_False);
1856 } else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
1857 const Handle(NIS_InteractiveObject) aShape =
1858 Handle(NIS_InteractiveObject)::DownCast(it.Key1());
ffe2bea7 1859 TheNISContext()->Erase(aShape);
7fd59977 1860 }
1861 it.Next();
1862 }
1863 it.Reset();
1864 while ( it.More() ) {
1865 if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
1866 const Handle(AIS_InteractiveObject) aShape =
1867 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
1868 TheAISContext()->Display(aShape, Standard_False);
1869 } else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
ffe2bea7 1870 Handle(NIS_InteractiveObject) aShape =
7fd59977 1871 Handle(NIS_InteractiveObject)::DownCast(it.Key1());
ffe2bea7 1872 TheNISContext()->Display(aShape);
7fd59977 1873 }
1874 it.Next();
1875 }
1876 TheAISContext() ->UpdateCurrentViewer();
ffe2bea7 1877// TheNISContext() ->UpdateViews();
7fd59977 1878 }
1879 return 0;
1880}
1881
7fd59977 1882//#######################################################################################################
1883
1884//## VTexture
1885
1886//#######################################################################################################
1887
1888Standard_Integer VTexture (Draw_Interpretor& di,Standard_Integer argc, const char** argv )
1889{
1890 Standard_Integer command = (strcasecmp(argv[0],"vtexture")==0)? 1:
1891 (strcasecmp(argv[0],"vtexscale")==0) ? 2 :
1892 (strcasecmp(argv[0],"vtexorigin")==0) ? 3 :
1893 (strcasecmp(argv[0],"vtexrepeat")==0) ? 4 :
1894 (strcasecmp(argv[0],"vtexdefault")==0) ? 5 : -1;
1895
1896 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1897 if(myAISContext.IsNull())
1898 {
1899 di << "use 'vinit' command before " << argv[0] << "\n";
31160f80 1900 return 1;
7fd59977 1901 }
1902
1903 Handle(AIS_InteractiveObject) TheAisIO;
1904 Handle(AIS_TexturedShape) myShape;
1905 Standard_Integer myPreviousMode = 0;
1906
31160f80 1907 if (argc<2 || !argv[1])
7fd59977 1908 {
1909 di << argv[0] <<" syntax error - Type 'help vtex'"<<"\n";
31160f80 1910 return 1;
7fd59977 1911 }
1912
1913 TCollection_AsciiString name = argv[1];
1914 ViewerTest::CurrentView()->SetSurfaceDetail(V3d_TEX_ALL);
1915
1916 if (GetMapOfAIS().IsBound2(name))
1917 TheAisIO = Handle(AIS_InteractiveObject)::DownCast
1918 (GetMapOfAIS().Find2(name));
1919 if (TheAisIO.IsNull())
1920 {
1921 di <<"shape "<<name.ToCString()<<" doesn\'t exist"<<"\n";
31160f80 1922 return 1;
7fd59977 1923 }
1924
1925 if (TheAisIO->IsKind(STANDARD_TYPE(AIS_TexturedShape)) && !TheAisIO.IsNull())
1926 {
1927 myShape = Handle(AIS_TexturedShape)::DownCast(TheAisIO);
1928 myPreviousMode = myShape->DisplayMode() ;
1929 }
1930 else
1931 {
31160f80 1932 myAISContext->Clear(TheAisIO,Standard_False);
7fd59977 1933 myShape = new AIS_TexturedShape (DBRep::Get(argv[1]));
1934 GetMapOfAIS().UnBind1(TheAisIO);
1935 GetMapOfAIS().UnBind2(name);
1936 GetMapOfAIS().Bind(myShape, name);
1937 }
1938 switch (command)
1939 {
1940 case 1: // vtexture : we only map a texture on the shape
1941 if(argc<=1)
1942 {
1943 di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
31160f80 1944 return 1;
7fd59977 1945 }
31160f80 1946 if (argc>2 && argv[2])
7fd59977 1947 {
1948 if(strcasecmp(argv[2],"?")==0)
1949 {
bf75be98 1950 TCollection_AsciiString monPath = Graphic3d_TextureRoot::TexturesFolder();
7fd59977 1951 di<<"\n Files in current directory : \n"<<"\n";
1952 TCollection_AsciiString Cmnd ("glob -nocomplain *");
1953 di.Eval(Cmnd.ToCString());
1954
1955 Cmnd = TCollection_AsciiString("glob -nocomplain ") ;
1956 Cmnd += monPath ;
1957 Cmnd += "/* " ;
1958 di<<"Files in "<<monPath.ToCString()<<" : \n"<<"\n";
1959 di.Eval(Cmnd.ToCString());
1960
1961 return 0;
1962 }
1963 else
1964 myShape->SetTextureFileName(argv[2]);
1965 }
1966 else
1967 {
1968 di <<"Texture mapping disabled \n \
1969 To enable it, use 'vtexture NameOfShape NameOfTexture' \n"<<"\n";
1970
1971 myAISContext->SetDisplayMode(myShape,1,Standard_False);
1972 if (myPreviousMode == 3 )
1973 myAISContext->RecomputePrsOnly(myShape);
1974 myAISContext->Display(myShape, Standard_True);
1975 return 0;
1976 }
1977 break;
1978
1979 case 2: // vtexscale : we change the scaling factor of the texture
1980
1981 if(argc<2)
1982 {
1983 di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
31160f80 1984 return 1;
7fd59977 1985 }
1986
1987 myShape->SetTextureScale (( argv[2] ? Standard_True : Standard_False ),
91322f44 1988 ( argv[2] ? Draw::Atof(argv[2]) : 1.0 ),
1989 ( argv[2] ? Draw::Atof(argv[argc-1]) : 1.0 ) );
7fd59977 1990 break;
1991
1992 case 3: // vtexorigin : we change the origin of the texture on the shape
1993 if(argc<2)
1994 {
1995 di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
31160f80 1996 return 1;
7fd59977 1997 }
1998 myShape->SetTextureOrigin (( argv[2] ? Standard_True : Standard_False ),
91322f44 1999 ( argv[2] ? Draw::Atof(argv[2]) : 0.0 ),
2000 ( argv[2] ? Draw::Atof(argv[argc-1]) : 0.0 ));
7fd59977 2001 break;
2002
2003 case 4: // vtexrepeat : we change the number of occurences of the texture on the shape
2004 if(argc<2)
2005 {
2006 di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
31160f80 2007 return 1;
7fd59977 2008 }
31160f80 2009 if (argc>2 && argv[2])
7fd59977 2010 {
2011 di <<"Texture repeat enabled"<<"\n";
91322f44 2012 myShape->SetTextureRepeat(Standard_True, Draw::Atof(argv[2]), Draw::Atof(argv[argc-1]) );
7fd59977 2013 }
2014 else
2015 {
2016 di <<"Texture repeat disabled"<<"\n";
2017 myShape->SetTextureRepeat(Standard_False);
2018 }
2019 break;
2020
2021 case 5: // vtexdefault : default texture mapping
2022 // ScaleU = ScaleV = 100.0
2023 // URepeat = VRepeat = 1.0
2024 // Uorigin = VOrigin = 0.0
2025
2026 if(argc<2)
2027 {
2028 di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
31160f80 2029 return 1;
7fd59977 2030 }
2031 myShape->SetTextureRepeat(Standard_False);
2032 myShape->SetTextureOrigin(Standard_False);
2033 myShape->SetTextureScale (Standard_False);
2034 break;
2035 }
2036
2037 if ((myShape->DisplayMode() == 3) || (myPreviousMode == 3 ))
2038 myAISContext->RecomputePrsOnly(myShape);
2039 else
2040 {
2041 myAISContext->SetDisplayMode(myShape,3,Standard_False);
2042 myAISContext->Display(myShape, Standard_True);
2043 myAISContext->Update(myShape,Standard_True);
2044 }
31160f80 2045 return 0;
7fd59977 2046}
2047
2048//==============================================================================
2049//function : VDisplay2
2050//author : ege
2051//purpose : Display an object from its name
2052//Draw arg : vdisplay name1 [name2] ... [name n]
2053//==============================================================================
2054static int VDisplay2 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2055
2056{
2057 // Verification des arguments
2058 if ( a3DView().IsNull() ) {
2059
2060 ViewerTest::ViewerInit();
2061 di<<"La commande vinit n'a pas ete appele avant"<<"\n";
2062 // return 1;
2063 }
2064
2065 if ( argc<2) {
2066 di<<argv[0]<<" Syntaxe error"<<"\n";
2067 return 1;
2068 }
2069
2070
2071 TCollection_AsciiString name;
2072 if (TheAISContext()->HasOpenedContext())
2073 TheAISContext()->CloseLocalContext();
2074
2075 for ( int i = 1; i < argc; i++ ) {
2076 name = argv[i];
2077 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
2078 Standard_Boolean IsDatum = Standard_False;
2079 Handle(Standard_Transient) anObj;
2080 if ( IsBound ) {
2081 anObj = GetMapOfAIS().Find2(name);
2082 if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
2083 Handle(AIS_InteractiveObject) aShape =
2084 Handle(AIS_InteractiveObject)::DownCast(anObj);
2085 if (aShape->Type()==AIS_KOI_Datum) {
2086 IsDatum = Standard_True;
2087 TheAISContext()->Display(aShape, Standard_False);
2088 }
2089 if (!IsDatum) {
2090 di << "Display " << name.ToCString() << "\n";
2091 // Get the Shape from a name
2092 TopoDS_Shape NewShape = GetShapeFromName((const char *)name.ToCString());
2093
2094 // Update the Shape in the AIS_Shape
2095 Handle(AIS_Shape) TheRealSh = Handle(AIS_Shape)::DownCast(aShape);
2096 if(!TheRealSh.IsNull())
2097 TheRealSh->Set(NewShape);
2098 TheAISContext()->Redisplay(aShape, Standard_False);
2099 TheAISContext()->Display(aShape, Standard_False);
2100 }
2101 aShape.Nullify();
2102 } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
2103 Handle(NIS_InteractiveObject) aShape =
2104 Handle(NIS_InteractiveObject)::DownCast(anObj);
ffe2bea7 2105 TheNISContext()->Display(aShape);
7fd59977 2106 }
2107 }
2108 else { // Create the AIS_Shape from a name
2109 const Handle(AIS_InteractiveObject) aShape =
2110 GetAISShapeFromName((const char *)name.ToCString());
2111 if ( !aShape.IsNull() ) {
2112 GetMapOfAIS().Bind(aShape, name);
2113 TheAISContext()->Display(aShape, Standard_False);
2114 }
2115 }
2116 }
2117 // Upadate the screen and redraw the view
2118 TheAISContext()->UpdateCurrentViewer();
ffe2bea7 2119// TheNISContext()->UpdateViews();
7fd59977 2120 return 0;
2121}
2122
f3889691 2123//===============================================================================================
2124//function : VUpdate
2125//purpose :
2126//===============================================================================================
2127static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
2128{
2129 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
2130 if (aContextAIS.IsNull())
2131 {
2132 std::cout << theArgVec[0] << "AIS context is not available.\n";
2133 return 1;
2134 }
2135
2136 if (theArgsNb < 2)
2137 {
2138 std::cout << theArgVec[0] << ": insufficient arguments. Type help for more information.\n";
2139 return 1;
2140 }
2141
2142 const ViewerTest_DoubleMapOfInteractiveAndName& anAISMap = GetMapOfAIS();
2143
2144 AIS_ListOfInteractive aListOfIO;
2145
2146 for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
2147 {
2148 TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]);
2149
2150 Handle(AIS_InteractiveObject) anAISObj;
2151 if (anAISMap.IsBound2 (aName))
2152 {
2153 anAISObj = Handle(AIS_InteractiveObject)::DownCast (anAISMap.Find2 (aName));
2154 }
2155
2156 if (anAISObj.IsNull())
2157 {
2158 std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n";
2159 return 1;
2160 }
2161
2162 aListOfIO.Append (anAISObj);
2163 }
2164
2165 AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO);
2166 for (; anIOIt.More(); anIOIt.Next())
2167 {
2168 aContextAIS->Update (anIOIt.Value(), Standard_False);
2169 }
2170
2171 aContextAIS->UpdateCurrentViewer();
2172
2173 return 0;
2174}
2175
7fd59977 2176//==============================================================================
7fd59977 2177//function : VPerf
2178//purpose : Test the annimation of an object along a
2179// predifined trajectory
2180//Draw arg : vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)
2181//==============================================================================
2182
2183static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
2184
2185 OSD_Timer myTimer;
2186 if (TheAISContext()->HasOpenedContext())
2187 TheAISContext()->CloseLocalContext();
2188
c6541a0c 2189 Standard_Real Step=4*M_PI/180;
7fd59977 2190 Standard_Real Angle=0;
2191
2192 Handle(AIS_InteractiveObject) aIO;
2193 if (GetMapOfAIS().IsBound2(argv[1]))
2194 aIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
2195 if (aIO.IsNull())
2196 return 1;
2197
2198 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aIO);
2199
2200 myTimer.Start();
2201
91322f44 2202 if (Draw::Atoi(argv[3])==1 ) {
7fd59977 2203 di<<" Primitives sensibles OFF"<<"\n";
2204 TheAISContext()->Deactivate(aIO);
2205 }
2206 else {
2207 di<<" Primitives sensibles ON"<<"\n";
2208 }
2209 // Movement par transformation
91322f44 2210 if(Draw::Atoi(argv[2]) ==1) {
7fd59977 2211 di<<" Calcul par Transformation"<<"\n";
c6541a0c 2212 for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
7fd59977 2213
2214 Angle=Step*myAngle;
2215 gp_Trsf myTransfo;
2216 myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ) ,Angle );
2217 TheAISContext()->SetLocation(aShape,myTransfo);
2218 TheAISContext() ->UpdateCurrentViewer();
2219
2220 }
2221 }
2222 else {
2223 di<<" Calcul par Locations"<<"\n";
2224 gp_Trsf myAngleTrsf;
2225 myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ), Step );
2226 TopLoc_Location myDeltaAngle (myAngleTrsf);
2227 TopLoc_Location myTrueLoc;
2228
c6541a0c 2229 for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
7fd59977 2230
2231 Angle=Step*myAngle;
2232 myTrueLoc=myTrueLoc*myDeltaAngle;
2233 TheAISContext()->SetLocation(aShape,myTrueLoc );
2234 TheAISContext() ->UpdateCurrentViewer();
2235 }
2236 }
91322f44 2237 if (Draw::Atoi(argv[3])==1 ){
7fd59977 2238 // On reactive la selection des primitives sensibles
2239 TheAISContext()->Activate(aIO,0);
2240 }
2241 a3DView() -> Redraw();
2242 myTimer.Stop();
2243 di<<" Temps ecoule "<<"\n";
2244 myTimer.Show();
2245 return 0;
2246}
2247
2248
2249//==================================================================================
2250// Function : VAnimation
2251//==================================================================================
2252static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
31160f80 2253 if (argc != 5) {
7fd59977 2254 di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n";
2255 return 1;
2256 }
2257
2258 Standard_Real thread = 4;
2259 Standard_Real angleA=0;
2260 Standard_Real angleB;
2261 Standard_Real X;
2262 gp_Ax1 Ax1(gp_Pnt(0,0,0),gp_Vec(0,0,1));
2263
2264 BRep_Builder B;
2265 TopoDS_Shape CrankArm;
2266 TopoDS_Shape CylinderHead;
2267 TopoDS_Shape Propeller;
2268 TopoDS_Shape EngineBlock;
2269
2270 //BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B);
2271 //BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B);
2272 //BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B);
2273 //BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B);
2274 BRepTools::Read(CrankArm,argv[1],B);
2275 BRepTools::Read(CylinderHead,argv[2],B);
2276 BRepTools::Read(Propeller,argv[3],B);
2277 BRepTools::Read(EngineBlock,argv[4],B);
2278
2279 if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) {di<<" Syntaxe error:loading failure."<<"\n";}
2280
2281
2282 OSD_Timer myTimer;
2283 myTimer.Start();
2284
2285 Handle(AIS_Shape) myAisCylinderHead = new AIS_Shape (CylinderHead);
2286 Handle(AIS_Shape) myAisEngineBlock = new AIS_Shape (EngineBlock);
2287 Handle(AIS_Shape) myAisCrankArm = new AIS_Shape (CrankArm);
2288 Handle(AIS_Shape) myAisPropeller = new AIS_Shape (Propeller);
2289
2290 GetMapOfAIS().Bind(myAisCylinderHead,"a");
2291 GetMapOfAIS().Bind(myAisEngineBlock,"b");
2292 GetMapOfAIS().Bind(myAisCrankArm,"c");
2293 GetMapOfAIS().Bind(myAisPropeller,"d");
2294
2295 TheAISContext()->SetColor(myAisCylinderHead, Quantity_NOC_INDIANRED);
2296 TheAISContext()->SetColor(myAisEngineBlock , Quantity_NOC_RED);
2297 TheAISContext()->SetColor(myAisPropeller , Quantity_NOC_GREEN);
2298
2299 TheAISContext()->Display(myAisCylinderHead,Standard_False);
2300 TheAISContext()->Display(myAisEngineBlock,Standard_False );
2301 TheAISContext()->Display(myAisCrankArm,Standard_False );
2302 TheAISContext()->Display(myAisPropeller,Standard_False);
2303
2304 TheAISContext()->Deactivate(myAisCylinderHead);
2305 TheAISContext()->Deactivate(myAisEngineBlock );
2306 TheAISContext()->Deactivate(myAisCrankArm );
2307 TheAISContext()->Deactivate(myAisPropeller );
2308
2309 // Boucle de mouvement
c6541a0c 2310 for (Standard_Real myAngle = 0;angleA<2*M_PI*10.175 ;myAngle++) {
7fd59977 2311
c6541a0c 2312 angleA = thread*myAngle*M_PI/180;
7fd59977 2313 X = Sin(angleA)*3/8;
2314 angleB = atan(X / Sqrt(-X * X + 1));
2315 Standard_Real decal(25*0.6);
2316
2317
2318 //Build a transformation on the display
2319 gp_Trsf aPropellerTrsf;
2320 aPropellerTrsf.SetRotation(Ax1,angleA);
2321 TheAISContext()->SetLocation(myAisPropeller,aPropellerTrsf);
2322
2323 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));
2324 gp_Trsf aCrankArmTrsf;
2325 aCrankArmTrsf.SetTransformation( base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB));
2326 TheAISContext()->SetLocation(myAisCrankArm,aCrankArmTrsf);
2327
2328 TheAISContext()->UpdateCurrentViewer();
2329 }
2330
2331 TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Location() );
2332 TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Location() );
2333
2334 myAisCrankArm ->ResetLocation();
2335 myAisPropeller->ResetLocation();
2336
2337 myAisCrankArm -> Set(myNewCrankArm );
2338 myAisPropeller -> Set(myNewPropeller);
2339
2340 TheAISContext()->Activate(myAisCylinderHead,0);
2341 TheAISContext()->Activate(myAisEngineBlock,0 );
2342 TheAISContext()->Activate(myAisCrankArm ,0 );
2343 TheAISContext()->Activate(myAisPropeller ,0 );
2344
2345 myTimer.Stop();
2346 myTimer.Show();
2347 myTimer.Start();
2348
2349 TheAISContext()->Redisplay(myAisCrankArm ,Standard_False);
2350 TheAISContext()->Redisplay(myAisPropeller,Standard_False);
2351
2352 TheAISContext()->UpdateCurrentViewer();
2353 a3DView()->Redraw();
2354
2355 myTimer.Stop();
2356 myTimer.Show();
2357
2358 return 0;
2359
2360}
2361
2362//==============================================================================
2363//function : VShading
2364//purpose : Sharpen or roughten the quality of the shading
2365//Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg
2366//==============================================================================
5cbef0fe
S
2367static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
2368{
7fd59977 2369 Standard_Real myDevCoef;
2370 Handle(AIS_InteractiveObject) TheAisIO;
2371
2372 // Verifications
5cbef0fe
S
2373 const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
2374
7fd59977 2375 if (TheAISContext()->HasOpenedContext())
2376 TheAISContext()->CloseLocalContext();
2377
2378 if (argc < 3) {
2379 myDevCoef = 0.0008;
2380 } else {
91322f44 2381 myDevCoef =Draw::Atof(argv[2]);
7fd59977 2382 }
2383
7fd59977 2384 TCollection_AsciiString name=argv[1];
2385 if (GetMapOfAIS().IsBound2(name ))
5cbef0fe 2386 TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
7fd59977 2387 if (TheAisIO.IsNull())
2388 TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
2389
5cbef0fe 2390 if (HaveToSet)
7fd59977 2391 TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
5cbef0fe 2392 else
7fd59977 2393 TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
2394
7fd59977 2395 TheAISContext()->Redisplay(TheAisIO);
2396 return 0;
2397}
2398//==============================================================================
2399//function : HaveMode
2400//use : VActivatedModes
2401//==============================================================================
2402#include <TColStd_ListIteratorOfListOfInteger.hxx>
2403
2404Standard_Boolean HaveMode(const Handle(AIS_InteractiveObject)& TheAisIO,const Standard_Integer mode )
2405{
2406 TColStd_ListOfInteger List;
2407 TheAISContext()->ActivatedModes (TheAisIO,List);
2408 TColStd_ListIteratorOfListOfInteger it;
2409 Standard_Boolean Found=Standard_False;
2410 for (it.Initialize(List); it.More()&&!Found; it.Next() ){
2411 if (it.Value()==mode ) Found=Standard_True;
2412 }
2413 return Found;
2414}
2415
2416
2417
2418//==============================================================================
2419//function : VActivatedMode
2420//author : ege
2421//purpose : permet d'attribuer a chacune des shapes un mode d'activation
2422// (edges,vertex...)qui lui est propre et le mode de selection standard.
2423// La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer)
2424// Dans le cas ou on veut psser la shape en argument, la fonction n'autorise
2425// qu'un nom et qu'un mode.
2426//Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7)
2427//==============================================================================
2428#include <AIS_ListIteratorOfListOfInteractive.hxx>
2429
2430static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2431
2432{
7fd59977 2433 Standard_Boolean ThereIsName = Standard_False ;
2434
2435 if(!a3DView().IsNull()){
2436
5cbef0fe 2437 const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
7fd59977 2438 // verification des arguments
2439 if (HaveToSet) {
2440 if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;}
5cbef0fe 2441 ThereIsName = (argc == 3);
7fd59977 2442 }
2443 else {
2444 // vunsetam
2445 if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;}
2446 else {
5cbef0fe
S
2447 di<<" R.A.Z de tous les modes de selecion"<<"\n";
2448 di<<" Fermeture du Context local"<<"\n";
7fd59977 2449 if (TheAISContext()->HasOpenedContext())
2450 TheAISContext()->CloseLocalContext();
2451 }
7fd59977 2452 }
2453
7fd59977 2454 // IL n'y a aps de nom de shape passe en argument
2455 if (HaveToSet && !ThereIsName){
91322f44 2456 Standard_Integer aMode=Draw::Atoi(argv [1]);
7fd59977 2457
2458 const char *cmode="???";
7fd59977 2459 switch (aMode) {
2460 case 0: cmode = "Shape"; break;
2461 case 1: cmode = "Vertex"; break;
2462 case 2: cmode = "Edge"; break;
2463 case 3: cmode = "Wire"; break;
2464 case 4: cmode = "Face"; break;
2465 case 5: cmode = "Shell"; break;
2466 case 6: cmode = "Solid"; break;
2467 case 7: cmode = "Compound"; break;
2468 }
2469
2470 if( !TheAISContext()->HasOpenedContext() ) {
5cbef0fe
S
2471 // il n'y a pas de Context local d'ouvert
2472 // on en ouvre un et on charge toutes les shapes displayees
2473 // on load tous les objets displayees et on Activate les objets de la liste
2474 AIS_ListOfInteractive ListOfIO;
2475 // on sauve dans une AISListOfInteractive tous les objets currents
2476 if (TheAISContext()->NbCurrents()>0 ){
2477 TheAISContext()->UnhilightCurrents(Standard_False);
2478
2479 for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
2480 ListOfIO.Append(TheAISContext()->Current() );
7fd59977 2481 }
2482 }
2483
2484 TheAISContext()->OpenLocalContext(Standard_False);
2485 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
2486 it (GetMapOfAIS());
2487 while(it.More()){
2488 Handle(AIS_InteractiveObject) aIO =
2489 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
2490 if (!aIO.IsNull())
2491 TheAISContext()->Load(aIO,0,Standard_False);
2492 it.Next();
2493 }
2494 // traitement des objets qui etaient currents dans le Contexte global
2495 if (!ListOfIO.IsEmpty() ) {
2496 // il y avait des objets currents
2497 AIS_ListIteratorOfListOfInteractive iter;
2498 for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) {
2499 Handle(AIS_InteractiveObject) aIO=iter.Value();
2500 TheAISContext()->Activate(aIO,aMode);
2501 di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2502 }
2503 }
2504 else {
2505 // On applique le mode a tous les objets displayes
2506 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
2507 it2 (GetMapOfAIS());
2508 while(it2.More()){
2509 Handle(AIS_InteractiveObject) aIO =
2510 Handle(AIS_InteractiveObject)::DownCast(it2.Key1());
2511 if (!aIO.IsNull()) {
2512 di<<" Mode: "<<cmode<<" ON pour "<<it2.Key2().ToCString() <<"\n";
2513 TheAISContext()->Activate(aIO,aMode);
2514 }
2515 it2.Next();
2516 }
2517 }
2518
2519 }
2520
2521 else {
2522 // un Context local est deja ouvert
2523 // Traitement des objets du Context local
2524 if (TheAISContext()->NbSelected()>0 ){
2525 TheAISContext()->UnhilightSelected(Standard_False);
2526 // il y a des objets selected,on les parcourt
2527 for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
2528 Handle(AIS_InteractiveObject) aIO=TheAISContext()->Interactive();
2529
2530
2531 if (HaveMode(aIO,aMode) ) {
2532 di<<" Mode: "<<cmode<<" OFF pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2533 TheAISContext()->Deactivate(aIO,aMode);
2534 }
2535 else{
2536 di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2537 TheAISContext()->Activate(aIO,aMode);
2538 }
2539
2540 }
2541 }
2542 else{
2543 // il n'y a pas d'objets selected
2544 // tous les objets diplayes sont traites
2545 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
2546 it (GetMapOfAIS());
2547 while(it.More()){
2548 Handle(AIS_InteractiveObject) aIO =
2549 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
2550 if (!aIO.IsNull()) {
2551 if (HaveMode(aIO,aMode) ) {
2552 di<<" Mode: "<<cmode<<" OFF pour "
2553 <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2554 TheAISContext()->Deactivate(aIO,aMode);
2555 }
2556 else{
2557 di<<" Mode: "<<cmode<<" ON pour"
2558 <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2559 TheAISContext()->Activate(aIO,aMode);
2560 }
2561 }
2562 it.Next();
2563 }
2564 }
2565 }
2566 }
2567 else if (HaveToSet && ThereIsName){
91322f44 2568 Standard_Integer aMode=Draw::Atoi(argv [2]);
7fd59977 2569 Handle(AIS_InteractiveObject) aIO =
2570 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
2571
2572 if (!aIO.IsNull()) {
2573 const char *cmode="???";
2574
2575 switch (aMode) {
2576 case 0: cmode = "Shape"; break;
2577 case 1: cmode = "Vertex"; break;
2578 case 2: cmode = "Edge"; break;
2579 case 3: cmode = "Wire"; break;
2580 case 4: cmode = "Face"; break;
2581 case 5: cmode = "Shell"; break;
2582 case 6: cmode = "Solid"; break;
2583 case 7: cmode = "Compound"; break;
2584 }
2585
2586 if( !TheAISContext()->HasOpenedContext() ) {
2587 TheAISContext()->OpenLocalContext(Standard_False);
2588 // On charge tous les objets de la map
2589 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
2590 while(it.More()){
2591 Handle(AIS_InteractiveObject) aShape=
2592 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
2593 if (!aShape.IsNull())
2594 TheAISContext()->Load(aShape,0,Standard_False);
2595 it.Next();
2596 }
2597 TheAISContext()->Activate(aIO,aMode);
2598 di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
2599 }
2600
2601 else {
2602 // un Context local est deja ouvert
2603 if (HaveMode(aIO,aMode) ) {
2604 di<<" Mode: "<<cmode<<" OFF pour "<<argv[1]<<"\n";
2605 TheAISContext()->Deactivate(aIO,aMode);
2606 }
2607 else{
2608 di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
2609 TheAISContext()->Activate(aIO,aMode);
2610 }
2611 }
2612 }
2613 }
2614 }
2615 return 0;
7fd59977 2616}
2617
cb78155f 2618//! Auxiliary method to print Interactive Object information
2619static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected,
2620 const Handle(Standard_Transient)& theObject,
2621 Draw_Interpretor& theDI)
2622{
2623 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theObject);
2624 if (anObj.IsNull())
2625 {
2626 theDI << theObject->DynamicType()->Name() << " is not AIS presentation\n";
2627 return;
2628 }
7fd59977 2629
cb78155f 2630 theDI << (TheAISContext()->IsDisplayed (anObj) ? "Displayed" : "Hidden ")
2631 << (TheAISContext()->IsSelected (anObj) ? " Selected" : " ")
2632 << (theDetected.Contains (anObj) ? " Detected" : " ")
2633 << " Type: ";
2634 if (anObj->Type() == AIS_KOI_Datum)
2635 {
2636 // AIS_Datum
2637 if (anObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
2638 else if (anObj->Signature() == 2) { theDI << " AIS_Axis"; }
2639 else if (anObj->Signature() == 6) { theDI << " AIS_Circle"; }
2640 else if (anObj->Signature() == 5) { theDI << " AIS_Line"; }
2641 else if (anObj->Signature() == 7) { theDI << " AIS_Plane"; }
2642 else if (anObj->Signature() == 1) { theDI << " AIS_Point"; }
2643 else if (anObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
7fd59977 2644 }
2645 // AIS_Shape
cb78155f 2646 else if (anObj->Type() == AIS_KOI_Shape
2647 && anObj->Signature() == 0)
2648 {
2649 theDI << " AIS_Shape";
7fd59977 2650 }
cb78155f 2651 else if (anObj->Type() == AIS_KOI_Relation)
2652 {
2653 // AIS_Dimention and AIS_Relation
2654 Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (anObj);
2655 switch (aRelation->KindOfDimension())
2656 {
2657 case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break;
2658 case AIS_KOD_LENGTH: theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break;
2659 case AIS_KOD_DIAMETER: theDI << " AIS_DiameterDimension"; break;
2660 case AIS_KOD_ELLIPSERADIUS: theDI << " AIS_EllipseRadiusDimension"; break;
2661 //case AIS_KOD_FILLETRADIUS: theDI << " AIS_FilletRadiusDimension "; break;
2662 case AIS_KOD_OFFSET: theDI << " AIS_OffsetDimension"; break;
2663 case AIS_KOD_RADIUS: theDI << " AIS_RadiusDimension"; break;
2664 default: theDI << " UNKNOWN dimension"; break;
2665 }
2666 }
2667 else
2668 {
2669 theDI << " UserPrs";
2670 }
2671 theDI << " (" << theObject->DynamicType()->Name() << ")";
7fd59977 2672}
2673
cb78155f 2674//! Print information about locally selected sub-shapes
2675static void localCtxInfo (Draw_Interpretor& theDI)
2676{
2677 Handle(AIS_InteractiveContext) aCtx = TheAISContext();
2678 if (!aCtx->HasOpenedContext())
2679 {
2680 return;
2681 }
7fd59977 2682
cb78155f 2683 TCollection_AsciiString aPrevName;
2684 Handle(AIS_LocalContext) aCtxLoc = aCtx->LocalContext();
2685 for (aCtxLoc->InitSelected(); aCtxLoc->MoreSelected(); aCtxLoc->NextSelected())
2686 {
2687 const TopoDS_Shape aSubShape = aCtxLoc->SelectedShape();
2688 const Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (aCtxLoc->SelectedInteractive());
2689 if (aSubShape.IsNull()
2690 || aShapeIO.IsNull()
2691 || !GetMapOfAIS().IsBound1 (aShapeIO))
2692 {
2693 continue;
2694 }
2695
2696 const TCollection_AsciiString aParentName = GetMapOfAIS().Find1 (aShapeIO);
2697 TopTools_MapOfShape aFilter;
2698 Standard_Integer aNumber = 0;
2699 const TopoDS_Shape aShape = aShapeIO->Shape();
2700 for (TopExp_Explorer anIter (aShape, aSubShape.ShapeType());
2701 anIter.More(); anIter.Next())
2702 {
2703 if (!aFilter.Add (anIter.Current()))
2704 {
2705 continue; // filter duplicates
2706 }
2707
2708 ++aNumber;
2709 if (!anIter.Current().IsSame (aSubShape))
2710 {
2711 continue;
2712 }
2713
2714 Standard_CString aShapeName = NULL;
2715 switch (aSubShape.ShapeType())
2716 {
2717 case TopAbs_COMPOUND: aShapeName = " Compound"; break;
2718 case TopAbs_COMPSOLID: aShapeName = "CompSolid"; break;
2719 case TopAbs_SOLID: aShapeName = " Solid"; break;
2720 case TopAbs_SHELL: aShapeName = " Shell"; break;
2721 case TopAbs_FACE: aShapeName = " Face"; break;
2722 case TopAbs_WIRE: aShapeName = " Wire"; break;
2723 case TopAbs_EDGE: aShapeName = " Edge"; break;
2724 case TopAbs_VERTEX: aShapeName = " Vertex"; break;
2725 default:
2726 case TopAbs_SHAPE: aShapeName = " Shape"; break;
2727 }
2728
2729 if (aParentName != aPrevName)
2730 {
2731 theDI << "Locally selected sub-shapes within " << aParentName << ":\n";
2732 aPrevName = aParentName;
2733 }
2734 theDI << " " << aShapeName << " #" << aNumber << "\n";
2735 break;
2736 }
2737 }
2738}
7fd59977 2739
2740//==============================================================================
2741//function : VState
2742//purpose :
2743//Draw arg : vstate [nameA] ... [nameN]
2744//==============================================================================
cb78155f 2745static Standard_Integer VState (Draw_Interpretor& theDI,
2746 Standard_Integer theArgNb,
2747 Standard_CString* theArgVec)
7fd59977 2748{
cb78155f 2749 Handle(AIS_InteractiveContext) aCtx = TheAISContext();
2750 if (aCtx.IsNull())
2751 {
2752 std::cerr << "Error: No opened viewer!\n";
2753 return 1;
7fd59977 2754 }
cb78155f 2755
2756 NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
2757 for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
2758 {
2759 aDetected.Add (aCtx->DetectedCurrentObject());
2760 }
2761
2762 const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
2763 if (theArgNb >= 2
2764 && !toShowAll)
2765 {
2766 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
7fd59977 2767 {
cb78155f 2768 const TCollection_AsciiString anObjName = theArgVec[anArgIter];
2769 if (!GetMapOfAIS().IsBound2 (anObjName))
2770 {
2771 theDI << anObjName << " doesn't exist!\n";
2772 continue;
7fd59977 2773 }
2774
cb78155f 2775 const Handle(Standard_Transient) anObjTrans = GetMapOfAIS().Find2 (anObjName);
2776 TCollection_AsciiString aName = anObjName;
2777 aName.LeftJustify (20, ' ');
2778 theDI << " " << aName << " ";
2779 objInfo (aDetected, anObjTrans, theDI);
2780 theDI << "\n";
7fd59977 2781 }
cb78155f 2782 return 0;
7fd59977 2783 }
cb78155f 2784
2785 if (aCtx->NbCurrents() > 0
2786 && !toShowAll)
2787 {
2788 for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
2789 {
2790 Handle(AIS_InteractiveObject) anObj = aCtx->Current();
2791 TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
2792 aName.LeftJustify (20, ' ');
2793 theDI << aName << " ";
2794 objInfo (aDetected, anObj, theDI);
2795 theDI << "\n";
7fd59977 2796 }
cb78155f 2797 return 0;
7fd59977 2798 }
2799
cb78155f 2800 theDI << "Neutral-point state:\n";
2801 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
2802 anObjIter.More(); anObjIter.Next())
2803 {
2804 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anObjIter.Key1());
2805 if (anObj.IsNull())
2806 {
2807 continue;
2808 }
2809
2810 TCollection_AsciiString aName = anObjIter.Key2();
2811 aName.LeftJustify (20, ' ');
2812 theDI << " " << aName << " ";
2813 objInfo (aDetected, anObj, theDI);
2814 theDI << "\n";
2815 }
2816 localCtxInfo (theDI);
7fd59977 2817 return 0;
2818}
2819
7fd59977 2820//=======================================================================
2821//function : PickObjects
2822//purpose :
2823//=======================================================================
2824Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& arr,
2825 const AIS_KindOfInteractive TheType,
2826 const Standard_Integer TheSignature,
2827 const Standard_Integer MaxPick)
2828{
2829 Handle(AIS_InteractiveObject) IO;
2830 Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
2831
2832 // step 1: prepare the data
4952a30a 2833 if(curindex !=0){
7fd59977 2834 Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
2835 TheAISContext()->AddFilter(F1);
2836 }
2837
2838 // step 2 : wait for the selection...
2839// Standard_Boolean IsGood (Standard_False);
2840// Standard_Integer NbPick(0);
2841 Standard_Boolean NbPickGood (0),NbToReach(arr->Length());
2842 Standard_Integer NbPickFail(0);
2843 Standard_Integer argccc = 5;
2844 const char *bufff[] = { "A", "B", "C","D", "E" };
2845 const char **argvvv = (const char **) bufff;
2846
2847
2848 while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
2849 while(ViewerMainLoop(argccc,argvvv)){}
2850 Standard_Integer NbStored = TheAISContext()->NbSelected();
2851 if((unsigned int ) NbStored != NbPickGood)
2852 NbPickGood= NbStored;
2853 else
2854 NbPickFail++;
2855 cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<endl;
2856 }
2857
2858 // step3 get result.
2859
2860 if((unsigned int ) NbPickFail >= NbToReach) return Standard_False;
2861
2862 Standard_Integer i(0);
2863 for(TheAISContext()->InitSelected();
2864 TheAISContext()->MoreSelected();
2865 TheAISContext()->NextSelected()){
2866 i++;
2867 Handle(AIS_InteractiveObject) IO2 = TheAISContext()->SelectedInteractive();
2868 arr->SetValue(i,IO2);
2869 }
2870
2871
2872 if(curindex>0)
2873 TheAISContext()->CloseLocalContext(curindex);
2874
2875 return Standard_True;
2876}
2877
2878
2879//=======================================================================
2880//function : PickObject
2881//purpose :
2882//=======================================================================
2883Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive TheType,
2884 const Standard_Integer TheSignature,
2885 const Standard_Integer MaxPick)
2886{
2887 Handle(AIS_InteractiveObject) IO;
2888 Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
2889
2890 // step 1: prepare the data
2891
4952a30a 2892 if(curindex !=0){
7fd59977 2893 Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
2894 TheAISContext()->AddFilter(F1);
2895 }
2896
2897 // step 2 : wait for the selection...
2898 Standard_Boolean IsGood (Standard_False);
2899 Standard_Integer NbPick(0);
2900 Standard_Integer argccc = 5;
2901 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2902 const char **argvvv = (const char **) bufff;
2903
2904
2905 while(!IsGood && NbPick<= MaxPick){
2906 while(ViewerMainLoop(argccc,argvvv)){}
2907 IsGood = (TheAISContext()->NbSelected()>0) ;
2908 NbPick++;
2909 cout<<"Nb Pick :"<<NbPick<<endl;
2910 }
2911
2912
2913 // step3 get result.
2914 if(IsGood){
2915 TheAISContext()->InitSelected();
2916 IO = TheAISContext()->SelectedInteractive();
2917 }
2918
4952a30a 2919 if(curindex!=0)
7fd59977 2920 TheAISContext()->CloseLocalContext(curindex);
2921 return IO;
2922}
2923
2924//=======================================================================
2925//function : PickShape
2926//purpose : First Activate the rightmode + Put Filters to be able to
2927// pick objets that are of type <TheType>...
2928//=======================================================================
2929
2930TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
2931 const Standard_Integer MaxPick)
2932{
2933
2934 // step 1: prepare the data
2935
2936 Standard_Integer curindex = TheAISContext()->OpenLocalContext();
2937 TopoDS_Shape result;
2938
2939 if(TheType==TopAbs_SHAPE){
2940 Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
2941 TheAISContext()->AddFilter(F1);
2942 }
2943 else{
2944 Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
2945 TheAISContext()->AddFilter(TF);
2946 TheAISContext()->ActivateStandardMode(TheType);
2947
2948 }
2949
2950
2951 // step 2 : wait for the selection...
2952 Standard_Boolean NoShape (Standard_True);
2953 Standard_Integer NbPick(0);
2954 Standard_Integer argccc = 5;
2955 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2956 const char **argvvv = (const char **) bufff;
2957
2958
2959 while(NoShape && NbPick<= MaxPick){
2960 while(ViewerMainLoop(argccc,argvvv)){}
2961 NoShape = (TheAISContext()->NbSelected()==0) ;
2962 NbPick++;
2963 cout<<"Nb Pick :"<<NbPick<<endl;
2964 }
2965
2966 // step3 get result.
2967
2968 if(!NoShape){
2969
2970 TheAISContext()->InitSelected();
2971 if(TheAISContext()->HasSelectedShape())
2972 result = TheAISContext()->SelectedShape();
2973 else{
2974 Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
2975 result = (*((Handle(AIS_Shape)*) &IO))->Shape();
2976 }
2977 }
2978
2979 if(curindex>0)
2980 TheAISContext()->CloseLocalContext(curindex);
2981
2982 return result;
2983}
2984
2985
2986//=======================================================================
2987//function : PickShapes
2988//purpose :
2989//=======================================================================
2990Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
2991 Handle(TopTools_HArray1OfShape)& thearr,
2992 const Standard_Integer MaxPick)
2993{
2994
2995 Standard_Integer Taille = thearr->Length();
2996 if(Taille>1)
2997 cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object"<<"\n";
2998
2999 // step 1: prepare the data
3000 Standard_Integer curindex = TheAISContext()->OpenLocalContext();
3001 if(TheType==TopAbs_SHAPE){
3002 Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
3003 TheAISContext()->AddFilter(F1);
3004 }
3005 else{
3006 Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
3007 TheAISContext()->AddFilter(TF);
3008 TheAISContext()->ActivateStandardMode(TheType);
3009
3010 }
3011
3012 // step 2 : wait for the selection...
3013
3014 Standard_Boolean NbPickGood (0),NbToReach(thearr->Length());
3015 Standard_Integer NbPickFail(0);
3016 Standard_Integer argccc = 5;
3017 const char *bufff[] = { "A", "B", "C","D", "E" };
3018 const char **argvvv = (const char **) bufff;
3019
3020
3021 while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
3022 while(ViewerMainLoop(argccc,argvvv)){}
3023 Standard_Integer NbStored = TheAISContext()->NbSelected();
3024 if((unsigned int ) NbStored != NbPickGood)
3025 NbPickGood= NbStored;
3026 else
3027 NbPickFail++;
3028 cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<"\n";
3029 }
3030
3031 // step3 get result.
3032
3033 if((unsigned int ) NbPickFail >= NbToReach) return Standard_False;
3034
3035 Standard_Integer i(0);
3036 for(TheAISContext()->InitSelected();TheAISContext()->MoreSelected();TheAISContext()->NextSelected()){
3037 i++;
3038 if(TheAISContext()->HasSelectedShape())
3039 thearr->SetValue(i,TheAISContext()->SelectedShape());
3040 else{
3041 Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
3042 thearr->SetValue(i,(*((Handle(AIS_Shape)*) &IO))->Shape());
3043 }
3044 }
3045
3046 TheAISContext()->CloseLocalContext(curindex);
3047 return Standard_True;
3048}
3049
3050
3051//=======================================================================
3052//function : VPickShape
3053//purpose :
3054//=======================================================================
3055static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3056{
3057 TopoDS_Shape PickSh;
3058 TopAbs_ShapeEnum theType = TopAbs_COMPOUND;
3059
3060 if(argc==1)
3061 theType = TopAbs_SHAPE;
3062 else{
3063 if(!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX;
3064 else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE;
3065 else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE;
3066 else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE;
3067 else if(!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE;
3068 else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL;
3069 else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID;
3070 }
3071
3072 static Standard_Integer nbOfSub[8]={0,0,0,0,0,0,0,0};
3073 static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
3074
3075 TCollection_AsciiString name;
3076
3077
3078 Standard_Integer NbToPick = argc>2 ? argc-2 : 1;
3079 if(NbToPick==1){
3080 PickSh = ViewerTest::PickShape(theType);
3081
3082 if(PickSh.IsNull())
3083 return 1;
3084 if(argc>2){
3085 name += argv[2];
3086 }
3087 else{
3088
3089 if(!PickSh.IsNull()){
3090 nbOfSub[Standard_Integer(theType)]++;
3091 name += "Picked_";
3092 name += nameType[Standard_Integer(theType)];
3093 TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
3094 name +="_";
3095 name+=indxstring;
3096 }
3097 }
3098 // si on avait une petite methode pour voir si la shape
3099 // est deja dans la Double map, ca eviterait de creer....
3100 DBRep::Set(name.ToCString(),PickSh);
3101
3102 Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
3103 GetMapOfAIS().Bind(newsh, name);
3104 TheAISContext()->Display(newsh);
3105 di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n";
3106 }
3107
3108 // Plusieurs objets a picker, vite vite vite....
3109 //
3110 else{
3111 Standard_Boolean autonaming = !strcasecmp(argv[2],".");
3112 Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
3113 if(ViewerTest::PickShapes(theType,arr)){
3114 for(Standard_Integer i=1;i<=NbToPick;i++){
3115 PickSh = arr->Value(i);
3116 if(!PickSh.IsNull()){
3117 if(autonaming){
3118 nbOfSub[Standard_Integer(theType)]++;
3119 name.Clear();
3120 name += "Picked_";
3121 name += nameType[Standard_Integer(theType)];
3122 TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
3123 name +="_";
3124 name+=indxstring;
3125 }
3126 }
3127 else
3128 name = argv[1+i];
3129
3130 DBRep::Set(name.ToCString(),PickSh);
3131 Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
3132 GetMapOfAIS().Bind(newsh, name);
3133 di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n";
3134 TheAISContext()->Display(newsh);
3135
3136 }
3137 }
3138 }
3139 return 0;
7fd59977 3140}
7fd59977 3141
3142//=======================================================================
3143//function : list of known objects
3144//purpose :
3145//=======================================================================
3146static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
3147{
3148 // 1234567890 12345678901234567 123456789
3149 TCollection_AsciiString Colum [3]={"Standard Types","Type Of Object","Signature"};
3150 TCollection_AsciiString BlankLine(64,'_');
3151 Standard_Integer i ;
3152
3153 di<<"/n"<<BlankLine.ToCString()<<"\n";
3154
3155 for( i =0;i<=2;i++)
3156 Colum[i].Center(20,' ');
3157 for(i=0;i<=2;i++)
3158 di<<"|"<<Colum[i].ToCString();
3159 di<<"|"<<"\n";
3160
3161 di<<BlankLine.ToCString()<<"\n";
3162
3163 // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"};
3164 const char ** names = GetTypeNames();
3165
3166 TCollection_AsciiString curstring;
3167 TCollection_AsciiString curcolum[3];
3168
3169
3170 // les objets de type Datum..
3171 curcolum[1]+="Datum";
3172 for(i =0;i<=6;i++){
3173 curcolum[0].Clear();
3174 curcolum[0] += names[i];
3175
3176 curcolum[2].Clear();
3177 curcolum[2]+=TCollection_AsciiString(i+1);
3178
3179 for(Standard_Integer j =0;j<=2;j++){
3180 curcolum[j].Center(20,' ');
3181 di<<"|"<<curcolum[j].ToCString();
3182 }
3183 di<<"|"<<"\n";
3184 }
3185 di<<BlankLine.ToCString()<<"\n";
3186
3187 // les objets de type shape
3188 curcolum[1].Clear();
3189 curcolum[1]+="Shape";
3190 curcolum[1].Center(20,' ');
3191
3192 for(i=0;i<=2;i++){
3193 curcolum[0].Clear();
3194 curcolum[0] += names[7+i];
3195 curcolum[2].Clear();
3196 curcolum[2]+=TCollection_AsciiString(i);
3197
3198 for(Standard_Integer j =0;j<=2;j++){
3199 curcolum[j].Center(20,' ');
3200 di<<"|"<<curcolum[j].ToCString();
3201 }
3202 di<<"|"<<"\n";
3203 }
3204 di<<BlankLine.ToCString()<<"\n";
3205 // les IO de type objet...
3206 curcolum[1].Clear();
3207 curcolum[1]+="Object";
3208 curcolum[1].Center(20,' ');
3209 for(i=0;i<=1;i++){
3210 curcolum[0].Clear();
3211 curcolum[0] += names[10+i];
3212 curcolum[2].Clear();
3213 curcolum[2]+=TCollection_AsciiString(i);
3214
3215 for(Standard_Integer j =0;j<=2;j++){
3216 curcolum[j].Center(20,' ');
3217 di<<"|"<<curcolum[j].ToCString();
3218 }
3219 di<<"|"<<"\n";
3220 }
3221 di<<BlankLine.ToCString()<<"\n";
3222 // les contraintes et dimensions.
3223 // pour l'instant on separe juste contraintes et dimensions...
3224 // plus tard, on detaillera toutes les sortes...
3225 curcolum[1].Clear();
3226 curcolum[1]+="Relation";
3227 curcolum[1].Center(20,' ');
3228 for(i=0;i<=1;i++){
3229 curcolum[0].Clear();
3230 curcolum[0] += names[12+i];
3231 curcolum[2].Clear();
3232 curcolum[2]+=TCollection_AsciiString(i);
3233
3234 for(Standard_Integer j =0;j<=2;j++){
3235 curcolum[j].Center(20,' ');
3236 di<<"|"<<curcolum[j].ToCString();
3237 }
3238 di<<"|"<<"\n";
3239 }
3240 di<<BlankLine.ToCString()<<"\n";
3241
3242
3243 return 0;
3244}
3245
3246
3247static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
3248{
4952a30a 3249 if(argc!=2) return 1;
7fd59977 3250
3251 AIS_KindOfInteractive TheType;
3252 Standard_Integer TheSign(-1);
3253 GetTypeAndSignfromString(argv[1],TheType,TheSign);
3254
3255
3256 AIS_ListOfInteractive LIO;
3257
3258 // en attendant l'amelioration ais pour les dimensions...
3259 //
3260 Standard_Integer dimension_status(-1);
3261 if(TheType==AIS_KOI_Relation){
3262 dimension_status = TheSign ==1 ? 1 : 0;
3263 TheSign=-1;
3264 }
3265
3266 TheAISContext()->DisplayedObjects(TheType,TheSign,LIO);
3267 Handle(AIS_InteractiveObject) curio;
3268 for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){
3269 curio = it.Value();
3270
3271 if(dimension_status == -1)
3272 TheAISContext()->Erase(curio,Standard_False);
3273 else {
3274 AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
3275 if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
3276 (dimension_status==1 && KOD != AIS_KOD_NONE))
3277 TheAISContext()->Erase(curio,Standard_False);
3278 }
3279 }
3280 TheAISContext()->UpdateCurrentViewer();
3281 return 0;
3282}
3283static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char** argv)
3284{
3285 if(argc!=2) return 1;
3286
3287 AIS_KindOfInteractive TheType;
3288 Standard_Integer TheSign(-1);
3289 GetTypeAndSignfromString(argv[1],TheType,TheSign);
3290
3291 // en attendant l'amelioration ais pour les dimensions...
3292 //
3293 Standard_Integer dimension_status(-1);
3294 if(TheType==AIS_KOI_Relation){
3295 dimension_status = TheSign ==1 ? 1 : 0;
3296 TheSign=-1;
3297 }
3298
3299 AIS_ListOfInteractive LIO;
3300 TheAISContext()->ObjectsInside(LIO,TheType,TheSign);
3301 Handle(AIS_InteractiveObject) curio;
3302 for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){
3303 curio = it.Value();
3304 if(dimension_status == -1)
3305 TheAISContext()->Display(curio,Standard_False);
3306 else {
3307 AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
3308 if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
3309 (dimension_status==1 && KOD != AIS_KOD_NONE))
3310 TheAISContext()->Display(curio,Standard_False);
3311 }
3312
3313 }
3314
3315 TheAISContext()->UpdateCurrentViewer();
3316 return 0;
3317}
3318
3319//==============================================================================
3320//function : VSetTransMode
3321//purpose :
3322//Draw arg : vsettransmode shape flag1 [flag2] [flag3] [X Y Z]
3323//==============================================================================
3324
3325static int VSetTransMode ( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3326 // Verification des arguments
3327 if ( a3DView().IsNull() ) {
3328 ViewerTest::ViewerInit();
3329 di << "La commande vinit n'a pas ete appele avant" << "\n";
3330 }
3331
3332 if ( argc < 3 || argc > 8 ) {
3333 di << argv[0] << " Invalid number of arguments" << "\n";
3334 return 1;
3335 }
3336
3337 TCollection_AsciiString shapeName;
3338 shapeName = argv[1];
91322f44 3339 Standard_Integer persFlag1 = Draw::Atoi(argv[2]);
7fd59977 3340 Standard_Integer persFlag2 = 0;
3341 Standard_Integer persFlag3 = 0;
3342 gp_Pnt origin = gp_Pnt( 0.0, 0.0, 0.0 );
3343 if ( argc == 4 || argc == 5 || argc == 7 || argc == 8 ) {
91322f44 3344 persFlag2 = Draw::Atoi(argv[3]);
7fd59977 3345 }
3346 if ( argc == 5 || argc == 8 ) {
91322f44 3347 persFlag3 = Draw::Atoi(argv[4]);
7fd59977 3348 }
3349 if ( argc >= 6 ) {
91322f44 3350 origin.SetX( Draw::Atof(argv[argc - 3]) );
3351 origin.SetY( Draw::Atof(argv[argc - 2]) );
3352 origin.SetZ( Draw::Atof(argv[argc - 1]) );
7fd59977 3353 }
3354
3355 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(shapeName);
7fd59977 3356 Handle(Standard_Transient) anObj;
3357 if ( IsBound ) {
3358 anObj = GetMapOfAIS().Find2(shapeName);
3359 if ( anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject)) ) {
3360 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(anObj);
3361 aShape->SetTransformPersistence( (persFlag1 | persFlag2 | persFlag3), origin );
3362 if ( persFlag1 == 0 && persFlag2 == 0 && persFlag3 == 0 ) {
3363 di << argv[0] << " All persistence modifiers were removed" << "\n";
3364 }
3365 } else {
3366 di << argv[0] << " Wrong object type" << "\n";
3367 return 1;
3368 }
3369 } else { // Create the AIS_Shape from a name
3370 const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName((const char* )shapeName.ToCString());
3371 if ( !aShape.IsNull() ) {
3372 GetMapOfAIS().Bind( aShape, shapeName );
3373 aShape->SetTransformPersistence( (persFlag1 | persFlag2 | persFlag3), origin );
3374 TheAISContext()->Display( aShape, Standard_False );
3375 } else {
3376 di << argv[0] << " Object not found" << "\n";
3377 return 1;
3378 }
3379 }
3380
3381 // Upadate the screen and redraw the view
3382 TheAISContext()->UpdateCurrentViewer();
3383 return 0;
3384}
3385
3386static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a)
3387{
3388 ifstream s(a[1]);
3389 BRep_Builder builder;
3390 TopoDS_Shape shape;
3391 BRepTools::Read(shape, s, builder);
3392 DBRep::Set(a[1], shape);
3393 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
3394 Handle(AIS_Shape) ais = new AIS_Shape(shape);
3395 Ctx->Display(ais);
3396 return 0;
3397}
7fd59977 3398
3399//==============================================================================
3400//function : ViewerTest::Commands
3401//purpose : Add all the viewer command in the Draw_Interpretor
3402//==============================================================================
3403
3404void ViewerTest::Commands(Draw_Interpretor& theCommands)
3405{
3406 ViewerTest::ViewerCommands(theCommands);
3407 ViewerTest::RelationCommands(theCommands);
3408 ViewerTest::ObjectCommands(theCommands);
3409 ViewerTest::FilletCommands(theCommands);
3410 ViewerTest::VoxelCommands(theCommands);
3946774d 3411 ViewerTest::OpenGlCommands(theCommands);
7fd59977 3412
3413 const char *group = "AIS_Display";
3414
3415 // display
1c88cbaf 3416 theCommands.Add("visos",
3417 "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n"
3418 "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n",
3419 __FILE__, visos, group);
7fd59977 3420
3421 theCommands.Add("vdisplay",
ac4aaa98 3422 "vdisplay name1 [name2] ... [name n]"
3423 "\n\t\t: Displays named objects",
7fd59977 3424 __FILE__,VDisplay2,group);
3425
f3889691 3426 theCommands.Add ("vupdate",
3427 "vupdate name1 [name2] ... [name n]"
3428 "\n\t\t: Updates named objects in interactive context",
3429 __FILE__, VUpdate, group);
3430
7fd59977 3431 theCommands.Add("verase",
ac4aaa98 3432 "verase [name1] ... [name n]"
3433 "\n\t\t: Erases selected or named objects."
3434 "\n\t\t: If there are no selected or named objects the whole viewer is erased.",
b514beda 3435 __FILE__, VErase, group);
7fd59977 3436
eef7fc64 3437 theCommands.Add("vremove",
3438 "vremove [-context] [name1] ... [name n]"
3439 "or vremove [-context] -all to remove all objects"
3440 "\n\t\t: Removes selected or named objects."
3441 "\n\t\t If -context is in arguments, the objects are not deleted"
3442 "\n\t\t from the map of objects and names.",
3443 __FILE__, VRemove, group);
3444
7fd59977 3445 theCommands.Add("vdonly",
ac4aaa98 3446 "vdonly [name1] ... [name n]"
3447 "\n\t\t: Displays only selected or named objects",
7fd59977 3448 __FILE__,VDonly2,group);
3449
3450 theCommands.Add("vdisplayall",
ac4aaa98 3451 "Displays all erased interactive objects (see vdir and vstate)",
7fd59977 3452 __FILE__,VDisplayAll,group);
3453
3454 theCommands.Add("veraseall",
ac4aaa98 3455 "Erases all objects displayed in the viewer",
b514beda 3456 __FILE__, VErase, group);
7fd59977 3457
3458 theCommands.Add("verasetype",
ac4aaa98 3459 "verasetype <Type>"
3460 "\n\t\t: Erase all the displayed objects of one given kind (see vtypes)",
7fd59977 3461 __FILE__,VEraseType,group);
3462
3463 theCommands.Add("vdisplaytype",
3464 "vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
3465 __FILE__,VDisplayType,group);
3466
3467 theCommands.Add("vdisplaymode",
3468 "vdispmode : vdispmode [name] mode(1,2,..) : no name -> on selected objects ",
3469 __FILE__,VDispMode,group);
3470
3471 theCommands.Add("verasemode",
3472 "verasemode : verasemode [name] mode(1,2,..) : no name -> on selected objects",
3473 __FILE__,VDispMode,group);
3474
3475 theCommands.Add("vsetdispmode",
ac4aaa98 3476 "vsetdispmode [name] mode(1,2,..)"
3477 "\n\t\t: Sets display mode for all, selected or named objects.",
7fd59977 3478 __FILE__,VDispMode,group);
3479
3480 theCommands.Add("vunsetdispmode",
ac4aaa98 3481 "vunsetdispmode [name]"
3482 "\n\t\t: Unsets custom display mode for selected or named objects.",
7fd59977 3483 __FILE__,VDispMode,group);
3484
3485 theCommands.Add("vdir",
ac4aaa98 3486 "Lists all objects displayed in 3D viewer",
7fd59977 3487 __FILE__,VDebug,group);
3488
3489 theCommands.Add("vdump",
ac4aaa98 3490 #ifdef HAVE_FREEIMAGE
b5ac8292 3491 "<filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
ac4aaa98 3492 "\n\t\t: Dumps contents of viewer window to PNG, BMP, JPEG or GIF file",
3493 #else
b5ac8292 3494 "<filename>.{ppm} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
ac4aaa98 3495 "\n\t\t: Dumps contents of viewer window to PPM image file",
3496 #endif
7fd59977 3497 __FILE__,VDump,group);
3498
3499 theCommands.Add("vsub", "vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects",
3500 __FILE__,VSubInt,group);
3501
3502 theCommands.Add("vsetcolor",
ac4aaa98 3503 "vsetcolor [name] ColorName"
3504 "\n\t\t: Sets color for all, selected or named objects.",
7fd59977 3505 __FILE__,VColor2,group);
3506
3507 theCommands.Add("vunsetcolor",
ac4aaa98 3508 "vunsetcolor [name]"
3509 "\n\t\t: Resets color for all, selected or named objects.",
7fd59977 3510 __FILE__,VColor2,group);
3511
3512 theCommands.Add("vsettransparency",
ac4aaa98 3513 "vsettransparency [name] Coefficient"
3514 "\n\t\t: Sets transparency for all, selected or named objects."
3515 "\n\t\t: The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent).",
7fd59977 3516 __FILE__,VTransparency,group);
3517
3518 theCommands.Add("vunsettransparency",
ac4aaa98 3519 "vunsettransparency [name]"
3520 "\n\t\t: Resets transparency for all, selected or named objects.",
7fd59977 3521 __FILE__,VTransparency,group);
3522
3523 theCommands.Add("vsetmaterial",
3524 "vmaterial : vmaterial [name of shape] MaterialName",
3525 __FILE__,VMaterial,group);
3526
3527 theCommands.Add("vunsetmaterial",
3528 "vmaterial : vmaterial [name of shape]",
3529 __FILE__,VMaterial,group);
3530
3531 theCommands.Add("vsetwidth",
3532 "vsetwidth : vwidth [name of shape] width(0->10)",
3533 __FILE__,VWidth,group);
3534
3535 theCommands.Add("vunsetwidth",
3536 "vunsetwidth : vwidth [name of shape]",
3537 __FILE__,VWidth,group);
3538
99c56d44 3539 theCommands.Add("vsetinteriorstyle",
3540 "vsetinteriorstyle : vsetinteriorstyle [name of shape] style",
3541 __FILE__,VInteriorStyle,group);
3542
7fd59977 3543 theCommands.Add("vardis",
3544 "vardis : display activeareas",
3545 __FILE__,VDispAreas,group);
3546
3547 theCommands.Add("varera",
3548 "varera : erase activeareas",
3549 __FILE__,VClearAreas,group);
3550
3551 theCommands.Add("vsensdis",
3552 "vardisp : display active entities",