]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implementation of Partition movement using new result creation, with different data...
authormpv <mpv@opencascade.com>
Fri, 7 Aug 2015 13:39:15 +0000 (16:39 +0300)
committermpv <mpv@opencascade.com>
Fri, 7 Aug 2015 13:39:15 +0000 (16:39 +0300)
16 files changed:
src/FeaturesPlugin/FeaturesPlugin_Movement.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/placement_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_Movement.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultPart.cpp
src/Model/Model_ResultPart.h
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_Document.h
src/XGUI/XGUI_ErrorMgr.cpp

index bebbcd735c6ee6584d19a427e01de07c98d04628..3a298e2a4c255f9c193fc84e6cf1b23dd1e7647d 100644 (file)
@@ -100,17 +100,7 @@ void FeaturesPlugin_Movement::execute()
     // Setting result.
     if (isPart) {
       ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-
-      ResultPartPtr aCurrentResult;
-      const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = results();
-      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aResults.begin();
-      for(int a = 0; aResIter != aResults.end(); aResIter++, a++)  {
-        if (a == aResultIndex) {
-          aCurrentResult = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aResIter);
-          break;
-        }
-      }
-      ResultPartPtr aResultPart = document()->copyPart(aCurrentResult, anOrigin, aResultIndex);
+      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
       aResultPart->setTrsf(*aContext, aMovementAlgo.transformation());
       setResult(aResultPart);
     } else {
index 69d3cc4a7240f893056b7c79e940ab474f7b5945..a52a2be08bfbc45a5d5953b4fa6e333963d1a647 100644 (file)
@@ -110,8 +110,6 @@ void FeaturesPlugin_Placement::execute()
   bool isReverse = boolean(REVERSE_ID())->value();
   bool isCentering = boolean(CENTERING_ID())->value();
 
-  bool isPart = aContextRes->groupName() == ModelAPI_ResultPart::group();
-
   // Getting transformation.
   GeomAlgoAPI_Placement aPlacementAlgo(
     aStartShape, anEndShape, aStartFace, anEndFace, isReverse, isCentering, true);
@@ -128,11 +126,11 @@ void FeaturesPlugin_Placement::execute()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
       anObjectsIt++, aContext++) {
 
-    if (isPart) { // for part results just set transformation
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aContextRes);
-      ResultPartPtr aResultPart = document()->copyPart(firstResult(), anOrigin);
+    if ((*aContext)->groupName() == ModelAPI_ResultPart::group()) { // for part results just set transformation
+      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
+      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
       aResultPart->setTrsf(aContextRes, aTrsf);
-      setResult(aResultPart);
+      setResult(aResultPart, aResultIndex);
     } else {
       std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
       GeomAlgoAPI_Transform aTransformAlgo(aBaseShape, aTrsf);
index aea860dcb5c98830f5b7fed93f74c355d2c348c3..7007b9bbf5d3bebc7a3566d5f926251a4e6ed2a0 100755 (executable)
@@ -100,17 +100,7 @@ void FeaturesPlugin_Rotation::execute()
     // Setting result.
     if (isPart) {
       ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-
-      ResultPartPtr aCurrentResult;
-      const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = results();
-      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aResults.begin();
-      for(int a = 0; aResIter != aResults.end(); aResIter++, a++)  {
-        if (a == aResultIndex) {
-          aCurrentResult = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aResIter);
-          break;
-        }
-      }
-      ResultPartPtr aResultPart = document()->copyPart(aCurrentResult, anOrigin, aResultIndex);
+      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
       aResultPart->setTrsf(*aContext, aRotationAlgo.transformation());
       setResult(aResultPart);
     } else {
index ec6f228b0d53e17cb32afd1427ee7e5345f27519..1989fb3a99f13969ba09268a8491a0c687df280b 100644 (file)
@@ -5,7 +5,8 @@
     label="Select a solid objects"
     icon=":icons/cut_shape.png"
     tooltip="Select a solid objects"
-    type_choice="Solids">
+    type_choice="Solids"
+    concealment="true" >
   </multi_selector>
   <shape_selector id="placement_start_face"
     label="Select an object" 
@@ -17,8 +18,7 @@
     label="Select an object" 
     icon=":icons/placement_to.png"
     tooltip="Select an end face"
-    shape_types="face"
-    concealment="true" >
+    shape_types="face" >
     <validator id="PartSet_DifferentObjects"/>
   </shape_selector>
   <boolvalue id="placement_reverse_direction"
index 9be419ffec9b2e0d0d4e946e87775438e6e487de..48073be5f519b342bd259ced85e55f18093310b8 100644 (file)
@@ -53,7 +53,8 @@ void GeomAlgoAPI_Movement::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
     TopLoc_Location aDelta(aTrsf);
     aResult = aSourceShape.Moved(aDelta);
     // store the accumulated information about the result and this delta
-    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
+    //myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
+    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf)));
     myDone = true; // is OK for sure
   } else {
     BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
index 6e28fc603c5231023467fcbed35e795957c7fbbc..4e29cdb305d6df989964137f3b9a8ecbba547c9d 100644 (file)
@@ -195,7 +195,8 @@ void GeomAlgoAPI_Placement::build(
     TopoDS_Shape aResult = aSourceShape.Moved(aDelta);
     myShape->setImpl(new TopoDS_Shape(aResult));
     // store the accumulated information about the result and this delta
-    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
+    //myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
+    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf)));
     myDone = true; // it is allways true for simple transformation generation
   } else { // internal rebuild of the shape
     // Transform the shape with copying it
index 1d1d8495971a03daf71238b9c369c11c488df01c..17c88e408cc942d164eaa83d6f03430d97f8afce 100644 (file)
@@ -51,7 +51,8 @@ void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
   if (theSimpleTransform) {
     TopLoc_Location aDelta(aTrsf);
     aResult = aSourceShape.Moved(aDelta);
-    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
+    //myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
+    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf)));
     myDone = true; // is OK for sure
   } else {
     BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
index b160e375259d2b04afbf57cac3d00620ab834600..2ff8141aa7f299036b7229ca609499c63134f257 100644 (file)
@@ -813,11 +813,10 @@ std::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
 }
 
 std::shared_ptr<ModelAPI_ResultPart> Model_Document::copyPart(
-      const std::shared_ptr<ModelAPI_Result>& theOldPart, 
-      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin, 
-      const int theIndex)
+      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
-  return myObjs->copyPart(theOldPart, theOrigin, theIndex);
+  return myObjs->copyPart(theOrigin, theFeatureData, theIndex);
 }
 
 std::shared_ptr<ModelAPI_ResultGroup> Model_Document::createGroup(
index 626e2f4b2a8636abaffb9ab2cbb30236bee3e750..3b7da979074b2efa6f0054ddb9dfd4c68de82e60 100644 (file)
@@ -157,11 +157,10 @@ class Model_Document : public ModelAPI_Document
   /// Creates a part results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
-  //! Copies a part result, keeping the same data
+  //! Copies a part result, keeping the reference to origin
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> copyPart(
-      const std::shared_ptr<ModelAPI_Result>& theOldPart, 
-      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin, 
-      const int theIndex = 0);
+    const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a group results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
index bec8764981b61c836d663b56105a010969f0b36f..9e4e270ac0e02706ae5e4bf060bc5792f1e13dcf 100644 (file)
@@ -799,18 +799,11 @@ std::shared_ptr<ModelAPI_ResultPart> Model_Objects::createPart(
 }
 
 std::shared_ptr<ModelAPI_ResultPart> Model_Objects::copyPart(
-    const std::shared_ptr<ModelAPI_Result>& theOldPart, 
-    const std::shared_ptr<ModelAPI_ResultPart>& theOrigin, const int theIndex)
+    const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
-  std::shared_ptr<ModelAPI_ResultPart> aResult;
-  if (theOldPart.get()) {
-    aResult = std::dynamic_pointer_cast<ModelAPI_ResultPart>(theOldPart);
-  }
-  if (!aResult) {
-    aResult = std::shared_ptr<ModelAPI_ResultPart>(new Model_ResultPart);
-    aResult->setDoc(myDoc);
-    aResult->setData(theOrigin->data());
-  }
+  std::shared_ptr<ModelAPI_ResultPart> aResult = createPart(theFeatureData, theIndex);
+  aResult->data()->reference(Model_ResultPart::BASE_REF_ID())->setValue(theOrigin);
   return aResult;
 }
 
