X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModuleBase%2FModuleBase_Tools.cpp;h=13d1d22d69b7298e9d20e35eef91ef5b4e4f4310;hb=f9fd953bf814fad40ae045f6164c7f80229b0872;hp=1d87b4ae22475427772f15b6eefe99eb075f9f67;hpb=653805f5d615b18e3a5a9640a86ae55ba5779d69;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 1d87b4ae2..13d1d22d6 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -5,11 +5,15 @@ // Author: Vitaly Smetannikov #include "ModuleBase_Tools.h" +#include #include #include #include #include +#include +#include +#include #include #include @@ -20,6 +24,8 @@ #include #include +#include + namespace ModuleBase_Tools { //****************************************************************** @@ -107,8 +113,30 @@ QPixmap lighter(const QString& theIcon, const int theLighterValue) return QPixmap::fromImage(aResult); } +void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText) +{ + if (theSpin->text() == theText) + return; + // In order to avoid extra text setting because it will + // reset cursor position in control + bool isBlocked = theSpin->blockSignals(true); + theSpin->setText(theText); + theSpin->blockSignals(isBlocked); +} + void setSpinValue(QDoubleSpinBox* theSpin, double theValue) { + if (theSpin->value() == theValue) + return; + bool isBlocked = theSpin->blockSignals(true); + theSpin->setValue(theValue); + theSpin->blockSignals(isBlocked); +} + +void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue) +{ + //if (theSpin->value() == theValue) + // return; bool isBlocked = theSpin->blockSignals(true); theSpin->setValue(theValue); theSpin->blockSignals(isBlocked); @@ -116,18 +144,33 @@ void setSpinValue(QDoubleSpinBox* theSpin, double theValue) QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) { + QString aFeatureStr = "feature"; + if (!theObj.get()) + return aFeatureStr; + + std::ostringstream aPtrStr; + aPtrStr << "[" << theObj.get() << "]"; + ResultPtr aRes = std::dynamic_pointer_cast(theObj); FeaturePtr aFeature = std::dynamic_pointer_cast(theObj); - QString aFeatureStr = "feature"; if(aRes.get()) { - aFeatureStr.append("(Result)"); + aFeatureStr.append(QString("(result%1)").arg(aPtrStr.str().c_str()).toStdString() .c_str()); + if (aRes->isDisabled()) + aFeatureStr.append("[disabled]"); + if (aRes->isConcealed()) + aFeatureStr.append("[concealed]"); + aFeature = ModelAPI_Feature::feature(aRes); } + else + aFeatureStr.append(aPtrStr.str().c_str()); + if (aFeature.get()) { aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str()); - if (aFeature->data().get() && aFeature->data()->isValid()) + if (aFeature->data()->isValid()) { aFeatureStr.append(QString(", name=%1").arg(aFeature->data()->name().c_str()).toStdString() .c_str()); + } if (isUseAttributesInfo) { std::list anAttrs = aFeature->data()->attributes(""); std::list::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end(); @@ -179,6 +222,43 @@ TopAbs_ShapeEnum shapeType(const QString& theType) return TopAbs_SHAPE; } +bool isSubResult(ObjectPtr theObject) +{ + bool aSubResult = false; + + //ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(aResult); + return aSubResult; +} + +void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature) +{ + hasResult = false; + hasFeature = false; + hasParameter = false; + hasSubFeature = false; + foreach(ObjectPtr aObj, theObjects) { + FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); + ResultPtr aResult = std::dynamic_pointer_cast(aObj); + ResultParameterPtr aConstruction = std::dynamic_pointer_cast(aResult); + + bool aSubResult = isSubResult(aResult); + + /// results of compsolids are not processed in SHOW/HIDE/WIREFRAME operations + hasResult = (aResult.get() != NULL && !aSubResult); + hasFeature = (aFeature.get() != NULL); + hasParameter = (aConstruction.get() != NULL); + if (hasFeature) + hasSubFeature = (ModelAPI_Tools::compositeOwner(aFeature) != NULL); + if (hasFeature && hasResult && hasParameter && hasSubFeature) + break; + } +} + +double defaultDeviationCoefficient() +{ + // this value is chosen by performance check. Test case is an extrusion on sketch circle. + return 1.e-3; +} }