Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Thu, 24 Jul 2014 10:19:02 +0000 (14:19 +0400)
committersbh <sergey.belash@opencascade.com>
Thu, 24 Jul 2014 10:19:02 +0000 (14:19 +0400)
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i
src/ModuleBase/ModuleBase_Tools.cpp
src/SketchPlugin/Test/TestSketchBasics.py
src/XGUI/XGUI_Workshop.cpp

index e662ea2548c0c26cb72e81cd89b65684cb874a0c..ded2008375e370727b818657712fae59ee2c7634 100644 (file)
@@ -9,5 +9,10 @@
 #define MY_PNT static_cast<gp_Pnt*>(myImpl)
 
 GeomAPI_Shape::GeomAPI_Shape()
-  : GeomAPI_Interface(new TopoDS_Shape())
-{}
+    : GeomAPI_Interface(new TopoDS_Shape()) {
+}
+
+bool GeomAPI_Shape::isNull()
+{
+  return MY_SHAPE->IsNull();
+}
index 8a9d3b26c9a1b81076ec086b292bb0f328ec0318..514287a03a22a08f89a1a7467b30c6fb4247c4e9 100644 (file)
  * \ingroup DataModel
  * \brief Interface to the topological shape object
  */
+class TopoDS_Shape;
+
+#define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
 
 class GEOMAPI_EXPORT GeomAPI_Shape: public GeomAPI_Interface
 {
 public:
   /// Creation of empty (null) shape
   GeomAPI_Shape();
+
+  bool isNull();
+
 };
 
 #endif
index 8f02b77ab8e0f4e92e4b241e6adc9abed25153ca..731a449c7c72998a5c9ec4c1d502a9b6f075fa0f 100644 (file)
@@ -43,7 +43,9 @@ SET_TARGET_PROPERTIES(ModelAPI PROPERTIES LINKER_LANGUAGE CXX)
 TARGET_LINK_LIBRARIES(ModelAPI ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
-  ../Config ../Events
+  ../Config 
+  ../Events
+  ../GeomAPI
 )
 
 SET(CMAKE_SWIG_FLAGS "")
index b6a337d3e38ba0d3b448b52e2463649b3d88333f..456a52775ebc92d6ef9d4c83149264716d959351 100644 (file)
   #include "ModelAPI_Validator.h"
   #include "ModelAPI_AttributeRefList.h"
   #include "ModelAPI_Result.h"
+  #include "ModelAPI_ResultConstruction.h"
+  
+  template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject) 
+  { 
+    return boost::dynamic_pointer_cast<T>(theObject); 
+  }
+  
+   
 %}
 
 // to avoid error on this
 #define MODELAPI_EXPORT
+#define GEOMAPI_EXPORT
 
 // standard definitions
 %include "typemaps.i"
@@ -39,6 +48,7 @@
 %shared_ptr(ModelAPI_AttributeRefAttr)
 %shared_ptr(ModelAPI_AttributeRefList)
 %shared_ptr(ModelAPI_Result)
+%shared_ptr(ModelAPI_ResultConstruction)
 
 // all supported interfaces
 %include "ModelAPI_Document.h"
 %include "ModelAPI_Validator.h"
 %include "ModelAPI_AttributeRefList.h"
 %include "ModelAPI_Result.h"
+%include "ModelAPI_ResultConstruction.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>;
index 3f0069eca9640597f7c35a9033f82e48a6bc7d1d..dfd282ea34fe5e90343f49154cf837cc6ca40f16 100644 (file)
@@ -13,14 +13,10 @@ namespace ModuleBase_Tools
 boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
 {
   ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
-  if (aBody)
-    return aBody->shape();
-
+  if (aBody) return aBody->shape();
   ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
-  if (aConstruct)
-    return aConstruct->shape();
-
+  if (aConstruct) return aConstruct->shape();
   return boost::shared_ptr<GeomAPI_Shape>();
 }
 
-}
\ No newline at end of file
+}
index 2d68e89218ebae4d9ac987d5fbbb3921c6379e6a..22df6ce62f7ae48ce41b387e97ca586422353a4b 100644 (file)
@@ -4,11 +4,10 @@
 from GeomDataAPI import *
 from ModelAPI import *
 
-__updated__ = "2014-07-23"
+__updated__ = "2014-07-24"
 
 aPluginManager = ModelAPI_PluginManager.get()
 aDocument = aPluginManager.rootDocument()
-aDocument.startOperation()
 #===============================================================================
 # Test ModelAPI static methods
 # TODO: Move this test in the ModelAPI progect 
@@ -29,6 +28,7 @@ assert (GeomDataAPI_Point2D.type() == "Point2D")
 #=========================================================================
 # Creation of a sketch
 #=========================================================================
+aDocument.startOperation()
 aSketchFeature = aDocument.addFeature("Sketch")
 assert (aSketchFeature.getKind() == "Sketch")
 aSketchFeatureData = aSketchFeature.data()
@@ -57,9 +57,11 @@ norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
 assert (norm.x() == 0)
 assert (norm.y() == 0)
 assert (norm.z() == 1)
+aDocument.finishOperation()
 #=========================================================================
 # Creation of a point
 #=========================================================================
+aDocument.startOperation()
 aSketchReflist = aSketchFeatureData.reflist("Features")
 assert (not aSketchReflist.isInitialized())
 assert(aSketchReflist.size() == 0)
@@ -83,9 +85,11 @@ aSketchPointData = aSketchPoint.data()
 coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
 assert (coords.x() == 10.0)
 assert (coords.y() == 10.0)
+aDocument.finishOperation()
 #===============================================================================
 # Creation of a line
 #===============================================================================
+aDocument.startOperation()
 aSketchLine = aDocument.addFeature("SketchLine")
 aSketchReflist.append(aSketchLine)
 assert (aSketchReflist.size() == 2)
@@ -112,9 +116,16 @@ assert (aLineStartPoint.x() == 50.0)
 assert (aLineStartPoint.y() == 50.0)
 assert (aLineEndPoint.x() == 60.0)
 assert (aLineEndPoint.y() == 60.0)
-aSketchLine.firstResult()
+aDocument.finishOperation()
+#===============================================================================
+# Check results
+#===============================================================================
+aResult = aSketchLine.firstResult()
+assert (aResult is not None)
+aResultConstruction = modelAPI_ResultConstruction(aResult)
+aShape = aResult.shape()
+assert (aShape is not None)
+assert (not aShape.isNull())
  #==============================================================================
  # Finish the test
  #==============================================================================
-aDocument.finishOperation()
-
index 03a3bae5e5fc833d343a6b181665f4d7ed1c8c4a..27eee74701d21f716bc7f1b6a43ba4059287590f 100644 (file)
@@ -331,7 +331,9 @@ void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* the
     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
     if (aPart) {
       aHasPart = true;
-    } else {
+    // If a feature is created from the aplication's python console  
+    // it doesn't stored in the operation mgr and doesn't displayed
+    } else if(myOperationMgr->hasOperation()) {
       ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
       if (aOperation->hasObject(*aIt)) { // Display only current operation results
         myDisplayer->display(*aIt, false);