Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 28 Oct 2014 17:30:28 +0000 (20:30 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 28 Oct 2014 17:30:28 +0000 (20:30 +0300)
34 files changed:
src/ConstructionPlugin/Test/TestPointName.py
src/Model/Model_Data.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_AttributeBoolean.h
src/ModelAPI/ModelAPI_AttributeDocRef.h
src/ModelAPI/ModelAPI_AttributeRefAttr.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeReference.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/Test/TestUndoRedo.py
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/Test/TestConstraintConcidence.py
src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestConstraintLength.py
src/SketchPlugin/Test/TestConstraintParallel.py
src/SketchPlugin/Test/TestConstraintPerpendicular.py
src/SketchPlugin/Test/TestConstraintRadius.py
src/SketchPlugin/Test/TestSketchArcCircle.py
src/SketchPlugin/Test/TestSketchPointLine.py
src/XGUI/XGUI_ContextMenuMgr.cpp

index 740bd52df948bef566b46c4c73af4f5cfc80a296..df76871f2d02cf6e0488d9e9df9c8fbbdea7a3f8 100644 (file)
@@ -6,10 +6,11 @@ aDoc = aSession.moduleDocument()
 aSession.startOperation()
 aFeature = aDoc.addFeature("Point")
 aFeatureData = aFeature.data()
+assert(aFeatureData is not None)
 aFeatureData.real("x").setValue(0.)
 aFeatureData.real("y").setValue(0.)
 aFeatureData.real("z").setValue(0.)
-aFeatureName = aFeatureData.name()
+aFeatureName = aFeature.name()
 aFeature.execute()
 aSession.finishOperation()
 
index fe65a751d7719525fa0721b123a776b358241481..a3a1177410a933b240cda98348d735da7eff1481 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomData_Point.h>
 #include <GeomData_Point2D.h>
index ccdd45e77d1588a490b8edec85e784be4178a34c..c6a669718b51b5456b35293d41880af09acfee91 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Session.h>
 #include <Events_Loop.h>
 #include <Events_LongOp.h>
 #include <Events_Error.h>
index 7ff2bfc8e52974b6b3030849510dac2f7d67c6e1..ba16e8f1c1a2ffbe453e7956f5d3b59105f8092a 100644 (file)
@@ -8,6 +8,7 @@
   #include "ModelAPI_Session.h"
   #include "ModelAPI_Object.h"
   #include "ModelAPI_Feature.h"
+  #include "ModelAPI_CompositeFeature.h"
   #include "ModelAPI_Data.h"
   #include "ModelAPI_Attribute.h"
   #include "ModelAPI_AttributeDocRef.h"
   #include "ModelAPI_ResultBody.h"
   #include "ModelAPI_ResultPart.h"
   
-  template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject) 
+  template<class T1, class T2> 
+  boost::shared_ptr<T1> boost_cast(boost::shared_ptr<T2> theObject)
   { 
-    return boost::dynamic_pointer_cast<T>(theObject); 
+    return boost::dynamic_pointer_cast<T1>(theObject); 
   }
   
-   
 %}
 
 // to avoid error on this
@@ -52,6 +53,7 @@
 %shared_ptr(ModelAPI_Session)
 %shared_ptr(ModelAPI_Object)
 %shared_ptr(ModelAPI_Feature)
+%shared_ptr(ModelAPI_CompositeFeature)
 %shared_ptr(ModelAPI_Data)
 %shared_ptr(ModelAPI_Attribute)
 %shared_ptr(ModelAPI_AttributeDocRef)
@@ -76,6 +78,7 @@
 %include "ModelAPI_Session.h"
 %include "ModelAPI_Object.h"
 %include "ModelAPI_Feature.h"
+%include "ModelAPI_CompositeFeature.h"
 %include "ModelAPI_Data.h"
 %include "ModelAPI_Attribute.h"
 %include "ModelAPI_AttributeDocRef.h"
 %template(ObjectList) std::list<boost::shared_ptr<ModelAPI_Object> >;
 %template(ResultList) std::list<boost::shared_ptr<ModelAPI_Result> >;
 
-template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject);
-%template(modelAPI_ResultConstruction) castTo<ModelAPI_ResultConstruction>;
-%template(modelAPI_ResultBody) castTo<ModelAPI_ResultBody>;
-%template(modelAPI_ResultPart) castTo<ModelAPI_ResultPart>;
+template<class T1, class T2> boost::shared_ptr<T1> boost_cast(boost::shared_ptr<T2> theObject);
+%template(modelAPI_CompositeFeature) boost_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
+%template(modelAPI_ResultConstruction) boost_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
+%template(modelAPI_ResultBody) boost_cast<ModelAPI_ResultBody, ModelAPI_Result>;
+%template(modelAPI_ResultPart) boost_cast<ModelAPI_ResultPart, ModelAPI_Result>;
+
+
index dcd76efc7a9b7184de03fe8cbcf42c25899f0ab8..cf431322bf298de5b87f8aea74aa707746ad4c43 100644 (file)
@@ -45,4 +45,6 @@ class ModelAPI_AttributeBoolean : public ModelAPI_Attribute
   }
 };
 
