#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationDescription.h>
#include "ModuleBase_ToolBox.h"
+#include "ModuleBase_ISelection.h"
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Point.h>
#include <XGUI_Workshop.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_OperationMgr.h>
#include <XGUI_PropertyPanel.h>
#include <XGUI_ErrorMgr.h>
+#include <XGUI_SelectionMgr.h>
#include <QToolButton>
if (!anError.isEmpty()) {
aFOperation->setEditOperation(false);
//workshop()->operationMgr()->updateApplyOfOperations();
- beforeStopInternalEdit();
myIsInternalEditOperation = false;
updateAcceptAllAction();
}
}
bool aCanBeActivatedByMove = isLineFeature || isArcFeature;
if (aCanBeActivatedByMove) {
+ /// before restarting of operation we need to clear selection, as it may take part in
+ /// new feature creation, e.g. tangent arc. But it is not necessary as it was processed
+ /// by mouse release when the operation was restarted.
+ workshop()->selector()->clearSelection();\r
+
myPreviousFeature = aFOperation->feature();
restartOperation();
myPreviousFeature = FeaturePtr();
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
myPreviousFeature = aFOperation->feature();
+
+ /// selection should be obtained from workshop before ask if the operation can be started as
+ /// the canStartOperation method performs commit/abort of previous operation. Sometimes commit/abort
+ /// may cause selection clear(Sketch operation) as a result it will be lost and is not used for preselection.
+ ModuleBase_ISelection* aSelection = myWorkshop->selection();
+ QList<ModuleBase_ViewerPrsPtr> aPreSelected = aSelection->getSelected(ModuleBase_ISelection::AllControls);
+
restartOperation();
myPreviousFeature = FeaturePtr();
aProcessed = true;
PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
+ if (!aPreSelected.empty())
+ aPoint2DWdg->setPreSelection(aPreSelected.front());
aPoint2DWdg->mouseReleased(theWnd, theEvent);
+ if (!aPreSelected.empty())
+ aPoint2DWdg->setPreSelection(ModuleBase_ViewerPrsPtr());
}
// unblock viewer update
ModuleBase_Tools::blockUpdateViewer(false);
if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
return;
- if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation,
- module()->sketchMgr()->activeSketch())) {
+ if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
bool isStarted = false;
if (!module()->sketchMgr()->sketchSolverError()) {
if (myRestartingMode != RM_Forbided) {
bool anActive = PartSet_SketcherMgr::isSketchOperation(aCurrentOperation);
if (!anActive) {
- anActive = PartSet_SketcherMgr::isNestedSketchOperation(aCurrentOperation,
- module()->sketchMgr()->activeSketch());
+ anActive = module()->sketchMgr()->isNestedSketchOperation(aCurrentOperation);
if (anActive) { // the manager is not active when the current operation is a usual Edit
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
- if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation,
- module()->sketchMgr()->activeSketch())) {
+ if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
aFOperation->setEditOperation(true/*, false*/);
createInternalFeature();
if (aFOperation) {
myNoMoreWidgetsAttribute = "";
myIsFlagsBlocked = true;
- FeaturePtr aPrevFeature = aFOperation->feature();
- aFOperation->commit();
module()->launchOperation(aFOperation->id());
myIsFlagsBlocked = false;
resetFlags();
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
- if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation,
- module()->sketchMgr()->activeSketch())) {
+ if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
FeaturePtr anOperationFeature = aFOperation->feature();
CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
const bool isTemporary)
{
bool aChanged = false;
- if (!theSourceFeature.get())
+ if (!theSourceFeature.get() || !theSourceFeature->data().get() ||
+ !theSourceFeature->data()->isValid())
return aChanged;
std::string aFeatureKind = theSourceFeature->getKind();
}
bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation,
- const CompositeFeaturePtr& theSketch)
+ const CompositeFeaturePtr& /*theSketch*/) const
{
bool aTangentArc = false;
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(theOperation);
- if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation, theSketch)) {
+ if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
FeaturePtr aFeature = aFOperation->feature();
if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());