]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
PositionMgr improvement
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 16 Mar 2015 14:18:58 +0000 (17:18 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 16 Mar 2015 14:18:58 +0000 (17:18 +0300)
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_PositionMgr.cpp
src/SketcherPrs/SketcherPrs_PositionMgr.h
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Tools.h

index 0b98b3328d093614273088bd8b96b577e79d4b63..06167aa91dc42af558e6a9963f2938e2a3bd9730 100644 (file)
       <feature id="SketchConstraintRigid" title="Fixed" tooltip="Fix an object" icon=":icons/fixed.png">
         <shape_selector id="ConstraintEntityA" label="Object" tooltip="Select an object" 
             shape_types="edge vertex">
-               <validator id="SketchPlugin_ResultPoint"/>
+            <validator id="SketchPlugin_ResultPoint"/>
             <validator id="SketchPlugin_ResultLine"/>
             <validator id="SketchPlugin_ResultArc"/>
         </shape_selector>
index 380c15f9ca12cd94b89729c0f0d63fd47d2cf480..09aebca45e48f0bf4b916e7682f154c09796e119 100644 (file)
@@ -56,17 +56,20 @@ void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& t
 {
   prepareAspect();
 
-  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
   if (aLine1.get() == NULL)
     return;
 
-  std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+  std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(aObj2);
   if (aLine2.get() == NULL)
     return;
-
+  
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
-  gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
-  gp_Pnt aP2 = aMgr->getPosition(aLine2, this);
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+  gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
   aGroup->SetPrimitivesAspect(myAspect);
index 0c9e45da273a071f60fa41c1ec420809a31dc720..287c5fe69dc13f916334038927d0fb46b323d897 100644 (file)
@@ -42,7 +42,7 @@ SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(SketchPlugin_Constraint* th
 {
   myPntArray = new Graphic3d_ArrayOfPoints(2);
   myPntArray->AddVertex(0., 0., 0.);
-  myPntArray->AddVertex(0. ,0., 0.);
+  myPntArray->AddVertex(0.0., 0.);
 }  
 
 void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
@@ -51,17 +51,20 @@ void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3
 {
   prepareAspect();
 
-  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
   if (aLine1.get() == NULL)
     return;
 
-  std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+  std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(aObj2);
   if (aLine2.get() == NULL)
     return;
 
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
-  gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
-  gp_Pnt aP2 = aMgr->getPosition(aLine2, this);
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+  gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
   aGroup->SetPrimitivesAspect(myAspect);
index 5237b18e2b038f8c6d8300320ddbcc02037a6435..36c5a72b2da20374062eda77e6f1bc53f76b9512 100644 (file)
@@ -5,6 +5,7 @@
 // Author:      Vitaly SMETANNIKOV
 
 #include "SketcherPrs_PositionMgr.h"
+#include "SketcherPrs_Tools.h"
 
 #include <GeomAPI_Edge.h>
 
@@ -25,7 +26,7 @@ SketcherPrs_PositionMgr::SketcherPrs_PositionMgr()
 }
 
 
-int SketcherPrs_PositionMgr::getPositionIndex(std::shared_ptr<GeomAPI_Shape> theLine, 
+int SketcherPrs_PositionMgr::getPositionIndex(ObjectPtr theLine, 
                                               Handle(SketcherPrs_SymbolPrs) thePrs)
 {
   if (myShapes.count(theLine) == 1) {
@@ -45,11 +46,12 @@ int SketcherPrs_PositionMgr::getPositionIndex(std::shared_ptr<GeomAPI_Shape> the
   }
 }
 
-gp_Pnt SketcherPrs_PositionMgr::getPosition(std::shared_ptr<GeomAPI_Shape> theLine, 
+gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theLine, 
                                             Handle(SketcherPrs_SymbolPrs) thePrs)
 {
+  std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getLine(theLine);
   std::shared_ptr<GeomAPI_Edge> aEdge = 
-    std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(theLine));
+    std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aShape));
 
   std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
   std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
@@ -96,7 +98,7 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(std::shared_ptr<GeomAPI_Shape> theLi
 
 void SketcherPrs_PositionMgr::deleteConstraint(Handle(SketcherPrs_SymbolPrs) thePrs)
 {
-  std::map<std::shared_ptr<GeomAPI_Shape>, PositionsMap>::iterator aIt;
+  std::map<ObjectPtr, PositionsMap>::iterator aIt;
   for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) {
     PositionsMap& aPosMap = aIt->second;
     if (aPosMap.count(thePrs.Access()) > 0) 
index 8c8445de8d2b9195e91e2710873fc4edd3e72d92..65a2aa06827c3407fe1e780c5fddb95b70d48f58 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <GeomAPI_Shape.h>
 #include <gp_Pnt.hxx>
+#include <ModelAPI_Object.h>
 
 #include <map>
 
@@ -28,7 +29,7 @@ public:
   /// Returns position of symbol for the given presentation
   /// \param theLine constrained object 
   /// \param thePrs a presentation of constraint
-  gp_Pnt getPosition(std::shared_ptr<GeomAPI_Shape> theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
+  gp_Pnt getPosition(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
 
   /// Deletes constraint object from internal structures. Has to be called on constraint delete.
   /// \param thePrs a constraint presentation
@@ -41,7 +42,7 @@ private:
   /// Returns position index of the given constraint
   /// \param theLine constrained object 
   /// \param thePrs a presentation of constraint
-  int getPositionIndex(std::shared_ptr<GeomAPI_Shape> theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
+  int getPositionIndex(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
 
 private:
   typedef std::map<void*, int> PositionsMap;
@@ -50,7 +51,7 @@ private:
   PositionsMap myIndexes;
 
   /// The map contains position index 
-  std::map<std::shared_ptr<GeomAPI_Shape>, PositionsMap> myShapes;
+  std::map<ObjectPtr, PositionsMap> myShapes;
 };
 
 #endif
\ No newline at end of file
index e171bf80cf4edc98205f9feec8c7252ecd725250..099096c202c60ef6f2d4962b6a35fbd319409351 100644 (file)
@@ -55,12 +55,13 @@ void SketcherPrs_Rigid::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
 {
   prepareAspect();
 
-  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
   if (aLine1.get() == NULL)
     return;
 
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
-  gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
   aGroup->SetPrimitivesAspect(myAspect);
index fe06620a3703c8bf4a97c0aa18c8025fc4bc1141..9e051971af61cd2853c8e0ea2b05a2d2ea50719c 100644 (file)
@@ -70,7 +70,8 @@ void SketcherPrs_SymbolPrs::prepareAspect()
 
 void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
 {
-  std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
+  ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, theAttrName);
+  std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getLine(aObj);
   if (aLine.get() == NULL)
     return;
   std::shared_ptr<GeomAPI_Edge> aEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLine));
index 5f109ca4d4236923ce24f2d4f97f25e0834c8157..e92283e42c13fdaf130bbce827c7d5c189e7e128 100644 (file)
 
 namespace SketcherPrs_Tools {
 
-
-std::shared_ptr<GeomAPI_Shape> getLine(SketchPlugin_Constraint* theFeature,
-                                      const std::string& theAttrName)
+ObjectPtr getResult(SketchPlugin_Constraint* theFeature, const std::string& theAttrName)
 {
   std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttrName));
 
-  ObjectPtr aObject = anAttr->object();
-  ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObject);
+  return anAttr->object();
+}
+
+
+std::shared_ptr<GeomAPI_Shape> getLine(ObjectPtr theObject)
+{
+  ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theObject);
   if (aRes.get() != NULL) {
     return aRes->shape();
   }
index ac779d38e6cf8d3d02f2c02de79e610d64fd0351..e913a2fd696f11464e5243e7c04a17b4aee87996 100644 (file)
 #include "SketcherPrs.h"
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_Pnt2d.h>
+#include <ModelAPI_Object.h>
 #include <string>
 
 class SketchPlugin_Constraint;
 
 namespace SketcherPrs_Tools {
 
-  std::shared_ptr<GeomAPI_Shape> getLine(SketchPlugin_Constraint* theFeature,
-                                        const std::string& theAttrName);
+  ObjectPtr getResult(SketchPlugin_Constraint* theFeature,
+                      const std::string& theAttrName);
+
+  std::shared_ptr<GeomAPI_Shape> getLine(ObjectPtr theObject);
 
   std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
                                           const std::string& theAttrName);