void FeaturesPlugin_Group::execute()
{
- //AttributeStringPtr aNameAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeString>(
- // data()->attribute(FeaturesPlugin_Group::NAME_ID()));
- //if (!aNameAttr)
- // return;
- //std::string aName = aNameAttr->value();
- //data()->setName(aName);
+ if (results().empty()) { // just create result if not exists
+ document()->createGroup(data());
+ }
}
/// Request for initialization of data model of the feature: adding all attributes
FEATURESPLUGIN_EXPORT virtual void initAttributes();
+ /// Result of groups is created on the fly and don't stored to the document
+ FEATURESPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
/// Use plugin manager for features creation
FeaturesPlugin_Group();
Model_ResultBody.h
Model_ResultConstruction.h
Model_ResultPart.h
+ Model_ResultGroup.h
Model_FeatureValidator.h
)
Model_ResultBody.cpp
Model_ResultConstruction.cpp
Model_ResultPart.cpp
+ Model_ResultGroup.cpp
Model_FeatureValidator.cpp
)
// body: just a named shape, use selection mechanism from OCCT
TNaming_Selector aSelector(selectionLabel());
TDF_LabelMap aScope; // empty means the whole document
+ owner()->data()->sendAttributeUpdated(this);
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
}
if (aNewSelected) { // store this new selection
selectConstruction(aContext, aNewSelected);
+ owner()->data()->sendAttributeUpdated(this);
return true;
}
}
#include <Model_ResultPart.h>
#include <Model_ResultConstruction.h>
#include <Model_ResultBody.h>
+#include <Model_ResultGroup.h>
#include <ModelAPI_Validator.h>
#include <Events_Loop.h>
#include <Events_Error.h>
return aResult;
}
+boost::shared_ptr<ModelAPI_ResultGroup> Model_Document::createGroup(
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+ TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+ TDataStd_Comment::Set(aLab, ModelAPI_ResultGroup::group().c_str());
+ ObjectPtr anOldObject = object(aLab);
+ boost::shared_ptr<ModelAPI_ResultGroup> aResult;
+ if (anOldObject) {
+ aResult = boost::dynamic_pointer_cast<ModelAPI_ResultGroup>(anOldObject);
+ }
+ if (!aResult) {
+ aResult = boost::shared_ptr<ModelAPI_ResultGroup>(new Model_ResultGroup(theFeatureData));
+ storeResult(theFeatureData, aResult, theIndex);
+ }
+ return aResult;
+}
+
boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
const boost::shared_ptr<ModelAPI_Result>& theResult)
{
aNewBody = createBody(theFeature->data(), aResIndex);
} else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
aNewBody = createPart(theFeature->data(), aResIndex);
- } else if (aGroup->Get() != ModelAPI_ResultConstruction::group().c_str()) {
+ } else if (aGroup->Get() != ModelAPI_ResultConstruction::group().c_str() &&
+ aGroup->Get() != ModelAPI_ResultGroup::group().c_str()) {
Events_Error::send(std::string("Unknown type of result is found in the document:") +
TCollection_AsciiString(aGroup->Get()).ToCString());
}
/// Creates a part results
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+ /// Creates a group results
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultGroup> createGroup(
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
//! Returns a feature by result (owner of result)
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
return boost::shared_ptr<GeomAPI_Shape>();
}
-boost::shared_ptr<ModelAPI_Feature> Model_ResultBody::owner()
-{
- return myOwner;
-}
-
void Model_ResultBody::clean()
{
std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
*/
class Model_ResultBody : public ModelAPI_ResultBody
{
- boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
/// builders that tores the naming history: one per label to allow store several shapes to one
/// label; index in vector corresponds to the label tag
std::vector<TNaming_Builder*> myBuilders;
/// Returns the shape-result produced by this feature
MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
- /// Returns the source feature of this result
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
/// 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.
--- /dev/null
+// File: Model_ResultGroup.cpp
+// Created: 08 Jul 2014
+// Author: Mikhail PONIKAROV
+
+#include <Model_ResultGroup.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
+
+Model_ResultGroup::Model_ResultGroup(boost::shared_ptr<ModelAPI_Data> theOwnerData)
+{
+ setIsConcealed(false);
+ myOwnerData = theOwnerData;
+}
+
+boost::shared_ptr<GeomAPI_Shape> Model_ResultGroup::shape() const
+{
+ boost::shared_ptr<GeomAPI_Shape> aResult;
+ if (myOwnerData) {
+ AttributeSelectionListPtr aList = myOwnerData->selectionList("group_list");
+ if (aList) {
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aSubs;
+ for(int a = aList->size(); a >= 0; a--) {
+ boost::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
+ if (aSelection && !aSelection->isNull()) {
+ aSubs.push_back(aSelection);
+ }
+ }
+ if (!aSubs.empty()) {
+ aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);
+ }
+ }
+ }
+ return aResult;
+}
--- /dev/null
+// File: Model_ResultGroup.h
+// Created: 08 Jul 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Model_ResultGroup_H_
+#define Model_ResultGroup_H_
+
+#include "Model.h"
+#include <ModelAPI_ResultGroup.h>
+
+/**\class ModelAPI_ResultGroup
+ * \ingroup DataModel
+ * \brief The groups result.
+ *
+ * Provides a compound of selected elements, without storage, one the fly.
+ */
+class Model_ResultGroup : public ModelAPI_ResultGroup
+{
+ boost::shared_ptr<ModelAPI_Data> myOwnerData; ///< data of owner of this result
+public:
+ /// Returns the compound of selected entities
+ MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape() const;
+
+ /// Removes the stored builders
+ MODEL_EXPORT virtual ~Model_ResultGroup() {}
+
+protected:
+ /// Makes a body on the given feature data
+ Model_ResultGroup(boost::shared_ptr<ModelAPI_Data> theOwnerData);
+
+ friend class Model_Document;
+};
+
+#endif
ModelAPI_ResultConstruction.h
ModelAPI_ResultPart.h
ModelAPI_ResultParameters.h
+ ModelAPI_ResultGroup.h
ModelAPI_ResultValidator.h
ModelAPI_AttributeValidator.h
ModelAPI_Tools.h
class ModelAPI_ResultConstruction;
class ModelAPI_ResultBody;
class ModelAPI_ResultPart;
+class ModelAPI_ResultGroup;
class ModelAPI_Data;
/**\class Model_Document
/// Creates a part results
virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+ /// Creates a group results
+ virtual boost::shared_ptr<ModelAPI_ResultGroup> createGroup(
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
//! Returns a feature by result (owner of result)
virtual boost::shared_ptr<ModelAPI_Feature> feature(
--- /dev/null
+// File: ModelAPI_ResultGroup.hxx
+// Created: 07 Jul 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef ModelAPI_ResultGroup_H_
+#define ModelAPI_ResultGroup_H_
+
+#include "ModelAPI_Result.h"
+#include <GeomAPI_Shape.h>
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+/**\class ModelAPI_ResultGroup
+ * \ingroup DataModel
+ * \brief The groups result.
+ *
+ * Provides a compound of selected elements, without storage, one the fly.
+ */
+class ModelAPI_ResultGroup : public ModelAPI_Result
+{
+public:
+ /// Returns the group identifier of this result
+ virtual std::string groupName()
+ {
+ return group();
+ }
+
+ /// Returns the group identifier of this result
+ static std::string group()
+ {
+ static std::string MY_GROUP = "Groups";
+ return MY_GROUP;
+ }
+
+ /// Returns the compound of selected entities
+ virtual boost::shared_ptr<GeomAPI_Shape> shape() const = 0;
+};
+
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_ResultGroup> ResultGroupPtr;
+
+#endif
SketchPlugin_Line::SketchPlugin_Line()
: SketchPlugin_Feature()
-{
-}
+{}
void SketchPlugin_Line::initAttributes()
{