2. Selection should be cleared only if the operation is stopped but it is not a reentrant operation because on restart the previous selected object is used as a preselection for the new created object.
/// \param theStdActions - a map of standard actions\r
virtual void updateViewerMenu(const QMap<QString, QAction*>& theStdActions) {}\r
\r
+ /// Returns true if the action should be always enabled\r
+ /// \param theActionId an action index: Accept or Accept All\r
+ /// \return boolean value\r
+ virtual bool isActionEnableStateFixed(const int theActionId) const { return false; }\r
+\r
//! Returns the feature error if the current state of the feature in the module is not correct\r
//! If the feature is correct, it returns an empty value\r
//! \return string value\r
#include <XGUI_ErrorMgr.h>
#include <XGUI_CustomPrs.h>
#include <XGUI_SelectionMgr.h>
+#include <XGUI_ActionsMgr.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
myMenuMgr->updateViewerMenu(theStdActions);
}
+bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
+{
+ bool isEnabledFixed = false;
+ if (theActionId == XGUI_ActionsMgr::AcceptAll &&
+ mySketchReentrantMgr->isInternalEditStarted())
+ isEnabledFixed = true;
+ return isEnabledFixed;
+}
+
QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
{
QString anError = ModuleBase_IModule::getFeatureError(theFeature);
/// \param theStdActions - a map of standard actions
virtual void updateViewerMenu(const QMap<QString, QAction*>& theStdActions);
+ /// Returns true if the action should be always enabled
+ /// \param theActionId an action index: Accept or Accept All
+ /// \return boolean value
+ virtual bool isActionEnableStateFixed(const int theActionId) const;
+
//! Returns the feature error if the current state of the feature in the module is not correct
//! If the feature is correct, it returns an empty value
//! \return string value
#include <ModelAPI_Session.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
+
#include <QMouseEvent>
#include <QApplication>
#include <QCursor>
#include <QMessageBox>
+#include <QMainWindow>
//#define DEBUG_DO_NOT_BY_ENTER
}
myCurrentSketch->setDisplayed(false);
+ // Remove invalid sketch entities
+ /*
+ std::set<FeaturePtr> anInvalidFeatures;
+ ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
+ for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ FeaturePtr aFeature = myCurrentSketch->subFeature(i);
+ if (aFeature.get()) {
+ if (!aFactory->validate(aFeature))
+ anInvalidFeatures.insert(aFeature);
+ }
+ }
+ std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
+ ModelAPI_Tools::findAllReferences(anInvalidFeatures, aReferences, false);
+ std::set<FeaturePtr> aFeatureRefsToDelete;
+ if (ModuleBase_Tools::askToDelete(anInvalidFeatures, aReferences, aConnector->desktop(), aFeatureRefsToDelete)) {
+ if (!aFeatureRefsToDelete.empty())
+ anInvalidFeatures.insert(aFeatureRefsToDelete.begin(), aFeatureRefsToDelete.end());
+ bool aDone = ModelAPI_Tools::removeFeatures(anInvalidFeatures, false);
+ }
+ else
+ return;
+ */
// Display sketcher objects
for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
FeaturePtr aFeature = myCurrentSketch->subFeature(i);
}
/// improvement to deselect automatically all eventual selected objects, when
// returning to the neutral point of the Sketcher
- workshop()->selector()->clearSelection();
+ // if the operation is restarted, the previous selection is used to initialize started operation
+ if (!myModule->sketchReentranceMgr()->isInternalEditStarted())
+ workshop()->selector()->clearSelection();
}
void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
#include <XGUI_ModuleConnector.h>
#include <XGUI_OperationMgr.h>
#include <XGUI_PropertyPanel.h>
+#include <XGUI_ErrorMgr.h>
#include <QToolButton>
//workshop()->operationMgr()->updateApplyOfOperations();
beforeStopInternalEdit();
myIsInternalEditOperation = false;
+ updateAcceptAllAction();
}
}
}
return !isActiveMgr() || myRestartingMode == RM_None;
}
+bool PartSet_SketcherReetntrantMgr::isInternalEditStarted() const
+{
+ return myIsInternalEditOperation;
+}
+
bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
{
ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
aFOperation->setEditOperation(true/*, false*/);
- workshop()->operationMgr()->updateApplyOfOperations();
-
createInternalFeature();
myIsInternalEditOperation = true;
+ updateAcceptAllAction();
+
isDone = true;
connect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
{
if (!myIsFlagsBlocked) {
myIsInternalEditOperation = false;
+ updateAcceptAllAction();
myRestartingMode = RM_None;
}
}
return aTangentArc;
}
+void PartSet_SketcherReetntrantMgr::updateAcceptAllAction()
+{
+ CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
+ if (aSketch.get())
+ workshop()->errorMgr()->updateAcceptAllAction(aSketch);
+}
+
XGUI_Workshop* PartSet_SketcherReetntrantMgr::workshop() const
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
/// Returns false if the reentrant mode of the operation is not empty.
bool canBeCommittedByPreselection();
+ /// returns true if an internal edit operation is started
+ /// \return boolean value
+ bool isInternalEditStarted() const;
+
private slots:
/// SLOT, that is called by a widget activating in the property panel
/// If the 'internal' edit operation is started, it activates the first widget selection
static bool isTangentArc(ModuleBase_Operation* theOperation);
+ /// Accept All action is enabled if an internal edit is started. It updates the state of the button
+ void updateAcceptAllAction();
+
/// Returns the workshop
XGUI_Workshop* workshop() const;
addAction("SELECT_FACE_CMD", aAction);
//mySelectActions->addAction(aAction);
- aAction = ModuleBase_Tools::createAction(QIcon(":pictures/result.png"), tr("Result"), aDesktop,
+ aAction = ModuleBase_Tools::createAction(QIcon(":pictures/result.png"), tr("Results"), aDesktop,
this, SLOT(onResultSelection(bool)));
aAction->setCheckable(true);
addAction("SELECT_RESULT_CMD", aAction);
if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty())
storeInitialActionValues();
- QString anError = myWorkshop->module()->getFeatureError(theFeature);
- if (anError.isEmpty()) {
- ModuleBase_ModelWidget* anActiveWidget = activeWidget();
- if (anActiveWidget)
- anError = anActiveWidget->getError();
+ QString anError = "";
+ /// to allow the module have the button always enabled
+ bool isActionStateEnabled = myWorkshop->module()->isActionEnableStateFixed(XGUI_ActionsMgr::AcceptAll);
+ if (!isActionStateEnabled) {
+ anError = myWorkshop->module()->getFeatureError(theFeature);
+ if (anError.isEmpty()) {
+ ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+ if (anActiveWidget)
+ anError = anActiveWidget->getError();
+ }
}
XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
if (workshop()->isFeatureOfNested(theFeature)) {