0024203: Command "sameparameter" in DRAW on attached edge set tolerance equal to...
[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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
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>
7fd59977 31#include <OSD_Timer.hxx>
32#include <Geom_Axis2Placement.hxx>
33#include <Geom_Axis1Placement.hxx>
34#include <gp_Trsf.hxx>
35#include <TopExp_Explorer.hxx>
36#include <BRepAdaptor_Curve.hxx>
37#include <StdSelect_ShapeTypeFilter.hxx>
38#include <AIS.hxx>
99c56d44 39#include <AIS_Drawer.hxx>
7fd59977 40#include <AIS_InteractiveObject.hxx>
41#include <AIS_Trihedron.hxx>
42#include <AIS_Axis.hxx>
43#include <AIS_Relation.hxx>
44#include <AIS_TypeFilter.hxx>
45#include <AIS_SignatureFilter.hxx>
cb78155f 46#include <AIS_LocalContext.hxx>
7fd59977 47#include <AIS_ListOfInteractive.hxx>
48#include <AIS_ListIteratorOfListOfInteractive.hxx>
99c56d44 49#include <Aspect_InteriorStyle.hxx>
50#include <Graphic3d_AspectFillArea3d.hxx>
1c88cbaf 51#include <Graphic3d_AspectLine3d.hxx>
392ac980 52#include <Graphic3d_TextureRoot.hxx>
692613e5 53#include <Image_AlienPixMap.hxx>
99c56d44 54#include <Prs3d_ShadingAspect.hxx>
1c88cbaf 55#include <Prs3d_IsoAspect.hxx>
cb78155f 56#include <TopTools_MapOfShape.hxx>
7fd59977 57
58#ifdef HAVE_CONFIG_H
59# include <config.h>
60#endif
61#include <stdio.h>
62#ifdef HAVE_STRINGS_H
63# include <strings.h>
64#endif
65
66#include <Draw_Interpretor.hxx>
67#include <TCollection_AsciiString.hxx>
68#include <Draw_PluginMacro.hxx>
69#include <ViewerTest.hxx>
7fd59977 70
71// avoid warnings on 'extern "C"' functions returning C++ classes
72#ifdef WNT
73#define _CRT_SECURE_NO_DEPRECATE
74#pragma warning(4:4190)
75#pragma warning (disable:4996)
76#endif
77
78#include <NIS_InteractiveContext.hxx>
79#include <NIS_Triangulated.hxx>
80extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
81
7fd59977 82#include <Quantity_Color.hxx>
83#include <Quantity_NameOfColor.hxx>
84
85#include <Graphic3d_NameOfMaterial.hxx>
86
87#define DEFAULT_COLOR Quantity_NOC_GOLDENROD
88#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
89
1c88cbaf 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
2123//==============================================================================
7fd59977 2124//function : VPerf
2125//purpose : Test the annimation of an object along a
2126// predifined trajectory
2127//Draw arg : vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)
2128//==============================================================================
2129
2130static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
2131
2132 OSD_Timer myTimer;
2133 if (TheAISContext()->HasOpenedContext())
2134 TheAISContext()->CloseLocalContext();
2135
c6541a0c 2136 Standard_Real Step=4*M_PI/180;
7fd59977 2137 Standard_Real Angle=0;
2138
2139 Handle(AIS_InteractiveObject) aIO;
2140 if (GetMapOfAIS().IsBound2(argv[1]))
2141 aIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
2142 if (aIO.IsNull())
2143 return 1;
2144
2145 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aIO);
2146
2147 myTimer.Start();
2148
91322f44 2149 if (Draw::Atoi(argv[3])==1 ) {
7fd59977 2150 di<<" Primitives sensibles OFF"<<"\n";
2151 TheAISContext()->Deactivate(aIO);
2152 }
2153 else {
2154 di<<" Primitives sensibles ON"<<"\n";
2155 }
2156 // Movement par transformation
91322f44 2157 if(Draw::Atoi(argv[2]) ==1) {
7fd59977 2158 di<<" Calcul par Transformation"<<"\n";
c6541a0c 2159 for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
7fd59977 2160
2161 Angle=Step*myAngle;
2162 gp_Trsf myTransfo;
2163 myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ) ,Angle );
2164 TheAISContext()->SetLocation(aShape,myTransfo);
2165 TheAISContext() ->UpdateCurrentViewer();
2166
2167 }
2168 }
2169 else {
2170 di<<" Calcul par Locations"<<"\n";
2171 gp_Trsf myAngleTrsf;
2172 myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ), Step );
2173 TopLoc_Location myDeltaAngle (myAngleTrsf);
2174 TopLoc_Location myTrueLoc;
2175
c6541a0c 2176 for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
7fd59977 2177
2178 Angle=Step*myAngle;
2179 myTrueLoc=myTrueLoc*myDeltaAngle;
2180 TheAISContext()->SetLocation(aShape,myTrueLoc );
2181 TheAISContext() ->UpdateCurrentViewer();
2182 }
2183 }
91322f44 2184 if (Draw::Atoi(argv[3])==1 ){
7fd59977 2185 // On reactive la selection des primitives sensibles
2186 TheAISContext()->Activate(aIO,0);
2187 }
2188 a3DView() -> Redraw();
2189 myTimer.Stop();
2190 di<<" Temps ecoule "<<"\n";
2191 myTimer.Show();
2192 return 0;
2193}
2194
2195
2196//==================================================================================
2197// Function : VAnimation
2198//==================================================================================
2199static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
31160f80 2200 if (argc != 5) {
7fd59977 2201 di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n";
2202 return 1;
2203 }
2204
2205 Standard_Real thread = 4;
2206 Standard_Real angleA=0;
2207 Standard_Real angleB;
2208 Standard_Real X;
2209 gp_Ax1 Ax1(gp_Pnt(0,0,0),gp_Vec(0,0,1));
2210
2211 BRep_Builder B;
2212 TopoDS_Shape CrankArm;
2213 TopoDS_Shape CylinderHead;
2214 TopoDS_Shape Propeller;
2215 TopoDS_Shape EngineBlock;
2216
2217 //BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B);
2218 //BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B);
2219 //BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B);
2220 //BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B);
2221 BRepTools::Read(CrankArm,argv[1],B);
2222 BRepTools::Read(CylinderHead,argv[2],B);
2223 BRepTools::Read(Propeller,argv[3],B);
2224 BRepTools::Read(EngineBlock,argv[4],B);
2225
2226 if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) {di<<" Syntaxe error:loading failure."<<"\n";}
2227
2228
2229 OSD_Timer myTimer;
2230 myTimer.Start();
2231
2232 Handle(AIS_Shape) myAisCylinderHead = new AIS_Shape (CylinderHead);
2233 Handle(AIS_Shape) myAisEngineBlock = new AIS_Shape (EngineBlock);
2234 Handle(AIS_Shape) myAisCrankArm = new AIS_Shape (CrankArm);
2235 Handle(AIS_Shape) myAisPropeller = new AIS_Shape (Propeller);
2236
2237 GetMapOfAIS().Bind(myAisCylinderHead,"a");
2238 GetMapOfAIS().Bind(myAisEngineBlock,"b");
2239 GetMapOfAIS().Bind(myAisCrankArm,"c");
2240 GetMapOfAIS().Bind(myAisPropeller,"d");
2241
2242 TheAISContext()->SetColor(myAisCylinderHead, Quantity_NOC_INDIANRED);
2243 TheAISContext()->SetColor(myAisEngineBlock , Quantity_NOC_RED);
2244 TheAISContext()->SetColor(myAisPropeller , Quantity_NOC_GREEN);
2245
2246 TheAISContext()->Display(myAisCylinderHead,Standard_False);
2247 TheAISContext()->Display(myAisEngineBlock,Standard_False );
2248 TheAISContext()->Display(myAisCrankArm,Standard_False );
2249 TheAISContext()->Display(myAisPropeller,Standard_False);
2250
2251 TheAISContext()->Deactivate(myAisCylinderHead);
2252 TheAISContext()->Deactivate(myAisEngineBlock );
2253 TheAISContext()->Deactivate(myAisCrankArm );
2254 TheAISContext()->Deactivate(myAisPropeller );
2255
2256 // Boucle de mouvement
c6541a0c 2257 for (Standard_Real myAngle = 0;angleA<2*M_PI*10.175 ;myAngle++) {
7fd59977 2258
c6541a0c 2259 angleA = thread*myAngle*M_PI/180;
7fd59977 2260 X = Sin(angleA)*3/8;
2261 angleB = atan(X / Sqrt(-X * X + 1));
2262 Standard_Real decal(25*0.6);
2263
2264
2265 //Build a transformation on the display
2266 gp_Trsf aPropellerTrsf;
2267 aPropellerTrsf.SetRotation(Ax1,angleA);
2268 TheAISContext()->SetLocation(myAisPropeller,aPropellerTrsf);
2269
2270 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));
2271 gp_Trsf aCrankArmTrsf;
2272 aCrankArmTrsf.SetTransformation( base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB));
2273 TheAISContext()->SetLocation(myAisCrankArm,aCrankArmTrsf);
2274
2275 TheAISContext()->UpdateCurrentViewer();
2276 }
2277
2278 TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Location() );
2279 TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Location() );
2280
2281 myAisCrankArm ->ResetLocation();
2282 myAisPropeller->ResetLocation();
2283
2284 myAisCrankArm -> Set(myNewCrankArm );
2285 myAisPropeller -> Set(myNewPropeller);
2286
2287 TheAISContext()->Activate(myAisCylinderHead,0);
2288 TheAISContext()->Activate(myAisEngineBlock,0 );
2289 TheAISContext()->Activate(myAisCrankArm ,0 );
2290 TheAISContext()->Activate(myAisPropeller ,0 );
2291
2292 myTimer.Stop();
2293 myTimer.Show();
2294 myTimer.Start();
2295
2296 TheAISContext()->Redisplay(myAisCrankArm ,Standard_False);
2297 TheAISContext()->Redisplay(myAisPropeller,Standard_False);
2298
2299 TheAISContext()->UpdateCurrentViewer();
2300 a3DView()->Redraw();
2301
2302 myTimer.Stop();
2303 myTimer.Show();
2304
2305 return 0;
2306
2307}
2308
2309//==============================================================================
2310//function : VShading
2311//purpose : Sharpen or roughten the quality of the shading
2312//Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg
2313//==============================================================================
5cbef0fe
S
2314static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
2315{
7fd59977 2316 Standard_Real myDevCoef;
2317 Handle(AIS_InteractiveObject) TheAisIO;
2318
2319 // Verifications
5cbef0fe
S
2320 const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
2321
7fd59977 2322 if (TheAISContext()->HasOpenedContext())
2323 TheAISContext()->CloseLocalContext();
2324
2325 if (argc < 3) {
2326 myDevCoef = 0.0008;
2327 } else {
91322f44 2328 myDevCoef =Draw::Atof(argv[2]);
7fd59977 2329 }
2330
7fd59977 2331 TCollection_AsciiString name=argv[1];
2332 if (GetMapOfAIS().IsBound2(name ))
5cbef0fe 2333 TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
7fd59977 2334 if (TheAisIO.IsNull())
2335 TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
2336
5cbef0fe 2337 if (HaveToSet)
7fd59977 2338 TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
5cbef0fe 2339 else
7fd59977 2340 TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
2341
7fd59977 2342 TheAISContext()->Redisplay(TheAisIO);
2343 return 0;
2344}
2345//==============================================================================
2346//function : HaveMode
2347//use : VActivatedModes
2348//==============================================================================
2349#include <TColStd_ListIteratorOfListOfInteger.hxx>
2350
2351Standard_Boolean HaveMode(const Handle(AIS_InteractiveObject)& TheAisIO,const Standard_Integer mode )
2352{
2353 TColStd_ListOfInteger List;
2354 TheAISContext()->ActivatedModes (TheAisIO,List);
2355 TColStd_ListIteratorOfListOfInteger it;
2356 Standard_Boolean Found=Standard_False;
2357 for (it.Initialize(List); it.More()&&!Found; it.Next() ){
2358 if (it.Value()==mode ) Found=Standard_True;
2359 }
2360 return Found;
2361}
2362
2363
2364
2365//==============================================================================
2366//function : VActivatedMode
2367//author : ege
2368//purpose : permet d'attribuer a chacune des shapes un mode d'activation
2369// (edges,vertex...)qui lui est propre et le mode de selection standard.
2370// La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer)
2371// Dans le cas ou on veut psser la shape en argument, la fonction n'autorise
2372// qu'un nom et qu'un mode.
2373//Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7)
2374//==============================================================================
2375#include <AIS_ListIteratorOfListOfInteractive.hxx>
2376
2377static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2378
2379{
7fd59977 2380 Standard_Boolean ThereIsName = Standard_False ;
2381
2382 if(!a3DView().IsNull()){
2383
5cbef0fe 2384 const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
7fd59977 2385 // verification des arguments
2386 if (HaveToSet) {
2387 if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;}
5cbef0fe 2388 ThereIsName = (argc == 3);
7fd59977 2389 }
2390 else {
2391 // vunsetam
2392 if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;}
2393 else {
5cbef0fe
S
2394 di<<" R.A.Z de tous les modes de selecion"<<"\n";
2395 di<<" Fermeture du Context local"<<"\n";
7fd59977 2396 if (TheAISContext()->HasOpenedContext())
2397 TheAISContext()->CloseLocalContext();
2398 }
7fd59977 2399 }
2400
7fd59977 2401 // IL n'y a aps de nom de shape passe en argument
2402 if (HaveToSet && !ThereIsName){
91322f44 2403 Standard_Integer aMode=Draw::Atoi(argv [1]);
7fd59977 2404
2405 const char *cmode="???";
7fd59977 2406 switch (aMode) {
2407 case 0: cmode = "Shape"; break;
2408 case 1: cmode = "Vertex"; break;
2409 case 2: cmode = "Edge"; break;
2410 case 3: cmode = "Wire"; break;
2411 case 4: cmode = "Face"; break;
2412 case 5: cmode = "Shell"; break;
2413 case 6: cmode = "Solid"; break;
2414 case 7: cmode = "Compound"; break;
2415 }
2416
2417 if( !TheAISContext()->HasOpenedContext() ) {
5cbef0fe
S
2418 // il n'y a pas de Context local d'ouvert
2419 // on en ouvre un et on charge toutes les shapes displayees
2420 // on load tous les objets displayees et on Activate les objets de la liste
2421 AIS_ListOfInteractive ListOfIO;
2422 // on sauve dans une AISListOfInteractive tous les objets currents
2423 if (TheAISContext()->NbCurrents()>0 ){
2424 TheAISContext()->UnhilightCurrents(Standard_False);
2425
2426 for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
2427 ListOfIO.Append(TheAISContext()->Current() );
7fd59977 2428 }
2429 }
2430
2431 TheAISContext()->OpenLocalContext(Standard_False);
2432 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
2433 it (GetMapOfAIS());
2434 while(it.More()){
2435 Handle(AIS_InteractiveObject) aIO =
2436 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
2437 if (!aIO.IsNull())
2438 TheAISContext()->Load(aIO,0,Standard_False);
2439 it.Next();
2440 }
2441 // traitement des objets qui etaient currents dans le Contexte global
2442 if (!ListOfIO.IsEmpty() ) {
2443 // il y avait des objets currents
2444 AIS_ListIteratorOfListOfInteractive iter;
2445 for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) {
2446 Handle(AIS_InteractiveObject) aIO=iter.Value();
2447 TheAISContext()->Activate(aIO,aMode);
2448 di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2449 }
2450 }
2451 else {
2452 // On applique le mode a tous les objets displayes
2453 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
2454 it2 (GetMapOfAIS());
2455 while(it2.More()){
2456 Handle(AIS_InteractiveObject) aIO =
2457 Handle(AIS_InteractiveObject)::DownCast(it2.Key1());
2458 if (!aIO.IsNull()) {
2459 di<<" Mode: "<<cmode<<" ON pour "<<it2.Key2().ToCString() <<"\n";
2460 TheAISContext()->Activate(aIO,aMode);
2461 }
2462 it2.Next();
2463 }
2464 }
2465
2466 }
2467
2468 else {
2469 // un Context local est deja ouvert
2470 // Traitement des objets du Context local
2471 if (TheAISContext()->NbSelected()>0 ){
2472 TheAISContext()->UnhilightSelected(Standard_False);
2473 // il y a des objets selected,on les parcourt
2474 for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
2475 Handle(AIS_InteractiveObject) aIO=TheAISContext()->Interactive();
2476
2477
2478 if (HaveMode(aIO,aMode) ) {
2479 di<<" Mode: "<<cmode<<" OFF pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2480 TheAISContext()->Deactivate(aIO,aMode);
2481 }
2482 else{
2483 di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2484 TheAISContext()->Activate(aIO,aMode);
2485 }
2486
2487 }
2488 }
2489 else{
2490 // il n'y a pas d'objets selected
2491 // tous les objets diplayes sont traites
2492 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
2493 it (GetMapOfAIS());
2494 while(it.More()){
2495 Handle(AIS_InteractiveObject) aIO =
2496 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
2497 if (!aIO.IsNull()) {
2498 if (HaveMode(aIO,aMode) ) {
2499 di<<" Mode: "<<cmode<<" OFF pour "
2500 <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2501 TheAISContext()->Deactivate(aIO,aMode);
2502 }
2503 else{
2504 di<<" Mode: "<<cmode<<" ON pour"
2505 <<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
2506 TheAISContext()->Activate(aIO,aMode);
2507 }
2508 }
2509 it.Next();
2510 }
2511 }
2512 }
2513 }
2514 else if (HaveToSet && ThereIsName){
91322f44 2515 Standard_Integer aMode=Draw::Atoi(argv [2]);
7fd59977 2516 Handle(AIS_InteractiveObject) aIO =
2517 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
2518
2519 if (!aIO.IsNull()) {
2520 const char *cmode="???";
2521
2522 switch (aMode) {
2523 case 0: cmode = "Shape"; break;
2524 case 1: cmode = "Vertex"; break;
2525 case 2: cmode = "Edge"; break;
2526 case 3: cmode = "Wire"; break;
2527 case 4: cmode = "Face"; break;
2528 case 5: cmode = "Shell"; break;
2529 case 6: cmode = "Solid"; break;
2530 case 7: cmode = "Compound"; break;
2531 }
2532
2533 if( !TheAISContext()->HasOpenedContext() ) {
2534 TheAISContext()->OpenLocalContext(Standard_False);
2535 // On charge tous les objets de la map
2536 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
2537 while(it.More()){
2538 Handle(AIS_InteractiveObject) aShape=
2539 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
2540 if (!aShape.IsNull())
2541 TheAISContext()->Load(aShape,0,Standard_False);
2542 it.Next();
2543 }
2544 TheAISContext()->Activate(aIO,aMode);
2545 di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
2546 }
2547
2548 else {
2549 // un Context local est deja ouvert
2550 if (HaveMode(aIO,aMode) ) {
2551 di<<" Mode: "<<cmode<<" OFF pour "<<argv[1]<<"\n";
2552 TheAISContext()->Deactivate(aIO,aMode);
2553 }
2554 else{
2555 di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
2556 TheAISContext()->Activate(aIO,aMode);
2557 }
2558 }
2559 }
2560 }
2561 }
2562 return 0;
7fd59977 2563}
2564
cb78155f 2565//! Auxiliary method to print Interactive Object information
2566static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected,
2567 const Handle(Standard_Transient)& theObject,
2568 Draw_Interpretor& theDI)
2569{
2570 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theObject);
2571 if (anObj.IsNull())
2572 {
2573 theDI << theObject->DynamicType()->Name() << " is not AIS presentation\n";
2574 return;
2575 }
7fd59977 2576
cb78155f 2577 theDI << (TheAISContext()->IsDisplayed (anObj) ? "Displayed" : "Hidden ")
2578 << (TheAISContext()->IsSelected (anObj) ? " Selected" : " ")
2579 << (theDetected.Contains (anObj) ? " Detected" : " ")
2580 << " Type: ";
2581 if (anObj->Type() == AIS_KOI_Datum)
2582 {
2583 // AIS_Datum
2584 if (anObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
2585 else if (anObj->Signature() == 2) { theDI << " AIS_Axis"; }
2586 else if (anObj->Signature() == 6) { theDI << " AIS_Circle"; }
2587 else if (anObj->Signature() == 5) { theDI << " AIS_Line"; }
2588 else if (anObj->Signature() == 7) { theDI << " AIS_Plane"; }
2589 else if (anObj->Signature() == 1) { theDI << " AIS_Point"; }
2590 else if (anObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
7fd59977 2591 }
2592 // AIS_Shape
cb78155f 2593 else if (anObj->Type() == AIS_KOI_Shape
2594 && anObj->Signature() == 0)
2595 {
2596 theDI << " AIS_Shape";
7fd59977 2597 }
cb78155f 2598 else if (anObj->Type() == AIS_KOI_Relation)
2599 {
2600 // AIS_Dimention and AIS_Relation
2601 Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (anObj);
2602 switch (aRelation->KindOfDimension())
2603 {
2604 case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break;
2605 case AIS_KOD_LENGTH: theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break;
2606 case AIS_KOD_DIAMETER: theDI << " AIS_DiameterDimension"; break;
2607 case AIS_KOD_ELLIPSERADIUS: theDI << " AIS_EllipseRadiusDimension"; break;
2608 //case AIS_KOD_FILLETRADIUS: theDI << " AIS_FilletRadiusDimension "; break;
2609 case AIS_KOD_OFFSET: theDI << " AIS_OffsetDimension"; break;
2610 case AIS_KOD_RADIUS: theDI << " AIS_RadiusDimension"; break;
2611 default: theDI << " UNKNOWN dimension"; break;
2612 }
2613 }
2614 else
2615 {
2616 theDI << " UserPrs";
2617 }
2618 theDI << " (" << theObject->DynamicType()->Name() << ")";
7fd59977 2619}
2620
cb78155f 2621//! Print information about locally selected sub-shapes
2622static void localCtxInfo (Draw_Interpretor& theDI)
2623{
2624 Handle(AIS_InteractiveContext) aCtx = TheAISContext();
2625 if (!aCtx->HasOpenedContext())
2626 {
2627 return;
2628 }
7fd59977 2629
cb78155f 2630 TCollection_AsciiString aPrevName;
2631 Handle(AIS_LocalContext) aCtxLoc = aCtx->LocalContext();
2632 for (aCtxLoc->InitSelected(); aCtxLoc->MoreSelected(); aCtxLoc->NextSelected())
2633 {
2634 const TopoDS_Shape aSubShape = aCtxLoc->SelectedShape();
2635 const Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (aCtxLoc->SelectedInteractive());
2636 if (aSubShape.IsNull()
2637 || aShapeIO.IsNull()
2638 || !GetMapOfAIS().IsBound1 (aShapeIO))
2639 {
2640 continue;
2641 }
2642
2643 const TCollection_AsciiString aParentName = GetMapOfAIS().Find1 (aShapeIO);
2644 TopTools_MapOfShape aFilter;
2645 Standard_Integer aNumber = 0;
2646 const TopoDS_Shape aShape = aShapeIO->Shape();
2647 for (TopExp_Explorer anIter (aShape, aSubShape.ShapeType());
2648 anIter.More(); anIter.Next())
2649 {
2650 if (!aFilter.Add (anIter.Current()))
2651 {
2652 continue; // filter duplicates
2653 }
2654
2655 ++aNumber;
2656 if (!anIter.Current().IsSame (aSubShape))
2657 {
2658 continue;
2659 }
2660
2661 Standard_CString aShapeName = NULL;
2662 switch (aSubShape.ShapeType())
2663 {
2664 case TopAbs_COMPOUND: aShapeName = " Compound"; break;
2665 case TopAbs_COMPSOLID: aShapeName = "CompSolid"; break;
2666 case TopAbs_SOLID: aShapeName = " Solid"; break;
2667 case TopAbs_SHELL: aShapeName = " Shell"; break;
2668 case TopAbs_FACE: aShapeName = " Face"; break;
2669 case TopAbs_WIRE: aShapeName = " Wire"; break;
2670 case TopAbs_EDGE: aShapeName = " Edge"; break;
2671 case TopAbs_VERTEX: aShapeName = " Vertex"; break;
2672 default:
2673 case TopAbs_SHAPE: aShapeName = " Shape"; break;
2674 }
2675
2676 if (aParentName != aPrevName)
2677 {
2678 theDI << "Locally selected sub-shapes within " << aParentName << ":\n";
2679 aPrevName = aParentName;
2680 }
2681 theDI << " " << aShapeName << " #" << aNumber << "\n";
2682 break;
2683 }
2684 }
2685}
7fd59977 2686
2687//==============================================================================
2688//function : VState
2689//purpose :
2690//Draw arg : vstate [nameA] ... [nameN]
2691//==============================================================================
cb78155f 2692static Standard_Integer VState (Draw_Interpretor& theDI,
2693 Standard_Integer theArgNb,
2694 Standard_CString* theArgVec)
7fd59977 2695{
cb78155f 2696 Handle(AIS_InteractiveContext) aCtx = TheAISContext();
2697 if (aCtx.IsNull())
2698 {
2699 std::cerr << "Error: No opened viewer!\n";
2700 return 1;
7fd59977 2701 }
cb78155f 2702
2703 NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
2704 for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
2705 {
2706 aDetected.Add (aCtx->DetectedCurrentObject());
2707 }
2708
2709 const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
2710 if (theArgNb >= 2
2711 && !toShowAll)
2712 {
2713 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
7fd59977 2714 {
cb78155f 2715 const TCollection_AsciiString anObjName = theArgVec[anArgIter];
2716 if (!GetMapOfAIS().IsBound2 (anObjName))
2717 {
2718 theDI << anObjName << " doesn't exist!\n";
2719 continue;
7fd59977 2720 }
2721
cb78155f 2722 const Handle(Standard_Transient) anObjTrans = GetMapOfAIS().Find2 (anObjName);
2723 TCollection_AsciiString aName = anObjName;
2724 aName.LeftJustify (20, ' ');
2725 theDI << " " << aName << " ";
2726 objInfo (aDetected, anObjTrans, theDI);
2727 theDI << "\n";
7fd59977 2728 }
cb78155f 2729 return 0;
7fd59977 2730 }
cb78155f 2731
2732 if (aCtx->NbCurrents() > 0
2733 && !toShowAll)
2734 {
2735 for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
2736 {
2737 Handle(AIS_InteractiveObject) anObj = aCtx->Current();
2738 TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
2739 aName.LeftJustify (20, ' ');
2740 theDI << aName << " ";
2741 objInfo (aDetected, anObj, theDI);
2742 theDI << "\n";
7fd59977 2743 }
cb78155f 2744 return 0;
7fd59977 2745 }
2746
cb78155f 2747 theDI << "Neutral-point state:\n";
2748 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
2749 anObjIter.More(); anObjIter.Next())
2750 {
2751 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anObjIter.Key1());
2752 if (anObj.IsNull())
2753 {
2754 continue;
2755 }
2756
2757 TCollection_AsciiString aName = anObjIter.Key2();
2758 aName.LeftJustify (20, ' ');
2759 theDI << " " << aName << " ";
2760 objInfo (aDetected, anObj, theDI);
2761 theDI << "\n";
2762 }
2763 localCtxInfo (theDI);
7fd59977 2764 return 0;
2765}
2766
7fd59977 2767//=======================================================================
2768//function : PickObjects
2769//purpose :
2770//=======================================================================
2771Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& arr,
2772 const AIS_KindOfInteractive TheType,
2773 const Standard_Integer TheSignature,
2774 const Standard_Integer MaxPick)
2775{
2776 Handle(AIS_InteractiveObject) IO;
2777 Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
2778
2779 // step 1: prepare the data
4952a30a 2780 if(curindex !=0){
7fd59977 2781 Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
2782 TheAISContext()->AddFilter(F1);
2783 }
2784
2785 // step 2 : wait for the selection...
2786// Standard_Boolean IsGood (Standard_False);
2787// Standard_Integer NbPick(0);
2788 Standard_Boolean NbPickGood (0),NbToReach(arr->Length());
2789 Standard_Integer NbPickFail(0);
2790 Standard_Integer argccc = 5;
2791 const char *bufff[] = { "A", "B", "C","D", "E" };
2792 const char **argvvv = (const char **) bufff;
2793
2794
2795 while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
2796 while(ViewerMainLoop(argccc,argvvv)){}
2797 Standard_Integer NbStored = TheAISContext()->NbSelected();
2798 if((unsigned int ) NbStored != NbPickGood)
2799 NbPickGood= NbStored;
2800 else
2801 NbPickFail++;
2802 cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<endl;
2803 }
2804
2805 // step3 get result.
2806
2807 if((unsigned int ) NbPickFail >= NbToReach) return Standard_False;
2808
2809 Standard_Integer i(0);
2810 for(TheAISContext()->InitSelected();
2811 TheAISContext()->MoreSelected();
2812 TheAISContext()->NextSelected()){
2813 i++;
2814 Handle(AIS_InteractiveObject) IO2 = TheAISContext()->SelectedInteractive();
2815 arr->SetValue(i,IO2);
2816 }
2817
2818
2819 if(curindex>0)
2820 TheAISContext()->CloseLocalContext(curindex);
2821
2822 return Standard_True;
2823}
2824
2825
2826//=======================================================================
2827//function : PickObject
2828//purpose :
2829//=======================================================================
2830Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive TheType,
2831 const Standard_Integer TheSignature,
2832 const Standard_Integer MaxPick)
2833{
2834 Handle(AIS_InteractiveObject) IO;
2835 Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
2836
2837 // step 1: prepare the data
2838
4952a30a 2839 if(curindex !=0){
7fd59977 2840 Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
2841 TheAISContext()->AddFilter(F1);
2842 }
2843
2844 // step 2 : wait for the selection...
2845 Standard_Boolean IsGood (Standard_False);
2846 Standard_Integer NbPick(0);
2847 Standard_Integer argccc = 5;
2848 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2849 const char **argvvv = (const char **) bufff;
2850
2851
2852 while(!IsGood && NbPick<= MaxPick){
2853 while(ViewerMainLoop(argccc,argvvv)){}
2854 IsGood = (TheAISContext()->NbSelected()>0) ;
2855 NbPick++;
2856 cout<<"Nb Pick :"<<NbPick<<endl;
2857 }
2858
2859
2860 // step3 get result.
2861 if(IsGood){
2862 TheAISContext()->InitSelected();
2863 IO = TheAISContext()->SelectedInteractive();
2864 }
2865
4952a30a 2866 if(curindex!=0)
7fd59977 2867 TheAISContext()->CloseLocalContext(curindex);
2868 return IO;
2869}
2870
2871//=======================================================================
2872//function : PickShape
2873//purpose : First Activate the rightmode + Put Filters to be able to
2874// pick objets that are of type <TheType>...
2875//=======================================================================
2876
2877TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
2878 const Standard_Integer MaxPick)
2879{
2880
2881 // step 1: prepare the data
2882
2883 Standard_Integer curindex = TheAISContext()->OpenLocalContext();
2884 TopoDS_Shape result;
2885
2886 if(TheType==TopAbs_SHAPE){
2887 Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
2888 TheAISContext()->AddFilter(F1);
2889 }
2890 else{
2891 Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
2892 TheAISContext()->AddFilter(TF);
2893 TheAISContext()->ActivateStandardMode(TheType);
2894
2895 }
2896
2897
2898 // step 2 : wait for the selection...
2899 Standard_Boolean NoShape (Standard_True);
2900 Standard_Integer NbPick(0);
2901 Standard_Integer argccc = 5;
2902 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2903 const char **argvvv = (const char **) bufff;
2904
2905
2906 while(NoShape && NbPick<= MaxPick){
2907 while(ViewerMainLoop(argccc,argvvv)){}
2908 NoShape = (TheAISContext()->NbSelected()==0) ;
2909 NbPick++;
2910 cout<<"Nb Pick :"<<NbPick<<endl;
2911 }
2912
2913 // step3 get result.
2914
2915 if(!NoShape){
2916
2917 TheAISContext()->InitSelected();
2918 if(TheAISContext()->HasSelectedShape())
2919 result = TheAISContext()->SelectedShape();
2920 else{
2921 Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
2922 result = (*((Handle(AIS_Shape)*) &IO))->Shape();
2923 }
2924 }
2925
2926 if(curindex>0)
2927 TheAISContext()->CloseLocalContext(curindex);
2928
2929 return result;
2930}
2931
2932
2933//=======================================================================
2934//function : PickShapes
2935//purpose :
2936//=======================================================================
2937Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
2938 Handle(TopTools_HArray1OfShape)& thearr,
2939 const Standard_Integer MaxPick)
2940{
2941
2942 Standard_Integer Taille = thearr->Length();
2943 if(Taille>1)
2944 cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object"<<"\n";
2945
2946 // step 1: prepare the data
2947 Standard_Integer curindex = TheAISContext()->OpenLocalContext();
2948 if(TheType==TopAbs_SHAPE){
2949 Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
2950 TheAISContext()->AddFilter(F1);
2951 }
2952 else{
2953 Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
2954 TheAISContext()->AddFilter(TF);
2955 TheAISContext()->ActivateStandardMode(TheType);
2956
2957 }
2958
2959 // step 2 : wait for the selection...
2960
2961 Standard_Boolean NbPickGood (0),NbToReach(thearr->Length());
2962 Standard_Integer NbPickFail(0);
2963 Standard_Integer argccc = 5;
2964 const char *bufff[] = { "A", "B", "C","D", "E" };
2965 const char **argvvv = (const char **) bufff;
2966
2967
2968 while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
2969 while(ViewerMainLoop(argccc,argvvv)){}
2970 Standard_Integer NbStored = TheAISContext()->NbSelected();
2971 if((unsigned int ) NbStored != NbPickGood)
2972 NbPickGood= NbStored;
2973 else
2974 NbPickFail++;
2975 cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<"\n";
2976 }
2977
2978 // step3 get result.
2979
2980 if((unsigned int ) NbPickFail >= NbToReach) return Standard_False;
2981
2982 Standard_Integer i(0);
2983 for(TheAISContext()->InitSelected();TheAISContext()->MoreSelected();TheAISContext()->NextSelected()){
2984 i++;
2985 if(TheAISContext()->HasSelectedShape())
2986 thearr->SetValue(i,TheAISContext()->SelectedShape());
2987 else{
2988 Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
2989 thearr->SetValue(i,(*((Handle(AIS_Shape)*) &IO))->Shape());
2990 }
2991 }
2992
2993 TheAISContext()->CloseLocalContext(curindex);
2994 return Standard_True;
2995}
2996
2997
2998//=======================================================================
2999//function : VPickShape
3000//purpose :
3001//=======================================================================
3002static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv)
3003{
3004 TopoDS_Shape PickSh;
3005 TopAbs_ShapeEnum theType = TopAbs_COMPOUND;
3006
3007 if(argc==1)
3008 theType = TopAbs_SHAPE;
3009 else{
3010 if(!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX;
3011 else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE;
3012 else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE;
3013 else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE;
3014 else if(!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE;
3015 else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL;
3016 else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID;
3017 }
3018
3019 static Standard_Integer nbOfSub[8]={0,0,0,0,0,0,0,0};
3020 static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
3021
3022 TCollection_AsciiString name;
3023
3024
3025 Standard_Integer NbToPick = argc>2 ? argc-2 : 1;
3026 if(NbToPick==1){
3027 PickSh = ViewerTest::PickShape(theType);
3028
3029 if(PickSh.IsNull())
3030 return 1;
3031 if(argc>2){
3032 name += argv[2];
3033 }
3034 else{
3035
3036 if(!PickSh.IsNull()){
3037 nbOfSub[Standard_Integer(theType)]++;
3038 name += "Picked_";
3039 name += nameType[Standard_Integer(theType)];
3040 TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
3041 name +="_";
3042 name+=indxstring;
3043 }
3044 }
3045 // si on avait une petite methode pour voir si la shape
3046 // est deja dans la Double map, ca eviterait de creer....
3047 DBRep::Set(name.ToCString(),PickSh);
3048
3049 Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
3050 GetMapOfAIS().Bind(newsh, name);
3051 TheAISContext()->Display(newsh);
3052 di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n";
3053 }
3054
3055 // Plusieurs objets a picker, vite vite vite....
3056 //
3057 else{
3058 Standard_Boolean autonaming = !strcasecmp(argv[2],".");
3059 Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
3060 if(ViewerTest::PickShapes(theType,arr)){
3061 for(Standard_Integer i=1;i<=NbToPick;i++){
3062 PickSh = arr->Value(i);
3063 if(!PickSh.IsNull()){
3064 if(autonaming){
3065 nbOfSub[Standard_Integer(theType)]++;
3066 name.Clear();
3067 name += "Picked_";
3068 name += nameType[Standard_Integer(theType)];
3069 TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
3070 name +="_";
3071 name+=indxstring;
3072 }
3073 }
3074 else
3075 name = argv[1+i];
3076
3077 DBRep::Set(name.ToCString(),PickSh);
3078 Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
3079 GetMapOfAIS().Bind(newsh, name);
3080 di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n";
3081 TheAISContext()->Display(newsh);
3082
3083 }
3084 }
3085 }
3086 return 0;
7fd59977 3087}
7fd59977 3088
3089//=======================================================================
3090//function : list of known objects
3091//purpose :
3092//=======================================================================
3093static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
3094{
3095 // 1234567890 12345678901234567 123456789
3096 TCollection_AsciiString Colum [3]={"Standard Types","Type Of Object","Signature"};
3097 TCollection_AsciiString BlankLine(64,'_');
3098 Standard_Integer i ;
3099
3100 di<<"/n"<<BlankLine.ToCString()<<"\n";
3101
3102 for( i =0;i<=2;i++)
3103 Colum[i].Center(20,' ');
3104 for(i=0;i<=2;i++)
3105 di<<"|"<<Colum[i].ToCString();
3106 di<<"|"<<"\n";
3107
3108 di<<BlankLine.ToCString()<<"\n";
3109
3110 // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"};
3111 const char ** names = GetTypeNames();
3112
3113 TCollection_AsciiString curstring;
3114 TCollection_AsciiString curcolum[3];
3115
3116
3117 // les objets de type Datum..
3118 curcolum[1]+="Datum";
3119 for(i =0;i<=6;i++){
3120 curcolum[0].Clear();
3121 curcolum[0] += names[i];
3122
3123 curcolum[2].Clear();
3124 curcolum[2]+=TCollection_AsciiString(i+1);
3125
3126 for(Standard_Integer j =0;j<=2;j++){
3127 curcolum[j].Center(20,' ');
3128 di<<"|"<<curcolum[j].ToCString();
3129 }
3130 di<<"|"<<"\n";
3131 }
3132 di<<BlankLine.ToCString()<<"\n";
3133
3134 // les objets de type shape
3135 curcolum[1].Clear();
3136 curcolum[1]+="Shape";
3137 curcolum[1].Center(20,' ');
3138
3139 for(i=0;i<=2;i++){
3140 curcolum[0].Clear();
3141 curcolum[0] += names[7+i];
3142 curcolum[2].Clear();
3143 curcolum[2]+=TCollection_AsciiString(i);
3144
3145 for(Standard_Integer j =0;j<=2;j++){
3146 curcolum[j].Center(20,' ');
3147 di<<"|"<<curcolum[j].ToCString();
3148 }
3149 di<<"|"<<"\n";
3150 }
3151 di<<BlankLine.ToCString()<<"\n";
3152 // les IO de type objet...
3153 curcolum[1].Clear();
3154 curcolum[1]+="Object";
3155 curcolum[1].Center(20,' ');
3156 for(i=0;i<=1;i++){
3157 curcolum[0].Clear();
3158 curcolum[0] += names[10+i];
3159 curcolum[2].Clear();
3160 curcolum[2]+=TCollection_AsciiString(i);
3161
3162 for(Standard_Integer j =0;j<=2;j++){
3163 curcolum[j].Center(20,' ');
3164 di<<"|"<<curcolum[j].ToCString();
3165 }
3166 di<<"|"<<"\n";
3167 }
3168 di<<BlankLine.ToCString()<<"\n";
3169 // les contraintes et dimensions.
3170 // pour l'instant on separe juste contraintes et dimensions...
3171 // plus tard, on detaillera toutes les sortes...
3172 curcolum[1].Clear();
3173 curcolum[1]+="Relation";
3174 curcolum[1].Center(20,' ');
3175 for(i=0;i<=1;i++){
3176 curcolum[0].Clear();
3177 curcolum[0] += names[12+i];
3178 curcolum[2].Clear();
3179 curcolum[2]+=TCollection_AsciiString(i);
3180
3181 for(Standard_Integer j =0;j<=2;j++){
3182 curcolum[j].Center(20,' ');
3183 di<<"|"<<curcolum[j].ToCString();
3184 }
3185 di<<"|"<<"\n";
3186 }
3187 di<<BlankLine.ToCString()<<"\n";
3188
3189
3190 return 0;
3191}
3192
3193
3194static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
3195{
4952a30a 3196 if(argc!=2) return 1;
7fd59977 3197
3198 AIS_KindOfInteractive TheType;
3199 Standard_Integer TheSign(-1);
3200 GetTypeAndSignfromString(argv[1],TheType,TheSign);
3201
3202
3203 AIS_ListOfInteractive LIO;
3204
3205 // en attendant l'amelioration ais pour les dimensions...
3206 //
3207 Standard_Integer dimension_status(-1);
3208 if(TheType==AIS_KOI_Relation){
3209 dimension_status = TheSign ==1 ? 1 : 0;
3210 TheSign=-1;
3211 }
3212
3213 TheAISContext()->DisplayedObjects(TheType,TheSign,LIO);
3214 Handle(AIS_InteractiveObject) curio;
3215 for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){
3216 curio = it.Value();
3217
3218 if(dimension_status == -1)
3219 TheAISContext()->Erase(curio,Standard_False);
3220 else {
3221 AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
3222 if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
3223 (dimension_status==1 && KOD != AIS_KOD_NONE))
3224 TheAISContext()->Erase(curio,Standard_False);
3225 }
3226 }
3227 TheAISContext()->UpdateCurrentViewer();
3228 return 0;
3229}
3230static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char** argv)
3231{
3232 if(argc!=2) return 1;
3233
3234 AIS_KindOfInteractive TheType;
3235 Standard_Integer TheSign(-1);
3236 GetTypeAndSignfromString(argv[1],TheType,TheSign);
3237
3238 // en attendant l'amelioration ais pour les dimensions...
3239 //
3240 Standard_Integer dimension_status(-1);
3241 if(TheType==AIS_KOI_Relation){
3242 dimension_status = TheSign ==1 ? 1 : 0;
3243 TheSign=-1;
3244 }
3245
3246 AIS_ListOfInteractive LIO;
3247 TheAISContext()->ObjectsInside(LIO,TheType,TheSign);
3248 Handle(AIS_InteractiveObject) curio;
3249 for(AIS_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){
3250 curio = it.Value();
3251 if(dimension_status == -1)
3252 TheAISContext()->Display(curio,Standard_False);
3253 else {
3254 AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
3255 if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
3256 (dimension_status==1 && KOD != AIS_KOD_NONE))
3257 TheAISContext()->Display(curio,Standard_False);
3258 }
3259
3260 }
3261
3262 TheAISContext()->UpdateCurrentViewer();
3263 return 0;
3264}
3265
3266//==============================================================================
3267//function : VSetTransMode
3268//purpose :
3269//Draw arg : vsettransmode shape flag1 [flag2] [flag3] [X Y Z]
3270//==============================================================================
3271
3272static int VSetTransMode ( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
3273 // Verification des arguments
3274 if ( a3DView().IsNull() ) {
3275 ViewerTest::ViewerInit();
3276 di << "La commande vinit n'a pas ete appele avant" << "\n";
3277 }
3278
3279 if ( argc < 3 || argc > 8 ) {
3280 di << argv[0] << " Invalid number of arguments" << "\n";
3281 return 1;
3282 }
3283
3284 TCollection_AsciiString shapeName;
3285 shapeName = argv[1];
91322f44 3286 Standard_Integer persFlag1 = Draw::Atoi(argv[2]);
7fd59977 3287 Standard_Integer persFlag2 = 0;
3288 Standard_Integer persFlag3 = 0;
3289 gp_Pnt origin = gp_Pnt( 0.0, 0.0, 0.0 );
3290 if ( argc == 4 || argc == 5 || argc == 7 || argc == 8 ) {
91322f44 3291 persFlag2 = Draw::Atoi(argv[3]);
7fd59977 3292 }
3293 if ( argc == 5 || argc == 8 ) {
91322f44 3294 persFlag3 = Draw::Atoi(argv[4]);
7fd59977 3295 }
3296 if ( argc >= 6 ) {
91322f44 3297 origin.SetX( Draw::Atof(argv[argc - 3]) );
3298 origin.SetY( Draw::Atof(argv[argc - 2]) );
3299 origin.SetZ( Draw::Atof(argv[argc - 1]) );
7fd59977 3300 }
3301
3302 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(shapeName);
7fd59977 3303 Handle(Standard_Transient) anObj;
3304 if ( IsBound ) {
3305 anObj = GetMapOfAIS().Find2(shapeName);
3306 if ( anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject)) ) {
3307 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(anObj);
3308 aShape->SetTransformPersistence( (persFlag1 | persFlag2 | persFlag3), origin );
3309 if ( persFlag1 == 0 && persFlag2 == 0 && persFlag3 == 0 ) {
3310 di << argv[0] << " All persistence modifiers were removed" << "\n";
3311 }
3312 } else {
3313 di << argv[0] << " Wrong object type" << "\n";
3314 return 1;
3315 }
3316 } else { // Create the AIS_Shape from a name
3317 const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName((const char* )shapeName.ToCString());
3318 if ( !aShape.IsNull() ) {
3319 GetMapOfAIS().Bind( aShape, shapeName );
3320 aShape->SetTransformPersistence( (persFlag1 | persFlag2 | persFlag3), origin );
3321 TheAISContext()->Display( aShape, Standard_False );
3322 } else {
3323 di << argv[0] << " Object not found" << "\n";
3324 return 1;
3325 }
3326 }
3327
3328 // Upadate the screen and redraw the view
3329 TheAISContext()->UpdateCurrentViewer();
3330 return 0;
3331}
3332
3333static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a)
3334{
3335 ifstream s(a[1]);
3336 BRep_Builder builder;
3337 TopoDS_Shape shape;
3338 BRepTools::Read(shape, s, builder);
3339 DBRep::Set(a[1], shape);
3340 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
3341 Handle(AIS_Shape) ais = new AIS_Shape(shape);
3342 Ctx->Display(ais);
3343 return 0;
3344}
7fd59977 3345
3346//==============================================================================
3347//function : ViewerTest::Commands
3348//purpose : Add all the viewer command in the Draw_Interpretor
3349//==============================================================================
3350
3351void ViewerTest::Commands(Draw_Interpretor& theCommands)
3352{
3353 ViewerTest::ViewerCommands(theCommands);
3354 ViewerTest::RelationCommands(theCommands);
3355 ViewerTest::ObjectCommands(theCommands);
3356 ViewerTest::FilletCommands(theCommands);
3357 ViewerTest::VoxelCommands(theCommands);
3946774d 3358 ViewerTest::OpenGlCommands(theCommands);
7fd59977 3359
3360 const char *group = "AIS_Display";
3361
3362 // display
1c88cbaf 3363 theCommands.Add("visos",
3364 "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n"
3365 "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n",
3366 __FILE__, visos, group);
7fd59977 3367
3368 theCommands.Add("vdisplay",
ac4aaa98 3369 "vdisplay name1 [name2] ... [name n]"
3370 "\n\t\t: Displays named objects",
7fd59977 3371 __FILE__,VDisplay2,group);
3372
3373 theCommands.Add("verase",
ac4aaa98 3374 "verase [name1] ... [name n]"
3375 "\n\t\t: Erases selected or named objects."
3376 "\n\t\t: If there are no selected or named objects the whole viewer is erased.",
b514beda 3377 __FILE__, VErase, group);
7fd59977 3378
eef7fc64 3379 theCommands.Add("vremove",
3380 "vremove [-context] [name1] ... [name n]"
3381 "or vremove [-context] -all to remove all objects"
3382 "\n\t\t: Removes selected or named objects."
3383 "\n\t\t If -context is in arguments, the objects are not deleted"
3384 "\n\t\t from the map of objects and names.",
3385 __FILE__, VRemove, group);
3386
7fd59977 3387 theCommands.Add("vdonly",
ac4aaa98 3388 "vdonly [name1] ... [name n]"
3389 "\n\t\t: Displays only selected or named objects",
7fd59977 3390 __FILE__,VDonly2,group);
3391
3392 theCommands.Add("vdisplayall",
ac4aaa98 3393 "Displays all erased interactive objects (see vdir and vstate)",
7fd59977 3394 __FILE__,VDisplayAll,group);
3395
3396 theCommands.Add("veraseall",
ac4aaa98 3397 "Erases all objects displayed in the viewer",
b514beda 3398 __FILE__, VErase, group);
7fd59977 3399
3400 theCommands.Add("verasetype",
ac4aaa98 3401 "verasetype <Type>"
3402 "\n\t\t: Erase all the displayed objects of one given kind (see vtypes)",
7fd59977 3403 __FILE__,VEraseType,group);
3404
3405 theCommands.Add("vdisplaytype",
3406 "vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
3407 __FILE__,VDisplayType,group);
3408
3409 theCommands.Add("vdisplaymode",
3410 "vdispmode : vdispmode [name] mode(1,2,..) : no name -> on selected objects ",
3411 __FILE__,VDispMode,group);
3412
3413 theCommands.Add("verasemode",
3414 "verasemode : verasemode [name] mode(1,2,..) : no name -> on selected objects",
3415 __FILE__,VDispMode,group);
3416
3417 theCommands.Add("vsetdispmode",
ac4aaa98 3418 "vsetdispmode [name] mode(1,2,..)"
3419 "\n\t\t: Sets display mode for all, selected or named objects.",
7fd59977 3420 __FILE__,VDispMode,group);
3421
3422 theCommands.Add("vunsetdispmode",
ac4aaa98 3423 "vunsetdispmode [name]"
3424 "\n\t\t: Unsets custom display mode for selected or named objects.",
7fd59977 3425 __FILE__,VDispMode,group);
3426
3427 theCommands.Add("vdir",
ac4aaa98 3428 "Lists all objects displayed in 3D viewer",
7fd59977 3429 __FILE__,VDebug,group);
3430
3431 theCommands.Add("vdump",
ac4aaa98 3432 #ifdef HAVE_FREEIMAGE
b5ac8292 3433 "<filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
ac4aaa98 3434 "\n\t\t: Dumps contents of viewer window to PNG, BMP, JPEG or GIF file",
3435 #else
b5ac8292 3436 "<filename>.{ppm} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
ac4aaa98 3437 "\n\t\t: Dumps contents of viewer window to PPM image file",
3438 #endif
7fd59977 3439 __FILE__,VDump,group);
3440
3441 theCommands.Add("vsub", "vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects",
3442 __FILE__,VSubInt,group);
3443
3444 theCommands.Add("vsetcolor",
ac4aaa98 3445 "vsetcolor [name] ColorName"
3446 "\n\t\t: Sets color for all, selected or named objects.",
7fd59977 3447 __FILE__,VColor2,group);
3448
3449 theCommands.Add("vunsetcolor",
ac4aaa98 3450 "vunsetcolor [name]"
3451 "\n\t\t: Resets color for all, selected or named objects.",
7fd59977 3452 __FILE__,VColor2,group);
3453
3454 theCommands.Add("vsettransparency",
ac4aaa98 3455 "vsettransparency [name] Coefficient"
3456 "\n\t\t: Sets transparency for all, selected or named objects."
3457 "\n\t\t: The Coefficient may be between 0.0 (opaque) and 1.0 (fully transparent).",
7fd59977 3458 __FILE__,VTransparency,group);
3459
3460 theCommands.Add("vunsettransparency",
ac4aaa98 3461 "vunsettransparency [name]"
3462 "\n\t\t: Resets transparency for all, selected or named objects.",
7fd59977 3463 __FILE__,VTransparency,group);
3464
3465 theCommands.Add("vsetmaterial",
3466 "vmaterial : vmaterial [name of shape] MaterialName",
3467 __FILE__,VMaterial,group);
3468
3469 theCommands.Add("vunsetmaterial",
3470 "vmaterial : vmaterial [name of shape]",
3471 __FILE__,VMaterial,group);
3472
3473 theCommands.Add("vsetwidth",
3474 "vsetwidth : vwidth [name of shape] width(0->10)",
3475 __FILE__,VWidth,group);
3476
3477 theCommands.Add("vunsetwidth",
3478 "vunsetwidth : vwidth [name of shape]",
3479 __FILE__,VWidth,group);
3480
99c56d44 3481 theCommands.Add("vsetinteriorstyle",
3482 "vsetinteriorstyle : vsetinteriorstyle [name of shape] style",
3483 __FILE__,VInteriorStyle,group);
3484
7fd59977 3485 theCommands.Add("vardis",
3486 "vardis : display activeareas",
3487 __FILE__,VDispAreas,group);
3488
3489 theCommands.Add("varera",
3490 "varera : erase activeareas",
3491 __FILE__,VClearAreas,group);
3492
3493 theCommands.Add("vsensdis",
3494 "vardisp : display active entities",
3495 __FILE__,VDispSensi,group);
3496 theCommands.Add("vsensera",
3497 "vardisp : erase active entities",
3498 __FILE__,VClearSensi,group);
3499
3c982548 3500 theCommands.Add("vselprecision",
3501 "vselprecision : vselprecision [precision_mode [tolerance_value]]",
3502 __FILE__,VSelPrecision,group);
3503
7fd59977 3504 theCommands.Add("vperf",
3505 "vperf: vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)",
3506 __FILE__,VPerf,group);
3507
3508 theCommands.Add("vanimation",
3509 "vanimation CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile",
3510 __FILE__,VAnimation,group);
3511
3512 theCommands.Add("vsetshading",
3513 "vsetshading : vsetshading name Quality(default=0.0008) ",
3514 __FILE__,VShading,group);
3515
3516 theCommands.Add("vunsetshading",
3517 "vunsetshading :vunsetshading name ",
3518 __FILE__,VShading,group);
3519
3520 theCommands.Add("vtexture",
3521 "'vtexture NameOfShape TextureFile' \n \
3522 or 'vtexture NameOfShape' if you want to disable texture mapping \n \
3523 or 'vtexture NameOfShape ?' to list available textures\n \
3524 or 'vtexture NameOfShape IdOfTexture' (0<=IdOfTexture<=20)' to use predefined textures\n ",
3525 __FILE__,VTexture,group);
3526
3527 theCommands.Add("vtexscale",
3528 "'vtexscale NameOfShape ScaleU ScaleV' \n \
3529 or 'vtexscale NameOfShape ScaleUV' \n \
3530 or 'vtexscale NameOfShape' to disable scaling\n ",
3531 __FILE__,VTexture,group);
3532
3533 theCommands.Add("vtexorigin",
3534 "'vtexorigin NameOfShape UOrigin VOrigin' \n \
3535 or 'vtexorigin NameOfShape UVOrigin' \n \
3536 or 'vtexorigin NameOfShape' to disable origin positioning\n ",
3537 __FILE__,VTexture,group);
3538
3539 theCommands.Add("vtexrepeat",
3540 "'vtexrepeat NameOfShape URepeat VRepeat' \n \
3541 or 'vtexrepeat NameOfShape UVRepeat \n \
3542 or 'vtexrepeat NameOfShape' to disable texture repeat \n ",
3543 VTexture,group);
3544
3545 theCommands.Add("vtexdefault",
3546 "'vtexdefault NameOfShape' to set texture mapping default parameters \n",
3547 VTexture,group);
3548