Added dragging sectors to Manipulator presentation.
Test added.
#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>
myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myHighlightAspect->SetMaterial (aHilightMaterial);
+ Graphic3d_MaterialAspect aDraggerMaterial;
+ aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
+ aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
+ aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
+ aDraggerMaterial.SetMaterialType(Graphic3d_MATERIAL_ASPECT);
+ aDraggerMaterial.SetAmbient(1.0);
+
+ 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;
}
//=======================================================================
void AIS_Manipulator::SetPart (const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled)
{
- for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
+ for (Standard_Integer anIt = 0; anIt < 4; ++anIt)
{
SetPart (anIt, theMode, theIsEnabled);
}
EnableMode (AIS_MM_Rotation);
EnableMode (AIS_MM_Translation);
EnableMode (AIS_MM_Scaling);
+ EnableMode (AIS_MM_TranslationPlane);
}
}
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;
}
}
- 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);
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());
}
// 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);
+ 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())
{
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());
+ }
+ }
}
//! - FollowRotation - whether the manipulator will be rotated together with an object.
struct BehaviorOnTransform {
- BehaviorOnTransform() : FollowTranslation (Standard_True), FollowRotation (Standard_True) {}
+ BehaviorOnTransform() : FollowTranslation (Standard_True), FollowRotation (Standard_True), FollowDragging (Standard_True) {}
BehaviorOnTransform& SetFollowTranslation (const Standard_Boolean theApply) { FollowTranslation = theApply; return *this; }
BehaviorOnTransform& SetFollowRotation (const Standard_Boolean theApply) { FollowRotation = theApply; return *this; }
+ BehaviorOnTransform& SetFollowDragging (const Standard_Boolean theApply) { FollowDragging = theApply; return *this; }
Standard_Boolean FollowTranslation;
Standard_Boolean FollowRotation;
+ Standard_Boolean FollowDragging;
};
//! Sets behavior settings for transformation action carried on the manipulator,
Handle(Graphic3d_ArrayOfTriangles) myArray;
};
+ class Sector : public Quadric
+ {
+ public:
+
+ Sector()
+ : Quadric(),
+ myRadius(0.0f)
+ { }
+
+ ~Sector() { }
+
+ void Init(const Standard_ShortReal theRadius,
+ const gp_Ax1& thePosition,
+ const gp_Dir& theXDirection,
+ const Standard_Integer theSlicesNb = 5,
+ const Standard_Integer theStacksNb = 5);
+
+ protected:
+
+ gp_Ax1 myPosition;
+ Standard_ShortReal myRadius;
+ };
+
//! The class describes on axis sub-object.
//! It includes sub-objects itself:
//! -rotator
{
myHighlightRotator->SetTransformPersistence (theTrsfPers);
}
+
+ if (!myHighlightDragger.IsNull())
+ {
+ myHighlightDragger->SetTransformPersistence(theTrsfPers);
+ }
}
void Transform (const Handle(Geom_Transformation)& theTransformation)
{
myHighlightRotator->SetTransformation (theTransformation);
}
+
+ if (!myHighlightDragger.IsNull())
+ {
+ myHighlightDragger->SetTransformation(theTransformation);
+ }
}
Standard_Boolean HasTranslation() const { return myHasTranslation; }
Standard_Boolean HasScaling() const { return myHasScaling; }
+ Standard_Boolean HasDragging() const { return myHasDragging; }
+
void SetTranslation (const Standard_Boolean theIsEnabled) { myHasTranslation = theIsEnabled; }
void SetRotation (const Standard_Boolean theIsEnabled) { myHasRotation = theIsEnabled; }
void SetScaling (const Standard_Boolean theIsEnabled) { myHasScaling = theIsEnabled; }
+ void SetDragging(const Standard_Boolean theIsEnabled) { myHasDragging = theIsEnabled; }
+
Quantity_Color Color() const { return myColor; }
Standard_ShortReal AxisLength() const { return myLength; }
const Handle(Prs3d_Presentation)& ScalerHighlightPrs() const { return myHighlightScaler; }
+ const Handle(Prs3d_Presentation)& DraggerHighlightPrs() const { return myHighlightDragger; }
+
const Handle(Graphic3d_Group)& TranslatorGroup() const { return myTranslatorGroup; }
const Handle(Graphic3d_Group)& RotatorGroup() const { return myRotatorGroup; }
const Handle(Graphic3d_Group)& ScalerGroup() const { return myScalerGroup; }
+ const Handle(Graphic3d_Group)& DraggerGroup() const { return myDraggerGroup; }
+
const Handle(Graphic3d_ArrayOfTriangles)& TriangleArray() const { return myTriangleArray; }
void SetIndent (const Standard_ShortReal theValue) { myIndent = theValue; }
public:
const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
+ const Sector& DraggerSector() const { return mySector; }
const Disk& RotatorDisk() const { return myCircle; }
float RotatorDiskRadius() const { return myCircleRadius; }
const Cube& ScalerCube() const { return myCube; }
Standard_ShortReal myDiskThickness;
Standard_ShortReal myIndent; //!< Gap between visual part of the manipulator.
+ Standard_Boolean myHasDragging;
+
protected:
Standard_Integer myFacettesNumber;
gp_Pnt myArrowTipPos;
+ Sector mySector;
Disk myCircle;
float myCircleRadius;
Cube myCube;
Handle(Graphic3d_Group) myTranslatorGroup;
Handle(Graphic3d_Group) myScalerGroup;
Handle(Graphic3d_Group) myRotatorGroup;
+ Handle(Graphic3d_Group) myDraggerGroup;
Handle(Prs3d_Presentation) myHighlightTranslator;
Handle(Prs3d_Presentation) myHighlightScaler;
Handle(Prs3d_Presentation) myHighlightRotator;
+ Handle(Prs3d_Presentation) myHighlightDragger;
Handle(Graphic3d_ArrayOfTriangles) myTriangleArray;
//! Aspect used to color current detected part and current selected part.
Handle(Prs3d_ShadingAspect) myHighlightAspect;
+
+ //! Aspect used to color sector part when it's selected.
+ Handle(Prs3d_ShadingAspect) myDraggerHighlight;
public:
DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)
AIS_MM_None = 0,
AIS_MM_Translation = 1,
AIS_MM_Rotation,
- AIS_MM_Scaling
+ AIS_MM_Scaling,
+ AIS_MM_TranslationPlane
};
#endif
\ No newline at end of file
Prs3d_ToolCylinder.cxx
Prs3d_ToolQuadric.hxx
Prs3d_ToolQuadric.cxx
+Prs3d_ToolSector.hxx
+Prs3d_ToolSector.cxx
Prs3d_ToolSphere.hxx
Prs3d_ToolSphere.cxx
Prs3d_TypeOfHighlight.hxx
--- /dev/null
+// Created on: 2019-02-25
+// Created by: Artem NOVIKOV
+// Copyright (c) 2019 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 <Prs3d_ToolSector.hxx>
+
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+Prs3d_ToolSector::Prs3d_ToolSector (const Standard_Real theRadius,
+ const Standard_Integer theNbSlices,
+ const Standard_Integer theNbStacks)
+: myRadius (theRadius)
+{
+ mySlicesNb = theNbSlices;
+ myStacksNb = theNbStacks;
+}
+
+//=======================================================================
+//function : Vertex
+//purpose :
+//=======================================================================
+gp_Pnt Prs3d_ToolSector::Vertex (const Standard_Real theU, const Standard_Real theV)
+{
+ const Standard_Real aU = theU * M_PI / 2.0;
+ const Standard_Real aRadius = myRadius * theV;
+ return gp_Pnt (Cos (aU) * aRadius,
+ Sin (aU) * aRadius,
+ 0.0);
+}
+
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+gp_Dir Prs3d_ToolSector::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
+{
+ return gp_Dir (0.0, 0.0, -1.0);
+}
+
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolSector::Create (const Standard_Real theRadius,
+ const Standard_Integer theNbSlices,
+ const Standard_Integer theNbStacks,
+ const gp_Trsf& theTrsf)
+{
+ Handle(Graphic3d_ArrayOfTriangles) anArray;
+ Prs3d_ToolSector aTool (theRadius, theNbSlices, theNbStacks);
+ aTool.FillArray (anArray, theTrsf);
+ return anArray;
+}
--- /dev/null
+// Created on: 2019-02-25
+// Created by: Artem NOVIKOV
+// Copyright (c) 2019 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_ToolSector_HeaderFile
+#define _Prs3d_ToolSector_HeaderFile
+
+#include <Standard.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//! Standard presentation algorithm that outputs graphical primitives for disk surface.
+class Prs3d_ToolSector : public Prs3d_ToolQuadric
+{
+public:
+
+ //! Generate primitives for 3D quadric surface and return a filled array.
+ Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theRadius,
+ const Standard_Integer theNbSlices,
+ const Standard_Integer theNbStacks,
+ const gp_Trsf& theTrsf);
+public:
+
+ //! Initializes the algorithm.
+ Standard_EXPORT Prs3d_ToolSector (const Standard_Real theRadius,
+ const Standard_Integer theNbSlices,
+ const Standard_Integer theNbStacks);
+protected:
+
+ //! Computes vertex at given parameter location of the surface.
+ Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+
+ //! Computes normal at given parameter location of the surface.
+ Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+
+protected:
+
+ Standard_Real myRadius;
+
+};
+
+#endif
aCmd.AddOption ("autoActivate", "... {0|1} - set activation on detection");
aCmd.AddOption ("followTranslation", "... {0|1} - set following translation transform");
aCmd.AddOption ("followRotation", "... {0|1} - set following rotation transform");
+ aCmd.AddOption ("followDragging", "... {0|1} - set following dragging transform");
aCmd.AddOption ("gap", "... value - set gap between sub-parts");
aCmd.AddOption ("part", "... axis mode {0|1} - set visual part");
aCmd.AddOption ("pos", "... x y z [nx ny nz [xx xy xz]] - set position of manipulator");
{
aManipulator->ChangeTransformBehavior().SetFollowRotation (aCmd.ArgBool ("followRotation"));
}
+ if (aCmd.HasOption("followDragging", 1, Standard_True))
+ {
+ aManipulator->ChangeTransformBehavior().SetFollowDragging(aCmd.ArgBool("followDragging"));
+ }
if (aCmd.HasOption ("gap", 1, Standard_True))
{
aManipulator->SetGap (aCmd.ArgFloat ("gap"));
Standard_Integer anAxis = aCmd.ArgInt ("part", 0);
Standard_Integer aMode = aCmd.ArgInt ("part", 1);
Standard_Boolean aOnOff = aCmd.ArgBool ("part", 2);
- if (aMode < 1 || aMode > 3)
+ if (aMode < 1 || aMode > 4)
{
- std::cerr << theArgVec[0] << " error: mode value should be in range [1, 3].\n";
+ std::cerr << theArgVec[0] << " error: mode value should be in range [1, 4].\n";
return 1;
}
"\n '-autoActivate {0|1}' - set activation on detection"
"\n '-followTranslation {0|1}' - set following translation transform"
"\n '-followRotation {0|1}' - set following rotation transform"
+ "\n '-followDragging {0|1}' - set following dragging transform"
"\n '-gap value' - set gap between sub-parts"
"\n '-part axis mode {0|1}' - set visual part"
"\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator"
--- /dev/null
+puts "====================================="
+puts "AIS_Manipulator - drag an object"
+puts "====================================="
+
+set anImage1 $imagedir/${casename}_1.png
+set anImage2 $imagedir/${casename}_2.png
+set anImage3 $imagedir/${casename}_3.png
+set anImage4 $imagedir/${casename}_4.png
+set anImage5 $imagedir/${casename}_5.png
+
+# -------------------------------------
+# create manipulated and helper objects
+# -------------------------------------
+
+pcylinder c1 5 10
+pcylinder c2 10 20
+ttranslate c1 105 0 20
+ttranslate c2 100 0 0
+trotate c1 100 0 25 0 1 0 90
+trotate c1 100 0 25 0 0 1 10
+
+# -------------------------------------
+# display manipulated objects
+# -------------------------------------
+
+vdisplay c1
+vdisplay c2
+vsetdispmode 1
+vaxo
+vfit
+
+# ------------------
+# attach manipulator
+# ------------------
+
+vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
+vmanipulator m -followRotation 1
+vmanipulator m -followTranslation 1
+vdump $anImage1
+
+# ----------------------------------------------------
+# test xz plane dragging transform (world reference frame)
+# ----------------------------------------------------
+
+set mouse_pick {211 129}
+set mouse_drag {284 248}
+
+vmoveto {*}$mouse_pick
+vselect {*}$mouse_pick
+vmanipulator m -startTransform {*}$mouse_pick
+vmanipulator m -transform {*}$mouse_drag
+vmanipulator m -stopTransform
+vselect 0 0
+vmoveto {*}$mouse_drag
+vdump $anImage2
+
+# -------------------------------------------
+# rotate around y axis
+# -------------------------------------------
+
+set mouse_pick {316 257}
+set mouse_drag {279 286}
+
+vmoveto {*}$mouse_pick
+vselect {*}$mouse_pick
+vmanipulator m -startTransform {*}$mouse_pick
+vmanipulator m -transform {*}$mouse_drag
+vmanipulator m -stopTransform
+vselect 0 0
+vmoveto {*}$mouse_drag
+vdump $anImage3
+
+# ----------------------------------------------------
+# test xy plane dragging transform (world reference frame)
+# ----------------------------------------------------
+
+set mouse_pick {278 267}
+set mouse_drag {156 276}
+
+vmoveto {*}$mouse_pick
+vselect {*}$mouse_pick
+vmanipulator m -startTransform {*}$mouse_pick
+vmanipulator m -transform {*}$mouse_drag
+vmanipulator m -stopTransform
+vselect 0 0
+vmoveto {*}$mouse_drag
+vdump $anImage4
+
+# ----------------------------------------------------
+# test yz plane dragging transform (world reference frame)
+# ----------------------------------------------------
+
+set mouse_pick {168 258}
+set mouse_drag {166 182}
+
+vmoveto {*}$mouse_pick
+vselect {*}$mouse_pick
+vmanipulator m -startTransform {*}$mouse_pick
+vmanipulator m -transform {*}$mouse_drag
+vmanipulator m -stopTransform
+vselect 0 0
+vmoveto {*}$mouse_drag
+vdump $anImage5
vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
vmanipulator m -followRotation 1
vmanipulator m -followTranslation 1
+vmanipulator m -part 0 4 0
+vmanipulator m -part 1 4 0
+vmanipulator m -part 2 4 0
# ----------------------------------------------------
# test x translation transform (world reference frame)
vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
vmanipulator m -followRotation 1
vmanipulator m -followTranslation 1
+vmanipulator m -part 0 4 0
+vmanipulator m -part 1 4 0
+vmanipulator m -part 2 4 0
set mouse_pick {223 143}
set mouse_drag {181 141}