]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Revision of unit tests for Sketcher
authorazv <azv@opencascade.com>
Wed, 17 Aug 2016 06:30:24 +0000 (09:30 +0300)
committerazv <azv@opencascade.com>
Wed, 17 Aug 2016 06:30:24 +0000 (09:30 +0300)
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchPlugin/SketchPlugin_MultiRotation.cpp
src/SketchPlugin/SketchPlugin_MultiTranslation.cpp
src/SketchPlugin/Test/TestConstraintDistance.py

index d63c196a4e754a309447dc41ea979276079a1451..42ed4d5b48911f67d7396b26352780bfe8502dc5 100755 (executable)
@@ -229,7 +229,6 @@ void SketchPlugin_ConstraintMirror::erase()
   SketchPlugin_ConstraintBase::erase();
 }
 
-#include <ModelAPI_AttributeRefAttrList.h>
 void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID)
 {
   if (theID == MIRROR_LIST_ID()) {
@@ -240,8 +239,8 @@ void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID)
       AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
           data()->attribute(SketchPlugin_Constraint::ENTITY_C()));
       std::list<ObjectPtr> aTargetList = aRefListOfMirrored->list();
-      std::list<ObjectPtr>::reverse_iterator aTargetIter = aTargetList.rbegin();
-      for (; aTargetIter != aTargetList.rend(); aTargetIter++) {
+      std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
+      for (; aTargetIter != aTargetList.end(); aTargetIter++) {
         FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
         if (aFeature)
           aDoc->removeFeature(aFeature);
index 0ef30f7a166309271f9a23516f049997c243bbea..6ae033dec67086f271731da7795cd6f4f3d1f044 100755 (executable)
@@ -332,8 +332,7 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
         return;
 
       // Clear list of objects
-      AttributeRefListPtr aRefListOfRotated = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-          data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
+      AttributeRefListPtr aRefListOfRotated = reflist(SketchPlugin_Constraint::ENTITY_B());
       std::list<ObjectPtr> aTargetList = aRefListOfRotated->list();
       std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
       std::set<FeaturePtr> aFeaturesToBeRemoved;
@@ -342,10 +341,7 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
         for (int i = 0; i < aNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) {
           aRefListOfRotated->remove(*aTargetIter);
           // remove the corresponding feature from the sketch
-          ResultConstructionPtr aRC =
-            std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aTargetIter);
-          DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
-          FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
+          FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
           if (aFeature)
             aFeaturesToBeRemoved.insert(aFeature);
         }
@@ -353,10 +349,7 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
       ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
 
       aRefListOfRotated->clear();
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        data()->attribute(SketchPlugin_Constraint::ENTITY_A()))->clear();
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        data()->attribute(SketchPlugin_Constraint::ENTITY_B()))->clear();
+      reflist(SketchPlugin_Constraint::ENTITY_A())->clear();
     }
   }
 }
index d6e1d5dd22b50b5b679a11c9ca4ed4cdf4459d22..34e26377b424630c042a9c2233f207dfeced6d2b 100755 (executable)
@@ -274,29 +274,23 @@ void SketchPlugin_MultiTranslation::attributeChanged(const std::string& theID)
       int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value()-1;
       if (aNbCopies <= 0)
         return;
+
+      DocumentPtr aDoc = document();
       // Clear list of objects
-      AttributeRefListPtr aRefListOfTranslated = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-          data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
+      AttributeRefListPtr aRefListOfTranslated = reflist(SketchPlugin_Constraint::ENTITY_B());
       std::list<ObjectPtr> aTargetList = aRefListOfTranslated->list();
       std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
       while (aTargetIter != aTargetList.end()) {
         aTargetIter++;
         for (int i = 0; i < aNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) {
           aRefListOfTranslated->remove(*aTargetIter);
-          // remove the corresponding feature from the sketch
-          ResultConstructionPtr aRC =
-            std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aTargetIter);
-          DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
-          FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
+          FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
           if (aFeature)
             aDoc->removeFeature(aFeature);
         }
       }
       aRefListOfTranslated->clear();
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        data()->attribute(SketchPlugin_Constraint::ENTITY_A()))->clear();
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        data()->attribute(SketchPlugin_Constraint::ENTITY_B()))->clear();
+      reflist(SketchPlugin_Constraint::ENTITY_A())->clear();
     }
   }
 }
index 9f64238c7c9c104e67fff37efd2021d9a345db19..75f4d3fbbbdf94a956e845f5b83a75898548a54b 100644 (file)
@@ -104,9 +104,13 @@ assert (aLineResult is not None)
 aConstraint.execute()
 refattrA.setAttr(aSketchPointCoords)
 refattrB.setAttr(aLineAStartPoint)
+aSession.finishOperation()
+# set flyout point then abort operation, after that check the Distance is correct
+aSession.startOperation()
 aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
 aFlyoutPoint.setValue(50.0, 100.0)
 aSession.finishOperation()
+aSession.abortOperation()
 assert (refattrA.isInitialized())
 assert (refattrB.isInitialized())
 assert (aDistance.isInitialized())
@@ -154,9 +158,13 @@ aLineResult = aSketchLine.firstResult()
 assert (aLineResult is not None)
 refattrA.setObject(aLineResult)
 refattrB.setAttr(aSketchPointCoords)
+aSession.finishOperation()
+# set flyout point then abort operation, after that check the Distance is correct
+aSession.startOperation()
 aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
 aFlyoutPoint.setValue(50.0, 100.0)
 aSession.finishOperation()
+aSession.abortOperation()
 assert (refattrA.isInitialized())
 assert (refattrB.isInitialized())
 assert (aDistance.isInitialized())