]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Tue, 28 Oct 2014 08:26:22 +0000 (11:26 +0300)
committersbh <sergey.belash@opencascade.com>
Tue, 28 Oct 2014 08:26:22 +0000 (11:26 +0300)
28 files changed:
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/boolean_widget.xml
src/FeaturesPlugin/extrusion_widget.xml
src/GeomAPI/GeomAPI_Shape.h
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h [new file with mode: 0644]
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_Validator.h
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_SalomeConnector.h
src/XGUI/XGUI_Workshop.cpp

index 4d2b643d5eb0b0d7d868ff360f99dc3adec4e58c..a0886cbb16364a482cb4e6d544dab887deaa9362 100644 (file)
@@ -26,14 +26,14 @@ INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
+  ../Events
 )
 
 SET(PROJECT_LIBRARIES
+    Events
     ModelAPI 
     GeomAPI 
     GeomAlgoAPI
-    ${CAS_KERNEL}
-    ${CAS_SHAPE}
 )
 
 ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
index 0e997edafe6fe27d0eda36920a0cdb026c80a0e9..b32f2e97a5e09841d36fb2602636c248b78121f4 100644 (file)
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeBoolean.h>
-
+#include <Events_Error.h>
 #include <GeomAlgoAPI_Extrusion.h>
 
 using namespace std;
+#define _LATERAL_TAG 1
+#define _FIRST_TAG 2
+#define _LAST_TAG 3
+#ifdef _DEBUG
+#include <iostream>
+#include <ostream>
+#endif
 
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
 {
@@ -30,19 +37,126 @@ void FeaturesPlugin_Extrusion::initAttributes()
 void FeaturesPlugin_Extrusion::execute()
 {
   boost::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = boost::dynamic_pointer_cast<
-      ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
+    ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
   if (!aFaceRef)
     return;
+
   boost::shared_ptr<GeomAPI_Shape> aFace = 
     boost::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->value());
   if (!aFace)
     return;
 
+  boost::shared_ptr<GeomAPI_Shape> aContext;
+  ResultPtr aContextRes = aFaceRef->context();
+  if (aContextRes) {
+    if (aContextRes->groupName() == ModelAPI_ResultBody::group())
+      aContext = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
+    else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group())
+      aContext = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
+  }
+  if (!aContext) {
+    std::string aContextError = "The selection context is bad";
+    Events_Error::send(aContextError, this);
+    return;
+  }
+
   double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
   if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
     aSize = -aSize;
 
-  boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
-  aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
-  setResult(aResult);
+  boost::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
+  //TCollection_AsciiString anError;
+  GeomAlgoAPI_Extrusion aFeature(aFace, aSize);
+  if(!aFeature.isDone()) {
+    std::string aFeatureError = "Extrusion algorithm failed";  
+    Events_Error::send(aFeatureError, this);
+    return;
+  }
+
+  // Check if shape is valid
+  if (aFeature.shape()->isNull()) {
+    std::string aShapeError = "Resulting shape is Null";     
+    Events_Error::send(aShapeError, this);
+#ifdef _DEBUG
+    std::cerr << aShapeError << std::endl;
+#endif
+    return;
+  }
+  if(!aFeature.isValid()) {
+    std::string aFeatureError = "Warning: resulting shape is not valid";  
+    Events_Error::send(aFeatureError, this);
+    return;
+  }  
+  //LoadNamingDS
+  LoadNamingDS(aFeature, aResultBody, aFace, aContext);
+
+  setResult(aResultBody);
+}
+
+//============================================================================
+void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature, 
+  boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
+  boost::shared_ptr<GeomAPI_Shape> theBasis,
+  boost::shared_ptr<GeomAPI_Shape> theContext)
+{  
+
+
+  //load result
+  if(theBasis->isEqual(theContext))
+    theResultBody->store(theFeature.shape());
+  else
+    theResultBody->storeGenerated(theContext, theFeature.shape());
+  /*
+  TopTools_DataMapOfShapeShape aSubShapes;
+  for (TopExp_Explorer Exp(theFeature.shape()->impl<TopoDS_Shape>(),TopAbs_FACE); Exp.More(); Exp.Next()) {
+    aSubShapes.Bind(Exp.Current(),Exp.Current());
+  }
+
+  //Insert lateral face : Face from Edge
+  //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
+
+
+  TopTools_MapOfShape aView;
+  TopExp_Explorer aShapeExplorer (theFeature.shape()->impl<TopoDS_Shape>(), TopAbs_EDGE);
+  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
+    if (!aView.Add(aRoot)) continue;
+    boost::shared_ptr<GeomAPI_Shape> aRootG(new GeomAPI_Shape());
+    aRootG->setImpl((void *)&aRoot);
+    const ListOfShape& aShapes = theFeature.generated(aRootG);
+    std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();          
+    for (; anIt != aLast; anIt++) {
+      TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>(); 
+      if (aSubShapes.IsBound(aNewShape)) {
+        aNewShape.Orientation((aSubShapes(aNewShape)).Orientation());
+      }
+
+      if (!aRoot.IsSame (aNewShape)) {
+        boost::shared_ptr<GeomAPI_Shape> aNew(new GeomAPI_Shape());
+        aNew->setImpl((void *)&aNewShape);
+        theResultBody->generated(aRootG, aNew,_LATERAL_TAG); 
+      }
+    }
+  }
+  //Insert bottom face
+  const boost::shared_ptr<GeomAPI_Shape>& aBottomFace = theFeature.firstShape();
+  if (!aBottomFace->isNull()) {
+    if (aSubShapes.IsBound(aBottomFace->impl<TopoDS_Shape>())) {
+      aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl<TopoDS_Shape>()));
+    }    
+    theResultBody->generated(aBottomFace, _FIRST_TAG);
+  }
+
+
+
+  //Insert top face
+  boost::shared_ptr<GeomAPI_Shape> aTopFace = theFeature.lastShape();
+  if (!aTopFace->isNull()) {
+    if (aSubShapes.IsBound(aTopFace->impl<TopoDS_Shape>())) {
+      aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl<TopoDS_Shape>()));
+    }
+    theResultBody->generated(aTopFace, _FIRST_TAG);
+  }
+  */
+
 }
