]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authornds <natalia.donis@opencascade.com>
Tue, 28 Oct 2014 06:53:24 +0000 (09:53 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 28 Oct 2014 06:53:24 +0000 (09:53 +0300)
56 files changed:
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/extrusion_widget.xml
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_PlanarEdges.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_PlanarEdges.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_Shape.h
src/GeomAPI/GeomAPI_Wire.cpp [deleted file]
src/GeomAPI/GeomAPI_Wire.h [deleted file]
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/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp
src/Model/Model_AttributeReference.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultPart.cpp
src/Model/Model_Session.cpp
src/Model/Model_Update.cpp
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_Result.h
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_Validator.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/XGUI/XGUI_Preferences.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index 1f7a65b2dcbc366f278e94c9c37b4d09da2d57ae..5c4ffba8e2f0650a41d6995b9b223073ace77022 100644 (file)
@@ -92,7 +92,7 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theNode,
 
 bool Config_FeatureReader::isInternalFeature(xmlNodePtr theNode)
 {
-  std::string prop = getProperty(theNode, FEATURE_INTERNAL);
+  std::string prop = getProperty(theNode, ATTRIBUTE_INTERNAL);
   std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);
   if (prop.empty() || prop == "false" || prop == "0") {
     return false;
index 5a4eb46831dba5b22024708dbf6a753c6f30ae5e..46338306b780427c9477f28978e747a0769b3621 100644 (file)
@@ -50,8 +50,10 @@ const static char* FEATURE_ICON = "icon";
 const static char* FEATURE_TEXT = "title";
 const static char* FEATURE_KEYSEQUENCE = "keysequence";
 const static char* FEATURE_NESTED = "nested";
-const static char* FEATURE_INTERNAL = "internal";
-const static char* FEATURE_OBLIGATORY = "obligatory";
+
+const static char* ATTRIBUTE_INTERNAL = "internal";
+const static char* ATTRIBUTE_OBLIGATORY = "obligatory";
+const static char* ATTRIBUTE_CONCEALMENT = "concealment";
 // TODO: Rename
 const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param";
 const static char* ANY_WDG_TOOLTIP = FEATURE_TOOLTIP;
index 4d2b643d5eb0b0d7d868ff360f99dc3adec4e58c..ab966dff693de7c0d3dd58afa168fc35561f344c 100644 (file)
@@ -26,9 +26,12 @@ INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
+  ../Events
+  ${CAS_INCLUDE_DIRS}
 )
 
 SET(PROJECT_LIBRARIES
+    Events
     ModelAPI 
     GeomAPI 
     GeomAlgoAPI
index 0e997edafe6fe27d0eda36920a0cdb026c80a0e9..b49f5885488d020c7618e28923def08d36433ae3 100644 (file)
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeBoolean.h>
-
+#include <Events_Error.h>
 #include <GeomAlgoAPI_Extrusion.h>
-
+#include <TopoDS_Shape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_MapOfShape.hxx>
 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()
 {
 }
@@ -33,16 +42,112 @@ void FeaturesPlugin_Extrusion::execute()
       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 = 
+    boost::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->context());
+
   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()->impl<TopoDS_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->impl<TopoDS_Shape>().IsEqual(theContext->impl<TopoDS_Shape>()))
+         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->impl<TopoDS_Shape>().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->impl<TopoDS_Shape>().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 c7c5f4bdd90bebae461edbd3873fae7ace5471a5..4158caaa9ccfa9530086a189f0835978c6b94cfd 100644 (file)
@@ -6,6 +6,7 @@
     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 f2e238051b1a78c16b33e8323d27f0078dd2acaa..8700473eef8ac81a409b9c08a24d6b34631f458e 100644 (file)
@@ -19,7 +19,7 @@ SET(PROJECT_HEADERS
     GeomAPI_Pln.h
     GeomAPI_Shape.h
     GeomAPI_Edge.h
-    GeomAPI_Wire.h
+    GeomAPI_PlanarEdges.h
     GeomAPI_AISObject.h
     GeomAPI_IPresentable.h
     GeomAPI_Curve.h 
@@ -40,7 +40,7 @@ SET(PROJECT_SOURCES
     GeomAPI_Pln.cpp
     GeomAPI_Shape.cpp
     GeomAPI_Edge.cpp
-    GeomAPI_Wire.cpp
+    GeomAPI_PlanarEdges.cpp
     GeomAPI_AISObject.cpp
     GeomAPI_Curve.cpp
 )
diff --git a/src/GeomAPI/GeomAPI_PlanarEdges.cpp b/src/GeomAPI/GeomAPI_PlanarEdges.cpp
new file mode 100644 (file)
index 0000000..f12d622
--- /dev/null
@@ -0,0 +1,50 @@
+// File:        GeomAPI_PlanarEdges.cpp
+// Created:     06 Oct 2014
+// Author:      Sergey BELASH
+
+#include <GeomAPI_Interface.h>
+#include <GeomAPI_PlanarEdges.h>
+
+#include <Standard_TypeDef.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <list>
+
+GeomAPI_PlanarEdges::GeomAPI_PlanarEdges() : GeomAPI_Shape()
+{
+  TopoDS_Compound aBigWireImpl;
+  BRep_Builder aBuilder;
+  aBuilder.MakeCompound(aBigWireImpl);
+  this->setImpl(new TopoDS_Shape(aBigWireImpl));
+}
+
+void GeomAPI_PlanarEdges::addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge)
+{
+  const TopoDS_Edge& anEdge = theEdge->impl<TopoDS_Edge>();
+  if (anEdge.ShapeType() != TopAbs_EDGE)
+    return;
+  TopoDS_Shape& aWire = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
+  BRep_Builder aBuilder;
+  aBuilder.Add(aWire, anEdge);
+}
+
+std::list<boost::shared_ptr<GeomAPI_Shape> > GeomAPI_PlanarEdges::getEdges()
+{
+  TopoDS_Shape& aShape = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
+  //BRepTools_WireExplorer aWireExp(TopoDS::Wire(aShape));
+  TopExp_Explorer aWireExp(aShape, TopAbs_EDGE);
+  std::list<boost::shared_ptr<GeomAPI_Shape> > aResult;
+  for (; aWireExp.More(); aWireExp.Next()) {
+    boost::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
+    anEdge->setImpl(new TopoDS_Shape(aWireExp.Current()));
+    aResult.push_back(anEdge);
+  }
+  return aResult;
+}
diff --git a/src/GeomAPI/GeomAPI_PlanarEdges.h b/src/GeomAPI/GeomAPI_PlanarEdges.h
new file mode 100644 (file)
index 0000000..af84226
--- /dev/null
@@ -0,0 +1,70 @@
+// File:        GeomAPI_PlanarEdges.hxx
+// Created:     24 Jul 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef GEOMAPI_WIRE_H_
+#define GEOMAPI_WIRE_H_
+
+#include "GeomAPI.h"
+#include "GeomAPI_Edge.h"
+#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Dir.h"
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+
+#include <list>
+
+/**\class GeomAPI_PlanarEdges
+ * \ingroup DataModel
+ * \brief Interface to the edge object
+ */
+
+class GeomAPI_PlanarEdges : public GeomAPI_Shape
+{
+ public:
+  /// Creation of empty (null) shape
+  GEOMAPI_EXPORT GeomAPI_PlanarEdges();
+
+  GEOMAPI_EXPORT virtual bool isVertex() const
+  {
+    return false;
+  }
+
+  /// Returns whether the shape is an edge
+  GEOMAPI_EXPORT virtual bool isEdge() const
+  {
+    return false;
+  }
+
+  GEOMAPI_EXPORT void addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge);
+  GEOMAPI_EXPORT std::list<boost::shared_ptr<GeomAPI_Shape> > getEdges();
+
+  /// Returns True if the wire is defined in a plane
+  GEOMAPI_EXPORT bool hasPlane() const { return myOrigin && myNorm && myDirX && myDirY; }
+
+  /// Set/Get origin point
+  GEOMAPI_EXPORT void setOrigin(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin) 
+  { myOrigin = theOrigin; }
+  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Pnt> origin() const { return myOrigin; }
+
+  /// Set/Get X direction vector
+  GEOMAPI_EXPORT void setDirX(const boost::shared_ptr<GeomAPI_Dir>& theDirX) { myDirX = theDirX; }
+  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Dir> dirX() const { return myDirX; }
+
+  /// Set/Get Y direction vector
+  GEOMAPI_EXPORT void setDirY(const boost::shared_ptr<GeomAPI_Dir>& theDirY) { myDirY = theDirY; }
+  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Dir> dirY() const { return myDirY; }
+
+  /// Set/Get Normal direction vector
+  GEOMAPI_EXPORT void setNorm(const boost::shared_ptr<GeomAPI_Dir>& theNorm) { myNorm = theNorm; }
+  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Dir> norm() const { return myNorm; }
+
+private:
+  boost::shared_ptr<GeomAPI_Pnt> myOrigin;
+  boost::shared_ptr<GeomAPI_Dir> myDirX;
+  boost::shared_ptr<GeomAPI_Dir> myDirY;
+  boost::shared_ptr<GeomAPI_Dir> myNorm;
+};
+
+#endif
+
index 96db714562f42983e3730546629d62bb049c306e..9c903d68295a10fcba2b842cf8dd6c0dd2749eb4 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;
 
