X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_Tools.cpp;h=a60e3c2bb875230bac764226e769b7b16d20b6d0;hb=d3b52be3c4baef3776ee87bf5c194d33b0d4aa4d;hp=8b09ef91aed1d2169bd03f8a8a0cd4568bd20485;hpb=5dd20824a5f43d2b9f54a79986b659251c2489a1;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 8b09ef91a..a60e3c2bb 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -45,7 +45,6 @@ #include #include -#include #include #include #include @@ -183,28 +182,32 @@ QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon) { QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon); QImage anAditional(theAdditionalIcon); + return composite(anAditional, anIcon); +} - if (anIcon.isNull()) +QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon) +{ + if (theIcon.isNull()) return QPixmap(); - int anAddWidth = anAditional.width(); - int anAddHeight = anAditional.height(); + int anAddWidth = theAdditionalIcon.width(); + int anAddHeight = theAdditionalIcon.height(); - int aWidth = anIcon.width(); - int aHeight = anIcon.height(); + int aWidth = theIcon.width(); + int aHeight = theIcon.height(); - int aStartWidthPos = aWidth - anAddWidth - 1; - int aStartHeightPos = aHeight - anAddHeight - 1; + int aStartWidthPos = aWidth - anAddWidth; + int aStartHeightPos = aHeight - anAddHeight; for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++) { for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++) { - if (qAlpha(anAditional.pixel(i, j)) > 0) - anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j)); + if (qAlpha(theAdditionalIcon.pixel(i, j)) > 0) + theIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, theAdditionalIcon.pixel(i, j)); } } - return QPixmap::fromImage(anIcon); + return QPixmap::fromImage(theIcon); } QPixmap lighter(const QString& theIcon, const int theLighterValue) @@ -680,18 +683,16 @@ bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject, } else if (aType == ModelAPI_AttributeSelection::typeId()) { AttributeSelectionPtr aSelectAttr = std::dynamic_pointer_cast(theAttribute); - ResultPtr aResult = std::dynamic_pointer_cast(theObject); if (aSelectAttr.get() != NULL) { - aSelectAttr->setValue(aResult, theShape, theTemporarily); + aSelectAttr->setValue(theObject, theShape, theTemporarily); } } if (aType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aSelectionListAttr = std::dynamic_pointer_cast(theAttribute); - ResultPtr aResult = std::dynamic_pointer_cast(theObject); if (!theCheckIfAttributeHasObject || - !aSelectionListAttr->isInList(aResult, theShape, theTemporarily)) - aSelectionListAttr->append(aResult, theShape, theTemporarily); + !aSelectionListAttr->isInList(theObject, theShape, theTemporarily)) + aSelectionListAttr->append(theObject, theShape, theTemporarily); } else if (aType == ModelAPI_AttributeRefList::typeId()) { AttributeRefListPtr aRefListAttr = @@ -1025,7 +1026,8 @@ bool askToDelete(const std::set theFeatures, .arg(anOtherFeatureNames.join(aSep)); } if (!aParamFeatureNames.empty()) { - const char* aMsg = "Parameters are used in the following features: %1.\nThese features will " + const char* aMsg = "Parameters are used directly and through a sequence " + "of dependencies in the following features: %1.\nThese features will " "be deleted.\nOr parameters could be replaced by their values.\n"; aText += QString(QObject::tr(aMsg)) .arg(aParamFeatureNames.join(aSep)); @@ -1269,6 +1271,31 @@ FeaturePtr findParameter(const QString& theName) } +//******************************************************************** +std::string generateName(const AttributePtr& theAttribute, + ModuleBase_IWorkshop* theWorkshop) +{ + std::string aName; + if (theAttribute.get() != NULL) { + ModuleBase_Operation* anOperation = theWorkshop->currentOperation(); + + FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); + if (aFeature.get()) { + std::string aXmlCfg, aDescription; + theWorkshop->module()->getXMLRepresentation(aFeature->getKind(), aXmlCfg, aDescription); + + ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop); + std::string anAttributeTitle; + aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle); + + std::stringstream aStreamName; + aStreamName << theAttribute->owner()->data()->name() << "/" << anAttributeTitle.c_str(); + aName = aStreamName.str(); + } + } + return aName; +} + } // namespace ModuleBase_Tools