index 13a8c226e9ea2bc48ae7d6d936b6290fe656218e..d136c84915156754b490365fc715d73ad09d2d91 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "FeaturesPlugin.h"
 #include <ModelAPI_Feature.h>
-
+#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_Extrusion.h>
 class FeaturesPlugin_Extrusion : public ModelAPI_Feature
 {
  public:
@@ -51,6 +52,11 @@ class FeaturesPlugin_Extrusion : public ModelAPI_Feature
 
   /// Use plugin manager for features creation
   FeaturesPlugin_Extrusion();
+
+  /// Load Naming data structure of the feature to the document
+  void LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature, boost::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                       boost::shared_ptr<GeomAPI_Shape> theBasis,
+                       boost::shared_ptr<GeomAPI_Shape> theContext);
 };
 
 #endif
index cdf8e195ef0b7b990725039730beec66023b5361..af4822c2c848784f950bbf54d3726034ccd4ccda 100644 (file)
@@ -4,12 +4,14 @@
     icon=":icons/cut_shape.png" 
     tooltip="Select an object to cut"
     shape_types="solid shell"
+    concealment="true"
   />
   <shape_selector id="tool_object" 
     label="Tool object" 
     icon=":icons/cut_tool.png" 
     tooltip="Select a tool"
     shape_types="solid"
+    concealment="true"
   />
   <choice id="bool_type" 
     label="Type" 
index 4158caaa9ccfa9530086a189f0835978c6b94cfd..c7c5f4bdd90bebae461edbd3873fae7ace5471a5 100644 (file)
@@ -6,7 +6,6 @@
     activate="true"
     shape_types="face"
     use_subshapes="true"
-    concealment="true"
   />
   <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="1" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
     <validator id="GeomValidators_Positive"/>
index 96db714562f42983e3730546629d62bb049c306e..03f75d7453da0e4c85e475bb7e1595a2f6d44b0e 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <GeomAPI_Interface.h>
 #include <boost/shared_ptr.hpp>