index bf6904715014fe90783cbfb906b55e2b6dddfeb9..45c837d624110ef58fe09faabb03b89175143ddd 100644 (file)
@@ -106,10 +106,10 @@ class Model_Objects
   /// Creates a part results
   std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
-  /// Copies a part results, keeping the same data
+  /// Copies a part results, keeping the reference to origin
   std::shared_ptr<ModelAPI_ResultPart> copyPart(
-      const std::shared_ptr<ModelAPI_Result>& theOldPart, 
-      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin, const int theIndex = 0);
+      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a group results
   std::shared_ptr<ModelAPI_ResultGroup> createGroup(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
index 96957848aa88043dc3419ed34bce058356d5c5c2..246621acd2b626e2f16b8c40e225a886903fc76b 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeReference.h>
 #include <Model_Document.h>
 #include <Events_Loop.h>
 #include <ModelAPI_Events.h>
 #include <BRep_Builder.hxx>
 #include <TopExp_Explorer.hxx>
 
+#define baseRef() std::dynamic_pointer_cast<Model_ResultPart>(data()->reference(BASE_REF_ID())->value())
+
 void Model_ResultPart::initAttributes()
 {
   // append the color attribute. It is empty, the attribute will be filled by a request
   data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
   data()->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
+  data()->addAttribute(BASE_REF_ID(), ModelAPI_AttributeReference::typeId());
 }
 
 std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
 {
+  if (myTrsf.get()) {
+    return baseRef()->partDoc();
+  }
   return data()->document("PartDocument")->value();
 }
 
-std::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
-{
-  return std::shared_ptr<ModelAPI_Feature>();  // return empty pointer
-}
-
 Model_ResultPart::Model_ResultPart()
 {
   myIsDisabled = true; // by default it is not initialized and false to be after created
@@ -50,6 +52,11 @@ Model_ResultPart::Model_ResultPart()
 
 void Model_ResultPart::activate()
 {
+  if (myTrsf.get()) {
+    baseRef()->activate();
+    return;
+  }
+
   std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
   
   if (!aDocRef->value().get()) {  // create (or open) a document if it is not yet created
@@ -74,6 +81,10 @@ void Model_ResultPart::activate()
 
 bool Model_ResultPart::isActivated() 
 {
+  if (myTrsf.get()) {
+    return baseRef()->isActivated();
+  }
+
   std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
   return aDocRef->value().get() != NULL;
 }
@@ -106,8 +117,7 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
 {
   std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
   if (myTrsf.get()) { // get shape of the base result and apply the transformation
-    ResultPtr anOrigResult = 
-      std::dynamic_pointer_cast<ModelAPI_Result>(data()->attribute(COLOR_ID())->owner());
+    ResultPtr anOrigResult = baseRef();
     std::shared_ptr<GeomAPI_Shape> anOrigShape = anOrigResult->shape();
     if (anOrigShape.get()) {
       TopoDS_Shape aShape = anOrigShape->impl<TopoDS_Shape>();
@@ -165,8 +175,7 @@ std::string Model_ResultPart::nameInPart(const std::shared_ptr<GeomAPI_Shape>& t
   theIndex = 0; // not initialized
 
   if (myTrsf.get()) { // if this is moved copy of part => return the name of original shape
-    ResultPartPtr anOrigResult = 
-      std::dynamic_pointer_cast<ModelAPI_ResultPart>(data()->attribute(COLOR_ID())->owner());
+    ResultPartPtr anOrigResult = baseRef();
     // searching in the origin the shape equal to the given but with myTrsf
     TopoDS_Shape aSelection = theShape->impl<TopoDS_Shape>();
     gp_Trsf aSelTrsf = aSelection.Location().Transformation();
index a04e0024f5ce6a650f9a671402fac06ee677af1e..fee8e0ad1e657c8ab37c7867a57d7acc6ebed7d2 100644 (file)
@@ -24,12 +24,17 @@ class Model_ResultPart : public ModelAPI_ResultPart
   TopoDS_Shape myShape; ///< shape of this part created from bodies (updated only of Part deactivation)
   std::shared_ptr<gp_Trsf> myTrsf; ///< if it is just copy of original shape, keep just transformation
  public:
+
+  /// the reference to the base result document, may be null if this is the root, others make sequence of references
+  inline static const std::string& BASE_REF_ID()
+  {
+    static const std::string MY_BASE_REF("BaseReference");
+    return MY_BASE_REF;
+  }
   /// Request for initialization of data model of the result: adding all attributes
   virtual void initAttributes();
   /// Returns the part-document of this result
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> partDoc();
-  /// Part has no stored feature: this method returns NULL
-  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> owner();
 
   /// Sets this document as current and if it is not loaded yet, loads it
   MODEL_EXPORT virtual void activate();
index 692cc088180d9d38797358abfec81e192c3ba916..46efe12ab7e1b30b0c39b8cb12330a758aabceca 100644 (file)
@@ -10,6 +10,7 @@
 
 %{
   #include "ModelAPI.h"
+  #include "ModelAPI_Entity.h"
   #include "ModelAPI_Document.h"
   #include "ModelAPI_Session.h"
   #include "ModelAPI_Object.h"
@@ -69,6 +70,7 @@
 
 // shared pointers
 // For ModelAPI_ResultConstruction.shape()
+%shared_ptr(ModelAPI_Entity)
 %shared_ptr(ModelAPI_Document)
 %shared_ptr(ModelAPI_Session)
 %shared_ptr(ModelAPI_Plugin)
 %shared_ptr(ModelAPI_ResultParameter)
 
 // all supported interfaces
+%include "ModelAPI_Entity.h"
 %include "ModelAPI_Document.h"
 %include "ModelAPI_Session.h"
 %include "ModelAPI_Plugin.h"
index 9557a0851235e1552d27c5cebf82efa864e2cd3e..c05f5c7fe14e9d0753c5f9d95d006b20df29b528 100644 (file)
@@ -130,11 +130,10 @@ public:
   //! Creates a part results
   virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
-  //! Copies a part result, keeping the same data
+  //! Copies a part result, keeping the reference to the origin
   virtual std::shared_ptr<ModelAPI_ResultPart> copyPart(
-      const std::shared_ptr<ModelAPI_Result>& theOldPart, 
-      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin, 
-      const int theIndex = 0) = 0;
+      const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
   //! Creates a group results
   virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
index f46a9291e36d0574b97d96be3470daebe7b2504e..9dda1abbb0ed1f23d7eaa6c83ce2a42eac9b1ebc 100644 (file)
@@ -53,7 +53,7 @@ void XGUI_ErrorMgr::onValidationStateChanged()
 
   // get feature
   FeaturePtr aFeature = anOperationMgr->currentOperation()->feature();
-  if (!aFeature.get())
+  if (!aFeature.get() || !aFeature->data()->isValid())
     return;
 
   // set error indication