X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParametersPlugin%2FParametersPlugin_WidgetParamsMgr.cpp;h=fa31070fa9cf2658e91ebd3e1ecd4b29857d5d91;hb=a13f87935d2a6f52f942790b6abc874f1016c9fc;hp=679d42896eb06ba690bb2fde4bd5e6fbc8edc11c;hpb=49d5a27258260087aad5e7ca30d6863e08a186d1;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp index 679d42896..fa31070fa 100644 --- a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp @@ -1,13 +1,28 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: ParametersPlugin_WidgetParamsMgr.cpp -// Created: 11 Apr 2016 -// Author: Vitaly SMETANNIKOV +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "ParametersPlugin_WidgetParamsMgr.h" #include "ParametersPlugin_Parameter.h" #include "ParametersPlugin_Validators.h" +#include + #include #include #include @@ -15,10 +30,18 @@ #include #include #include +#include +#include + +#include +#include #include +#include +#include #include +#include #include #include @@ -29,6 +52,8 @@ #include #include #include +#include +#include enum ColumnType { Col_Name, @@ -39,7 +64,6 @@ enum ColumnType { const char* NoName = ""; const char* NoValue = ""; -const char* NotValid = ""; /*! * \ingroup GUI @@ -50,23 +74,23 @@ class ParametersPlugin_ItemDelegate : public QStyledItemDelegate public: /// Constructor /// \param thaParent a parent - ParametersPlugin_ItemDelegate(QObject* thaParent) : + ParametersPlugin_ItemDelegate(QObject* thaParent) : QStyledItemDelegate(thaParent) {} /// Redefinition of virtual method /// \param painter a painter object /// \param option the item options /// \param index the current index - virtual void paint(QPainter* painter, - const QStyleOptionViewItem& option, + virtual void paint(QPainter* painter, + const QStyleOptionViewItem& option, const QModelIndex& index ) const; - + /// Redefinition of virtual method /// \param parent a parent widget /// \param option the item options /// \param index the current index - virtual QWidget* createEditor(QWidget* parent, - const QStyleOptionViewItem& option, + virtual QWidget* createEditor(QWidget* parent, + const QStyleOptionViewItem& option, const QModelIndex& index) const; /// Returns True if the given index is editable item @@ -91,13 +115,14 @@ bool ParametersPlugin_ItemDelegate::isEditable(const QModelIndex& theIndex) cons return true; } -void ParametersPlugin_ItemDelegate::paint(QPainter* painter, - const QStyleOptionViewItem& option, +void ParametersPlugin_ItemDelegate::paint(QPainter* painter, + const QStyleOptionViewItem& option, const QModelIndex& index ) const { QBrush aBrush = painter->brush(); QPen aPen = painter->pen(); -// if (!isEditable(index)) + //if (!isEditable(index)) + // painter->setBrush(Qt::lightGray); if (!index.parent().isValid()) painter->setBrush(Qt::lightGray); @@ -109,8 +134,8 @@ void ParametersPlugin_ItemDelegate::paint(QPainter* painter, painter->setBrush(aBrush); } -QWidget* ParametersPlugin_ItemDelegate::createEditor(QWidget* parent, - const QStyleOptionViewItem& option, +QWidget* ParametersPlugin_ItemDelegate::createEditor(QWidget* parent, + const QStyleOptionViewItem& option, const QModelIndex& index) const { myEditingIdx = index; @@ -118,7 +143,8 @@ QWidget* ParametersPlugin_ItemDelegate::createEditor(QWidget* parent, } ///////////////////////////////////////////////////////////////////////////////////////////////// -void ParametersPlugin_TreeWidget::closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint) +void ParametersPlugin_TreeWidget::closeEditor(QWidget* theEditor, + QAbstractItemDelegate::EndEditHint theHint) { if (theHint == QAbstractItemDelegate::EditNextItem) { QModelIndex aCurrent = currentIndex(); @@ -153,15 +179,18 @@ void ParametersPlugin_TreeWidget::closeEditor(QWidget* theEditor, QAbstractItemD ///////////////////////////////////////////////////////////////////////////////////////////////// -ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData) - : ModuleBase_ModelWidget(theParent, theData) +ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent, + const Config_WidgetAPI* theData, ModuleBase_IWorkshop* theWorkshop) + : ModuleBase_ModelDialogWidget(theParent, theData), + myWorkshop(theWorkshop), isUpplyBlocked(false) { QVBoxLayout* aLayout = new QVBoxLayout(this); myTable = new ParametersPlugin_TreeWidget(this); myTable->setColumnCount(4); QStringList aHeaders; - aHeaders << tr("Name") << tr("Equation") << tr("Result") << tr("Comment"); + aHeaders << translate("Name") << translate("Expression") + << translate("Result") << translate("Comment"); myTable->setHeaderLabels(aHeaders); myTable->setColumnWidth(Col_Name, 200); myTable->setColumnWidth(Col_Equation, 100); @@ -176,7 +205,7 @@ ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theP connect(myTable, SIGNAL(itemSelectionChanged()), SLOT(onSelectionChanged())); myDelegate = new ParametersPlugin_ItemDelegate(myTable); - connect(myDelegate, SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)), + connect(myDelegate, SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)), SLOT(onCloseEditor(QWidget*, QAbstractItemDelegate::EndEditHint))); myTable->setItemDelegate(myDelegate); @@ -184,13 +213,13 @@ ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theP // Define root nodes QStringList aNames; - aNames<setFlags(Qt::ItemIsEnabled); myTable->addTopLevelItem(myParameters); aNames.clear(); - aNames<setFlags(Qt::ItemIsEnabled); myTable->addTopLevelItem(myFeatures); @@ -209,15 +238,22 @@ ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theP aBtnLayout->addStretch(); - myAddBtn = new QPushButton(tr("Add"), this); + myAddBtn = new QPushButton(translate("Add"), this); connect(myAddBtn, SIGNAL(clicked(bool)), SLOT(onAdd())); aBtnLayout->addWidget(myAddBtn); - myInsertBtn = new QPushButton(tr("Insert"), this); + QString aAddStr(Config_PropManager::string("Shortcuts", "add_parameter_shortcut").c_str()); + if (aAddStr.isEmpty()) + aAddStr = "Ctrl+A"; + + QShortcut* aAddShc = new QShortcut(QKeySequence(aAddStr), myAddBtn); + connect(aAddShc, SIGNAL(activated()), SLOT(onAdd())); + + myInsertBtn = new QPushButton(translate("Insert"), this); connect(myInsertBtn, SIGNAL(clicked(bool)), SLOT(onInsert())); aBtnLayout->addWidget(myInsertBtn); - myRemoveBtn = new QPushButton(tr("Remove"), this); + myRemoveBtn = new QPushButton(translate("Remove"), this); connect(myRemoveBtn, SIGNAL(clicked(bool)), SLOT(onRemove())); aBtnLayout->addWidget(myRemoveBtn); @@ -226,6 +262,20 @@ ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theP onSelectionChanged(); } +void ParametersPlugin_WidgetParamsMgr::setDialogButtons(QDialogButtonBox* theButtons) +{ + ModuleBase_ModelDialogWidget::setDialogButtons(theButtons); + + QWidget* aBtnParentWgt = myOkCancelBtn->parentWidget(); + QHBoxLayout* aBtnParentLayout = dynamic_cast(aBtnParentWgt->layout()); + + QPushButton* aPreviewBtn = new QPushButton(translate("See preview"), aBtnParentWgt); + aBtnParentLayout->insertWidget(0, aPreviewBtn); + aBtnParentLayout->insertStretch(1, 1); + connect(aPreviewBtn, SIGNAL(clicked(bool)), SLOT(onShowPreview())); +} + + QList ParametersPlugin_WidgetParamsMgr::getControls() const { QList aList; @@ -239,7 +289,7 @@ void ParametersPlugin_WidgetParamsMgr::selectItemScroll(QTreeWidgetItem* aItem) QModelIndex aParent = myTable->model()->index(0, 0); int aChildIdx = myParameters->indexOfChild(aItem); QModelIndex aIndex = myTable->model()->index(aChildIdx, Col_Name, aParent); - myTable->selectionModel()->select(aIndex, + myTable->selectionModel()->select(aIndex, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); myTable->scrollToItem(aItem); } @@ -250,16 +300,21 @@ bool ParametersPlugin_WidgetParamsMgr::storeValueCustom() ParametersPlugin_ExpressionValidator aValidator; std::list aArgs; std::string aAttrId = ParametersPlugin_Parameter::VARIABLE_ID(); - std::string aErr; + Events_InfoMessage aErr; int aId = 0; foreach(FeaturePtr aFeature, myParametersList) { if (!aValidator.isValid(aFeature->attribute(aAttrId), aArgs, aErr)) { - QMessageBox::warning(this, tr("Warning"), aErr.c_str()); + QMessageBox::warning(this, translate("Warning"), aErr.messageString().c_str()); selectItemScroll(myParameters->child(aId)); return false; } aId++; } + // #2813 : make the current feature the latest in the document + std::list allFeatures = myFeature->document()->allFeatures(); + if (!allFeatures.empty()) { + myFeature->document()->setCurrentFeature(*(allFeatures.rbegin()), true); + } return true; } @@ -288,7 +343,7 @@ void ParametersPlugin_WidgetParamsMgr::updateParametersFeatures() int aNbFeatures = aDoc->numInternalFeatures(); for (int i = 0; i < aNbFeatures; i++) { aParamFeature = aDoc->internalFeature(i); - if (aParamFeature->getKind() == ParametersPlugin_Parameter::ID()) { + if (aParamFeature && aParamFeature->getKind() == ParametersPlugin_Parameter::ID()) { myParametersList.append(aParamFeature); } } @@ -296,23 +351,23 @@ void ParametersPlugin_WidgetParamsMgr::updateParametersFeatures() void ParametersPlugin_WidgetParamsMgr::updateFeaturesPart() { - updateItem(myFeatures, featuresItems(myParametersList)); + QList aFeatureList; + updateItem(myFeatures, featuresItems(myParametersList, aFeatureList)); } void ParametersPlugin_WidgetParamsMgr::updateParametersPart() { updateItem(myParameters, parametersItems(myParametersList)); - bool aIsValid = checkIsValid(); + bool aIsValid = isValid(); enableButtons(aIsValid); } QList ParametersPlugin_WidgetParamsMgr:: - featuresItems(const QList& theFeatures) const + featuresItems(const QList& theFeatures, QList& theFeatureList) const { QList aItemsList; ResultParameterPtr aParam; - QList aFeatures; foreach(FeaturePtr aParameter, theFeatures) { aParam = std::dynamic_pointer_cast(aParameter->firstResult()); const std::set>& aRefs = aParam->data()->refsToMe(); @@ -320,31 +375,55 @@ QList ParametersPlugin_WidgetParamsMgr:: for(aIt = aRefs.cbegin(); aIt != aRefs.cend(); aIt++) { std::shared_ptr aAttr = (*aIt); FeaturePtr aReferenced = std::dynamic_pointer_cast(aAttr->owner()); - if (aReferenced.get()) { + if (aReferenced.get() && (aReferenced != aParameter)) { if (aReferenced->getKind() == ParametersPlugin_Parameter::ID()) { // Find referenced feature Recursive QList aList; aList.append(aReferenced); - QList aItems = featuresItems(aList); + QList aItems = featuresItems(aList, theFeatureList); aItemsList.append(aItems); } else { - if (!aFeatures.contains(aReferenced)) { + if (!theFeatureList.contains(aReferenced)) { QStringList aValNames; - aValNames << aReferenced->data()->name().c_str(); + aValNames << QString::fromStdWString(aReferenced->data()->name()); - AttributeDoublePtr aDouble = std::dynamic_pointer_cast(aAttr); - if (aDouble.get()) { + std::string aId = aAttr->attributeType(); + if (aId == ModelAPI_AttributeDouble::typeId()) { + AttributeDoublePtr aDouble = + std::dynamic_pointer_cast(aAttr); aValNames << aDouble->text().c_str(); aValNames << QString::number(aDouble->value()); - } else { - AttributeIntegerPtr aInt = std::dynamic_pointer_cast(aAttr); - if (aInt.get()) { - aValNames << aInt->text().c_str(); - aValNames << QString::number(aInt->value()); - } + } + else if (aId == ModelAPI_AttributeInteger::typeId()) { + AttributeIntegerPtr aInt = + std::dynamic_pointer_cast(aAttr); + aValNames << aInt->text().c_str(); + aValNames << QString::number(aInt->value()); + } + else if (aId == GeomDataAPI_Point::typeId()) { + std::shared_ptr aPnt = + std::dynamic_pointer_cast(aAttr); + + QString aExpr = QString("%1,%2,%3").arg(aPnt->textX().c_str()). + arg(aPnt->textY().c_str()).arg(aPnt->textZ().c_str()); + aValNames << aExpr; + + QString aRes = QString("%1,%2,%3").arg(aPnt->x()).arg(aPnt->y()).arg(aPnt->z()); + aValNames << aRes; + } + else if (aId == GeomDataAPI_Point2D::typeId()) { + std::shared_ptr aPnt = + std::dynamic_pointer_cast(aAttr); + + QString aExpr = QString("%1,%2").arg(aPnt->textX().c_str()). + arg(aPnt->textY().c_str()); + aValNames << aExpr; + + QString aRes = QString("%1,%2").arg(aPnt->x()).arg(aPnt->y()); + aValNames << aRes; } aItemsList.append(aValNames); - aFeatures.append(aReferenced); + theFeatureList.append(aReferenced); } } } @@ -366,17 +445,18 @@ QList ParametersPlugin_WidgetParamsMgr:: std::string aName = aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->value(); if (aName.empty()) { - aValues << NoName; + aValues << translate(NoName); } else aValues << aName.c_str(); std::string aExpr = aParameter->string(ParametersPlugin_Parameter::EXPRESSION_ID())->value(); if (aName.empty()) { - aValues << NoValue; + aValues << translate(NoValue); } else aValues << aExpr.c_str(); - std::string aErr = aParameter->data()->string(ParametersPlugin_Parameter::EXPRESSION_ERROR_ID())->value(); + std::string aErr = + aParameter->data()->string(ParametersPlugin_Parameter::EXPRESSION_ERROR_ID())->value(); if (aErr.empty()) { AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); aValues << QString::number(aValueAttribute->value()); @@ -398,7 +478,7 @@ void ParametersPlugin_WidgetParamsMgr::onDoubleClick(const QModelIndex& theIndex } } -void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor, +void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint) { FeaturePtr aFeature = myParametersList.at(myDelegate->editIndex().row()); @@ -416,18 +496,19 @@ void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor, aText.replace(" ", ""); } if (hasName(aText)) { - myMessage = tr("Name %1 already exists.").arg(aText); + myMessage = translate("Name '%1' already exists.").arg(aText); QTimer::singleShot(50, this, SLOT(sendWarning())); return; } aStringAttr->setValue(aText.toStdString()); isModified = true; - } + } } break; case Col_Equation: { - AttributeStringPtr aStringAttr = aFeature->string(ParametersPlugin_Parameter::EXPRESSION_ID()); + AttributeStringPtr aStringAttr = + aFeature->string(ParametersPlugin_Parameter::EXPRESSION_ID()); if (!aText.isEmpty()) { if (aText != aStringAttr->value().c_str()) { aStringAttr->setValue(aText.toStdString()); @@ -453,20 +534,22 @@ void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor, aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); - if (aColumn == Col_Equation) + if (aColumn != Col_Comment) updateParametersPart(); updateFeaturesPart(); + + onSelectionChanged(); } -void ParametersPlugin_WidgetParamsMgr::updateItem(QTreeWidgetItem* theItem, +void ParametersPlugin_WidgetParamsMgr::updateItem(QTreeWidgetItem* theItem, const QList& theFeaturesList) { if (theFeaturesList.count() != theItem->childCount()) { if (theItem->childCount() < theFeaturesList.count()) { - while (theItem->childCount() != theFeaturesList.count()) + while (theItem->childCount() != theFeaturesList.count()) theItem->addChild(createNewItem(theItem)); } else { - while (theItem->childCount() != theFeaturesList.count()) + while (theItem->childCount() != theFeaturesList.count()) theItem->removeChild(theItem->child(theItem->childCount() - 1)); } } @@ -501,13 +584,14 @@ FeaturePtr ParametersPlugin_WidgetParamsMgr::createParameter() const QTreeWidgetItem* ParametersPlugin_WidgetParamsMgr::createNewItem(QTreeWidgetItem* theParent) const { QStringList aValues; - aValues << NoName; - aValues << NoValue; + aValues << translate(NoName); + aValues << translate(NoValue); QTreeWidgetItem* aItem = new QTreeWidgetItem(aValues); - if (theParent == myParameters) + if (theParent == myParameters) { aItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); - else + aItem->setForeground(2, Qt::darkGray); + } else aItem->setFlags(Qt::NoItemFlags); return aItem; } @@ -520,7 +604,7 @@ void ParametersPlugin_WidgetParamsMgr::onAdd() return; myParametersList.append(aFeature); - updateParametersPart(); + updateParametersPart(); QTreeWidgetItem* aItem = myParameters->child(myParameters->childCount() - 1); @@ -588,26 +672,16 @@ void ParametersPlugin_WidgetParamsMgr::onRemove() QObjectPtrList anObjects; anObjects.append(aCurFeature); - std::set aDirectRefFeatures, aIndirectRefFeatures; - ModuleBase_Tools::findReferences(anObjects, aDirectRefFeatures, aIndirectRefFeatures); + std::map > aReferences; + std::set aFeatures; + ModuleBase_Tools::convertToFeatures(anObjects, aFeatures); + ModelAPI_Tools::findAllReferences(aFeatures, aReferences); - bool doDeleteReferences = true; - if (ModuleBase_Tools::isDeleteFeatureWithReferences(anObjects, aDirectRefFeatures, - aIndirectRefFeatures, this, doDeleteReferences)) { - - std::set aFeaturesToDelete; - if (doDeleteReferences) { - aFeaturesToDelete = aDirectRefFeatures; - aFeaturesToDelete.insert(aIndirectRefFeatures.begin(), aIndirectRefFeatures.end()); - } - aDoc->removeFeature(aCurFeature); - std::set::const_iterator anIt = aFeaturesToDelete.begin(), - aLast = aFeaturesToDelete.end(); - for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt); - DocumentPtr aDoc = aFeature->document(); - aDoc->removeFeature(aFeature); - } + std::set aFeatureRefsToDelete; + if (ModuleBase_Tools::askToDelete(aFeatures, aReferences, this, aFeatureRefsToDelete)) { + if (!aFeatureRefsToDelete.empty()) + aFeatures.insert(aFeatureRefsToDelete.begin(), aFeatureRefsToDelete.end()); + ModelAPI_Tools::removeFeatures(aFeatures, false); Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)); Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -695,7 +769,7 @@ bool ParametersPlugin_WidgetParamsMgr::hasName(const QString& theName) const int aCurrent = myDelegate->editIndex().row(); int i = 0; foreach(FeaturePtr aFeature, myParametersList) { - if ((i != aCurrent) && (aFeature->data()->name() == theName.toStdString())) + if ((i != aCurrent) && (aFeature->data()->name() == theName.toStdWString())) return true; i++; } @@ -704,14 +778,17 @@ bool ParametersPlugin_WidgetParamsMgr::hasName(const QString& theName) const void ParametersPlugin_WidgetParamsMgr::sendWarning() { - QMessageBox::warning(this, tr("Warning"), myMessage); + QMessageBox::warning(this, translate("Warning"), myMessage); + QTreeWidgetItem* aItem = myTable->currentItem(); + if (aItem) + myTable->editItem(aItem); } void ParametersPlugin_WidgetParamsMgr::onSelectionChanged() { - bool isValid = checkIsValid(); - if (isValid) { - QList aItemsList = myTable->selectedItems(); + QList aItemsList = myTable->selectedItems(); + bool aIsValid = isValid(); + if (aIsValid) { bool isParameter = false; foreach(QTreeWidgetItem* aItem, aItemsList) { if (aItem->parent() == myParameters) { @@ -720,41 +797,67 @@ void ParametersPlugin_WidgetParamsMgr::onSelectionChanged() } } myInsertBtn->setEnabled(isParameter); - myRemoveBtn->setEnabled(isParameter); + //myRemoveBtn->setEnabled(isParameter); myUpBtn->setEnabled(isParameter); myDownBtn->setEnabled(isParameter); } else { myInsertBtn->setEnabled(false); - myRemoveBtn->setEnabled(false); + //myRemoveBtn->setEnabled(false); myUpBtn->setEnabled(false); myDownBtn->setEnabled(false); } + myRemoveBtn->setEnabled(!aItemsList.isEmpty()); } void ParametersPlugin_WidgetParamsMgr::enableButtons(bool theEnable) { myAddBtn->setEnabled(theEnable); - if (theEnable) + if (theEnable) onSelectionChanged(); else { myInsertBtn->setEnabled(theEnable); - myRemoveBtn->setEnabled(theEnable); + //myRemoveBtn->setEnabled(theEnable); myUpBtn->setEnabled(theEnable); myDownBtn->setEnabled(theEnable); } + myOkCancelBtn->button(QDialogButtonBox::Ok)->setEnabled(theEnable); } -bool ParametersPlugin_WidgetParamsMgr::checkIsValid() +bool ParametersPlugin_WidgetParamsMgr::isValid() { QTreeWidgetItem* aItem; - bool aIsValid = true; for(int i = 0; i < myParameters->childCount(); i++) { aItem = myParameters->child(i); - if ((aItem->text(Col_Name) == NoName) || (aItem->text(Col_Equation) == NoValue)) { - aIsValid = false; - break; + if ((aItem->text(Col_Name) == NoName) || + (aItem->text(Col_Equation) == translate(NoValue)) || + (!ModelAPI_Expression::isVariable(aItem->text(Col_Name).toStdString())) ) { + return false; } } - return aIsValid; + return true; +} + +void ParametersPlugin_WidgetParamsMgr::showEvent(QShowEvent* theEvent) +{ + ModuleBase_ModelDialogWidget::showEvent(theEvent); + SessionPtr aMgr = ModelAPI_Session::get(); + isUpplyBlocked = aMgr->isAutoUpdateBlocked(); + aMgr->blockAutoUpdate(true); + Events_Loop* aLoop = Events_Loop::loop(); + aLoop->flush(aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE)); } +void ParametersPlugin_WidgetParamsMgr::hideEvent(QHideEvent* theEvent) +{ + ModuleBase_ModelDialogWidget::hideEvent(theEvent); + SessionPtr aMgr = ModelAPI_Session::get(); + aMgr->blockAutoUpdate(isUpplyBlocked); +} + +void ParametersPlugin_WidgetParamsMgr::onShowPreview() +{ + SessionPtr aMgr = ModelAPI_Session::get(); + aMgr->blockAutoUpdate(false); + aMgr->blockAutoUpdate(true); + myWorkshop->viewer()->update(); +}