+#include <list>
 
 /**\class GeomAPI_Shape
  * \ingroup DataModel
@@ -31,6 +32,9 @@ class GEOMAPI_EXPORT GeomAPI_Shape : public GeomAPI_Interface
 
 };
 
+//! Pointer on list of shapes
+typedef std::list<boost::shared_ptr<GeomAPI_Shape> > ListOfShape;
+
 //! Pointer on attribute object
 typedef boost::shared_ptr<GeomAPI_Shape> GeomShapePtr;
 
index 05e91eb61f219862c278b69f91a60c1779763eb9..5656a0ad8a5e0227eaa10d12050708099e3a7f12 100644 (file)
@@ -12,6 +12,8 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_SketchBuilder.h
     GeomAlgoAPI_Extrusion.h
     GeomAlgoAPI_Boolean.h
+    GeomAlgoAPI_MakeShape.h
+    GeomAlgoAPI_DFLoader.h
 )
 
 SET(PROJECT_SOURCES
@@ -22,14 +24,18 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_SketchBuilder.cpp
     GeomAlgoAPI_Extrusion.cpp
     GeomAlgoAPI_Boolean.cpp
+    GeomAlgoAPI_MakeShape.cpp
+    GeomAlgoAPI_DFLoader.cpp
 )
 
 SET(PROJECT_LIBRARIES
-    GeomAPI 
+    GeomAPI
+    ModelAPI 
     ${CAS_TKBool} 
     ${CAS_TKBO} 
     ${CAS_TKPrim}
     ${CAS_SHAPE}
+    ${CAS_TKTopAlgo}
 )
 
 ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS})
@@ -42,6 +48,7 @@ SET_SOURCE_FILES_PROPERTIES(GeomAlgoAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
 
 INCLUDE_DIRECTORIES(
   ../GeomAPI
+  ../ModelAPI
   ${CAS_INCLUDE_DIRS}
 )
 
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp
new file mode 100644 (file)
index 0000000..d309de4
--- /dev/null
@@ -0,0 +1,103 @@
+// File:        GeomAlgoAPI_DFLoader.cpp
+// Created:     23 October 2014
+// Author:      Sergey Zaritchny
+
+#include <GeomAlgoAPI_DFLoader.h>
+#include <TopoDS_Iterator.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+//=======================================================================
+//function : refineResult
+//purpose  :
+//=======================================================================
+const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const  TopoDS_Shape& theResult)
+{
+  TopoDS_Shape aResult;
+  if (theResult.ShapeType() == TopAbs_COMPOUND) {
+    Standard_Integer nbSubResults = 0;
+    TopoDS_Iterator itr(theResult);
+    for (; itr.More(); itr.Next()) nbSubResults++;
+    if (nbSubResults == 1) {
+      itr.Initialize(theResult);
+      if (itr.More()) aResult = itr.Value();
+    }
+  }
+  return aResult;
+}
+/*
+//=======================================================================
+//function : loadDeletedShapes
+//purpose  : load deleted shapes in DF
+//=======================================================================
+void GeomAlgoAPI_DFLoader::loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS,
+                                       const TopoDS_Shape&     theShapeIn,
+                                       const TopAbs_ShapeEnum  theKindOfShape,
+                                       TNaming_Builder&        theBuilder)
+{
+  TopTools_MapOfShape aView;
+  TopExp_Explorer ShapeExplorer (theShapeIn, theKindOfShape);
+  for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
+    const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
+    if (!aView.Add(aRoot)) continue;
+    if (theMS.IsDeleted (aRoot)) {
+      theBuilder.Delete (aRoot);
+    }
+  }
+}
+
+//=======================================================================
+//function : loadAndOrientModifiedShapes
+//purpose  : load modified shapes in DF with preliminary orientation adjustment
+//=======================================================================
+void GeomAlgoAPI_DFLoader::loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape&    theMS,
+                                           const TopoDS_Shape&        theShapeIn,
+                                           const TopAbs_ShapeEnum     theKindOfShape,
+                                           TNaming_Builder&           theBuilder,
+                                           const TopTools_DataMapOfShapeShape& theSubShapes)
+{
+  TopTools_MapOfShape aView;
+  TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape);
+  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
+    if (!aView.Add(aRoot)) continue;
+    const TopTools_ListOfShape& aShapes = theMS.Modified (aRoot);
+    TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes);
+    for (;aShapesIterator.More (); aShapesIterator.Next ()) {
+      TopoDS_Shape aNewShape = aShapesIterator.Value ();
+      if (theSubShapes.IsBound(aNewShape)) {
+        aNewShape.Orientation((theSubShapes(aNewShape)).Orientation());
+      }
+      if (!aRoot.IsSame (aNewShape)) theBuilder.Modify (aRoot, aNewShape );
+    }
+  }
+}
+
+//=======================================================================
+//function : loadAndOrientGeneratedShapes
+//purpose  : load generated shapes in DF with preliminary orientation adjustment
+//=======================================================================
+
+void GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape&     theMS,
+                                                const TopoDS_Shape&           theShapeIn,
+                                                const TopAbs_ShapeEnum        theKindOfShape,
+                                                TNaming_Builder&              theBuilder,
+                                                const TopTools_DataMapOfShapeShape&    theSubShapes)
+{
+  TopTools_MapOfShape aView;
+  TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape);
+  for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+    const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
+    if (!aView.Add(aRoot)) continue;
+    const TopTools_ListOfShape& aShapes = theMS.Generated (aRoot);
+    TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes);
+    for (;aShapesIterator.More (); aShapesIterator.Next ()) {
+      TopoDS_Shape aNewShape = aShapesIterator.Value ();
+      if (theSubShapes.IsBound(aNewShape)) {
+        aNewShape.Orientation((theSubShapes(aNewShape)).Orientation());
+      }
+      if (!aRoot.IsSame (aNewShape)) theBuilder.Generated (aRoot,aNewShape );
+    }
+  }
+}
+*/
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h b/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h
new file mode 100644 (file)
index 0000000..815b8cb
--- /dev/null
@@ -0,0 +1,44 @@
+// File:        GeomAlgoAPI_DFLoader.h
+// Created:     23 October 2014
+// Author:      Sergey Zaritchny
+
+#ifndef GeomAlgoAPI_DFLoader_H_
+#define GeomAlgoAPI_DFLoader_H_
+#include <GeomAlgoAPI.h>
+//#include <boost/shared_ptr.hpp>
+#include <BRepBuilderAPI_MakeShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TNaming_Builder.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+
+/**\class GeomAlgoAPI_DFLoader
+ * \ingroup DataAlgo
+ * \brief Defines several static methods useful for Data Framework filling
+ */
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_DFLoader 
+{
+ public:
+        /*
+  /// Loads to DF deleted shapes
+  static void loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS, const TopoDS_Shape& theShapeIn,
+                                 const TopAbs_ShapeEnum  KindOfShape, TNaming_Builder&  theBuilder);
+
+  /// Loads to DF generated shapes
+  static void loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape&                  theMS,
+                                            const TopoDS_Shape&                 theShapeIn,
+                                            const TopAbs_ShapeEnum              theKindOfShape,
+                                            TNaming_Builder&                    theBuilder,
+                                            const TopTools_DataMapOfShapeShape& theSubShapes);
+  /// Loads to DF modified shapes 
+  static void loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape&                   theMS,
+                                           const TopoDS_Shape&                  theShapeIn,
+                                           const TopAbs_ShapeEnum               theKindOfShape,
+                                           TNaming_Builder&                     theBuilder,
+                                           const TopTools_DataMapOfShapeShape&  theSubShapes);
+  */
+  /// Refine result
+  static const TopoDS_Shape refineResult(const TopoDS_Shape& theShape);
+};
+
+#endif
\ No newline at end of file
index a236fc8bb00135cd62e014ec1236d88b2e83b9c2..b81b0f5fe2b1fa09b9a9150b70ac6ba4dac3f7d7 100644 (file)
 // Author:      Artem ZHIDKOV
 
 #include <GeomAlgoAPI_Extrusion.h>
-
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_DFLoader.h>
 #include <gp_Pln.hxx>
-
 #include <BRepPrimAPI_MakePrism.hxx>
+#include <BRepBuilderAPI_MakeShape.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_Surface.hxx>
 #include <TopExp_Explorer.hxx>
-#include <BRep_Builder.hxx>
-
+#include <BRepCheck_Analyzer.hxx>
+#include <GProp_GProps.hxx>
+#include <BRepGProp.hxx>
+#include <TopoDS.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <Precision.hxx>
+#include <TDF_TagSource.hxx>
+#include <boost/shared_ptr.hpp>
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <TopoDS_Shape.hxx>
+
 const double tolerance = Precision::Angular();
