]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for selection point of transformation constraint presentation
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 17 Jun 2015 10:08:30 +0000 (13:08 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 17 Jun 2015 10:08:30 +0000 (13:08 +0300)
src/SketcherPrs/SketcherPrs_SensitivePoint.cpp
src/SketcherPrs/SketcherPrs_SensitivePoint.h
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/SketcherPrs_Transformation.cpp

index f9a49e9d1dc5aab6e79ac398026d097672cf7e66..fa091f9a75822e7d1b4e2a6f9dffed5350b8fe11 100644 (file)
@@ -7,18 +7,15 @@
 
 #include "SketcherPrs_SensitivePoint.h"
 
-#include <Bnd_Box2d.hxx>
-#include <CSLib_Class2d.hxx>
-#include <ElCLib.hxx>
-#include <TopLoc_Location.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include "SketcherPrs_SymbolPrs.h"
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
 
 SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& anOwner,
-                                                        const Handle(Graphic3d_ArrayOfPoints)& thePntArray, 
-                                                        int theId)
-:Select3D_SensitiveEntity(anOwner), myId(theId), myPntArray(thePntArray)
+                                                       int theId)
+:Select3D_SensitiveEntity(anOwner), myId(theId)
 {
   SetSensitivityFactor(12.);
 }
@@ -28,7 +25,7 @@ Standard_Boolean SketcherPrs_SensitivePoint::Matches (SelectBasics_SelectingVolu
 {
   Standard_Real aDepth      = RealLast();
   Standard_Real aDistToCOG  = RealLast();
-  gp_Pnt aPnt = myPntArray->Vertice(myId);
+  gp_Pnt aPnt = Point();
   if (!theMgr.Overlaps (aPnt, aDepth))
   {
     thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
@@ -42,12 +39,16 @@ Standard_Boolean SketcherPrs_SensitivePoint::Matches (SelectBasics_SelectingVolu
 
 gp_Pnt SketcherPrs_SensitivePoint::Point() const
 {
-  return myPntArray->Vertice(myId);
+  const Handle(SelectMgr_EntityOwner)& anOwner =
+    Handle(SelectMgr_EntityOwner)::DownCast(OwnerId());
+  const Handle(SketcherPrs_SymbolPrs)& aSymbPrs =
+    Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable());
+  return aSymbPrs->pointsArray()->Vertice(myId);
 }
 
 Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected()
 {
-  Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myPntArray, myId);
+  Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myId);
   return aNewEntity;
 }
 
@@ -58,7 +59,7 @@ gp_Pnt SketcherPrs_SensitivePoint::CenterOfGeometry() const
 
 Select3D_BndBox3d SketcherPrs_SensitivePoint::BoundingBox()
 {
-  gp_Pnt aPnt = myPntArray->Vertice(myId);
+  gp_Pnt aPnt = Point();
   return Select3D_BndBox3d (SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()),
                             SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()));
 }
index 31cad7bb22473e9ac0b8eb0bb23b3920e29b7d6b..408bec8e4887034f1e34bdbe5386709303d0aeba 100644 (file)
@@ -8,7 +8,6 @@
 #define SketcherPrs_SensitivePoint_H
 
 #include <Select3D_SensitiveEntity.hxx>
-#include <Graphic3d_ArrayOfPoints.hxx>
 #include <Standard_DefineHandle.hxx>
 
 
@@ -24,8 +23,7 @@ class SketcherPrs_SensitivePoint : public Select3D_SensitiveEntity
 public: 
   //! Constructs a sensitive point object defined by the
   //! owner OwnerId and the point Point.
-  Standard_EXPORT SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& OwnerId, 
-    const Handle(Graphic3d_ArrayOfPoints)& thePntArray, int theId);
+  Standard_EXPORT SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& OwnerId, int theId);
   
   Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
 
@@ -53,7 +51,6 @@ public:
 
 private: 
   int myId;
-  Handle(Graphic3d_ArrayOfPoints) myPntArray;
 };
 
 
index 33a363a1b31e007fc8161234e5be3dd2780f77b0..adc71b67bbadcaba0f17ada42ccdb798228c3e7c 100644 (file)
@@ -352,7 +352,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
 
   mySPoints.Clear();
   for (int i = 1; i <= aNbVertex; i++) {
-    Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
+    Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, i);
     mySPoints.Append(aSP);
   }
 
index 31fb15e5e63edf96a3a22e26ec18833aeb9805ef..1f8894f174c0da0f48c0300737aeadd8a6775a4f 100644 (file)
@@ -65,7 +65,7 @@ public:
   Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }
 
   /// Return array of points where symbols will be placed
-  Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
+  const Handle(Graphic3d_ArrayOfPoints)& pointsArray() const { return myPntArray; }
 
   /// Render of the presentation
   /// \param theWorkspace is OpenGl workspace
index 02a326bfe1a61fe308f865b538bdf661c2226355..47f32f7b550213e411718ed771ad3de8e7a5f604 100644 (file)
@@ -9,9 +9,6 @@
 #include "SketcherPrs_PositionMgr.h"
 
 #include <SketchPlugin_Constraint.h>
-#include <SketchPlugin_MultiRotation.h>
-#include <SketchPlugin_MultiTranslation.h>
-#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeRefList.h>
 
 #include <Graphic3d_AspectLine3d.hxx>
@@ -29,14 +26,6 @@ SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theCons
                                            bool isTranslation) 
  : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
 {
-  int aPointsNb = 0;
-  if (theConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
-    aPointsNb = theConstraint->integer(SketchPlugin_MultiTranslation::NUMBER_OF_COPIES_ID())->value();
-  } else if (theConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
-    aPointsNb = theConstraint->integer(SketchPlugin_MultiRotation::NUMBER_OF_COPIES_ID())->value();
-  }
-  aPointsNb == 0 ? aPointsNb = 2 : aPointsNb++; // by default we have 2 points for symbols
-  myPntArray = new Graphic3d_ArrayOfPoints(aPointsNb);
 }  
 
 bool SketcherPrs_Transformation::updatePoints(double theStep) const 
@@ -51,6 +40,7 @@ bool SketcherPrs_Transformation::updatePoints(double theStep) const
     return false;
 
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  myPntArray = new Graphic3d_ArrayOfPoints(aNbB);
 
   int i;
   ObjectPtr aObj;