aChangeSet->LineWidth = 1.0;
}
else if (anArg == "-settransp"
- || anArg == "-settransparancy")
+ || anArg == "-settransparency")
{
if (++anArgIter >= theArgNb)
{
}
}
else if (anArg == "-unsettransp"
- || anArg == "-unsettransparancy"
+ || anArg == "-unsettransparency"
|| anArg == "-unsetalpha"
|| anArg == "-opaque")
{
ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
Standard_Boolean isContextOnly = Standard_False;
Standard_Boolean toRemoveAll = Standard_False;
+ Standard_Boolean toPrintInfo = Standard_True;
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
toRemoveAll = Standard_True;
}
+ else if (anArg == "-noinfo")
+ {
+ toPrintInfo = Standard_False;
+ }
else if (!parseRedrawMode (anArg, aToUpdate))
{
break;
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
-
if (!anIO.IsNull())
{
TheAISContext()->Remove (anIO, Standard_False);
- theDI << anIter.Value().ToCString() << " was removed\n";
+ if (toPrintInfo)
+ {
+ theDI << anIter.Value().ToCString() << " was removed\n";
+ }
}
else
{
if (!aNisIO.IsNull())
{
TheNISContext()->Remove (aNisIO);
- theDI << anIter.Value().ToCString() << " was removed\n";
+ if (toPrintInfo)
+ {
+ theDI << anIter.Value().ToCString() << " was removed\n";
+ }
}
}
-
if (!isContextOnly)
{
GetMapOfAIS().UnBind2 (anIter.Value());
return 0;
}
+//! Auxiliary method to find presentation
+inline Handle(PrsMgr_Presentation) findPresentation (const Handle(AIS_InteractiveContext)& theCtx,
+ const Handle(AIS_InteractiveObject)& theIO,
+ const Standard_Integer theMode)
+{
+ if (theIO.IsNull())
+ {
+ return Handle(PrsMgr_Presentation)();
+ }
+
+ if (theMode != -1)
+ {
+ if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode))
+ {
+ return theCtx->MainPrsMgr()->Presentation (theIO, theMode);
+ }
+ }
+ else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode()))
+ {
+ return theCtx->MainPrsMgr()->Presentation (theIO, theIO->DisplayMode());
+ }
+ else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode()))
+ {
+ return theCtx->MainPrsMgr()->Presentation (theIO, theCtx->DisplayMode());
+ }
+ return Handle(PrsMgr_Presentation)();
+}
+
+enum ViewerTest_BndAction
+{
+ BndAction_Hide,
+ BndAction_Show,
+ BndAction_Print
+};
+
+//! Auxiliary method to print bounding box of presentation
+inline void bndPresentation (Draw_Interpretor& theDI,
+ const Handle(PrsMgr_Presentation)& thePrs,
+ const TCollection_AsciiString& theName,
+ const ViewerTest_BndAction theAction)
+{
+ switch (theAction)
+ {
+ case BndAction_Hide:
+ {
+ thePrs->Presentation()->GraphicUnHighlight();
+ break;
+ }
+ case BndAction_Show:
+ {
+ thePrs->Presentation()->BoundBox();
+ break;
+ }
+ case BndAction_Print:
+ {
+ Graphic3d_Vec3d aMin, aMax;
+ thePrs->Presentation()->MinMaxValues (aMin.x(), aMin.y(), aMin.z(),
+ aMax.x(), aMax.y(), aMax.z());
+ theDI << theName << "\n"
+ << aMin.x() << " " << aMin.y() << " " << aMin.z() << " "
+ << aMax.x() << " " << aMax.y() << " " << aMax.z() << "\n";
+ break;
+ }
+ }
+}
+
+//==============================================================================
+//function : VBounding
+//purpose :
+//==============================================================================
+int VBounding (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ if (aCtx.IsNull())
+ {
+ std::cout << "Error: no active view!\n";
+ return 1;
+ }
+
+ ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
+ ViewerTest_BndAction anAction = BndAction_Show;
+ Standard_Integer aMode = -1;
+
+ Standard_Integer anArgIter = 1;
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "-print")
+ {
+ anAction = BndAction_Print;
+ }
+ else if (anArg == "-show")
+ {
+ anAction = BndAction_Show;
+ }
+ else if (anArg == "-hide")
+ {
+ anAction = BndAction_Hide;
+ }
+ else if (anArg == "-mode")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aMode = Draw::Atoi (theArgVec[anArgIter]);
+ }
+ else if (!parseRedrawMode (anArg, aToUpdate))
+ {
+ break;
+ }
+ }
+
+ if (anArgIter < theArgNb)
+ {
+ // has a list of names
+ for (; anArgIter < theArgNb; ++anArgIter)
+ {
+ TCollection_AsciiString aName = theArgVec[anArgIter];
+ if (!GetMapOfAIS().IsBound2 (aName))
+ {
+ std::cout << "Error: presentation " << aName << " does not exist\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+ Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
+ if (aPrs.IsNull())
+ {
+ std::cout << "Error: presentation " << aName << " does not exist\n";
+ return 1;
+ }
+ bndPresentation (theDI, aPrs, aName, anAction);
+ }
+ }
+ else if (TheAISContext()->NbCurrents() > 0)
+ {
+ // remove all currently selected objects
+ for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
+ {
+ Handle(AIS_InteractiveObject) anIO = aCtx->Current();
+ Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
+ if (!aPrs.IsNull())
+ {
+ bndPresentation (theDI, aPrs, GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction);
+ }
+ }
+ }
+ else
+ {
+ // all objects
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
+ anIter.More(); anIter.Next())
+ {
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+ Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
+ if (!aPrs.IsNull())
+ {
+ bndPresentation (theDI, aPrs, anIter.Key2(), anAction);
+ }
+ }
+ }
+
+ // update the screen and redraw the view
+ const Standard_Boolean isAutoUpdate = a3DView()->SetImmediateUpdate (Standard_False);
+ a3DView()->SetImmediateUpdate (isAutoUpdate);
+ if ((isAutoUpdate && aToUpdate != ViewerTest_RM_RedrawSuppress)
+ || aToUpdate == ViewerTest_RM_RedrawForce)
+ {
+ TheAISContext()->UpdateCurrentViewer();
+ }
+
+ return 0;
+}
+
//==============================================================================
//function : VTexture
//purpose :
}
ViewerTest_RedrawMode aToUpdate = ViewerTest_RM_Auto;
+ Standard_Integer isMutable = -1;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
- const TCollection_AsciiString aName = theArgVec[anArgIter];
+ const TCollection_AsciiString aName = theArgVec[anArgIter];
+ TCollection_AsciiString aNameCase = aName;
+ aNameCase.LowerCase();
if (parseRedrawMode (aName, aToUpdate))
{
continue;
}
+ else if (aNameCase == "-mutable")
+ {
+ isMutable = 1;
+ continue;
+ }
else if (!GetMapOfAIS().IsBound2 (aName))
{
// create the AIS_Shape from a name
const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName (aName.ToCString());
if (!aShape.IsNull())
{
+ if (isMutable != -1)
+ {
+ aShape->SetMutable (isMutable == 1);
+ }
GetMapOfAIS().Bind (aShape, aName);
aCtx->Display (aShape, Standard_False);
}
if (anObj->IsKind (STANDARD_TYPE (AIS_InteractiveObject)))
{
Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anObj);
+ if (isMutable != -1)
+ {
+ aShape->SetMutable (isMutable == 1);
+ }
+
if (aShape->Type() == AIS_KOI_Datum)
{
aCtx->Display (aShape, Standard_False);
aCtx->Redisplay (aShape, Standard_False);
aCtx->Display (aShape, Standard_False);
}
- aShape.Nullify();
}
else if (anObj->IsKind (STANDARD_TYPE (NIS_InteractiveObject)))
{
GetMapOfAIS().Bind(myAisCrankArm,"c");
GetMapOfAIS().Bind(myAisPropeller,"d");
- TheAISContext()->SetColor(myAisCylinderHead, Quantity_NOC_INDIANRED);
- TheAISContext()->SetColor(myAisEngineBlock , Quantity_NOC_RED);
- TheAISContext()->SetColor(myAisPropeller , Quantity_NOC_GREEN);
+ myAisCylinderHead->SetMutable (Standard_True);
+ myAisEngineBlock ->SetMutable (Standard_True);
+ myAisCrankArm ->SetMutable (Standard_True);
+ myAisPropeller ->SetMutable (Standard_True);
+
+ TheAISContext()->SetColor (myAisCylinderHead, Quantity_NOC_INDIANRED);
+ TheAISContext()->SetColor (myAisEngineBlock, Quantity_NOC_RED);
+ TheAISContext()->SetColor (myAisPropeller, Quantity_NOC_GREEN);
- TheAISContext()->Display(myAisCylinderHead,Standard_False);
- TheAISContext()->Display(myAisEngineBlock,Standard_False );
- TheAISContext()->Display(myAisCrankArm,Standard_False );
- TheAISContext()->Display(myAisPropeller,Standard_False);
+ TheAISContext()->Display (myAisCylinderHead, Standard_False);
+ TheAISContext()->Display (myAisEngineBlock, Standard_False);
+ TheAISContext()->Display (myAisCrankArm, Standard_False);
+ TheAISContext()->Display (myAisPropeller, Standard_False);
TheAISContext()->Deactivate(myAisCylinderHead);
TheAISContext()->Deactivate(myAisEngineBlock );
TheAISContext()->UpdateCurrentViewer();
}
- TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Location() );
- TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Location() );
+ TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() );
+ TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() );
- myAisCrankArm ->ResetLocation();
- myAisPropeller->ResetLocation();
+ myAisCrankArm ->ResetTransformation();
+ myAisPropeller->ResetTransformation();
myAisCrankArm -> Set(myNewCrankArm );
myAisPropeller -> Set(myNewPropeller);
__FILE__, visos, group);
theCommands.Add("vdisplay",
- "vdisplay [-noupdate|-update] name1 [name2] ... [name n]"
+ "vdisplay [-noupdate|-update] [-mutable] name1 [name2] ... [name n]"
"\n\t\t: Displays named objects."
"\n\t\t: Option -noupdate suppresses viewer redraw call."
+ "\n\t\t: Option -mutable enables optimizations for mutable objects."
__FILE__,VDisplay2,group);
theCommands.Add ("vupdate",
__FILE__, VErase, group);
theCommands.Add("vremove",
- "vremove [-noupdate|-update] [-context] [-all] [name1] ... [name n]"
+ "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ... [name n]"
"or vremove [-context] -all to remove all objects"
"\n\t\t: Removes selected or named objects."
"\n\t\t If -context is in arguments, the objects are not deleted"
"\n\t\t from the map of objects and names."
- "\n\t\t: Option -noupdate suppresses viewer redraw call.",
+ "\n\t\t: Option -noupdate suppresses viewer redraw call."
+ "\n\t\t: Option -noinfo suppresses displaying the list of removed objects.",
__FILE__, VRemove, group);
theCommands.Add("vdonly",
"\n\t\t: Erase all the displayed objects of one given kind (see vtypes)",
__FILE__,VEraseType,group);
+ theCommands.Add("vbounding",
+ "vbounding [-noupdate|-update] [-mode] name1 [name2 [...]]"
+ "\n\t\t: [-print] [-hide]"
+ "\n\t\t: Temporarily display bounding box of specified Interactive"
+ "\n\t\t: Objects, or print it to console if -print is specified."
+ "\n\t\t: Already displayed box might be hidden by -hide option.",
+ __FILE__,VBounding,group);
+
theCommands.Add("vdisplaytype",
"vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
__FILE__,VDisplayType,group);
"vaspects [-noupdate|-update] [name1 [name2 [...]]]"
"\n\t\t: [-setcolor ColorName] [-unsetcolor]"
"\n\t\t: [-setmaterial MatName] [-unsetmaterial]"
- "\n\t\t: [-settransparency Transp] [-unsettransparancy]"
+ "\n\t\t: [-settransparency Transp] [-unsettransparency]"
"\n\t\t: [-setwidth LineWidth] [-unsetwidth]"
"\n\t\t: [-subshapes subname1 [subname2 [...]]]"
"\n\t\t: Manage presentation properties of all, selected or named objects."