+// Constructor
+GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion(
+  boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize)
+: mySize(theSize), myDone(false),
+  myShape(new GeomAPI_Shape()), myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape())
+{
+  build(theBasis);
+}
 
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
-    boost::shared_ptr<GeomAPI_Shape> theShape, boost::shared_ptr<GeomAPI_Dir> theDir,
-    double theSize)
+//============================================================================
+void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr<GeomAPI_Shape>& theBasis)
 {
-  const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
-  gp_Vec aDir(theDir->impl<gp_Dir>().XYZ() * theSize);
+  bool isFirstNorm = true;
+  gp_Dir aShapeNormal;
 
-  TopoDS_Shape aPrism = BRepPrimAPI_MakePrism(aShape, aDir);
-  if (aPrism.IsNull())
-    return boost::shared_ptr<GeomAPI_Shape>();
+  //const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>(); 
+  TopoDS_Face aBasis = TopoDS::Face(theBasis->impl<TopoDS_Shape>());
+  Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(
+    BRep_Tool::Surface(aBasis));
+  if (aPlane.IsNull())  // non-planar shapes is not supported for extrusion yet
+    return;
 
-  boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
-  aResult->setImpl(new TopoDS_Shape(aPrism));
-  return aResult;
+  const gp_Dir& aNormal = aPlane->Pln().Axis().Direction();  
+  gp_Vec aVec(aNormal);
+  aVec = aVec * mySize;
+
+  BRepPrimAPI_MakePrism* aBuilder = new BRepPrimAPI_MakePrism(aBasis, aVec);
+  if(aBuilder) {
+    setImpl(aBuilder);
+    myDone = aBuilder->IsDone() == Standard_True;
+    if (myDone) {
+      BRepCheck_Analyzer aChecker(aBuilder->Shape());
+      myDone = aChecker.IsValid() == Standard_True;
+    }
+    if(myDone) {
+      TopoDS_Shape aResult;
+      if(aBuilder->Shape().ShapeType() == TopAbs_COMPOUND) 
+        aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape());
+      else
+        aResult = aBuilder->Shape();
+      myShape->setImpl(new TopoDS_Shape(aResult));
+      myFirst->setImpl(new TopoDS_Shape(aBuilder->FirstShape()));
+      myLast->setImpl(new TopoDS_Shape(aBuilder-> LastShape()));
+    }
+  }    
 }
 
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
-    boost::shared_ptr<GeomAPI_Shape> theShape, double theSize)
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::isDone() const
+{return myDone;}
+
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::isValid() const
 {
-  bool isFirstNorm = true;
-  gp_Dir aShapeNormal;
+  return myDone;
+}
 
-  const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
-  TopExp_Explorer aFaceExp(aShape, TopAbs_FACE);
-  TopoDS_Compound aFaces; // use only faces from the shape: make compound for this
-  BRep_Builder aBuilder;
-  aBuilder.MakeCompound(aFaces);
-  for (; aFaceExp.More(); aFaceExp.Next()) {
-    const TopoDS_Face& aFace = (const TopoDS_Face&) aFaceExp.Current();
-    Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace));
-    if (aPlane.IsNull())  // non-planar shapes is not supported for extrusion yet
-      continue;
-
-    const gp_Dir& aNormal = aPlane->Pln().Axis().Direction();
-    if (isFirstNorm) {
-      aShapeNormal = aNormal;
-      isFirstNorm = false;
-    } else if (!aShapeNormal.IsEqual(aNormal, tolerance))  // non-planar shapes is not supported for extrusion yet
-      return boost::shared_ptr<GeomAPI_Shape>();
-    aBuilder.Add(aFaces, aFace);
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::hasVolume() const
+{
+  bool hasVolume(false);
+  if(isValid()) {
+    const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
+    GProp_GProps aGProp;
+    BRepGProp::VolumeProperties(aRShape, aGProp);
+    if(aGProp.Mass() > Precision::Confusion()) 
+      hasVolume = true;        
   }
-  if (aFaces.IsNull())
-    return boost::shared_ptr<GeomAPI_Shape>();
+  return hasVolume;
+}
 
-  boost::shared_ptr<GeomAPI_Dir> aDir(
-      new GeomAPI_Dir(aShapeNormal.X(), aShapeNormal.Y(), aShapeNormal.Z()));
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::shape () const 
+{return myShape;}
 
-  boost::shared_ptr<GeomAPI_Shape> aFacesShape(new (GeomAPI_Shape));
-  aFacesShape->setImpl(new TopoDS_Shape(aFaces));
-  return GeomAlgoAPI_Extrusion::makeExtrusion(aFacesShape, aDir, theSize);
+//============================================================================
+void GeomAlgoAPI_Extrusion::generated(
+  const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+  theHistory.clear();
+  if(myDone) {
+    const TopTools_ListOfShape& aList = implPtr<BRepPrimAPI_MakePrism>()
+      ->Generated(theShape->impl<TopoDS_Shape>());
+    TopTools_ListIteratorOfListOfShape it(aList);
+    for(;it.More();it.Next()) {
+      boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      aShape->setImpl(&(it.Value()));
+      theHistory.push_back(aShape);
+    }
+  }
+}
+
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::firstShape()
+{
+  return myFirst;
+}
+
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::lastShape()
+{
+  return myLast;
+}
+
+//============================================================================
+/*
+void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
+boost::shared_ptr<GeomAPI_Shape> theContext)
+{
+if(isValid()) {
+const TopoDS_Shape& aShape = myBuilder->Shape();
+TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aShape);
+boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResultBody->data());
+if (aData) {
+const TDF_Label& aShapeLab = aData->shapeLab();
+const Handle(TDF_TagSource)& Tagger = TDF_TagSource::Set(aShapeLab);
+if (Tagger.IsNull()) return;
+Tagger->Set(0);
+
+TNaming_Builder aBuilder (aShapeLab);
+if(myBasis.IsEqual(theContext->impl<TopoDS_Shape>()))
+aBuilder.Generated(aResult);
+else
+aBuilder.Generated(theContext->impl<TopoDS_Shape>(), aResult);
+
+TopTools_DataMapOfShapeShape aSubShapes;
+for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
+aSubShapes.Bind(Exp.Current(),Exp.Current());
+}
+
+//Insert lateral face : Face from Edge
+TNaming_Builder  aLateralFaceBuilder(aShapeLab.NewChild());
+GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
+
+//Insert bottom face
+TopoDS_Shape aBottomFace = myBuilder->FirstShape();
+if (!aBottomFace.IsNull()) {
+if (aBottomFace.ShapeType() != TopAbs_COMPOUND) {
+TNaming_Builder aBottomBuilder(aShapeLab.NewChild());  //2
+if (aSubShapes.IsBound(aBottomFace)) {
+aBottomFace = aSubShapes(aBottomFace);
+}
+aBottomBuilder.Generated(aBottomFace);
+} else {
+TopoDS_Iterator itr(aBottomFace);
+for (; itr.More(); itr.Next()) {
+TNaming_Builder aBottomBuilder(aShapeLab.NewChild());
+aBottomBuilder.Generated(itr.Value());
+}
+}
+
+}
+
+//Insert top face
+TopoDS_Shape aTopFace = myBuilder->LastShape();
+if (!aTopFace.IsNull()) {
+if (aTopFace.ShapeType() != TopAbs_COMPOUND) {
+TNaming_Builder aTopBuilder(aShapeLab.NewChild()); //3
+if (aSubShapes.IsBound(aTopFace)) {
+aTopFace = aSubShapes(aTopFace);
+}
+aTopBuilder.Generated(aTopFace);
+} else {
+TopoDS_Iterator itr(aTopFace);
+for (; itr.More(); itr.Next()) {
+TNaming_Builder aTopBuilder(aShapeLab.NewChild());
+aTopBuilder.Generated(itr.Value());
+}
+}
+}
+}
 }
+*/
\ No newline at end of file
index 31b3d4406378d519d1f7b78d4c79c3c83c3c66d9..bebeb35f5cdbb70df4b18946f26dcbfb6ae1137a 100644 (file)
@@ -1,6 +1,6 @@
 // File:        GeomAlgoAPI_Extrusion.h
