#include <ViewerTest.hxx>
#include <ViewerTest_CmdParser.hxx>
+#include <Draw.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <TColStd_HArray1OfTransient.hxx>
return Standard_False;
}
+//=======================================================================
+//function : GetSelectedShapes
+//purpose :
+//=======================================================================
+void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes)
+{
+ for (GetAISContext()->InitSelected(); GetAISContext()->MoreSelected(); GetAISContext()->NextSelected())
+ {
+ TopoDS_Shape aShape = GetAISContext()->SelectedShape();
+ if (!aShape.IsNull())
+ {
+ theSelectedShapes.Append (aShape);
+ }
+ }
+}
+
+//=======================================================================
+//function : ParseLineType
+//purpose :
+//=======================================================================
+Standard_Boolean ViewerTest::ParseLineType (Standard_CString theArg,
+ Aspect_TypeOfLine& theType)
+{
+ TCollection_AsciiString aTypeStr (theArg);
+ aTypeStr.LowerCase();
+ if (aTypeStr == "empty")
+ {
+ theType = Aspect_TOL_EMPTY;
+ }
+ else if (aTypeStr == "solid")
+ {
+ theType = Aspect_TOL_SOLID;
+ }
+ else if (aTypeStr == "dot")
+ {
+ theType = Aspect_TOL_DOT;
+ }
+ else if (aTypeStr == "dash")
+ {
+ theType = Aspect_TOL_DASH;
+ }
+ else if (aTypeStr == "dotdash")
+ {
+ theType = Aspect_TOL_DOTDASH;
+ }
+ else
+ {
+ const int aTypeInt = Draw::Atoi (theArg);
+ if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
+ {
+ return Standard_False;
+ }
+ theType = (Aspect_TypeOfLine )aTypeInt;
+ }
+ return Standard_True;
+}
+
//=======================================================================
//function : GetTypeNames
//purpose :
Handle(AIS_InteractiveObject) anOldObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
if (!anOldObj.IsNull())
{
- aCtx->Remove (anOldObj, Standard_True);
+ aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate);
}
aMap.UnBind2 (theName);
}
void ViewerTest::Clear()
{
if ( !a3DView().IsNull() ) {
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
while ( it.More() ) {
cout << "Remove " << it.Key2() << endl;
//purpose : Activate a selection mode, vertex, edge, wire ..., in a local
// Context
//==============================================================================
+Standard_DISABLE_DEPRECATION_WARNINGS
void ViewerTest::StandardModeActivation(const Standard_Integer mode )
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if(mode==0) {
if (TheAISContext()->HasOpenedContext())
+ {
aContext->CloseLocalContext();
+ }
} else {
if(!aContext->HasOpenedContext()) {
// Open a local Context in order to be able to select subshape from
// the selected shape if any or for all if there is no selection
if (!aContext->FirstSelectedObject().IsNull()){
- aContext->OpenLocalContext(Standard_False);
+ aContext->OpenLocalContext(Standard_False);
for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){
aContext->Load( aContext->SelectedInteractive(),-1,Standard_True);
}
}
else
- aContext->OpenLocalContext();
+ {
+ aContext->OpenLocalContext();
+ }
}
const char *cmode="???";
}
if(theactivatedmodes.Contains(mode))
- { // Desactivate
- aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
- theactivatedmodes.Remove(mode);
- cout<<"Mode "<< cmode <<" OFF"<<endl;
- }
+ { // Desactivate
+ aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
+ theactivatedmodes.Remove(mode);
+ cout<<"Mode "<< cmode <<" OFF"<<endl;
+ }
else
- { // Activate
- aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
- theactivatedmodes.Add(mode);
- cout<<"Mode "<< cmode << " ON" << endl;
- }
+ { // Activate
+ aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
+ theactivatedmodes.Add(mode);
+ cout<<"Mode "<< cmode << " ON" << endl;
+ }
}
}
+Standard_ENABLE_DEPRECATION_WARNINGS
//==============================================================================
//function : CopyIsoAspect
return 0;
}
-//==============================================================================
-//function : VSelPrecision
-//purpose : To set the selection tolerance value
-//Draw arg : Selection tolerance value (real value determining the width and
-// height of selecting frustum bases). Without arguments the function
-// just prints current tolerance.
-//==============================================================================
-static int VSelPrecision(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if( argc > 2 )
- {
- di << "Wrong parameters! Must be: " << argv[0] << " [-unset] [tolerance]\n";
- return 1;
- }
-
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if( aContext.IsNull() )
- return 1;
-
- if( argc == 1 )
- {
- Standard_Real aPixelTolerance = aContext->PixelTolerance();
- di << "Pixel tolerance : " << aPixelTolerance << "\n";
- }
- else if (argc == 2)
- {
- TCollection_AsciiString anArg = TCollection_AsciiString (argv[1]);
- anArg.LowerCase();
- if (anArg == "-unset")
- {
- aContext->SetPixelTolerance (-1);
- }
- else
- {
- aContext->SetPixelTolerance (anArg.IntegerValue());
- }
- }
-
- return 0;
-}
-
//! Auxiliary enumeration
enum ViewerTest_StereoPair
{
}
Image_AlienPixMap aPixMap;
-
- bool isBigEndian = Image_PixMap::IsBigEndianHost();
Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
switch (aParams.BufferType)
{
- case Graphic3d_BT_RGB: aFormat = isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; break;
- case Graphic3d_BT_RGBA: aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break;
+ case Graphic3d_BT_RGB: aFormat = Image_PixMap::ImgRGB; break;
+ case Graphic3d_BT_RGBA: aFormat = Image_PixMap::ImgRGBA; break;
case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
}
}
Image_PixMap aPixMapL, aPixMapR;
- aPixMapL.InitWrapper (aFormat, aPixMap.ChangeData(),
+ aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
- aPixMapR.InitWrapper (aFormat, aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
+ aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
aParams.StereoOptions = V3d_SDO_LEFT_EYE;
return 1;
}
- if (aCtx->HasOpenedContext())
- {
- aCtx->CloseLocalContext();
- }
for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
Standard_Integer SelectionMode;
Standard_Integer Sensitivity;
+ Standard_Integer ToSetHatch;
+ Standard_Integer StdHatchStyle;
+ TCollection_AsciiString PathToHatchPattern;
+
//! Empty constructor
ViewerTest_AspectsChangeSet()
: ToSetVisibility (0),
MaxParamValue (500000),
ToSetSensitivity (0),
SelectionMode (-1),
- Sensitivity (-1) {}
+ Sensitivity (-1),
+ ToSetHatch (0),
+ StdHatchStyle (-1)
+ {}
//! @return true if no changes have been requested
Standard_Boolean IsEmpty() const
&& ToSetFreeBoundaryColor == 0
&& ToSetFreeBoundaryWidth == 0
&& ToSetMaxParamValue == 0
- && ToSetSensitivity == 0;
+ && ToSetSensitivity == 0
+ && ToSetHatch == 0;
}
//! @return true if properties are valid
std::cout << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")\n";
isOk = Standard_False;
}
+ if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "")
+ {
+ std::cout << "Error: hatch style must be specified\n";
+ isOk = Standard_False;
+ }
return isOk;
}
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
-
- TCollection_AsciiString aValue (theArgVec[anArgIter]);
- aValue.LowerCase();
-
- if (aValue.IsEqual ("solid"))
- {
- aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
- }
- else if (aValue.IsEqual ("dot"))
- {
- aChangeSet->TypeOfLine = Aspect_TOL_DOT;
- }
- else if (aValue.IsEqual ("dash"))
- {
- aChangeSet->TypeOfLine = Aspect_TOL_DASH;
- }
- else if (aValue.IsEqual ("dotdash"))
- {
- aChangeSet->TypeOfLine = Aspect_TOL_DOTDASH;
- }
- else
+ if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
aChangeSet->ToSetFreeBoundaryWidth = -1;
aChangeSet->FreeBoundaryWidth = 1.0;
+ aChangeSet->ToSetHatch = -1;
+ aChangeSet->StdHatchStyle = -1;
+ aChangeSet->PathToHatchPattern.Clear();
}
else if (anArg == "-isoontriangulation"
|| anArg == "-isoontriang")
aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
}
+ else if (anArg == "-sethatch")
+ {
+ if (isDefaults)
+ {
+ std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
+ return 1;
+ }
+
+ if (aNames.IsEmpty())
+ {
+ std::cout << "Error: object should be specified explicitly when -setHatch is used!\n";
+ return 1;
+ }
+
+ aChangeSet->ToSetHatch = 1;
+ TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]);
+ if (anArgHatch.Length() <= 2)
+ {
+ aChangeSet->StdHatchStyle = Draw::Atoi (anArgHatch.ToCString());
+ }
+ else
+ {
+ aChangeSet->PathToHatchPattern = anArgHatch;
+ }
+ }
else
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
isFirst = Standard_False;
}
- if (aCtx->HasOpenedContext())
- {
- aCtx->CloseLocalContext();
- }
-
// special case for -defaults parameter.
// all changed values will be set to DefaultDrawer.
if (isDefaults)
{
aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
}
+ if (aChangeSet->ToSetHatch != 0)
+ {
+ if (!aDrawer->HasOwnShadingAspect())
+ {
+ aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
+ }
+
+ Handle(Graphic3d_AspectFillArea3d) anAsp = aDrawer->ShadingAspect()->Aspect();
+ if (aChangeSet->ToSetHatch == -1)
+ {
+ anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+ }
+ else
+ {
+ anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+ if (!aChangeSet->PathToHatchPattern.IsEmpty())
+ {
+ Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+ if (anImage->Load (TCollection_AsciiString (aChangeSet->PathToHatchPattern.ToCString())))
+ {
+ anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+ }
+ else
+ {
+ std::cout << "Error: cannot load the following image: " << aChangeSet->PathToHatchPattern << std::endl;
+ return 1;
+ }
+ }
+ else if (aChangeSet->StdHatchStyle != -1)
+ {
+ anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)aChangeSet->StdHatchStyle));
+ }
+ }
+ toRedisplay = Standard_True;
+ }
}
for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (aCtx->HasOpenedContext())
{
aCtx->CloseLocalContext();
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toRemoveLocal && !aCtx->HasOpenedContext())
{
std::cerr << "Error: local selection context is not open.\n";
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
NCollection_List<TCollection_AsciiString> anIONameList;
if (toRemoveAll)
// Close local context if it is empty
TColStd_MapOfTransient aLocalIO;
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (aCtx->HasOpenedContext()
&& !aCtx->LocalContext()->DisplayedObjects (aLocalIO))
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
return 0;
}
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toEraseLocal && !aCtx->HasOpenedContext())
{
std::cerr << "Error: local selection context is not open.\n";
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
if (!aNamesOfEraseIO.IsEmpty())
{
return 1;
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toDisplayLocal && !aCtx->HasOpenedContext())
{
std::cerr << "Error: local selection context is not open.\n";
{
aCtx->CloseLocalContext (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
anIter.More(); anIter.Next())
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)
+//! Auxiliary method to check if presentation exists
+inline Standard_Integer checkMode (const Handle(AIS_InteractiveContext)& theCtx,
+ const Handle(AIS_InteractiveObject)& theIO,
+ const Standard_Integer theMode)
{
- if (theIO.IsNull())
+ if (theIO.IsNull() || theCtx.IsNull())
{
- return Handle(PrsMgr_Presentation)();
+ return -1;
}
if (theMode != -1)
{
if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode))
{
- return theCtx->MainPrsMgr()->Presentation (theIO, theMode);
+ return theMode;
}
}
else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode()))
{
- return theCtx->MainPrsMgr()->Presentation (theIO, theIO->DisplayMode());
+ return theIO->DisplayMode();
}
else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode()))
{
- return theCtx->MainPrsMgr()->Presentation (theIO, theCtx->DisplayMode());
+ return theCtx->DisplayMode();
}
- return Handle(PrsMgr_Presentation)();
+
+ return -1;
}
enum ViewerTest_BndAction
};
//! 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)
+inline void bndPresentation (Draw_Interpretor& theDI,
+ const Handle(PrsMgr_PresentationManager)& theMgr,
+ const Handle(AIS_InteractiveObject)& theObj,
+ const Standard_Integer theDispMode,
+ const TCollection_AsciiString& theName,
+ const ViewerTest_BndAction theAction,
+ const Handle(Prs3d_Drawer)& theStyle)
{
switch (theAction)
{
case BndAction_Hide:
{
- thePrs->Presentation()->GraphicUnHighlight();
+ theMgr->Unhighlight (theObj);
break;
}
case BndAction_Show:
{
- Handle(Graphic3d_Structure) aPrs (thePrs->Presentation());
- aPrs->CStructure()->HighlightColor = Quantity_NOC_GRAY99;
- aPrs->CStructure()->HighlightWithBndBox (aPrs, Standard_True);
+ theMgr->Color (theObj, theStyle, theDispMode);
break;
}
case BndAction_Print:
{
- Bnd_Box aBox = thePrs->Presentation()->MinMaxValues();
+ Bnd_Box aBox;
+ for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next())
+ {
+ if (aPrsIter.Value().Mode() != theDispMode)
+ continue;
+
+ aBox = aPrsIter.Value().Presentation()->Presentation()->MinMaxValues();
+ }
gp_Pnt aMin = aBox.CornerMin();
gp_Pnt aMax = aBox.CornerMax();
theDI << theName << "\n"
ViewerTest_BndAction anAction = BndAction_Show;
Standard_Integer aMode = -1;
+ Handle(Prs3d_Drawer) aStyle;
+
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
}
}
+ if (anAction == BndAction_Show)
+ {
+ aStyle = new Prs3d_Drawer();
+ aStyle->SetMethod (Aspect_TOHM_BOUNDBOX);
+ aStyle->SetColor (Quantity_NOC_GRAY99);
+ }
+
+ Standard_Integer aHighlightedMode = -1;
if (anArgIter < theArgNb)
{
// has a list of names
}
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
- Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
- if (aPrs.IsNull())
+ aHighlightedMode = checkMode (aCtx, anIO, aMode);
+ if (aHighlightedMode == -1)
{
- std::cout << "Error: presentation " << aName << " does not exist\n";
+ std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl;
return 1;
}
- bndPresentation (theDI, aPrs, aName, anAction);
+ bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle);
}
}
else if (aCtx->NbSelected() > 0)
for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
{
Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive();
- Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode);
- if (!aPrs.IsNull())
+ aHighlightedMode = checkMode (aCtx, anIO, aMode);
+ if (aHighlightedMode != -1)
{
- bndPresentation (theDI, aPrs, GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction);
+ bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode,
+ GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle);
}
}
}
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())
+ aHighlightedMode = checkMode (aCtx, anIO, aMode);
+ if (aHighlightedMode != -1)
{
- bndPresentation (theDI, aPrs, anIter.Key2(), anAction);
+ bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle);
}
}
}
}
// Prepare context for display
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (toDisplayLocal && !aCtx->HasOpenedContext())
{
aCtx->OpenLocalContext (Standard_False);
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
// Display interactive objects
for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
OSD_Timer myTimer;
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
-
Standard_Real Step=4*M_PI/180;
Standard_Real Angle=0;
return 0;
}
-
-//==================================================================================
-// Function : VAnimation
-//==================================================================================
-static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
- if (argc != 5) {
- di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile\n";
- return 1;
- }
-
- Standard_Real thread = 4;
- Standard_Real angleA=0;
- Standard_Real angleB;
- Standard_Real X;
- gp_Ax1 Ax1(gp_Pnt(0,0,0),gp_Vec(0,0,1));
-
- BRep_Builder B;
- TopoDS_Shape CrankArm;
- TopoDS_Shape CylinderHead;
- TopoDS_Shape Propeller;
- TopoDS_Shape EngineBlock;
-
- //BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B);
- //BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B);
- //BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B);
- //BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B);
- BRepTools::Read(CrankArm,argv[1],B);
- BRepTools::Read(CylinderHead,argv[2],B);
- BRepTools::Read(Propeller,argv[3],B);
- BRepTools::Read(EngineBlock,argv[4],B);
-
- if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) {di<<" Syntaxe error:loading failure.\n";}
-
-
- OSD_Timer myTimer;
- myTimer.Start();
-
- Handle(AIS_Shape) myAisCylinderHead = new AIS_Shape (CylinderHead);
- Handle(AIS_Shape) myAisEngineBlock = new AIS_Shape (EngineBlock);
- Handle(AIS_Shape) myAisCrankArm = new AIS_Shape (CrankArm);
- Handle(AIS_Shape) myAisPropeller = new AIS_Shape (Propeller);
-
- GetMapOfAIS().Bind(myAisCylinderHead,"a");
- GetMapOfAIS().Bind(myAisEngineBlock,"b");
- GetMapOfAIS().Bind(myAisCrankArm,"c");
- GetMapOfAIS().Bind(myAisPropeller,"d");
-
- 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()->Deactivate(myAisCylinderHead);
- TheAISContext()->Deactivate(myAisEngineBlock );
- TheAISContext()->Deactivate(myAisCrankArm );
- TheAISContext()->Deactivate(myAisPropeller );
-
- // Boucle de mouvement
- for (Standard_Real myAngle = 0;angleA<2*M_PI*10.175 ;myAngle++) {
-
- angleA = thread*myAngle*M_PI/180;
- X = Sin(angleA)*3/8;
- angleB = atan(X / Sqrt(-X * X + 1));
- Standard_Real decal(25*0.6);
-
-
- //Build a transformation on the display
- gp_Trsf aPropellerTrsf;
- aPropellerTrsf.SetRotation(Ax1,angleA);
- TheAISContext()->SetLocation(myAisPropeller,aPropellerTrsf);
-
- 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));
- gp_Trsf aCrankArmTrsf;
- aCrankArmTrsf.SetTransformation( base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB));
- TheAISContext()->SetLocation(myAisCrankArm,aCrankArmTrsf);
-
- TheAISContext()->UpdateCurrentViewer();
- }
-
- TopoDS_Shape myNewCrankArm =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() );
- TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() );
-
- myAisCrankArm ->ResetTransformation();
- myAisPropeller->ResetTransformation();
-
- myAisCrankArm -> Set(myNewCrankArm );
- myAisPropeller -> Set(myNewPropeller);
-
- TheAISContext()->Activate(myAisCylinderHead,0);
- TheAISContext()->Activate(myAisEngineBlock,0 );
- TheAISContext()->Activate(myAisCrankArm ,0 );
- TheAISContext()->Activate(myAisPropeller ,0 );
-
- myTimer.Stop();
- myTimer.Show();
- myTimer.Start();
-
- TheAISContext()->Redisplay(myAisCrankArm ,Standard_False);
- TheAISContext()->Redisplay(myAisPropeller,Standard_False);
-
- TheAISContext()->UpdateCurrentViewer();
- a3DView()->Redraw();
-
- myTimer.Stop();
- myTimer.Show();
-
- return 0;
-
-}
-
//==============================================================================
//function : VShading
//purpose : Sharpen or roughten the quality of the shading
// Verifications
const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
-
- if (TheAISContext()->HasOpenedContext())
- TheAISContext()->CloseLocalContext();
-
if (argc < 3) {
myDevCoef = 0.0008;
} else {
if (argc<2||argc>3) { di<<" Syntaxe error\n";return 1;}
ThereIsName = (argc == 3);
}
- else {
+ else
+ {
+ Standard_DISABLE_DEPRECATION_WARNINGS
// vunsetam
if (argc>1) {di<<" Syntaxe error\n";return 1;}
else {
di<<" R.A.Z de tous les modes de selecion\n";
di<<" Fermeture du Context local\n";
if (TheAISContext()->HasOpenedContext())
+ {
TheAISContext()->CloseLocalContext();
+ }
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
}
// IL n'y a aps de nom de shape passe en argument
}
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->OpenLocalContext(Standard_False);
+ Standard_ENABLE_DEPRECATION_WARNINGS
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it (GetMapOfAIS());
while(it.More()){
}
if( !TheAISContext()->HasOpenedContext() ) {
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->OpenLocalContext(Standard_False);
+ Standard_ENABLE_DEPRECATION_WARNINGS
// On charge tous les objets de la map
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
while(it.More()){
if (toPrintEntities)
{
theDI << "Detected entities:\n";
+ Standard_DISABLE_DEPRECATION_WARNINGS
Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
+ Standard_ENABLE_DEPRECATION_WARNINGS
SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
aName.LeftJustify (20, ' ');
char anInfoStr[512];
Sprintf (anInfoStr,
- " Depth: %+.3f Distance: %+.3f Point: %+.3f %+.3f %+.3f",
+ " Depth: %g Distance: %g Point: %g %g %g",
aPickData.Depth,
aPickData.MinDist,
aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z());
}
NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
+ Standard_DISABLE_DEPRECATION_WARNINGS
for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
{
aDetected.Add (aCtx->DetectedCurrentObject());
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
if (theArgNb >= 2
theDI << "\n";
}
printLocalSelectionInfo (aCtx, theDI);
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (aCtx->HasOpenedContext())
printLocalSelectionInfo (aCtx->LocalContext(), theDI);
+ Standard_ENABLE_DEPRECATION_WARNINGS
return 0;
}
const Standard_Integer MaxPick)
{
Handle(AIS_InteractiveObject) IO;
+ Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
+ Standard_ENABLE_DEPRECATION_WARNINGS
// step 1: prepare the data
if(curindex !=0){
arr->SetValue(i,IO2);
}
-
- if(curindex>0)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ if (curindex > 0)
+ {
TheAISContext()->CloseLocalContext(curindex);
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
return Standard_True;
}
const Standard_Integer MaxPick)
{
Handle(AIS_InteractiveObject) IO;
+ Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
+ Standard_ENABLE_DEPRECATION_WARNINGS
// step 1: prepare the data
IO = TheAISContext()->SelectedInteractive();
}
- if(curindex!=0)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ if (curindex != 0)
+ {
TheAISContext()->CloseLocalContext(curindex);
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
return IO;
}
{
// step 1: prepare the data
-
+ Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Integer curindex = TheAISContext()->OpenLocalContext();
+ Standard_ENABLE_DEPRECATION_WARNINGS
TopoDS_Shape result;
if(TheType==TopAbs_SHAPE){
else{
Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
TheAISContext()->AddFilter(TF);
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->ActivateStandardMode(TheType);
-
+ Standard_ENABLE_DEPRECATION_WARNINGS
}
}
}
- if(curindex>0)
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ if (curindex > 0)
+ {
TheAISContext()->CloseLocalContext(curindex);
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
return result;
}
cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
// step 1: prepare the data
+ Standard_DISABLE_DEPRECATION_WARNINGS
Standard_Integer curindex = TheAISContext()->OpenLocalContext();
+ Standard_ENABLE_DEPRECATION_WARNINGS
if(TheType==TopAbs_SHAPE){
Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
TheAISContext()->AddFilter(F1);
else{
Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
TheAISContext()->AddFilter(TF);
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->ActivateStandardMode(TheType);
-
+ Standard_ENABLE_DEPRECATION_WARNINGS
}
// step 2 : wait for the selection...
}
}
+ Standard_DISABLE_DEPRECATION_WARNINGS
TheAISContext()->CloseLocalContext(curindex);
+ Standard_ENABLE_DEPRECATION_WARNINGS
return Standard_True;
}
}
// Prepare context
+ Standard_DISABLE_DEPRECATION_WARNINGS
if (isLocal && !aCtx->HasOpenedContext())
{
aCtx->OpenLocalContext (Standard_False);
{
aCtx->CloseAllContexts (Standard_False);
}
+ Standard_ENABLE_DEPRECATION_WARNINGS
// Load selection of interactive objects
for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
return 0;
}
-//==============================================================================
-//function : VAutoActivateSelection
-//purpose : Activates or deactivates auto computation of selection
-//==============================================================================
-static int VAutoActivateSelection (Draw_Interpretor& theDi,
- Standard_Integer theArgNb,
- const char** theArgVec)
-{
-
- if (theArgNb > 2)
- {
- std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
- return 1;
- }
-
- Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
- if (aCtx.IsNull())
- {
- ViewerTest::ViewerInit();
- aCtx = ViewerTest::GetAISContext();
- }
-
- if (theArgNb == 1)
- {
- TCollection_AsciiString aSelActivationString;
- if (aCtx->GetAutoActivateSelection())
- {
- aSelActivationString.Copy ("ON");
- }
- else
- {
- aSelActivationString.Copy ("OFF");
- }
-
- theDi << "Auto activation of selection is: " << aSelActivationString << "\n";
- }
- else
- {
- Standard_Boolean toActivate = Draw::Atoi (theArgVec[1]) != 0;
- aCtx->SetAutoActivateSelection (toActivate);
- }
-
- return 0;
-}
-
//==============================================================================
//function : ViewerTest::Commands
//purpose : Add all the viewer command in the Draw_Interpretor
"vsensera : erase active entities",
__FILE__,VClearSensi,group);
- theCommands.Add("vselprecision",
- "vselprecision [-unset] [tolerance_value]"
- "\n\t\t Manages selection precision or prints current value if no parameter is passed."
- "\n\t\t -unset - restores default selection tolerance behavior, based on individual entity tolerance",
- __FILE__,VSelPrecision,group);
-
theCommands.Add("vperf",
"vperf: vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)"
"\n\t\t: Tests the animation of an object along a predefined trajectory.",
__FILE__,VPerf,group);
- theCommands.Add("vanimation",
- "vanimation CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile",
- __FILE__,VAnimation,group);
-
theCommands.Add("vsetshading",
"vsetshading : vsetshading name Quality(default=0.0008) "
"\n\t\t: Sets deflection coefficient that defines the quality of the shape representation in the shading mode.",
"\n\t\t: -local - open local context before selection computation",
__FILE__, VLoadSelection, group);
- theCommands.Add ("vautoactivatesel",
- "vautoactivatesel [0|1] : manage or display the option to automatically"
- "\n\t\t: activate selection for newly displayed objects"
- "\n\t\t: [0|1] - turn off | on auto activation of selection",
- __FILE__, VAutoActivateSelection, group);
-
theCommands.Add("vbsdf", "vbsdf [name] [options]"
"\nAdjusts parameters of material BSDF:"
"\n -help : Shows this message"
{
// definition of Viewer Command
ViewerTest::Commands(theDI);
- ViewerTest::AviCommands(theDI);
#ifdef OCCT_DEBUG
theDI << "Draw Plugin : OCC V2d & V3d commands are loaded\n";