diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index 2bdee5f579..c35661d2f0 100644 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -16,104 +16,113 @@ #include -#include #include #include -#include -#include -#include -#include +#include + #include -#include -#include -#include -#include #include -#include -#include -#include #include -#include -#include +#include +#include #include #include -#include -#include + #include #include #include #include #include #include +#include +#include #include + #include -#include + #include +#include #include #include #include #include #include -#include #include -IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron,AIS_InteractiveObject) +//#define POINT_SELECTION_MODE + +#define PATCH_TO_OCCT_710 + +IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject) + +static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode) +{ + TColStd_ListIteratorOfListOfInteger It(LL); + for (;It.More(); It.Next()){ + if (It.Value() == aMode) + return Standard_True; + } + return Standard_False; +} //======================================================================= //function : AIS_Trihedron //purpose : //======================================================================= -AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& aComponent): -myComponent (aComponent), -myHasOwnSize (Standard_False), -myHasOwnTextColor (Standard_False), -myHasOwnArrowColor (Standard_False) +AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent) +: myHasOwnSize(Standard_False), + myHasOwnTextColor(Standard_False), + myHasOwnArrowColor(Standard_False), + myComponent(theComponent), + myDisplayMode(Prs3d_DM_WireFrame) { - LoadSubObjects(); + // default presentation parameters + SetDisplayMode (0); + SetHilightMode (0); + + // datum creation + Handle (Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect(); + myDrawer->SetDatumAspect(aDatumAspect); + + // entities to provide custom selection + Quantity_Color aHighlightColor = Quantity_NOC_GRAY80; + myHighlightAspect = new Prs3d_ShadingAspect(); + myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID); + myHighlightAspect->SetColor(aHighlightColor); + Graphic3d_MaterialAspect aHighlightMaterial; + aHighlightMaterial.SetColor (aHighlightColor); + myHighlightAspect->SetMaterial (aHighlightMaterial); + + Handle(Prs3d_LineAspect) aLineAspect = aDatumAspect->LineAspect(Prs3d_DP_XAxis); + myHighlightLineAspect = new Prs3d_LineAspect(aHighlightColor, aLineAspect->Aspect()->Type(), + aLineAspect->Aspect()->Width()); + myHighlightPointAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, aHighlightColor, 1.0); + + // selection priorities + mySelectionPriority.Bind(Prs3d_DP_None, 5); // complete triedron: priority 5 (same as faces) + mySelectionPriority.Bind(Prs3d_DP_Origin, 8); // origin: priority 8 + for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++) + mySelectionPriority.Bind((Prs3d_DatumParts)i, 7); // axes: priority: 7 + for (int i = Prs3d_DP_XOYAxis; i <= Prs3d_DP_XOZAxis; i++) + mySelectionPriority.Bind((Prs3d_DatumParts)i, 5); // planes: priority: 5 + + // trihedron labels + myLabel.Bind(Prs3d_DP_XAxis, "X"); + myLabel.Bind(Prs3d_DP_YAxis, "Y"); + myLabel.Bind(Prs3d_DP_ZAxis, "Z"); + + Aspect_TypeOfMarker aPointMarker = Aspect_TOM_POINT; + myPointAspect = new Prs3d_PointAspect(aPointMarker, aHighlightColor, 0.1); } //======================================================================= //function : SetComponent //purpose : //======================================================================= - -void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& aComponent) +void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& theComponent) { - myComponent = aComponent; - - // Remove from current context and nullify objects to update - Handle(AIS_InteractiveContext) anAISContext = GetContext(); - Standard_Boolean hasContext = (anAISContext.IsNull() == Standard_False); - Standard_Integer anIdx; - for (anIdx = 0; anIdx < 7; anIdx++) - { - // Deselect object - if (hasContext) - { - if (anAISContext->IsSelected (myShapes[anIdx])) - anAISContext->AddOrRemoveSelected (myShapes[anIdx], Standard_False); - - anAISContext->Remove (myShapes[anIdx], Standard_False); - } - myShapes[anIdx].Nullify(); - } - - LoadSubObjects(); -} - -//======================================================================= -//function : setLocalTransformation -//purpose : -//======================================================================= - -void AIS_Trihedron::setLocalTransformation (const Handle(Geom_Transformation)& theTrsf) -{ - // Update location to the subshapes - Standard_Integer anIdx; - for (anIdx = 0; anIdx < 7; anIdx++) - myShapes[anIdx]->SetLocalTransformation (theTrsf); - - AIS_InteractiveObject::setLocalTransformation (theTrsf); + myComponent = theComponent; + LoadRecomputable (AIS_WireFrame); } //======================================================================= @@ -123,28 +132,17 @@ void AIS_Trihedron::setLocalTransformation (const Handle(Geom_Transformation)& t void AIS_Trihedron::SetSize(const Standard_Real aValue) { myHasOwnSize = Standard_True; - if(!myDrawer->HasOwnDatumAspect()){ - Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); - myDrawer->SetDatumAspect(DA); - } - - myDrawer->DatumAspect()->SetAxisLength(aValue,aValue,aValue); - - for(Standard_Integer i=4;i<=6;i++) - Handle(AIS_Plane)::DownCast (myShapes[i])->SetSize(aValue); + myDrawer->DatumAspect()->SetAxisLength(aValue, aValue, aValue); Update(); UpdateSelection(); } - - //======================================================================= //function : UnsetSize //purpose : if the object has 1 color, the default size of the // drawer is reproduced, otherwise DatumAspect becomes null //======================================================================= - void AIS_Trihedron::UnsetSize() { if(!myHasOwnSize) return; @@ -153,14 +151,11 @@ void AIS_Trihedron::UnsetSize() if(hasOwnColor){ const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() : new Prs3d_DatumAspect(); - myDrawer->DatumAspect()->SetAxisLength(DA->FirstAxisLength(), - DA->SecondAxisLength(), - DA->ThirdAxisLength()); + myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DP_XAxis), + DA->AxisLength(Prs3d_DP_YAxis), + DA->AxisLength(Prs3d_DP_ZAxis)); } else - { - myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)()); - } Update(); UpdateSelection(); @@ -173,498 +168,658 @@ void AIS_Trihedron::UnsetSize() Standard_Real AIS_Trihedron::Size() const { - return myDrawer->DatumAspect()->FirstAxisLength(); -} - -//======================================================================= -//function : XAxis -//purpose : -//======================================================================= -Handle(AIS_Axis) AIS_Trihedron::XAxis() const -{ - Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[1]); - if (anAxis.IsNull()) - { - anAxis = new AIS_Axis (myComponent,AIS_TOAX_XAxis); - } - return anAxis; -} - -//======================================================================= -//function : YAxis -//purpose : -//======================================================================= -Handle(AIS_Axis) AIS_Trihedron::YAxis() const -{ - Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[2]); - if (anAxis.IsNull()) - { - anAxis = new AIS_Axis (myComponent,AIS_TOAX_YAxis); - } - - return anAxis; -} - -//======================================================================= -//function : Axis -//purpose : -//======================================================================= -Handle(AIS_Axis) AIS_Trihedron::Axis() const -{ - Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[3]); - if (anAxis.IsNull()) - { - anAxis = new AIS_Axis (myComponent,AIS_TOAX_ZAxis); - } - return anAxis; -} - -//======================================================================= -//function : Position -//purpose : -//======================================================================= -Handle(AIS_Point) AIS_Trihedron::Position() const -{ - Handle(AIS_Point) aPt = Handle(AIS_Point)::DownCast(myShapes[0]); - if (aPt.IsNull()) { - gp_Pnt aPnt = myComponent->Ax2().Location(); - Handle(Geom_Point) aPoint = new Geom_CartesianPoint(aPnt); - aPt = new AIS_Point (aPoint); - } - return aPt; -} - -//======================================================================= -//function : XYPlane -//purpose : -//======================================================================= -Handle(AIS_Plane) AIS_Trihedron::XYPlane() const -{ - Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[4]); - if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_XYPlane); - return aPl; -} - -//======================================================================= -//function : XZPlane -//purpose : -//======================================================================= -Handle(AIS_Plane) AIS_Trihedron::XZPlane() const -{ - Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[5]); - if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_XZPlane); - return aPl; -} - -//======================================================================= -//function : YZPlane -//purpose : -//======================================================================= -Handle(AIS_Plane) AIS_Trihedron::YZPlane() const -{ - Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[6]); - if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_YZPlane); - return aPl; + return myDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis); } //======================================================================= //function : Compute //purpose : //======================================================================= -void AIS_Trihedron::Compute( - const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer aMode) +void AIS_Trihedron::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, + const Handle(Prs3d_Presentation)& thePrs, + const Standard_Integer /*theMode*/) { - aPresentation->SetInfiniteState (Standard_True); - switch(aMode){ - case 0: - DsgPrs_DatumPrs::Add(aPresentation,myComponent->Ax2(),myDrawer); - break; - case 1: - break; - case 2: - break; - } + thePrs->SetInfiniteState (Standard_True); + + gp_Ax2 anAxis(myComponent->Ax2()); + myDrawer->DatumAspect()->UpdatePrimitives(myDisplayMode, anAxis.Location(), + anAxis.XDirection(), anAxis.YDirection(), + anAxis.Direction()); + ComputePresentation (thePrsMgr, thePrs); } //======================================================================= //function : Compute -//purpose : +//purpose : //======================================================================= - -void AIS_Trihedron::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Geom_Transformation)& aTransformation, - const Handle(Prs3d_Presentation)& aPresentation) +void AIS_Trihedron::Compute (const Handle(Prs3d_Projector)& theProjector, + const Handle(Geom_Transformation)& theTrsf, + const Handle(Prs3d_Presentation)& thePrs) { -// Standard_NotImplemented::Raise("AIS_Trihedron::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ; + PrsMgr_PresentableObject::Compute (theProjector, theTrsf, thePrs); } //======================================================================= //function : ComputeSelection +//purpose : +//======================================================================= +void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) +{ + theSelection->Clear(); + + Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect(); + switch (theMode) + { + case 0: // complete triedron: only 1 owner + { + Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this, + mySelectionPriority.Find(Prs3d_DP_None)); + bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded; + for (int i = isShadingMode ? Prs3d_DP_Origin : Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)i; + if (!anAspect->DrawDatumPart(aPart)) + continue; + theSelection->Add (CreateSensitiveEntity(aPart, anOwner)); + } + } + break; + case 1: // origin + { + Prs3d_DatumParts aPart = Prs3d_DP_Origin; + if (anAspect->DrawDatumPart(aPart)) + { + Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, + mySelectionPriority.Find(aPart)); + Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = anAspect->ArrayOfPrimitives(aPart); + theSelection->Add (CreateSensitiveEntity(aPart, anOwner)); + } + } + break; + case 2: // axes + { + for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)i; + if (!anAspect->DrawDatumPart(aPart)) + continue; + Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, + mySelectionPriority.Find(aPart)); + theSelection->Add (CreateSensitiveEntity(aPart, anOwner)); + } + } + break; + case 3: // main planes + { + /// Creates Trihedron owner for each trihedron plane + { +#ifndef PATCH_TO_OCCT_710 + for (int i = Prs3d_DP_XOYAxis; i <= Prs3d_DP_XOZAxis; i++) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)i; + if (!anAspect->DrawDatumPart(aPart)) + continue; + Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, + mySelectionPriority.Find(aPart)); + theSelection->Add (CreateSensitiveEntity(aPart, anOwner)); + } +#endif + } + } + break; + default: + break; + } +} + +//======================================================================= +//function : IsAutoHilight +//purpose : +//======================================================================= +Standard_Boolean AIS_Trihedron::IsAutoHilight() const +{ + // highlight is processed in the current presentation + return false; +} + +//======================================================================= +//function : HilightOwnerWithColor +//purpose : +//======================================================================= +void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner) +{ + Handle(AIS_TrihedronOwner) anOwner = Handle(AIS_TrihedronOwner)::DownCast (theOwner); + if (anOwner.IsNull()) + { + /// default 0 selectin mode + Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0; + thePM->Color (this, theStyle, aHiMode, NULL, Graphic3d_ZLayerId_Top); + } + else { + Handle(Prs3d_Presentation) aPresentation = GetHilightPresentation(thePM); + if (!aPresentation.IsNull()) + { + aPresentation->Clear(); + const Prs3d_DatumParts& aPart = anOwner->DatumPart(); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation); + Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect(); + if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis) + { + // planes selection is equal in both shading and wireframe mode + aGroup->SetGroupPrimitivesAspect (myHighlightLineAspect->Aspect()); + } + else { + if (DatumDisplayMode() == Prs3d_DM_Shaded) + aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect()); + else { + if (aPart == Prs3d_DP_Origin) + aGroup->SetGroupPrimitivesAspect (myHighlightPointAspect->Aspect()); + else + aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect()); + } + } + aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart)); + + aPresentation->Highlight (theStyle); + thePM->AddToImmediateList (aPresentation); + } + } +} + +//======================================================================== +//function : HilightSelected +//purpose : +//======================================================================== +void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM, + const SelectMgr_SequenceOfOwner& theOwners) +{ + if (theOwners.IsEmpty() || GetContext().IsNull()) + { + return; + } + + Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect(); + bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded; + + SelectMgr_SequenceOfOwner::Iterator anIterator(theOwners); + +#ifndef PATCH_TO_OCCT_710 + const Handle(Prs3d_Drawer)& aContextSelStyle = GetContext()->SelectionStyle(); + const Quantity_Color& aSelectionColor = aContextSelStyle->Color(); +#else + const Quantity_Color& aSelectionColor = GetContext()->SelectionStyle()->Color(); +#endif + for (; anIterator.More(); anIterator.Next()) + { + const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value(); + if (!anOwner->IsKind (STANDARD_TYPE (AIS_TrihedronOwner))) + { +#ifdef PATCH_TO_OCCT_710 + thePM->Color (this, GetContext()->SelectionStyle(), 0); +#else + thePM->Color (this, aContextSelStyle, 0); +#endif + } + else + { + Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast + (anOwner); + const Prs3d_DatumParts& aPart = aTrihedronOwner->DatumPart(); + if (mySelectedParts.Contains(aPart)) + { + // the owner has been already selected + continue; + } + Handle(Graphic3d_Group) aGroup; + if (!myPartToGroup.Find(aTrihedronOwner->DatumPart(), aGroup) ) + { + // graphical group for this owner was not created + continue; + } + + if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis) { + Handle(Prs3d_LineAspect) aLineAspect = myHighlightLineAspect; + aLineAspect->SetColor(aSelectionColor); + aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect()); + } + else { + if (isShadingMode) { + Handle(Prs3d_ShadingAspect) aShadingAspect = myHighlightAspect; + aShadingAspect->SetColor(aSelectionColor); + aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect()); + } + else { + if (aPart == Prs3d_DP_Origin) { +#ifndef POINT_SELECTION_MODE +#ifdef PATCH_TO_OCCT_710 + myPointAspect->SetColor(aSelectionColor); + myPointAspect->SetTypeOfMarker(Aspect_TOM_PLUS); +#else + Handle(Prs3d_PointAspect) aPointAspect = myHighlightPointAspect; + aPointAspect->SetColor(aSelectionColor); + aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect()); +#endif +#else + anAspect->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS); +#endif + } + else { + Handle(Prs3d_LineAspect) aLineAspect = myHighlightLineAspect; + aLineAspect->SetColor(aSelectionColor); + aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect()); + } + } + } + mySelectedParts.Append(aPart); + } + } + SynchronizeAspects(); +} + +//======================================================================= +//function : ClearSelected +//purpose : +//======================================================================= +void AIS_Trihedron::ClearSelected() +{ + NCollection_List::Iterator anIterator(mySelectedParts); + Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect(); + bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded; + for (; anIterator.More(); anIterator.Next()) + { + Prs3d_DatumParts aPart = anIterator.Value(); + Handle(Graphic3d_Group) aGroup = myPartToGroup.Find(aPart); + if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis) { + aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect()); + } + if (isShadingMode) + aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect()); + else { + if (aPart == Prs3d_DP_Origin) { +#ifndef POINT_SELECTION_MODE +#ifdef PATCH_TO_OCCT_710 + myPointAspect->SetTypeOfMarker(Aspect_TOM_POINT); + aGroup->SetGroupPrimitivesAspect(myPointAspect->Aspect()); +#else + aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect()); +#endif +#else + anAspect->PointAspect()->SetTypeOfMarker(Aspect_TOM_EMPTY); + SynchronizeAspects(); +#endif + } + else + aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect()); + } + } + mySelectedParts.Clear(); +} + +//======================================================================= +//function : ComputePresentation +//purpose : +//======================================================================= +void AIS_Trihedron::ComputePresentation (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/, + const Handle(Prs3d_Presentation)& thePrs) +{ + myPartToGroup.Clear(); + Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect(); + bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded; + // display origin + { + // Origin is visualized only in shading mode + Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs); + Prs3d_DatumParts aPart = Prs3d_DP_Origin; +#ifdef PATCH_TO_OCCT_710 + // Origin is visualized only in shading mode + //Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs); + //Prs3d_DatumParts aPart = Prs3d_DP_Origin; + myPartToGroup.Bind(aPart, aGroup); + if (isShadingMode) + aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect()); + else + aGroup->SetGroupPrimitivesAspect(myPointAspect->Aspect()); + aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart)); +#else + if (anAspect->DrawDatumPart(aPart)) { + myPartToGroup.Bind(aPart, aGroup); + if (isShadingMode) + aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect()); + else { + aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect()); + } + aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart)); + } +#endif + } + + // display axes + { + for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; ++anAxisIter) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; + if (!anAspect->DrawDatumPart(aPart)) + continue; + { + Handle(Graphic3d_Group) anAxisGroup = Prs3d_Root::NewGroup (thePrs); + myPartToGroup.Bind(aPart, anAxisGroup); + if (isShadingMode) + anAxisGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect()); + else + anAxisGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect()); + anAxisGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart)); + + // draw arrow + Handle(Graphic3d_Group) anArrowGroup = Prs3d_Root::NewGroup (thePrs); + anArrowGroup->SetPrimitivesAspect(anAspect->ArrowAspect()->Aspect()); + + Prs3d_DatumParts anArrowPart = anAspect->ArrowPartForAxis(aPart); + if (!anAspect->DrawDatumPart(anArrowPart)) + continue; + anArrowGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(anArrowPart)); + } + } + } + // display labels + if (anAspect->ToDrawLabels()) + { + Handle(Geom_Axis2Placement) aComponent = myComponent; + gp_Pnt anOrigin = aComponent->Location(); + for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; ++anAxisIter) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; + if (!anAspect->DrawDatumPart(aPart)) + continue; + Standard_Real anAxisLength = anAspect->AxisLength(aPart); + TCollection_ExtendedString aLabel = myLabel.Find(aPart); + gp_Dir aDir; + switch (aPart) + { + case Prs3d_DP_XAxis: aDir = aComponent->XDirection(); break; + case Prs3d_DP_YAxis: aDir = aComponent->YDirection(); break; + case Prs3d_DP_ZAxis: aDir = aComponent->Direction(); break; + default: break; + } + Handle(Graphic3d_Group) aLabelGroup = Prs3d_Root::NewGroup (thePrs); + gp_Pnt aPoint = anOrigin.XYZ() + aDir.XYZ()*anAxisLength; + Prs3d_Text::Draw (aLabelGroup, anAspect->TextAspect(), aLabel, aPoint); + } + } + // planes invisible group for planes selection + /// plane selection mode is available only in wireframe mode +#ifndef PATCH_TO_OCCT_710 + for (Standard_Integer anAxisIter = Prs3d_DP_XOYAxis; anAxisIter <= Prs3d_DP_XOZAxis; ++anAxisIter) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; + if (!anAspect->DrawDatumPart(aPart)) + continue; + { + Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs); + myPartToGroup.Bind(aPart, aGroup); + + const Handle(Graphic3d_AspectLine3d)& aLineAspect = anAspect->LineAspect(aPart)->Aspect(); + aLineAspect->SetType(Aspect_TOL_EMPTY); + + aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart)); + aGroup->SetGroupPrimitivesAspect (aLineAspect); + } + } +#endif +} + +//======================================================================= +//function : LoadRecomputable //purpose : //======================================================================= -void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) +void AIS_Trihedron::LoadRecomputable(const Standard_Integer TheMode) { - // retrieve the tops of the trihedron. - Standard_Integer Prior, anIdx; - Handle(SelectMgr_EntityOwner) eown; - TColgp_Array1OfPnt PP(1,4),PO(1,4); - ExtremityPoints(PP); + myRecomputeEveryPrs = Standard_False; + if(!IsInList(myToRecomputeModes,TheMode)) + myToRecomputeModes.Append(TheMode); +} - // remove shapes from active selections - Handle(AIS_InteractiveContext) anAISContext = GetContext(); - if (!anAISContext.IsNull()) - for (anIdx = 0; anIdx < 7; anIdx++) - { - // Deselect object - if (anAISContext->IsSelected (myShapes[anIdx])) - anAISContext->AddOrRemoveSelected (myShapes[anIdx], Standard_False); +//======================================================================= +//function : SetColor +//purpose : +//======================================================================= - anAISContext->Remove (myShapes[anIdx], Standard_False); - } - - switch (aMode) { - case 0: - { // complete triedron only 1 owner : this... priority 5 (same as faces) - Prior = 5; - eown = new SelectMgr_EntityOwner(this,Prior); - for (Standard_Integer i=1; i<=3;i++) - aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1))); - break; - } - case 1: - { //origin : - Prior = 8; - const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity - eown= new SelectMgr_EntityOwner(anObj,Prior); - - aSelection->Add(new Select3D_SensitivePoint (eown,myComponent->Location())); - // If the trihedron's shapes display and selection modes are the same - // the shapes are still displayed after selection, so we need to - // use different presentation and hide it by nullifying - if (!anAISContext.IsNull()) - { - anAISContext->Display (myShapes[0], 1, 0, Standard_False); - anAISContext->ClearPrs (myShapes[0], 1, Standard_False); - } - - break; - } - case 2: - { //axes ... priority 7 - Prior = 7; - for (Standard_Integer i=1; i<=3;i++){ - const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity - eown= new SelectMgr_EntityOwner(anObj,Prior); - aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1))); +void AIS_Trihedron::SetColor (const Prs3d_DatumParts& thePart, + const Quantity_Color& theColor) +{ + myDrawer->DatumAspect()->ShadingAspect(thePart)->SetColor(theColor); + if (thePart != Prs3d_DP_Origin) + myDrawer->DatumAspect()->LineAspect(thePart)->SetColor(theColor); +} - } +//======================================================================= +//function : SetTextColor +//purpose : +//======================================================================= - // If the trihedron's shapes display and selection modes are the same - // the shapes are still displayed after selection, so we need to - // use different presentation and hide it by nullifying - AIS_TypeOfAxis anAxisType; - if (!anAISContext.IsNull()) - for (anIdx = 1; anIdx <= 3; anIdx++) - { - // update AIS_Axis for selection - Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[anIdx]); - Handle(Prs3d_Drawer) aDrawer = anAxis->Attributes(); - Handle(Prs3d_DatumAspect) aDatum = myDrawer->DatumAspect(); - aDrawer->SetDatumAspect (aDatum); - anAxisType = anAxis->TypeOfAxis(); - anAxis->SetAxis2Placement (myComponent, anAxisType); +void AIS_Trihedron::SetTextColor (const Quantity_NameOfColor theColor) +{ + SetTextColor(Quantity_Color(theColor)); +} - // display - anAISContext->Display (myShapes[anIdx], 1, 0, Standard_False); - anAISContext->ClearPrs (myShapes[anIdx], 1, Standard_False); - } - - break; - } - - case 3: - { // main planes priority 6 -// PO(1) = PP(1); -// PO(4) = PP(1); - Prior =5; - - - const Handle(SelectMgr_SelectableObject)& anObj4 = myShapes[4]; // to avoid ambiguity - eown= new SelectMgr_EntityOwner(anObj4,Prior); -// PO(2) = PP(2);PO(3) = PP(3); - aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(3))); +//======================================================================= +//function : SetTextColor +//purpose : +//======================================================================= - const Handle(SelectMgr_SelectableObject)& anObj5 = myShapes[5]; // to avoid ambiguity - eown= new SelectMgr_EntityOwner(anObj5,Prior); -// PO(2) = PP(3);PO(3) = PP(4); - aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(4))); +void AIS_Trihedron::SetTextColor (const Quantity_Color& theColor) +{ + myDrawer->DatumAspect()->TextAspect()->SetColor(theColor); +} - const Handle(SelectMgr_SelectableObject)& anObj6 = myShapes[6]; // to avoid ambiguity - eown= new SelectMgr_EntityOwner(anObj6,Prior); -// PO(2) = PP(4);PO(3) = PP(2); - aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(3),PP(4))); - - // If the trihedron's shapes display and selection modes are the same - // the shapes are still displayed after selection, so we need to - // use different presentation and hide it by nullifying - if (!anAISContext.IsNull()) - for (anIdx = 4; anIdx < 7; anIdx++) - { - anAISContext->Display (myShapes[anIdx], 1, 0, Standard_False); - anAISContext->ClearPrs (myShapes[anIdx], 1, Standard_False); - } - } +Quantity_Color AIS_Trihedron::Color (const Prs3d_DatumParts& thePart) +{ + Quantity_Color aColor; + if (DatumDisplayMode() == Prs3d_DM_Shaded) + { + aColor = myDrawer->DatumAspect()->ShadingAspect(thePart)->Color(); } - + else + { + aColor = myDrawer->DatumAspect()->LineAspect(thePart)->Aspect()->Color(); + } + return aColor; +} + +//======================================================================= +//function : SetOriginColor +//purpose : +//======================================================================= +void AIS_Trihedron::SetOriginColor (const Quantity_Color& theColor) +{ + if (DatumDisplayMode() == Prs3d_DM_Shaded) + { + SetColor(Prs3d_DP_Origin, theColor); + } +} + +//======================================================================= +//function : SetXAxisColor +//purpose : +//======================================================================= +void AIS_Trihedron::SetXAxisColor (const Quantity_Color& theColor) +{ + SetColor(Prs3d_DP_XAxis, theColor); +} + +//======================================================================= +//function : SetYAxisColor +//purpose : +//======================================================================= +void AIS_Trihedron::SetYAxisColor (const Quantity_Color& theColor) +{ + SetColor(Prs3d_DP_YAxis, theColor); +} + +//======================================================================= +//function : SetAxisColor +//purpose : +//======================================================================= +void AIS_Trihedron::SetAxisColor (const Quantity_Color& theColor) +{ + SetColor(Prs3d_DP_ZAxis, theColor); } //======================================================================= //function : SetColor //purpose : //======================================================================= - -void AIS_Trihedron::SetColor(const Quantity_NameOfColor aCol) +void AIS_Trihedron::SetColor (const Quantity_NameOfColor theColor) { - SetColor(Quantity_Color(aCol)); + SetColor(Quantity_Color(theColor)); } -void AIS_Trihedron::SetColor(const Quantity_Color &aCol) +void AIS_Trihedron::SetColor (const Quantity_Color& theColor) { - hasOwnColor=Standard_True; - myOwnColor = aCol; - - if(!myDrawer->HasOwnDatumAspect()){ - Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); - - DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(), - myDrawer->DatumAspect()->SecondAxisLength(), - myDrawer->DatumAspect()->ThirdAxisLength()); - myDrawer->SetDatumAspect(DA); - } - myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(aCol); - myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(aCol); - myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(aCol); - + hasOwnColor = Standard_True; +#ifndef PATCH_TO_OCCT_710 + myDrawer->SetColor(theColor); +#endif + SetColor(Prs3d_DP_Origin, theColor); + SetColor(Prs3d_DP_XAxis, theColor); + SetColor(Prs3d_DP_YAxis, theColor); + SetColor(Prs3d_DP_ZAxis, theColor); } -//======================================================================= -//function : SetTextColor -//purpose : -//======================================================================= - -void AIS_Trihedron::SetTextColor(const Quantity_NameOfColor aCol) +void AIS_Trihedron::SetArrowColor (const Quantity_NameOfColor theColor) { - myHasOwnTextColor = Standard_True; - myOwnTextColor = aCol; - - if(!myDrawer->HasOwnDatumAspect()){ - Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); - - DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(), - myDrawer->DatumAspect()->SecondAxisLength(), - myDrawer->DatumAspect()->ThirdAxisLength()); - myDrawer->SetDatumAspect(DA); - } - Handle(Prs3d_TextAspect) aspect = myDrawer->TextAspect(); - aspect->SetColor(aCol); - myDrawer->SetTextAspect(aspect); + SetArrowColor(Quantity_Color(theColor)); } -void AIS_Trihedron::SetArrowColor(const Quantity_NameOfColor aCol) +void AIS_Trihedron::SetArrowColor (const Quantity_Color& theColor) { myHasOwnArrowColor = Standard_True; - myOwnArrowColor = aCol; - - if(!myDrawer->HasOwnDatumAspect()){ - Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); - - DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(), - myDrawer->DatumAspect()->SecondAxisLength(), - myDrawer->DatumAspect()->ThirdAxisLength()); - myDrawer->SetDatumAspect(DA); - } - Handle(Prs3d_ArrowAspect) aspect = myDrawer->ArrowAspect(); - aspect->SetColor(aCol); - myDrawer->SetArrowAspect(aspect); + myDrawer->DatumAspect()->ArrowAspect()->SetColor(theColor); } //======================================================================= -Standard_Boolean AIS_Trihedron::HasTextColor() const { - +Standard_Boolean AIS_Trihedron::HasTextColor() const +{ return myHasOwnTextColor; } //======================================================================= -Quantity_NameOfColor AIS_Trihedron::TextColor() const { - - return myOwnTextColor; +Quantity_Color AIS_Trihedron::TextColor() const +{ + return myDrawer->DatumAspect()->TextAspect()->Aspect()->Color(); } //======================================================================= -Standard_Boolean AIS_Trihedron::HasArrowColor() const { - +Standard_Boolean AIS_Trihedron::HasArrowColor () const +{ return myHasOwnArrowColor; } //======================================================================= -Quantity_NameOfColor AIS_Trihedron::ArrowColor() const { - - return myOwnArrowColor; -} - - -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Trihedron::Compute(const Handle(Prs3d_Projector)&, - const Handle(Prs3d_Presentation)&) +Quantity_Color AIS_Trihedron::ArrowColor () const { + return myDrawer->DatumAspect()->ArrowAspect()->Aspect()->Color(); } + //======================================================================= //function : Type //purpose : //======================================================================= - -AIS_KindOfInteractive AIS_Trihedron::Type() const -{return AIS_KOI_Datum;} +AIS_KindOfInteractive AIS_Trihedron::Type () const +{ + return AIS_KOI_Datum; +} //======================================================================= //function : Signature //purpose : //======================================================================= - - Standard_Integer AIS_Trihedron::Signature() const -{return 3;} - -//======================================================================= -//function : ExtremityPoints -//purpose : to avoid warning -//======================================================================= -void AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const + Standard_Integer AIS_Trihedron::Signature () const { - gp_Ax2 theax(myComponent->Ax2()); - PP(1) = theax.Location(); - - Standard_Real len = myDrawer->DatumAspect()->FirstAxisLength(); - gp_Vec vec = theax.XDirection(); - vec *= len; - PP(2) = PP(1).Translated(vec); - - len = myDrawer->DatumAspect()->SecondAxisLength(); - vec = theax.YDirection(); - vec *= len; - PP(3) = PP(1).Translated(vec); - - len = myDrawer->DatumAspect()->ThirdAxisLength(); - vec = theax.Direction(); - vec *= len; - PP(4) = PP(1).Translated(vec); -} + return 3; + } //======================================================================= //function : AcceptDisplayMode //purpose : //======================================================================= - - Standard_Boolean AIS_Trihedron:: -AcceptDisplayMode(const Standard_Integer aMode) const -{return aMode == 0;} - - +Standard_Boolean AIS_Trihedron::AcceptDisplayMode (const Standard_Integer theMode) const +{ + return theMode == AIS_WireFrame || theMode == AIS_Shaded; +} //======================================================================= //function : UnsetColor //purpose : //======================================================================= - void AIS_Trihedron::UnsetColor() { hasOwnColor=Standard_False; - myOwnColor = Quantity_NOC_LIGHTSTEELBLUE4; - myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(myOwnColor); - myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(myOwnColor); - myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(myOwnColor); - if( HasTextColor() ) { - SetTextColor(myOwnColor.Name()); + Quantity_Color aDefaultColor = Quantity_NOC_LIGHTSTEELBLUE4; + SetColor(aDefaultColor); + if( HasTextColor() ) + { + SetTextColor(aDefaultColor.Name()); myHasOwnTextColor = Standard_False; } - if( HasArrowColor() ) { - SetArrowColor(myOwnColor.Name()); + if( HasArrowColor() ) + { + SetArrowColor(aDefaultColor.Name()); myHasOwnArrowColor = Standard_False; } - } -//======================================================================= -//function : UnsetWitdth -//purpose : -//======================================================================= - -void AIS_Trihedron::UnsetWidth() +Handle(SelectBasics_SensitiveEntity) AIS_Trihedron::CreateSensitiveEntity( + const Prs3d_DatumParts& thePart, + const Handle(SelectBasics_EntityOwner)& theOwner) const { - myOwnWidth =0.0; - myDrawer->DatumAspect()->FirstAxisAspect()->SetWidth(1.); - myDrawer->DatumAspect()->SecondAxisAspect()->SetWidth(1.); - myDrawer->DatumAspect()->ThirdAxisAspect()->SetWidth(1.); + Handle(SelectBasics_SensitiveEntity) aSelectEntity; -} -void AIS_Trihedron::LoadSubObjects() -{ - myShapes[0] = Position(); - myShapes[1] = XAxis(); - myShapes[2] = YAxis(); - myShapes[3] = Axis(); - myShapes[4] = XYPlane(); - myShapes[5] = XZPlane(); - myShapes[6] = YZPlane(); -} + Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect(); + Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = anAspect->ArrayOfPrimitives(thePart); + if (aPrimitives.IsNull()) + return aSelectEntity; -//======================================================================= -//function : SetContext -//purpose : -//======================================================================= - -void AIS_Trihedron::SetContext(const Handle(AIS_InteractiveContext)& Ctx) -{ -// Standard_Boolean same_DA = myDrawer->Link() == Ctx->DefaultDrawer(); - - if( Ctx.IsNull()) - { - Standard_Integer anIdx; - for (anIdx = 0; anIdx < 7; anIdx++) - { - myShapes[anIdx]->SetContext(Ctx); - } - AIS_InteractiveObject::SetContext (Ctx); - return; - } - // Remove subobjects from current context - Handle(AIS_InteractiveContext) anAISContext = GetContext(); - - Standard_Boolean hasContext = (anAISContext.IsNull() == Standard_False); - Standard_Integer anIdx; - for (anIdx = 0; anIdx < 7; anIdx++) +#ifndef PATCH_TO_OCCT_710 + if (thePart >= Prs3d_DP_XOYAxis && thePart <= Prs3d_DP_XOZAxis) + { // plane + Standard_Real aX1, anY1, aZ1, aX2, anY2, aZ2, aX3, anY3, aZ3; + aPrimitives->Vertice(1, aX1, anY1, aZ1); + aPrimitives->Vertice(2, aX2, anY2, aZ2); + aPrimitives->Vertice(3, aX3, anY3, aZ3); + aSelectEntity = new Select3D_SensitiveTriangle(theOwner, gp_Pnt(aX1, anY1, aZ1), + gp_Pnt(aX2, anY2, aZ2), gp_Pnt(aX3, anY3, aZ3)); + } + else if (DatumDisplayMode() == Prs3d_DM_Shaded) +#else + if (DatumDisplayMode() == Prs3d_DM_Shaded) +#endif + { + Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray + (theOwner); + aSelArray->InitTriangulation (aPrimitives->Attributes(), aPrimitives->Indices(), + TopLoc_Location()); + aSelectEntity = aSelArray; + } + else { + if (!Handle(Graphic3d_ArrayOfPoints)::DownCast(aPrimitives).IsNull()) { - // Deselect object - if (hasContext) - { - if (anAISContext->IsSelected (myShapes[anIdx])) - anAISContext->AddOrRemoveSelected (myShapes[anIdx]); - - anAISContext->Remove (myShapes[anIdx], Standard_False); - } - myShapes[anIdx].Nullify(); + Standard_Real aX, anY, aZ; + aPrimitives->Vertice(1, aX, anY, aZ); + aSelectEntity = new Select3D_SensitivePoint(theOwner, gp_Pnt(aX, anY, aZ)); } - - AIS_InteractiveObject::SetContext (Ctx); - LoadSubObjects(); - for(Standard_Integer i= 0;i<=6;i++) - myShapes[i]->SetContext (Ctx); + else if (!Handle(Graphic3d_ArrayOfSegments)::DownCast(aPrimitives).IsNull()) + { + Standard_Real aX1, anY1, aZ1, aX2, anY2, aZ2; + aPrimitives->Vertice(1, aX1, anY1, aZ1); + aPrimitives->Vertice(2, aX2, anY2, aZ2); + aSelectEntity = new Select3D_SensitiveSegment(theOwner, gp_Pnt(aX1, anY1, aZ1), + gp_Pnt(aX2, anY2, aZ2)); + } + } + return aSelectEntity; } diff --git a/src/AIS/AIS_Trihedron.hxx b/src/AIS/AIS_Trihedron.hxx index 980b3e9371..0a691940dd 100644 --- a/src/AIS/AIS_Trihedron.hxx +++ b/src/AIS/AIS_Trihedron.hxx @@ -17,18 +17,31 @@ #ifndef _AIS_Trihedron_HeaderFile #define _AIS_Trihedron_HeaderFile -#include -#include - -#include -#include #include -#include -#include -#include -#include #include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + #include + class Geom_Axis2Placement; class AIS_InteractiveObject; class AIS_Axis; @@ -46,26 +59,24 @@ class AIS_Trihedron; DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject) //! Create a selectable trihedron -//! there are 4 modes of selection : -//! mode = 0 to select trihedron ,priority = 1 -//! mode = 1 to select its origin ,priority = 5 -//! mode = 2 to select its axis ,priority = 3 -//! mode = 3 to select its planes ,priority = 2 -//! a trihedron has 1 origin, 3 axes and 3 planes. +//! The trihedron includes 1 origin, 3 axes and 3 labels. +//! Default text of labels are "X", "Y", "Z". +//! Color of origin and any axis, color of arrows and labels may be changed. +//! Visual presentation might be shown in two, shading and wireframe modes(wireframe by default) +//! There are 4 modes of selection : +//! mode = 0 to select trihedron, priority = 1 +//! mode = 1 to select its origin, priority = 5 +//! mode = 2 to select its axis, priority = 3 +//! mode = 3 to select its planes, priority = 2 //! Warning -//! For the presentation of trihedra, the default unit of -//! length is the millimeter, and the default value for the -//! representation of axes is 10. To modify these +//! For the presentation of trihedron, the default unit of +//! length is the millimetre, and the default value for the +//! representation of the axes is 100. If you modify these //! dimensions, you must temporarily recover the Drawer. //! From inside it, you take the aspect in which the values -//! for length are stocked. For trihedra, this is FirstAxisLength from -//! Prs3d_DatumAspect(). Change the +//! for length are stocked. For trihedron, this is +//! Prs3d_Drawer_LineAspect. You change the //! values inside this Aspect and recalculate the presentation. -//! If you want to use extended selection modes, different than 0, -//! you should take care of removing of the shapes from the interactive -//! context that has been computed for selection; it might be necessary -//! when you change selection mode. You can use methods Axis, Point, -//! Plane to retrieve the shapes. class AIS_Trihedron : public AIS_InteractiveObject { DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject) @@ -75,18 +86,24 @@ public: //! Initializes a trihedron entity. Standard_EXPORT AIS_Trihedron(const Handle(Geom_Axis2Placement)& aComponent); + //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively. + Standard_EXPORT void SetDatumDisplayMode(const Prs3d_DatumMode& theMode) { myDisplayMode = theMode; } + + //! Returns datum display mode. + Standard_EXPORT Prs3d_DatumMode DatumDisplayMode() const { return myDisplayMode; } + //! Returns the right-handed coordinate system set in SetComponent. - const Handle(Geom_Axis2Placement)& Component() const; - + Standard_EXPORT const Handle(Geom_Axis2Placement)& Component() const { return myComponent; } + //! Constructs the right-handed coordinate system aComponent. - Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& aComponent); - + Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& theComponent); + //! Returns true if the trihedron object has a size other - //! than the default size of 10 mm. along each axis. - Standard_Boolean HasOwnSize() const; - + //! than the default size of 100 mm. along each axis. + Standard_Boolean HasOwnSize() const; + //! Sets the size aValue for the trihedron object. - //! The default value is 10 mm. + //! The default value is 100 mm. Standard_EXPORT void SetSize (const Standard_Real aValue); //! Removes any non-default settings for size of this @@ -95,43 +112,9 @@ public: Standard_EXPORT Standard_Real Size() const; - //! Returns the "XAxis". - Standard_EXPORT Handle(AIS_Axis) XAxis() const; - - //! Returns the "YAxis". - Standard_EXPORT Handle(AIS_Axis) YAxis() const; - - //! Returns the main Axis. - Standard_EXPORT Handle(AIS_Axis) Axis() const; - - //! Returns the origine. - Standard_EXPORT Handle(AIS_Point) Position() const; - - //! Returns the "XYPlane". - Standard_EXPORT Handle(AIS_Plane) XYPlane() const; - - //! Returns the "XZPlane". - Standard_EXPORT Handle(AIS_Plane) XZPlane() const; - - //! Returns the "YZPlane". - Standard_EXPORT Handle(AIS_Plane) YZPlane() const; - - //! connection to default drawer implies a recomputation - //! of SubObjects values. - Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx) Standard_OVERRIDE; - //! Returns true if the display mode selected, aMode, is //! valid for trihedron datums. Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE; - - //! Computes the presentation according to a point of view - //! given by . - //! To be Used when the associated degenerated Presentations - //! have been transformed by which is not a Pure - //! Translation. The HLR Prs can't be deducted automatically - //! WARNING : must be applied - //! to the object to display before computation !!! - Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; //! Returns index 3, selection of the planes XOY, YOZ, XOZ. Standard_EXPORT virtual Standard_Integer Signature() const Standard_OVERRIDE; @@ -139,63 +122,154 @@ public: //! Indicates that the type of Interactive Object is datum. Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE; - Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor) Standard_OVERRIDE; - - //! Sets the color aColor for this trihedron object. - Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; - - Standard_EXPORT void SetTextColor (const Quantity_NameOfColor aColor); + //! Sets the color theColor for this trihedron object, it changes color of axes. + Standard_EXPORT void SetColor (const Quantity_NameOfColor theColor) Standard_OVERRIDE; + + //! Sets the color theColor for this trihedron object, it changes color of axes. + Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; + //! Sets color of label of trihedron axes. + Standard_EXPORT void SetTextColor (const Quantity_NameOfColor theColor); + + //! Sets color of label of trihedron axes. + Standard_EXPORT void SetTextColor (const Quantity_Color& theColor); + + //! Returns true if trihedron has own text color Standard_EXPORT Standard_Boolean HasTextColor() const; - Standard_EXPORT Quantity_NameOfColor TextColor() const; - - Standard_EXPORT void SetArrowColor (const Quantity_NameOfColor aColor); + //! Returns trihedron text color + Standard_EXPORT Quantity_Color TextColor() const; + + //! Sets color of arrow of trihedron axes. Used only in wireframe mode + Standard_EXPORT void SetArrowColor (const Quantity_NameOfColor theColor); + //! Sets color of arrow of trihedron axes. Used only in wireframe mode + Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor); + + //! Returns true if trihedron has own arrow color Standard_EXPORT Standard_Boolean HasArrowColor() const; - Standard_EXPORT Quantity_NameOfColor ArrowColor() const; - - //! Returns the four extremities of the trihedron from the - //! array of points, TheExtrem. - Standard_EXPORT void ExtremityPoints (TColgp_Array1OfPnt& TheExtrem) const; + //! Returns trihedron arrow color + Standard_EXPORT Quantity_Color ArrowColor() const; //! Removes the settings for color. Standard_EXPORT void UnsetColor() Standard_OVERRIDE; - //! Removes the non-default settings for width set in SetWidth. - Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; + //! Sets color of datum part: origin or some of trihedron axes. + //! If presentation is shading mode, this color is set for both sides of facing model + Standard_EXPORT void SetColor (const Prs3d_DatumParts& thePart, + const Quantity_Color& theColor); + + //! Returns color of datum part: origin or some of trihedron axes. + Standard_EXPORT Quantity_Color Color (const Prs3d_DatumParts& thePart); + + //! Sets color of origin. + //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") + Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor); + + //! Sets color of x-axis. + //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") + Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor); + + //! Sets color of y-axis. + //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") + Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor); + + //! Sets color of z-axis. + //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") + Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor); + + //! Sets priority of selection for owner of the given type + Standard_EXPORT void SetSelectionPriority(const Prs3d_DatumParts& thePart, const Standard_Integer thePriority) + { + mySelectionPriority.Bind(thePart, thePriority); + } + + //! Sets priority of selection for owner of the given type + Standard_EXPORT Standard_Integer SelectionPriority(const Prs3d_DatumParts& thePart) + { + return mySelectionPriority.Find(thePart); + } + + //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis + Standard_EXPORT void SetLabel(const Prs3d_DatumParts& thePart, const TCollection_ExtendedString& thePriority) + { + myLabel.Bind(thePart, thePriority); + } + + //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis + Standard_EXPORT const TCollection_ExtendedString& Label(const Prs3d_DatumParts& thePart) + { + return myLabel.Find(thePart); + } + +public: + + //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods. + Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE; + + //! Method which clear all selected owners belonging + //! to this selectable object ( for fast presentation draw ). + Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; + + //! Method which draws selected owners ( for fast presentation draw ). + Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM, + const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE; + + //! Method which hilight an owner belonging to + //! this selectable object ( for fast presentation draw ). + Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner); protected: - Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE; + //! Compute trihedron presentation. + Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, + const Handle(Prs3d_Presentation)& thePrs, + const Standard_Integer theMode) Standard_OVERRIDE; -private: + //! This compute is unavailable for trihedron presentation. + void Compute (const Handle(Prs3d_Projector)& , const Handle(Prs3d_Presentation)& ) Standard_OVERRIDE {} - Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE; - - Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; - - Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE; - - Standard_EXPORT void LoadSubObjects(); + //! This compute is unavailable for trihedron presentation. + Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector, + const Handle(Geom_Transformation)& theTrsf, + const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE; + + //! Compute selection. + Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) Standard_OVERRIDE; + + //! Computes presentation for display mode equal 1. + Standard_EXPORT void ComputePresentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, + const Handle(Prs3d_Presentation)& thePrs); + + Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode); + + //! Created a sensitive entity for the datum part that will be used in selection owner creation + Handle(SelectBasics_SensitiveEntity) CreateSensitiveEntity(const Prs3d_DatumParts& thePart, + const Handle(SelectBasics_EntityOwner)& theOwner) const; protected: - - Handle(Geom_Axis2Placement) myComponent; - Handle(AIS_InteractiveObject) myShapes[7]; Standard_Boolean myHasOwnSize; Standard_Boolean myHasOwnTextColor; - Quantity_NameOfColor myOwnTextColor; Standard_Boolean myHasOwnArrowColor; - Quantity_NameOfColor myOwnArrowColor; + + Prs3d_DatumMode myDisplayMode; + Handle(Geom_Axis2Placement) myComponent; + + NCollection_DataMap mySelectionPriority; + NCollection_DataMap myLabel; + + NCollection_DataMap myPartToGroup; + NCollection_List mySelectedParts; + + Handle(Prs3d_PointAspect) myPointAspect; + + Handle(Prs3d_ShadingAspect) myHighlightAspect; // internal container to set group selected + Handle(Prs3d_LineAspect) myHighlightLineAspect; // internal container to set group selected + Handle(Prs3d_PointAspect) myHighlightPointAspect; // internal container to set group selected }; - -#include - - - - - #endif // _AIS_Trihedron_HeaderFile diff --git a/src/AIS/AIS_TrihedronOwner.cxx b/src/AIS/AIS_TrihedronOwner.cxx new file mode 100644 index 0000000000..5a60f0f8f4 --- /dev/null +++ b/src/AIS/AIS_TrihedronOwner.cxx @@ -0,0 +1,66 @@ +// Created by: Ilya SEVRIKOV +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +IMPLEMENT_STANDARD_RTTIEXT (AIS_TrihedronOwner, SelectMgr_EntityOwner) + +AIS_TrihedronOwner::AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, + const Prs3d_DatumParts thePart, + const Standard_Integer thePriority) +: SelectMgr_EntityOwner (theSelObject, thePriority), + myDatumPart (thePart) +{ +} + +//======================================================================= +//function : HilightWithColor +//purpose : +//======================================================================= +void AIS_TrihedronOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer /*theMode*/) +{ + Selectable()->HilightOwnerWithColor (thePM, theStyle, this); +} + +//======================================================================= +//function : IsHilighted +//purpose : +//======================================================================= +Standard_Boolean AIS_TrihedronOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) const +{ + if (!HasSelectable()) + { + return Standard_False; + } + + return thePM->IsHighlighted (Selectable(), theMode); +} + +//======================================================================= +//function : Unhilight +//purpose : +//======================================================================= +void AIS_TrihedronOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) +{ + if (!HasSelectable()) + { + return; + } + + thePM->Unhighlight (Selectable()); +} diff --git a/src/AIS/AIS_TrihedronOwner.hxx b/src/AIS/AIS_TrihedronOwner.hxx new file mode 100644 index 0000000000..7d452ce75d --- /dev/null +++ b/src/AIS/AIS_TrihedronOwner.hxx @@ -0,0 +1,56 @@ +// Created by: Ilya SEVRIKOV +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _AIS_TrihedronOwner_HeaderFile +#define _AIS_TrihedronOwner_HeaderFile + +#include +#include +#include + +//! Entity owner for selection management of AIS_Trihedron object. +class AIS_TrihedronOwner : public SelectMgr_EntityOwner +{ + DEFINE_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner) +public: + + //! Creates an owner of AIS_Trihedron object. + Standard_EXPORT AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, + const Prs3d_DatumParts theDatumPart, + const Standard_Integer thePriority); + + Standard_EXPORT const Prs3d_DatumParts& DatumPart() const { return myDatumPart; } + + //! Highlights selectable object's presentation. + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode = 0); + + //! Returns true if the presentation manager thePM + //! highlights selections corresponding to the selection mode aMode. + Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) const Standard_OVERRIDE; + + //! Removes highlighting from the owner of a detected + //! selectable object in the presentation manager thePM. + Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) Standard_OVERRIDE; + +protected: + Prs3d_DatumParts myDatumPart; //! Part of datum selected +}; + +DEFINE_STANDARD_HANDLE (AIS_TrihedronOwner, SelectMgr_EntityOwner) + +#endif // _AIS_TrihedronOwner_HeaderFile diff --git a/src/AIS/FILES b/src/AIS/FILES index 4c878ef9ff..9016828408 100644 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -179,6 +179,8 @@ AIS_Triangulation.hxx AIS_Trihedron.cxx AIS_Trihedron.hxx AIS_Trihedron.lxx +AIS_TrihedronOwner.cxx +AIS_TrihedronOwner.hxx AIS_TypeFilter.cxx AIS_TypeFilter.hxx AIS_TypeOfAngle.hxx diff --git a/src/Prs3d/FILES b/src/Prs3d/FILES index a982836f3d..7fc0bd1ebb 100755 --- a/src/Prs3d/FILES +++ b/src/Prs3d/FILES @@ -8,6 +8,10 @@ Prs3d_BasicAspect.cxx Prs3d_BasicAspect.hxx Prs3d_DatumAspect.cxx Prs3d_DatumAspect.hxx +Prs3d_DatumAttribute.hxx +Prs3d_DatumAxes.hxx +Prs3d_DatumMode.hxx +Prs3d_DatumParts.hxx Prs3d_DimensionArrowOrientation.hxx Prs3d_DimensionAspect.cxx Prs3d_DimensionAspect.hxx diff --git a/src/Prs3d/Prs3d_Arrow.cxx b/src/Prs3d/Prs3d_Arrow.cxx index 3c9d12bbc3..b502e1a34a 100644 --- a/src/Prs3d/Prs3d_Arrow.cxx +++ b/src/Prs3d/Prs3d_Arrow.cxx @@ -31,20 +31,38 @@ //purpose : //======================================================================= void Prs3d_Arrow::Draw(const Handle(Graphic3d_Group)& theGroup, - const gp_Pnt& aLocation, - const gp_Dir& aDirection, - const Quantity_PlaneAngle anAngle, - const Quantity_Length aLength) + const gp_Pnt& theLocation, + const gp_Dir& theDirection, + const Quantity_PlaneAngle theAngle, + const Quantity_Length theLength) { - Quantity_Length dx,dy,dz; aDirection.Coord(dx,dy,dz); + Handle(Graphic3d_ArrayOfSegments) aPrimitives = Prs3d_Arrow::DrawSegments(theLocation, + theDirection, theAngle, theLength, 15); + theGroup->AddPrimitiveArray (aPrimitives); +} + +//======================================================================= +//function : DrawSegments +//purpose : +//======================================================================= +Handle(Graphic3d_ArrayOfSegments) Prs3d_Arrow::DrawSegments (const gp_Pnt& theLocation, + const gp_Dir& theDirection, + const Quantity_PlaneAngle theAngle, + const Quantity_Length theLength, + const int theNumberOfSegments) +{ + Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments(theNumberOfSegments+1, + 2*(2*theNumberOfSegments)); + + Quantity_Length dx,dy,dz; theDirection.Coord(dx,dy,dz); // // Point of the arrow: - Quantity_Length xo,yo,zo; aLocation.Coord(xo,yo,zo); + Quantity_Length xo,yo,zo; theLocation.Coord(xo,yo,zo); // Center of the base circle of the arrow: - Quantity_Length xc = xo - dx * aLength; - Quantity_Length yc = yo - dy * aLength; - Quantity_Length zc = zo - dz * aLength; + Quantity_Length xc = xo - dx * theLength; + Quantity_Length yc = yo - dy * theLength; + Quantity_Length zc = zo - dz * theLength; // Construction of i,j mark for the circle: Quantity_Length xn=0., yn=0., zn=0.; @@ -63,32 +81,43 @@ void Prs3d_Arrow::Draw(const Handle(Graphic3d_Group)& theGroup, const Quantity_Length yj = dz * xi - dx * zi; const Quantity_Length zj = dx * yi - dy * xi; - const Standard_Integer NbPoints = 15; + const Standard_Integer NbPoints = theNumberOfSegments; - Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments(2*NbPoints); - Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines(NbPoints+1); + aSegments->AddVertex(theLocation); gp_Pnt p1; - const Standard_Real Tg=tan(anAngle); + const Standard_Real Tg=tan(theAngle); for (Standard_Integer i = 1; i <= NbPoints ; i++) { - const Standard_Real cosinus = cos ( 2 * M_PI / NbPoints * (i-1) ); + const Standard_Real cosinus = cos ( 2 * M_PI / NbPoints * (i-1) ); const Standard_Real sinus = sin ( 2 * M_PI / NbPoints * (i-1) ); - const gp_Pnt pp(xc + (cosinus * xi + sinus * xj) * aLength * Tg, - yc + (cosinus * yi + sinus * yj) * aLength * Tg, - zc + (cosinus * zi + sinus * zj) * aLength * Tg); + const gp_Pnt pp(xc + (cosinus * xi + sinus * xj) * theLength * Tg, + yc + (cosinus * yi + sinus * yj) * theLength * Tg, + zc + (cosinus * zi + sinus * zj) * theLength * Tg); - aPrims1->AddVertex(aLocation); - aPrims1->AddVertex(pp); - if(i==1) p1 = pp; - aPrims2->AddVertex(pp); + aSegments->AddVertex(pp); } - aPrims2->AddVertex(p1); - theGroup->AddPrimitiveArray (aPrims1); - theGroup->AddPrimitiveArray (aPrims2); + int aNbVertices = NbPoints + 1; + int aFirstContourVertex = 2; + int anEdgeCount = 0; + for (Standard_Integer i = aFirstContourVertex; i <= aNbVertices ; i++) { + aSegments->AddEdge(1); // location vertex + aSegments->AddEdge(i); + anEdgeCount++; + } + aSegments->AddEdge(aNbVertices); + aSegments->AddEdge(aFirstContourVertex); + anEdgeCount++; + + for (Standard_Integer i = aFirstContourVertex; i <= aNbVertices-1 ; i++) { + aSegments->AddEdge(i); + aSegments->AddEdge(i+1); + anEdgeCount++; + } + return aSegments; } // ============================================================================ diff --git a/src/Prs3d/Prs3d_Arrow.hxx b/src/Prs3d/Prs3d_Arrow.hxx index 21917b7203..b16c5f870f 100644 --- a/src/Prs3d/Prs3d_Arrow.hxx +++ b/src/Prs3d/Prs3d_Arrow.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -46,6 +47,18 @@ public: const Standard_Real theConeLength, const Standard_Integer theNbFacettes); + //! Defines the representation of the arrow as a container of segments. + //! @param theLocation location of the arrow tip + //! @param theDirection direction of the arrow + //! @param theAngle angle of opening of the arrow head + //! @param theLength length of the arrow (from the tip) + //! @param theNumberOfSegments count of points on polyline where location is connected + Standard_EXPORT static Handle(Graphic3d_ArrayOfSegments) DrawSegments (const gp_Pnt& theLocation, + const gp_Dir& theDirection, + const Quantity_PlaneAngle theAngle, + const Quantity_Length theLength, + const int theNumberOfSegments); + //! Defines the representation of the arrow. //! Note that this method does NOT assign any presentation aspects to the primitives group! //! @param theGroup presentation group to add primitives diff --git a/src/Prs3d/Prs3d_DatumAspect.cxx b/src/Prs3d/Prs3d_DatumAspect.cxx index 4736cf515b..5a1859b496 100644 --- a/src/Prs3d/Prs3d_DatumAspect.cxx +++ b/src/Prs3d/Prs3d_DatumAspect.cxx @@ -12,105 +12,248 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include +#include +#include #include -#include -#include +#include +#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) +#define PATCH_TO_OCCT_710 + +// ======================================================================= +// function : Prs3d_DatumAspect +// purpose : +// ======================================================================= Prs3d_DatumAspect::Prs3d_DatumAspect() -: myDrawFirstAndSecondAxis (Standard_True), - myDrawThirdAxis (Standard_True), - myToDrawLabels (Standard_True), - myFirstAxisLength (10.0), - mySecondAxisLength (10.0), - myThirdAxisLength (10.0) +: myAxes (Prs3d_DA_XYZAxis), + myToDrawLabels (Standard_True) { - myFirstAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0); - mySecondAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0); - myThirdAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0); + myAttributes.Bind(Prs3d_DA_XAxisLength, 10.0); + myAttributes.Bind(Prs3d_DA_YAxisLength, 10.0); + myAttributes.Bind(Prs3d_DA_ZAxisLength, 10.0); + myAttributes.Bind(Prs3d_DP_ShadingTubeRadiusPercent, 0.02); + myAttributes.Bind(Prs3d_DP_ShadingConeRadiusPercent, 0.04); + myAttributes.Bind(Prs3d_DP_ShadingConeLengthPercent, 0.1); + myAttributes.Bind(Prs3d_DP_ShadingOriginRadiusPercent, 0.015); + myAttributes.Bind(Prs3d_DP_ShadingNumberOfFacettes, 12.); + + myDefaultColors.Bind(Prs3d_DP_Origin, Quantity_Color(Quantity_NOC_BLUE1)); + myDefaultColors.Bind(Prs3d_DP_XAxis, Quantity_Color(Quantity_NOC_RED)); + myDefaultColors.Bind(Prs3d_DP_YAxis, Quantity_Color(Quantity_NOC_GREEN)); + myDefaultColors.Bind(Prs3d_DP_ZAxis, Quantity_Color(Quantity_NOC_BLUE1)); + + Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID; + Standard_Real aWidth = 1.0; + for (int i = Prs3d_DP_Origin; i <= Prs3d_DP_XOZAxis; i++) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)i; + Quantity_Color aDefaultColor; + if (!myDefaultColors.Find(aPart, aDefaultColor)) + aDefaultColor = Quantity_NOC_PEACHPUFF; + if (aPart != Prs3d_DP_Origin) // origin point is used only in shading mode + myLineAspects.Bind(aPart, new Prs3d_LineAspect (aDefaultColor, aLineType, aWidth)); + Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect(); + aShadingAspect->SetColor(aDefaultColor); + myShadedAspects.Bind(aPart, aShadingAspect); + } + myTextAspect = new Prs3d_TextAspect (); +#ifdef PATCH_TO_OCCT_710 + myPointAspect = new Prs3d_PointAspect(Aspect_TOM_POINT/*Aspect_TOM_EMPTY*/, +#else + myPointAspect = new Prs3d_PointAspect(Aspect_TOM_EMPTY, +#endif + myDefaultColors.Find(Prs3d_DP_Origin), 1.0); + myArrowAspect = new Prs3d_ArrowAspect(); } -Handle(Prs3d_LineAspect) Prs3d_DatumAspect::FirstAxisAspect() const { - - return myFirstAxisAspect; -} - -Handle(Prs3d_LineAspect) Prs3d_DatumAspect::SecondAxisAspect() const { - - return mySecondAxisAspect; -} - -Handle(Prs3d_LineAspect) Prs3d_DatumAspect::ThirdAxisAspect() const { - - return myThirdAxisAspect; - -} -Standard_Boolean Prs3d_DatumAspect::DrawFirstAndSecondAxis () const { - - return myDrawFirstAndSecondAxis; - -} - -void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (const Standard_Boolean draw) +Handle(Graphic3d_ArrayOfPrimitives) Prs3d_DatumAspect::ArrayOfPrimitives( + const Prs3d_DatumParts& theDatumPart) const { - myDrawFirstAndSecondAxis = draw; + Handle(Graphic3d_ArrayOfPrimitives) anArray; + myPrimitives.Find(theDatumPart, anArray); + return anArray; } -Standard_Boolean Prs3d_DatumAspect::DrawThirdAxis () const { - - return myDrawThirdAxis; - -} - -void Prs3d_DatumAspect::SetDrawThirdAxis (const Standard_Boolean draw) +void Prs3d_DatumAspect::UpdatePrimitives(const Prs3d_DatumMode& theMode, const gp_Pnt& theOrigin, + const gp_Dir& theXDirection, + const gp_Dir& theYDirection, const gp_Dir& theZDirection) { - myDrawThirdAxis = draw; + myPrimitives.Clear(); + + NCollection_DataMap anAxisDirs; + anAxisDirs.Bind(Prs3d_DP_XAxis, theXDirection); + anAxisDirs.Bind(Prs3d_DP_YAxis, theYDirection); + anAxisDirs.Bind(Prs3d_DP_ZAxis, theZDirection); + + NCollection_DataMap anAxisPoints; + gp_XYZ anXYZOrigin = theOrigin.XYZ(); + for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)i; + anAxisPoints.Bind(aPart, gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ()*AxisLength(aPart))); + } + + if (theMode == Prs3d_DM_WireFrame) + { + // origin + Prs3d_DatumParts aPart = Prs3d_DP_Origin; + if (DrawDatumPart(aPart)) + { + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPoints(1); + aPrims->AddVertex(theOrigin); + myPrimitives.Bind(aPart, aPrims); + } + // axes + for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)i; + if (DrawDatumPart(aPart)) + { + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(theOrigin); + aPrims->AddVertex(anAxisPoints.Find(aPart)); + myPrimitives.Bind(aPart, aPrims); + } + + Prs3d_DatumParts anArrowPart = ArrowPartForAxis(aPart); + if (DrawDatumPart(anArrowPart)) + { + myPrimitives.Bind(anArrowPart, + Prs3d_Arrow::DrawSegments(anAxisPoints.Find(aPart), anAxisDirs.Find(aPart), + ArrowAspect()->Angle(), + AxisLength(aPart)*Attribute(Prs3d_DP_ShadingConeLengthPercent), + (Standard_Integer)Attribute(Prs3d_DP_ShadingNumberOfFacettes))); + } + } + } + else { // shading mode + // origin + Prs3d_DatumParts aPart = Prs3d_DP_Origin; + if (DrawDatumPart(aPart)) + { + Standard_Real aSphereRadius = AxisLength(Prs3d_DP_XAxis)* + Attribute(Prs3d_DP_ShadingOriginRadiusPercent); + Standard_Integer aNbOfFacettes = (Standard_Integer)Attribute(Prs3d_DP_ShadingNumberOfFacettes); + gp_Trsf aSphereTransform; + aSphereTransform.SetTranslationPart(gp_Vec(gp_Pnt(0.0, 0.0, 0.0), theOrigin)); + myPrimitives.Bind(aPart, Prs3d_ToolSphere::Create(aSphereRadius, aNbOfFacettes, + aNbOfFacettes, aSphereTransform)); + } + // axes + { + Standard_Integer aNbOfFacettes = + (Standard_Integer)Attribute(Prs3d_DP_ShadingNumberOfFacettes); + Standard_Real aTubeRadiusPercent = Attribute(Prs3d_DP_ShadingTubeRadiusPercent); + Standard_Real aConeLengthPercent = Attribute(Prs3d_DP_ShadingConeLengthPercent); + Standard_Real aConeRadiusPercent = Attribute(Prs3d_DP_ShadingConeRadiusPercent); + for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; + ++anAxisIter) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; + Prs3d_DatumParts anArrowPart = ArrowPartForAxis(aPart); + bool aDrawArrow = DrawDatumPart(anArrowPart); + Standard_Real anAxisLength = AxisLength(aPart); + gp_Ax1 anAxis (theOrigin, anAxisDirs.Find(aPart)); + + if (DrawDatumPart(aPart)) + // draw cylinder + myPrimitives.Bind(aPart, Prs3d_Arrow::DrawShaded (anAxis, anAxisLength*aTubeRadiusPercent, + aDrawArrow ? anAxisLength - anAxisLength*aConeLengthPercent: anAxisLength, + 0.0, 0.0, aNbOfFacettes)); + + // draw arrow + if (aDrawArrow) + myPrimitives.Bind(anArrowPart, Prs3d_Arrow::DrawShaded (anAxis, + 0.0, anAxisLength, anAxisLength*aConeRadiusPercent, + anAxisLength*aConeLengthPercent, aNbOfFacettes)); + } + } + } + // planes + for (Standard_Integer aPlaneIter = Prs3d_DP_XOYAxis; aPlaneIter <= Prs3d_DP_XOZAxis; + ++aPlaneIter) + { + Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPlaneIter; + if (!DrawDatumPart(aPart)) + continue; + + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(4); + aPrims->AddVertex(theOrigin); + + Prs3d_DatumParts aPart1, aPart2; + switch (aPart) { + case Prs3d_DP_XOYAxis: { aPart1 = Prs3d_DP_XAxis; aPart2 = Prs3d_DP_YAxis; } break; + case Prs3d_DP_YOZAxis: { aPart1 = Prs3d_DP_YAxis; aPart2 = Prs3d_DP_ZAxis; } break; + case Prs3d_DP_XOZAxis: { aPart1 = Prs3d_DP_XAxis; aPart2 = Prs3d_DP_ZAxis; } break; + default: break; + } + aPrims->AddVertex(anAxisPoints.Find(aPart1)); + aPrims->AddVertex(anAxisPoints.Find(aPart2)); + + aPrims->AddVertex(theOrigin); + myPrimitives.Bind(aPart, aPrims); + } } -void Prs3d_DatumAspect::SetAxisLength (const Quantity_Length L1, - const Quantity_Length L2, - const Quantity_Length L3) { - - myFirstAxisLength = L1; - mySecondAxisLength = L2; - myThirdAxisLength = L3; -} - - -Quantity_Length Prs3d_DatumAspect::FirstAxisLength () const { - - return myFirstAxisLength; - -} - -Quantity_Length Prs3d_DatumAspect::SecondAxisLength () const { - - return mySecondAxisLength; - -} - -Quantity_Length Prs3d_DatumAspect::ThirdAxisLength () const { - - return myThirdAxisLength; - -} - -//======================================================================= -//function : SetToDrawLabels -//purpose : -//======================================================================= -void Prs3d_DatumAspect::SetToDrawLabels (const Standard_Boolean theToDraw) +void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (const Standard_Boolean theToDraw) { - myToDrawLabels = theToDraw; + if (theToDraw) + myAxes = Prs3d_DatumAxes(myAxes | Prs3d_DA_XAxis | Prs3d_DA_YAxis); + else + myAxes = Prs3d_DatumAxes(myAxes & !Prs3d_DA_XAxis & !Prs3d_DA_YAxis); } -//======================================================================= -//function : ToDrawLabels -//purpose : -//======================================================================= -Standard_Boolean Prs3d_DatumAspect::ToDrawLabels() const +void Prs3d_DatumAspect::SetDrawThirdAxis (const Standard_Boolean theToDraw) { - return myToDrawLabels; + if (theToDraw) + myAxes = Prs3d_DatumAxes(myAxes | Prs3d_DA_ZAxis); + else + myAxes = Prs3d_DatumAxes(myAxes & !Prs3d_DA_ZAxis); +} + +bool Prs3d_DatumAspect::DrawDatumPart(const Prs3d_DatumParts& thePart) const +{ + switch (thePart) + { + case Prs3d_DP_Origin: return true; + case Prs3d_DP_XAxis: + case Prs3d_DP_XArrow: return (myAxes & Prs3d_DA_XAxis) != 0; + case Prs3d_DP_YAxis: + case Prs3d_DP_YArrow: return (myAxes & Prs3d_DA_YAxis) != 0; + case Prs3d_DP_ZAxis: + case Prs3d_DP_ZArrow: return (myAxes & Prs3d_DA_ZAxis) != 0; + case Prs3d_DP_XOYAxis: return DrawDatumPart(Prs3d_DP_XAxis) && DrawDatumPart(Prs3d_DP_YAxis); + case Prs3d_DP_YOZAxis: return DrawDatumPart(Prs3d_DP_YAxis) && DrawDatumPart(Prs3d_DP_ZAxis); + case Prs3d_DP_XOZAxis: return DrawDatumPart(Prs3d_DP_XAxis) && DrawDatumPart(Prs3d_DP_ZAxis); + default: break; + } + return false; +} + +Quantity_Length Prs3d_DatumAspect::AxisLength(const Prs3d_DatumParts& thePart) const +{ + switch (thePart) + { + case Prs3d_DP_XAxis: return (Quantity_Length)myAttributes.Find(Prs3d_DA_XAxisLength); + case Prs3d_DP_YAxis: return (Quantity_Length)myAttributes.Find(Prs3d_DA_YAxisLength); + case Prs3d_DP_ZAxis: return (Quantity_Length)myAttributes.Find(Prs3d_DA_ZAxisLength); + default: break; + } + return Quantity_Length(0); +} + +Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis(const Prs3d_DatumParts& thePart) const +{ + switch (thePart) + { + case Prs3d_DP_XAxis: return Prs3d_DP_XArrow; + case Prs3d_DP_YAxis: return Prs3d_DP_YArrow; + case Prs3d_DP_ZAxis: return Prs3d_DP_ZArrow; + default: break; + } + return Prs3d_DP_None; } diff --git a/src/Prs3d/Prs3d_DatumAspect.hxx b/src/Prs3d/Prs3d_DatumAspect.hxx index 50f0b25f65..cf8bf24816 100644 --- a/src/Prs3d/Prs3d_DatumAspect.hxx +++ b/src/Prs3d/Prs3d_DatumAspect.hxx @@ -17,87 +17,173 @@ #ifndef _Prs3d_DatumAspect_HeaderFile #define _Prs3d_DatumAspect_HeaderFile -#include -#include +#include + +#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include #include -class Prs3d_LineAspect; - - -class Prs3d_DatumAspect; -DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect) +#include //! A framework to define the display of datums. class Prs3d_DatumAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) public: //! An empty framework to define the display of datums. Standard_EXPORT Prs3d_DatumAspect(); - + + //! Returns the right-handed coordinate system set in SetComponent. + Standard_EXPORT const Handle(Prs3d_LineAspect)& LineAspect(const Prs3d_DatumParts& thePart) const + { + return myLineAspects.Find(thePart); + } + + //! Returns the right-handed coordinate system set in SetComponent. + Standard_EXPORT const Handle(Prs3d_ShadingAspect)& ShadingAspect(const Prs3d_DatumParts& thePart) const + { + return myShadedAspects.Find(thePart); + } + + //! Returns the right-handed coordinate system set in SetComponent. + Standard_EXPORT const Handle(Prs3d_TextAspect)& TextAspect() const + { + return myTextAspect; + } + + //! Returns the point aspect of origin wireframe presentation + Standard_EXPORT const Handle(Prs3d_PointAspect)& PointAspect() const + { + return myPointAspect; + } + + //! Returns the arrow aspect of presentation + Standard_EXPORT const Handle(Prs3d_ArrowAspect)& ArrowAspect() const + { + return myArrowAspect; + } + + //! Returns primitives. + Handle(Graphic3d_ArrayOfPrimitives) ArrayOfPrimitives(const Prs3d_DatumParts& thePart) const; + + //! Updates graphic groups for the current datum mode + //! Parameters of datum position and orientation + Standard_EXPORT void UpdatePrimitives(const Prs3d_DatumMode& theMode, const gp_Pnt& theOrigin, + const gp_Dir& theXDirection, const gp_Dir& theYDirection, + const gp_Dir& theZDirection); + //! Returns the attributes for display of the first axis. - Standard_EXPORT Handle(Prs3d_LineAspect) FirstAxisAspect() const; + Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead") + const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find(Prs3d_DP_XAxis); } //! Returns the attributes for display of the second axis. - Standard_EXPORT Handle(Prs3d_LineAspect) SecondAxisAspect() const; + Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead") + const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects.Find(Prs3d_DP_YAxis); } //! Returns the attributes for display of the third axis. - Standard_EXPORT Handle(Prs3d_LineAspect) ThirdAxisAspect() const; + Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead") + const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects.Find(Prs3d_DP_ZAxis); } //! Sets the DrawFirstAndSecondAxis attributes to active. - Standard_EXPORT void SetDrawFirstAndSecondAxis (const Standard_Boolean draw); + Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead") + Standard_EXPORT void SetDrawFirstAndSecondAxis (const Standard_Boolean theToDraw); //! Returns true if the first and second axes can be drawn. - Standard_EXPORT Standard_Boolean DrawFirstAndSecondAxis() const; - + Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead") + Standard_Boolean DrawFirstAndSecondAxis() const { return (myAxes & Prs3d_DA_XAxis & Prs3d_DA_YAxis) != 0; } + //! Sets the DrawThirdAxis attributes to active. - Standard_EXPORT void SetDrawThirdAxis (const Standard_Boolean draw); + Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead") + Standard_EXPORT void SetDrawThirdAxis (const Standard_Boolean theToDraw); //! Returns true if the third axis can be drawn. - Standard_EXPORT Standard_Boolean DrawThirdAxis() const; - - //! Sets the lengths L1, L2 and L3 of the three axes. - Standard_EXPORT void SetAxisLength (const Standard_Real L1, const Standard_Real L2, const Standard_Real L3); - + Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead") + Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DA_ZAxis) != 0; } + + //! Returns true if the given part is used in axes of aspect + Standard_EXPORT Standard_Boolean DrawDatumPart(const Prs3d_DatumParts& thePart) const; + + //! Sets the axes used in the datum aspect + void SetDrawDatumAxes(const Prs3d_DatumAxes& theType) { myAxes = theType; } + + //! Returns axes used in the datum aspect + Prs3d_DatumAxes DatumAxes() const { return myAxes; } + + //! Sets the attribute of the datum type + void SetAttribute(const Prs3d_DatumAttribute& theType, const Standard_Real& theValue) + { + myAttributes.Bind(theType, theValue); + } + + //! Returns the attribute of the datum type + Standard_Real Attribute(const Prs3d_DatumAttribute& theType) const + { + return myAttributes.Find(theType); + } + + //! Sets the lengths of the three axes. + void SetAxisLength (const Standard_Real theL1, const Standard_Real theL2, const Standard_Real theL3) + { + myAttributes.Bind(Prs3d_DA_XAxisLength, theL1); + myAttributes.Bind(Prs3d_DA_YAxisLength, theL2); + myAttributes.Bind(Prs3d_DA_ZAxisLength, theL3); + } + //! Returns the length of the displayed first axis. - Standard_EXPORT Quantity_Length FirstAxisLength() const; - + Quantity_Length AxisLength(const Prs3d_DatumParts& thePart) const; + + //! Returns the length of the displayed first axis. + Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead") + Quantity_Length FirstAxisLength() const { return (Quantity_Length)myAttributes.Find(Prs3d_DA_XAxisLength); } + //! Returns the length of the displayed second axis. - Standard_EXPORT Quantity_Length SecondAxisLength() const; + Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead") + Quantity_Length SecondAxisLength() const { return (Quantity_Length)myAttributes.Find(Prs3d_DA_YAxisLength); } //! Returns the length of the displayed third axis. - Standard_EXPORT Quantity_Length ThirdAxisLength() const; + Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead") + Quantity_Length ThirdAxisLength() const { return (Quantity_Length)myAttributes.Find(Prs3d_DA_ZAxisLength); } //! Sets option to draw or not to draw text labels for axes - Standard_EXPORT void SetToDrawLabels (const Standard_Boolean theToDraw); + void SetToDrawLabels (const Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; } //! @return true if axes labels are drawn - Standard_EXPORT Standard_Boolean ToDrawLabels() const; + Standard_Boolean ToDrawLabels() const { return myToDrawLabels; } - DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect,Prs3d_BasicAspect) + //! Returns type of arrow for a type of axis + Prs3d_DatumParts ArrowPartForAxis(const Prs3d_DatumParts& thePart) const; private: - - Handle(Prs3d_LineAspect) myFirstAxisAspect; - Handle(Prs3d_LineAspect) mySecondAxisAspect; - Handle(Prs3d_LineAspect) myThirdAxisAspect; - Standard_Boolean myDrawFirstAndSecondAxis; - Standard_Boolean myDrawThirdAxis; + Prs3d_DatumAxes myAxes; Standard_Boolean myToDrawLabels; - Quantity_Length myFirstAxisLength; - Quantity_Length mySecondAxisLength; - Quantity_Length myThirdAxisLength; + NCollection_DataMap myAttributes; + NCollection_DataMap myPrimitives; + NCollection_DataMap myShadedAspects; + NCollection_DataMap myLineAspects; + + NCollection_DataMap myDefaultColors; + + Handle(Prs3d_TextAspect) myTextAspect; + Handle(Prs3d_PointAspect) myPointAspect; + Handle(Prs3d_ArrowAspect) myArrowAspect; }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect) #endif // _Prs3d_DatumAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_DatumAttribute.hxx b/src/Prs3d/Prs3d_DatumAttribute.hxx new file mode 100644 index 0000000000..d76e2eafaf --- /dev/null +++ b/src/Prs3d/Prs3d_DatumAttribute.hxx @@ -0,0 +1,30 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Prs3d_DatumAttribute_HeaderFile +#define _Prs3d_DatumAttribute_HeaderFile + +//! Enumeration defining a part of datum aspect, see Prs3d_Datum. +enum Prs3d_DatumAttribute +{ + Prs3d_DA_XAxisLength = 0, + Prs3d_DA_YAxisLength, + Prs3d_DA_ZAxisLength, + Prs3d_DP_ShadingTubeRadiusPercent, + Prs3d_DP_ShadingConeRadiusPercent, + Prs3d_DP_ShadingConeLengthPercent, + Prs3d_DP_ShadingOriginRadiusPercent, + Prs3d_DP_ShadingNumberOfFacettes +}; + +#endif // _Prs3d_DatumAttribute_HeaderFile diff --git a/src/Prs3d/Prs3d_DatumAxes.hxx b/src/Prs3d/Prs3d_DatumAxes.hxx new file mode 100644 index 0000000000..02665512e0 --- /dev/null +++ b/src/Prs3d/Prs3d_DatumAxes.hxx @@ -0,0 +1,34 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Prs3d_DatumAxes_HeaderFile +#define _Prs3d_DatumAxes_HeaderFile + +//! Enumeration defining an axes used in datum aspect, see Prs3d_Datum. +enum Prs3d_DatumAxes +{ + Prs3d_DA_XAxis = 0x00000001, //!< X axis of the datum + Prs3d_DA_YAxis = 0x00000002, //!< Y axis of the datum + Prs3d_DA_ZAxis = 0x00000004, //!< Z axis of the datum + Prs3d_DA_XYAxis = Prs3d_DA_XAxis + | Prs3d_DA_YAxis, //!< XOY 2D axes + Prs3d_DA_YZAxis = Prs3d_DA_YAxis + | Prs3d_DA_ZAxis, //!< YOZ 2D axes + Prs3d_DA_XZAxis = Prs3d_DA_XAxis + | Prs3d_DA_ZAxis, //!< XOZ 2D axes + Prs3d_DA_XYZAxis = Prs3d_DA_XAxis + | Prs3d_DA_YAxis + | Prs3d_DA_ZAxis //!< XYZ 3D axes +}; + +#endif // _Prs3d_DatumParts_HeaderFile diff --git a/src/Prs3d/Prs3d_DatumMode.hxx b/src/Prs3d/Prs3d_DatumMode.hxx new file mode 100644 index 0000000000..45d40ca4fd --- /dev/null +++ b/src/Prs3d/Prs3d_DatumMode.hxx @@ -0,0 +1,24 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Prs3d_DatumMode_HeaderFile +#define _Prs3d_DatumMode_HeaderFile + +//! Enumeration defining a mode of datum graphic presentation, see Prs3d_Datum. +enum Prs3d_DatumMode +{ + Prs3d_DM_WireFrame = 0, + Prs3d_DM_Shaded +}; + +#endif // _Prs3d_DatumMode_HeaderFile diff --git a/src/Prs3d/Prs3d_DatumParts.hxx b/src/Prs3d/Prs3d_DatumParts.hxx new file mode 100644 index 0000000000..e784a374bf --- /dev/null +++ b/src/Prs3d/Prs3d_DatumParts.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Prs3d_DatumParts_HeaderFile +#define _Prs3d_DatumParts_HeaderFile + +//! Enumeration defining a part of datum aspect, see Prs3d_Datum. +enum Prs3d_DatumParts +{ + Prs3d_DP_Origin = 0, + Prs3d_DP_XAxis, + Prs3d_DP_YAxis, + Prs3d_DP_ZAxis, + Prs3d_DP_XArrow, + Prs3d_DP_YArrow, + Prs3d_DP_ZArrow, + Prs3d_DP_XOYAxis, + Prs3d_DP_YOZAxis, + Prs3d_DP_XOZAxis, + Prs3d_DP_None +}; + +#endif // _Prs3d_DatumParts_HeaderFile diff --git a/src/QADraw/QADraw.cxx b/src/QADraw/QADraw.cxx index d4cd82be35..61aa7bbf16 100644 --- a/src/QADraw/QADraw.cxx +++ b/src/QADraw/QADraw.cxx @@ -85,7 +85,7 @@ static int VTrihedronOrigins(Draw_Interpretor& di, } //get axis - Handle(AIS_Axis) XAxis = aTrih->XAxis(); + /*Handle(AIS_Axis) XAxis = aTrih->XAxis(); Handle(AIS_Axis) YAxis = aTrih->YAxis(); Handle(AIS_Axis) ZAxis = aTrih->Axis(); @@ -110,7 +110,7 @@ static int VTrihedronOrigins(Draw_Interpretor& di, TheAISContext()->Display(XLine); TheAISContext()->Display(YLine); TheAISContext()->Display(ZLine); - + */ return 0; }