-// Created:     06 Jun 2014
-// Author:      Artem ZHIDKOV
+// Created:     22 October 2014
+// Author:      Sergey Zaritchny
 
 #ifndef GeomAlgoAPI_Extrusion_H_
 #define GeomAlgoAPI_Extrusion_H_
@@ -8,33 +8,60 @@
 #include <GeomAlgoAPI.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_Dir.h>
+#include <ModelAPI_ResultBody.h>
 #include <boost/shared_ptr.hpp>
-
 /**\class GeomAlgoAPI_Extrusion
  * \ingroup DataAlgo
  * \brief Allows to create the prism based on a given face and a direction
  */
 
-class GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion
+class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
 {
  public:
-  /* \brief Creates extrusion for the given shape
-   * \param[in] theShape face or wire to be extruded
-   * \param[in] theDir   direction of extrusion
-   * \param[in] theSize  the length of extrusion (if the value is less than 0, the extrusion in opposite direction)
-   * \return a solid or a face which is obtained from specified one
-   */
-  static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<GeomAPI_Shape> theShape,
-                                                        boost::shared_ptr<GeomAPI_Dir> theDir,
-                                                        double theSize);
 
   /* \brief Creates extrusion for the given shape along the normal for this shape
    * \param[in] theShape face or wire to be extruded
    * \param[in] theSize  the length of extrusion (if the value is less than 0, the extrusion in opposite normal)
    * \return a solid or a face which is obtained from specified one
-   */
-  static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<GeomAPI_Shape> theShape,
-                                                        double theSize);
+  
+  static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<ModelAPI_ResultBody> theResult,
+                                                                                                               boost::shared_ptr<GeomAPI_Shape> theBasis,
+                                                                                                               boost::shared_ptr<GeomAPI_Shape> theContext,
+                                                        double theSize); */
+  /// Constructor
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize);
+
+  /// Returns True if algorithm succeed
+  GEOMALGOAPI_EXPORT const bool isDone() const;
+
+  ///  Returns True if resulting shape is valid
+  GEOMALGOAPI_EXPORT const bool isValid() const;
+
+  /// Returns True if resulting shape has volume
+  GEOMALGOAPI_EXPORT const bool hasVolume() const;
+
+  /// Returns result of the Extrusion algorithm which may be a Solid or a Face
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& shape () const;
+
+  /// Returns list of shapes generated from theShape
+  GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
+                                    ListOfShape& theHistory);
+
+  /// Returns the first shape 
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& firstShape();
+
+  /// returns last shape
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();       
+
+private:
+  /// builds resulting shape
+  void build(const boost::shared_ptr<GeomAPI_Shape>& theBasis);
+
+  double mySize;
+  bool myDone;
+  boost::shared_ptr<GeomAPI_Shape> myShape;
+  boost::shared_ptr<GeomAPI_Shape> myFirst;
+  boost::shared_ptr<GeomAPI_Shape> myLast;
 };
 
 #endif
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
new file mode 100644 (file)
index 0000000..679526b
--- /dev/null
@@ -0,0 +1,58 @@
+// File:        GeomAlgoAPI_MakeShape.cpp
+// Created:     20 Oct 2014
+// Author:      Sergey ZARITCHNY
+
+#include <GeomAlgoAPI_MakeShape.h>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
+  : GeomAPI_Interface(theMkShape)
+{}
+
+const boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
+{
+  return myShape;
+}
+
+/// Returns the  list   of shapes generated   from the shape <theShape>
+void GeomAlgoAPI_MakeShape::generated(
+  const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+  BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+  if(aBuilder) {
+    const TopTools_ListOfShape& aList =  aBuilder->Generated(theShape->impl<TopoDS_Shape>());
+    TopTools_ListIteratorOfListOfShape it(aList);
+    for(;it.More();it.Next()) {
+      boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      aShape->setImpl(&(it.Value()));
+      theHistory.push_back(aShape);
+    }
+  }
+}
+
+/// Returns the  list   of shapes modified   from the shape <theShape>
+void GeomAlgoAPI_MakeShape::modified(
+  const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+  BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+  if(aBuilder) {
+    const TopTools_ListOfShape& aList =  aBuilder->Modified(theShape->impl<TopoDS_Shape>());
+    TopTools_ListIteratorOfListOfShape it(aList);
+    for(;it.More();it.Next()) {
+      boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      aShape->setImpl(&(it.Value()));
+      theHistory.push_back(aShape);
+    }
+  }
+}
+
+/// Returns whether the shape is an edge
+bool GeomAlgoAPI_MakeShape::isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+  bool isDeleted(false);
+  BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+  if(aBuilder) {
+    isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+  }
+  return isDeleted;
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
new file mode 100644 (file)
index 0000000..89dae08
--- /dev/null
@@ -0,0 +1,38 @@
+// File:        GeomAlgoAPI_MakeShape.h
+// Created:     17 Oct 2014
+// Author:      Sergey ZARITCHNY
+#ifndef GeomAlgoAPI_MakeShape_H_
+#define GeomAlgoAPI_MakeShape_H_
+
+#include <GeomAPI_Shape.h>
+#include <boost/shared_ptr.hpp>
+#include <GeomAlgoAPI.h>
+#include <BRepBuilderAPI_MakeShape.hxx>
+/**\class GeomAlgoAPI_MakeShape
+ * \ingroup DataModel
+ * \Interface to the root class of all topological shapes constructions
+ */
+class GeomAlgoAPI_MakeShape : GeomAPI_Interface
+{
+ public:
+   /// Constructor
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder);
+  /// Returns a shape built by the shape construction algorithm
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>  shape() const;
+
+  /// Returns the  list   of shapes generated   from the shape <theShape>
+  GEOMALGOAPI_EXPORT virtual void generated(
+    const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
+
+  /// Returns the  list   of shapes modified   from the shape <theShape>
+  GEOMALGOAPI_EXPORT virtual void modified(
+    const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
+
+  /// Returns whether the shape is an edge
+  GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
+
+  protected:
+       boost::shared_ptr<GeomAPI_Shape> myShape;
+};
+
+#endif
index 54a52a22a96386b1f4eb5bea7237dac30ffa1852..f502aee03ba59f3ce286eebee36505058ad38da9 100644 (file)
@@ -168,10 +168,10 @@ bool Model_AttributeSelection::update()
             }
           }
         }
