std::shared_ptr<GeomAPI_Circ2d> aCircle;
if (aCirc2d) {
const gp_Pnt2d& aCenter = aCirc2d->Location();
- const gp_Dir2d& aXAxis = aCirc2d->XAxis().Direction();
+ const gp_Dir2d& aXAxis = aCirc2d->Position().XDirection();
std::shared_ptr<GeomAPI_Pnt2d> aCircleCenter(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y()));
std::shared_ptr<GeomAPI_Dir2d> aCircleDir(new GeomAPI_Dir2d(aXAxis.X(), aXAxis.Y()));
if (aFeatureOwner.get()) {
aEraseResults = !aFeatureOwner->results().empty();
if (aEraseResults) // erase results without flash deleted and redisplay: do it after Select
- aFeatureOwner->removeResults(0, false);
+ aFeatureOwner->removeResults(0, false, false);
}
aSel.Select(aNewSub, aNewContext);
ModelAPI_EventCreator::get()->sendDeleted(myDoc, ModelAPI_Feature::group());
ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP);
aFeature->removeResults(0, false);
- //aFeature->eraseResults();
aFeature->erase();
myFeatures.UnBind(aFeaturesIter.Key());
}
{
myPluginObjs[myCurrentPluginName] = thePlugin;
static Events_ID EVENT_LOAD = Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED);
- ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD);
- Events_Loop::loop()->flush(EVENT_LOAD);
+ ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD, false);
// If the plugin has an ability to process GUI events, register it
Events_Listener* aListener = dynamic_cast<Events_Listener*>(thePlugin);
if (aListener) {
#ifdef DEB_UPDATE
std::cout<<"Invalid args "<<theFeature->name()<<std::endl;
#endif
- theFeature->eraseResults();
+ theFeature->eraseResults(false);
redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
return true; // so, feature is modified (results are erased)
}
#ifdef DEB_UPDATE
std::cout<<"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
#endif
- theFeature->eraseResults();
+ theFeature->eraseResults(false);
redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
}
return true;
// The macro feature has to be deleted in any case even its execution is failed
myWaitForFinish.insert(theFeature);
if (aState != ModelAPI_StateDone) {
- theFeature->eraseResults();
+ theFeature->eraseResults(false);
}
theFeature->data()->setUpdateID(ModelAPI_Session::get()->transactionID());
redisplayWithResults(theFeature, aState);
public:
/// Creates an empty message
MODELAPI_EXPORT ModelAPI_EventReentrantMessage(const Events_ID theID,
- const void* theSender = 0);
+ const void* theSender);
/// The virtual destructor
MODELAPI_EXPORT virtual ~ModelAPI_EventReentrantMessage() {}
/// Static. Returns EventID of the message.
}
}
-void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlush)
+void ModelAPI_Feature::removeResults(
+ const int theSinceIndex, const bool theForever, const bool theFlush)
{
std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
for(int anIndex = 0; anIndex < theSinceIndex && aResIter != myResults.end(); anIndex++)
while( aNextIter != myResults.end()) {
aGroup = (*aNextIter)->groupName();
// remove previously erased results: to enable later if needed only actual (of history change)
- //if (theSinceIndex == 0 && (*aNextIter)->isDisabled()) {
- // aNextIter = myResults.erase(aNextIter);
- //} else {
- (*aNextIter)->setDisabled(*aNextIter, true); // just disable results
+ (*aNextIter)->setDisabled(*aNextIter, true); // just disable results
+ if (theForever) {
+ aNextIter = myResults.erase(aNextIter);
+ } else {
aNextIter++;
- //}
+ }
}
if (!aGroup.empty() && theFlush) {
// flush visualisation changes
}
}
-void ModelAPI_Feature::eraseResults()
+void ModelAPI_Feature::eraseResults(const bool theForever)
{
- removeResults(0);
+ removeResults(0, theForever, true);
}
const std::string& ModelAPI_Feature::documentToAdd()
if (myIsDisabled != theFlag) {
myIsDisabled = theFlag;
if (myIsDisabled) {
- removeResults(0, false); // flush will be in setCurrentFeature
+ removeResults(0, false, false); // flush will be in setCurrentFeature
} else {
// enable all disabled previously results
std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
MODELAPI_EXPORT void removeResult(const std::shared_ptr<ModelAPI_Result>& theResult);
/// removes all results starting from the given index (zero-based)
/// \param theSinceIndex - index of the deleted result and all after also will be deleted
+ /// \param theForever - removes results for long period (not just because of feature disabling)
/// \param theFlush - if it is false, REDISPLAY message is not flushed
- MODELAPI_EXPORT void removeResults(const int theSinceIndex, const bool theFlush = true);
+ MODELAPI_EXPORT void removeResults(const int theSinceIndex,
+ const bool theForever = true, const bool theFlush = true);
/// removes all results from the feature
- MODELAPI_EXPORT void eraseResults();
+ MODELAPI_EXPORT void eraseResults(const bool theForever = true);
/// removes all fields from this feature: results, data, etc
MODELAPI_EXPORT virtual void erase();
/// removes the result from the list of feature (not doing in disabled): normally this
void ModuleBase_IModule::launchModal(const QString& theCmdId)
{
- if (!myWorkshop->canStartOperation(theCmdId))
+ bool isCommitted;
+ if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
return;
std::string aXmlCfg, aDescription;
}
-void ModuleBase_IModule::launchOperation(const QString& theCmdId)
+void ModuleBase_IModule::launchOperation(const QString& theCmdId,
+ const bool& isStartAfterCommitOnly)
{
/// selection should be obtained from workshop before ask if the operation can be started as
/// the canStartOperation method performs commit/abort of previous operation.
QList<ModuleBase_ViewerPrsPtr> aPreSelected =
aSelection->getSelected(ModuleBase_ISelection::AllControls);
- if (!myWorkshop->canStartOperation(theCmdId))
+ bool isCommitted;
+ if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
+ return;
+
+ /// reentrant operation(Sketch Line) should not be started if operation is aborted
+ if (isStartAfterCommitOnly && !isCommitted)
return;
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
//Do nothing on uncheck
if (aCmd->isCheckable() && !aCmd->isChecked()) {
ModuleBase_Operation* anOperation = myWorkshop->findStartedOperation(aCmd->data().toString());
- if (myWorkshop->canStopOperation(anOperation))
- myWorkshop->stopOperation(anOperation);
+ if (myWorkshop->canStopOperation(anOperation)) {
+ bool isCommitted;
+ myWorkshop->stopOperation(anOperation, isCommitted);
+ }
else {
aCmd->setChecked(true);
}
if (aInfo.get() && aInfo->isModal()) {
launchModal(aCmdId);
} else {
- launchOperation(aCmdId);
+ launchOperation(aCmdId, false);
emit operationLaunched();
}
}
void ModuleBase_IModule::editFeature(FeaturePtr theFeature)
{
std::string aFeatureId = theFeature->getKind();
- if (!myWorkshop->canStartOperation(aFeatureId.c_str()))
+ bool isCommitted;
+ if (!myWorkshop->canStartOperation(aFeatureId.c_str(), isCommitted))
return;
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
/// Creates an operation and send it to loop
/// \param theCmdId the operation name
- virtual void launchOperation(const QString& theCmdId);
+ /// \param isStartAfterCommitOnly operation is launched if there is no active operation or
+ /// it is committed
+ virtual void launchOperation(const QString& theCmdId,
+ const bool& isStartAfterCommitOnly);
/// Executes feature as a modal dialog box
/// \param theCmdId the operation name
virtual ModuleBase_Operation* currentOperation() const = 0;
//! Returns true if the operation with id theId can be started
- virtual bool canStartOperation(QString theId) = 0;
+ virtual bool canStartOperation(QString theId, bool& isCommitted) = 0;
//! Performs the operation launch
//! \param theOperation an operation to be launched
//! Commits if possible or aborts the given operation.
//! \param theOperation an aborted operation
- virtual void stopOperation(ModuleBase_Operation* theOperation) = 0;
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ virtual void stopOperation(ModuleBase_Operation* theOperation,
+ bool& isCommitted) = 0;
//! Returns AIS object by data object
//! \param theObject a data object
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
// in order to do not abort/commit it
- if (!anOpMgr->canStartOperation(tr("Detach")))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(tr("Detach"), isCommitted))
return; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule);
bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
- if (!anOpMgr->canStartOperation(anOpAction->id()))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
return; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
// in order to do not abort/commit it
- if (!anOpMgr->canStartOperation(anOpAction->id()))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
return true; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
return isProcessed;
}
-void PartSet_Module::onFeatureTriggered()
-{
- // is commented for imp: Unpressing the button of the current action must behave like
- // a validation if the entity can be created (instead of Cancel, as currently)
- /*QAction* aCmd = dynamic_cast<QAction*>(sender());
- if (aCmd->isCheckable() && aCmd->isChecked()) {
- // 1. check whether the delete should be processed in the module
- ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- bool isNestedOp = myModule->sketchMgr()->isNestedCreateOperation(anOperation);
- if (isNestedOp) {
- // in case if in the viewer nothing is displayed, the create operation should not be
- // comitted even if all values of the feature are initialized
- if (!mySketchMgr->canDisplayCurrentCreatedFeature()) {
- // the action information should be saved before the operation is aborted
- // because this abort leads to update command status, which unchecks this action
- anOperation->abort();
- launchOperation(aCmd->data().toString());
- }
- }
- }*/
- ModuleBase_IModule::onFeatureTriggered();
-}
-
void PartSet_Module::editFeature(FeaturePtr theFeature)
{
storeConstraintsState(theFeature->getKind());
return true;
}
-void PartSet_Module::launchOperation(const QString& theCmdId)
+void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
{
myIsOperationIsLaunched = true;
storeConstraintsState(theCmdId.toStdString());
updateConstraintsState(theCmdId.toStdString());
- ModuleBase_IModule::launchOperation(theCmdId);
+ ModuleBase_IModule::launchOperation(theCmdId, isStartAfterCommitOnly);
myIsOperationIsLaunched = false;
}
/// Creates an operation and send it to loop
/// \param theCmdId the operation name
- virtual void launchOperation(const QString& theCmdId);
+ /// \param isStartAfterCommitOnly operation is launched if there is no active operation or
+ /// it is committed
+ virtual void launchOperation(const QString& theCmdId,
+ const bool& isStartAfterCommitOnly);
/// Realizes some functionality by an operation start
/// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
XGUI_Workshop* getWorkshop() const;
public slots:
- /// Redefines the parent method in order to customize the next case:
- /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
- /// the operation should be always aborted.
- virtual void onFeatureTriggered();
-
/// Slolt called on object display
/// \param theObject a data object
/// \param theAIS a presentation object
#include <PartSet_SketcherMgr.h>
#include <PartSet_SketcherReentrantMgr.h>
+#include "XGUI_CustomPrs.h"
+#include "XGUI_Displayer.h"
#include "XGUI_ModuleConnector.h"
+#include "XGUI_OperationMgr.h"
+#include "XGUI_Tools.h"
#include "XGUI_Workshop.h"
-#include "XGUI_Displayer.h"
-#include "XGUI_CustomPrs.h"
#include "SketcherPrs_SymbolPrs.h"
#include "SketchPlugin_SketchEntity.h"
}
else if (anEventID == ModelAPI_EventReentrantMessage::eventId() ||
anEventID == SketchPlugin_MacroArcReentrantMessage::eventId()) {
- PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
- PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
- aReentrantMgr->setReentrantMessage(theMessage);
+ // the message is sent to sketcher reentrant manager only if the kind of feature
+ // sender is equal to kind of the current operation. E.g. Horizontal create operation
+ // is active. Sketch Line feature is changed, so execute is called, it will send message
+ // This Line's message should not be processed, as the reentrant operation is not for Line
+ std::string aCurrentFeatureKind;
+ ModuleBase_Operation* anOperation =
+ XGUI_Tools::workshop(myWorkshop)->operationMgr()->currentOperation();
+ if (anOperation) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (anOperation);
+ if (aFOperation) {
+ FeaturePtr aFeature = aFOperation->feature();
+ if (aFeature.get())
+ aCurrentFeatureKind = aFeature->getKind();
+ }
+ }
+ if (theMessage->sender()) {
+ ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theMessage->sender());
+ if (aSender) {
+ FeaturePtr aFeatureSender =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(aSender->data()->owner());
+ if (aFeatureSender.get() && aFeatureSender->getKind() == aCurrentFeatureKind) {
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
+ aReentrantMgr->setReentrantMessage(theMessage);
+ }
+ }
+ }
}
#ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
+ // Clear dragging mode
+ myIsDragging = false;
+
if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent))
return;
-
//get2dPoint(theWnd, theEvent, myClickedPoint);
-
if (!(theEvent->buttons() & Qt::LeftButton))
return;
- // Clear dragging mode
- myIsDragging = false;
-
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = aWorkshop->viewer();
if (!aViewer->canDragByMouse())
void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
+ bool aWasDragging = myIsDragging;
+ myIsDragging = false;
+
if (myModule->sketchReentranceMgr()->processMouseReleased(theWnd, theEvent))
return;
if (aOp) {
if (isNestedSketchOperation(aOp)) {
// Only for sketcher operations
- if (myIsDragging) {
+ if (aWasDragging) {
if (myDragDone) {
myCurrentSelection.clear();
}
}
aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled);
- myIsDragging = false;
ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
PartSet_MouseProcessor* aProcessor = dynamic_cast<PartSet_MouseProcessor*>(anActiveWidget);
QList<ModuleBase_ViewerPrsPtr> aPreSelected =
aSelection->getSelected(ModuleBase_ISelection::AllControls);
-
-
if (myInternalFeature.get())
copyReetntrantAttributes(myInternalFeature, aFOperation->feature(),
module()->sketchMgr()->activeSketch());
myNoMoreWidgetsAttribute = "";
myIsFlagsBlocked = true;
- module()->launchOperation(aFOperation->id());
+ /// launch has 'false' parameter to do not start new operation if the previous operation
+ /// is not committed. It is important for Line Sketch feature as it uses the previous
+ /// created feature parameter(to build coincidence), but by abort the previous is removed
+ module()->launchOperation(aFOperation->id(), true);
myIsFlagsBlocked = false;
resetFlags();
Test1673.py
Test1924.py
Test1966.py
- Test1967.py)
+ Test1967.py
+ TestTrimArc01.py
+ TestTrimArc02.py
+ TestTrimArc03.py
+ TestTrimArc04.py
+ TestTrimArc05.py
+ TestTrimArc06.py
+ TestTrimArc07.py
+ TestTrimCircle01.py
+ TestTrimCircle02.py
+ TestTrimCircle03.py
+ TestTrimCircle04.py
+ TestTrimCircle05.py
+ TestTrimCircleAndArc01.py
+ TestTrimLine01.py
+ TestTrimLine02.py)
static Events_ID anId = ModelAPI_EventReentrantMessage::eventId();
std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage = std::shared_ptr
- <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(anId, 0));
+ <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(anId, this));
aMessage->setCreatedFeature(ModelAPI_Feature::feature(
data()->attribute(START_ID())->owner()));
Events_Loop::loop()->send(aMessage);
// message to init reentrant operation
static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
std::shared_ptr<SketchPlugin_MacroArcReentrantMessage> aMessage = std::shared_ptr
- <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, 0));
+ <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, this));
std::string anEditArcType = string(EDIT_ARC_TYPE_ID())->value();
aMessage->setTypeOfCreation(!anEditArcType.empty() ? anEditArcType : anArcType);
public:
/// Creates an empty message
SKETCHPLUGIN_EXPORT SketchPlugin_MacroArcReentrantMessage(const Events_ID theID,
- const void* theSender = 0)
+ const void* theSender)
: ModelAPI_EventReentrantMessage(theID, theSender) {}
/// The virtual destructor
SKETCHPLUGIN_EXPORT virtual ~SketchPlugin_MacroArcReentrantMessage() {}
// message to init reentrant operation
static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
std::shared_ptr<SketchPlugin_MacroArcReentrantMessage> aMessage = std::shared_ptr
- <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, 0));
+ <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, this));
std::string anEditType = string(EDIT_CIRCLE_TYPE())->value();
aMessage->setTypeOfCreation(!anEditType.empty() ? anEditType : aType);
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
attribute(aReferenceAttributeName));
if (aRefAttr.get()) {
- if (anAttribute.get())
+ if (anAttribute.get()) {
+ if (!anAttribute->owner().get() || !anAttribute->owner()->data()->isValid()) {
+ FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature();
+ if (aCreatedFeature.get()) {
+ std::string anID = anAttribute->id();
+ std::string anArcID;
+ if (anID == CENTER_POINT_ID())
+ anArcID = SketchPlugin_Circle::CENTER_ID();
+ anAttribute = aCreatedFeature->attribute(anArcID);
+ }
+ }
aRefAttr->setAttr(anAttribute);
+ }
else if (anObject.get()) {
// if presentation of previous reentrant macro arc is used, the object is invalid,
// we should use result of previous feature of the message(Arc)
AttributeDoublePtr aRadiusAttr = real(CIRCLE_RADIUS_ID());
bool aWasBlocked = data()->blockSendAttributeUpdated(true);
+ if(myCenter.get()) {
+ // center attribute is used in processEvent() to set reference to reentrant arc
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_POINT_ID()))
+ ->setValue(myCenter);
+ }
aRadiusAttr->setValue(myRadius);
data()->blockSendAttributeUpdated(aWasBlocked, false);
}
if (aPreviewObject.get()) {
std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage = std::shared_ptr
<ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(
- ModelAPI_EventReentrantMessage::eventId(), 0));
+ ModelAPI_EventReentrantMessage::eventId(), this));
aMessage->setSelectedObject(aPreviewObject);
Events_Loop::loop()->send(aMessage);
}
def assertNotInitializedByCenterAndPassed(theMacroCircle):
# check points
- aCenterPoint = geomDataAPI_Point2D(theMacroCircle.attribute("center_point"))
aPassedPoint = geomDataAPI_Point2D(theMacroCircle.attribute("passed_point"))
- assert (not aCenterPoint.isInitialized())
assert (not aPassedPoint.isInitialized())
# check references
aCenterPointRef = theMacroCircle.refattr("center_point_ref")
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
SketchTrim = Sketch.addTrim(SketchArc_1, Sketch.to2D(GeomPoint))
SketchTrim.execute()
-
-# Another case
-#GeomPoint = geom.Pnt2d(60, 50)
-#model.do()
-#SketchTrim = Sketch.addTrim(SketchArc_1, GeomPoint)
-#SketchTrim.execute()
-
-
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
assert(idList_after.count(SketchConstraintCoincidenceId) == 8)
-#check arc position intersections of created arc to an additional line
-#SketchLine_intersecting_1 = Sketch.addLine(0, 0, 50, 50)
-#SketchLine_intersecting_2 = Sketch.addLine(50, 50, 100, 100)
-
-#Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_1.feature()]))
-#Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_2.feature()]))
-
-#assert(len(Intersection_Points_1) == 1)
-#assert(len(Intersection_Points_2) == 0)
-
#add point for check
SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchPoint.feature()]))
assert(len(Intersection_Points_3) == 0)
-
-
#perform trim: horizontal
#second intersection point - horizontal
SketchLine_intersecting_h = Sketch.addLine(10, 48, 72, 48)
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
model.end()
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
EntityWrapperPtr anAngle;
EntityWrapperPtr aRotationCenter;
- bool isFullValue;
std::list<EntityWrapperPtr> aBaseEntities;
- getAttributes(aRotationCenter, anAngle, isFullValue, aBaseEntities);
+ getAttributes(aRotationCenter, anAngle, myIsFullValue, aBaseEntities);
if (!myErrorMsg.empty())
return;
}
EntityWrapperPtr aStartPoint, aEndPoint;
- bool aFullValue;
std::list<EntityWrapperPtr> aBaseEntities;
- getAttributes(aStartPoint, aEndPoint, aFullValue, aBaseEntities);
+ getAttributes(aStartPoint, aEndPoint, myIsFullValue, aBaseEntities);
if (!myErrorMsg.empty())
return;
myWorkshop->setStatusBarMessage(theMessage);
}
-bool XGUI_ModuleConnector::canStartOperation(QString theId)
+bool XGUI_ModuleConnector::canStartOperation(QString theId, bool& isCommitted)
{
- return myWorkshop->operationMgr()->canStartOperation(theId);
+ return myWorkshop->operationMgr()->canStartOperation(theId, isCommitted);
}
void XGUI_ModuleConnector::processLaunchOperation(ModuleBase_Operation* theOperation)
return myWorkshop->operationMgr()->canStopOperation(theOperation);
}
-void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation)
+void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation,
+ bool& isCommitted)
{
- myWorkshop->operationMgr()->stopOperation(theOperation);
+ myWorkshop->operationMgr()->stopOperation(theOperation, isCommitted);
}
void XGUI_ModuleConnector::updateCommandStatus()
virtual ModuleBase_Operation* currentOperation() const;
//! Returns true if the operation with id theId can be started
- virtual bool canStartOperation(QString theId);
+ /// \param theId id of the operation which is going to start
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ virtual bool canStartOperation(QString theId, bool& isCommitted);
//! Performs the operation launch
//! \param theOperation an operation to be launched
//! Commits if possible or aborts the given operation.
//! \param theOperation an aborted operation
- virtual void stopOperation(ModuleBase_Operation* theOperation);
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ virtual void stopOperation(ModuleBase_Operation* theOperation,
+ bool& isCommitted);
//! Returns AIS object by data object
virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
aMgr->finishOperation();
}
-bool XGUI_OperationMgr::canStartOperation(const QString& theId)
+bool XGUI_OperationMgr::canStartOperation(const QString& theId, bool& isCommitted)
{
bool aCanStart = true;
+ isCommitted = false;
ModuleBase_Operation* aCurrentOp = currentOperation();
if (aCurrentOp) {
bool aGranted = aCurrentOp->isGranted(theId);
else if (canStopOperation(aCurrentOp)) {
// the started operation is granted in the parrent operation,
// e.g. current - Line in Sketch, started Circle
- stopOperation(aCurrentOp);
+ stopOperation(aCurrentOp, isCommitted);
} else {
aCanStart = false;
}
return aCanStart;
}
-void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation)
+void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted)
{
if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
- theOperation->commit();
- else
+ isCommitted = theOperation->commit();
+ else {
+ isCommitted = false;
abortOperation(theOperation);
+ }
}
void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
/// Returns whether the operation can be started. Check if there is already started operation and
/// the granted parameter of the launched operation
/// \param theId id of the operation which is going to start
- bool canStartOperation(const QString& theId);
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ bool canStartOperation(const QString& theId, bool& isCommitted);
/// If Apply is enabled and operation has modification, it is applyed, otherwise aborted
/// \param theOperation the started operation
- void stopOperation(ModuleBase_Operation* theOperation);
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ void stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted);
/// Aborts the parameter operation if it is current, else abort operations from the stack
/// of operations until the operation is found. All operations upper the parameter one are