diff --git a/src/GeomAPI/GeomAPI_Wire.cpp b/src/GeomAPI/GeomAPI_Wire.cpp
deleted file mode 100644 (file)
index 39da519..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// File:        GeomAPI_Wire.cpp
-// Created:     06 Oct 2014
-// Author:      Sergey BELASH
-
-#include <GeomAPI_Interface.h>
-#include <GeomAPI_Wire.h>
-
-#include <Standard_TypeDef.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Wire.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools_WireExplorer.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <list>
-
-GeomAPI_Wire::GeomAPI_Wire() : GeomAPI_Shape()
-{
-  TopoDS_Compound aBigWireImpl;
-  BRep_Builder aBuilder;
-  aBuilder.MakeCompound(aBigWireImpl);
-  this->setImpl(new TopoDS_Shape(aBigWireImpl));
-}
-
-void GeomAPI_Wire::addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge)
-{
-  const TopoDS_Edge& anEdge = theEdge->impl<TopoDS_Edge>();
-  if (anEdge.ShapeType() != TopAbs_EDGE)
-    return;
-  TopoDS_Shape& aWire = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
-  BRep_Builder aBuilder;
-  aBuilder.Add(aWire, anEdge);
-}
-
-std::list<boost::shared_ptr<GeomAPI_Shape> > GeomAPI_Wire::getEdges()
-{
-  TopoDS_Shape& aShape = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
-  //BRepTools_WireExplorer aWireExp(TopoDS::Wire(aShape));
-  TopExp_Explorer aWireExp(aShape, TopAbs_EDGE);
-  std::list<boost::shared_ptr<GeomAPI_Shape> > aResult;
-  for (; aWireExp.More(); aWireExp.Next()) {
-    boost::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
-    anEdge->setImpl(new TopoDS_Shape(aWireExp.Current()));
-    aResult.push_back(anEdge);
-  }
-  return aResult;
-}
diff --git a/src/GeomAPI/GeomAPI_Wire.h b/src/GeomAPI/GeomAPI_Wire.h
deleted file mode 100644 (file)
index 86a4578..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-// File:        GeomAPI_Wire.hxx
-// Created:     24 Jul 2014
-// Author:      Artem ZHIDKOV
-
-#ifndef GEOMAPI_WIRE_H_
-#define GEOMAPI_WIRE_H_
-
-#include "GeomAPI.h"
-#include "GeomAPI_Edge.h"
-#include "GeomAPI_Pnt.h"
-#include "GeomAPI_Dir.h"
-
-#include <boost/smart_ptr/shared_ptr.hpp>
-
-#include <list>
-
-/**\class GeomAPI_Wire
- * \ingroup DataModel
- * \brief Interface to the edge object
- */
-
-class GeomAPI_Wire : public GeomAPI_Shape
-{
- public:
-  /// Creation of empty (null) shape
-  GEOMAPI_EXPORT GeomAPI_Wire();
-
-  GEOMAPI_EXPORT virtual bool isVertex() const
-  {
-    return false;
-  }
-
-  /// Returns whether the shape is an edge
-  GEOMAPI_EXPORT virtual bool isEdge() const
-  {
-    return false;
-  }
-
-  GEOMAPI_EXPORT void addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge);
-  GEOMAPI_EXPORT std::list<boost::shared_ptr<GeomAPI_Shape> > getEdges();
-
-  /// Returns True if the wire is defined in a plane
-  GEOMAPI_EXPORT bool hasPlane() const { return myOrigin && myNorm && myDirX && myDirY; }
-
-  /// Set/Get origin point
-  GEOMAPI_EXPORT void setOrigin(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin) 
-  { myOrigin = theOrigin; }
-  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Pnt> origin() const { return myOrigin; }
-
-  /// Set/Get X direction vector
-  GEOMAPI_EXPORT void setDirX(const boost::shared_ptr<GeomAPI_Dir>& theDirX) { myDirX = theDirX; }
-  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Dir> dirX() const { return myDirX; }
-
-  /// Set/Get Y direction vector
-  GEOMAPI_EXPORT void setDirY(const boost::shared_ptr<GeomAPI_Dir>& theDirY) { myDirY = theDirY; }
-  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Dir> dirY() const { return myDirY; }
-
-  /// Set/Get Normal direction vector
-  GEOMAPI_EXPORT void setNorm(const boost::shared_ptr<GeomAPI_Dir>& theNorm) { myNorm = theNorm; }
-  GEOMAPI_EXPORT boost::shared_ptr<GeomAPI_Dir> norm() const { return myNorm; }
-
-private:
-  boost::shared_ptr<GeomAPI_Pnt> myOrigin;
-  boost::shared_ptr<GeomAPI_Dir> myDirX;
-  boost::shared_ptr<GeomAPI_Dir> myDirY;
-  boost::shared_ptr<GeomAPI_Dir> myNorm;
-};
-
-#endif
-
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..d5f2c4379debded24d1f39ee735f1efac3cbd172 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>
+
 const double tolerance = Precision::Angular();
+  // Constructor
+GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize)
+         : mySize(theSize), myBuilder(NULL), myDone(false), myShape(new GeomAPI_Shape())
+  {
+    myBasis = theBasis->impl<TopoDS_Shape>();
+       build();
+  }
 
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
-    boost::shared_ptr<GeomAPI_Shape> theShape, boost::shared_ptr<GeomAPI_Dir> theDir,
-    double theSize)
-{
-  const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
-  gp_Vec aDir(theDir->impl<gp_Dir>().XYZ() * theSize);
+  //============================================================================
+  void GeomAlgoAPI_Extrusion::build()
+  {
+    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>(); 
+    Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(TopoDS::Face(myBasis)));
+    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;
 
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
-    boost::shared_ptr<GeomAPI_Shape> theShape, double theSize)
+    myBuilder = new BRepPrimAPI_MakePrism(myBasis, aVec);
+       if(myBuilder != NULL) {
+         myDone = myBuilder->IsDone();
+         if(myDone) {
+               if(myBuilder->Shape().ShapeType() == TopAbs_COMPOUND) 
+                 myResult = GeomAlgoAPI_DFLoader::refineResult(myBuilder->Shape());
+               else
+                 myResult = myBuilder->Shape();                
+               myShape->setImpl((void *)&myResult);  
+               myFirst->setImpl((void *)&(myBuilder->FirstShape()));
+               myLast->setImpl((void *)&(myBuilder-> LastShape()));
+         }
+       }       
+  }
+
+  //============================================================================
+const bool GeomAlgoAPI_Extrusion::isDone() const
+{return myDone;}
+
+  //============================================================================
+const bool GeomAlgoAPI_Extrusion::isValid() const
 {
-  bool isFirstNorm = true;
-  gp_Dir aShapeNormal;
-
-  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);
+       bool isValid(false);
+       if(myDone && !myBuilder->Shape().IsNull()) {
+         BRepCheck_Analyzer aChecker(myBuilder->Shape());
+         isValid = aChecker.IsValid();
+       }
+       return isValid;
+  }
+
+  //============================================================================
+  const bool GeomAlgoAPI_Extrusion::hasVolume() const
+  {
+       bool hasVolume(false);
+       if(isValid()) {
+         const TopoDS_Shape& aRShape = myBuilder->Shape();
+         GProp_GProps aGProp;
+      BRepGProp::VolumeProperties(aRShape, aGProp);
+      if(aGProp.Mass() > Precision::Confusion()) 
+               hasVolume = true;       
+       }
+       return hasVolume;
   }
-  if (aFaces.IsNull())
-    return boost::shared_ptr<GeomAPI_Shape>();
 
-  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);
-}
+  //============================================================================
+  const ListOfShape& GeomAlgoAPI_Extrusion::generated(const boost::shared_ptr<GeomAPI_Shape> theShape)
+  {
+       myHistory.clear();
+    if(myDone) {
+       const TopTools_ListOfShape& aList =  myBuilder->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()));
+               myHistory.push_back(aShape);
+       }
+  }
+  return myHistory;
+  }
+  
+  //============================================================================
+   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..03d704d5dd6a4fdafe5276f845d0b4b16c5f924b 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,65 @@
 #include <GeomAlgoAPI.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_Dir.h>
+#include <ModelAPI_ResultBody.h>
 #include <boost/shared_ptr.hpp>