-        if (aNewSelected) { // store this new selection
-          selectConstruction(aContext, aNewSelected);
-          return true;
-        }
+      }
+      if (aNewSelected) { // store this new selection
+        selectConstruction(aContext, aNewSelected);
+        return true;
       }
     }
   }
index cc3ed5ef3b003ba4390bb21cddbd6d4a1b3574e2..fe65a751d7719525fa0721b123a776b358241481 100644 (file)
@@ -16,6 +16,7 @@
 #include <Model_Events.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomData_Point.h>
 #include <GeomData_Point2D.h>
@@ -356,10 +357,25 @@ int Model_Data::featureId() const
   return myLab.Father().Tag(); // tag of the feature label
 }
 
+void Model_Data::eraseBackReferences()
+{
+  myRefsToMe.clear();
+  boost::shared_ptr<ModelAPI_Result> aRes = 
+    boost::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+  if (aRes)
+    aRes->setIsConcealed(false);
+}
+
 void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID)
 {
-  // TODO: the concealment state update
   myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
+  if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
+    boost::shared_ptr<ModelAPI_Result> aRes = 
+      boost::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+    if (aRes) {
+      aRes->setIsConcealed(true);
+    }
+  }
 }
 
 void Model_Data::referencesToObjects(
index 46d50acc0080a7dc069f0a9db8198e6abd22ecc2..cb7158b75de28390da8316551c2dd3bfcfc26e1a 100644 (file)
@@ -154,7 +154,7 @@ class Model_Data : public ModelAPI_Data
 
 private:
   // removes all information about back references
-  inline void eraseBackReferences() {myRefsToMe.clear();}
+  void eraseBackReferences();
   // adds a back reference (with identifier which attribute references to this object
   void addBackReference(FeaturePtr theFeature, std::string theAttrID);
   // returns all objects referenced to this
index 05452239ceba196e3b7763f29263c154c8bf29db..cb05a7fbbf59b7af19f8125c262da3210faeafd9 100644 (file)
@@ -288,7 +288,6 @@ void Model_Document::finishOperation()
     myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();  // && (myNestedNum == -1);
     myTransactionsAfterSave++;
   }
-
 }
 
 void Model_Document::abortOperation()
@@ -793,6 +792,10 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated, const bool t
 
 void Model_Document::synchronizeBackRefs()
 {
+  boost::shared_ptr<ModelAPI_Document> aThis = 
+    Model_Application::getApplication()->getDocument(myID);
+  // keeps the concealed flags of result to catch the change and create created/deleted events
+  std::list<std::pair<ResultPtr, bool> > aConcealed;
   // first cycle: erase all data about back-references
   NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFeatures(myObjs);
   for(; aFeatures.More(); aFeatures.Next()) {
@@ -808,6 +811,7 @@ void Model_Document::synchronizeBackRefs()
       boost::shared_ptr<Model_Data> aResData = 
         boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
       if (aResData) {
+        aConcealed.push_back(std::pair<ResultPtr, bool>(*aRIter, (*aRIter)->isConcealed()));
         aResData->eraseBackReferences();
       }
     }
@@ -835,6 +839,17 @@ void Model_Document::synchronizeBackRefs()
       }
     }
   }
+  std::list<std::pair<ResultPtr, bool> >::iterator aCIter = aConcealed.begin();
+  for(; aCIter != aConcealed.end(); aCIter++) {
+    if (aCIter->first->isConcealed() != aCIter->second) { // somethign is changed => produce event
+      if (aCIter->second) { // was concealed become not => creation event
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+        ModelAPI_EventCreator::get()->sendUpdated(aCIter->first, anEvent);
+      } else { // was not concealed become concealed => delete event
+        ModelAPI_EventCreator::get()->sendDeleted(aThis, aCIter->first->groupName());
+      }
+    }
+  }
 }
 
 TDF_Label Model_Document::resultLabel(
index 1fad264d8122ff265b11deea8178ad15d0ce9bce..9b18bc0469d0bc5492d6e270d84aebd05c3012e9 100644 (file)
@@ -20,12 +20,8 @@ void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
     TDF_Label& aShapeLab = aData->shapeLab();
-    // remove the previous history
-    clean();
-    aShapeLab.ForgetAttribute(TNaming_NamedShape::GetID());
-    for(TDF_ChildIterator anIter(aShapeLab); anIter.More(); anIter.Next()) {
-      anIter.Value().ForgetAllAttributes();
-    }
+    // clean builders
+    clean();   
     // store the new shape as primitive
     TNaming_Builder aBuilder(aShapeLab);
     if (!theShape)
@@ -38,6 +34,50 @@ void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
   }
 }
 