+typedef boost::shared_ptr<ModelAPI_AttributeBoolean> AttributeBooleanPtr;
+
 #endif
index 7ee1ff1ca0477a790475474e05c6aea5bd620d54..cf7cc84f379c0f8cab8cb209312d4034fd8a3c06 100644 (file)
@@ -46,4 +46,6 @@ class ModelAPI_AttributeDocRef : public ModelAPI_Attribute
   }
 };
 
+typedef boost::shared_ptr<ModelAPI_AttributeDocRef> AttributeDocRefPtr;
+
 #endif
index dc862f3a63d37bda21f87d2fb6fcd6f1ecedfd24..a3bf80601bbac2ade06f79d8de8f621b32b2276b 100644 (file)
@@ -56,4 +56,6 @@ class ModelAPI_AttributeRefAttr : public ModelAPI_Attribute
   }
 };
 
+typedef boost::shared_ptr<ModelAPI_AttributeRefAttr> AttributeRefAttrPtr;
+
 #endif
index abb39beb645cc8b9bb3cf6b58c54cb291406aa88..d8edfe8d0bfdb1a4d8411512cc6b1823e3fdabda 100644 (file)
@@ -51,4 +51,6 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute
   }
 };
 
+typedef boost::shared_ptr<ModelAPI_AttributeRefList> AttributeRefListPtr;
+
 #endif
index 14d63ae32551893516dcd42ab8b0b3df4faf0fc9..5354e8af54a15214a9d8ee3d76873107b4a65286 100644 (file)
@@ -46,4 +46,6 @@ class ModelAPI_AttributeReference : public ModelAPI_Attribute
   }
 };
 
+typedef boost::shared_ptr<ModelAPI_AttributeReference> AttributeReferencePtr;
+
 #endif
index b3dc06045a0461975b881b84a58398613e2281ab..14a1e396f55f0ad3c252e315a7c2c8f93d1937d0 100644 (file)
@@ -7,6 +7,7 @@
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Session.h>
 #include <Events_Loop.h>
 
 const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results()
index a6c51d0407958d4831cc29773cc8e127aec5e9d1..3dc6a3d5d956a1e6622a51cb37647b559a1f31c1 100644 (file)
@@ -5,13 +5,27 @@
 #ifndef ModelAPI_Feature_H_
 #define ModelAPI_Feature_H_
 
-#include "ModelAPI_Object.h"
-#include "ModelAPI_Session.h"
+#include <ModelAPI.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Result.h>
 
-#include <string>
-#include <list>
 #include <boost/shared_ptr.hpp>
 
+#include <list>
+#include <string>
+
 class ModelAPI_Data;
 class ModelAPI_Document;
 class ModelAPI_Result;
@@ -36,6 +50,12 @@ class ModelAPI_Feature : public ModelAPI_Object
     return MY_GROUP;
   }
 