-
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <TopoDS_Shape.hxx>
 /**\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_EXPORT GeomAlgoAPI_Extrusion  
 {
  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_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize);
+
+  /// Returns True if algorithm succeed
+  const bool isDone() const;
+
+  ///  Returns True if resulting shape is valid
+  const bool isValid() const;
+
+  /// Returns True if resulting shape has volume
+  const bool hasVolume() const;
+
+  /// Returns result of the Extrusion algorithm which may be a Solid or a Face
+  const boost::shared_ptr<GeomAPI_Shape>& shape () const;
+
+  /// Returns list of shapes generated from theShape
+  const ListOfShape& generated(const boost::shared_ptr<GeomAPI_Shape> theShape);
+
+  /// Returns the first shape 
+  const boost::shared_ptr<GeomAPI_Shape>& firstShape();
+
+  /// returns last shape
+  const boost::shared_ptr<GeomAPI_Shape>& lastShape();  
+
+private:
+  /// builds resulting shape
+  void build();
+
+  BRepPrimAPI_MakePrism * myBuilder;
+  TopoDS_Shape myBasis;
+  double mySize;
+  bool myDone;
+  TopoDS_Shape myResult;
+  ListOfShape myHistory;
+  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..d743b56
--- /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(BRepBuilderAPI_MakeShape *  theMkShape)
+{ myBuilder = theMkShape;}
+
+const boost::shared_ptr<GeomAPI_Shape>  GeomAlgoAPI_MakeShape::shape() const
+{
+  boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  if(myBuilder != NULL) 
+    aShape->setImpl(new TopoDS_Shape(myBuilder->Shape()));
+  return aShape;
+}
+
+  /// Returns the  list   of shapes generated   from the shape <theShape>
+const ListOfShape& GeomAlgoAPI_MakeShape::generated(const boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+  myHistory.clear();
+  if(myBuilder != NULL) {
+       const TopTools_ListOfShape& aList =  myBuilder->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()));
+               myHistory.push_back(aShape);
+       }
+  }
+  return myHistory;
+}
+
+  /// Returns the  list   of shapes modified   from the shape <theShape>
+const ListOfShape& GeomAlgoAPI_MakeShape::modified(const boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+  myHistory.clear();
+  if(myBuilder != NULL) {
+       const TopTools_ListOfShape& aList =  myBuilder->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()));
+               myHistory.push_back(aShape);
+       }
+  }
+  return myHistory;
+}
+
+  /// Returns whether the shape is an edge
+bool GeomAlgoAPI_MakeShape::isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+  bool isDeleted(false);
+  if (myBuilder != NULL) 
+       isDeleted = (bool) myBuilder->IsDeleted(theShape->impl<TopoDS_Shape>());        
+  return isDeleted;
+}
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
new file mode 100644 (file)
index 0000000..9357ff4
--- /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_EXPORT GeomAlgoAPI_MakeShape
+{
+ public:
+   /// Constructor
+  GeomAlgoAPI_MakeShape(BRepBuilderAPI_MakeShape * theBuilder);
+  /// Returns a shape built by the shape construction algorithm
+  const boost::shared_ptr<GeomAPI_Shape>  shape() const;
+
+  /// Returns the  list   of shapes generated   from the shape <theShape>
+  virtual const ListOfShape& generated(const boost::shared_ptr<GeomAPI_Shape> theShape);
+
+  /// Returns the  list   of shapes modified   from the shape <theShape>
+  virtual const ListOfShape& modified(const boost::shared_ptr<GeomAPI_Shape> theShape);
+
+  /// Returns whether the shape is an edge
+  virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
+
+  protected:
+       boost::shared_ptr<GeomAPI_Shape> myShape;
+       ListOfShape myHistory;
+       BRepBuilderAPI_MakeShape * myBuilder;
+};
+
+#endif
\ No newline at end of file
index 0d0fc34183ce5cdb61dcc341e98ccc075a8915f3..ddd6d397712e5bcf3aa29e2ae2b38616ad4a71e3 100644 (file)
@@ -3,7 +3,7 @@
 // Author:      Artem ZHIDKOV
 
 #include <GeomAlgoAPI_SketchBuilder.h>
-#include <GeomAPI_Wire.h>
+#include <GeomAPI_PlanarEdges.h>
 
 #include <set>
 
@@ -378,7 +378,7 @@ void GeomAlgoAPI_SketchBuilder::createFaces(const boost::shared_ptr<GeomAPI_Pnt>
                                             const boost::shared_ptr<GeomAPI_Shape>& theWire,
                                             std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces)
 {
-  boost::shared_ptr<GeomAPI_Wire> aWire = boost::dynamic_pointer_cast<GeomAPI_Wire>(theWire);
+  boost::shared_ptr<GeomAPI_PlanarEdges> aWire = boost::dynamic_pointer_cast<GeomAPI_PlanarEdges>(theWire);
   if(!aWire)
     return;
   // Filter wires, return only faces.
index 134516972b2a2eecfacab366f3bb46f9204d5a8c..3781fb2a2c4157a37b8a9b605b596e85ec4a3179 100644 (file)
@@ -20,9 +20,7 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
 
     boost::shared_ptr<Model_Document> aDoc =
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
-    if (aDoc) aDoc->objectIsNotReferenced(aDoc->object(myRef->Get()));
     myRef->Set(aData->label().Father());  // references to the feature label
-    boost::shared_dynamic_cast<Model_Document>(owner()->document())->objectIsReferenced(theObject);
 
     owner()->data()->sendAttributeUpdated(this);
   }
@@ -51,7 +49,6 @@ Model_AttributeReference::Model_AttributeReference(TDF_Label& theLabel)
     if (owner()) {
       boost::shared_ptr<Model_Document> aDoc =
         boost::dynamic_pointer_cast<Model_Document>(owner()->document());
-      if (aDoc) aDoc->objectIsReferenced(aDoc->object(myRef->Get()));
     }
   }
 }
@@ -62,7 +59,6 @@ void Model_AttributeReference::setObject(const boost::shared_ptr<ModelAPI_Object
     ModelAPI_AttributeReference::setObject(theObject);
     boost::shared_ptr<Model_Document> aDoc =
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
-    if (aDoc) aDoc->objectIsReferenced(aDoc->object(myRef->Get()));
   }
 }
 
@@ -71,5 +67,4 @@ Model_AttributeReference::~Model_AttributeReference()
   boost::shared_ptr<Model_Document> aDoc =
     boost::dynamic_pointer_cast<Model_Document>(owner()->document());
   TDF_Label aLab = myRef->Get();
-  if (aDoc && !aLab.IsNull()) aDoc->objectIsNotReferenced(aDoc->object(myRef->Get()));
 }
index 9c71730a021a647bef420f490b566f0c6cdb8c29..54a52a22a96386b1f4eb5bea7237dac30ffa1852 100644 (file)
@@ -11,8 +11,9 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <GeomAPI_Shape.h>
-#include <GeomAPI_Wire.h>
+#include <GeomAPI_PlanarEdges.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
+#include <Events_Error.h>
 
 #include <TNaming_Selector.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -56,7 +57,7 @@ boost::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
   boost::shared_ptr<GeomAPI_Shape> aResult;
   if (myIsInitialized) {
     Handle(TNaming_NamedShape) aSelection;
-    if (myRef.myRef->Label().FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
+    if (selectionLabel().FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
       TopoDS_Shape aSelShape = aSelection->Get();
       aResult = boost::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
       aResult->setImpl(new TopoDS_Shape(aSelShape));
@@ -88,14 +89,14 @@ bool Model_AttributeSelection::update()
   if (!aContext) return false;
   if (aContext->groupName() == ModelAPI_ResultBody::group()) {
     // body: just a named shape, use selection mechanism from OCCT
-    TNaming_Selector aSelector(myRef.myRef->Label());
+    TNaming_Selector aSelector(selectionLabel());
     TDF_LabelMap aScope; // empty means the whole document
     return aSelector.Solve(aScope) == Standard_True;
    
   } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) {
     // construction: identification by the results indexes, recompute faces and
     // take the face that more close by the indexes
-    boost::shared_ptr<GeomAPI_Wire> aWirePtr = boost::dynamic_pointer_cast<GeomAPI_Wire>(
+    boost::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = boost::dynamic_pointer_cast<GeomAPI_PlanarEdges>(
       boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext)->shape());
     if (aWirePtr && aWirePtr->hasPlane()) {
         // If this is a wire with plane defined thin it is a sketch-like object
@@ -129,7 +130,7 @@ bool Model_AttributeSelection::update()
             for(; aRes != aResults.cend(); aRes++) {
               ResultConstructionPtr aConstr = 
                 boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aRes);
-              if (aConstr->shape()) {
+              if (aConstr->shape() && aConstr->shape()->isEdge()) {
                 const TopoDS_Shape& aResShape = aConstr->shape()->impl<TopoDS_Shape>();
                 TopoDS_Edge anEdge = TopoDS::Edge(aResShape);
                 if (!anEdge.IsNull()) {
@@ -182,7 +183,7 @@ void Model_AttributeSelection::selectBody(
     const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
   // perform the selection
-  TNaming_Selector aSel(myRef.myRef->Label());
+  TNaming_Selector aSel(selectionLabel());
   TopoDS_Shape aNewShape = theSubShape ? theSubShape->impl<TopoDS_Shape>() : TopoDS_Shape();
   TopoDS_Shape aContext;
 
@@ -191,14 +192,13 @@ void Model_AttributeSelection::selectBody(
     aContext = aBody->shape()->impl<TopoDS_Shape>();
   else {
     ResultConstructionPtr aConstr = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myRef.value());
-    if (aConstr)
+    if (aConstr) {
       aContext = aConstr->shape()->impl<TopoDS_Shape>();
-    else
-      throw std::invalid_argument("a result with shape is expected");
+    } else {
+      Events_Error::send("A result with shape is expected");
+      return;
+    }
   }
-  Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aNewShape, myRef.myRef->Label());
-  TDF_Label aLab = aNS->Label();
-
   aSel.Select(aNewShape, aContext);
 }
 
@@ -233,7 +233,7 @@ void Model_AttributeSelection::selectConstruction(
     for(; aRes != aResults.cend(); aRes++) {
       ResultConstructionPtr aConstr = 
         boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aRes);
-      if (aConstr->shape()) {
+      if (aConstr->shape() && aConstr->shape()->isEdge()) {
         const TopoDS_Shape& aResShape = aConstr->shape()->impl<TopoDS_Shape>();
         TopoDS_Edge anEdge = TopoDS::Edge(aResShape);
         if (!anEdge.IsNull()) {
@@ -249,6 +249,11 @@ void Model_AttributeSelection::selectConstruction(
     }
   }
   // store the selected as primitive
-  TNaming_Builder aBuilder(myRef.myRef->Label());
+  TNaming_Builder aBuilder(selectionLabel());
   aBuilder.Generated(aSubShape);
 }
+
+TDF_Label Model_AttributeSelection::selectionLabel()
+{
+  return myRef.myRef->Label().FindChild(1);
+}
index 79ce151daf2fd6cd10c683f167cc15914e76a846..1508476794ba5bd7f6ebd46d9d4c4a8e45a47b06 100644 (file)
@@ -47,6 +47,10 @@ protected:
   virtual void selectConstruction(
     const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape);
 
+  /// Returns the label where TNaming_Selection results are stored
+  /// Note: there must be no attributes stored at the same label because Selector clears this lab
+  TDF_Label selectionLabel();
+
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
 };
index 31a2e6473fac8d178f86dc21c3fcad510c595558..a95510118475b39a4e03d102df82725f09fa8de9 100644 (file)
@@ -43,6 +43,7 @@ boost::shared_ptr<ModelAPI_AttributeSelection>
 void Model_AttributeSelectionList::clear()
 {
   if (!mySubs.empty()) {
+    mySize->Set(0);
     mySubs.clear();
     TDF_ChildIterator aSubIter(mySize->Label());
     for(; aSubIter.More(); aSubIter.Next()) {
index b293bd3f9af914a6cf302e57f57d0325da9a53ff..cc3ed5ef3b003ba4390bb21cddbd6d4a1b3574e2 100644 (file)
@@ -351,44 +351,52 @@ bool Model_Data::mustBeUpdated()
   return myLab.IsAttribute(kMustBeUpdatedGUID) == Standard_True;
 }
 
-bool Model_Data::referencesTo(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+int Model_Data::featureId() const
 {
-  // collect results of this feature first to check references quickly in the cycle
-  std::set<ObjectPtr> aFeatureObjs;
-  aFeatureObjs.insert(theFeature);
-  std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter =
-    theFeature->results().cbegin();
-  for(; aRIter != theFeature->results().cend(); aRIter++) {
-    if (*aRIter)
-      aFeatureObjs.insert(*aRIter);
-  }
+  return myLab.Father().Tag(); // tag of the feature label
+}
 
-  std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = 
-    myAttrs.begin();
-  for (; anAttrsIter != myAttrs.end(); anAttrsIter++) {
-    if (anAttrsIter->second->attributeType() == ModelAPI_AttributeRefAttr::type()) {
-      boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr = 
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttrsIter->second);
-      if (aRefAttr && aRefAttr->isObject()) { // check referenced object
-        if (aFeatureObjs.find(aRefAttr->object()) != aFeatureObjs.end())
-          return true;
-      } else { // check object of referenced attribute
-        boost::shared_ptr<ModelAPI_Attribute> anAttr = aRefAttr->attr();
-        if (anAttr && aFeatureObjs.find(anAttr->owner()) != aFeatureObjs.end())
-          return true;
-      }
-    } else if (anAttrsIter->second->attributeType() == ModelAPI_AttributeReference::type()) {
-      boost::shared_ptr<ModelAPI_AttributeReference> aRef = 
-        boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttrsIter->second);
-      if (aFeatureObjs.find(aRef->value()) != aFeatureObjs.end()) {
-        return true;
-      }
-    }
-  }
-  return false;
+void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID)
+{
+  // TODO: the concealment state update
+  myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
 }
 
-int Model_Data::featureId() const
+void Model_Data::referencesToObjects(
+  std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs)
 {
-  return myLab.Father().Tag(); // tag of the feature label
+  std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
+  std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory menagement
+  for(; anAttr != myAttrs.end(); anAttr++) {
+    std::string aType = anAttr->second->attributeType();
+    if (aType == ModelAPI_AttributeReference::type()) { // reference to object
+      boost::shared_ptr<ModelAPI_AttributeReference> aRef = boost::dynamic_pointer_cast<
+          ModelAPI_AttributeReference>(anAttr->second);
+      aReferenced.push_back(aRef->value());
+      theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
+    } else if (aType == ModelAPI_AttributeRefAttr::type()) { // reference to attribute or object
+      boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+          ModelAPI_AttributeRefAttr>(anAttr->second);
+      aReferenced.push_back(aRef->isObject() ? aRef->object() : aRef->attr()->owner());
+    } else if (aType == ModelAPI_AttributeRefList::type()) { // list of references
+      aReferenced = boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
+    } else if (aType == ModelAPI_AttributeSelection::type()) { // selection attribute
+      boost::shared_ptr<ModelAPI_AttributeSelection> aRef = boost::dynamic_pointer_cast<
+          ModelAPI_AttributeSelection>(anAttr->second);
+      aReferenced.push_back(aRef->context());
+      theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
+    } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes
+      boost::shared_ptr<ModelAPI_AttributeSelectionList> aRef = boost::dynamic_pointer_cast<
+          ModelAPI_AttributeSelectionList>(anAttr->second);
+      for(int a = aRef->size() - 1; a >= 0; a--) {
+        aReferenced.push_back(aRef->value(a)->context());
+      }
+    } else
+      continue; // nothing to do, not reference
+
+    if (!aReferenced.empty()) {
+      theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
+      aReferenced.clear();
+    }
+  }
 }
index d61ddd6c2ca45302e1ef062982c815abf8302f63..46d50acc0080a7dc069f0a9db8198e6abd22ecc2 100644 (file)
@@ -26,6 +26,7 @@
 #include <map>
 #include <list>
 #include <string>
+#include <set>
 
 class ModelAPI_Attribute;
 
@@ -44,6 +45,9 @@ class Model_Data : public ModelAPI_Data
   /// needed here to emit signal that object changed on change of the attribute
   ObjectPtr myObject;
 
+  /// List of attributes referenced to owner (updated only during the transaction change)
+  std::set<AttributePtr> myRefsToMe;
+
   Model_Data();
 
   /// Returns label of this feature
@@ -53,6 +57,7 @@ class Model_Data : public ModelAPI_Data
   }
 
   friend class Model_Document;
+  friend class Model_Update;
   friend class Model_AttributeReference;
   friend class Model_AttributeRefAttr;
   friend class Model_AttributeRefList;
@@ -144,12 +149,19 @@ class Model_Data : public ModelAPI_Data
   /// Returns true if feature must be updated (re-executed) on rebuild
   MODEL_EXPORT virtual bool mustBeUpdated();
 
-  /// Returns true if this data attributes are referenced to the given feature or its results
-  MODEL_EXPORT virtual bool referencesTo(const boost::shared_ptr<ModelAPI_Feature>& theFeature);
-
   /// Returns the identifier of feature-owner, unique in this document
   MODEL_EXPORT virtual int featureId() const;
 
+private:
+  // removes all information about back references
+  inline void eraseBackReferences() {myRefsToMe.clear();}
+  // 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
+  const std::set<AttributePtr>& refsToMe() {return myRefsToMe;}
+  // returns all references by attributes of this data
+  // \param the returned list of pairs: id of referenced attribute and list of referenced objects
+  void referencesToObjects(std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
 };
 
 #endif
index 59ebd2fb0f1663417cfa9e1b17c945d973215a64..05452239ceba196e3b7763f29263c154c8bf29db 100644 (file)
@@ -10,6 +10,7 @@
 #include <Model_ResultPart.h>
 #include <Model_ResultConstruction.h>
 #include <Model_ResultBody.h>
+#include <ModelAPI_Validator.h>
 #include <Events_Loop.h>
 #include <Events_Error.h>
 
@@ -146,7 +147,7 @@ bool Model_Document::load(const char* theFileName)
     myDoc->SetUndoLimit(UNDO_LIMIT);
     // to avoid the problem that feature is created in the current, not this, document
     Model_Session::get()->setActiveDocument(anApp->getDocument(myID));
-    synchronizeFeatures();
+    synchronizeFeatures(false, true);
   }
   return !isError;
 }
@@ -264,10 +265,12 @@ void Model_Document::finishOperation()
   if (!myDoc->HasOpenCommand() && myNestedNum != -1)
     boost::static_pointer_cast<Model_Session>(Model_Session::get())
         ->setCheckTransactions(false);  // for nested transaction commit
+  synchronizeBackRefs();
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
   if (!myDoc->HasOpenCommand() && myNestedNum != -1)
     boost::static_pointer_cast<Model_Session>(Model_Session::get())
@@ -304,7 +307,7 @@ void Model_Document::abortOperation()
       myNestedNum = -1;
     myDoc->AbortCommand();
   }
-  synchronizeFeatures(true);
+  synchronizeFeatures(true, false); // references were not changed since transaction start
   // abort for all subs
   std::set<std::string>::iterator aSubIter = mySubs.begin();
   for (; aSubIter != mySubs.end(); aSubIter++)
@@ -343,7 +346,7 @@ void Model_Document::undo()
     myNestedNum--;
   if (!myIsEmptyTr[myTransactionsAfterSave])
     myDoc->Undo();
-  synchronizeFeatures(true);
+  synchronizeFeatures(true, true);
   // undo for all subs
   std::set<std::string>::iterator aSubIter = mySubs.begin();
   for (; aSubIter != mySubs.end(); aSubIter++)
@@ -369,7 +372,7 @@ void Model_Document::redo()
   if (!myIsEmptyTr[myTransactionsAfterSave])
     myDoc->Redo();
   myTransactionsAfterSave++;
-  synchronizeFeatures(true);
+  synchronizeFeatures(true, true);
   // redo for all subs
   std::set<std::string>::iterator aSubIter = mySubs.begin();
   for (; aSubIter != mySubs.end(); aSubIter++)
@@ -467,16 +470,11 @@ void Model_Document::removeFeature(FeaturePtr theFeature, const bool theCheck)
     // check the feature: it must have no depended objects on it
     std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
     for(; aResIter != theFeature->results().cend(); aResIter++) {
-      if (myConcealedResults.find(*aResIter) != myConcealedResults.end()) {
-        Events_Error::send("Feature '" + theFeature->data()->name() + "' is used and can not be deleted");
-        return;
-      }
-    }
-    NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator anObjIter(myObjs);
-    for(; anObjIter.More(); anObjIter.Next()) {
-      DataPtr aData = anObjIter.Value()->data();
-      if (aData->referencesTo(theFeature)) {
-        Events_Error::send("Feature '" + theFeature->data()->name() + "' is used and can not be deleted");
+      boost::shared_ptr<Model_Data> aData = 
+        boost::dynamic_pointer_cast<Model_Data>((*aResIter)->data());
+      if (aData && !aData->refsToMe().empty()) {
+        Events_Error::send(
+          "Feature '" + theFeature->data()->name() + "' is used and can not be deleted");
         return;
       }
     }
@@ -493,22 +491,11 @@ void Model_Document::removeFeature(FeaturePtr theFeature, const bool theCheck)
   // erase all attributes under the label of feature
   aFeatureLabel.ForgetAllAttributes();
   // remove it from the references array
-  RemoveFromRefArray(featuresLabel(), aFeatureLabel);
-
+  if (theFeature->isInHistory()) {
+    RemoveFromRefArray(featuresLabel(), aFeatureLabel);
+  }
   // event: feature is deleted
   ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
-  /* this is in "erase"
-  // results of this feature must be redisplayed
-  static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-  const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
-  std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
-  for (; aRIter != aResults.cend(); aRIter++) {
-    boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
-    aRes->setData(boost::shared_ptr<ModelAPI_Data>());  // deleted flag
-    ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
-    ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName());
-  }
-  */
 }
 
 FeaturePtr Model_Document::feature(TDF_Label& theLabel)
