subDoc(*aSubIter)->abortOperation();
}
-bool Model_Document::isOperation()
+bool Model_Document::isOperation() const
{
// operation is opened for all documents: no need to check subs
return myDoc->HasOpenCommand() == Standard_True ;
std::list<std::string> Model_Document::undoList() const
{
std::list<std::string> aResult;
+ // the number of skipped current operations (on undo they will be aborted)
+ int aSkipCurrent = isOperation() ? 1 : 0;
std::list<Transaction>::const_reverse_iterator aTrIter = myTransactions.crbegin();
int aNumUndo = myTransactions.size();
if (!myNestedNum.empty())
aNumUndo = *myNestedNum.rbegin();
for( ; aNumUndo > 0; aTrIter++, aNumUndo--) {
- aResult.push_back(aTrIter->myId);
+ if (aSkipCurrent == 0) aResult.push_back(aTrIter->myId);
+ else aSkipCurrent--;
}
return aResult;
}
//! Aborts the operation
MODEL_EXPORT virtual void abortOperation();
//! Returns true if operation has been started, but not yet finished or aborted
- MODEL_EXPORT virtual bool isOperation();
+ MODEL_EXPORT virtual bool isOperation() const;
//! Returns true if document was modified (since creation/opening)
MODEL_EXPORT virtual bool isModified();
};
/// Message that document (Part, PartSet) was created
-class MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage : public Events_Message
+class ModelAPI_DocumentCreatedMessage : public Events_Message
{
DocumentPtr myDocument;
public:
/// Creates an empty message
- ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
+ MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
/// The virtual destructor
- virtual ~ModelAPI_DocumentCreatedMessage();
+ MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage();
- static Events_ID eventId()
+ MODELAPI_EXPORT static Events_ID eventId()
{
static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
}
- DocumentPtr document() const;
- void setDocument(DocumentPtr theDocument);
+ MODELAPI_EXPORT DocumentPtr document() const;
+ MODELAPI_EXPORT void setDocument(DocumentPtr theDocument);
};
#endif
PartSet_WidgetSketchLabel.h
PartSet_Validators.h
PartSet_WidgetPoint2d.h
+ PartSet_WidgetConstraintShapeSelector.h
PartSet_WidgetPoint2dDistance.h
PartSet_WidgetShapeSelector.h
PartSet_Filters.h
PartSet_Tools.cpp
PartSet_WidgetSketchLabel.cpp
PartSet_Validators.cpp
+ PartSet_WidgetConstraintShapeSelector.cpp
PartSet_WidgetPoint2d.cpp
PartSet_WidgetPoint2dDistance.cpp
PartSet_WidgetShapeSelector.cpp
#include <PartSet_WidgetPoint2d.h>
#include <PartSet_WidgetPoint2dDistance.h>
#include <PartSet_WidgetShapeSelector.h>
+#include <PartSet_WidgetConstraintShapeSelector.h>
#include <PartSet_SketcherMgr.h>
#include <ModuleBase_Operation.h>
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetShapeSelector.cpp
+// Created: 27 Nov 2014
+// Author: Vitaly Smetannikov
+
+#include "PartSet_WidgetConstraintShapeSelector.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <PartSet_Tools.h>
+#include <SketchPlugin_Feature.h>
+
+
+//*********************************************
+bool PartSet_WidgetConstraintShapeSelector::storeValueCustom() const
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
+ if (aFeature) {
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if ((!aSPFeature) && (!myShape->isNull())) {
+ ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
+ mySelectedObject, mySketch);
+ if (aObj) {
+ PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
+ that->mySelectedObject = aObj;
+ } else
+ return false;
+ }
+ }
+ return ModuleBase_WidgetShapeSelector::storeValueCustom();
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetShapeSelector.h
+// Created: 27 Nov 2014
+// Author: Vitaly Smetannikov
+
+
+#ifndef PartSet_WidgetConstraintShapeSelector_H
+#define PartSet_WidgetConstraintShapeSelector_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_WidgetShapeSelector.h>
+
+#include <ModelAPI_CompositeFeature.h>
+
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetShapeSelector in order to provide
+* working with constraints.
+*/
+class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
+{
+Q_OBJECT
+ public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theWorkshop instance of workshop interface
+ /// \param theData the widget configuation. The attribute of the model widget is obtained from
+ /// \param theParentId is Id of a parent of the current attribute
+ PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData, const std::string& theParentId)
+ : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
+
+ virtual ~PartSet_WidgetConstraintShapeSelector() {}
+
+ /// Set sketcher
+ /// \param theSketch a sketcher object
+ void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+
+ /// Retrurns installed sketcher
+ CompositeFeaturePtr sketch() const { return mySketch; }
+
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValueCustom() const;
+
+private:
+ /// Pointer to a sketch
+ CompositeFeaturePtr mySketch;
+};
+
+#endif
\ No newline at end of file
return true;
}
-//*********************************************
-bool PartSet_WidgetConstraintShapeSelector::storeValueCustom() const
-{
- FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
- if (aFeature) {
- std::shared_ptr<SketchPlugin_Feature> aSPFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if ((!aSPFeature) && (!myShape->isNull())) {
- ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
- mySelectedObject, mySketch);
- if (aObj) {
- PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
- that->mySelectedObject = aObj;
- } else
- return false;
- }
- }
- return ModuleBase_WidgetShapeSelector::storeValueCustom();
-}
CompositeFeaturePtr mySketch;
};
-/**
-* \ingroup Modules
-* Customosation of ModuleBase_WidgetShapeSelector in order to provide
-* working with constraints.
-*/
-class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
-{
-Q_OBJECT
- public:
- /// Constructor
- /// \param theParent the parent object
- /// \param theWorkshop instance of workshop interface
- /// \param theData the widget configuation. The attribute of the model widget is obtained from
- /// \param theParentId is Id of a parent of the current attribute
- PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
- const Config_WidgetAPI* theData, const std::string& theParentId)
- : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
-
- virtual ~PartSet_WidgetConstraintShapeSelector() {}
-
- /// Set sketcher
- /// \param theSketch a sketcher object
- void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
-
- /// Retrurns installed sketcher
- CompositeFeaturePtr sketch() const { return mySketch; }
-
-protected:
- /// Saves the internal parameters to the given feature
- /// \return True in success
- virtual bool storeValueCustom() const;
-
-private:
- /// Pointer to a sketch
- CompositeFeaturePtr mySketch;
-};
-
#endif
\ No newline at end of file
<sketch-2dpoint_selector id="ArcEndPoint" title="End point" tooltip="End point"/>
</feature>
</group>
-
+
<group id="Constraints">
<feature
id="SketchConstraintCoincidence"
title="Coincident"
tooltip="Create constraint for the coincidence of two points"
internal="1" />
- <!-- SketchConstraintDistance -->
+ <!-- SketchConstraintDistance -->
<feature
id="SketchConstraintDistance"
title="Distance"
shape_types="edge vertex">
<selection_filter id="MultiFilter" parameters="line,vertex"/>
</sketch_shape_selector>/>
- <sketch_shape_selector
+ <sketch_shape_selector
id="ConstraintEntityB"
label="Last object"
tooltip="Select point, line end point, line, center of circle or arc."
- shape_types="edge vertex">
- <validator id="SketchPlugin_DifferentObjects"/>
+ shape_types="edge vertex">
+ <validator id="SketchPlugin_DifferentObjects"/>
<validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
<selection_filter id="MultiFilter" parameters="line,vertex"/>
</sketch_shape_selector>
-
+
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
- <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed" min="0">
+ <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed" min="0">
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
- <validator id="PartSet_DistanceValidator"/>
+ <validator id="PartSet_DistanceValidator"/>
</feature>
- <!-- SketchConstraintLength -->
+ <!-- SketchConstraintLength -->
<feature id="SketchConstraintLength" title="Length" tooltip="Set fixed length of a line segment" icon=":icons/length.png">
<label title="Select a line on which to calculate length" tooltip="Select a line on which to calculate length"/>
- <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line"
- shape_types="edge" >
- <validator id="SketchPlugin_ResultLine"/>
+ <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line"
+ shape_types="edge" >
+ <validator id="SketchPlugin_ResultLine"/>
<selection_filter id="EdgeFilter" parameters="line"/>
+ <validator id="SketchPlugin_ResultLine"/>
</shape_selector>
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
</doublevalue_editor>
<validator id="PartSet_LengthValidator"/>
</feature>
- <!-- SketchConstraintRadius -->
+ <!-- SketchConstraintRadius -->
<feature id="SketchConstraintRadius" title="Radius" tooltip="Set fixed radius of a circle or an arc" icon=":icons/radius_constr.png">
<label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
- <shape_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc"
- shape_types="edge">
- <validator id="SketchPlugin_ResultArc"/>
- <selection_filter id="EdgeFilter" parameters="circle"/>
- </shape_selector>
+ <shape_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc"
+ shape_types="edge">
+ <validator id="SketchPlugin_ResultArc"/>
+ <selection_filter id="EdgeFilter" parameters="circle"/>
+ </shape_selector>
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed"/>
<validator id="PartSet_RadiusValidator"/>
</feature>
- <!-- SketchConstraintParallel -->
+ <!-- SketchConstraintParallel -->
<feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
- label="First line" tooltip="Select a line" shape_types="edge">
- <selection_filter id="EdgeFilter" parameters="line"/>
- </sketch_constraint_shape_selector>
-
- <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line"
- shape_types="edge">
- <selection_filter id="EdgeFilter" parameters="line"/>
- <validator id="SketchPlugin_DifferentObjects"/>
- </sketch_constraint_shape_selector>
-
+ <sketch_constraint_shape_selector id="ConstraintEntityA"
+ label="First line" tooltip="Select a line" shape_types="edge">
+ <selection_filter id="EdgeFilter" parameters="line"/>
+ </sketch_constraint_shape_selector>
+
+ <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line"
+ shape_types="edge">
+ <selection_filter id="EdgeFilter" parameters="line"/>
+ <validator id="SketchPlugin_DifferentObjects"/>
+ </sketch_constraint_shape_selector>
+
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
<validator id="PartSet_ParallelValidator"/>
</feature>
- <!-- SketchConstraintPerpendicular -->
+ <!-- SketchConstraintPerpendicular -->
<feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines" icon=":icons/perpendicular.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
- label="First line" tooltip="Select an line"
- shape_types="edge">
+ <sketch_constraint_shape_selector id="ConstraintEntityA"
+ label="First line" tooltip="Select an line"
+ shape_types="edge">
<selection_filter id="EdgeFilter" parameters="line"/>
</sketch_constraint_shape_selector>
-
- <sketch_constraint_shape_selector id="ConstraintEntityB"
- label="Last line" tooltip="Select an line"
- shape_types="edge">
- <validator id="SketchPlugin_DifferentObjects"/>
+
+ <sketch_constraint_shape_selector id="ConstraintEntityB"
+ label="Last line" tooltip="Select an line"
+ shape_types="edge">
+ <validator id="SketchPlugin_DifferentObjects"/>
<selection_filter id="EdgeFilter" parameters="line"/>
</sketch_constraint_shape_selector>
<validator id="PartSet_PerpendicularValidator"/>
</feature>
- <!-- SketchConstraintRigid -->
+ <!-- SketchConstraintRigid -->
<feature id="SketchConstraintRigid" title="Fixed" tooltip="Fix an object" icon=":icons/fixed.png">
<shape_selector id="ConstraintEntityA" label="Object" tooltip="Select an object"
- shape_types="edge vertex">
- <validator id="SketchPlugin_ResultPoint"/>
- <validator id="SketchPlugin_ResultLine"/>
- <validator id="SketchPlugin_ResultArc"/>
- </shape_selector>
- <validator id="PartSet_RigidValidator"/>
+ shape_types="edge vertex">
+ <validator id="SketchPlugin_ResultPoint"/>
+ <validator id="SketchPlugin_ResultLine"/>
+ <validator id="SketchPlugin_ResultArc"/>
+ </shape_selector>
+ <validator id="PartSet_RigidValidator"/>
</feature>
</group>
</workbench>