../ModelAPI
../GeomAPI
../GeomAlgoAPI
+ ../Events
)
SET(PROJECT_LIBRARIES
+ Events
ModelAPI
GeomAPI
GeomAlgoAPI
- ${CAS_KERNEL}
- ${CAS_SHAPE}
)
ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeBoolean.h>
-
+#include <Events_Error.h>
#include <GeomAlgoAPI_Extrusion.h>
using namespace std;
+#define _LATERAL_TAG 1
+#define _FIRST_TAG 2
+#define _LAST_TAG 3
+#ifdef _DEBUG
+#include <iostream>
+#include <ostream>
+#endif
FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
{
void FeaturesPlugin_Extrusion::execute()
{
boost::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
+ ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
if (!aFaceRef)
return;
+
boost::shared_ptr<GeomAPI_Shape> aFace =
boost::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->value());
if (!aFace)
return;
+ boost::shared_ptr<GeomAPI_Shape> aContext;
+ ResultPtr aContextRes = aFaceRef->context();
+ if (aContextRes) {
+ if (aContextRes->groupName() == ModelAPI_ResultBody::group())
+ aContext = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
+ else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group())
+ aContext = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
+ }
+ if (!aContext) {
+ std::string aContextError = "The selection context is bad";
+ Events_Error::send(aContextError, this);
+ return;
+ }
+
double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
aSize = -aSize;
- boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
- aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
- setResult(aResult);
+ boost::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
+ //TCollection_AsciiString anError;
+ GeomAlgoAPI_Extrusion aFeature(aFace, aSize);
+ if(!aFeature.isDone()) {
+ std::string aFeatureError = "Extrusion algorithm failed";
+ Events_Error::send(aFeatureError, this);
+ return;
+ }
+
+ // Check if shape is valid
+ if (aFeature.shape()->isNull()) {
+ std::string aShapeError = "Resulting shape is Null";
+ Events_Error::send(aShapeError, this);
+#ifdef _DEBUG
+ std::cerr << aShapeError << std::endl;
+#endif
+ return;
+ }
+ if(!aFeature.isValid()) {
+ std::string aFeatureError = "Warning: resulting shape is not valid";
+ Events_Error::send(aFeatureError, this);
+ return;
+ }
+ //LoadNamingDS
+ LoadNamingDS(aFeature, aResultBody, aFace, aContext);
+
+ setResult(aResultBody);
+}
+
+//============================================================================
+void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature,
+ boost::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ boost::shared_ptr<GeomAPI_Shape> theBasis,
+ boost::shared_ptr<GeomAPI_Shape> theContext)
+{
+
+
+ //load result
+ if(theBasis->isEqual(theContext))
+ theResultBody->store(theFeature.shape());
+ else
+ theResultBody->storeGenerated(theContext, theFeature.shape());
+ /*
+ TopTools_DataMapOfShapeShape aSubShapes;
+ for (TopExp_Explorer Exp(theFeature.shape()->impl<TopoDS_Shape>(),TopAbs_FACE); Exp.More(); Exp.Next()) {
+ aSubShapes.Bind(Exp.Current(),Exp.Current());
+ }
+
+ //Insert lateral face : Face from Edge
+ //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
+
+
+ TopTools_MapOfShape aView;
+ TopExp_Explorer aShapeExplorer (theFeature.shape()->impl<TopoDS_Shape>(), TopAbs_EDGE);
+ for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+ const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
+ if (!aView.Add(aRoot)) continue;
+ boost::shared_ptr<GeomAPI_Shape> aRootG(new GeomAPI_Shape());
+ aRootG->setImpl((void *)&aRoot);
+ const ListOfShape& aShapes = theFeature.generated(aRootG);
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();
+ for (; anIt != aLast; anIt++) {
+ TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
+ if (aSubShapes.IsBound(aNewShape)) {
+ aNewShape.Orientation((aSubShapes(aNewShape)).Orientation());
+ }
+
+ if (!aRoot.IsSame (aNewShape)) {
+ boost::shared_ptr<GeomAPI_Shape> aNew(new GeomAPI_Shape());
+ aNew->setImpl((void *)&aNewShape);
+ theResultBody->generated(aRootG, aNew,_LATERAL_TAG);
+ }
+ }
+ }
+ //Insert bottom face
+ const boost::shared_ptr<GeomAPI_Shape>& aBottomFace = theFeature.firstShape();
+ if (!aBottomFace->isNull()) {
+ if (aSubShapes.IsBound(aBottomFace->impl<TopoDS_Shape>())) {
+ aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl<TopoDS_Shape>()));
+ }
+ theResultBody->generated(aBottomFace, _FIRST_TAG);
+ }
+
+
+
+ //Insert top face
+ boost::shared_ptr<GeomAPI_Shape> aTopFace = theFeature.lastShape();
+ if (!aTopFace->isNull()) {
+ if (aSubShapes.IsBound(aTopFace->impl<TopoDS_Shape>())) {
+ aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl<TopoDS_Shape>()));
+ }
+ theResultBody->generated(aTopFace, _FIRST_TAG);
+ }
+ */
+
}
#include "FeaturesPlugin.h"
#include <ModelAPI_Feature.h>
-
+#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_Extrusion.h>
class FeaturesPlugin_Extrusion : public ModelAPI_Feature
{
public:
/// 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
icon=":icons/cut_shape.png"
tooltip="Select an object to cut"
shape_types="solid shell"
+ concealment="true"
/>
<shape_selector id="tool_object"
label="Tool object"
icon=":icons/cut_tool.png"
tooltip="Select a tool"
shape_types="solid"
+ concealment="true"
/>
<choice id="bool_type"
label="Type"
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"/>
#include <GeomAPI_Interface.h>
#include <boost/shared_ptr.hpp>
+#include <list>
/**\class GeomAPI_Shape
* \ingroup DataModel
};
+//! 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;
GeomAlgoAPI_SketchBuilder.h
GeomAlgoAPI_Extrusion.h
GeomAlgoAPI_Boolean.h
+ GeomAlgoAPI_MakeShape.h
+ GeomAlgoAPI_DFLoader.h
)
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})
INCLUDE_DIRECTORIES(
../GeomAPI
+ ../ModelAPI
${CAS_INCLUDE_DIRS}
)
--- /dev/null
+// 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
--- /dev/null
+// 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
// Author: Artem ZHIDKOV
#include <GeomAlgoAPI_Extrusion.h>
-
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_DFLoader.h>
#include <gp_Pln.hxx>
-
#include <BRepPrimAPI_MakePrism.hxx>
+#include <BRepBuilderAPI_MakeShape.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <TopExp_Explorer.hxx>
-#include <BRep_Builder.hxx>
-
+#include <BRepCheck_Analyzer.hxx>
+#include <GProp_GProps.hxx>
+#include <BRepGProp.hxx>
+#include <TopoDS.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <Precision.hxx>
+#include <TDF_TagSource.hxx>
+#include <boost/shared_ptr.hpp>
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <TopoDS_Shape.hxx>
+
const double tolerance = Precision::Angular();
+// Constructor
+GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion(
+ boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize)
+: mySize(theSize), myDone(false),
+ myShape(new GeomAPI_Shape()), myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape())
+{
+ build(theBasis);
+}
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
- boost::shared_ptr<GeomAPI_Shape> theShape, boost::shared_ptr<GeomAPI_Dir> theDir,
- double theSize)
+//============================================================================
+void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr<GeomAPI_Shape>& theBasis)
{
- const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
- gp_Vec aDir(theDir->impl<gp_Dir>().XYZ() * theSize);
+ bool isFirstNorm = true;
+ gp_Dir aShapeNormal;
- TopoDS_Shape aPrism = BRepPrimAPI_MakePrism(aShape, aDir);
- if (aPrism.IsNull())
- return boost::shared_ptr<GeomAPI_Shape>();
+ //const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Face aBasis = TopoDS::Face(theBasis->impl<TopoDS_Shape>());
+ Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(
+ BRep_Tool::Surface(aBasis));
+ if (aPlane.IsNull()) // non-planar shapes is not supported for extrusion yet
+ return;
- boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
- aResult->setImpl(new TopoDS_Shape(aPrism));
- return aResult;
+ const gp_Dir& aNormal = aPlane->Pln().Axis().Direction();
+ gp_Vec aVec(aNormal);
+ aVec = aVec * mySize;
+
+ BRepPrimAPI_MakePrism* aBuilder = new BRepPrimAPI_MakePrism(aBasis, aVec);
+ if(aBuilder) {
+ setImpl(aBuilder);
+ myDone = aBuilder->IsDone() == Standard_True;
+ if (myDone) {
+ BRepCheck_Analyzer aChecker(aBuilder->Shape());
+ myDone = aChecker.IsValid() == Standard_True;
+ }
+ if(myDone) {
+ TopoDS_Shape aResult;
+ if(aBuilder->Shape().ShapeType() == TopAbs_COMPOUND)
+ aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape());
+ else
+ aResult = aBuilder->Shape();
+ myShape->setImpl(new TopoDS_Shape(aResult));
+ myFirst->setImpl(new TopoDS_Shape(aBuilder->FirstShape()));
+ myLast->setImpl(new TopoDS_Shape(aBuilder-> LastShape()));
+ }
+ }
}
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
- boost::shared_ptr<GeomAPI_Shape> theShape, double theSize)
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::isDone() const
+{return myDone;}
+
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::isValid() const
{
- bool isFirstNorm = true;
- gp_Dir aShapeNormal;
+ return myDone;
+}
- const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
- TopExp_Explorer aFaceExp(aShape, TopAbs_FACE);
- TopoDS_Compound aFaces; // use only faces from the shape: make compound for this
- BRep_Builder aBuilder;
- aBuilder.MakeCompound(aFaces);
- for (; aFaceExp.More(); aFaceExp.Next()) {
- const TopoDS_Face& aFace = (const TopoDS_Face&) aFaceExp.Current();
- Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace));
- if (aPlane.IsNull()) // non-planar shapes is not supported for extrusion yet
- continue;
-
- const gp_Dir& aNormal = aPlane->Pln().Axis().Direction();
- if (isFirstNorm) {
- aShapeNormal = aNormal;
- isFirstNorm = false;
- } else if (!aShapeNormal.IsEqual(aNormal, tolerance)) // non-planar shapes is not supported for extrusion yet
- return boost::shared_ptr<GeomAPI_Shape>();
- aBuilder.Add(aFaces, aFace);
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::hasVolume() const
+{
+ bool hasVolume(false);
+ if(isValid()) {
+ const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
+ GProp_GProps aGProp;
+ BRepGProp::VolumeProperties(aRShape, aGProp);
+ if(aGProp.Mass() > Precision::Confusion())
+ hasVolume = true;
}
- if (aFaces.IsNull())
- return boost::shared_ptr<GeomAPI_Shape>();
+ return hasVolume;
+}
- boost::shared_ptr<GeomAPI_Dir> aDir(
- new GeomAPI_Dir(aShapeNormal.X(), aShapeNormal.Y(), aShapeNormal.Z()));
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::shape () const
+{return myShape;}
- boost::shared_ptr<GeomAPI_Shape> aFacesShape(new (GeomAPI_Shape));
- aFacesShape->setImpl(new TopoDS_Shape(aFaces));
- return GeomAlgoAPI_Extrusion::makeExtrusion(aFacesShape, aDir, theSize);
+//============================================================================
+void GeomAlgoAPI_Extrusion::generated(
+ const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+ theHistory.clear();
+ if(myDone) {
+ const TopTools_ListOfShape& aList = implPtr<BRepPrimAPI_MakePrism>()
+ ->Generated(theShape->impl<TopoDS_Shape>());
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for(;it.More();it.Next()) {
+ boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(&(it.Value()));
+ theHistory.push_back(aShape);
+ }
+ }
+}
+
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::firstShape()
+{
+ return myFirst;
+}
+
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::lastShape()
+{
+ return myLast;
+}
+
+//============================================================================
+/*
+void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr<ModelAPI_ResultBody> theResultBody,
+boost::shared_ptr<GeomAPI_Shape> theContext)
+{
+if(isValid()) {
+const TopoDS_Shape& aShape = myBuilder->Shape();
+TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aShape);
+boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResultBody->data());
+if (aData) {
+const TDF_Label& aShapeLab = aData->shapeLab();
+const Handle(TDF_TagSource)& Tagger = TDF_TagSource::Set(aShapeLab);
+if (Tagger.IsNull()) return;
+Tagger->Set(0);
+
+TNaming_Builder aBuilder (aShapeLab);
+if(myBasis.IsEqual(theContext->impl<TopoDS_Shape>()))
+aBuilder.Generated(aResult);
+else
+aBuilder.Generated(theContext->impl<TopoDS_Shape>(), aResult);
+
+TopTools_DataMapOfShapeShape aSubShapes;
+for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
+aSubShapes.Bind(Exp.Current(),Exp.Current());
+}
+
+//Insert lateral face : Face from Edge
+TNaming_Builder aLateralFaceBuilder(aShapeLab.NewChild());
+GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
+
+//Insert bottom face
+TopoDS_Shape aBottomFace = myBuilder->FirstShape();
+if (!aBottomFace.IsNull()) {
+if (aBottomFace.ShapeType() != TopAbs_COMPOUND) {
+TNaming_Builder aBottomBuilder(aShapeLab.NewChild()); //2
+if (aSubShapes.IsBound(aBottomFace)) {
+aBottomFace = aSubShapes(aBottomFace);
+}
+aBottomBuilder.Generated(aBottomFace);
+} else {
+TopoDS_Iterator itr(aBottomFace);
+for (; itr.More(); itr.Next()) {
+TNaming_Builder aBottomBuilder(aShapeLab.NewChild());
+aBottomBuilder.Generated(itr.Value());
+}
+}
+
+}
+
+//Insert top face
+TopoDS_Shape aTopFace = myBuilder->LastShape();
+if (!aTopFace.IsNull()) {
+if (aTopFace.ShapeType() != TopAbs_COMPOUND) {
+TNaming_Builder aTopBuilder(aShapeLab.NewChild()); //3
+if (aSubShapes.IsBound(aTopFace)) {
+aTopFace = aSubShapes(aTopFace);
+}
+aTopBuilder.Generated(aTopFace);
+} else {
+TopoDS_Iterator itr(aTopFace);
+for (; itr.More(); itr.Next()) {
+TNaming_Builder aTopBuilder(aShapeLab.NewChild());
+aTopBuilder.Generated(itr.Value());
+}
+}
+}
+}
}
+*/
\ No newline at end of file
// 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_
#include <GeomAlgoAPI.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_Dir.h>
+#include <ModelAPI_ResultBody.h>
#include <boost/shared_ptr.hpp>
-
/**\class GeomAlgoAPI_Extrusion
* \ingroup DataAlgo
* \brief Allows to create the prism based on a given face and a direction
*/
-class GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion
+class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
{
public:
- /* \brief Creates extrusion for the given shape
- * \param[in] theShape face or wire to be extruded
- * \param[in] theDir direction of extrusion
- * \param[in] theSize the length of extrusion (if the value is less than 0, the extrusion in opposite direction)
- * \return a solid or a face which is obtained from specified one
- */
- static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<GeomAPI_Shape> theShape,
- boost::shared_ptr<GeomAPI_Dir> theDir,
- double theSize);
/* \brief Creates extrusion for the given shape along the normal for this shape
* \param[in] theShape face or wire to be extruded
* \param[in] theSize the length of extrusion (if the value is less than 0, the extrusion in opposite normal)
* \return a solid or a face which is obtained from specified one
- */
- static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<GeomAPI_Shape> theShape,
- double theSize);
+
+ static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<ModelAPI_ResultBody> theResult,
+ boost::shared_ptr<GeomAPI_Shape> theBasis,
+ boost::shared_ptr<GeomAPI_Shape> theContext,
+ double theSize); */
+ /// Constructor
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize);
+
+ /// Returns True if algorithm succeed
+ GEOMALGOAPI_EXPORT const bool isDone() const;
+
+ /// Returns True if resulting shape is valid
+ GEOMALGOAPI_EXPORT const bool isValid() const;
+
+ /// Returns True if resulting shape has volume
+ GEOMALGOAPI_EXPORT const bool hasVolume() const;
+
+ /// Returns result of the Extrusion algorithm which may be a Solid or a Face
+ GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& shape () const;
+
+ /// Returns list of shapes generated from theShape
+ GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
+ ListOfShape& theHistory);
+
+ /// Returns the first shape
+ GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& firstShape();
+
+ /// returns last shape
+ GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();
+
+private:
+ /// builds resulting shape
+ void build(const boost::shared_ptr<GeomAPI_Shape>& theBasis);
+
+ double mySize;
+ bool myDone;
+ boost::shared_ptr<GeomAPI_Shape> myShape;
+ boost::shared_ptr<GeomAPI_Shape> myFirst;
+ boost::shared_ptr<GeomAPI_Shape> myLast;
};
#endif
--- /dev/null
+// File: GeomAlgoAPI_MakeShape.cpp
+// Created: 20 Oct 2014
+// Author: Sergey ZARITCHNY
+
+#include <GeomAlgoAPI_MakeShape.h>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
+ : GeomAPI_Interface(theMkShape)
+{}
+
+const boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
+{
+ return myShape;
+}
+
+/// Returns the list of shapes generated from the shape <theShape>
+void GeomAlgoAPI_MakeShape::generated(
+ const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+ BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+ if(aBuilder) {
+ const TopTools_ListOfShape& aList = aBuilder->Generated(theShape->impl<TopoDS_Shape>());
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for(;it.More();it.Next()) {
+ boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(&(it.Value()));
+ theHistory.push_back(aShape);
+ }
+ }
+}
+
+/// Returns the list of shapes modified from the shape <theShape>
+void GeomAlgoAPI_MakeShape::modified(
+ const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+ BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+ if(aBuilder) {
+ const TopTools_ListOfShape& aList = aBuilder->Modified(theShape->impl<TopoDS_Shape>());
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for(;it.More();it.Next()) {
+ boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(&(it.Value()));
+ theHistory.push_back(aShape);
+ }
+ }
+}
+
+/// Returns whether the shape is an edge
+bool GeomAlgoAPI_MakeShape::isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+ bool isDeleted(false);
+ BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+ if(aBuilder) {
+ isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+ }
+ return isDeleted;
+}
--- /dev/null
+// File: GeomAlgoAPI_MakeShape.h
+// Created: 17 Oct 2014
+// Author: Sergey ZARITCHNY
+#ifndef GeomAlgoAPI_MakeShape_H_
+#define GeomAlgoAPI_MakeShape_H_
+
+#include <GeomAPI_Shape.h>
+#include <boost/shared_ptr.hpp>
+#include <GeomAlgoAPI.h>
+#include <BRepBuilderAPI_MakeShape.hxx>
+/**\class GeomAlgoAPI_MakeShape
+ * \ingroup DataModel
+ * \Interface to the root class of all topological shapes constructions
+ */
+class GeomAlgoAPI_MakeShape : GeomAPI_Interface
+{
+ public:
+ /// Constructor
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder);
+ /// Returns a shape built by the shape construction algorithm
+ GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape> shape() const;
+
+ /// Returns the list of shapes generated from the shape <theShape>
+ GEOMALGOAPI_EXPORT virtual void generated(
+ const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
+
+ /// Returns the list of shapes modified from the shape <theShape>
+ GEOMALGOAPI_EXPORT virtual void modified(
+ const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
+
+ /// Returns whether the shape is an edge
+ GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
+
+ protected:
+ boost::shared_ptr<GeomAPI_Shape> myShape;
+};
+
+#endif
}
}
}
- if (aNewSelected) { // store this new selection
- selectConstruction(aContext, aNewSelected);
- return true;
- }
+ }
+ if (aNewSelected) { // store this new selection
+ selectConstruction(aContext, aNewSelected);
+ return true;
}
}
}
#include <Model_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_Validator.h>
#include <GeomData_Point.h>
#include <GeomData_Point2D.h>
return myLab.Father().Tag(); // tag of the feature label
}
+void Model_Data::eraseBackReferences()
+{
+ myRefsToMe.clear();
+ boost::shared_ptr<ModelAPI_Result> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ if (aRes)
+ aRes->setIsConcealed(false);
+}
+
void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID)
{
- // TODO: the concealment state update
myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
+ if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
+ boost::shared_ptr<ModelAPI_Result> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ if (aRes) {
+ aRes->setIsConcealed(true);
+ }
+ }
}
void Model_Data::referencesToObjects(
private:
// removes all information about back references
- inline void eraseBackReferences() {myRefsToMe.clear();}
+ void eraseBackReferences();
// adds a back reference (with identifier which attribute references to this object
void addBackReference(FeaturePtr theFeature, std::string theAttrID);
// returns all objects referenced to this
myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand(); // && (myNestedNum == -1);
myTransactionsAfterSave++;
}
-
}
void Model_Document::abortOperation()
void Model_Document::synchronizeBackRefs()
{
+ boost::shared_ptr<ModelAPI_Document> aThis =
+ Model_Application::getApplication()->getDocument(myID);
+ // keeps the concealed flags of result to catch the change and create created/deleted events
+ std::list<std::pair<ResultPtr, bool> > aConcealed;
// first cycle: erase all data about back-references
NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFeatures(myObjs);
for(; aFeatures.More(); aFeatures.Next()) {
boost::shared_ptr<Model_Data> aResData =
boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
if (aResData) {
+ aConcealed.push_back(std::pair<ResultPtr, bool>(*aRIter, (*aRIter)->isConcealed()));
aResData->eraseBackReferences();
}
}
}
}
}
+ std::list<std::pair<ResultPtr, bool> >::iterator aCIter = aConcealed.begin();
+ for(; aCIter != aConcealed.end(); aCIter++) {
+ if (aCIter->first->isConcealed() != aCIter->second) { // somethign is changed => produce event
+ if (aCIter->second) { // was concealed become not => creation event
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+ ModelAPI_EventCreator::get()->sendUpdated(aCIter->first, anEvent);
+ } else { // was not concealed become concealed => delete event
+ ModelAPI_EventCreator::get()->sendDeleted(aThis, aCIter->first->groupName());
+ }
+ }
+ }
}
TDF_Label Model_Document::resultLabel(
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)
}
}
+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());
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
void Model_ValidatorsFactory::registerConcealment(std::string theFeature, std::string theAttribute)
{
-
+ std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
+ if (aFind == myConcealed.end()) {
+ std::set<std::string> aNewSet;
+ aNewSet.insert(theAttribute);
+ myConcealed[theFeature] = aNewSet;
+ } else {
+ aFind->second.insert(theAttribute);
+ }
}
-
+bool Model_ValidatorsFactory::isConcealed(std::string theFeature, std::string theAttribute)
+{
+ std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
+ return aFind != myConcealed.end() && aFind->second.find(theAttribute) != aFind->second.end();
+}
std::map<std::string, AttrValidators> myFeatures;
/// validators IDs and arguments by feature and attribute IDs
std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
+ /// Stores the registered attributes that leads to the concealment of referenced objects in
+ /// data tree. Map from feature kind to set of attribute IDs.
+ std::map<std::string, std::set<std::string> > myConcealed;
+
public:
/// Registers the instance of the validator by the ID
MODEL_EXPORT virtual void registerValidator(const std::string& theID,
/// all referenced features after execution
virtual void registerConcealment(std::string theFeature, std::string theAttribute);
+ /// Returns true that it was registered that attribute conceals the referenced result
+ virtual bool isConcealed(std::string theFeature, std::string theAttribute);
+
protected:
void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
/// Get instance from Session
/// 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;
/// all referenced features after execution
virtual void registerConcealment(std::string theFeature, std::string theAttribute) = 0;
+ /// Returns true that it was registered that attribute conceals the referenced result
+ virtual bool isConcealed(std::string theFeature, std::string theAttribute) = 0;
+
protected:
/// Get instance from Session
ModelAPI_ValidatorsFactory()
#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Preferences.h>
#include <XGUI_ObjectsBrowser.h>
+#include <XGUI_OperationMgr.h>
+
+#include <ModuleBase_Operation.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
mySelector = createSelector(OCCViewManagers.first());
}
}
- myWorkshop->propertyPanel()->hide();
QtxPopupMgr* aMgr = popupMgr(); // Create popup manager
action(myEraseAll)->setEnabled(false);
QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults()));
}
}
+ SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
+ myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
+
+ // this following row is caused by #187 bug.
+ // SALOME saves the dock widget positions before deactivateModule() and
+ // load it after the module activation. So, if the panel is visible before
+ // deactivate, it becomes visible after activate.
+ // In order to avoid the visible property panel, the widget position save is
+ // switch off in this module
+ aResMgr->setValue("Study", "store_positions", false);
+
return isDone;
}
setMenuShown(false);
setToolShown(false);
- myWorkshop->propertyPanel()->setVisible(false);
- desktop()->removeDockWidget(myWorkshop->propertyPanel());
-
QObject* aObj = myWorkshop->objectBrowser()->parent();
QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
if (aObjDoc) {
aViewAct->setEnabled(false);
}
+ // the active operation should be stopped for the next activation.
+ // There should not be active operation and visualized preview.
+ // Abort operation should be performed before the selection's remove
+ // because the displayed objects should be removed from the viewer, but
+ // the AIS context is obtained from the selector.
+ ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+ if (anOperation)
+ anOperation->abort();
+
// Delete selector because it has to be redefined on next activation
if (mySelector) {
myProxyViewer->setSelector(0);
}
//myWorkshop->contextMenuMgr()->disconnectViewer();
+
+ SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
+ aResMgr->setValue("Study", "store_positions", myIsStorePositions);
+
return LightApp_Module::deactivateModule(theStudy);
}
return QStringList();
}
+//******************************************************
+void NewGeom_Module::setDocumentKind(const QString& theId, const QString& theKind)
+{
+ myDocumentType[theId] = theKind;
+}
+
+//******************************************************
+QString NewGeom_Module::documentKind(const QString& theId) const
+{
+ if (myDocumentType.contains(theId))
+ return myDocumentType[theId];
+ return QString();
+
+}
+
//******************************************************
void NewGeom_Module::selectionChanged()
{
//! Returns list of nested actions according to the given command ID
virtual QStringList nestedActions(const QString& theId) const;
+ //! Set the document kind of the action by the given command Id
+ //! \param theId - the command ID
+ //! \param theKind - the document kind
+ virtual void setDocumentKind(const QString& theId, const QString& theKind);
+
+ //! Returns the document kind of the action by the given command ID
+ virtual QString documentKind(const QString& theId) const;
+
//! Returns interface to Salome viewer
virtual ModuleBase_IViewer* viewer() const
{
NewGeom_SalomeViewer* myProxyViewer;
QMap<QString, QStringList> myNestedActions;
+ QMap<QString, QString> myDocumentType;
bool myIsOpened;
+ bool myIsStorePositions;
+
};
#endif
{
std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind();
QString aDocKind = QString::fromStdString(aStdDocKind);
+ XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
foreach(QAction* eachAction, myActions.values()) {
XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(eachAction);
+ QString aCmdDocKind;
if(aCmd) {
- QString aCmdDocKind = aCmd->documentKind();
- if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
- eachAction->setEnabled(false);
+ aCmdDocKind = aCmd->documentKind();
+ }
+ else {
+ QString aId = eachAction->data().toString();
+ if (!aId.isEmpty()) {
+ aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId);
}
}
+ if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
+ eachAction->setEnabled(false);
+ }
}
}
//! Returns list of nested actions according to the given command ID
virtual QStringList nestedActions(const QString& theId) const = 0;
+ //! Set the document kind of the action by the given command Id
+ //! \param theId - the command ID
+ //! \param theKind - the document kind
+ virtual void setDocumentKind(const QString& theId, const QString& theKind) = 0;
+
+ //! Returns the document kind of the action by the given command ID
+ virtual QString documentKind(const QString& theId) const = 0;
+
//! Returns interface to Salome viewer
virtual ModuleBase_IViewer* viewer() const = 0;
QKeySequence(),
isUsePropPanel);
salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
+ salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind()));
+
myActionsMgr->addCommand(aAction);
myModule->featureCreated(aAction);
} else {