// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <ViewerTest.hxx>
-#include <string.h>
-
#include <Quantity_NameOfColor.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw.hxx>
#include <DBRep.hxx>
#include <Font_BRepFont.hxx>
+#include <Font_BRepTextBuilder.hxx>
#include <Font_FontMgr.hxx>
#include <OSD_Chronometer.hxx>
#include <TCollection_AsciiString.hxx>
-#include <Visual3d_View.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <V3d.hxx>
#include <AIS_Shape.hxx>
#include <AIS_DisplayMode.hxx>
+#include <AIS_PointCloud.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <AIS_MapOfInteractive.hxx>
+#include <ViewerTest_AutoUpdater.hxx>
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
#include <ViewerTest_EventManager.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
#include <gp_Trsf.hxx>
+#include <gp_Quaternion.hxx>
#include <TopLoc_Location.hxx>
#include <HLRAlgo_Projector.hxx>
#include <Standard_Real.hxx>
#include <AIS_Circle.hxx>
-#include <AIS_Drawer.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <TopoDS_Wire.hxx>
-#include <AIS_ConnectedShape.hxx>
#include <AIS_MultipleConnectedInteractive.hxx>
-#include <AIS_MultipleConnectedShape.hxx>
+#include <AIS_ConnectedInteractive.hxx>
+#include <AIS_TextLabel.hxx>
#include <TopLoc_Location.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <BRepExtrema_ExtPC.hxx>
#include <BRepExtrema_ExtPF.hxx>
+#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_VertexDrawMode.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
#include <Image_AlienPixMap.hxx>
#include <TColStd_HArray1OfAsciiString.hxx>
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#ifdef WNT
-#define _CRT_SECURE_NO_DEPRECATE
-#pragma warning (disable:4996)
-#endif
+#include <TColStd_HSequenceOfAsciiString.hxx>
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
{
// Verification des arguments
- if ( argc!=2) {di<<argv[0]<<" error"<<"\n"; return 1;}
+ if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
// Declarations
Standard_Integer myCurrentIndex;
myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
// On active les modes de selections faces.
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
- di<<" Select a face ."<<"\n";
+ di<<" Select a face .\n";
// Boucle d'attente waitpick.
Standard_Integer argccc = 5;
//Draw arg : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw]
//==============================================================================
-static int VTrihedron (Draw_Interpretor& theDi,
+static int VTrihedron (Draw_Interpretor& /*theDi*/,
Standard_Integer theArgsNb,
const char** theArgVec)
{
- if (theArgsNb != 2 && theArgsNb != 5 && theArgsNb != 11)
+ if (theArgsNb < 2 || theArgsNb > 11)
+ {
+ std::cout << theArgVec[0] << " syntax error\n";
+ return 1;
+ }
+
+ // Parse parameters
+ NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
+ TCollection_AsciiString aParseKey;
+ for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
+ {
+ TCollection_AsciiString anArg (theArgVec [anArgIt]);
+
+ if (anArg.Value (1) == '-' && !anArg.IsRealValue())
+ {
+ aParseKey = anArg;
+ aParseKey.Remove (1);
+ aParseKey.LowerCase();
+ aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
+ continue;
+ }
+
+ if (aParseKey.IsEmpty())
+ {
+ continue;
+ }
+
+ aMapOfArgs(aParseKey)->Append (anArg);
+ }
+
+ // Check parameters
+ if ( (aMapOfArgs.IsBound ("xaxis") && !aMapOfArgs.IsBound ("zaxis"))
+ || (!aMapOfArgs.IsBound ("xaxis") && aMapOfArgs.IsBound ("zaxis")) )
{
- theDi << theArgVec[0] << " Syntax error\n";
+ std::cout << theArgVec[0] << " error: -xaxis and -yaxis parameters are to set together.\n";
return 1;
}
+ for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
+ aMapIt.More(); aMapIt.Next())
+ {
+ const TCollection_AsciiString& aKey = aMapIt.Key();
+ const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
+
+ // Bool key, without arguments
+ if (aKey.IsEqual ("hidelabels") && anArgs->IsEmpty())
+ {
+ continue;
+ }
+
+ if ( (aKey.IsEqual ("xaxis") || aKey.IsEqual ("zaxis") || aKey.IsEqual ("origin")) && anArgs->Length() == 3
+ && anArgs->Value(1).IsRealValue() && anArgs->Value(2).IsRealValue() && anArgs->Value(3).IsRealValue() )
+ {
+ continue;
+ }
+ }
+
+ // Process parameters
gp_Pnt anOrigin (0.0, 0.0, 0.0);
gp_Dir aDirZ = gp::DZ();
gp_Dir aDirX = gp::DX();
- Standard_Integer anArgIter = 2; // 1st is an IO name
- if (anArgIter < theArgsNb)
+
+ Handle(TColStd_HSequenceOfAsciiString) aValues;
+
+ if (aMapOfArgs.Find ("origin", aValues))
{
- anOrigin.SetX (Draw::Atof (theArgVec[anArgIter++]));
- anOrigin.SetY (Draw::Atof (theArgVec[anArgIter++]));
- anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter++]));
- if (anArgIter < theArgsNb)
- {
- Standard_Real aX = Draw::Atof (theArgVec[anArgIter++]);
- Standard_Real aY = Draw::Atof (theArgVec[anArgIter++]);
- Standard_Real aZ = Draw::Atof (theArgVec[anArgIter++]);
- aDirZ.SetCoord (aX, aY, aZ);
+ anOrigin.SetX (aValues->Value(1).RealValue());
+ anOrigin.SetY (aValues->Value(2).RealValue());
+ anOrigin.SetZ (aValues->Value(3).RealValue());
+ }
- aX = Draw::Atof (theArgVec[anArgIter++]);
- aY = Draw::Atof (theArgVec[anArgIter++]);
- aZ = Draw::Atof (theArgVec[anArgIter++]);
- aDirX.SetCoord (aX, aY, aZ);
- }
+ Handle(TColStd_HSequenceOfAsciiString) aValues2;
+ if (aMapOfArgs.Find ("xaxis", aValues) && aMapOfArgs.Find ("zaxis", aValues2))
+ {
+ Standard_Real aX = aValues->Value(1).RealValue();
+ Standard_Real aY = aValues->Value(2).RealValue();
+ Standard_Real aZ = aValues->Value(3).RealValue();
+ aDirX.SetCoord (aX, aY, aZ);
+
+ aX = aValues->Value(1).RealValue();
+ aY = aValues->Value(2).RealValue();
+ aZ = aValues->Value(3).RealValue();
+ aDirZ.SetCoord (aX, aY, aZ);
}
if (!aDirZ.IsNormal (aDirX, M_PI / 180.0))
{
- theDi << theArgVec[0] << " - VectorX is not normal to VectorZ\n";
+ std::cout << theArgVec[0] << " error - VectorX is not normal to VectorZ\n";
return 1;
}
Handle(Geom_Axis2Placement) aPlacement = new Geom_Axis2Placement (anOrigin, aDirZ, aDirX);
Handle(AIS_Trihedron) aShape = new AIS_Trihedron (aPlacement);
+
+ if (aMapOfArgs.Find ("hidelabels", aValues))
+ {
+ const Handle(Prs3d_Drawer)& aDrawer = aShape->Attributes();
+
+ if(!aDrawer->HasOwnDatumAspect())
+ {
+ Handle(Prs3d_DatumAspect) aDefAspect = ViewerTest::GetAISContext()->DefaultDrawer()->DatumAspect();
+
+ Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
+ aDatumAspect->FirstAxisAspect()->SetAspect (aDefAspect->FirstAxisAspect()->Aspect());
+ aDatumAspect->SecondAxisAspect()->SetAspect (aDefAspect->SecondAxisAspect()->Aspect());
+ aDatumAspect->ThirdAxisAspect()->SetAspect (aDefAspect->ThirdAxisAspect()->Aspect());
+ aDatumAspect->SetAxisLength (aDefAspect->FirstAxisLength(),
+ aDefAspect->SecondAxisLength(),
+ aDefAspect->ThirdAxisLength());
+
+ aDrawer->SetDatumAspect (aDatumAspect);
+ }
+
+ aDrawer->DatumAspect()->SetToDrawLabels (Standard_False);
+ }
+
VDisplayAISObject (theArgVec[1], aShape);
return 0;
}
Quantity_NameOfColor col = Quantity_NOC_BLACK ;
// Verification des arguments
- if ( argc>3 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
+ if ( argc>3 ) {di<<argv[0]<<" Syntaxe error\n"; return 1;}
// Verification du nombre d'arguments
if (argc==1) {ThereIsName=Standard_False;value=100;}
TheAISContext()->CloseLocalContext();
// On set le booleen ThereIsCurrent
- if (TheAISContext() -> NbCurrents() > 0) {ThereIsCurrent=Standard_True;}
+ if (TheAISContext() -> NbSelected() > 0) {ThereIsCurrent=Standard_True;}
else {ThereIsCurrent=Standard_False;}
Handle(AIS_InteractiveObject) aShape=
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
- if (!aShape.IsNull() && TheAISContext()->IsCurrent(aShape) )
+ if (!aShape.IsNull() && TheAISContext()->IsSelected(aShape) )
{
// On verifie que l'AIS InteraciveObject selectionne est bien
// On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
// pour lui appliquer la methode SetSize()
- Handle(AIS_Trihedron) aTrihedron = *(Handle(AIS_Trihedron)*) &aShape;
+ Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast (aShape);
// C'est bien un triedre,on chage sa valeur!
aTrihedron->SetSize(value);
// On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
// pour lui appliquer la methode SetSize()
- Handle(AIS_Trihedron) aTrihedron = *(Handle(AIS_Trihedron)*) &aShape;
+ Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast (aShape);
// C'est bien un triedre,on chage sa valeur
aTrihedron->SetSize(value);
{
// Verification des arguments
- if ( argc!=2) {di<<argv[0]<<" error"<<"\n"; return 1;}
+ if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
// Declarations
Standard_Integer myCurrentIndex;
if (!ShapeA.IsNull() &&
ShapeA->Type()==AIS_KOI_Datum && ShapeA->Signature()==3 ) {
// on le downcast
- Handle(AIS_Trihedron) TrihedronA =((*(Handle(AIS_Trihedron)*)&ShapeA));
+ Handle(AIS_Trihedron) TrihedronA =(Handle(AIS_Trihedron)::DownCast (ShapeA));
// on le charge dans le contexte et on active le mode Plane.
TheAISContext()->Load(TrihedronA,0,Standard_False);
TheAISContext()->Activate(TrihedronA,3);
it.Next();
}
- di<<" Select a plane."<<"\n";
+ di<<" Select a plane.\n";
// Boucle d'attente waitpick.
Standard_Integer argccc = 5;
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
Handle(AIS_InteractiveObject) theIOB;
for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
- theIOB = TheAISContext()->Interactive();
+ theIOB = TheAISContext()->SelectedInteractive();
}
// on le downcast
- Handle(AIS_Plane) PlaneB =((*(Handle(AIS_Plane)*)&theIOB));
+ Handle(AIS_Plane) PlaneB =(Handle(AIS_Plane)::DownCast (theIOB));
// Fermeture du contexte local.
TheAISContext()->CloseLocalContext(myCurrentIndex);
Standard_Integer MyCurrentIndex;
// Verification
- if (argc<2 || argc>8 ) {di<<" Syntaxe error"<<"\n";return 1;}
+ if (argc<2 || argc>8 ) {di<<" Syntaxe error\n";return 1;}
if (argc==8) HasArg=Standard_True;
else HasArg=Standard_False;
// Active le mode edge et le mode vertex
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
- di<<" Select an edge or a vertex."<<"\n";
+ di<<" Select an edge or a vertex.\n";
// Boucle d'attente waitpick.
Standard_Integer argcc = 5;
if (ShapeA.ShapeType()==TopAbs_VERTEX) {
// on desactive le mode edge
TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
- di<<" Select a different vertex."<<"\n";
+ di<<" Select a different vertex.\n";
TopoDS_Shape ShapeB;
do {
// Active le mode edge
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
- di<<" Select an edge."<<"\n";
+ di<<" Select an edge.\n";
// Boucle d'attente waitpick.
Standard_Integer argcc = 5;
// Active le mode vertex et deactive edges
TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
- di<<" Select a vertex."<<"\n";
+ di<<" Select a vertex.\n";
// Boucle d'attente waitpick.
Standard_Integer argccc = 5;
// Active le mode edge
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
- di<<" Select an edge."<<"\n";
+ di<<" Select an edge.\n";
// Boucle d'attente waitpick.
Standard_Integer argcc = 5;
// Active le mode vertex et deactive edges
TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
- di<<" Slect a vertex."<<"\n";
+ di<<" Slect a vertex.\n";
// Boucle d'attente waitpick.
Standard_Integer argccc = 5;
Standard_Integer myCurrentIndex;
// Verification
- if (argc<2 || argc>5 ) {di<<" Syntaxe error"<<"\n";return 1;}
+ if (argc<2 || argc>5 ) {di<<" Syntaxe error\n";return 1;}
if (argc==5) HasArg=Standard_True;
else HasArg=Standard_False;
// Active le mode Vertex et Edges
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
- di<<" Select a vertex or an edge(build the middle)"<<"\n";
+ di<<" Select a vertex or an edge(build the middle)\n";
// Boucle d'attente waitpick.
Standard_Integer argcc = 5;
Abs(aCartPointB->Z()-aCartPointA->Z())<=Precision::Confusion())
{
// B=A
- std::cout<<"vplane error: same points"<<"\n";return 1;
+ std::cout<<"vplane error: same points\n";return 1;
}
if(Abs(aCartPointC->X()-aCartPointA->X())<=Precision::Confusion() &&
Abs(aCartPointC->Y()-aCartPointA->Y())<=Precision::Confusion() &&
Abs(aCartPointC->Z()-aCartPointA->Z())<=Precision::Confusion())
{
// C=A
- std::cout<<"vplane error: same points"<<"\n";return 1;
+ std::cout<<"vplane error: same points\n";return 1;
}
if(Abs(aCartPointC->X()-aCartPointB->X())<=Precision::Confusion() &&
Abs(aCartPointC->Y()-aCartPointB->Y())<=Precision::Confusion() &&
Abs(aCartPointC->Z()-aCartPointB->Z())<=Precision::Confusion())
{
// C=B
- std::cout<<"vplane error: same points"<<"\n";return 1;
+ std::cout<<"vplane error: same points\n";return 1;
}
gp_Pnt A = aCartPointA->Pnt();
}
else
{
- std::cout<<" vplanepara: error"<<"\n";return 1;
+ std::cout<<" vplanepara: error\n";return 1;
}
}
}
aPlane->SetComponent (new Geom_Plane (aCenterPnt, aDirection));
aPlane->SetSize (aSizeX, aSizeY);
- if (isUpdate)
- {
- aContextAIS->Update (aPlane, Standard_True);
- }
+ aContextAIS->Update (aPlane, isUpdate);
return 0;
}
{
Standard_Integer myCurrentIndex;
// Verifications
- if (argc!=4 && argc!=8 && argc!=2 ) {di<<"vline error: number of arguments not correct "<<"\n";return 1; }
+ if (argc!=4 && argc!=8 && argc!=2 ) {di<<"vline error: number of arguments not correct \n";return 1; }
// Fermeture des contextes
TheAISContext()->CloseAllContexts();
if (theShapeA.IsNull() ||
(!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
{
- di <<"vline error: wrong type of 2de argument."<<"\n";
+ di <<"vline error: wrong type of 2de argument.\n";
return 1;
}
}
- else {di <<"vline error: wrong type of 1st argument."<<"\n";return 1; }
+ else {di <<"vline error: wrong type of 1st argument.\n";return 1; }
// Les deux parametres sont du bon type. On verifie que les points ne sont pas confondus
- Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
- Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
+ Handle(AIS_Point) theAISPointA= Handle(AIS_Point)::DownCast (theShapeA);
+ Handle(AIS_Point) theAISPointB= Handle(AIS_Point)::DownCast (theShapeB);
Handle(Geom_Point ) myGeomPointBA= theAISPointA->Component();
- Handle(Geom_CartesianPoint ) myCartPointA= *((Handle(Geom_CartesianPoint)*)& myGeomPointBA);
+ Handle(Geom_CartesianPoint ) myCartPointA= Handle(Geom_CartesianPoint)::DownCast (myGeomPointBA);
// Handle(Geom_CartesianPoint ) myCartPointA= *(Handle(Geom_CartesianPoint)*)& (theAISPointA->Component() ) ;
Handle(Geom_Point ) myGeomPointB= theAISPointB->Component();
- Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& myGeomPointB);
+ Handle(Geom_CartesianPoint ) myCartPointB= Handle(Geom_CartesianPoint)::DownCast (myGeomPointB);
// Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAISPointB->Component() ) ;
if (myCartPointB->X()==myCartPointA->X() && myCartPointB->Y()==myCartPointA->Y() && myCartPointB->Z()==myCartPointA->Z() ) {
// B=A
- di<<"vline error: same points"<<"\n";return 1;
+ di<<"vline error: same points\n";return 1;
}
// Les deux points sont OK...Construction de l'AIS_Line (en faite, le segment AB)
Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
// Active le mode Vertex.
TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
- di<<" Select a vertex "<<"\n";
+ di<<" Select a vertex \n";
// Boucle d'attente waitpick.
Standard_Integer argcc = 5;
// ShapeA est un Vertex
if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
- di<<" Select a different vertex."<<"\n";
+ di<<" Select a different vertex.\n";
TopoDS_Shape ShapeB;
do {
}
else {
- di<<"vline error."<<"\n";
+ di<<"vline error.\n";
}
}
return aCircle;
}
-DEFINE_STANDARD_HANDLE(FilledCircle, AIS_InteractiveObject)
-
class FilledCircle : public AIS_InteractiveObject
{
public:
// CASCADE RTTI
- DEFINE_STANDARD_RTTI(FilledCircle);
+ DEFINE_STANDARD_RTTI_INLINE(FilledCircle,AIS_InteractiveObject);
FilledCircle(gp_Pnt theCenter, Standard_Real theRadius);
FilledCircle(Handle(Geom_Circle) theCircle);
// Virtual methods implementation
void Compute ( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode);
+ const Standard_Integer theMode) Standard_OVERRIDE;
void ComputeSelection ( const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode);
+ const Standard_Integer theMode) Standard_OVERRIDE;
protected:
Handle(Geom_Circle) myCircle;
};
-IMPLEMENT_STANDARD_HANDLE(FilledCircle, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(FilledCircle, AIS_InteractiveObject)
FilledCircle::FilledCircle(gp_Pnt theCenter, Standard_Real theRadius)
{
return aFace;
}
-void FilledCircle::Compute(const Handle_PrsMgr_PresentationManager3d &/*thePresentationManager*/,
- const Handle_Prs3d_Presentation &thePresentation,
+void FilledCircle::Compute(const Handle(PrsMgr_PresentationManager3d) &/*thePresentationManager*/,
+ const Handle(Prs3d_Presentation) &thePresentation,
const Standard_Integer theMode)
{
thePresentation->Clear();
StdPrs_ShadedShape::Add(thePresentation, aFace, myDrawer);
}
-void FilledCircle::ComputeSelection(const Handle_SelectMgr_Selection &theSelection,
+void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelection,
const Standard_Integer /*theMode*/)
{
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
{
// Get arguments
TCollection_AsciiString aName(argv[1]);
- Standard_Boolean isFilled = (Standard_Boolean)Draw::Atoi(argv[5]);
+ Standard_Boolean isFilled = Draw::Atoi(argv[5]) != 0;
Handle(AIS_InteractiveObject) theShapeA;
Handle(AIS_InteractiveObject) theShapeB;
std::cout << "vcircle error: 2d element is a unexpected to be a point.\n";
return 1; // TCL_ERROR
}
- // Ñheck that the radius is >= 0
+ // Check that the radius is >= 0
if (Draw::Atof(argv[4]) <= 0 )
{
std::cout << "vcircle error: the radius must be >=0.\n";
// Recover the center
gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB));
- // Ñonstruct the circle
+ // Construct the circle
GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,theRad);
Handle (Geom_Circle) theGeomCircle;
try
return 0;
}
-
-//===============================================================================================
+//=======================================================================
//function : VDrawText
-//author : psn
-//purpose : Create a text.
-//Draw arg : vdrawtext name [X] [Y] [Z] [R] [G] [B] [hor_align] [ver_align] [angle] [zoomable]
-//===============================================================================================
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_StructureManager.hxx>
-#include <Graphic3d_VerticalTextAlignment.hxx>
-#include <Graphic3d_HorizontalTextAlignment.hxx>
-
-#include <Font_NameOfFont.hxx>
-
-#include <Visual3d_ViewManager.hxx>
-#include <ViewerTest_Tool.ixx>
-
-#include <Standard_DefineHandle.hxx>
+//purpose :
+//=======================================================================
+static int VDrawText (Draw_Interpretor& theDI,
+ Standard_Integer theArgsNb,
+ const char** theArgVec)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (theArgsNb < 3)
+ {
+ std::cout << "Error: wrong number of arguments! See usage:\n";
+ theDI.PrintHelp (theArgVec[0]);
+ return 1;
+ }
+ else if (aContext.IsNull())
+ {
+ std::cout << "Error: no active view!\n";
+ return 1;
+ }
-#include <Prs3d_Root.hxx>
-#include <Prs3d_Text.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
+ Standard_Integer anArgIt = 1;
+ TCollection_ExtendedString aName (theArgVec[anArgIt++], Standard_True);
+ TCollection_ExtendedString aText (theArgVec[anArgIt++], Standard_True);
+ Handle(AIS_TextLabel) aTextPrs;
+ ViewerTest_AutoUpdater anAutoUpdater (aContext, ViewerTest::CurrentView());
-#include <TCollection_ExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
+ Standard_Boolean isNewPrs = Standard_False;
+ if (GetMapOfAIS().IsBound2 (aName))
+ {
+ aTextPrs = Handle(AIS_TextLabel)::DownCast (GetMapOfAIS().Find2 (aName));
+ }
-#include <gp_Pnt.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <Quantity_Color.hxx>
+ if (aTextPrs.IsNull())
+ {
+ isNewPrs = Standard_True;
+ aTextPrs = new AIS_TextLabel();
+ aTextPrs->SetFont ("Courier");
+ }
+ aTextPrs->SetText (aText);
-DEFINE_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
+ Handle(Graphic3d_TransformPers) aTrsfPers;
+ Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
-class MyTextClass:public AIS_InteractiveObject
-{
-public:
- // CASCADE RTTI
- DEFINE_STANDARD_RTTI(MyTextClass );
-
- MyTextClass(){};
-
- MyTextClass
- (
- const TCollection_ExtendedString& , const gp_Pnt& ,
- Quantity_Color color,
- Standard_Integer aHJust,
- Standard_Integer aVJust ,
- Standard_Real Angle ,
- Standard_Boolean Zoom ,
- Standard_Real Height,
- Font_FontAspect FontAspect,
- Standard_CString Font
- );
+ Standard_Boolean aHasPlane = Standard_False;
+ gp_Dir aNormal;
+ gp_Dir aDirection;
+ gp_Pnt aPos;
-private:
+ for (; anArgIt < theArgsNb; ++anArgIt)
+ {
+ TCollection_AsciiString aParam (theArgVec[anArgIt]);
+ aParam.LowerCase();
- void Compute ( const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer aMode);
+ if (anAutoUpdater.parseRedrawMode (aParam))
+ {
+ continue;
+ }
+ else if (aParam == "-pos"
+ || aParam == "-position")
+ {
+ if (anArgIt + 3 >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- void ComputeSelection ( const Handle(SelectMgr_Selection)& /*aSelection*/,
- const Standard_Integer /*aMode*/){} ;
+ aPos.SetX (Draw::Atof (theArgVec[++anArgIt]));
+ aPos.SetY (Draw::Atof (theArgVec[++anArgIt]));
+ aPos.SetZ (Draw::Atof (theArgVec[++anArgIt]));
+ aTextPrs->SetPosition (aPos);
+ }
+ else if (aParam == "-color")
+ {
+ if (anArgIt + 1 >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
-protected:
- TCollection_ExtendedString aText;
- gp_Pnt aPosition;
- Standard_Real Red;
- Standard_Real Green;
- Standard_Real Blue;
- Standard_Real aAngle;
- Standard_Real aHeight;
- Standard_Boolean aZoomable;
- Quantity_Color aColor;
- TCollection_AsciiString aFont;
- Font_FontAspect aFontAspect;
- Graphic3d_HorizontalTextAlignment aHJustification;
- Graphic3d_VerticalTextAlignment aVJustification;
-};
+ TCollection_AsciiString aColor (theArgVec[anArgIt + 1]);
+ Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
+ if (Quantity_Color::ColorFromName (aColor.ToCString(), aNameOfColor))
+ {
+ anArgIt += 1;
+ aTextPrs->SetColor (aNameOfColor);
+ continue;
+ }
+ else if (anArgIt + 3 >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ TCollection_AsciiString aGreen (theArgVec[anArgIt + 2]);
+ TCollection_AsciiString aBlue (theArgVec[anArgIt + 3]);
+ if (!aColor.IsRealValue()
+ || !aGreen.IsRealValue()
+ || !aBlue.IsRealValue())
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ const Graphic3d_Vec3d anRGB (aColor.RealValue(),
+ aGreen.RealValue(),
+ aBlue.RealValue());
-IMPLEMENT_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(MyTextClass, AIS_InteractiveObject)
+ aTextPrs->SetColor (Quantity_Color (anRGB.r(), anRGB.g(), anRGB.b(), Quantity_TOC_RGB));
+ anArgIt += 3;
+ }
+ else if (aParam == "-halign")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ TCollection_AsciiString aType (theArgVec[anArgIt]);
+ aType.LowerCase();
+ if (aType == "left")
+ {
+ aTextPrs->SetHJustification (Graphic3d_HTA_LEFT);
+ }
+ else if (aType == "center")
+ {
+ aTextPrs->SetHJustification (Graphic3d_HTA_CENTER);
+ }
+ else if (aType == "right")
+ {
+ aTextPrs->SetHJustification (Graphic3d_HTA_RIGHT);
+ }
+ else
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-valign")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
-MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& position,
- Quantity_Color color = Quantity_NOC_YELLOW,
- Standard_Integer aHJust = Graphic3d_HTA_LEFT,
- Standard_Integer aVJust = Graphic3d_VTA_BOTTOM,
- Standard_Real angle = 0.0 ,
- Standard_Boolean zoomable = Standard_True,
- Standard_Real height = 12.,
- Font_FontAspect fontAspect = Font_FA_Regular,
- Standard_CString font = "Courier")
-{
- aText = text;
- aPosition = position;
- aHJustification = Graphic3d_HorizontalTextAlignment(aHJust);
- aVJustification = Graphic3d_VerticalTextAlignment(aVJust);
- aAngle = angle;
- aZoomable = zoomable;
- aHeight = height;
- aColor = color;
- aFontAspect = fontAspect;
- aFont = font;
-};
+ TCollection_AsciiString aType (theArgVec[anArgIt]);
+ aType.LowerCase();
+ if (aType == "top")
+ {
+ aTextPrs->SetVJustification (Graphic3d_VTA_TOP);
+ }
+ else if (aType == "center")
+ {
+ aTextPrs->SetVJustification (Graphic3d_VTA_CENTER);
+ }
+ else if (aType == "bottom")
+ {
+ aTextPrs->SetVJustification (Graphic3d_VTA_BOTTOM);
+ }
+ else if (aType == "topfirstline")
+ {
+ aTextPrs->SetVJustification (Graphic3d_VTA_TOPFIRSTLINE);
+ }
+ else
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-angle")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ aTextPrs->SetAngle (Draw::Atof (theArgVec[anArgIt]) * (M_PI / 180.0));
+ }
+ else if (aParam == "-zoom")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ aTextPrs->SetZoomable (Draw::Atoi (theArgVec[anArgIt]) == 1);
+ }
+ else if (aParam == "-height")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
-//////////////////////////////////////////////////////////////////////////////
-void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer /*aMode*/)
-{
+ aTextPrs->SetHeight (Draw::Atof(theArgVec[anArgIt]));
+ }
+ else if (aParam == "-aspect")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- aPresentation->Clear();
+ TCollection_AsciiString anOption (theArgVec[anArgIt]);
+ anOption.LowerCase();
+ if (anOption.IsEqual ("regular"))
+ {
+ aTextPrs->SetFontAspect (Font_FA_Regular);
+ }
+ else if (anOption.IsEqual ("bold"))
+ {
+ aTextPrs->SetFontAspect (Font_FA_Bold);
+ }
+ else if (anOption.IsEqual ("italic"))
+ {
+ aTextPrs->SetFontAspect (Font_FA_Italic);
+ }
+ else if (anOption.IsEqual ("bolditalic"))
+ {
+ aTextPrs->SetFontAspect (Font_FA_BoldItalic);
+ }
+ }
+ else if (aParam == "-font")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- Handle_Prs3d_TextAspect asp = myDrawer->TextAspect();
-
- asp->SetFont(aFont.ToCString());
- asp->SetColor(aColor);
- asp->SetHeight(aHeight); // I am changing the myHeight value
-
- asp->SetHorizontalJustification(aHJustification);
- asp->SetVerticalJustification(aVJustification);
- asp->Aspect()->SetTextZoomable(aZoomable);
- asp->Aspect()->SetTextAngle(aAngle);
- asp->Aspect()->SetTextFontAspect(aFontAspect);
- Prs3d_Text::Draw(aPresentation, asp, aText, aPosition);
-
- /* This comment code is worked
- Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
- Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
- Graphic3d_Vertex vertices_text;
- vertices_text.SetCoord(aPosition.X(),aPosition.Y(),aPosition.Y());
- TheGroup->SetPrimitivesAspect(aspect);
- TheGroup->Text(aText,vertices_text,aHeight,Standard_True);
- */
-};
+ aTextPrs->SetFont (theArgVec[anArgIt]);
+ }
+ else if (aParam == "-plane")
+ {
+ if (anArgIt + 6 >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
-static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- // Check arguments
- if (argc < 14)
- {
- di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
- di<<"Usage: type help "<<argv[0]<<"\n";
- return 1; //TCL_ERROR
- }
+ Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
+ Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
+ Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
+ aNormal.SetCoord (aX, aY, aZ);
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ aX = Draw::Atof (theArgVec[++anArgIt]);
+ aY = Draw::Atof (theArgVec[++anArgIt]);
+ aZ = Draw::Atof (theArgVec[++anArgIt]);
+ aDirection.SetCoord (aX, aY, aZ);
- // Create 3D view if it doesn't exist
- if ( aContext.IsNull() )
- {
- ViewerTest::ViewerInit();
- aContext = ViewerTest::GetAISContext();
- if( aContext.IsNull() )
+ aHasPlane = Standard_True;
+ }
+ else if (aParam == "-flipping")
{
- di << "Error: Cannot create a 3D view\n";
- return 1; //TCL_ERROR
+ aTextPrs->SetFlipping (Standard_True);
}
- }
-
- // Text position
- const Standard_Real X = Draw::Atof(argv[2]);
- const Standard_Real Y = Draw::Atof(argv[3]);
- const Standard_Real Z = Draw::Atof(argv[4]);
- const gp_Pnt pnt(X,Y,Z);
+ else if (aParam == "-disptype"
+ || aParam == "-displaytype")
+ {
+ if (++anArgIt >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ TCollection_AsciiString aType (theArgVec[anArgIt]);
+ aType.LowerCase();
+ if (aType == "subtitle")
+ aDisplayType = Aspect_TODT_SUBTITLE;
+ else if (aType == "decal")
+ aDisplayType = Aspect_TODT_DEKALE;
+ else if (aType == "blend")
+ aDisplayType = Aspect_TODT_BLEND;
+ else if (aType == "dimension")
+ aDisplayType = Aspect_TODT_DIMENSION;
+ else if (aType == "normal")
+ aDisplayType = Aspect_TODT_NORMAL;
+ else
+ {
+ std::cout << "Error: wrong display type '" << aType << "'.\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-subcolor"
+ || aParam == "-subtitlecolor")
+ {
+ if (anArgIt + 1 >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- // Text color
- const Quantity_Parameter R = Draw::Atof(argv[5])/255.;
- const Quantity_Parameter G = Draw::Atof(argv[6])/255.;
- const Quantity_Parameter B = Draw::Atof(argv[7])/255.;
- const Quantity_Color aColor( R, G, B, Quantity_TOC_RGB );
+ TCollection_AsciiString aColor (theArgVec[anArgIt + 1]);
+ Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
+ if (Quantity_Color::ColorFromName (aColor.ToCString(), aNameOfColor))
+ {
+ anArgIt += 1;
+ aTextPrs->SetColorSubTitle (aNameOfColor);
+ continue;
+ }
+ else if (anArgIt + 3 >= theArgsNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- // Text alignment
- const int hor_align = Draw::Atoi(argv[8]);
- const int ver_align = Draw::Atoi(argv[9]);
+ TCollection_AsciiString aGreen (theArgVec[anArgIt + 2]);
+ TCollection_AsciiString aBlue (theArgVec[anArgIt + 3]);
+ if (!aColor.IsRealValue()
+ || !aGreen.IsRealValue()
+ || !aBlue.IsRealValue())
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- // Text angle
- const Standard_Real angle = Draw::Atof(argv[10]);
+ const Graphic3d_Vec3d anRGB (aColor.RealValue(),
+ aGreen.RealValue(),
+ aBlue.RealValue());
- // Text zooming
- const Standard_Boolean zoom = Draw::Atoi(argv[11]);
+ aTextPrs->SetColorSubTitle (Quantity_Color (anRGB.r(), anRGB.g(), anRGB.b(), Quantity_TOC_RGB));
+ anArgIt += 3;
+ }
+ else if (aParam == "-2d")
+ {
+ aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_2d);
+ }
+ else if (aParam == "-trsfperspos"
+ || aParam == "-perspos")
+ {
+ if (anArgIt + 2 >= theArgsNb)
+ {
+ std::cerr << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
- // Text height
- const Standard_Real height = Draw::Atof(argv[12]);
+ TCollection_AsciiString aX (theArgVec[++anArgIt]);
+ TCollection_AsciiString aY (theArgVec[++anArgIt]);
+ TCollection_AsciiString aZ = "0";
+ if (!aX.IsIntegerValue()
+ || !aY.IsIntegerValue())
+ {
+ std::cerr << "Error: wrong syntax at '" << aParam << "'.\n";
+ return 1;
+ }
+ if (anArgIt + 1 < theArgsNb)
+ {
+ TCollection_AsciiString aTemp = theArgVec[anArgIt + 1];
+ if (aTemp.IsIntegerValue())
+ {
+ aZ = aTemp;
+ ++anArgIt;
+ }
+ }
- // Text aspect
- const Font_FontAspect aspect = Font_FontAspect(Draw::Atoi(argv[13]));
+ aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (Graphic3d_TMF_2d, gp_Pnt (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue()));
+ }
+ else
+ {
+ std::cout << "Error: unknown argument '" << aParam << "'\n";
+ return 1;
+ }
+ }
- // Text font
- TCollection_AsciiString font;
- if(argc < 15)
- font.AssignCat("Courier");
- else
- font.AssignCat(argv[14]);
+ if (aHasPlane)
+ {
+ aTextPrs->SetOrientation3D (gp_Ax2 (aPos, aNormal, aDirection));
+ }
- // Text is multibyte
- const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (Draw::Atoi(argv[15]) != 0);
+ aTextPrs->SetDisplayType (aDisplayType);
- // Read text string
- TCollection_ExtendedString name;
- if (isMultibyte)
+ if (!aTrsfPers.IsNull())
{
- const char *str = argv[1];
- while ( *str || *(str+1)=='\x0A' || *(str+1)=='\x0B' || *(str+1)=='\x0C' || *(str+1)=='\x0D'
- || *(str+1)=='\x07' || *(str+1)=='\x08' || *(str+1)=='\x09' )
+ aContext->SetTransformPersistence (aTextPrs, aTrsfPers);
+ aTextPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD);
+ if (aTextPrs->Position().Z() != 0)
{
- unsigned short c1 = *str++;
- unsigned short c2 = *str++;
- if (!c2) break;
- name += (Standard_ExtCharacter)((c1 << 8) | c2);
+ aTextPrs->SetPosition (gp_Pnt(aTextPrs->Position().X(), aTextPrs->Position().Y(), 0));
}
}
- else
+ else if (!aTextPrs->TransformPersistence().IsNull())
{
- name += argv[1];
+ aContext->SetTransformPersistence (aTextPrs, Handle(Graphic3d_TransformPers)());
}
- if (name.Length())
+ if (isNewPrs)
{
- Handle(MyTextClass) myT = new MyTextClass(name,pnt,aColor,hor_align,ver_align,angle,zoom,height,aspect,font.ToCString());
- aContext->Display(myT,Standard_True);
+ ViewerTest::Display (aName, aTextPrs, Standard_False);
+ }
+ else
+ {
+ aContext->Redisplay (aTextPrs, Standard_False, Standard_True);
}
-
return 0;
}
#include <TShort_HArray1OfShortReal.hxx>
#include <AIS_Triangulation.hxx>
-#include <StdPrs_ToolShadedShape.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <Poly_Connect.hxx>
#include <TColgp_Array1OfDir.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <StdSelect_ShapeTypeFilter.hxx>
+#include <AIS_InteractiveObject.hxx>
//===============================================================================================
Nor = gp_Dir(eqPlan);
else
Nor = gp_Dir(0., 0., 1.);
-
- Standard_Integer j = (i - PointsOfArray.Lower()) * 3;
- Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
- Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
- Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
+
+ Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
+ Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
+ Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
+ Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
}
delete pc;
Standard_Real aCenterY = (argc > 5) ? Draw::Atof (argv[4]) : 0.0;
Standard_Real aCenterZ = (argc > 5) ? Draw::Atof (argv[5]) : 0.0;
Standard_Real aRadius = (argc > 6) ? Draw::Atof (argv[6]) : 100.0;
- Standard_Boolean toShowEdges = (argc > 7) ? Draw::Atoi (argv[7]) : Standard_False;
+ Standard_Boolean toShowEdges = (argc > 7) ? Draw::Atoi (argv[7]) == 1 : Standard_False;
+ Standard_Boolean toPrintInfo = (argc > 8) ? Draw::Atoi (argv[8]) == 1 : Standard_True;
// remove AIS object with given name from map
VDisplayAISObject (aShapeName, Handle(AIS_InteractiveObject)());
- std::cout << "Compute Triangulation...\n";
+ if (toPrintInfo)
+ std::cout << "Compute Triangulation...\n";
Handle(AIS_Triangulation) aShape
= new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
aResolution,
// stupid initialization of Green color in RGBA space as integer
// probably wrong for big-endian CPUs
- Standard_Integer aRed = 0;
- Standard_Integer aGreen = 255;
- Standard_Integer aBlue = 0;
- Standard_Integer anAlpha = 0; // not used
- Standard_Integer aColorInt = aRed;
- aColorInt += aGreen << 8;
- aColorInt += aBlue << 16;
- aColorInt += anAlpha << 24;
+ const Graphic3d_Vec4ub aColor (0, 255, 0, 0);
// setup colors array per vertex
Handle(TColStd_HArray1OfInteger) aColorArray = new TColStd_HArray1OfInteger (1, aNumberPoints);
for (Standard_Integer aNodeId = 1; aNodeId <= aNumberPoints; ++aNodeId)
{
- aColorArray->SetValue (aNodeId, aColorInt);
+ aColorArray->SetValue (aNodeId, *reinterpret_cast<const Standard_Integer*> (&aColor));
}
aShape->SetColors (aColorArray);
aColorsSize >>= 20;
aTrianglesSize >>= 20;
aPolyConnectSize >>= 20;
- std::cout << "NumberOfPoints: " << aNumberPoints << "\n"
- << "NumberOfTriangles: " << aNumberTriangles << "\n"
- << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
- << "Amount of memory for colors: " << aColorsSize << " Mb\n"
- << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
- << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
+ if (toPrintInfo)
+ {
+ std::cout << "NumberOfPoints: " << aNumberPoints << "\n"
+ << "NumberOfTriangles: " << aNumberTriangles << "\n"
+ << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
+ << "Amount of memory for colors: " << aColorsSize << " Mb\n"
+ << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
+ << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
+ }
// Setting material properties, very important for desirable visual result!
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
if ( argc != 3 && argc != 12 )
{
di << "Usage: " << argv[0] << " ShapeName HlrName "
- << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]" << "\n"
+ << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]\n"
<< " ShapeName - name of the initial shape\n"
<< " HlrName - result hlr object from initial shape\n"
<< " eye, dir are eye position and look direction\n"
// This class is a wrap for Graphic3d_ArrayOfPrimitives; it is used for
// manipulating and displaying such an array with AIS context
-DEFINE_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
+
class MyPArrayObject : public AIS_InteractiveObject
{
myMarkerAspect = theMarkerAspect;
}
- DEFINE_STANDARD_RTTI(MyPArrayObject);
+ DEFINE_STANDARD_RTTI_INLINE(MyPArrayObject,AIS_InteractiveObject);
private:
void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer aMode);
+ const Standard_Integer aMode) Standard_OVERRIDE;
void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer /*theMode*/);
+ const Standard_Integer /*theMode*/) Standard_OVERRIDE;
bool CheckInputCommand (const TCollection_AsciiString theCommand,
const Handle(TColStd_HArray1OfAsciiString) theArgsArray,
};
-IMPLEMENT_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(MyPArrayObject, AIS_InteractiveObject)
void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
// Parsing array description
Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
- Standard_Boolean hasVColors, hasBColors, hasNormals, hasInfos, hasTexels;
- hasVColors = hasNormals = hasBColors = hasInfos = hasTexels = Standard_False;
+ Standard_Boolean hasVColors, hasBColors, hasNormals, hasTexels;
+ hasVColors = hasNormals = hasBColors = hasTexels = Standard_False;
Standard_Integer anArgIndex = 0;
Standard_Integer anArgsCount = myArrayDescription->Length();
// edge command
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
{
- // edge has a hide flag
- if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
- hasInfos = Standard_True;
-
aEdgeNum++;
}
// unknown command
anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
else if (anArrayType == "polylines")
anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
- hasVColors, hasBColors, hasInfos);
+ hasVColors, hasBColors);
else if (anArrayType == "triangles")
anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
- hasVColors, hasTexels, hasInfos);
+ hasVColors, hasTexels);
else if (anArrayType == "trianglefans")
anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
hasNormals, hasVColors,
else if (anArrayType == "quads")
anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
hasNormals, hasVColors,
- hasTexels, hasInfos);
+ hasTexels);
else if (anArrayType == "quadstrips")
anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
hasNormals, hasVColors,
else if (anArrayType == "polygons")
anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
hasNormals, hasVColors, hasBColors,
- hasTexels, hasInfos);
+ hasTexels);
anArgIndex = 1;
while (anArgIndex < anArgsCount)
anArray->AddVertex (myArrayDescription->Value (anArgIndex - 3).RealValue(),
myArrayDescription->Value (anArgIndex - 2).RealValue(),
myArrayDescription->Value (anArgIndex - 1).RealValue());
+ const Standard_Integer aVertIndex = anArray->VertexNumber();
// vertex has a normal or normal with color or texel
if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
- anArray->SetVertexNormal (anArray->VertexNumber (),
+ anArray->SetVertexNormal (aVertIndex,
myArrayDescription->Value (anArgIndex - 3).RealValue(),
myArrayDescription->Value (anArgIndex - 2).RealValue(),
myArrayDescription->Value (anArgIndex - 1).RealValue());
if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
- anArray->SetVertexColor (anArray->VertexNumber (),
+ anArray->SetVertexColor (aVertIndex,
myArrayDescription->Value (anArgIndex - 3).RealValue(),
myArrayDescription->Value (anArgIndex - 2).RealValue(),
myArrayDescription->Value (anArgIndex - 1).RealValue());
if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
- anArray->SetVertexTexel (anArray->VertexNumber (),
+ anArray->SetVertexTexel (aVertIndex,
myArrayDescription->Value (anArgIndex - 2).RealValue(),
myArrayDescription->Value (anArgIndex - 1).RealValue());
}
// edge command
else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
{
- Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
-
- // edge has/hasn't hide flag
- if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
- anArray->AddEdge (aVertIndex, Standard_False);
- else
- anArray->AddEdge (aVertIndex, Standard_True);
+ const Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
+ anArray->AddEdge (aVertIndex);
}
// unknown command
else
{
Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myMarkerAspect);
}
+ Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
+ Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (anArray);
}
<< " vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]"
<< " [texel={ 't' tx ty }] } \n"
<< " bounds={ 'b' verticies_count [color={ 'c' r g b }] }\n"
- << " edges={ 'e' vertex_id [hidden_edge={'h'}] }\n";
+ << " edges={ 'e' vertex_id }\n";
return 1;
}
return 0;
}
-//=======================================================================
-//function : VSetLocation
-//purpose : Change location of AIS interactive object
-//=======================================================================
-
-static Standard_Integer VSetLocation (Draw_Interpretor& di,
- Standard_Integer argc,
- const char ** argv)
+namespace
{
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if (aContext.IsNull())
+ //! Auxiliary function for parsing translation vector - either 2D or 3D.
+ static Standard_Integer parseTranslationVec (Standard_Integer theArgNb,
+ const char** theArgVec,
+ gp_Vec& theVec)
{
- di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
- return 1;
- }
+ if (theArgNb < 2)
+ {
+ return 0;
+ }
- if (argc != 5)
- {
- di << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n";
- return 1;
+ TCollection_AsciiString anX (theArgVec[0]);
+ TCollection_AsciiString anY (theArgVec[1]);
+ if (!anX.IsRealValue()
+ || !anY.IsRealValue())
+ {
+ return 0;
+ }
+
+ theVec.SetX (anX.RealValue());
+ theVec.SetY (anY.RealValue());
+ if (theArgNb >= 3)
+ {
+ TCollection_AsciiString anZ (theArgVec[2]);
+ if (anZ.IsRealValue())
+ {
+ theVec.SetZ (anZ.RealValue());
+ return 3;
+ }
+ }
+ return 2;
}
+}
- TCollection_AsciiString aName (argv[1]);
- Standard_Real aX = Draw::Atof (argv[2]);
- Standard_Real aY = Draw::Atof (argv[3]);
- Standard_Real aZ = Draw::Atof (argv[4]);
+//=======================================================================
+//function : VSetLocation
+//purpose : Change location of AIS interactive object
+//=======================================================================
- // find object
- ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
- Handle(AIS_InteractiveObject) anIObj;
- if (!aMap.IsBound2 (aName))
+static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
+ if (aContext.IsNull())
{
- di << "Use 'vdisplay' before" << "\n";
+ std::cout << "Error: no active view!\n";
return 1;
}
- else
+
+ Standard_Boolean toPrintInfo = Standard_True;
+ Handle(AIS_InteractiveObject) anObj;
+ TCollection_AsciiString aCmdName (theArgVec[0]);
+ aCmdName.LowerCase();
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
- anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
+ TCollection_AsciiString anArg = theArgVec[anArgIter];
+ anArg.LowerCase();
+ if (anUpdateTool.parseRedrawMode (anArg))
+ {
+ continue;
+ }
+ else if (anObj.IsNull())
+ {
+ const TCollection_AsciiString aName (theArgVec[anArgIter]);
+ const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ if (aMap.IsBound2 (aName))
+ {
+ anObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
+ }
+ if (anObj.IsNull())
+ {
+ std::cout << "Error: object '" << aName << "' is not displayed!\n";
+ return 1;
+ }
+ }
+ else if (anArg == "-reset")
+ {
+ toPrintInfo = Standard_False;
+ aContext->SetLocation (anObj, gp_Trsf());
+ }
+ else if (anArg == "-copyfrom"
+ || anArg == "-copy")
+ {
+ if (anArgIter + 1 >= theArgNb)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
- // not an AIS_InteractiveObject
- if (anIObj.IsNull())
+ const TCollection_AsciiString aName2 (theArgVec[anArgIter + 1]);
+ const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ Handle(AIS_InteractiveObject) anObj2;
+ if (aMap.IsBound2 (aName2))
+ {
+ anObj2 = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName2));
+ }
+ if (anObj2.IsNull())
+ {
+ std::cout << "Error: object '" << aName2 << "' is not displayed!\n";
+ return 1;
+ }
+
+ ++anArgIter;
+ aContext->SetLocation (anObj, anObj2->LocalTransformation());
+ }
+ else if (anArg == "-rotate")
+ {
+ toPrintInfo = Standard_False;
+ if (anArgIter + 7 >= theArgNb)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ gp_Trsf aTrsf;
+ aTrsf.SetRotation (gp_Ax1 (gp_Pnt (Draw::Atof (theArgVec[anArgIter + 1]),
+ Draw::Atof (theArgVec[anArgIter + 2]),
+ Draw::Atof (theArgVec[anArgIter + 3])),
+ gp_Vec (Draw::Atof (theArgVec[anArgIter + 4]),
+ Draw::Atof (theArgVec[anArgIter + 5]),
+ Draw::Atof (theArgVec[anArgIter + 6]))),
+ Draw::Atof (theArgVec[anArgIter + 7]) * (M_PI / 180.0));
+ anArgIter += 7;
+
+ aTrsf = anObj->LocalTransformation() * aTrsf;
+ aContext->SetLocation (anObj, aTrsf);
+ }
+ else if (anArg == "-translate")
+ {
+ toPrintInfo = Standard_False;
+ gp_Vec aLocVec;
+ Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter - 1, theArgVec + anArgIter + 1, aLocVec);
+ anArgIter += aNbParsed;
+ if (aNbParsed == 0)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslationPart (aLocVec);
+ aTrsf = anObj->LocalTransformation() * aTrsf;
+ aContext->SetLocation (anObj, aTrsf);
+ }
+ else if (anArg == "-scale"
+ || anArg == "-setscale")
+ {
+ toPrintInfo = Standard_False;
+ gp_XYZ aScaleLoc;
+ Standard_Real aScale = 1.0;
+ Standard_Boolean toPrintScale = Standard_True;
+ Standard_Boolean hasScaleLoc = Standard_False;
+ if (anArgIter + 4 < theArgNb)
+ {
+ TCollection_AsciiString aScaleArgs[4] =
+ {
+ TCollection_AsciiString (theArgVec[anArgIter + 1]),
+ TCollection_AsciiString (theArgVec[anArgIter + 2]),
+ TCollection_AsciiString (theArgVec[anArgIter + 3]),
+ TCollection_AsciiString (theArgVec[anArgIter + 4])
+ };
+ Standard_Integer aScaleArgIter = 0;
+ for (; aScaleArgIter < 4; ++aScaleArgIter)
+ {
+ if (!aScaleArgs[aScaleArgIter].IsRealValue())
+ {
+ break;
+ }
+ }
+ if (aScaleArgIter == 4)
+ {
+ aScaleLoc.SetCoord (aScaleArgs[0].RealValue(), aScaleArgs[1].RealValue(), aScaleArgs[2].RealValue());
+ aScale = aScaleArgs[3].RealValue();
+ anArgIter += 4;
+ toPrintScale = Standard_False;
+ hasScaleLoc = Standard_True;
+ }
+ else if (aScaleArgIter >= 1)
+ {
+ aScale = aScaleArgs[0].RealValue();
+ ++anArgIter;
+ toPrintScale = Standard_False;
+ }
+ }
+ else if (anArgIter + 1 < theArgNb)
+ {
+ TCollection_AsciiString aScaleArg (theArgVec[anArgIter + 1]);
+ if (aScaleArg.IsRealValue())
+ {
+ aScale = aScaleArg.RealValue();
+ ++anArgIter;
+ toPrintScale = Standard_False;
+ }
+ }
+
+ if (toPrintScale)
+ {
+ if (anArg == "-setscale")
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ char aText[1024];
+ Sprintf (aText, "%g ", anObj->LocalTransformation().ScaleFactor());
+ theDI << aText;
+ continue;
+ }
+
+ if (anArg == "-setscale")
+ {
+ gp_Trsf aTrsf = anObj->LocalTransformation();
+ if (hasScaleLoc)
+ {
+ aTrsf.SetScale (aScaleLoc, aScale);
+ }
+ else
+ {
+ aTrsf.SetScaleFactor (aScale);
+ }
+ aContext->SetLocation (anObj, aTrsf);
+ }
+ else
+ {
+ gp_Trsf aTrsf;
+ if (hasScaleLoc)
+ {
+ aTrsf.SetScale (aScaleLoc, aScale);
+ aTrsf = anObj->LocalTransformation() * aTrsf;
+ }
+ else
+ {
+ aTrsf = anObj->LocalTransformation();
+ aTrsf.SetScaleFactor (aTrsf.ScaleFactor() * aScale);
+ }
+ aContext->SetLocation (anObj, aTrsf);
+ }
+ }
+ else if (anArg == "-mirror")
+ {
+ toPrintInfo = Standard_False;
+ if (anArgIter + 6 >= theArgNb)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ gp_Trsf aTrsf;
+ aTrsf.SetMirror (gp_Ax2 (gp_Pnt (Draw::Atof(theArgVec[theArgNb - 6]),
+ Draw::Atof(theArgVec[theArgNb - 5]),
+ Draw::Atof(theArgVec[theArgNb - 4])),
+ gp_Vec (Draw::Atof(theArgVec[theArgNb - 3]),
+ Draw::Atof(theArgVec[theArgNb - 2]),
+ Draw::Atof(theArgVec[theArgNb - 1]))));
+ anArgIter += 6;
+ aTrsf = anObj->LocalTransformation() * aTrsf;
+ aContext->SetLocation (anObj, aTrsf);
+ }
+ else if (anArg == "-setrotation"
+ || anArg == "-rotation")
+ {
+ toPrintInfo = Standard_False;
+ if (anArgIter + 4 < theArgNb)
+ {
+ TCollection_AsciiString aQuatArgs[4] =
+ {
+ TCollection_AsciiString (theArgVec[anArgIter + 1]),
+ TCollection_AsciiString (theArgVec[anArgIter + 2]),
+ TCollection_AsciiString (theArgVec[anArgIter + 3]),
+ TCollection_AsciiString (theArgVec[anArgIter + 4])
+ };
+ Standard_Integer aQuatArgIter = 0;
+ for (; aQuatArgIter < 4; ++aQuatArgIter)
+ {
+ if (!aQuatArgs[aQuatArgIter].IsRealValue())
+ {
+ break;
+ }
+ }
+
+ if (aQuatArgIter == 4)
+ {
+ anArgIter += 4;
+ const gp_Quaternion aQuat (aQuatArgs[0].RealValue(),
+ aQuatArgs[1].RealValue(),
+ aQuatArgs[2].RealValue(),
+ aQuatArgs[3].RealValue());
+ gp_Trsf aTrsf = anObj->LocalTransformation();
+ aTrsf.SetRotation (aQuat);
+ aContext->SetLocation (anObj, aTrsf);
+ continue;
+ }
+ else if (anArg == "-setrotation")
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+ }
+
+ char aText[1024];
+ const gp_Quaternion aQuat = anObj->LocalTransformation().GetRotation();
+ Sprintf (aText, "%g %g %g %g ", aQuat.X(), aQuat.Y(), aQuat.Z(), aQuat.W());
+ theDI << aText;
+ }
+ else if (anArg == "-setlocation"
+ || anArg == "-location")
+ {
+ toPrintInfo = Standard_False;
+ gp_Vec aLocVec;
+ Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter - 1, theArgVec + anArgIter + 1, aLocVec);
+ anArgIter += aNbParsed;
+ if (aNbParsed != 0)
+ {
+ gp_Trsf aTrsf = anObj->LocalTransformation();
+ aTrsf.SetTranslationPart (aLocVec);
+ aContext->SetLocation (anObj, aTrsf);
+ }
+ else if (anArg == "-setlocation")
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+
+ char aText[1024];
+ const gp_XYZ aLoc = anObj->LocalTransformation().TranslationPart();
+ Sprintf (aText, "%g %g %g ", aLoc.X(), aLoc.Y(), aLoc.Z());
+ theDI << aText;
+ }
+ else if (aCmdName == "vsetlocation")
{
- di << argv[1] << " : Not an AIS interactive object" << "\n";
+ // compatibility with old syntax
+ gp_Vec aLocVec;
+ Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter, theArgVec + anArgIter, aLocVec);
+ if (aNbParsed == 0)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+ anArgIter = anArgIter + aNbParsed - 1;
+
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslationPart (aLocVec);
+ aContext->SetLocation (anObj, aTrsf);
+ toPrintInfo = Standard_False;
+ }
+ else
+ {
+ std::cout << "Error: unknown argument '" << anArg << "'\n";
return 1;
}
+ }
- gp_Trsf aTrsf;
- aTrsf.SetTranslation (gp_Vec (aX, aY, aZ));
- TopLoc_Location aLocation (aTrsf);
- aContext->SetLocation (anIObj, aLocation);
- aContext->UpdateCurrentViewer();
+ if (anObj.IsNull())
+ {
+ std::cout << "Syntax error - wrong number of arguments\n";
+ return 1;
+ }
+ else if (!toPrintInfo)
+ {
+ return 0;
}
+ const gp_Trsf aTrsf = anObj->LocalTransformation();
+ const gp_XYZ aLoc = aTrsf.TranslationPart();
+ const gp_Quaternion aRot = aTrsf.GetRotation();
+ char aText[4096];
+ Sprintf (aText, "Location: %g %g %g\n"
+ "Rotation: %g %g %g %g\n"
+ "Scale: %g\n",
+ aLoc.X(), aLoc.Y(), aLoc.Z(),
+ aRot.X(), aRot.Y(), aRot.Z(), aRot.W(),
+ aTrsf.ScaleFactor());
+ theDI << aText;
return 0;
}
//===============================================================================================
//function : VConnect
//purpose : Creates and displays AIS_ConnectedInteractive object from input object and location
-//Draw arg : vconnect name Xo Yo Zo Xu Xv Xw Zu Zv Zw object1 object2 ... [color=NAME]
+//Draw arg : vconnect name Xo Yo Zo object1 object2 ... [color=NAME]
//===============================================================================================
-static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
- Standard_Integer argc,
- const char ** argv)
+static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
+ Standard_Integer argc,
+ const char ** argv)
{
// Check the viewer
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
return 1; // TCL_ERROR
}
// Check argumnets
- if (argc < 12)
+ if (argc < 6)
{
- std::cout << "vconnect error: expect at least 11 arguments\n";
+ std::cout << "vconnect error: expect at least 5 arguments\n";
return 1; // TCL_ERROR
}
// Get values
Standard_Integer anArgIter = 1;
TCollection_AsciiString aName (argv[anArgIter++]);
- Handle(AIS_InteractiveObject) anOriginObject;
+ Handle(AIS_MultipleConnectedInteractive) anOriginObject;
TCollection_AsciiString aColorString (argv[argc-1]);
Standard_CString aColorName = "";
Standard_Boolean hasColor = Standard_False;
}
Handle(AIS_InteractiveObject) anObject;
- // AIS_ConnectedInteractive
- if (argc == 12 || (argc == 13 && hasColor))
+ // AIS_MultipleConnectedInteractive
+ const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
+ for (Standard_Integer i = 5; i < aNbShapes; ++i)
{
- TCollection_AsciiString anOriginObjectName(argv[11]);
+ TCollection_AsciiString anOriginObjectName (argv[i]);
if (aName.IsEqual (anOriginObjectName))
{
- std::cout << "vconnect error: equal names for connected objects\n";
- return 1; // TCL_ERROR
+ std::cout << "vconnect error: equal names for connected objects\n";
+ continue;
}
if (GetMapOfAIS().IsBound2 (anOriginObjectName))
{
Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
- anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
- if (anOriginObject.IsNull())
+ anObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
+ if (anObject.IsNull())
{
std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
- return 1; // TCL_ERROR
+ continue;
}
}
else
{
- Standard_CString aName = anOriginObjectName.ToCString();
- TopoDS_Shape aTDShape = DBRep::Get (aName);
+ Standard_CString aOriginName = anOriginObjectName.ToCString();
+ TopoDS_Shape aTDShape = DBRep::Get (aOriginName);
if (aTDShape.IsNull())
{
std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
- return 1; // TCL_ERROR
- }
- anOriginObject = new AIS_Shape (aTDShape);
- if (hasColor)
- {
- anOriginObject->SetColor (ViewerTest::GetColorFromName (aColorName));
- }
- }
- }
- // AIS_MultipleConnectedInteractive
- else
- {
- const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
- for (Standard_Integer i = 11; i < aNbShapes; ++i)
- {
- TCollection_AsciiString anOriginObjectName (argv[i]);
- if (aName.IsEqual (anOriginObjectName))
- {
- std::cout << "vconnect error: equal names for connected objects\n";
continue;
}
- if (GetMapOfAIS().IsBound2 (anOriginObjectName))
- {
- Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
- anObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
- if (anObject.IsNull())
- {
- std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
- continue;
- }
- }
- else
- {
- Standard_CString aName = anOriginObjectName.ToCString();
- TopoDS_Shape aTDShape = DBRep::Get (aName);
- if (aTDShape.IsNull())
- {
- std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
- continue;
- }
- anObject = new AIS_Shape (aTDShape);
- anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
- }
- if (anOriginObject.IsNull())
- {
- anOriginObject = new AIS_MultipleConnectedInteractive();
- Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject)->Connect (anObject);
- }
- else
- {
- Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject)->Connect (anObject);
- }
+ anObject = new AIS_Shape (aTDShape);
+ aContext->Load (anObject);
+ anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
}
+
if (anOriginObject.IsNull())
{
- std::cout << "vconect error : can't connect input objects\n";
- return 1; // TCL_ERROR
+ anOriginObject = new AIS_MultipleConnectedInteractive();
}
+
+ anOriginObject->Connect (anObject);
+ }
+ if (anOriginObject.IsNull())
+ {
+ std::cout << "vconect error : can't connect input objects\n";
+ return 1; // TCL_ERROR
}
// Get location data
Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
- Standard_Real aXu = Draw::Atof (argv[anArgIter++]);
- Standard_Real aXv = Draw::Atof (argv[anArgIter++]);
- Standard_Real aXw = Draw::Atof (argv[anArgIter++]);
- Standard_Real aZu = Draw::Atof (argv[anArgIter++]);
- Standard_Real aZv = Draw::Atof (argv[anArgIter++]);
- Standard_Real aZw = Draw::Atof (argv[anArgIter++]);
// Create transformation
- gp_Pnt aPoint(aXo, aYo, aZo);
- gp_Dir anXDir(aXu, aXv, aXw), aZDir(aZu, aZv, aZw);
- if(!anXDir.IsNormal(aZDir, Precision::Angular()))
- {
- std::cout << "vconnect error : XDir expects to be normal to ZDir\n";
- return 1; // TCL_ERROR
- }
- gp_Ax3 anAx3(aPoint, aZDir, anXDir);
+ gp_Vec aTranslation (aXo, aYo, aZo);
+
gp_Trsf aTrsf;
- aTrsf.SetTransformation(anAx3);
- TopLoc_Location aLocation(aTrsf);
+ aTrsf.SetTranslationPart (aTranslation);
+ TopLoc_Location aLocation (aTrsf);
- // Create connected object
- Handle(AIS_ConnectedInteractive) aConnected = new AIS_ConnectedInteractive();
- Handle(AIS_MultipleConnectedInteractive) anOrigin = Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject);
- if (anOrigin.IsNull())
- {
- aConnected->Connect (anOriginObject, aLocation);
- }
- else
- {
- aConnected->Connect (anOrigin, aLocation);
- }
+ anOriginObject->SetLocalTransformation (aTrsf);
// Check if there is another object with given name
// and remove it from context
}
// Bind connected object to its name
- GetMapOfAIS().Bind (aConnected, aName);
+ GetMapOfAIS().Bind (anOriginObject, aName);
// Display connected object
- TheAISContext()->Display (aConnected);
+ TheAISContext()->Display (anOriginObject);
return 0;
}
//===============================================================================================
-//function : VConnectShape
-//purpose : Creates and displays AIS_ConnectedShape from input shape and location
-//Draw arg : vconnectsh name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME]
+//function : VConnectTo
+//purpose : Creates and displays AIS_ConnectedInteractive object from input object and location
+//Draw arg : vconnectto name Xo Yo Zo object [-nodisplay|-noupdate|-update]
//===============================================================================================
-static Standard_Integer VConnectShape(Draw_Interpretor& /*di*/,
- Standard_Integer argc,
- const char ** argv)
+static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/,
+ Standard_Integer argc,
+ const char ** argv)
{
// Check the viewer
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
if (aContext.IsNull())
{
- std::cout << "vconnectsh error : call vinit before\n";
+ std::cout << "vconnect error : call vinit before\n";
return 1; // TCL_ERROR
}
- // Check argumnets
- if (argc < 12)
+ // Check argumnets
+ if (argc != 6 && argc != 7)
{
- std::cout << "vconnectsh error: expect at least 11 arguments\n";
+ std::cout << "vconnect error: expect at least 5 arguments\n";
return 1; // TCL_ERROR
}
// Get values
Standard_Integer anArgIter = 1;
TCollection_AsciiString aName (argv[anArgIter++]);
- Handle(AIS_InteractiveObject) anOriginShape;
- TCollection_AsciiString aColorString(argv[argc-1]);
- Standard_CString aColorName = "";
- Standard_Boolean hasColor = Standard_False;
- if (aColorString.Search ("color=") != -1)
+ Handle(AIS_InteractiveObject) anOriginObject;
+
+ TCollection_AsciiString anOriginObjectName(argv[5]);
+ if (aName.IsEqual (anOriginObjectName))
{
- hasColor = Standard_True;
- aColorString.Remove (1, 6);
- aColorName = aColorString.ToCString();
+ std::cout << "vconnect error: equal names for connected objects\n";
+ return 1; // TCL_ERROR
}
- Handle(AIS_Shape) aShape;
-
- // AIS_ConnectedShape
- if (argc == 12 || (argc == 13 && hasColor))
+ if (GetMapOfAIS().IsBound2 (anOriginObjectName))
{
- TCollection_AsciiString anOriginShapeName (argv[11]);
- if (aName.IsEqual (anOriginShapeName))
+ Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
+ anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
+ if (anOriginObject.IsNull())
{
- std::cout << "vconnectsh error: equal names for connected shapes\n";
+ std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
return 1; // TCL_ERROR
}
- if (GetMapOfAIS().IsBound2 (anOriginShapeName))
- {
- Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginShapeName);
- anOriginShape = Handle(AIS_Shape)::DownCast(anObj);
- if (anOriginShape.IsNull())
- {
- std::cout << "Shape " << anOriginShapeName << " is used for non AIS viewer\n!";
- return 1; // TCL_ERROR
- }
- }
- else
- {
- Standard_CString aName = anOriginShapeName.ToCString();
- TopoDS_Shape aTDShape = DBRep::Get (aName);
- if (aTDShape.IsNull())
- {
- std::cout << "vconnectsh error: object " << anOriginShapeName << " doesn't exist\n";
- return 1; // TCL_ERROR
- }
- anOriginShape = new AIS_Shape (aTDShape);
- if (hasColor)
- {
- anOriginShape->SetColor (ViewerTest::GetColorFromName (aColorName));
- }
- }
}
- // AIS_MultipleConnectedShape
else
{
- const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
- for (Standard_Integer i = 11; i < aNbShapes; ++i)
- {
- TCollection_AsciiString anOriginShapeName (argv[i]);
- if (aName.IsEqual (anOriginShapeName))
- {
- std::cout << "vconnectsh error: equal names for connected shapes\n";
- continue;
- }
- if (GetMapOfAIS().IsBound2 (anOriginShapeName))
- {
- Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginShapeName);
- aShape = Handle(AIS_Shape)::DownCast(anObj);
- if (aShape.IsNull())
- {
- std::cout << "Shape " << anOriginShapeName << " is used for non AIS viewer\n";
- continue;
- }
- }
- else
- {
- Standard_CString aName = anOriginShapeName.ToCString();
- TopoDS_Shape aTDShape = DBRep::Get (aName);
- if (aTDShape.IsNull())
- {
- std::cout << "vconnectsh error: object " << anOriginShapeName << " doesn't exist\n";
- continue;
- }
- aShape = new AIS_Shape (aTDShape);
- if (hasColor)
- {
- aShape->SetColor (ViewerTest::GetColorFromName (aColorName));
- }
- }
- if (anOriginShape.IsNull())
- {
- anOriginShape = new AIS_MultipleConnectedShape (aShape->Shape());
- Handle(AIS_MultipleConnectedShape)::DownCast(anOriginShape)->Connect (aShape);
- }
- else
- {
- Handle(AIS_MultipleConnectedShape)::DownCast(anOriginShape)->Connect (aShape);
- }
- }
- if (anOriginShape.IsNull())
+ Standard_CString aOriginName = anOriginObjectName.ToCString();
+ TopoDS_Shape aTDShape = DBRep::Get (aOriginName);
+ if (aTDShape.IsNull())
{
- std::cout << "vconectsh error : can't connect input objects\n";
+ std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
return 1; // TCL_ERROR
}
+ anOriginObject = new AIS_Shape (aTDShape);
+ GetMapOfAIS().Bind (anOriginObject, anOriginObjectName);
}
-
- // Get location data
+
+ // Get location data
Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
- Standard_Real aXu = Draw::Atof (argv[anArgIter++]);
- Standard_Real aXv = Draw::Atof (argv[anArgIter++]);
- Standard_Real aXw = Draw::Atof (argv[anArgIter++]);
- Standard_Real aZu = Draw::Atof (argv[anArgIter++]);
- Standard_Real aZv = Draw::Atof (argv[anArgIter++]);
- Standard_Real aZw = Draw::Atof (argv[anArgIter++]);
// Create transformation
- gp_Pnt aPoint(aXo, aYo, aZo);
- gp_Dir anXDir(aXu, aXv, aXw), aZDir(aZu, aZv, aZw);
- if(!anXDir.IsNormal(aZDir, Precision::Angular()))
- {
- std::cout << "vconnectsh error : XDir expects to be normal to ZDir\n";
- return 1; // TCL_ERROR
- }
- gp_Ax3 anAx3(aPoint, aZDir, anXDir);
- gp_Trsf aTrsf;
- aTrsf.SetTransformation(anAx3);
- TopLoc_Location aLocation(aTrsf);
+ gp_Vec aTranslation (aXo, aYo, aZo);
- // Create connected shape
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslationPart (aTranslation);
+
Handle(AIS_ConnectedInteractive) aConnected;
- Handle(AIS_Shape) anOrigin = Handle(AIS_Shape)::DownCast(anOriginShape);
- if (!anOrigin.IsNull())
- {
- aConnected = new AIS_ConnectedShape (anOrigin);
- aConnected->Connect (anOrigin, aLocation);
- }
- else
- {
- aConnected = new AIS_ConnectedInteractive();
- aConnected->Connect (anOriginShape, aLocation);
- }
+
+ aConnected = new AIS_ConnectedInteractive();
+
+ aConnected->Connect (anOriginObject, aTrsf);
// Check if there is another object with given name
// and remove it from context
GetMapOfAIS().UnBind2(aName);
}
- // Bind connected shape to its name
+ // Bind connected object to its name
GetMapOfAIS().Bind (aConnected, aName);
- // Display connected shape
- TheAISContext()->Display (aConnected);
+ if (argc == 7)
+ {
+ TCollection_AsciiString anArg = argv[6];
+ anArg.LowerCase();
+ if (anArg == "-nodisplay")
+ return 0;
+
+ if (!anUpdateTool.parseRedrawMode (anArg))
+ {
+ std::cout << "Warning! Unknown argument '" << anArg << "' passed, -nodisplay|-noupdate|-update expected at this point.\n";
+ }
+ }
+
+ // Display connected object
+ TheAISContext()->Display (aConnected, Standard_False);
+
+ return 0;
+}
+
+//=======================================================================
+//function : VDisconnect
+//purpose :
+//=======================================================================
+static Standard_Integer VDisconnect (Draw_Interpretor& di,
+ Standard_Integer argc,
+ const char ** argv)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ std::cout << argv[0] << "ERROR : use 'vinit' command before \n";
+ return 1;
+ }
+
+ if (argc != 3)
+ {
+ std::cout << "ERROR : Usage : " << argv[0] << " name object\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aName (argv[1]);
+ TCollection_AsciiString anObject (argv[2]);
+ Standard_Integer anObjectNumber = Draw::Atoi (argv[2]);
+
+ // find objects
+ ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ Handle(AIS_MultipleConnectedInteractive) anAssembly;
+ if (!aMap.IsBound2 (aName) )
+ {
+ std::cout << "Use 'vdisplay' before\n";
+ return 1;
+ }
+
+ anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+ if (anAssembly.IsNull())
+ {
+ di << "Not an assembly\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveObject) anIObj;
+ if (!aMap.IsBound2 (anObject))
+ {
+ // try to interpret second argument as child number
+ if (anObjectNumber > 0 && anObjectNumber <= anAssembly->Children().Size())
+ {
+ Standard_Integer aCounter = 1;
+ for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
+ {
+ if (aCounter == anObjectNumber)
+ {
+ anIObj = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
+ break;
+ }
+ ++aCounter;
+ }
+ }
+ else
+ {
+ std::cout << "Use 'vdisplay' before\n";
+ return 1;
+ }
+ }
+
+ // if object was found by name
+ if (anIObj.IsNull())
+ {
+ anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
+ }
+
+ aContext->Disconnect (anAssembly, anIObj);
+ aContext->UpdateCurrentViewer();
+
+ return 0;
+}
+
+//=======================================================================
+//function : VAddConnected
+//purpose :
+//=======================================================================
+static Standard_Integer VAddConnected (Draw_Interpretor& di,
+ Standard_Integer argc,
+ const char ** argv)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ std::cout << argv[0] << "error : use 'vinit' command before \n";
+ return 1;
+ }
+
+ if (argc != 6)
+ {
+ std::cout << argv[0] << " error: expect 5 arguments\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aName (argv[1]);
+ TCollection_AsciiString anObject (argv[5]);
+ Standard_Real aX = Draw::Atof (argv[2]);
+ Standard_Real aY = Draw::Atof (argv[3]);
+ Standard_Real aZ = Draw::Atof (argv[4]);
+
+ // find object
+ ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ Handle(AIS_MultipleConnectedInteractive) anAssembly;
+ if (!aMap.IsBound2 (aName) )
+ {
+ std::cout << "Use 'vdisplay' before\n";
+ return 1;
+ }
+
+ anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+ if (anAssembly.IsNull())
+ {
+ di << "Not an assembly\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveObject) anIObj;
+ if (!aMap.IsBound2 (anObject))
+ {
+ std::cout << "Use 'vdisplay' before\n";
+ return 1;
+ }
+
+ anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
+
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation (gp_Vec (aX, aY, aZ));
+
+ anAssembly->Connect (anIObj, aTrsf);
+ TheAISContext()->Display (anAssembly);
+ TheAISContext()->RecomputeSelectionOnly (anAssembly);
+ aContext->UpdateCurrentViewer();
+
+ return 0;
+}
+
+//=======================================================================
+//function : VListConnected
+//purpose :
+//=======================================================================
+static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
+ Standard_Integer argc,
+ const char ** argv)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ std::cout << argv[0] << "ERROR : use 'vinit' command before \n";
+ return 1;
+ }
+
+ if (argc != 2)
+ {
+ std::cout << "ERROR : Usage : " << argv[0] << " name\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aName (argv[1]);
+
+ // find object
+ ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ Handle(AIS_MultipleConnectedInteractive) anAssembly;
+ if (!aMap.IsBound2 (aName) )
+ {
+ std::cout << "Use 'vdisplay' before\n";
+ return 1;
+ }
+
+ anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+ if (anAssembly.IsNull())
+ {
+ std::cout << "Not an assembly\n";
+ return 1;
+ }
+
+ std::cout << "Children of " << aName << ":\n";
+
+ Standard_Integer aCounter = 1;
+ for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
+ {
+ if (GetMapOfAIS().IsBound1 (anIter.Value()))
+ {
+ TCollection_AsciiString aCuurrentName = GetMapOfAIS().Find1 (anIter.Value());
+ std::cout << aCounter << ") " << aCuurrentName << " (" << anIter.Value()->DynamicType()->Name() << ")";
+ }
+
+ std::cout << aCounter << ") " << anIter.Value()->DynamicType()->Name();
+
+ Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (anIter.Value());
+ if (!aConnected.IsNull() && !aConnected->ConnectedTo().IsNull() && aMap.IsBound1 (aConnected->ConnectedTo()))
+ {
+ std::cout << " connected to " << aMap.Find1 (aConnected->ConnectedTo());
+ }
+ std::cout << std::endl;
+
+ ++aCounter;
+ }
return 0;
}
}
return Standard_False;
}
-};
+}
//===============================================================================================
//function : VSetSelectionMode
Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
if (anAISContext.IsNull())
{
- std::cerr << "Call vinit before!\n";
+ std::cerr << "Call vinit before!" << std::endl;
return 1;
}
// Check the arguments
- if (theArgc != 3 && theArgc != 4)
+ if (theArgc < 3 && theArgc > 5)
{
std::cerr << "vselmode error : expects at least 2 arguments.\n"
- << "Type help "<< theArgv[0] <<" for more information.";
+ << "Type help "<< theArgv[0] <<" for more information." << std::endl;
return 1;
}
+ TCollection_AsciiString aLastArg (theArgv[theArgc - 1]);
+ aLastArg.LowerCase();
+ Standard_Boolean isToOpenLocalCtx = aLastArg == "-local";
+
// get objects to change selection mode
AIS_ListOfInteractive aTargetIOs;
- if (theArgc == 3)
+ Standard_Integer anArgNb = isToOpenLocalCtx ? theArgc - 1 : theArgc;
+ if (anArgNb == 3)
{
anAISContext->DisplayedObjects (aTargetIOs);
}
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aNameIO));
if (anIO.IsNull())
{
- std::cerr << "vselmode error : object name is used for non AIS viewer\n";
+ std::cerr << "vselmode error : object name is used for non AIS viewer" << std::endl;
return 1;
}
aTargetIOs.Append (anIO);
}
}
- const Standard_Integer aSelectionMode = Draw::Atoi (theArgc == 3 ? theArgv[1] : theArgv[2]);
- const Standard_Boolean toTurnOn = Draw::Atoi (theArgc == 3 ? theArgv[2] : theArgv[3]);
+ const Standard_Integer aSelectionMode = Draw::Atoi (anArgNb == 3 ? theArgv[1] : theArgv[2]);
+ const Standard_Boolean toTurnOn = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]) != 0;
if (aSelectionMode == 0 && anAISContext->HasOpenedContext())
{
anAISContext->CloseLocalContext();
}
+ if (aSelectionMode == 0)
+ {
+ if (toTurnOn)
+ {
+ for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next())
+ {
+ const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value();
+ TColStd_ListOfInteger anActiveModes;
+ anAISContext->ActivatedModes (anIO, anActiveModes);
+ if (!anActiveModes.IsEmpty())
+ {
+ anAISContext->Deactivate (anIO);
+ }
+ if (!InList (anAISContext, anIO, aSelectionMode))
+ {
+ anAISContext->Activate (anIO);
+ }
+ }
+ }
+ else
+ {
+ for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next())
+ {
+ const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value();
+ if (InList (anAISContext, anIO, aSelectionMode))
+ {
+ anAISContext->Deactivate (anIO);
+ }
+ }
+ }
+ }
+
if (aSelectionMode != 0 && toTurnOn) // Turn on specified mode
{
- if (!anAISContext->HasOpenedContext())
+ if (!anAISContext->HasOpenedContext() && isToOpenLocalCtx)
{
anAISContext->OpenLocalContext (Standard_False);
}
for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next())
{
const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value();
+ if (InList (anAISContext, anIO, 0))
+ {
+ anAISContext->Deactivate (anIO, 0);
+ }
if (!InList (anAISContext, anIO, aSelectionMode))
{
anAISContext->Load (anIO, -1, Standard_True);
if (aSelectionMode != 0 && !toTurnOn) // Turn off specified mode
{
- if (!anAISContext->HasOpenedContext())
- {
- return 0;
- }
-
for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next())
{
const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value();
return 0;
}
+//===============================================================================================
+//function : VSelectionNext
+//purpose :
+//===============================================================================================
+static Standard_Integer VSelectionNext(Draw_Interpretor& /*theDI*/,
+ Standard_Integer /*theArgsNb*/,
+ const char** /*theArgVec*/)
+{
+ // Check errors
+ Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+
+ if (anAISContext.IsNull())
+ {
+ std::cerr << "Call vinit before!" << std::endl;
+ return 1;
+ }
+
+ anAISContext->HilightNextDetected (aView);
+ return 0;
+}
+
+//===============================================================================================
+//function : VSelectionPrevious
+//purpose :
+//===============================================================================================
+static Standard_Integer VSelectionPrevious(Draw_Interpretor& /*theDI*/,
+ Standard_Integer /*theArgsNb*/,
+ const char** /*theArgVec*/)
+{
+ // Check errors
+ Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+
+ if (anAISContext.IsNull())
+ {
+ std::cerr << "Call vinit before!" << std::endl;
+ return 1;
+ }
+
+ anAISContext->HilightPreviousDetected (aView);
+ return 0;
+}
+
+
//==========================================================================
//class : Triangle
//purpose : creates Triangle based on AIS_InteractiveObject.
// This class was implemented for testing Select3D_SensitiveTriangle
//===========================================================================
-DEFINE_STANDARD_HANDLE(Triangle, AIS_InteractiveObject)
+
class Triangle: public AIS_InteractiveObject
{
public:
// CASCADE RTTI
- DEFINE_STANDARD_RTTI(FilledCircle);
+ DEFINE_STANDARD_RTTI_INLINE(Triangle,AIS_InteractiveObject);
Triangle (const gp_Pnt& theP1,
const gp_Pnt& theP2,
const gp_Pnt& theP3);
protected:
void Compute ( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode);
+ const Standard_Integer theMode) Standard_OVERRIDE;
void ComputeSelection ( const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode);
+ const Standard_Integer theMode) Standard_OVERRIDE;
private:
gp_Pnt myPoint1;
gp_Pnt myPoint2;
gp_Pnt myPoint3;
};
-IMPLEMENT_STANDARD_HANDLE(Triangle, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(Triangle, AIS_InteractiveObject)
+
Triangle::Triangle (const gp_Pnt& theP1,
const gp_Pnt& theP2,
//class : SegmentObject
//purpose: creates segment based on AIS_InteractiveObject.
// This class was implemented for testing Select3D_SensitiveCurve
-DEFINE_STANDARD_HANDLE(SegmentObject, AIS_InteractiveObject)
+
class SegmentObject: public AIS_InteractiveObject
{
public:
// CASCADE RTTI
- DEFINE_STANDARD_RTTI(SegmentObject);
+ DEFINE_STANDARD_RTTI_INLINE(SegmentObject,AIS_InteractiveObject);
SegmentObject (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2);
protected:
void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode);
+ const Standard_Integer theMode) Standard_OVERRIDE;
void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode);
+ const Standard_Integer theMode) Standard_OVERRIDE;
private:
gp_Pnt myPoint1;
gp_Pnt myPoint2;
};
-IMPLEMENT_STANDARD_HANDLE(SegmentObject, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(SegmentObject, AIS_InteractiveObject)
+
SegmentObject::SegmentObject (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2)
{
myPoint2 = thePnt2;
}
-void SegmentObject::Compute (const Handle_PrsMgr_PresentationManager3d &/*thePresentationManager*/,
- const Handle_Prs3d_Presentation &thePresentation,
+void SegmentObject::Compute (const Handle(PrsMgr_PresentationManager3d) &/*thePresentationManager*/,
+ const Handle(Prs3d_Presentation) &thePresentation,
const Standard_Integer /*theMode*/)
{
thePresentation->Clear();
StdPrs_Curve::Add(thePresentation, aCurveAdaptor, myDrawer);
}
-void SegmentObject::ComputeSelection (const Handle_SelectMgr_Selection &theSelection,
+void SegmentObject::ComputeSelection (const Handle(SelectMgr_Selection) &theSelection,
const Standard_Integer /*theMode*/)
{
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
if (!aMap.IsBound2 (aName))
{
- di << "Use 'vdisplay' before" << "\n";
+ di << "Use 'vdisplay' before\n";
return 1;
}
}
// This class is used for testing markers.
-DEFINE_STANDARD_HANDLE(ViewerTest_MarkersArrayObject, AIS_InteractiveObject)
+
class ViewerTest_MarkersArrayObject : public AIS_InteractiveObject
{
myMarkerAspect = theMarkerAspect;
}
- DEFINE_STANDARD_RTTI(MyPArrayObject);
+ DEFINE_STANDARD_RTTI_INLINE(MyPArrayObject,AIS_InteractiveObject);
private:
void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer aMode);
+ const Standard_Integer aMode) Standard_OVERRIDE;
void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer /*theMode*/);
+ const Standard_Integer /*theMode*/) Standard_OVERRIDE;
protected:
Handle(Graphic3d_AspectMarker3d) myMarkerAspect;
};
-IMPLEMENT_STANDARD_HANDLE(ViewerTest_MarkersArrayObject, AIS_InteractiveObject)
-IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_MarkersArrayObject, AIS_InteractiveObject)
void ViewerTest_MarkersArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
std::cerr << "Could not load image from file '" << aFileName << "'!\n";
return 1;
}
+ if (anImage->Format() == Image_PixMap::ImgGray)
+ {
+ anImage->SetFormat (Image_PixMap::ImgAlpha);
+ }
+ else if (anImage->Format() == Image_PixMap::ImgGrayF)
+ {
+ anImage->SetFormat (Image_PixMap::ImgAlphaF);
+ }
anAspect = new Graphic3d_AspectMarker3d (anImage);
}
else
else if (theArg == "bold"
|| *theArg.ToCString() == 'b')
{
- theAspect = Font_FA_Bold;
- return Standard_True;
+ theAspect = Font_FA_Bold;
+ return Standard_True;
+ }
+ else if (theArg == "italic"
+ || *theArg.ToCString() == 'i')
+ {
+ theAspect = Font_FA_Italic;
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//! Auxiliary function
+static TCollection_AsciiString fontStyleString (const Font_FontAspect theAspect)
+{
+ switch (theAspect)
+ {
+ case Font_FA_Regular: return "regular";
+ case Font_FA_BoldItalic: return "bolditalic";
+ case Font_FA_Bold: return "bold";
+ case Font_FA_Italic: return "italic";
+ default: return "undefined";
+ }
+}
+
+//=======================================================================
+//function : TextToBrep
+//purpose : Tool for conversion text to occt-shapes
+//=======================================================================
+static int TextToBRep (Draw_Interpretor& /*theDI*/,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ // Check arguments
+ if (theArgNb < 3)
+ {
+ std::cerr << "Error: " << theArgVec[0] << " - invalid syntax\n";
+ return 1;
+ }
+
+ Standard_Integer anArgIt = 1;
+ Standard_CString aName = theArgVec[anArgIt++];
+ Standard_CString aText = theArgVec[anArgIt++];
+
+ Font_BRepFont aFont;
+ TCollection_AsciiString aFontName ("Courier");
+ Standard_Real aTextHeight = 16.0;
+ Font_FontAspect aFontAspect = Font_FA_Regular;
+ Standard_Boolean anIsCompositeCurve = Standard_False;
+ gp_Ax3 aPenAx3 (gp::XOY());
+ gp_Dir aNormal (0.0, 0.0, 1.0);
+ gp_Dir aDirection (1.0, 0.0, 0.0);
+ gp_Pnt aPenLoc;
+
+ Graphic3d_HorizontalTextAlignment aHJustification = Graphic3d_HTA_LEFT;
+ Graphic3d_VerticalTextAlignment aVJustification = Graphic3d_VTA_BOTTOM;
+
+ for (; anArgIt < theArgNb; ++anArgIt)
+ {
+ TCollection_AsciiString aParam (theArgVec[anArgIt]);
+ aParam.LowerCase();
+
+ if (aParam == "-pos"
+ || aParam == "-position")
+ {
+ if (anArgIt + 3 >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ aPenLoc.SetX (Draw::Atof(theArgVec[++anArgIt]));
+ aPenLoc.SetY (Draw::Atof(theArgVec[++anArgIt]));
+ aPenLoc.SetZ (Draw::Atof(theArgVec[++anArgIt]));
+ }
+ else if (aParam == "-halign")
+ {
+ if (++anArgIt >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aType (theArgVec[anArgIt]);
+ aType.LowerCase();
+ if (aType == "left")
+ {
+ aHJustification = Graphic3d_HTA_LEFT;
+ }
+ else if (aType == "center")
+ {
+ aHJustification = Graphic3d_HTA_CENTER;
+ }
+ else if (aType == "right")
+ {
+ aHJustification = Graphic3d_HTA_RIGHT;
+ }
+ else
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-valign")
+ {
+ if (++anArgIt >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aType (theArgVec[anArgIt]);
+ aType.LowerCase();
+ if (aType == "top")
+ {
+ aVJustification = Graphic3d_VTA_TOP;
+ }
+ else if (aType == "center")
+ {
+ aVJustification = Graphic3d_VTA_CENTER;
+ }
+ else if (aType == "bottom")
+ {
+ aVJustification = Graphic3d_VTA_BOTTOM;
+ }
+ else if (aType == "topfirstline")
+ {
+ aVJustification = Graphic3d_VTA_TOPFIRSTLINE;
+ }
+ else
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-height")
+ {
+ if (++anArgIt >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ aTextHeight = Draw::Atof(theArgVec[anArgIt]);
+ }
+ else if (aParam == "-aspect")
+ {
+ if (++anArgIt >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ TCollection_AsciiString anOption (theArgVec[anArgIt]);
+ anOption.LowerCase();
+
+ if (anOption.IsEqual ("regular"))
+ {
+ aFontAspect = Font_FA_Regular;
+ }
+ else if (anOption.IsEqual ("bold"))
+ {
+ aFontAspect = Font_FA_Bold;
+ }
+ else if (anOption.IsEqual ("italic"))
+ {
+ aFontAspect = Font_FA_Italic;
+ }
+ else if (anOption.IsEqual ("bolditalic"))
+ {
+ aFontAspect = Font_FA_BoldItalic;
+ }
+ else
+ {
+ std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-font")
+ {
+ if (++anArgIt >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ aFontName = theArgVec[anArgIt];
+ }
+ else if (aParam == "-composite")
+ {
+ if (++anArgIt >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ ViewerTest::ParseOnOff (theArgVec[anArgIt], anIsCompositeCurve);
+ }
+ else if (aParam == "-plane")
+ {
+ if (anArgIt + 6 >= theArgNb)
+ {
+ std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
+ Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
+ Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
+ aNormal.SetCoord (aX, aY, aZ);
+
+ aX = Draw::Atof (theArgVec[++anArgIt]);
+ aY = Draw::Atof (theArgVec[++anArgIt]);
+ aZ = Draw::Atof (theArgVec[++anArgIt]);
+ aDirection.SetCoord (aX, aY, aZ);
+ }
+ else
+ {
+ std::cerr << "Warning! Unknown argument '" << aParam << "'\n";
+ }
+ }
+
+ aFont.SetCompositeCurveMode (anIsCompositeCurve);
+ if (!aFont.Init (aFontName.ToCString(), aFontAspect, aTextHeight))
+ {
+ std::cerr << "Font initialization error\n";
+ return 1;
+ }
+
+ aPenAx3 = gp_Ax3 (aPenLoc, aNormal, aDirection);
+
+ Font_BRepTextBuilder aBuilder;
+ DBRep::Set (aName, aBuilder.Perform (aFont, aText, aPenAx3, aHJustification, aVJustification));
+ return 0;
+}
+
+//=======================================================================
+//function : VFont
+//purpose : Font management
+//=======================================================================
+
+static int VFont (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ Handle(Font_FontMgr) aMgr = Font_FontMgr::GetInstance();
+ if (theArgNb < 2)
+ {
+ // just print the list of available fonts
+ Standard_Boolean isFirst = Standard_True;
+ for (Font_NListOfSystemFont::Iterator anIter (aMgr->GetAvailableFonts());
+ anIter.More(); anIter.Next())
+ {
+ const Handle(Font_SystemFont)& aFont = anIter.Value();
+ if (!isFirst)
+ {
+ theDI << "\n";
+ }
+
+ theDI << aFont->FontName()->String()
+ << " " << fontStyleString (aFont->FontAspect())
+ << " " << aFont->FontPath()->String();
+ isFirst = Standard_False;
+ }
+ return 0;
+ }
+
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+ {
+ const TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ TCollection_AsciiString anArgCase (anArg);
+ anArgCase.LowerCase();
+ if (anArgCase == "find")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cerr << "Wrong syntax at argument '" << anArg.ToCString() << "'!\n";
+ return 1;
+ }
+
+ Standard_CString aFontName = theArgVec[anArgIter];
+ Font_FontAspect aFontAspect = Font_FA_Undefined;
+ if (++anArgIter < theArgNb)
+ {
+ anArgCase = theArgVec[anArgIter];
+ anArgCase.LowerCase();
+ if (!parseFontStyle (anArgCase, aFontAspect))
+ {
+ --anArgIter;
+ }
+ }
+ Handle(Font_SystemFont) aFont = aMgr->FindFont (new TCollection_HAsciiString (aFontName), aFontAspect, -1);
+ if (aFont.IsNull())
+ {
+ std::cerr << "Error: font '" << aFontName << "' is not found!\n";
+ continue;
+ }
+
+ theDI << aFont->FontName()->String()
+ << " " << fontStyleString (aFont->FontAspect())
+ << " " << aFont->FontPath()->String();
+ }
+ else if (anArgCase == "add"
+ || anArgCase == "register")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cerr << "Wrong syntax at argument '" << anArg.ToCString() << "'!\n";
+ return 1;
+ }
+ Standard_CString aFontPath = theArgVec[anArgIter];
+ Standard_CString aFontName = NULL;
+ Font_FontAspect aFontAspect = Font_FA_Undefined;
+ if (++anArgIter < theArgNb)
+ {
+ if (!parseFontStyle (anArgCase, aFontAspect))
+ {
+ aFontName = theArgVec[anArgIter];
+ }
+ if (++anArgIter < theArgNb)
+ {
+ anArgCase = theArgVec[anArgIter];
+ anArgCase.LowerCase();
+ if (!parseFontStyle (anArgCase, aFontAspect))
+ {
+ --anArgIter;
+ }
+ }
+ }
+
+ Handle(Font_SystemFont) aFont = aMgr->CheckFont (aFontPath);
+ if (aFont.IsNull())
+ {
+ std::cerr << "Error: font '" << aFontPath << "' is not found!\n";
+ continue;
+ }
+
+ if (aFontAspect != Font_FA_Undefined
+ || aFontName != NULL)
+ {
+ if (aFontAspect == Font_FA_Undefined)
+ {
+ aFontAspect = aFont->FontAspect();
+ }
+ Handle(TCollection_HAsciiString) aName = aFont->FontName();
+ if (aFontName != NULL)
+ {
+ aName = new TCollection_HAsciiString (aFontName);
+ }
+ aFont = new Font_SystemFont (aName, aFontAspect, new TCollection_HAsciiString (aFontPath));
+ }
+
+ aMgr->RegisterFont (aFont, Standard_True);
+ theDI << aFont->FontName()->String()
+ << " " << fontStyleString (aFont->FontAspect())
+ << " " << aFont->FontPath()->String();
+ }
+ else
+ {
+ std::cerr << "Warning! Unknown argument '" << anArg.ToCString() << "'\n";
+ }
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : VSetEdgeType
+//purpose : Edges type management
+//=======================================================================
+
+static int VSetEdgeType (Draw_Interpretor& theDI,
+ Standard_Integer theArgNum,
+ const char** theArgs)
+{
+ if (theArgNum < 4 || theArgNum > 9)
+ {
+ theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
+ << theArgs[0] << "' for more information.\n";
+ return 1;
+ }
+
+ Standard_Boolean isForceRedisplay = Standard_False;
+
+ // Get shape name
+ TCollection_AsciiString aName(theArgs[1]);
+ if (!GetMapOfAIS().IsBound2 (aName))
+ {
+ theDI << theArgs[0] << " error: wrong object name.\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveObject) anObject =
+ Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
+
+ // Enable trianle edge mode
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOn();
+
+ // Parse parameters
+ for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
+ {
+ TCollection_AsciiString aParam ((theArgs[anIt]));
+ if (aParam.Value (1) == '-' && !aParam.IsRealValue())
+ {
+ if (aParam.IsEqual ("-type"))
+ {
+ if (theArgNum <= anIt + 1)
+ {
+ theDI << theArgs[0] << " error: wrong number of values for parameter '"
+ << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aType = theArgs[++anIt];
+ aType.UpperCase();
+
+ if (aType.IsEqual ("SOLID"))
+ {
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_SOLID);
+ }
+ else if (aType.IsEqual ("DASH"))
+ {
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DASH);
+ }
+ else if (aType.IsEqual ("DOT"))
+ {
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOT);
+ }
+ else if (aType.IsEqual ("DOTDASH"))
+ {
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOTDASH);
+ }
+ else
+ {
+ theDI << theArgs[0] << " error: wrong line type: '" << aType.ToCString() << "'.\n";
+ return 1;
+ }
+
+ }
+ else if (aParam.IsEqual ("-color"))
+ {
+ if (theArgNum <= anIt + 3)
+ {
+ theDI << theArgs[0] << " error: wrong number of values for parameter '"
+ << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+
+ Quantity_Parameter aR = Draw::Atof(theArgs[++anIt]);
+ Quantity_Parameter aG = Draw::Atof(theArgs[++anIt]);
+ Quantity_Parameter aB = Draw::Atof(theArgs[++anIt]);
+ Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
+ aG > 1 ? aG / 255.0 : aG,
+ aB > 1 ? aB / 255.0 : aB,
+ Quantity_TOC_RGB);
+
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeColor (aColor);
+ }
+ else if (aParam.IsEqual ("-force"))
+ {
+ isForceRedisplay = Standard_True;
+ }
+ else
+ {
+ theDI << theArgs[0] << " error: unknown parameter '"
+ << aParam.ToCString() << "'.\n";
+ return 1;
+ }
+ }
+ }
+
+ // Update shape presentation as aspect parameters were changed
+ if (isForceRedisplay)
+ {
+ ViewerTest::GetAISContext()->Redisplay (anObject);
+ }
+ else
+ {
+ anObject->SetAspect (anObject->Attributes()->ShadingAspect());
+ }
+
+ //Update view
+ ViewerTest::CurrentView()->Redraw();
+
+ return 0;
+}
+
+//=======================================================================
+//function : VUnsetEdgeType
+//purpose : Unsets edges visibility in shading mode
+//=======================================================================
+
+static int VUnsetEdgeType (Draw_Interpretor& theDI,
+ Standard_Integer theArgNum,
+ const char** theArgs)
+{
+ if (theArgNum != 2 && theArgNum != 3)
+ {
+ theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
+ << theArgs[0] << "' for more information.\n";
+ return 1;
+ }
+
+ Standard_Boolean isForceRedisplay = Standard_False;
+
+ // Get shape name
+ TCollection_AsciiString aName (theArgs[1]);
+ if (!GetMapOfAIS().IsBound2 (aName))
+ {
+ theDI << theArgs[0] << " error: wrong object name.\n";
+ return 1;
}
- else if (theArg == "italic"
- || *theArg.ToCString() == 'i')
+
+ Handle(AIS_InteractiveObject) anObject =
+ Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
+
+ // Enable trianle edge mode
+ anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
+
+ // Parse parameters
+ if (theArgNum == 3)
{
- theAspect = Font_FA_Italic;
- return Standard_True;
+ TCollection_AsciiString aParam ((theArgs[2]));
+ if (aParam.IsEqual ("-force"))
+ {
+ isForceRedisplay = Standard_True;
+ }
+ else
+ {
+ theDI << theArgs[0] << " error: unknown parameter '"
+ << aParam.ToCString() << "'.\n";
+ return 1;
+ }
}
- return Standard_False;
-}
-//! Auxiliary function
-static TCollection_AsciiString fontStyleString (const Font_FontAspect theAspect)
-{
- switch (theAspect)
+ // Update shape presentation as aspect parameters were changed
+ if (isForceRedisplay)
{
- case Font_FA_Regular: return "regular";
- case Font_FA_BoldItalic: return "bolditalic";
- case Font_FA_Bold: return "bold";
- case Font_FA_Italic: return "italic";
- default: return "undefined";
+ ViewerTest::GetAISContext()->Redisplay (anObject);
}
+ else
+ {
+ anObject->SetAspect (anObject->Attributes()->ShadingAspect());
+ }
+
+ //Update view
+ ViewerTest::CurrentView()->Redraw();
+
+ return 0;
}
+
//=======================================================================
-//function : TextToBrep
-//purpose : Tool for conversion text to occt-shapes
+//function : VVertexMode
+//purpose : Switches vertex display mode for AIS_Shape or displays the current value
//=======================================================================
-static int TextToBRep (Draw_Interpretor& /*theDI*/,
- Standard_Integer theArgNb,
- const char** theArgVec)
+static int VVertexMode (Draw_Interpretor& theDI,
+ Standard_Integer theArgNum,
+ const char** theArgs)
{
- // Check arguments
- if (theArgNb < 5)
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
{
- std::cerr << "Error: " << theArgVec[0] << " - invalid syntax\n";
+ std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
return 1;
}
- Standard_Integer anArgIter = 1;
- Standard_CString aResName = theArgVec[anArgIter++];
- Standard_CString aText = theArgVec[anArgIter++];
- Standard_CString aFontName = theArgVec[anArgIter++];
- const Standard_Real aSize = Atof (theArgVec[anArgIter++]);
+ // No arguments --> print the current default vertex draw mode
+ if (theArgNum == 1)
+ {
+ Prs3d_VertexDrawMode aCurrMode = aContext->DefaultDrawer()->VertexDrawMode();
+ theDI << "Default vertex draw mode: " << (aCurrMode == Prs3d_VDM_Isolated ? "'isolated'" : "'all'") << "\n";
+ return 0;
+ }
- Font_BRepFont aFont;
- Font_FontAspect aFontAspect = Font_FA_Regular;
- Standard_Boolean isCompositeCurve = Standard_False;
- gp_Ax3 aPenAx3 (gp::XOY());
- gp_Pnt aPenLoc;
- while (anArgIter < theArgNb)
+ // -set argument --> change the default vertex draw mode and the mode for all displayed or given object(s)
+ TCollection_AsciiString aParam (theArgs[1]);
+ if (aParam == "-set")
{
- const TCollection_AsciiString anArg (theArgVec[anArgIter++]);
- TCollection_AsciiString anArgCase (anArg);
- anArgCase.LowerCase();
- if (anArgCase.Search ("x=") > -1)
- {
- aPenLoc.SetX (anArg.Token ("=", 2).RealValue());
- }
- else if (anArgCase.Search ("y=") > -1)
+ if (theArgNum == 2)
{
- aPenLoc.SetY (anArg.Token ("=", 2).RealValue());
- }
- else if (anArgCase.Search ("z=") > -1)
- {
- aPenLoc.SetZ (anArg.Token ("=", 2).RealValue());
+ std::cout << "Error: '-set' option not followed by the mode and optional object name(s)" << std::endl;
+ std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
+ return 1;
}
- else if (anArgCase.Search ("composite=") > -1)
+
+ TCollection_AsciiString aModeStr (theArgs[2]);
+ Prs3d_VertexDrawMode aNewMode =
+ aModeStr == "isolated" ? Prs3d_VDM_Isolated :
+ (aModeStr == "all" ? Prs3d_VDM_All :
+ Prs3d_VDM_Inherited);
+
+ Standard_Boolean aRedrawNeeded = Standard_False;
+ AIS_ListOfInteractive anObjs;
+
+ // No object(s) specified -> use all displayed
+ if (theArgNum == 3)
{
- isCompositeCurve = (anArg.Token ("=", 2).IntegerValue() == 1);
+ theDI << "Setting the default vertex draw mode and updating all displayed objects...\n";
+ aContext->DisplayedObjects (anObjs);
+ aContext->DefaultDrawer()->SetVertexDrawMode (aNewMode);
+ aRedrawNeeded = Standard_True;
}
- else if (parseFontStyle (anArgCase, aFontAspect))
+
+ Handle(AIS_InteractiveObject) anObject;
+ for (Standard_Integer aCount = 3; aCount < theArgNum; aCount++)
{
- //
+ TCollection_AsciiString aName (theArgs[aCount]);
+ if (!GetMapOfAIS().IsBound2 (aName))
+ {
+ theDI << "Warning: wrong object name ignored - " << theArgs[0] << "\n";
+ continue;
+ }
+ anObject = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
+ anObjs.Append (anObject);
}
- else
+
+ for (AIS_ListIteratorOfListOfInteractive anIt (anObjs); anIt.More(); anIt.Next())
{
- std::cerr << "Warning! Unknown argument '" << anArg.ToCString() << "'\n";
+ anObject = anIt.Value();
+ anObject->Attributes()->SetVertexDrawMode (aNewMode);
+ aContext->Redisplay (anObject, Standard_False);
+ aRedrawNeeded = Standard_True;
}
+
+ if (aRedrawNeeded)
+ ViewerTest::CurrentView()->Redraw();
+
+ return 0;
}
- aFont.SetCompositeCurveMode (isCompositeCurve);
- if (!aFont.Init (aFontName, aFontAspect, aSize))
+ if (theArgNum > 2)
{
- std::cerr << "Font initialization error\n";
+ std::cout << "Error: invalid number of arguments" << std::endl;
+ std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
return 1;
}
- aPenAx3.SetLocation (aPenLoc);
- DBRep::Set (aResName, aFont.RenderText (aText, aPenAx3));
+ // One argument (object name) --> print the current vertex draw mode for the object
+ Handle(AIS_InteractiveObject) anObject =
+ Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aParam));
+ Prs3d_VertexDrawMode aCurrMode = anObject->Attributes()->VertexDrawMode();
+ theDI << "Object's vertex draw mode: " << (aCurrMode == Prs3d_VDM_Isolated ? "'isolated'" : "'all'") << "\n";
return 0;
}
//=======================================================================
-//function : VFont
-//purpose : Font management
+//function : VPointCloud
+//purpose : Create interactive object for arbitary set of points.
//=======================================================================
-
-static int VFont (Draw_Interpretor& theDI,
- Standard_Integer theArgNb,
- const char** theArgVec)
+static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
+ Standard_Integer theArgNum,
+ const char** theArgs)
{
- Handle(Font_FontMgr) aMgr = Font_FontMgr::GetInstance();
- if (theArgNb < 2)
+ Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+ if (anAISContext.IsNull())
{
- // just print the list of available fonts
- Standard_Boolean isFirst = Standard_True;
- for (Font_NListOfSystemFont::Iterator anIter (aMgr->GetAvailableFonts());
- anIter.More(); anIter.Next())
- {
- const Handle(Font_SystemFont)& aFont = anIter.Value();
- if (!isFirst)
- {
- theDI << "\n";
- }
+ std::cerr << "Error: no active view!\n";
+ return 1;
+ }
- theDI << aFont->FontName()->String()
- << " " << fontStyleString (aFont->FontAspect())
- << " " << aFont->FontPath()->String();
- isFirst = Standard_False;
+ // command to execute
+ enum Command
+ {
+ CloudForShape, // generate point cloud for shape
+ CloudSphere, // generate point cloud for generic sphere
+ Unknow
+ };
+
+ // count number of non-optional command arguments
+ Command aCmd = Unknow;
+ Standard_Integer aCmdArgs = 0;
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgNum; ++anArgIter)
+ {
+ Standard_CString anArg = theArgs[anArgIter];
+ TCollection_AsciiString aFlag (anArg);
+ aFlag.LowerCase();
+ if (aFlag.IsRealValue() || aFlag.Search ("-") != 1)
+ {
+ aCmdArgs++;
}
- return 0;
+ }
+ switch (aCmdArgs)
+ {
+ case 2 : aCmd = CloudForShape; break;
+ case 7 : aCmd = CloudSphere; break;
+ default :
+ std::cout << "Error: wrong number of arguments! See usage:\n";
+ theDI.PrintHelp (theArgs[0]);
+ return 1;
}
- for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+ // parse options
+ Standard_Boolean toRandColors = Standard_False;
+ Standard_Boolean hasNormals = Standard_True;
+ Standard_Boolean isSetArgNorm = Standard_False;
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgNum; ++anArgIter)
{
- const TCollection_AsciiString anArg (theArgVec[anArgIter]);
- TCollection_AsciiString anArgCase (anArg);
- anArgCase.LowerCase();
- if (anArgCase == "find")
+ Standard_CString anArg = theArgs[anArgIter];
+ TCollection_AsciiString aFlag (anArg);
+ aFlag.LowerCase();
+ if (aFlag == "-randcolors"
+ || aFlag == "-randcolor")
{
- if (++anArgIter >= theArgNb)
+ if (isSetArgNorm && hasNormals)
{
- std::cerr << "Wrong syntax at argument '" << anArg.ToCString() << "'!\n";
+ std::cout << "Error: wrong syntax - normals can not be enabled with colors at the same time\n";
+ return 1;
+ }
+ toRandColors = Standard_True;
+ hasNormals = Standard_False;
+ }
+ else if (aFlag == "-normals"
+ || aFlag == "-normal")
+ {
+ if (toRandColors)
+ {
+ std::cout << "Error: wrong syntax - normals can not be enabled with colors at the same time\n";
return 1;
}
+ isSetArgNorm = Standard_True;
+ hasNormals = Standard_True;
+ }
+ else if (aFlag == "-nonormals"
+ || aFlag == "-nonormal")
+ {
+ isSetArgNorm = Standard_True;
+ hasNormals = Standard_False;
+ }
+ }
- Standard_CString aFontName = theArgVec[anArgIter];
- Font_FontAspect aFontAspect = Font_FA_Undefined;
- if (++anArgIter < theArgNb)
+ Standard_CString aName = theArgs[1];
+
+ // generate arbitrary set of points
+ Handle(Graphic3d_ArrayOfPoints) anArrayPoints;
+ if (aCmd == CloudForShape)
+ {
+ Standard_CString aShapeName = theArgs[2];
+ TopoDS_Shape aShape = DBRep::Get (aShapeName);
+
+ if (aShape.IsNull())
+ {
+ std::cout << "Error: no shape with name '" << aShapeName << "' found\n";
+ return 1;
+ }
+
+ // calculate number of points
+ TopLoc_Location aLocation;
+ Standard_Integer aNbPoints = 0;
+ for (TopExp_Explorer aFaceIt (aShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
+ {
+ const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
+ Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aFace, aLocation);
+ if (!aTriangulation.IsNull())
{
- anArgCase = theArgVec[anArgIter];
- anArgCase.LowerCase();
- if (!parseFontStyle (anArgCase, aFontAspect))
- {
- --anArgIter;
- }
+ aNbPoints += aTriangulation->NbNodes();
}
- Handle(Font_SystemFont) aFont = aMgr->FindFont (new TCollection_HAsciiString (aFontName), aFontAspect, -1);
- if (aFont.IsNull())
+ }
+ if (aNbPoints < 3)
+ {
+ std::cout << "Error: shape should be triangulated!\n";
+ return 1;
+ }
+
+ anArrayPoints = new Graphic3d_ArrayOfPoints (aNbPoints, toRandColors, hasNormals);
+ for (TopExp_Explorer aFaceIt (aShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
+ {
+ const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
+ Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aFace, aLocation);
+ if (aTriangulation.IsNull())
{
- std::cerr << "Error: font '" << aFontName << "' is not found!\n";
continue;
}
- theDI << aFont->FontName()->String()
- << " " << fontStyleString (aFont->FontAspect())
- << " " << aFont->FontPath()->String();
- }
- else if (anArgCase == "add"
- || anArgCase == "register")
- {
- if (++anArgIter >= theArgNb)
+ const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
+ const gp_Trsf& aTrsf = aLocation.Transformation();
+
+ // extract normals from nodes
+ TColgp_Array1OfDir aNormals (aNodes.Lower(), hasNormals ? aNodes.Upper() : aNodes.Lower());
+ if (hasNormals)
{
- std::cerr << "Wrong syntax at argument '" << anArg.ToCString() << "'!\n";
- return 1;
+ Poly_Connect aPolyConnect (aTriangulation);
+ StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
}
- Standard_CString aFontPath = theArgVec[anArgIter];
- Standard_CString aFontName = NULL;
- Font_FontAspect aFontAspect = Font_FA_Undefined;
- if (++anArgIter < theArgNb)
+
+ for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
{
- if (!parseFontStyle (anArgCase, aFontAspect))
- {
- aFontName = theArgVec[anArgIter];
- }
- if (++anArgIter < theArgNb)
+ gp_Pnt aPoint = aNodes (aNodeIter);
+ if (!aLocation.IsIdentity())
{
- anArgCase = theArgVec[anArgIter];
- anArgCase.LowerCase();
- if (!parseFontStyle (anArgCase, aFontAspect))
+ aPoint.Transform (aTrsf);
+ if (hasNormals)
{
- --anArgIter;
+ aNormals (aNodeIter).Transform (aTrsf);
}
}
+
+ // add vertex into array of points
+ const Standard_Integer anIndexOfPoint = anArrayPoints->AddVertex (aPoint);
+ if (toRandColors)
+ {
+ Quantity_Color aColor (360.0 * Standard_Real(anIndexOfPoint) / Standard_Real(aNbPoints),
+ 1.0, 0.5, Quantity_TOC_HLS);
+ anArrayPoints->SetVertexColor (anIndexOfPoint, aColor);
+ }
+
+ if (hasNormals)
+ {
+ anArrayPoints->SetVertexNormal (anIndexOfPoint, aNormals (aNodeIter));
+ }
}
+ }
+ }
+ else if (aCmd == CloudSphere)
+ {
+ Standard_Real aCenterX = Draw::Atof (theArgs[2]);
+ Standard_Real aCenterY = Draw::Atof (theArgs[3]);
+ Standard_Real aCenterZ = Draw::Atof (theArgs[4]);
+ Standard_Real aRadius = Draw::Atof (theArgs[5]);
+ Standard_Integer aNbPoints = Draw::Atoi (theArgs[6]);
- Handle(Font_SystemFont) aFont = aMgr->CheckFont (aFontPath);
- if (aFont.IsNull())
+ TCollection_AsciiString aDistribution = TCollection_AsciiString(theArgs[7]);
+ aDistribution.LowerCase();
+ if ( aDistribution != "surface" && aDistribution != "volume" )
+ {
+ std::cout << "Error: wrong arguments! See usage:\n";
+ theDI.PrintHelp (theArgs[0]);
+ return 1;
+ }
+ Standard_Boolean isSurface = aDistribution == "surface";
+
+ gp_Pnt aCenter(aCenterX, aCenterY, aCenterZ);
+
+ anArrayPoints = new Graphic3d_ArrayOfPoints (aNbPoints, toRandColors, hasNormals);
+ for (Standard_Integer aPntIt = 0; aPntIt < aNbPoints; ++aPntIt)
+ {
+ Standard_Real anAlpha = (Standard_Real (rand() % 2000) / 1000.0) * M_PI;
+ Standard_Real aBeta = (Standard_Real (rand() % 2000) / 1000.0) * M_PI;
+ Standard_Real aDistance = isSurface ?
+ aRadius : (Standard_Real (rand() % aNbPoints) / aNbPoints) * aRadius;
+
+ gp_Dir aDir (Cos (anAlpha) * Sin (aBeta),
+ Sin (anAlpha),
+ Cos (anAlpha) * Cos (aBeta));
+ gp_Pnt aPoint = aCenter.Translated (aDir.XYZ() * aDistance);
+
+ const Standard_Integer anIndexOfPoint = anArrayPoints->AddVertex (aPoint);
+ if (toRandColors)
{
- std::cerr << "Error: font '" << aFontPath << "' is not found!\n";
- continue;
+ Quantity_Color aColor (360.0 * Standard_Real (anIndexOfPoint) / Standard_Real (aNbPoints),
+ 1.0, 0.5, Quantity_TOC_HLS);
+ anArrayPoints->SetVertexColor (anIndexOfPoint, aColor);
}
- if (aFontAspect != Font_FA_Undefined
- || aFontName != NULL)
+ if (hasNormals)
{
- if (aFontAspect == Font_FA_Undefined)
- {
- aFontAspect = aFont->FontAspect();
- }
- Handle(TCollection_HAsciiString) aName = aFont->FontName();
- if (aFontName != NULL)
- {
- aName = new TCollection_HAsciiString (aFontName);
- }
- aFont = new Font_SystemFont (aName, aFontAspect, new TCollection_HAsciiString (aFontPath));
+ anArrayPoints->SetVertexNormal (anIndexOfPoint, aDir);
}
+ }
+ }
- aMgr->RegisterFont (aFont, Standard_True);
- theDI << aFont->FontName()->String()
- << " " << fontStyleString (aFont->FontAspect())
- << " " << aFont->FontPath()->String();
+ // set array of points in point cloud object
+ Handle(AIS_PointCloud) aPointCloud = new AIS_PointCloud();
+ aPointCloud->SetPoints (anArrayPoints);
+ VDisplayAISObject (aName, aPointCloud);
+ return 0;
+}
+
+//=======================================================================
+//function : VPriority
+//purpose : Prints or sets the display priority for an object
+//=======================================================================
+
+static int VPriority (Draw_Interpretor& theDI,
+ Standard_Integer theArgNum,
+ const char** theArgs)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
+ if (aContext.IsNull())
+ {
+ std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+ return 1;
+ }
+
+ TCollection_AsciiString aLastArg (theArgs[theArgNum - 1]);
+ Standard_Integer aPriority = -1;
+ Standard_Integer aNbArgs = theArgNum;
+ if (aLastArg.IsIntegerValue())
+ {
+ aPriority = aLastArg.IntegerValue();
+ --aNbArgs;
+ if (aPriority < 0 || aPriority > 10)
+ {
+ std::cout << "Error: the specified display priority value '" << aLastArg
+ << "' is outside the valid range [0..10]" << std::endl;
+ return 1;
+ }
+ }
+ else
+ {
+ anUpdateTool.Invalidate();
+ }
+
+ if (aNbArgs < 2)
+ {
+ std::cout << "Error: wrong number of arguments! See usage:\n";
+ theDI.PrintHelp (theArgs[0]);
+ return 1;
+ }
+
+ for (Standard_Integer anArgIter = 1; anArgIter < aNbArgs; ++anArgIter)
+ {
+ if (anUpdateTool.parseRedrawMode (theArgs[anArgIter]))
+ {
+ continue;
+ }
+
+ TCollection_AsciiString aName (theArgs[anArgIter]);
+ Handle(AIS_InteractiveObject) anIObj;
+ if (GetMapOfAIS().IsBound2 (aName))
+ {
+ anIObj = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+ }
+
+ if (anIObj.IsNull())
+ {
+ std::cout << "Error: the object '" << theArgs[1] << "' is not displayed" << std::endl;
+ return 1;
+ }
+
+ if (aPriority < 1)
+ {
+ theDI << aContext->DisplayPriority (anIObj) << " ";
}
else
{
- std::cerr << "Warning! Unknown argument '" << anArg.ToCString() << "'\n";
+ aContext->SetDisplayPriority (anIObj, aPriority);
}
}
-
return 0;
}
{
const char *group ="AISObjects";
theCommands.Add("vtrihedron",
- "vtrihedron : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw] ",
+ "vtrihedron : vtrihedron name [ -origin x y z ] [ -zaxis u v w -xaxis u v w ] [ -hidelabels ]"
+ "\n\t\t: Creates a new *AIS_Trihedron* object. If no argument is set, the default trihedron (0XYZ) is created."
+ "\n\t\t: -hidelabels allows to draw trihedron without axes labels. By default, they are displayed.",
__FILE__,VTrihedron,group);
theCommands.Add("vtri2d",
- "vtri2d Name Selection in the viewer only ",
+ "vtri2d Name"
+ "\n\t\t: Creates a plane with a 2D trihedron from an interactively selected face.",
__FILE__,VTrihedron2D ,group);
theCommands.Add("vplanetri",
- "vplanetri Name Selection in the viewer only ",
+ "vplanetri name"
+ "\n\t\t: Create a plane from a trihedron selection. If no arguments are set, the default",
__FILE__,VPlaneTrihedron ,group);
theCommands.Add("vsize",
- "vsize : vsize [name(Default=Current)] [size(Default=100)] ",
+ "vsize : vsize [name(Default=Current)] [size(Default=100)] "
+ "\n\t\t: Changes the size of a named or selected trihedron."
+ "\n\t\t: If the name is not defined: it affects the selected trihedrons otherwise nothing is done."
+ "\n\t\t: If the value is not defined: it is set to 100 by default.",
__FILE__,VSize,group);
theCommands.Add("vaxis",
- "vaxis nom [Xa] [Ya] [Za] [Xb] [Yb] [Zb]",
+ "vaxis name [Xa] [Ya] [Za] [Xb] [Yb] [Zb]"
+ "\n\t\t: Creates an axis. If the values are not defined, an axis is created by interactive selection of two vertices or one edge",
__FILE__,VAxisBuilder,group);
theCommands.Add("vaxispara",
- "vaxispara nom ",
+ "vaxispara name "
+ "\n\t\t: Creates an axis by interactive selection of an edge and a vertex.",
__FILE__,VAxisBuilder,group);
theCommands.Add("vaxisortho",
- "vaxisotho nom ",
+ "vaxisortho name "
+ "\n\t\t: Creates an axis by interactive selection of an edge and a vertex. The axis will be orthogonal to the selected edge.",
__FILE__,VAxisBuilder,group);
theCommands.Add("vpoint",
- "vpoint PointName [Xa] [Ya] [Za] ",
+ "vpoint PointName [Xa] [Ya] [Za] "
+ "\n\t\t: Creates a point from coordinates. If the values are not defined,"
+ "\n\t\t: a point is created by interactive selection of a vertice or an edge (in the center of the edge).",
__FILE__,VPointBuilder,group);
theCommands.Add("vplane",
- "vplane PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] [TypeOfSensitivity]",
+ "vplane PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] [TypeOfSensitivity {0|1}]"
+ "\n\t\t: Creates a plane from named or interactively selected entities."
+ "\n\t\t: TypeOfSensitivity:"
+ "\n\t\t: 0 - Interior"
+ "\n\t\t: 1 - Boundary",
__FILE__,VPlaneBuilder,group);
theCommands.Add ("vchangeplane", "vchangeplane usage: \n"
__FILE__, VChangePlane, group);
theCommands.Add("vplanepara",
- "vplanepara PlaneName ",
+ "vplanepara PlaneName "
+ "\n\t\t: Creates a plane from interactively selected vertex and face.",
__FILE__,VPlaneBuilder,group);
theCommands.Add("vplaneortho",
- "vplaneortho PlaneName ",
+ "vplaneortho PlaneName "
+ "\n\t\t: Creates a plane from interactive selected face and coplanar edge. ",
__FILE__,VPlaneBuilder,group);
theCommands.Add("vline",
- "vline: vline LineName [Xa/PointName] [Ya/PointName] [Za] [Xb] [Yb] [Zb] ",
+ "vline LineName [Xa/PointName] [Ya/PointName] [Za] [Xb] [Yb] [Zb] "
+ "\n\t\t: Creates a line from coordinates, named or interactively selected vertices. ",
__FILE__,VLineBuilder,group);
theCommands.Add("vcircle",
- "vcircle CircleName [PointName PointName PointName IsFilled]\n\t\t\t\t\t[PlaneName PointName Radius IsFilled]",
+ "vcircle CircleName [PointName PointName PointName IsFilled]\n\t\t\t\t\t[PlaneName PointName Radius IsFilled]"
+ "\n\t\t: Creates a circle from named or interactively selected entities."
+ "\n\t\t: Parameter IsFilled is defined as 0 or 1.",
__FILE__,VCircleBuilder,group);
- theCommands.Add("vdrawtext",
- "vdrawtext : vdrawtext name X Y Z R G B hor_align ver_align angle zoomable height Aspect [Font [isMultiByte]]",
- __FILE__,VDrawText,group);
+ theCommands.Add ("vdrawtext",
+ "vdrawtext name text"
+ "\n\t\t: [-pos X=0 Y=0 Z=0]"
+ "\n\t\t: [-color {R G B|name}=yellow]"
+ "\n\t\t: [-halign {left|center|right}=left]"
+ "\n\t\t: [-valign {top|center|bottom|topfirstline}=bottom}]"
+ "\n\t\t: [-angle angle=0]"
+ "\n\t\t: [-zoom {0|1}=0]"
+ "\n\t\t: [-height height=16]"
+ "\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]"
+ "\n\t\t: [-font font=Times]"
+ "\n\t\t: [-2d]"
+ "\n\t\t: [-perspos {X Y Z}=0 0 0], where"
+ "\n\t\t X and Y define the coordinate origin in 2d space relative to the view window"
+ "\n\t\t Example: X=0 Y=0 is center, X=1 Y=1 is upper right corner etc..."
+ "\n\t\t Z coordinate defines the gap from border of view window (except center position)."
+ "\n\t\t: [-disptype {blend|decal|subtitle|dimension|normal}=normal}"
+ "\n\t\t: [-subcolor {R G B|name}=white]"
+ "\n\t\t: [-noupdate]"
+ "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]"
+ "\n\t\t: [-flipping]"
+ "\n\t\t: Display text label at specified position.",
+ __FILE__, VDrawText, group);
theCommands.Add("vdrawsphere",
- "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]\n",
+ "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0] [ToPrintInfo=1]\n",
__FILE__,VDrawSphere,group);
+ theCommands.Add ("vlocation",
+ "vlocation name"
+ "\n\t\t: [-reset]"
+ "\n\t\t: [-copyFrom otherName]"
+ "\n\t\t: [-translate X Y [Z]]"
+ "\n\t\t: [-rotate x y z dx dy dz angle]"
+ "\n\t\t: [-scale [X Y Z] scale]"
+ "\n\t\t: [-mirror x y z dx dy dz]"
+ "\n\t\t: [-setLocation X Y [Z]]"
+ "\n\t\t: [-setRotation QX QY QZ QW]"
+ "\n\t\t: [-setScale [X Y Z] scale]"
+ "\n\t\t: Object local transformation management:"
+ "\n\t\t: -reset reset transformation to identity"
+ "\n\t\t: -translate translate object"
+ "\n\t\t: -rotate applies rotation to local transformation"
+ "\n\t\t: -scale applies scale to local transformation"
+ "\n\t\t: -mirror applies mirror to local transformation"
+ "\n\t\t: -setLocation assign object location"
+ "\n\t\t: -setRotation assign object rotation (quaternion)"
+ "\n\t\t: -setScale assign object scale factor",
+ __FILE__, VSetLocation, group);
theCommands.Add ("vsetlocation",
- "vsetlocation : name x y z; set new location for an interactive object",
+ "alias for vlocation",
__FILE__, VSetLocation, group);
theCommands.Add (
__FILE__, VComputeHLR, group);
theCommands.Add("vdrawparray",
- "vdrawparray : vdrawparray Name TypeOfArray [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id [edge_hidden = { 'h' }] ]",
+ "vdrawparray : vdrawparray Name TypeOfArray [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id ]",
__FILE__,VDrawPArray,group);
theCommands.Add("vconnect",
- "vconnect : name Xo Yo Zo Xu Xv Xw Zu Zv Zw object1 object2 ... [color=NAME]",
+ "vconnect name Xo Yo Zo object1 object2 ... [color=NAME]"
+ "\n\t\t: Creates and displays AIS_ConnectedInteractive object from input object and location.",
__FILE__, VConnect, group);
- theCommands.Add("vconnectsh",
- "vconnectsh : name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME]",
- __FILE__, VConnectShape, group);
+ theCommands.Add("vconnectto",
+ "vconnectto : instance_name Xo Yo Zo object [-nodisplay|-noupdate|-update]"
+ " Makes an instance 'instance_name' of 'object' with position (Xo Yo Zo)."
+ "\n\t\t: -nodisplay - only creates interactive object, but not displays it",
+ __FILE__, VConnectTo,group);
+
+ theCommands.Add("vdisconnect",
+ "vdisconnect assembly_name (object_name | object_number | 'all')"
+ " Disconnects all objects from assembly or disconnects object by name or number (use vlistconnected to enumerate assembly children).",
+ __FILE__,VDisconnect,group);
+
+ theCommands.Add("vaddconnected",
+ "vaddconnected assembly_name object_name"
+ "Adds object to assembly.",
+ __FILE__,VAddConnected,group);
+
+ theCommands.Add("vlistconnected",
+ "vlistconnected assembly_name"
+ "Lists objects in assembly.",
+ __FILE__,VListConnected,group);
+
theCommands.Add("vselmode",
"vselmode : [object] mode_number is_turned_on=(1|0)\n"
" 0 if mode is to be switched off\n",
__FILE__, VSetSelectionMode, group);
+ theCommands.Add("vselnext",
+ "vselnext : hilight next detected",
+ __FILE__, VSelectionNext, group);
+
+ theCommands.Add("vselprev",
+ "vselnext : hilight previous detected",
+ __FILE__, VSelectionPrevious, group);
+
theCommands.Add("vtriangle",
- "vtriangle Name PointName PointName PointName",
+ "vtriangle Name PointName PointName PointName"
+ "\n\t\t: Creates and displays a filled triangle from named points.",
__FILE__, VTriangle,group);
theCommands.Add("vsegment",
- "vsegment Name PointName PointName",
+ "vsegment Name PointName PointName"
+ "\n\t\t: Creates and displays a segment from named points.",
__FILE__, VSegment,group);
theCommands.Add("vobjzlayer",
__FILE__, VMarkersTest, group);
theCommands.Add ("text2brep",
- "text2brep: res text fontName fontSize [x=0.0 y=0.0 z=0.0 composite=1 {regular,bold,italic,bolditalic=regular}]\n",
+ "text2brep: name text"
+ "\n\t\t: [-pos X=0 Y=0 Z=0]"
+ "\n\t\t: [-halign {left|center|right}=left]"
+ "\n\t\t: [-valign {top|center|bottom|topfirstline}=bottom}]"
+ "\n\t\t: [-height height=16]"
+ "\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]"
+ "\n\t\t: [-font font=Courier]"
+ "\n\t\t: [-composite {on|off}=off]"
+ "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]",
__FILE__, TextToBRep, group);
theCommands.Add ("vfont",
"vfont [add pathToFont [fontName] [regular,bold,italic,bolditalic=undefined]]"
"\n\t\t: [find fontName [regular,bold,italic,bolditalic=undefined]]",
__FILE__, VFont, group);
+
+ theCommands.Add ("vsetedgetype",
+ "vsetedgetype usage:\n"
+ "vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
+ "\n\t\t: Sets edges type and color for input shape",
+ __FILE__, VSetEdgeType, group);
+
+ theCommands.Add ("vunsetedgetype",
+ "vunsetedgetype usage:\n"
+ "vunsetedgetype ShapeName [-force]"
+ "\n\t\t: Unsets edges type and color for input shape",
+ __FILE__, VUnsetEdgeType, group);
+
+ theCommands.Add ("vvertexmode",
+ "vvertexmode [name | -set {isolated | all | inherited} [name1 name2 ...]]\n"
+ "vvertexmode - prints the default vertex draw mode\n"
+ "vvertexmode name - prints the vertex draw mode of the given object\n"
+ "vvertexmode -set {isolated | all | inherited} - sets the default vertex draw mode and updates the mode for all displayed objects\n"
+ "vvertexmode -set {isolated | all | inherited} name1 name2 ... - sets the vertex draw mode for the specified object(s)\n",
+ __FILE__, VVertexMode, group);
+
+ theCommands.Add ("vpointcloud",
+ "vpointcloud name shape [-randColor] [-normals] [-noNormals]"
+ "\n\t\t: Create an interactive object for arbitary set of points"
+ "\n\t\t: from triangulated shape."
+ "\n"
+ "vpointcloud name x y z r npts {surface|volume}\n"
+ " ... [-randColor] [-normals] [-noNormals]"
+ "\n\t\t: Create arbitrary set of points (npts) randomly distributed"
+ "\n\t\t: on spheric surface or within spheric volume (x y z r)."
+ "\n\t\t:"
+ "\n\t\t: Additional options:"
+ "\n\t\t: -randColor - generate random color per point"
+ "\n\t\t: -normals - generate normal per point (default)"
+ "\n\t\t: -noNormals - do not generate normal per point"
+ "\n",
+ __FILE__, VPointCloud, group);
+
+ theCommands.Add("vpriority",
+ "vpriority [-noupdate|-update] name [value]\n\t\t prints or sets the display priority for an object",
+ __FILE__,
+ VPriority, group);
}