#include <AIS_ManipulatorOwner.hxx>
#include <Extrema_ExtElC.hxx>
#include <gce_MakeDir.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Transformation.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_ToolDisk.hxx>
+#include <Prs3d_ToolSector.hxx>
#include <Prs3d_ToolSphere.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitivePoint.hxx>
{
public:
//! Main constructor.
- ManipSensCircle (const Handle(SelectBasics_EntityOwner)& theOwnerId,
- const Handle(Geom_Circle)& theCircle,
+ ManipSensCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
+ const gp_Circ& theCircle,
const Standard_Integer theNbPnts)
: Select3D_SensitiveCircle (theOwnerId, theCircle, Standard_False, theNbPnts),
- ManipSensRotation (theCircle->Position().Direction()) {}
+ ManipSensRotation (theCircle.Position().Direction()) {}
//! Checks whether the circle overlaps current selecting volume
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
class ManipSensTriangulation : public Select3D_SensitiveTriangulation, public ManipSensRotation
{
public:
- ManipSensTriangulation (const Handle(SelectBasics_EntityOwner)& theOwnerId,
+ ManipSensTriangulation (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const Handle(Poly_Triangulation)& theTrg,
const gp_Dir& thePlaneNormal)
: Select3D_SensitiveTriangulation (theOwnerId, theTrg, TopLoc_Location(), Standard_True),
myAxes[2] = Axis (gp::OZ(), Quantity_NOC_BLUE1);
Graphic3d_MaterialAspect aShadingMaterial;
- aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
+ aShadingMaterial.SetSpecularColor(Quantity_NOC_BLACK);
aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
Graphic3d_MaterialAspect aHilightMaterial;
aHilightMaterial.SetColor (Quantity_NOC_AZURE);
- aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
- aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
- aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
- aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
+ aHilightMaterial.SetAmbientColor (Quantity_NOC_BLACK);
+ aHilightMaterial.SetDiffuseColor (Quantity_NOC_BLACK);
+ aHilightMaterial.SetSpecularColor(Quantity_NOC_BLACK);
+ aHilightMaterial.SetEmissiveColor(Quantity_NOC_BLACK);
aHilightMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
myHighlightAspect = new Prs3d_ShadingAspect();
myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myHighlightAspect->SetMaterial (aHilightMaterial);
+ Graphic3d_MaterialAspect aDraggerMaterial;
+ aDraggerMaterial.SetAmbientColor (Quantity_NOC_BLACK);
+ aDraggerMaterial.SetDiffuseColor (Quantity_NOC_BLACK);
+ aDraggerMaterial.SetSpecularColor(Quantity_NOC_BLACK);
+ aDraggerMaterial.SetMaterialType(Graphic3d_MATERIAL_ASPECT);
+
+ myDraggerHighlight = new Prs3d_ShadingAspect();
+ myDraggerHighlight->Aspect()->SetInteriorStyle(Aspect_IS_SOLID);
+ myDraggerHighlight->SetMaterial(aDraggerMaterial);
+
+ myDraggerHighlight->SetTransparency(0.5);
+
SetSize (100);
SetZLayer (Graphic3d_ZLayerId_Topmost);
}
switch (anOwner->Mode())
{
- case AIS_MM_Translation: return myAxes[anOwner->Index()].TranslatorHighlightPrs();
- case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs();
- case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs();
- case AIS_MM_None : break;
+ case AIS_MM_Translation : return myAxes[anOwner->Index()].TranslatorHighlightPrs();
+ case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs();
+ case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs();
+ case AIS_MM_TranslationPlane: return myAxes[anOwner->Index()].DraggerHighlightPrs();
+ case AIS_MM_None : break;
}
return aDummyPrs;
switch (theMode)
{
- case AIS_MM_Translation: return myAxes[theIndex].TranslatorGroup();
- case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup();
- case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup();
- case AIS_MM_None : break;
+ case AIS_MM_Translation : return myAxes[theIndex].TranslatorGroup();
+ case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup();
+ case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup();
+ case AIS_MM_TranslationPlane: return myAxes[theIndex].DraggerGroup();
+ case AIS_MM_None : break;
}
return aDummyGroup;
myAxes[theAxisIndex].SetScaling (theIsEnabled);
break;
+ case AIS_MM_TranslationPlane:
+ myAxes[theAxisIndex].SetDragging(theIsEnabled);
+ break;
+
case AIS_MM_None:
break;
}
EnableMode (AIS_MM_Rotation);
EnableMode (AIS_MM_Translation);
EnableMode (AIS_MM_Scaling);
+ EnableMode (AIS_MM_TranslationPlane);
}
}
const gp_Lin aLine (myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction());
Extrema_ExtElC anExtrema (anInputLine, aLine, Precision::Angular());
if (!anExtrema.IsDone()
+ || anExtrema.IsParallel()
|| anExtrema.NbExt() != 1)
{
// translation cannot be done co-directed with camera
const gp_Pnt aPosLoc = myStartPosition.Location();
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir (myStartPosition, myCurrentIndex);
IntAna_IntConicQuad aIntersector (anInputLine, gp_Pln (aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
- if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
+ if (!aIntersector.IsDone()
+ || aIntersector.IsParallel()
+ || aIntersector.NbPoints() < 1)
{
return Standard_False;
}
myPrevState = anAngle;
return Standard_True;
}
+ case AIS_MM_TranslationPlane:
+ {
+ const gp_Pnt aPosLoc = myStartPosition.Location();
+ const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex);
+ IntAna_IntConicQuad aIntersector(anInputLine, gp_Pln(aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
+ if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
+ {
+ return Standard_False;
+ }
+
+ const gp_Pnt aNewPosition = aIntersector.Point(1);
+ if (!myHasStartedTransformation)
+ {
+ myStartPick = aNewPosition;
+ myHasStartedTransformation = Standard_True;
+ return Standard_True;
+ }
+
+ if (aNewPosition.Distance(myStartPick) < Precision::Confusion())
+ {
+ return Standard_False;
+ }
+
+ gp_Trsf aNewTrsf;
+ aNewTrsf.SetTranslation(gp_Vec(myStartPick, aNewPosition));
+ theTrsf *= aNewTrsf;
+ return Standard_True;
+ }
case AIS_MM_None:
{
return Standard_False;
NCollection_Sequence<gp_Trsf>::Iterator aTrsfIter (myStartTrsfs);
for (; anObjIter.More(); anObjIter.Next(), aTrsfIter.Next())
{
- anObjIter.ChangeValue()->SetLocalTransformation (theTrsf * aTrsfIter.Value());
+ const Handle(AIS_InteractiveObject)& anObj = anObjIter.ChangeValue();
+ const gp_Trsf& anOldTrsf = aTrsfIter.Value();
+ const Handle(TopLoc_Datum3D)& aParentTrsf = anObj->CombinedParentTransformation();
+ if (!aParentTrsf.IsNull()
+ && aParentTrsf->Form() != gp_Identity)
+ {
+ // recompute local transformation relative to parent transformation
+ const gp_Trsf aNewLocalTrsf = aParentTrsf->Trsf().Inverted() * theTrsf * aParentTrsf->Trsf() * anOldTrsf;
+ anObj->SetLocalTransformation (aNewLocalTrsf);
+ }
+ else
+ {
+ anObj->SetLocalTransformation (theTrsf * anOldTrsf);
+ }
}
}
- if ((myCurrentMode == AIS_MM_Translation && myBehaviorOnTransform.FollowTranslation)
- || (myCurrentMode == AIS_MM_Rotation && myBehaviorOnTransform.FollowRotation))
+ if ((myCurrentMode == AIS_MM_Translation && myBehaviorOnTransform.FollowTranslation)
+ || (myCurrentMode == AIS_MM_Rotation && myBehaviorOnTransform.FollowRotation)
+ || (myCurrentMode == AIS_MM_TranslationPlane && myBehaviorOnTransform.FollowDragging))
{
gp_Pnt aPos = myStartPosition.Location().Transformed (theTrsf);
gp_Dir aVDir = myStartPosition.Direction().Transformed (theTrsf);
aTrsf.SetTransformation (gp_Ax2 (gp::Origin(), aVDir, aXDir), gp::XOY());
}
- Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (aTrsf);
+ Handle(TopLoc_Datum3D) aGeomTrsf = new TopLoc_Datum3D (aTrsf);
// we explicitly call here setLocalTransformation() of the base class
// since AIS_Manipulator::setLocalTransformation() implementation throws exception
// as protection from external calls
Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
anAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetMaterial (myDrawer->ShadingAspect()->Material());
- anAspect->SetTransparency (myDrawer->ShadingAspect()->Transparency());
- anAspect->SetColor (myAxes[myCurrentIndex].Color());
+ if (myCurrentMode == AIS_MM_TranslationPlane)
+ anAspect->SetTransparency(1.0);
+ else
+ {
+ anAspect->SetTransparency(myDrawer->ShadingAspect()->Transparency());
+ anAspect->SetColor(myAxes[myCurrentIndex].Color());
+ }
aGroup->SetGroupPrimitivesAspect (anAspect->Aspect());
}
//function : setLocalTransformation
//purpose :
//=======================================================================
-void AIS_Manipulator::setLocalTransformation (const Handle(Geom_Transformation)& /*theTrsf*/)
+void AIS_Manipulator::setLocalTransformation (const Handle(TopLoc_Datum3D)& /*theTrsf*/)
{
Standard_ASSERT_INVOKE ("AIS_Manipulator::setLocalTransformation: "
"Custom transformation is not supported by this class");
// Display center
myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin());
- aGroup = Prs3d_Root::NewGroup (thePrs);
+ aGroup = thePrs->NewGroup ();
aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myCenter.Array());
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
// Display axes
- aGroup = Prs3d_Root::NewGroup (thePrs);
+ aGroup = thePrs->NewGroup ();
Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
anAspectAx->SetColor (myAxes[anIt].Color());
return;
}
- aGroup->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
+ if (anOwner->Mode() == AIS_MM_TranslationPlane)
+ {
+ myDraggerHighlight->SetColor(myAxes[anOwner->Index()].Color());
+ aGroup->SetGroupPrimitivesAspect(myDraggerHighlight->Aspect());
+ }
+ else
+ aGroup->SetGroupPrimitivesAspect(myHighlightAspect->Aspect());
myCurrentIndex = anOwner->Index();
myCurrentMode = anOwner->Mode();
{
return;
}
- aPresentation->Highlight (theStyle);
+
+ aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
+
+ if (anOwner->Mode() == AIS_MM_TranslationPlane)
+ {
+ Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
+ aStyle->SetColor (myAxes[anOwner->Index()].Color());
+ aStyle->SetTransparency (0.5);
+ aPresentation->Highlight (aStyle);
+ }
+ else
+ {
+ aPresentation->Highlight (theStyle);
+ }
+
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
- if (!aGrp.IsNull()
- && aGrp->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ if (!aGrp.IsNull())
{
aGrp->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
}
anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Rotation, 9);
}
// define sensitivity by circle
- Handle(Geom_Circle) aGeomCircle = new Geom_Circle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
+ const gp_Circ aGeomCircle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, anAxis.FacettesNumber());
aCircle->SetSensitivityFactor (15);
theSelection->Add (aCircle);
theSelection->Add (aTri);
}
}
+
+ if (aMode == AIS_MM_TranslationPlane || aMode == AIS_MM_None)
+ {
+ for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
+ {
+ if (!myAxes[anIt].HasDragging())
+ {
+ continue;
+ }
+ if (aMode != AIS_MM_None)
+ {
+ anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
+ }
+
+ // define sensitivity by two crossed lines
+ gp_Pnt aP1, aP2;
+ aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition();
+ aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
+ gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
+
+ Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
+ aLine1->SetSensitivityFactor(10);
+ theSelection->Add(aLine1);
+ Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, gp::Origin(), aMidP);
+ aLine2->SetSensitivityFactor(10);
+ theSelection->Add(aLine2);
+
+ // enlarge sensitivity by triangulation
+ Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
+ theSelection->Add(aTri);
+ }
+ }
}
//=======================================================================
myArray->AddVertex (theP3, theNormal);
}
+//=======================================================================
+//class : Sector
+//function : Init
+//purpose :
+//=======================================================================
+void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
+ const gp_Ax1& thePosition,
+ const gp_Dir& theXDirection,
+ const Standard_Integer theSlicesNb,
+ const Standard_Integer theStacksNb)
+{
+ Prs3d_ToolSector aTool(theRadius, theSlicesNb, theStacksNb);
+ gp_Ax3 aSystem(thePosition.Location(), thePosition.Direction(), theXDirection);
+ gp_Trsf aTrsf;
+ aTrsf.SetTransformation(aSystem, gp_Ax3());
+ aTool.FillArray(myArray, myTriangulation, aTrsf);
+}
+
//=======================================================================
//class : Axis
//function : Constructor
myInnerRadius (myLength + myBoxSize),
myDiskThickness (myBoxSize * 0.5f),
myIndent (0.2f),
+ myHasDragging(Standard_True),
myFacettesNumber (20),
myCircleRadius (myLength + myBoxSize + myBoxSize * 0.5f * 0.5f)
{
myAxisRadius * 1.5,
anArrowLength,
myFacettesNumber);
- myTranslatorGroup = Prs3d_Root::NewGroup (thePrs);
+ myTranslatorGroup = thePrs->NewGroup ();
myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
- myScalerGroup = Prs3d_Root::NewGroup (thePrs);
+ myScalerGroup = thePrs->NewGroup ();
myScalerGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myScalerGroup->AddPrimitiveArray (myCube.Array());
{
myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
- myRotatorGroup = Prs3d_Root::NewGroup (thePrs);
+ myRotatorGroup = thePrs->NewGroup ();
myRotatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myRotatorGroup->AddPrimitiveArray (myCircle.Array());
aGroup->AddPrimitiveArray (myCircle.Array());
}
}
+
+ if (myHasDragging)
+ {
+ gp_Dir aXDirection;
+ if (myReferenceAxis.Direction().X() > 0)
+ aXDirection = gp::DY();
+ else if (myReferenceAxis.Direction().Y() > 0)
+ aXDirection = gp::DZ();
+ else
+ aXDirection = gp::DX();
+
+ mySector.Init(myInnerRadius + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection, myFacettesNumber * 2);
+ myDraggerGroup = thePrs->NewGroup();
+
+ Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d();
+ myDraggerGroup->SetGroupPrimitivesAspect(aFillArea);
+ myDraggerGroup->AddPrimitiveArray(mySector.Array());
+
+ if (myHighlightDragger.IsNull())
+ {
+ myHighlightDragger = new Prs3d_Presentation(thePrsMgr->StructureManager());
+ }
+ else
+ {
+ myHighlightDragger->Clear();
+ }
+ {
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(myHighlightDragger);
+ aGroup->SetGroupPrimitivesAspect(aFillArea);
+ aGroup->AddPrimitiveArray(mySector.Array());
+ }
+ }
}