#include <QMessageBox>
#include <QAction>
#include <QTextCodec>
+#include <QWindow>
+#include <QScreen>
#include <sstream>
#include <string>
void setFocus(QWidget* theWidget, const QString& theInfo)
{
- activateWindow(theWidget);
theWidget->setFocus();
// rectangle of focus is not visible on tool button widgets
- theWidget->repaint();
+ theWidget->update();
#ifdef DEBUG_SET_FOCUS
qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str());
#endif
void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue)
{
- if (fabs(theSpin->value() - theValue) < tolerance)
+ if (!theSpin->text().isEmpty() && fabs(theSpin->value() - theValue) < tolerance)
return;
bool isBlocked = theSpin->blockSignals(true);
theSpin->setValue(theValue);
if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
if (ModuleBase_Tools::hasModuleDocumentFeature(theFeatures))
aNotActivatedDocWrn =
- QObject::tr("Selected objects can be used in Part documents which are not loaded:%1.\n")
+ QObject::tr("Selected objects can be used in Part documents which are not loaded: %1.\n")
.arg(aNotActivatedNames.c_str());
}
aFile = std::string(anEnv) +
FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
} else {
- anEnv = getenv("OPENPARTS_ROOT_DIR");
+ anEnv = getenv("CADBUILDER_ROOT_DIR");
if (anEnv)
aFile = std::string(anEnv) + FSEP + "resources";
}
return aName;
}
+bool isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2)
+{
+ // In case of compound we cannot rely on simple comparison method.
+ // If the compound is generated by Group feature then this compound is alwais new.
+ // So, we have to compare content of these compounds
+ if (theShape1.ShapeType() != theShape2.ShapeType())
+ return false;
+
+ if (theShape1.ShapeType() != TopAbs_COMPOUND)
+ return theShape1.IsSame(theShape2);
+
+ TopoDS_Iterator aIt1(theShape1);
+ TopoDS_Iterator aIt2(theShape2);
+
+ for (; aIt1.More() && aIt2.More(); aIt1.Next(), aIt2.Next()) {
+ if (!(aIt1.Value()).IsSame(aIt2.Value()))
+ return false;
+ }
+ return true;
+}
+
+qreal currentPixelRatio()
+{
+ QWindowList aWnds = qApp->topLevelWindows();
+ if (aWnds.size() > 0)
+ return aWnds.first()->devicePixelRatio();
+ return qApp->primaryScreen()->devicePixelRatio();
+}
+
+
} // namespace ModuleBase_Tools