+void Model_ResultBody::storeGenerated(const boost::shared_ptr<GeomAPI_Shape>& theFromShape,
+                                         const boost::shared_ptr<GeomAPI_Shape>& theToShape)
+{
+  boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    // clean builders
+    clean();   
+    // store the new shape as primitive
+    TNaming_Builder aBuilder(aShapeLab);
+    if (!theFromShape || !theToShape)
+      return;  // bad shape
+    TopoDS_Shape aShapeBasis = theFromShape->impl<TopoDS_Shape>();
+    if (aShapeBasis.IsNull())
+      return;  // null shape inside
+       TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
+    if (aShapeNew.IsNull())
+      return;  // null shape inside
+    aBuilder.Generated(aShapeBasis, aShapeNew);
+  }
+}
+
+void Model_ResultBody::storeModified(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
+                                         const boost::shared_ptr<GeomAPI_Shape>& theNewShape)
+{
+  boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
+  if (aData) {
+    TDF_Label& aShapeLab = aData->shapeLab();
+    // clean builders
+    clean();   
+    // store the new shape as primitive
+    TNaming_Builder aBuilder(aShapeLab);
+    if (!theOldShape || !theNewShape)
+      return;  // bad shape
+    TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
+    if (aShapeOld.IsNull())
+      return;  // null shape inside
+       TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
+    if (aShapeNew.IsNull())
+      return;  // null shape inside
+    aBuilder.Generated(aShapeOld, aShapeNew);
+  }
+}
+
 boost::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
 {
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
index c4ffbea314ba5af26a775103d1083496091a0e32..f6174cdee1cb82798e836f80e67b954754e331e3 100644 (file)
@@ -28,6 +28,15 @@ class Model_ResultBody : public ModelAPI_ResultBody
 public:
   /// Stores the shape (called by the execution method).
   MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
+
+  /// Stores the generated shape (called by the execution method).
+  MODEL_EXPORT virtual void storeGenerated(const boost::shared_ptr<GeomAPI_Shape>& theFromShape,
+                                              const boost::shared_ptr<GeomAPI_Shape>& theToShape);
+
+  /// Stores the modified shape (called by the execution method).
+  MODEL_EXPORT virtual void storeModified(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
+                                              const boost::shared_ptr<GeomAPI_Shape>& theNewShape);
+
   /// Returns the shape-result produced by this feature
   MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
   /// Returns the source feature of this result
index d1adbbbe92d012f6cb37a6273a15b8354a0b8abd..eecd08b33013590344a004f9e794fc7a7031ac4a 100644 (file)
@@ -224,7 +224,18 @@ void Model_ValidatorsFactory::registerNotObligatory(std::string theFeature, std:
 
 void Model_ValidatorsFactory::registerConcealment(std::string theFeature, std::string theAttribute)
 {
-
+  std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
+  if (aFind == myConcealed.end()) {
+    std::set<std::string> aNewSet;
+    aNewSet.insert(theAttribute);
+    myConcealed[theFeature] = aNewSet;
+  } else {
+    aFind->second.insert(theAttribute);
+  }
 }
 
-
+bool Model_ValidatorsFactory::isConcealed(std::string theFeature, std::string theAttribute)
+{
+  std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
+  return aFind != myConcealed.end() && aFind->second.find(theAttribute) != aFind->second.end();
+}
index cfaeb89c5ff1369c9cb184385cb82228b2869d50..5fa3a8a9004441d4e0000a4f9eff83f25de94df5 100644 (file)
@@ -32,6 +32,10 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   std::map<std::string, AttrValidators> myFeatures;
   /// validators IDs and arguments by feature and attribute IDs
   std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
+  /// Stores the registered attributes that leads to the concealment of referenced objects in 
+  /// data tree. Map from feature kind to set of attribute IDs.
+  std::map<std::string, std::set<std::string> > myConcealed;
+
  public:
   /// Registers the instance of the validator by the ID
   MODEL_EXPORT virtual void registerValidator(const std::string& theID,
@@ -76,6 +80,9 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   /// all referenced features after execution
   virtual void registerConcealment(std::string theFeature, std::string theAttribute);
 
+  /// Returns true that it was registered that attribute conceals the referenced result
+  virtual bool isConcealed(std::string theFeature, std::string theAttribute);
+
 protected:
   void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
   /// Get instance from Session
index db329c1fc621be76c2fab6d7afd0015c197ab20a..8942a62f207a10a6917389e718c386b721a1559e 100644 (file)
@@ -36,6 +36,15 @@ public:
 
   /// Stores the shape (called by the execution method).
   virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
+  /// Stores the generated shape (called by the execution method).
+  virtual void storeGenerated(const boost::shared_ptr<GeomAPI_Shape>& theFromShape,
+                                 const boost::shared_ptr<GeomAPI_Shape>& theToShape) = 0;
+
+  /// Stores the modified shape (called by the execution method).
+  virtual void storeModified(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
+                                 const boost::shared_ptr<GeomAPI_Shape>& theNewShape) = 0;
+
   /// Returns the shape-result produced by this feature
   virtual boost::shared_ptr<GeomAPI_Shape> shape() = 0;
 
index 940be4c4d1b879039859579c5bb2bcda33d697be..cd73508d58ecb55d3b82e1590bacc6abe6b24a51 100644 (file)
@@ -87,6 +87,9 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory
   /// all referenced features after execution
   virtual void registerConcealment(std::string theFeature, std::string theAttribute) = 0;
 
+  /// Returns true that it was registered that attribute conceals the referenced result
+  virtual bool isConcealed(std::string theFeature, std::string theAttribute) = 0;
+
  protected:
   /// Get instance from Session
   ModelAPI_ValidatorsFactory()
index 5d614069f0268226d3613ee501afe2137f5c7c55..6bb769fdafa20b1bfe402eca040e8418232c6361 100644 (file)
@@ -8,6 +8,9 @@
 #include <XGUI_ContextMenuMgr.h>
 #include <XGUI_Preferences.h>
 #include <XGUI_ObjectsBrowser.h>
+#include <XGUI_OperationMgr.h>
+
+#include <ModuleBase_Operation.h>
 
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
@@ -128,7 +131,6 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
         mySelector = createSelector(OCCViewManagers.first());
       }
     }
-    myWorkshop->propertyPanel()->hide();
     QtxPopupMgr* aMgr = popupMgr();  // Create popup manager
     action(myEraseAll)->setEnabled(false);
 
@@ -139,6 +141,17 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
       QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults()));
     }
   }