@@ -590,9 +577,9 @@ ObjectPtr Model_Document::object(const std::string& theGroupID, const int theInd
       std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
       for (; aRIter != aResults.cend(); aRIter++) {
         if ((*aRIter)->groupName() != theGroupID) continue;
-        bool isIn = theHidden;
+        bool isIn = theHidden && (*aRIter)->isInHistory();
         if (!isIn && (*aRIter)->isInHistory()) { // check that there is nobody references this result
-          isIn = myConcealedResults.find(*aRIter) == myConcealedResults.end();
+          isIn = !(*aRIter)->isConcealed();
         }
         if (isIn) {
           if (anIndex == theIndex)
@@ -629,7 +616,7 @@ int Model_Document::size(const std::string& theGroupID, const bool theHidden)
         if ((*aRIter)->groupName() != theGroupID) continue;
         bool isIn = theHidden;
         if (!isIn && (*aRIter)->isInHistory()) { // check that there is nobody references this result
-          isIn = myConcealedResults.find(*aRIter) == myConcealedResults.end();
+          isIn = !(*aRIter)->isConcealed();
         }
         if (isIn)
           aResult++;
@@ -664,12 +651,12 @@ void Model_Document::setUniqueName(FeaturePtr theFeature)
   // check this is unique, if not, increase index by 1
   for (aFIter.Initialize(myObjs); aFIter.More();) {
     FeaturePtr aFeature = aFIter.Value();
-    bool isSameName = aFeature->isInHistory() && aFeature->data()->name() == aName;
+    bool isSameName = aFeature->data()->name() == aName;
     if (!isSameName) {  // check also results to avoid same results names (actual for Parts)
       const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
       std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
       for (; aRIter != aResults.cend(); aRIter++) {
-        isSameName = (*aRIter)->isInHistory() && (*aRIter)->data()->name() == aName;
+        isSameName = (*aRIter)->data()->name() == aName;
       }
     }
     if (isSameName) {
@@ -701,7 +688,7 @@ void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theT
   }
 }
 
-void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
+void Model_Document::synchronizeFeatures(const bool theMarkUpdated, const bool theUpdateReferences)
 {
   boost::shared_ptr<ModelAPI_Document> aThis = 
     Model_Application::getApplication()->getDocument(myID);
@@ -785,6 +772,10 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
       aFIter.Next();
   }
 
+  if (theUpdateReferences) {
+    synchronizeBackRefs();
+  }
+
   myExecuteFeatures = false;
   aLoop->activateFlushes(true);
 
@@ -794,11 +785,58 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
     aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
   boost::static_pointer_cast<Model_Session>(Model_Session::get())
     ->setCheckTransactions(true);
   myExecuteFeatures = true;
 }
 
+void Model_Document::synchronizeBackRefs()
+{
+  // first cycle: erase all data about back-references
+  NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFeatures(myObjs);
+  for(; aFeatures.More(); aFeatures.Next()) {
+    FeaturePtr aFeature = aFeatures.Value();
+    boost::shared_ptr<Model_Data> aFData = 
+      boost::dynamic_pointer_cast<Model_Data>(aFeature->data());
+    if (aFData) {
+      aFData->eraseBackReferences();
+    }
+    const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+    std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+    for (; aRIter != aResults.cend(); aRIter++) {
+      boost::shared_ptr<Model_Data> aResData = 
+        boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
+      if (aResData) {
+        aResData->eraseBackReferences();
+      }
+    }
+  }
+
+  // second cycle: set new back-references: only features may have reference, iterate only them
+  ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+  for(aFeatures.Initialize(myObjs); aFeatures.More(); aFeatures.Next()) {
+    FeaturePtr aFeature = aFeatures.Value();
+    boost::shared_ptr<Model_Data> aFData = 
+      boost::dynamic_pointer_cast<Model_Data>(aFeature->data());
+    if (aFData) {
+      std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
+      aFData->referencesToObjects(aRefs);
+      std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRefsIter = aRefs.begin();
+      for(; aRefsIter != aRefs.end(); aRefsIter++) {
+        std::list<ObjectPtr>::iterator aRefTo = aRefsIter->second.begin();
+        for(; aRefTo != aRefsIter->second.end(); aRefTo++) {
+          if (*aRefTo) {
+            boost::shared_ptr<Model_Data> aRefData = 
+              boost::dynamic_pointer_cast<Model_Data>((*aRefTo)->data());
+            aRefData->addBackReference(aFeature, aRefsIter->first); // here the Concealed flag is updated
+          }
+        }
+      }
+    }
+  }
+}
+
 TDF_Label Model_Document::resultLabel(
   const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theResultIndex) 
 {
@@ -928,48 +966,6 @@ void Model_Document::updateResults(FeaturePtr theFeature)
   }
 }
 
-void Model_Document::objectIsReferenced(const ObjectPtr& theObject)
-{
-  // only bodies are concealed now
-  ResultBodyPtr aResult = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theObject);
-  if (aResult) {
-    if (myConcealedResults.find(aResult) != myConcealedResults.end()) {
-      Events_Error::send(std::string("The object '") + aResult->data()->name() +
-        "' is already referenced");
-    } else {
-      myConcealedResults.insert(aResult);
-      boost::shared_ptr<ModelAPI_Document> aThis = 
-        Model_Application::getApplication()->getDocument(myID);
-      ModelAPI_EventCreator::get()->sendDeleted(aThis, ModelAPI_ResultBody::group());
-
-      static Events_Loop* aLoop = Events_Loop::loop();
-      static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-      static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
-      aECreator->sendUpdated(aResult, EVENT_DISP);
-    }
-  }
-}
-
-void Model_Document::objectIsNotReferenced(const ObjectPtr& theObject)
-{
-  // only bodies are concealed now
-  ResultBodyPtr aResult = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theObject);
-  if (aResult) {
-    std::set<ResultPtr>::iterator aFind = myConcealedResults.find(aResult);
-    if (aFind != myConcealedResults.end()) {
-      ResultPtr aFeature = *aFind;
-      myConcealedResults.erase(aFind);
-      boost::shared_ptr<ModelAPI_Document> aThis = 
-        Model_Application::getApplication()->getDocument(myID);
-      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
-      ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent, false);
-    } else {
-      Events_Error::send(std::string("The object '") + aResult->data()->name() +
-        "' was not referenced '");
-    }
-  }
-}
-
 Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper)
 {
   return TDF_LabelMapHasher::HashCode(theLab, theUpper);
index 6f813bd231da45a6b72917c1b7cb508605c3259f..cbea4a19e58826dd8c9148f0e33679ccea3b60d8 100644 (file)
@@ -130,12 +130,6 @@ class Model_Document : public ModelAPI_Document
   ///! On abort, undo or redo it is not necessary: results in document are updated automatically
   bool executeFeatures() {return myExecuteFeatures;}
 
-  ///! Reutrns true is result was conecaled because of usage it by other object
-  virtual bool isConcealed(const boost::shared_ptr<ModelAPI_Object>& theResult) {
-    return myConcealedResults.find(boost::dynamic_pointer_cast<ModelAPI_Result>(theResult))
-      != myConcealedResults.end();
-  }
-
  protected:
 
   //! Returns (creates if needed) the features label
@@ -146,7 +140,11 @@ class Model_Document : public ModelAPI_Document
   void setUniqueName(FeaturePtr theFeature);
 
   //! Synchronizes myFeatures list with the updated document
-  void synchronizeFeatures(const bool theMarkUpdated = false);
+  //! \param theMarkUpdated causes the "update" event for all features
+  //! \param theUpdateReferences causes the update of back-references
+  void synchronizeFeatures(const bool theMarkUpdated, const bool theUpdateReferences);
+  //! Synchronizes the BackReferences list in Data of Features and Results
+  void synchronizeBackRefs();
 
   //! Creates new document with binary file format
   Model_Document(const std::string theID, const std::string theKind);
@@ -174,11 +172,6 @@ class Model_Document : public ModelAPI_Document
   //! Updates the results list of the feature basing on the current data tree
   void updateResults(FeaturePtr theFeature);
 
-  //! Stores information that there is a reference to this object
-  void objectIsReferenced(const ObjectPtr& theObject);
-  //! Removes information that there is a reference to this object
-  void objectIsNotReferenced(const ObjectPtr& theObject);
-
   //! Returns all sub documents
   const std::set<std::string>& subDocuments() const {return mySubs;}
 
@@ -198,8 +191,6 @@ class Model_Document : public ModelAPI_Document
   /// All features managed by this document (not only in history of OB)
   /// For optimization mapped by labels
   NCollection_DataMap<TDF_Label, FeaturePtr> myObjs;
-  /// Results that are referenced and must be concealed for object browser
-  std::set<ResultPtr> myConcealedResults;
 
   ///< set of identifiers of sub-documents of this document
   std::set<std::string> mySubs;
index f5c8cb223d1d0438fc78fc0210628e840328add0..9b18bc0469d0bc5492d6e270d84aebd05c3012e9 100644 (file)
@@ -12,6 +12,7 @@
 
 Model_ResultBody::Model_ResultBody()
 {
+  setIsConcealed(false);
 }
 
 void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
@@ -19,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)
@@ -37,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 0b6d56612c64ffd89b2e735e8f45f67788a29f97..8af38252d8805c917b64bb5b34ace6b63ed55860 100644 (file)
@@ -17,6 +17,7 @@ boost::shared_ptr<GeomAPI_Shape>& Model_ResultConstruction::shape()
 Model_ResultConstruction::Model_ResultConstruction()
 {
   myIsInHistory = true;
+  setIsConcealed(false);
 }
 
 void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