+  /// Returns document this feature belongs to
+  virtual boost::shared_ptr<ModelAPI_Document> document()
+  {
+    return ModelAPI_Object::document();
+  }
+
   /// Returns the group identifier of this result
   virtual std::string groupName()
   {
@@ -84,9 +104,73 @@ class ModelAPI_Feature : public ModelAPI_Object
 
   MODELAPI_EXPORT static boost::shared_ptr<ModelAPI_Feature> feature(ObjectPtr theObject);
 
+ //
+ // Helper methods, aliases for data()->method()
+ // -----------------------------------------------------------------------------------------------
+  inline std::string name()
+  {
+    return data()->name();
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID)
+  {
+    return data()->boolean(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID)
+  {
+    return data()->document(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID)
+  {
+    return data()->real(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeInteger> integer(const std::string& theID)
+  {
+    return data()->integer(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID)
+  {
+    return data()->refattr(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID)
+  {
+    return data()->reference(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID)
+  {
+    return data()->reflist(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeSelection> selection(const std::string& theID)
+  {
+    return data()->selection(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeSelectionList> selectionList(const std::string& theID)
+  {
+    return data()->selectionList(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID)
+  {
+    return data()->string(theID);
+  }
+
+  inline boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID)
+  {
+    return data()->attribute(theID);
+  }
+ // -----------------------------------------------------------------------------------------------
 };
 
 //! Pointer on feature object
 typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;
 
 #endif
+
index 1d0a37209b80cba0da6721496cb0f3d4a349a71b..26f54acb57863f07827cc21a36449d08221d9668 100644 (file)
@@ -6,13 +6,12 @@ assert(not aSession.canRedo())
 \r
 aSession.startOperation()\r
 aFeature = aDoc.addFeature("Point")\r
-aFeatureData = aFeature.data()\r
 # Since validators are introduced we have to initialize all\r
 # the feature's attributes\r
-aFeatureData.real("x").setValue(1.)\r
-aFeatureData.real("y").setValue(-1.)\r
-aFeatureData.real("z").setValue(0.)\r
-aFeatureName = aFeatureData.name()\r
+aFeature.real("x").setValue(1.)\r
+aFeature.real("y").setValue(-1.)\r
+aFeature.real("z").setValue(0.)\r
+aFeatureName = aFeature.name()\r
 assert(aFeatureName == "Point_1")\r
 \r
 aFeature.execute()\r
index 3f29da13070d1ef9aa6ef8ed4783756aa21c6d26..896da097e6160d7f73ed867ea9b9c3a5dc48869d 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomAPI_Pnt2d.h>
 
index a4c08523d29c26bacb21aa46167d8e97b8b7a37b..bd45e4ee04ae26eabd8b8a42cbde496e3f80423b 100644 (file)
@@ -27,6 +27,7 @@
 #include <ModuleBase_WidgetMultiSelector.h>
 
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
index fcc226b3ea4cc67660f9edd0dc78992a95c30f01..faf664fe53e9d48180ac7323988e5be4e256808f 100644 (file)
@@ -21,6 +21,7 @@
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_ResultValidator.h>
 #include <ModelAPI_RefAttrValidator.h>
+#include <ModelAPI_Session.h>
 
 #include <QWidget>
 #include <QLineEdit>
index d2369702f9ec3f2e2a106f267fba9cb6b7cf680c..36191b141ad90918838b0122f2bacc47ccbc7fa0 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 #include <ModuleBase_WidgetFileSelector.h>
 #include <ModuleBase_Tools.h>
 
index 8f0252c8b50e9946416b66a7d149e2a7fd97ec1a..658dbff6cf60a2af127d0e1da8e40b0ea24b50ff 100644 (file)
@@ -18,6 +18,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Point.h>
index 74a83734c198efb1ead726d00276d7fab3cefc1b..dc4feb845df6099a441ecbec50a169b55709155c 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Dir.h>
index a2f006fa42880133ca20e36835d2a5f534517cf3..8c6e8cc0ae117285373734155090805ffa58069d 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Session.h>
 
 using namespace std;
 
index 5494949d8337448b660da84d563b46943b42ff1a..d459d9753a76aa8e4bb3176279b186e2c7f3e4ac 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Session.h>
 
 void PartSetPlugin_Remove::execute()
 {
index ec9d227deec81d97d63e91b2eec985cee2d73a7b..ae0b225ecb25e93cf741d734f4555bffa62c44ee 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomAPI_Circ2d.h>
 #include <GeomAPI_Pnt2d.h>
index 4828a0f7b91a7b247e6e833caa30d6abaf493664..e4d9d8e94411e5185246105a54ee92cf61a1a975 100644 (file)
@@ -8,6 +8,8 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomAPI_Pnt2d.h>
 #include <GeomDataAPI_Point2D.h>
@@ -15,7 +17,6 @@
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
-#include <ModelAPI_AttributeDouble.h>
 
 SketchPlugin_Circle::SketchPlugin_Circle()
     : SketchPlugin_Feature()
index 72a20f8618db061541c325f0ca7162a8f8d992ff..ccefb4bec3aba9a144313b2a8842b55e11629a54 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Lin2d.h>
index c198e9b90fd22c44e7c066ea30ee88a022aa2df1..1ad78684f8ab806ea8676054956b1083aac3aa47 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
 
 #include <GeomAPI_Pnt2d.h>
 
index 555f0abfeb50e3e2c0b05225e91e83e658fa2b93..b71d5adbd69b29d7baf6f03b3c0e9e924ebe2fc9 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_ResultValidator.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Session.h>
 #include <GeomDataAPI_Point2D.h>
 
 bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
index da616ce62143c5b0bba43d69ce88657b0b1d66e7..dedb420a5d7d41bc0b34474d21a33d4e16c1381f 100644 (file)
@@ -22,7 +22,7 @@ from ModelAPI import *
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-07-28"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -31,37 +31,34 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Create a line and an arc
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 aSketchArc = aDocument.addFeature("SketchArc")
 aSketchReflist.append(aSketchArc)
-aSketchArcData = aSketchArc.data()
-anArcCentr = geomDataAPI_Point2D(aSketchArcData.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
 anArcStartPoint = geomDataAPI_Point2D(
-    aSketchArcData.attribute("ArcStartPoint"))
-anArcEndPoint = geomDataAPI_Point2D(aSketchArcData.attribute("ArcEndPoint"))
+    aSketchArc.attribute("ArcStartPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 aSketchFeature = aDocument.addFeature("SketchConstraintCoincidence")
 anArcCentr.setValue(10., 10.)
 anArcStartPoint.setValue(0., 50.)
 anArcEndPoint.setValue(50., 0.)
 aSketchLine = aDocument.addFeature("SketchLine")
 aSketchReflist.append(aSketchLine)
-aSketchLineData = aSketchLine.data()
-aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint = geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 # Lets initialize line start at circle's end:
 aLineStartPoint.setValue(50., 0.)
 aLineEndPoint.setValue(100., 25.)
@@ -72,9 +69,8 @@ aSession.finishOperation()
 aSession.startOperation()
 aConstraint = aDocument.addFeature("SketchConstraintCoincidence")
 aSketchReflist.append(aConstraint)
-aConstraintData = aConstraint.data()
-reflistA = aConstraintData.refattr("ConstraintEntityA")
-reflistB = aConstraintData.refattr("ConstraintEntityB")
+reflistA = aConstraint.refattr("ConstraintEntityA")
+reflistB = aConstraint.refattr("ConstraintEntityB")
 reflistA.setAttr(anArcEndPoint)
 reflistB.setAttr(aLineStartPoint)
 aSession.finishOperation()
index 2d84321be0cf622a7f9d2b150233ed27e99138de..4c50263b2e1baf1ee85da7b24d4deffc29d85aee 100644 (file)
@@ -26,7 +26,7 @@ import math
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-07-29"
+__updated__ = "2014-10-28"
 
 
 def distance(pointA, pointB):
@@ -44,33 +44,28 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Create a point and a line
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchPoint = aDocument.addFeature("SketchPoint")
-aSketchReflist.append(aSketchPoint)
-aSketchPointData = aSketchPoint.data()
+aSketchPoint = aSketchFeature.addFeature("SketchPoint")
 aSketchPointCoords = geomDataAPI_Point2D(
-    aSketchPointData.attribute("PointCoordindates"))
+    aSketchPoint.attribute("PointCoordindates"))
 aSketchPointCoords.setValue(50., 50.)
-aSketchLine = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLine)
-aLineAStartPoint = geomDataAPI_Point2D(
-    aSketchLine.data().attribute("StartPoint"))
-aLineAEndPoint = geomDataAPI_Point2D(aSketchLine.data().attribute("EndPoint"))
+aSketchLine = aSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 aLineAStartPoint.setValue(0., 25.)
 aLineAEndPoint.setValue(100., 25.)
 aSession.finishOperation()
@@ -79,12 +74,10 @@ aSession.finishOperation()
 #=========================================================================
 assert (distance(aSketchPointCoords, aLineAStartPoint) != 25.)
 aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintDistance")
-aSketchReflist.append(aConstraint)
-aConstraintData = aConstraint.data()
-aDistance = aConstraintData.real("ConstraintValue")
-refattrA = aConstraintData.refattr("ConstraintEntityA")
-refattrB = aConstraintData.refattr("ConstraintEntityB")
+aConstraint = aSketchFeature.addFeature("SketchConstraintDistance")
+aDistance = aConstraint.real("ConstraintValue")
+refattrA = aConstraint.refattr("ConstraintEntityA")
+refattrB = aConstraint.refattr("ConstraintEntityB")
 assert (not aDistance.isInitialized())
 assert (not refattrA.isInitialized())
 assert (not refattrB.isInitialized())
index 28f032e4ad309da415c1e6b4fd1ed1e5e25530cc..48acf2c6b612bc12b12749f1bd089b5c8025f7ca 100644 (file)
@@ -15,7 +15,7 @@ from ModelAPI import *
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -23,27 +23,24 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Create a line with length 100
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
-aLineAStartPoint = geomDataAPI_Point2D(
-    aSketchLineA.data().attribute("StartPoint"))
-aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.data().attribute("EndPoint"))
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
 aLineAStartPoint.setValue(0., 25.)
 aLineAEndPoint.setValue(100., 25.)
 aSession.finishOperation()
@@ -51,11 +48,9 @@ aSession.finishOperation()
 # Make a constraint to keep the length
 #=========================================================================
 aSession.startOperation()
-aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
-aSketchReflist.append(aLengthConstraint)
-aConstraintData = aLengthConstraint.data()
-refattrA = aConstraintData.refattr("ConstraintEntityA")
-aLength = aConstraintData.real("ConstraintValue")
+aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
+refattrA = aLengthConstraint.refattr("ConstraintEntityA")
+aLength = aLengthConstraint.real("ConstraintValue")
 assert (not refattrA.isInitialized())
 assert (not aLength.isInitialized())
 
index aa244cee7ab3d08a016b464dbf6cf6a4068d130d..18fbc6832dfbec36bc441442cdab8e6ff41163d4 100644 (file)
@@ -15,7 +15,7 @@ from ModelAPI import *
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -23,38 +23,31 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Create two lines which are not parallel
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
 # line A
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
-aLineAStartPoint = geomDataAPI_Point2D(
-    aSketchLineA.data().attribute("StartPoint"))
-aLineAEndPoint = geomDataAPI_Point2D(
-    aSketchLineA.data().attribute("EndPoint"))
-aSketchLineB = aDocument.addFeature("SketchLine")
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aSketchLineB = aSketchFeature.addFeature("SketchLine")
 aLineAStartPoint.setValue(0., 25)
 aLineAEndPoint.setValue(85., 25)
 # line B
-aSketchReflist.append(aSketchLineB)
-aLineBStartPoint = geomDataAPI_Point2D(
-    aSketchLineB.data().attribute("StartPoint"))
-aLineBEndPoint = geomDataAPI_Point2D(
-    aSketchLineB.data().attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
 aLineBStartPoint.setValue(0., 50)
 aLineBEndPoint.setValue(80., 75)
 aSession.finishOperation()
@@ -64,10 +57,8 @@ aSession.finishOperation()
 #=========================================================================
 for eachFeature in [aSketchLineA, aSketchLineB]:
     aSession.startOperation()
-    aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
-    aSketchReflist.append(aLengthConstraint)
-    aLengthConstraintData = aLengthConstraint.data()
-    refattrA = aLengthConstraintData.refattr("ConstraintEntityA")
+    aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
+    refattrA = aLengthConstraint.refattr("ConstraintEntityA")
     aResultA = modelAPI_ResultConstruction(eachFeature.firstResult())
     assert (aResultA is not None)
     refattrA.setObject(aResultA)
@@ -86,11 +77,9 @@ assert (aLineBEndPoint.y() == 75)
 # Link lines with parallel constraint
 #=========================================================================
 aSession.startOperation()
-aParallelConstraint = aDocument.addFeature("SketchConstraintParallel")
-aSketchReflist.append(aParallelConstraint)
-aConstraintData = aParallelConstraint.data()
-refattrA = aConstraintData.refattr("ConstraintEntityA")
-refattrB = aConstraintData.refattr("ConstraintEntityB")
+aParallelConstraint = aSketchFeature.addFeature("SketchConstraintParallel")
+refattrA = aParallelConstraint.refattr("ConstraintEntityA")
+refattrB = aParallelConstraint.refattr("ConstraintEntityB")
 # aResultA is already defined for the length constraint
 aResultA = modelAPI_ResultConstruction(eachFeature.firstResult())
 aResultB = modelAPI_ResultConstruction(aSketchLineB.firstResult())
index 192f1d9ac12078f44d72a074f72b79d1157d54af..38b605f233f80cc82a0f393cd11cc87d36d26981 100644 (file)
@@ -22,7 +22,7 @@ from ModelAPI import *
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -30,38 +30,31 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Create two lines which are already perpendicular
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
 # line A
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
-aLineAStartPoint = geomDataAPI_Point2D(
-    aSketchLineA.data().attribute("StartPoint"))
-aLineAEndPoint = geomDataAPI_Point2D(
-    aSketchLineA.data().attribute("EndPoint"))
-aSketchLineB = aDocument.addFeature("SketchLine")
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+# line B
+aSketchLineB = aSketchFeature.addFeature("SketchLine")
 aLineAStartPoint.setValue(0., 25)
 aLineAEndPoint.setValue(85., 25)
-# line B
-aSketchReflist.append(aSketchLineB)
-aLineBStartPoint = geomDataAPI_Point2D(
-    aSketchLineB.data().attribute("StartPoint"))
-aLineBEndPoint = geomDataAPI_Point2D(
-    aSketchLineB.data().attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
 aLineBStartPoint.setValue(25., 40.)
 aLineBEndPoint.setValue(25., 125.)
 aSession.finishOperation()
@@ -72,10 +65,8 @@ aSession.finishOperation()
 
 for eachFeature in [aSketchLineA, aSketchLineB]:
     aSession.startOperation()
-    aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
-    aSketchReflist.append(aLengthConstraint)
-    aLengthConstraintData = aLengthConstraint.data()
-    refattrA = aLengthConstraintData.refattr("ConstraintEntityA")
+    aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
+    refattrA = aLengthConstraint.refattr("ConstraintEntityA")
     aResultA = modelAPI_ResultConstruction(eachFeature.firstResult())
     assert (aResultA is not None)
     refattrA.setObject(aResultA)
@@ -95,12 +86,10 @@ assert (aLineBEndPoint.y() == 125)
 # Link lines with perpendicular constraint
 #=========================================================================
 aSession.startOperation()
-aPerpendicularConstraint = aDocument.addFeature(
+aPerpendicularConstraint = aSketchFeature.addFeature(
     "SketchConstraintPerpendicular")
-aSketchReflist.append(aPerpendicularConstraint)
-aConstraintData = aPerpendicularConstraint.data()
-refattrA = aConstraintData.refattr("ConstraintEntityA")
-refattrB = aConstraintData.refattr("ConstraintEntityB")
+refattrA = aPerpendicularConstraint.refattr("ConstraintEntityA")
+refattrB = aPerpendicularConstraint.refattr("ConstraintEntityB")
 # aResultA is already defined for the length constraint
 aResultB = modelAPI_ResultConstruction(aSketchLineB.firstResult())
 assert (aResultB is not None)
index 630beb124a11f53709ffe9de1d9837628666e389..afe60ba4f4971bb09d57c0ea3e9d08f63e28533e 100644 (file)
@@ -24,7 +24,7 @@ import math
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -32,41 +32,34 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Creation of an arc and a circle
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchArc = aDocument.addFeature("SketchArc")
-aSketchReflist.append(aSketchArc)
-aSketchArcData = aSketchArc.data()
-anArcCentr = geomDataAPI_Point2D(aSketchArcData.attribute("ArcCenter"))
+aSketchArc = aSketchFeature.addFeature("SketchArc")
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
 anArcCentr.setValue(10., 10.)
-anArcStartPoint = geomDataAPI_Point2D(
-    aSketchArcData.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
 anArcStartPoint.setValue(0., 50.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArcData.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
 # Circle
 aSession.startOperation()
-aSketchCircle = aDocument.addFeature("SketchCircle")
-aSketchReflist.append(aSketchCircle)
-aSketchCircleData = aSketchCircle.data()
-anCircleCentr = geomDataAPI_Point2D(
-    aSketchCircleData.attribute("CircleCenter"))
-aCircleRadius = aSketchCircleData.real("CircleRadius")
+aSketchCircle = aSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
 anCircleCentr.setValue(-25., -25)
 aCircleRadius.setValue(25.)
 aSession.finishOperation()
@@ -74,11 +67,9 @@ aSession.finishOperation()
 # Make a constraint to keep the radius of the arc
 #=========================================================================
 aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintRadius")
-aSketchReflist.append(aConstraint)
-aConstraintData = aConstraint.data()
-aRadius = aConstraintData.real("ConstraintValue")
-aRefObject = aConstraintData.refattr("ConstraintEntityA")
+aConstraint = aSketchFeature.addFeature("SketchConstraintRadius")
+aRadius = aConstraint.real("ConstraintValue")
+aRefObject = aConstraint.refattr("ConstraintEntityA")
 aResult = aSketchArc.firstResult()
 assert (aResult is not None)
 aRefObject.setObject(modelAPI_ResultConstruction(aResult))
@@ -90,11 +81,9 @@ assert (aRefObject.isInitialized())
 # Make a constraint to keep the radius of the circle
 #=========================================================================
 aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintRadius")
-aSketchReflist.append(aConstraint)
-aConstraintData = aConstraint.data()
-aRadius = aConstraintData.real("ConstraintValue")
-aRefObject = aConstraintData.refattr("ConstraintEntityA")
+aConstraint = aSketchFeature.addFeature("SketchConstraintRadius")
+aRadius = aConstraint.real("ConstraintValue")
+aRefObject = aConstraint.refattr("ConstraintEntityA")
 aResult = aSketchCircle.firstResult()
 assert (aResult is not None)
 aRefObject.setObject(modelAPI_ResultConstruction(aResult))
index 4223d5c35d104583365f346c354538e8d3a2a320..8ce7a3186b3bef32c439dceab06b871ab1098e45 100644 (file)
@@ -22,7 +22,7 @@
 from GeomDataAPI import *
 from ModelAPI import *
 
-__updated__ = "2014-07-25"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -30,49 +30,49 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+#aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Creation of an arc
 # 1. Test SketchPlugin_Arc attributes
-# 2. 
+# 2.
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 assert (not aSketchReflist.isInitialized())
 assert (aSketchReflist.size() == 0)
 assert (len(aSketchReflist.list()) == 0)
-aSketchArc = aDocument.addFeature("SketchArc")
+aSketchArc = aSketchFeature.addFeature("SketchArc")
 assert (aSketchArc.getKind() == "SketchArc")
-aSketchReflist.append(aSketchArc)
-aSketchArcData = aSketchArc.data()
-anArcCentr = geomDataAPI_Point2D(aSketchArcData.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
 assert (anArcCentr.x() == 0)
 assert (anArcCentr.y() == 0)
 assert (not anArcCentr.isInitialized())
-anArcCentr.setValue(10.,10.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArcData.attribute("ArcStartPoint"))
+anArcCentr.setValue(10., 10.)
+anArcStartPoint = geomDataAPI_Point2D(
+    aSketchArc.attribute("ArcStartPoint"))
 assert (anArcStartPoint.x() == 0)
 assert (anArcStartPoint.y() == 0)
 assert (not anArcStartPoint.isInitialized())
 anArcStartPoint.setValue(0., 50.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArcData.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 assert (anArcEndPoint.x() == 0)
 assert (anArcEndPoint.y() == 0)
 assert (not anArcEndPoint.isInitialized())
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
 # check that values have been changed
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 assert (aSketchReflist.size() == 1)
 assert (len(aSketchReflist.list()) == 1)
 assert (anArcCentr.x() == 10.0)
@@ -81,15 +81,16 @@ assert (anArcStartPoint.x() == 0.0)
 assert (anArcStartPoint.y() == 50.0)
 assert (anArcEndPoint.x() == 50.0)
 assert (anArcEndPoint.y() == 0.0)
-#===============================================================================
+#=========================================================================
 # Edit the arc:
 # 1. Move whole arc
-# 2. Change the start point 
-#===============================================================================
+# 2. Change the start point
+#=========================================================================
 aSession.startOperation()
 deltaX, deltaY = 5., 10.
 anArcCentr.setValue(anArcCentr.x() + deltaX, anArcCentr.y() + deltaY)
-anArcStartPoint.setValue(anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY)
+anArcStartPoint.setValue(
+    anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY)
 anArcEndPoint.setValue(anArcEndPoint.x() + deltaX, anArcEndPoint.y() + deltaY)
 aSession.finishOperation()
 assert (anArcCentr.x() == 15)
@@ -111,32 +112,30 @@ assert (anArcStartPoint.y() == 60)
 assert (anArcEndPoint.x() != aPrevEndPointX)
 assert (anArcEndPoint.y() != aPrevEndPointY)
 #=========================================================================
-# Check results of the Arc 
+# Check results of the Arc
 #=========================================================================
 aResult = aSketchArc.firstResult()
 aResultConstruction = modelAPI_ResultConstruction(aResult)
 aShape = aResultConstruction.shape()
 assert (aShape is not None)
 assert (not aShape.isNull())
-#===============================================================================
+#=========================================================================
 # Create a circle
 # 1. Test SketchPlugin_Circle.h attributes
 # 2. ModelAPI_AttributeDouble attribute
-#===============================================================================
+#=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 # Arc is already added
 assert (aSketchReflist.size() == 1)
 assert (len(aSketchReflist.list()) == 1)
-aSketchCircle = aDocument.addFeature("SketchCircle")
+aSketchCircle = aSketchFeature.addFeature("SketchCircle")
 assert (aSketchCircle.getKind() == "SketchCircle")
-aSketchReflist.append(aSketchCircle)
-aSketchCircleData = aSketchCircle.data()
-anCircleCentr = geomDataAPI_Point2D(aSketchCircleData.attribute("CircleCenter"))
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
 assert (anCircleCentr.x() == 0)
 assert (anCircleCentr.y() == 0)
 assert (not anCircleCentr.isInitialized())
-aCircleRadius = aSketchCircleData.real("CircleRadius");
+aCircleRadius = aSketchCircle.real("CircleRadius")
 assert (type(aCircleRadius) == ModelAPI_AttributeDouble)
 # ModelAPI_AttributeDouble.type() is checked in ModelAPI_TestConstants
 assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.type())
@@ -147,11 +146,11 @@ assert (anCircleCentr.x() == -25)
 assert (anCircleCentr.y() == -25)
 assert (aCircleRadius.value() == 25)
 aSession.finishOperation()
-#===============================================================================
+#=========================================================================
 # Edit the Cricle
 # 1. Check that changing the centr of a circle does not affects radius
 # 2. and vise versa; also check that int is acceptable as well as a real
-#===============================================================================
+#=========================================================================
 aSession.startOperation()
 anCircleCentr.setValue(10, 60)
 aSession.finishOperation()
@@ -164,6 +163,6 @@ aSession.finishOperation()
 assert (anCircleCentr.x() == 10)
 assert (anCircleCentr.y() == 60)
 assert (aCircleRadius.value() == 20)
-#===============================================================================
+#=========================================================================
 # End of test
-#===============================================================================
+#=========================================================================
index dd90e27fd7df9ed05f8b921f913b93e5fb2b63da..df3f7cd64b6ab67a7ce2803a59d3c9409402f28a 100644 (file)
@@ -4,7 +4,7 @@
 from GeomDataAPI import *
 from ModelAPI import *
 
-__updated__ = "2014-07-24"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -12,32 +12,32 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
 assert (aSketchFeature.getKind() == "Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 # check that values have been changed
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 assert (origin.x() == 0)
 assert (origin.y() == 0)
 assert (origin.z() == 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 assert (dirx.x() == 1)
 assert (dirx.y() == 0)
 assert (dirx.z() == 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
 assert (diry.x() == 0)
 assert (diry.y() == 1)
 assert (diry.z() == 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 assert (norm.x() == 0)
 assert (norm.y() == 0)
 assert (norm.z() == 1)
@@ -45,15 +45,14 @@ assert (norm.z() == 1)
 # Creation of a point
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 assert (not aSketchReflist.isInitialized())
 assert(aSketchReflist.size() == 0)
 assert (len(aSketchReflist.list()) == 0)
-aSketchPoint = aDocument.addFeature("SketchPoint")
+# aSketchPoint = aDocument.addFeature("SketchPoint")
+aSketchPoint = aSketchFeature.addFeature("SketchPoint")
 assert (aSketchPoint.getKind() == "SketchPoint")
-aSketchReflist.append(aSketchPoint)
-aSketchPointData = aSketchPoint.data()
-coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
+coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordindates"))
 assert (coords.x() == 0)
 assert (coords.y() == 0)
 assert (not coords.isInitialized())
@@ -62,25 +61,23 @@ coords.setValue(10., 10.)
 assert (coords.isInitialized())
 aSession.finishOperation()
 # check that values have been changed
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 assert (aSketchReflist.size() == 1)
 assert (len(aSketchReflist.list()) == 1)
-aSketchPointData = aSketchPoint.data()
-coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
+coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordindates"))
 assert (coords.x() == 10.0)
 assert (coords.y() == 10.0)
-#===============================================================================
+#=========================================================================
 # Creation of a line
-#===============================================================================
+#=========================================================================
 aSession.startOperation()
-aSketchLine = aDocument.addFeature("SketchLine")
+# aSketchLine = aDocument.addFeature("SketchLine")
+aSketchLine = aSketchFeature.addFeature("SketchLine")
 assert (aSketchLine.getKind() == "SketchLine")
-aSketchReflist.append(aSketchLine)
 assert (aSketchReflist.size() == 2)
 assert (len(aSketchReflist.list()) == 2)
-aSketchLineData = aSketchLine.data()
-aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint= geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 assert (aLineStartPoint.x() == 0)
 assert (aLineStartPoint.y() == 0)
 assert (not aLineStartPoint.isInitialized())
@@ -94,17 +91,17 @@ assert (aLineStartPoint.isInitialized())
 assert (aLineEndPoint.isInitialized())
 aSession.finishOperation()
 # check that values have been changed
-aSketchLineData = aSketchLine.data()
-aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint= geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 assert (aLineStartPoint.x() == 50.0)
 assert (aLineStartPoint.y() == 50.0)
 assert (aLineEndPoint.x() == 60.0)
 assert (aLineEndPoint.y() == 60.0)
-#===============================================================================
+#=========================================================================
 # Check the results
-#===============================================================================
+#=========================================================================
 aResult = aSketchLine.firstResult()
+assert (aResult is not None)
 aResultConstruction = modelAPI_ResultConstruction(aResult)
 aShape = aResultConstruction.shape()
 assert (aShape is not None)
index 84bf0d7beaea67bbcafb0bb59a3ae0ea4f75740a..a9618988920f1a3df15eb3303d335e16bed1a827 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Session.h>
 
 #include <QAction>
 #include <QContextMenuEvent>