+  SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
+  myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
+
+  // this following row is caused by #187 bug.
+  // SALOME saves the dock widget positions before deactivateModule() and
+  // load it after the module activation. So, if the panel is visible before
+  // deactivate, it becomes visible after activate.
+  // In order to avoid the visible property panel, the widget position save is
+  // switch off in this module
+  aResMgr->setValue("Study", "store_positions", false);
+
   return isDone;
 }
 
@@ -148,9 +161,6 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
   setMenuShown(false);
   setToolShown(false);
 
-  myWorkshop->propertyPanel()->setVisible(false);
-  desktop()->removeDockWidget(myWorkshop->propertyPanel());
-
   QObject* aObj = myWorkshop->objectBrowser()->parent();
   QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
   if (aObjDoc) {
@@ -160,6 +170,15 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
     aViewAct->setEnabled(false);
   }
 
+  // the active operation should be stopped for the next activation.
+  // There should not be active operation and visualized preview.
+  // Abort operation should be performed before the selection's remove
+  // because the displayed objects should be removed from the viewer, but
+  // the AIS context is obtained from the selector.
+  ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+  if (anOperation)
+    anOperation->abort();
+
   // Delete selector because it has to be redefined on next activation
   if (mySelector) {
     myProxyViewer->setSelector(0);
@@ -168,6 +187,10 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
   }
 
   //myWorkshop->contextMenuMgr()->disconnectViewer();
+
+  SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
+  aResMgr->setValue("Study", "store_positions", myIsStorePositions);
+
   return LightApp_Module::deactivateModule(theStudy);
 }
 
@@ -319,6 +342,21 @@ QStringList NewGeom_Module::nestedActions(const QString& theId) const
   return QStringList();
 }
 
+//******************************************************
+void NewGeom_Module::setDocumentKind(const QString& theId, const QString& theKind)
+{
+  myDocumentType[theId] = theKind;
+}
+
+//******************************************************
+QString NewGeom_Module::documentKind(const QString& theId) const
+{
+  if (myDocumentType.contains(theId))
+    return myDocumentType[theId];
+  return QString();
+
+}
+
 //******************************************************
 void NewGeom_Module::selectionChanged()
 {
index 9da3e31af221efd2fd7d52c19f2fbde2d92e1e34..11a2e10355d209d230d91c66fc519d26a77c8779 100644 (file)
@@ -58,6 +58,14 @@ Q_OBJECT
   //! Returns list of nested actions according to the given command ID
   virtual QStringList nestedActions(const QString& theId) const;
 
+  //! Set the document kind of the action by the given command Id
+  //! \param theId - the command ID
+  //! \param theKind - the document kind
+  virtual void setDocumentKind(const QString& theId, const QString& theKind);
+
+  //! Returns the document kind of the action by the given command ID
+  virtual QString documentKind(const QString& theId) const;
+
   //! Returns interface to Salome viewer
   virtual ModuleBase_IViewer* viewer() const
   {
@@ -102,8 +110,11 @@ Q_OBJECT
   NewGeom_SalomeViewer* myProxyViewer;
 
   QMap<QString, QStringList> myNestedActions;
+  QMap<QString, QString> myDocumentType;
 
   bool myIsOpened;
+  bool myIsStorePositions;
+
 };
 
 #endif
index c3a35fe7cbc534739d8db3a16a52ed3ed00ccef4..081ab537f9c7a6ab02e2b24ab4873b78388813f9 100644 (file)
@@ -129,14 +129,22 @@ void XGUI_ActionsMgr::updateByDocumentKind()
 {
   std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind();
   QString aDocKind = QString::fromStdString(aStdDocKind);
+  XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
   foreach(QAction* eachAction, myActions.values()) {
     XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(eachAction);
+    QString aCmdDocKind;
     if(aCmd) {
-      QString aCmdDocKind = aCmd->documentKind();
-      if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
-        eachAction->setEnabled(false);
+      aCmdDocKind = aCmd->documentKind();
+    }
+    else {
+      QString aId = eachAction->data().toString();
+      if (!aId.isEmpty()) {
+        aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId);
       }
     }
+    if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
+      eachAction->setEnabled(false);
+    }
   }
 }
 
index e4a0276dbf2f728bb19a93653407966d8a26a7c8..0c36dada2d5113a860c4ca6e388abb3b0bd2a4f5 100644 (file)
@@ -67,6 +67,14 @@ class XGUI_EXPORT XGUI_SalomeConnector
   //! Returns list of nested actions according to the given command ID
   virtual QStringList nestedActions(const QString& theId) const = 0;
 
+  //! Set the document kind of the action by the given command Id
+  //! \param theId - the command ID
+  //! \param theKind - the document kind
+  virtual void setDocumentKind(const QString& theId, const QString& theKind) = 0;
+
+  //! Returns the document kind of the action by the given command ID
+  virtual QString documentKind(const QString& theId) const = 0;
+
   //! Returns interface to Salome viewer
   virtual ModuleBase_IViewer* viewer() const = 0;
 
index 8a60b2e4a264fe0e42a24eba2018206e49b194f3..6fd3bd0f3b02ab2d7175a6451fb563be63a8c845 100644 (file)
@@ -585,6 +585,8 @@ void XGUI_Workshop::addFeature(const boost::shared_ptr<Config_FeatureMessage>& t
                                                      QKeySequence(),
                                                      isUsePropPanel);
     salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
+    salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind()));
+
     myActionsMgr->addCommand(aAction);
     myModule->featureCreated(aAction);
   } else {