]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Jul 2014 13:16:09 +0000 (17:16 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Jul 2014 13:16:09 +0000 (17:16 +0400)
Conflicts:
src/ModuleBase/ModuleBase_Tools.cpp

12 files changed:
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i
src/ModuleBase/ModuleBase_Tools.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_OperationSketchBase.h
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 8c0471d9503f8b3f5cfee81a9c47754f2f151740..d3dd6f7ee16f288558d95a371f384d3100181d92 100644 (file)
@@ -14,13 +14,9 @@ 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>();
 }
 
@@ -39,4 +35,4 @@ FeaturePtr feature(ObjectPtr theObject)
   return aFeature;
 }
 
-}
\ No newline at end of file
+}
index 74debe86406ce079ae87c9cdceed536b294ae680..e3f4117e6175291803102a7d46faebbc41aef2bf 100644 (file)
@@ -344,7 +344,7 @@ void PartSet_Module::onCloseLocalContext()
   aDisplayer->closeLocalContexts();
 }
 
-void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
+void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
 {
 //  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
 //  if (isDisplay) {
@@ -442,8 +442,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
   // connect the operation
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
-    connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
-            this, SLOT(onFeatureConstructed(FeaturePtr, int)));
+    connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)),
+            this, SLOT(onFeatureConstructed(ObjectPtr, int)));
     connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)),
             this, SLOT(onLaunchOperation(std::string, ObjectPtr)));
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
index c32b3af077ecd2e5fbbabdcc27256bee8fcfce94..58e0995798c4a7cf5b4d5ab7a63542aade1da237 100644 (file)
@@ -134,8 +134,7 @@ public slots:
   /// SLOT, to visualize the feature in another local context mode
   /// \param theFeature the feature to be put in another local context mode
   /// \param theMode the mode appeared on the feature
-  void onFeatureConstructed(FeaturePtr theFeature,
-                            int theMode);
+  void onFeatureConstructed(ObjectPtr theFeature, int theMode);
 
   /// Slot which reacts to the point 2d set to the feature. Creates a constraint
   /// \param the feature
index 409adcd75adc9eeb40326fdd7874426b6173f241..3c74e6478c4b5e9129a5e459eb5875f2946492e1 100644 (file)
@@ -88,8 +88,15 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
     if(aHasShift && !theHighlighted.empty()) {
       QList<ObjectPtr> aSelected;
-      aSelected.push_back(feature());
-      aSelected.push_back(theHighlighted.front().object());
+      std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
+      for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
+        aSelected.append((*aIt).object());
+      /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
+        if (!aSelected.contains((*aIt).object()))
+          aSelected.append((*aIt).object());
+      }*/
+      //aSelected.push_back(feature());
+      //aSelected.push_back(theHighlighted.front().object());
       emit setSelection(aSelected);
     }
     else if (aFeature) {
index b08818ec7442a41cb8a9c8694fa42ea7ec1f230e..1768f0c94d82706699c8443b917d050919f0b793 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
 
 #include <ModelAPI_Events.h>
 
@@ -58,10 +59,9 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list<ModuleBase
     // deselected in the viewer by blockSelection signal in the startOperation method.
     bool isSelected = false;
     std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
-    // TODO
-    /*for (; anIt != aLast && !isSelected; anIt++) {
-      isSelected = (*anIt).feature() == feature();
-    }*/
+    for (; anIt != aLast && !isSelected; anIt++) {
+      isSelected = ModuleBase_Tools::feature((*anIt).object()) == feature();
+    }
     if (!isSelected)
       myFeatures = theHighlighted;
     else
@@ -110,14 +110,17 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle
     aSketchFeature->move(aDeltaX, aDeltaY);
 
     std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-    // TODO
-    /*for (; anIt != aLast; anIt++) {
-      FeaturePtr aFeature = (*anIt).feature();
-      if (!aFeature || aFeature == feature())
+    for (; anIt != aLast; anIt++) {
+      ObjectPtr aObject = (*anIt).object();
+      if (!aObject || aObject == feature())
         continue;
-      aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-      aSketchFeature->move(aDeltaX, aDeltaY);
-    }*/
+      FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+      if (aFeature) {
+        aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+        if (aSketchFeature)
+          aSketchFeature->move(aDeltaX, aDeltaY);
+      }
+    }
   }
   sendFeatures();
 
@@ -131,13 +134,12 @@ void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Han
   std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
   commit();
   std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
-  // TODO
-  /*for (; anIt != aLast; anIt++) {
-    FeaturePtr aFeature = (*anIt).feature();
+  for (; anIt != aLast; anIt++) {
+    ObjectPtr aFeature = (*anIt).object();
     if (aFeature) {
       emit featureConstructed(aFeature, FM_Deactivation);
-       }
-  }*/
+         }
+  }
 }
 
 void PartSet_OperationFeatureEditMulti::startOperation()
@@ -188,14 +190,13 @@ void PartSet_OperationFeatureEditMulti::sendFeatures()
 
   std::list<FeaturePtr > aFeatures;
   std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-  // TODO
-  /*for (; anIt != aLast; anIt++) {
-    FeaturePtr aFeature = (*anIt).feature();
+  for (; anIt != aLast; anIt++) {
+    ObjectPtr aFeature = (*anIt).object();
     if (!aFeature)
       continue;
 
     ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
-  }*/
+  }
   Events_Loop::loop()->flush(anEvent);
   flushUpdated();
 }
index 7916815d049e9b59a0af216966c41927103bc734..caae337a73894df0e2f689083d37450c390ce773 100644 (file)
@@ -123,14 +123,16 @@ signals:
   /// theName the operation name
   /// theFeature the operation argument
   void launchOperation(std::string theName, ObjectPtr theFeature);
+  
   /// Signal about the feature construing is finished
   /// \param theFeature the result feature
   /// \param theMode the mode of the feature modification
-  void featureConstructed(FeaturePtr theFeature,
-                          int theMode);
+  void featureConstructed(ObjectPtr theFeature, int theMode);
+
   /// Signal about the features should be selected
   /// \param theSelected the list of selected presentations
   void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
+  
   /// signal to enable/disable multi selection in the viewer
   /// \param theEnabled the boolean state
   void multiSelectionEnabled(bool theEnabled);
@@ -139,6 +141,7 @@ signals:
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
   void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
+  
   /// signal to set selection in the viewer
   /// \param theFeatures a list of features to be disabled
   void setSelection(const QList<ObjectPtr>& theFeatures);
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);