index 98319c4749f33fc524bba9e5ee00662d21a87043..a1fb09b010ff87b8cbbc935e96201ebcbb7d1dfe 100644 (file)
@@ -19,6 +19,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
 
 Model_ResultPart::Model_ResultPart()
 {
+  setIsConcealed(false);
 }
 
 void Model_ResultPart::setData(boost::shared_ptr<ModelAPI_Data> theData)
index 6a3cf53cc0718af4ba104f2e7d19a3bfededcb95..37b020eeeec6be69126e17a0eefcf386887059f8 100644 (file)
@@ -191,7 +191,7 @@ boost::shared_ptr<ModelAPI_Document> Model_Session::copy(
   aRT->SetRelocation(aSourceRoot, aTargetRoot);
   TDF_CopyTool::Copy(aDS, aRT);
 
-  aNew->synchronizeFeatures();
+  aNew->synchronizeFeatures(false, true);
   return aNew;
 }
 
index 5ef4a8f098d65d9383f74425ca700e106a6c14df..ccdd45e77d1588a490b8edec85e784be4178a34c 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <Model_Update.h>
 #include <Model_Document.h>
+#include <Model_Data.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
@@ -137,67 +138,16 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
           aMustbeUpdated = true;
       }
     }
-
-    // references
-    list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = theFeature->data()->attributes(
-        ModelAPI_AttributeReference::type());
-    list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
-    for (; aRefsIter != aRefs.end(); aRefsIter++) {
-      boost::shared_ptr<ModelAPI_Object> aSub = boost::dynamic_pointer_cast<
-          ModelAPI_AttributeReference>(*aRefsIter)->value();
-      if (updateObject(aSub)) {
-        aMustbeUpdated = true;
-      }
-    }
-    // reference to attribute or object
-    list<boost::shared_ptr<ModelAPI_Attribute> > aRefAttrs = theFeature->data()->attributes(
-        ModelAPI_AttributeRefAttr::type());
-    for (aRefsIter = aRefAttrs.begin(); aRefsIter != aRefAttrs.end(); aRefsIter++) {
-      boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*aRefsIter);
-      if (!aRef) continue;
-      if (aRef->isObject()) {
-        boost::shared_ptr<ModelAPI_Object> aSub = aRef->object();
-        if (updateObject(aSub)) {
-          aMustbeUpdated = true;
-        }
-      } else if (aRef->attr()) { // reference to the attribute
-        boost::shared_ptr<ModelAPI_Object> aSub = aRef->attr()->owner();
-        if (updateObject(aSub)) {
-          aMustbeUpdated = true;
-        }
-      }
-    }
-    // lists of references
-    aRefs = theFeature->data()->attributes(ModelAPI_AttributeRefList::type());
-    for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
-      list<ObjectPtr> aListRef = boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)
-          ->list();
-      list<ObjectPtr>::iterator aListIter = aListRef.begin();
-      for (; aListIter != aListRef.end(); aListIter++) {
-        boost::shared_ptr<ModelAPI_Object> aSub = *aListIter;
-        if (updateObject(aSub)) {
-          aMustbeUpdated = true;
-        }
-      }
-    }
-    // selection attributes: must be called "update" methods if needed
-    aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
-    for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
-      boost::shared_ptr<ModelAPI_AttributeSelection> aSel =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
-      if (updateObject(aSel->context())) {
-        aMustbeUpdated = true;
-        // aSel->update(); // this must be done on execution since it may be long operation
-      }
-    }
-    // lists of selection attributes: must be called "update" methods if needed
-    aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::type());
-    for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
-      boost::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
-      for(int a = aSel->size() - 1; a >= 0; a--) {
-        if (updateObject(aSel->value(a)->context())) {
+    // check all references: if referenced objects are updated, this object also must be updated
+    std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
+    boost::shared_ptr<Model_Data> aData = 
+      boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+    aData->referencesToObjects(aRefs);
+    std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRef = aRefs.begin();
+    for(; aRef != aRefs.end(); aRef++) {
+      std::list<ObjectPtr>::iterator aRefObj = aRef->second.begin();
+      for(; aRefObj != aRef->second.end(); aRefObj++) {
+        if (updateObject(*aRefObj)) {
           aMustbeUpdated = true;
         }
       }
@@ -214,8 +164,10 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
             !theFeature->isPersistentResult() /* execute quick, not persistent results */) 
           {
             // before execution update the selection attributes if any
-            aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
-            for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+            list<AttributePtr> aRefs = 
+              theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+            list<AttributePtr>::iterator aRefsIter = aRefs.begin();
+            for (; aRefsIter != aRefs.end(); aRefsIter++) {
               boost::shared_ptr<ModelAPI_AttributeSelection> aSel =
                 boost::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
               aSel->update(); // this must be done on execution since it may be long operation
index 987db716ea98142151bf654ad24eda776f23bb18..d1adbbbe92d012f6cb37a6273a15b8354a0b8abd 100644 (file)
@@ -211,8 +211,7 @@ bool Model_ValidatorsFactory::validate(const boost::shared_ptr<ModelAPI_Feature>
   return true;
 }
 
-void Model_ValidatorsFactory::registerNotObligatory(
-  std::string theFeature, std::string theAttribute) 
+void Model_ValidatorsFactory::registerNotObligatory(std::string theFeature, std::string theAttribute)
 {
   std::map<std::string, ModelAPI_Validator*>::const_iterator it = myIDs.find(kDefaultId);
   if (it != myIDs.end()) {
@@ -222,3 +221,10 @@ void Model_ValidatorsFactory::registerNotObligatory(
     }
   }
 }
+
+void Model_ValidatorsFactory::registerConcealment(std::string theFeature, std::string theAttribute)
+{
+
+}
+
+
index 38d2d7bf5bca0b60b539bb4499000e0b7824c03c..cfaeb89c5ff1369c9cb184385cb82228b2869d50 100644 (file)
@@ -72,6 +72,10 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   /// so, it is not needed for the standard validation mechanism
   virtual void registerNotObligatory(std::string theFeature, std::string theAttribute);
 
+  /// register that this attribute conceals in the object browser
+  /// all referenced features after execution
+  virtual void registerConcealment(std::string theFeature, std::string theAttribute);
+
 protected:
   void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
   /// Get instance from Session
index 85c65cbd5fbab26156409800dcb267504ddff955..2acf4fc6bf2cc264c2123d1c2094aa2f11119c6a 100644 (file)
@@ -106,9 +106,6 @@ class MODELAPI_EXPORT ModelAPI_Data
   /// Returns true if feature must be updated (re-executed) on rebuild
   virtual bool mustBeUpdated() = 0;
 
-  /// Returns true if this data attributes are referenced to the given feature or its results
-  virtual bool referencesTo(const boost::shared_ptr<ModelAPI_Feature>& theFeature) = 0;
-
   /// Returns the identifier of feature-owner, unique in this document
   virtual int featureId() const = 0;
 
index 773ec389cf5a49b52cd8259c8374a5b28e8f6119..cdfa1d75ed89bb6661e2d7e30a239cfc3eab1a88 100644 (file)
@@ -81,9 +81,6 @@ public:
   virtual boost::shared_ptr<ModelAPI_Feature> feature(
       const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
 
-  ///! Reutrns true is result was conecaled because of usage it by other object
-  virtual bool isConcealed(const boost::shared_ptr<ModelAPI_Object>& theResult) = 0;
-
 protected:
   /// Only for SWIG wrapping it is here
   MODELAPI_EXPORT ModelAPI_Document()
index 7c539d7d52e84608445a9033a9d5e8afaa4ca491..f6e3c6c3228d6b34867361e7ab06a8060b3c06d5 100644 (file)
@@ -56,6 +56,7 @@ class ModelAPI_Object
 
   /// To use virtuality for destructors
   virtual ~ModelAPI_Object() {}
+
  protected:
   /// Sets the data manager of an object (document does)
   virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
index af9e7ce87edba6ae1b672dc98f7c7cffe056d77b..eb664ec221c92ccb1a0befd1b1a9a5ab3d035c76 100644 (file)
@@ -17,12 +17,19 @@ class ModelAPI_Feature;
  */
 class ModelAPI_Result : public ModelAPI_Object
 {
+  bool myIsConcealed; ///< the result is concealed from the data tree (referenced by other objects)
  public:
-  /// Returns the source feature of this result
-  //virtual boost::shared_ptr<ModelAPI_Feature> owner() = 0;
+   /// Returns true if the result is concealed from the data tree (referenced by other objects)
+  inline bool isConcealed() {return myIsConcealed;}
+
+  /// Returns true if the result is concealed from the data tree (referenced by other objects)
+  inline void setIsConcealed(const bool theValue) {myIsConcealed = theValue;}
+
+  /// To virtually destroy the fields of successors
+  virtual ~ModelAPI_Result()
+  {
+  }
 
-  /// Returns the group identifier of this result
-  //virtual std::string groupName() = 0;
 };
 
 //! Pointer on feature object
index bcd45b354aa721d90e17cd7b32121c47f21fb2b9..8942a62f207a10a6917389e718c386b721a1559e 100644 (file)
@@ -36,14 +36,18 @@ 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;
 
-  /// To virtually destroy the fields of successors
-  virtual ~ModelAPI_ResultBody()
-  {
-  }
-
   /// Records the subshape newShape which was generated during a topological construction.
   /// As an example, consider the case of a face generated in construction of a box.
   virtual void generated(
@@ -66,11 +70,6 @@ public:
     const boost::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
 
 protected:
-  /// Use plugin manager for features creation: this method is 
-  /// defined here only for SWIG-wrapping
-  ModelAPI_ResultBody()
-  {
-  }
 };
 
 //! Pointer on feature object
index ea47856f4afd2b34b2a70191c165443d2d8be3f0..940be4c4d1b879039859579c5bb2bcda33d697be 100644 (file)
@@ -83,6 +83,10 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory
   /// so, it is not needed for the standard validation mechanism
   virtual void registerNotObligatory(std::string theFeature, std::string theAttribute) = 0;
 
+  /// register that this attribute conceals in the object browser
+  /// all referenced features after execution
+  virtual void registerConcealment(std::string theFeature, std::string theAttribute) = 0;
+
  protected:
   /// Get instance from Session
   ModelAPI_ValidatorsFactory()
index e2b934ee6de130eff7fab5672b876f9a0daf21e6..5a6ba6e1eb5b8032feef6a283c3cc5e09b16c8c1 100644 (file)
@@ -26,7 +26,6 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_
       myParentId(theParentId)
 {
   myIsComputedDefault = false;
-  myIsObligatory = theData ? theData->getBooleanAttribute(FEATURE_OBLIGATORY, true) : true;
   myAttributeID = theData ? theData->widgetId() : "";
 }
 
@@ -39,9 +38,8 @@ void ModuleBase_ModelWidget::enableFocusProcessing()
 {
   QList<QWidget*> aMyControls = getControls();
   foreach(QWidget*  eachControl, aMyControls) {
-    if(!myFocusInWidgets.contains(eachControl)) {
-      enableFocusProcessing(eachControl);
-    }
+    eachControl->setFocusPolicy(Qt::StrongFocus);
+    eachControl->installEventFilter(this);
   }
 }
 
@@ -92,20 +90,15 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
 }
 
-void ModuleBase_ModelWidget::enableFocusProcessing(QWidget* theWidget)
-{
-  theWidget->setFocusPolicy(Qt::StrongFocus);
-  theWidget->installEventFilter(this);
-  myFocusInWidgets.append(theWidget);
-}
-
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 {
   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
-  if (theEvent->type() == QEvent::MouseButtonRelease && 
-      myFocusInWidgets.contains(aWidget)) {
-    emit focusInWidget(this);
+  if (theEvent->type() == QEvent::FocusIn) {
+    if (getControls().contains(aWidget)) {
+      emit focusInWidget(this);
+    }
   } 
   // pass the event on to the parent class
+
   return QObject::eventFilter(theObject, theEvent);
 }
index 9f2f6f4555698d9c6b0dc6de3eea83087baa749a..25c0bf2469a3d34fc077546ae0ce56ec108a5b88 100644 (file)
@@ -48,10 +48,6 @@ Q_OBJECT
   /// on operation's execute, like radius for circle's constraint (can not be zero)
   bool isComputedDefault() { return myIsComputedDefault; }
 
-  /// Returns false for non-obligatory widgets which are
-  /// valid even if they are not initialized
-  bool isObligatory() { return myIsObligatory; }
-
   /// Defines if it is supposed that the widget should interact with the viewer.
   virtual bool isViewerSelector() { return false; }
 
@@ -139,22 +135,13 @@ signals:
 
   void updateObject(ObjectPtr theObj) const;
 
- private:
-  /// Let the widget process FocusIn events
-  void enableFocusProcessing(QWidget* theWidget);
-
  protected:
   std::string myAttributeID; /// the attribute name of the model feature
   std::string myParentId;    /// name of parent
   FeaturePtr myFeature;
 
   bool myIsComputedDefault; /// Value should be computed on execute,
-  /// like radius for circle's constraint (can not be zero)
-  bool myIsObligatory;      /// Non-obligatory widget is valid even if it is not initialized
-
- private:
-   /// Contains a list of widgets that may accept focus
-   QList<QWidget*> myFocusInWidgets;
+                            /// like radius for circle's constraint (can not be zero)
 };
 
 #endif
index 19876df75612ffd5f5b1d2ee36c8a92ed17e45c8..36bc9f6f3cc2fca75a21fcc5bc9911a018728a66 100644 (file)
@@ -187,8 +187,8 @@ void ModuleBase_Operation::start()
 void ModuleBase_Operation::resume()
 {
   if (myPropertyPanel)
-    connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
-            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+    connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+            this,            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
   emit resumed();
 }
 
index c8eea52c22e4155eaab79d4322e32f145c23351d..b039e9bfd34ee9223d29f27acbf8d207968f362c 100644 (file)
@@ -5,7 +5,7 @@
 #include "ModuleBase_ResultPrs.h"
 
 #include <ModelAPI_Tools.h>
-#include <GeomAPI_Wire.h>
+#include <GeomAPI_PlanarEdges.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
 
 #include <BRep_Builder.hxx>
@@ -20,8 +20,8 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   : AIS_Shape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
 {
   boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
-  boost::shared_ptr<GeomAPI_Wire> aWirePtr = 
-    boost::dynamic_pointer_cast<GeomAPI_Wire>(aShapePtr);
+  boost::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
+    boost::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
   if (aWirePtr) {
     if (aWirePtr->hasPlane() ) {
       // If this is a wire with plane defined thin it is a sketch-like object
index 057c4d5d3b19d3aff33415718fd537ae24d826e8..cbe7503a8e7a43833324fc3c275308d389ebf3db 100644 (file)
@@ -71,7 +71,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
     //Create a widget (doublevalue, groupbox, toolbox, etc.
     QWidget* aWidget = createWidgetByType(aWdgType, theParent);
     if (aWidget) {
-      if (!myWidgetApi->getBooleanAttribute(FEATURE_INTERNAL, false)) {
+      if (!myWidgetApi->getBooleanAttribute(ATTRIBUTE_INTERNAL, false)) {
         aWidgetLay->addWidget(aWidget);
       } else {
         aWidget->setVisible(false);
@@ -121,6 +121,25 @@ QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
   return result;
 }
 
+void ModuleBase_WidgetFactory::processAttributes()
+{
+  // register that this attribute in feature is not obligatory for the feature execution
+  // so, it is not needed for the standard validation mechanism
+  bool isObligatory = true;
+  bool isConcealment = false;
+  if( myWidgetApi ){
+    isObligatory = myWidgetApi->getBooleanAttribute(ATTRIBUTE_OBLIGATORY, true);
+    isConcealment = myWidgetApi->getBooleanAttribute(ATTRIBUTE_CONCEALMENT, false);
+  }
+  boost::shared_ptr<ModelAPI_Session> aSession = ModelAPI_Session::get();
+  if (!isObligatory) {
+    aSession->validators()->registerNotObligatory(myParentId, myWidgetApi->widgetId());
+  }
+  if(isConcealment) {
+    aSession->validators()->registerConcealment(myParentId, myWidgetApi->widgetId());
+  }
+}
+
 QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
                                                       QWidget* theParent)
 {
@@ -174,14 +193,7 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
 #endif
   }
   if (result) {
-    // register that this attribute in feature is not obligatory for the feature execution
-    // so, it is not needed for the standard validation mechanism
-    bool isObligatory = 
-      myWidgetApi ? myWidgetApi->getBooleanAttribute(FEATURE_OBLIGATORY, true) : true;
-    if (!isObligatory) {
-      ModelAPI_Session::get()->validators()->registerNotObligatory(
-        myParentId, myWidgetApi->widgetId());
-    }
+    processAttributes();
   }
 
   return result;
index fd267d41801bd144d92aa5841b20f71ece86af69..43b8208b6596d3912f436ea914ded46e337e8ab5 100644 (file)
@@ -53,6 +53,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
 
 
   QString qs(const std::string& theStdString) const;
+  void processAttributes();
 
  private:
   Config_WidgetAPI* myWidgetApi;
index 47045007066d2890123230111f8352465ea8efc1..d7518ef6098d73f87483810815450ddebb11fba7 100644 (file)
@@ -46,8 +46,7 @@
 #include <boost/smart_ptr/shared_ptr.hpp>
 
 #include <list>
-#include <stdexcept>
-#include <xstring>
+#include <string>
 
 typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
 static ShapeTypes MyShapeTypes;
@@ -227,7 +226,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, boost::shared_p
     if (!myUseSubShapes) {
       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
       ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
-      Events_Loop::loop()->flush(anEvent);
     }
   } 
   updateSelectionName();
index 9c98058604b8920cdbbb412820ecefd43d5b126c..7be21c613875411547a41c30fd7bcded3f536c6f 100644 (file)
 
 #include <V3d_View.hxx>
 
+#include <QMouseEvent>
 #ifdef _DEBUG
 #include <QDebug>
 #endif
 
-#include <QMouseEvent>
-
-using namespace std;
+//using namespace std;
 
 PartSet_OperationFeatureEditMulti::PartSet_OperationFeatureEditMulti(const QString& theId,
                                                                      QObject* theParent,
@@ -80,17 +79,16 @@ void PartSet_OperationFeatureEditMulti::initSelection(
   //} else
   myFeatures = theSelected;
   // add highlighted elements if they are not selected
-  std::list<ModuleBase_ViewerPrs>::const_iterator anIt;
-  for (anIt = theHighlighted.cbegin(); anIt != theHighlighted.cend(); ++anIt) {
+  std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theHighlighted.cbegin();
+  for ( ; anIt != theHighlighted.cend(); ++anIt) {
     if (!isContains(myFeatures, (*anIt)))
       myFeatures.push_back(*anIt);
   }
   // Remove current feature if it is in the list (it will be moved as main feature)
-  FeaturePtr aFea = feature();
-  for (anIt = myFeatures.cbegin(); anIt != myFeatures.cend(); ++anIt) {
-    FeaturePtr aF = ModelAPI_Feature::feature((*anIt).object());
-    if (ModelAPI_Feature::feature((*anIt).object()) == feature()) {
-      myFeatures.erase(anIt);
+  std::list<ModuleBase_ViewerPrs>::iterator anEraseIt = myFeatures.begin();
+  for ( ; anEraseIt != myFeatures.end(); ++anEraseIt) {
+    if (ModelAPI_Feature::feature((*anEraseIt).object()) == feature()) {
+      myFeatures.erase(anEraseIt);
       break;
     }
   }
index 44de5817bc6325261866f36df5e15fde4ab8a24f..1008f3deb34b39173b6bb64b1da76675fe8ae9ea 100644 (file)
@@ -10,6 +10,8 @@
 #include <PartSet_OperationSketchBase.h>
 #include <QObject>
 
+#include <list>
+
 class QMouseEvent;
 
 /*!
index d0ebbbf8e0957c752c1cfb19c5ceafe627efc57f..a66bd9ffb1b6a3040a79c005147862739e5db233 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <GeomAPI_AISObject.h>
 #include <GeomAPI_Dir.h>
-#include <GeomAPI_Wire.h>
+#include <GeomAPI_PlanarEdges.h>
 #include <GeomAPI_XYZ.h>
 
 #include <GeomDataAPI_Dir.h>
@@ -88,7 +88,7 @@ void SketchPlugin_Sketch::execute()
     return;
 
   // Collect all edges as one big wire
-  boost::shared_ptr<GeomAPI_Wire> aBigWire(new GeomAPI_Wire);
+  boost::shared_ptr<GeomAPI_PlanarEdges> aBigWire(new GeomAPI_PlanarEdges);
   std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator aShapeIt = aFeaturesPreview.begin();
   for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
     aBigWire->addEdge(*aShapeIt);
index 8f7b3059a79fadf2d4ca40cf26d94373ed49a1a1..4d91ceb34f95f03fff27d739069b10f19ec2c060 100644 (file)
@@ -270,11 +270,12 @@ void XGUI_PreferencesDlg::modified(XGUI_Prefs& theModified) const
 void XGUI_PreferencesDlg::onDefault()
 {
   // reset main resources
-  QtxResourceMgr::WorkingMode aPrev = myPreferences->resourceMgr()->setWorkingMode
-                                               (QtxResourceMgr::IgnoreUserValues);
+#ifdef WIN32
+  QtxResourceMgr::WorkingMode aPrev =
+      myPreferences->resourceMgr()->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
   myPreferences->retrieve();
   myPreferences->resourceMgr()->setWorkingMode(aPrev);
-
+#endif
   // reset plugin's resources
   XGUI_Preferences::resetConfig();
   XGUI_Preferences::updateResourcesByConfig();
index 93a35bdc99599051253912b42ee3b206a441962c..9f6a706cfb418d9c8b7d368440be2e1d8b3cc487 100644 (file)
@@ -23,7 +23,8 @@
 #endif
 
 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
-    : ModuleBase_IPropertyPanel(theParent), myActiveWidget(0)
+    : ModuleBase_IPropertyPanel(theParent), 
+    myActiveWidget(NULL)
 {
   this->setWindowTitle(tr("Property Panel"));
   QAction* aViewAct = this->toggleViewAction();
@@ -71,6 +72,7 @@ void XGUI_PropertyPanel::cleanContent()
 {
   myWidgets.clear();
   qDeleteAll(myCustomWidget->children());
+  myActiveWidget = NULL;
 }
 
 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
@@ -87,7 +89,7 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
     connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
             SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
-            this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
+            this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
 
     ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
     if (aPointWidget)
@@ -121,20 +123,17 @@ QWidget* XGUI_PropertyPanel::contentWidget()
 
 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
 {
-  int aS = myWidgets.size();
   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets)
   {
     eachWidget->setFeature(theFeature);
     eachWidget->restoreValue();
   }
-  // the repaint is used here to immediatelly react in GUI to the values change.
+  // the repaint is used here to immediately react in GUI to the values change.
   repaint();
 }
 
-
 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
 {
-  QObject* aSender = sender();
   ModuleBase_ModelWidget* aNextWidget = 0;
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
   bool isFoundWidget = false;
@@ -146,8 +145,11 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
     }
     isFoundWidget = (*anIt) == theWidget;
   }
-  myActiveWidget = aNextWidget;
-  emit widgetActivated(myActiveWidget);
+  // Normaly focusTo is enough to activate widget
+  // here is a special case on mouse click in the viewer
+  if(aNextWidget == NULL) {
+    activateWidget(NULL);
+  }
 }
 
 void XGUI_PropertyPanel::activateNextWidget()
@@ -160,3 +162,15 @@ void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled)
   QPushButton* anOkBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
   anOkBtn->setEnabled(isEnabled);
 }
+
+void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
+{
+  if(myActiveWidget) {
+    myActiveWidget->setHighlighted(false);
+  }
+  if(theWidget) {
+    theWidget->setHighlighted(true);
+  }
+  myActiveWidget = theWidget;
+  emit widgetActivated(theWidget);
+}
index b29d51579e9c1a238a8bfc365baae90eb11343e0..ebd529d11056c439f61df3f0353d807501862ea7 100644 (file)
@@ -51,12 +51,19 @@ Q_OBJECT
   // Enables / disables "ok" ("accept") button
   void setAcceptEnabled(bool);
 
-signals:
+ protected slots:
+  // Makes the given widget active, highlights it and removes
+  // highlighting from the previous active widget
+  // emits widgetActivated(theWidget) signal
+  void activateWidget(ModuleBase_ModelWidget* theWidget);
+
+ signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
   void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
+
  private:
   QWidget* myCustomWidget;
   QList<ModuleBase_ModelWidget*> myWidgets;
index 8ca4729a3f373e5765c1b5a69a41dba3a796862b..8a60b2e4a264fe0e42a24eba2018206e49b194f3 100644 (file)
@@ -419,7 +419,12 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_Objec
   QIntList aModes;
   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
     ObjectPtr aObj = (*aIt);
-    if (!aObj->data() || !aObj->data()->isValid() || aObj->document()->isConcealed(aObj))
+    bool aHide = !aObj->data() || !aObj->data()->isValid();
+    if (!aHide) { // check that this is not hidden result
+      ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+      aHide = aRes && aRes->isConcealed();
+    }
+    if (aHide)
       myDisplayer->erase(aObj, false);
     else {
       if (myDisplayer->isVisible(aObj))  {
@@ -463,8 +468,7 @@ void XGUI_Workshop::onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectU
       // it doesn't stored in the operation mgr and doesn't displayed
     } else if (myOperationMgr->hasOperation()) {
       ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-      if (!(*aIt)->document()->isConcealed(*aIt) &&
-          aOperation->hasObject(*aIt)) {  // Display only current operation results
+      if (aOperation->hasObject(*aIt)) {  // Display only current operation results
         myDisplayer->display(*aIt, false);
         isDisplayed = true;
       }
@@ -1011,10 +1015,6 @@ void XGUI_Workshop::createDockWidgets()
   connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
           SLOT(onKeyReleased(QKeyEvent*)));
-  //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
-  //        SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
-  //connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
-  //        SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
   connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
           SLOT(setAcceptEnabled(bool)));