+ {
+ if (theFeature->data()) {
+ return theFeature;
+ } else {
+ ObjectPtr aObject = std::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
+ return aObject->featureRef();
+ }
+ }*/
+
+//******************************************************************
+bool canRemoveOrRename(QWidget* theParent, const QObjectPtrList& theObjects)
+{
+ bool aResult = true;
+ QString aNotActivatedNames;
+ if (!XGUI_Tools::allDocumentsActivated(aNotActivatedNames)) {
+ DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
+ bool aFoundPartSetObject = false;
+ foreach (ObjectPtr aObj, theObjects) {
+ if (aObj->groupName() == ModelAPI_ResultPart::group())
+ continue;
+ aFoundPartSetObject = aObj->document() == aModuleDoc;
+ }
+ 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),
+ QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+ aResult = aRes == QMessageBox::Yes;
+ }
+ }
+ return aResult;
+}
+
+//******************************************************************
+bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName)
+{
+ if (std::dynamic_pointer_cast<ModelAPI_ResultParameter>(theObject).get()) {
+ double aValue;
+ ResultParameterPtr aParam;
+ if (ModelAPI_Tools::findVariable(theObject->document(), qPrintable(theName), aValue, aParam)) {
+ QMessageBox::information(theParent, QObject::tr("Rename parameter"),
+ QString(QObject::tr("Selected parameter can not be renamed to: %1. \
+There is a parameter with the same name. Its value is: %2.")).arg(qPrintable(theName)).arg(aValue));
+ return false;
+ }
+ }
+
+ 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;
+}
+
+//**************************************************************
+void refsToFeatureInFeatureDocument(const ObjectPtr& theObject, std::set<FeaturePtr>& theRefFeatures)
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get()) {
+ DocumentPtr aFeatureDoc = aFeature->document();
+ // 1. find references in the current document
+ aFeatureDoc->refsToFeature(aFeature, theRefFeatures, false);
+ }
+}
+
+//**************************************************************
+bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)