}
}
+//******************************************************************
+bool allDocumentsActivated(std::string& theNotActivatedNames)
+{
+ theNotActivatedNames = "";
+ bool anAllPartActivated = true;
+
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
+ for (int i = 0; i < aSize; i++) {
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+ if (!aPart->isActivated()) {
+ anAllPartActivated = false;
+ if (!theNotActivatedNames.empty())
+ theNotActivatedNames += ", ";
+ theNotActivatedNames += aObject->data()->name().c_str();
+ }
+ }
+ return anAllPartActivated;
+}
+
bool removeFeaturesAndReferences(const std::set<FeaturePtr>& theFeatures,
const bool theFlushRedisplay,
const bool theUseComposite,
*/
MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults);
+/*!
+ Returns true if there are no parts in the document, which are not activated
+ \param theNotActivatedNames out string which contains not activated names
+ \return a boolean value
+ */
+MODELAPI_EXPORT bool allDocumentsActivated(std::string& theNotActivatedNames);
+
/*! Removes features from the document
* \param theFeatures a list of features to be removed
return theObject->data()->attribute(attributeID())->isInitialized();
}
+void ModuleBase_ModelWidget::processValueState()
+{
+ myIsValueStateBlocked = false;
+ if (myState == ModifiedInPP || myState == ModifiedInViewer)
+ storeValue();
+ myState = Stored;
+}
+
QString ModuleBase_ModelWidget::getValueStateError() const
{
QString anError = "";
void ModuleBase_ModelWidget::deactivate()
{
- myIsValueStateBlocked = false;
- if (myState == ModifiedInPP || myState == ModifiedInViewer)
- storeValue();
- myState = Stored;
-
if (myWidgetValidator)
myWidgetValidator->activateFilters(false);
}
/// \return the enumeration result
ValueState getValueState() const { return myState; }
+ /// Stores the widget value if it is modified
+ void processValueState();
+
/// Returns an attribute error according to the value state
/// It exists in all cases excepring the "Store" case
QString getValueStateError() const;
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Point2D.h>
+#include <QMessageBox>
+
#include <string>
#include <set>
#include <sstream>
aParameter->data()->blockSendAttributeUpdated(false);
}
-#include <QMessageBox>
-#include <ModelAPI_ResultPart.h>
-bool allDocumentsActivated(QString& theNotActivatedNames)
-{
- bool anAllPartActivated = true;
- QStringList aRefNames;
-
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
- for (int i = 0; i < aSize; i++) {
- ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
- if (!aPart->isActivated()) {
- anAllPartActivated = false;
- aRefNames.append(aObject->data()->name().c_str());
- }
- }
- theNotActivatedNames = aRefNames.join(", ");
- return anAllPartActivated;
-}
-
void ParametersPlugin_EvalListener::processObjectRenamedEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
if (!aParameter.get())
return;
- QString aNotActivatedNames;
- if (!allDocumentsActivated(aNotActivatedNames)) {
+ std::string aNotActivatedNames;
+ if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
QMessageBox::StandardButton aRes = QMessageBox::warning(0, QObject::tr("Warning"),
QObject::tr("Selected objects can be used in Part documents which are not loaded: \
-%1. Whould you like to continue?").arg(aNotActivatedNames),
+%1. Whould you like to continue?").arg(aNotActivatedNames.c_str()),
QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (aRes != QMessageBox::Yes) {
setParameterName(aResultParameter, aMessage->oldName());
std::string aPreviosAttributeID;
if(myActiveWidget) {
aPreviosAttributeID = myActiveWidget->attributeID();
+ myActiveWidget->processValueState();
myActiveWidget->deactivate();
myActiveWidget->setHighlighted(false);
}
#include <iostream>
#include <sstream>
+#include <string>
namespace XGUI_Tools {
//******************************************************************
bool canRemoveOrRename(QWidget* theParent, const QObjectPtrList& theObjects)
{
bool aResult = true;
- QString aNotActivatedNames;
- if (!XGUI_Tools::allDocumentsActivated(aNotActivatedNames)) {
+ std::string aNotActivatedNames;
+ if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
bool aFoundPartSetObject = false;
foreach (ObjectPtr aObj, theObjects) {
if (aFoundPartSetObject) {
QMessageBox::StandardButton aRes = QMessageBox::warning(theParent, QObject::tr("Warning"),
QObject::tr("Selected objects can be used in Part documents which are not loaded: \
-%1. Whould you like to continue?").arg(aNotActivatedNames),
+%1. Whould you like to continue?").arg(aNotActivatedNames.c_str()),
QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
aResult = aRes == QMessageBox::Yes;
}
return true;
}
-//******************************************************************
-bool allDocumentsActivated(QString& theNotActivatedNames)
-{
- bool anAllPartActivated = true;
- QStringList aRefNames;
-
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
- for (int i = 0; i < aSize; i++) {
- ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
- if (!aPart->isActivated()) {
- anAllPartActivated = false;
- aRefNames.append(aObject->data()->name().c_str());
- }
- }
- theNotActivatedNames = aRefNames.join(", ");
- return anAllPartActivated;
-}
-
//**************************************************************
XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop)
*/
bool canRename(const ObjectPtr& theObject, const QString& theName);
-/*!
- Returns true if there are no parts in the document, which are not activated
- \param theNotActivatedNames out string which contains not activated names
- \return a boolean value
- */
-bool XGUI_EXPORT allDocumentsActivated(QString& theNotActivatedNames);
-
/*!
Returns converted workshop
\param theWorkshop an interface workshop