// TDataStd_Integer - type of the selected shape (for construction)
// TDF_Reference - from ReferenceAttribute, the context
void Model_AttributeSelection::setValue(const ResultPtr& theContext,
- const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+ const std::shared_ptr<GeomAPI_Shape>& theSubShape, const bool theTemporarily)
{
+ if (theTemporarily) { // just keep the stored without DF update
+ myTmpContext = theContext;
+ myTmpSubShape = theSubShape;
+ owner()->data()->sendAttributeUpdated(this);
+ return;
+ } else {
+ myTmpContext.reset();
+ myTmpSubShape.reset();
+ }
+
const std::shared_ptr<GeomAPI_Shape>& anOldShape = value();
bool isOldContext = theContext == myRef.value();
bool isOldShape = isOldContext &&
std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
{
+ if (myTmpContext.get() || myTmpSubShape.get()) {
+ return myTmpSubShape;
+ }
+
std::shared_ptr<GeomAPI_Shape> aResult;
if (myRef.isInitialized()) {
TDF_Label aSelLab = selectionLabel();
}
ResultPtr Model_AttributeSelection::context() {
+ if (myTmpContext.get() || myTmpSubShape.get()) {
+ return myTmpContext;
+ }
+
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
// for parts there could be same-data result, so take the last enabled
if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group()) {
{
Model_AttributeReference myRef; ///< The reference functionality reusage
TDF_LabelMap myScope; ///< the map of valid labels for naming selection solving
+ /// temporarily storages to avoid keeping in the data structure if not needed
+ ResultPtr myTmpContext;
+ /// temporarily storages to avoid keeping in the data structure if not needed
+ std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
public:
/// Defines the result and its selected sub-shape
+ /// \param theContext object where the sub-shape was selected
+ /// \param theSubShape selected sub-shape (if null, the whole context is selected)
+ /// \param theTemporarily if it is true, do not store and name the added in the data framework
+ /// (used to remove immideately, without the following updates)
MODEL_EXPORT virtual void setValue(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape);
+ const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+ const bool theTemporarily = false);
/// Returns the selected subshape
MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> value();
using namespace std;
void Model_AttributeSelectionList::append(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+ const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+ const bool theTemporarily)
{
// do not use the degenerated edge as a shape, a list is not incremented in this case
if (theSubShape.get() && !theSubShape->isNull() && theSubShape->isEdge()) {
}
aNewAttr->setID(id());
mySize->Set(aNewTag);
- aNewAttr->setValue(theContext, theSubShape);
+ aNewAttr->setValue(theContext, theSubShape, theTemporarily);
owner()->data()->sendAttributeUpdated(this);
}
Handle(TDataStd_Comment) mySelectionType; ///< Contains current type name (same as selection attribute)
public:
/// Adds the new reference to the end of the list
+ /// \param theContext object where the sub-shape was selected
+ /// \param theSubShape selected sub-shape (if null, the whole context is selected)
+ /// \param theTemporarily if it is true, do not store and name the added in the data framework
+ /// (used to remove immideately, without the following updates)
MODEL_EXPORT virtual void append(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape);
+ const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+ const bool theTemporarily = false);
/// Adds the new reference to the end of the list by the naming name of the selected shape
/// The type of shape is taken from the current selection type
{
public:
/// Defines the result and its selected sub-shape
+ /// \param theContext object where the sub-shape was selected
+ /// \param theSubShape selected sub-shape (if null, the whole context is selected)
+ /// \param theTemporarily if it is true, do not store and name the added in the data framework
+ /// (used to remove immideately, without the following updates)
virtual void setValue(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape) = 0;
+ const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+ const bool theTemporarily = false) = 0;
/// Returns the selected subshape
virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
{
public:
/// Adds the new reference to the end of the list
+ /// \param theContext object where the sub-shape was selected
+ /// \param theSubShape selected sub-shape (if null, the whole context is selected)
+ /// \param theTemporarily if it is true, do not store and name the added in the data framework
+ /// (used to remove immideately, without the following updates)
virtual void append(const ResultPtr& theContext,
- const GeomShapePtr& theSubShape) = 0;
+ const GeomShapePtr& theSubShape,
+ const bool theTemporarily = false) = 0;
/// Adds the new reference to the end of the list by the naming name of the selected shape
/// The type of shape is taken from the current selection type