Base: Quantity: return std::string
This commit is contained in:
committed by
Yorik van Havre
parent
c11b37e312
commit
2ea8a633ac
@@ -2294,7 +2294,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
return Py::String(args[0]->getPyValue().as_string());
|
||||
case PARSEQUANT: {
|
||||
auto quantity_text = args[0]->getPyValue().as_string();
|
||||
auto quantity_object = Quantity::parse(QString::fromStdString(quantity_text));
|
||||
auto quantity_object = Quantity::parse(quantity_text);
|
||||
return Py::asObject(new QuantityPy(new Quantity(quantity_object)));
|
||||
}
|
||||
case TRANSLATIONM: {
|
||||
|
||||
@@ -1621,10 +1621,10 @@ void PropertyString::setPathValue(const ObjectIdentifier& path, const boost::any
|
||||
setValue(std::to_string(App::any_cast<float>(value)));
|
||||
}
|
||||
else if (value.type() == typeid(Quantity)) {
|
||||
setValue(boost::any_cast<Quantity>(value).getUserString().toUtf8().constData());
|
||||
setValue(boost::any_cast<Quantity>(value).getUserString().c_str());
|
||||
}
|
||||
else if (value.type() == typeid(std::string)) {
|
||||
setValue(boost::any_cast<const std::string&>(value));
|
||||
setValue(boost::any_cast<const std::string &>(value));
|
||||
}
|
||||
else {
|
||||
Base::PyGILStateLocker lock;
|
||||
|
||||
@@ -68,7 +68,7 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject* value)
|
||||
Base::Quantity quant;
|
||||
|
||||
if (PyUnicode_Check(value)) {
|
||||
quant = Quantity::parse(QString::fromUtf8(PyUnicode_AsUTF8(value)));
|
||||
quant = Quantity::parse(PyUnicode_AsUTF8(value));
|
||||
}
|
||||
else if (PyFloat_Check(value)) {
|
||||
quant = Quantity(PyFloat_AsDouble(value), _Unit);
|
||||
|
||||
+22
-16
@@ -28,6 +28,7 @@
|
||||
#include <array>
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <Base/Tools.h>
|
||||
#include "Quantity.h"
|
||||
#include "Exception.h"
|
||||
@@ -81,10 +82,10 @@ Quantity::Quantity(double value, const Unit& unit)
|
||||
, myUnit {unit}
|
||||
{}
|
||||
|
||||
Quantity::Quantity(double value, const QString& unit)
|
||||
Quantity::Quantity(double value, const std::string& unit)
|
||||
: myValue {0.0}
|
||||
{
|
||||
if (unit.isEmpty()) {
|
||||
if (unit.empty()) {
|
||||
this->myValue = value;
|
||||
this->myUnit = Unit();
|
||||
return;
|
||||
@@ -236,29 +237,34 @@ Quantity Quantity::operator-() const
|
||||
return Quantity(-(this->myValue), this->myUnit);
|
||||
}
|
||||
|
||||
QString Quantity::getUserString(double& factor, QString& unitString) const
|
||||
std::string Quantity::getUserString(double& factor, std::string& unitString) const
|
||||
{
|
||||
return Base::UnitsApi::schemaTranslate(*this, factor, unitString);
|
||||
QString str = QString::fromStdString(unitString);
|
||||
QString ret = Base::UnitsApi::schemaTranslate(*this, factor, str);
|
||||
unitString = str.toStdString();
|
||||
return ret.toStdString();
|
||||
}
|
||||
|
||||
QString Quantity::getUserString(UnitsSchema* schema, double& factor, QString& unitString) const
|
||||
std::string
|
||||
Quantity::getUserString(UnitsSchema* schema, double& factor, std::string& unitString) const
|
||||
{
|
||||
return schema->schemaTranslate(*this, factor, unitString);
|
||||
QString str = QString::fromStdString(unitString);
|
||||
QString ret = schema->schemaTranslate(*this, factor, str);
|
||||
unitString = str.toStdString();
|
||||
return ret.toStdString();
|
||||
}
|
||||
|
||||
QString Quantity::getSafeUserString() const
|
||||
std::string Quantity::getSafeUserString() const
|
||||
{
|
||||
auto retString = getUserString();
|
||||
if (Q_LIKELY(this->myValue != 0)) {
|
||||
auto feedbackQty = parse(retString);
|
||||
auto ret = getUserString();
|
||||
if (this->myValue) {
|
||||
auto feedbackQty = parse(ret);
|
||||
auto feedbackVal = feedbackQty.getValue();
|
||||
if (feedbackVal == 0) {
|
||||
retString = QStringLiteral("%1 %2").arg(this->myValue).arg(QString::fromStdString(this->getUnit().getString()));
|
||||
ret = fmt::format("{} {}", this->myValue, this->getUnit().getString());
|
||||
}
|
||||
}
|
||||
retString =
|
||||
QString::fromStdString(Base::Tools::escapeQuotesFromString(retString.toStdString()));
|
||||
return retString;
|
||||
return Base::Tools::escapeQuotesFromString(ret);
|
||||
}
|
||||
|
||||
/// true if it has a number without a unit
|
||||
@@ -562,11 +568,11 @@ private:
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
Quantity Quantity::parse(const QString& string)
|
||||
Quantity Quantity::parse(const std::string& string)
|
||||
{
|
||||
// parse from buffer
|
||||
QuantityParser::YY_BUFFER_STATE my_string_buffer =
|
||||
QuantityParser::yy_scan_string(string.toUtf8().data());
|
||||
QuantityParser::yy_scan_string(string.c_str());
|
||||
QuantityParser::StringBufferCleaner cleaner(my_string_buffer);
|
||||
// set the global return variables
|
||||
QuantResult = Quantity(DOUBLE_MIN);
|
||||
|
||||
+8
-8
@@ -25,7 +25,7 @@
|
||||
#define BASE_Quantity_H
|
||||
|
||||
#include "Unit.h"
|
||||
#include <QString>
|
||||
#include <string>
|
||||
|
||||
// NOLINTBEGIN
|
||||
#ifndef DOUBLE_MAX
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
Quantity(const Quantity&) = default;
|
||||
Quantity(Quantity&&) = default;
|
||||
explicit Quantity(double value, const Unit& unit = Unit());
|
||||
explicit Quantity(double value, const QString& unit);
|
||||
explicit Quantity(double value, const std::string& unit);
|
||||
/// Destruction
|
||||
~Quantity() = default;
|
||||
|
||||
@@ -166,17 +166,17 @@ public:
|
||||
myFormat = fmt;
|
||||
}
|
||||
/// transfer to user preferred unit/potence
|
||||
QString getUserString(double& factor, QString& unitString) const;
|
||||
QString getUserString() const
|
||||
std::string getUserString(double& factor, std::string& unitString) const;
|
||||
std::string getUserString() const
|
||||
{ // to satisfy GCC
|
||||
double dummy1 {};
|
||||
QString dummy2 {};
|
||||
std::string dummy2 {};
|
||||
return getUserString(dummy1, dummy2);
|
||||
}
|
||||
QString getUserString(UnitsSchema* schema, double& factor, QString& unitString) const;
|
||||
QString getSafeUserString() const;
|
||||
std::string getUserString(UnitsSchema* schema, double& factor, std::string& unitString) const;
|
||||
std::string getSafeUserString() const;
|
||||
|
||||
static Quantity parse(const QString& string);
|
||||
static Quantity parse(const std::string& string);
|
||||
|
||||
/// returns the unit of the quantity
|
||||
const Unit& getUnit() const
|
||||
|
||||
+10
-10
@@ -127,10 +127,10 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
char* string {};
|
||||
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
|
||||
QString qstr = QString::fromUtf8(string);
|
||||
std::string str(string);
|
||||
PyMem_Free(string);
|
||||
try {
|
||||
*self = Quantity::parse(qstr);
|
||||
*self = Quantity::parse(str);
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
@@ -142,7 +142,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
if (PyArg_ParseTuple(args, "det", &f, "utf-8", &string)) {
|
||||
QString unit = QString::fromUtf8(string);
|
||||
std::string unit(string);
|
||||
PyMem_Free(string);
|
||||
try {
|
||||
*self = Quantity(f, unit);
|
||||
@@ -161,15 +161,15 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyObject* QuantityPy::getUserPreferred(PyObject* /*args*/)
|
||||
{
|
||||
QString uus;
|
||||
std::string uus;
|
||||
double factor {};
|
||||
Py::Tuple res(3);
|
||||
|
||||
QString uss = getQuantityPtr()->getUserString(factor, uus);
|
||||
auto uss = getQuantityPtr()->getUserString(factor, uus);
|
||||
|
||||
res[0] = Py::String(uss.toUtf8(), "utf-8");
|
||||
res[0] = Py::String(uss, "utf-8");
|
||||
res[1] = Py::Float(factor);
|
||||
res[2] = Py::String(uus.toUtf8(), "utf-8");
|
||||
res[2] = Py::String(uus, "utf-8");
|
||||
|
||||
return Py::new_reference_to(res);
|
||||
}
|
||||
@@ -236,9 +236,9 @@ PyObject* QuantityPy::getValueAs(PyObject* args)
|
||||
PyErr_Clear();
|
||||
char* string {};
|
||||
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
|
||||
QString qstr = QString::fromUtf8(string);
|
||||
std::string str(string);
|
||||
PyMem_Free(string);
|
||||
quant = Quantity::parse(qstr);
|
||||
quant = Quantity::parse(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ void QuantityPy::setUnit(Py::Object arg)
|
||||
|
||||
Py::String QuantityPy::getUserString() const
|
||||
{
|
||||
return {getQuantityPtr()->getUserString().toUtf8(), "utf-8"};
|
||||
return {getQuantityPtr()->getUserString(), "utf-8"};
|
||||
}
|
||||
|
||||
Py::Dict QuantityPy::getFormat() const
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ Unit::Unit() //NOLINT
|
||||
Unit::Unit(const std::string& expr) // NOLINT
|
||||
{
|
||||
try {
|
||||
*this = Quantity::parse(QString::fromStdString(expr)).getUnit();
|
||||
*this = Quantity::parse(expr).getUnit();
|
||||
}
|
||||
catch (const Base::ParserError&) {
|
||||
Val = 0;
|
||||
|
||||
@@ -84,10 +84,10 @@ int UnitPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
// get string
|
||||
char* string {};
|
||||
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
|
||||
QString qstr = QString::fromUtf8(string);
|
||||
std::string str(string);
|
||||
PyMem_Free(string);
|
||||
try {
|
||||
*self = Quantity::parse(qstr).getUnit();
|
||||
*self = Quantity::parse(str).getUnit();
|
||||
return 0;
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
|
||||
@@ -184,7 +184,7 @@ QString UnitsApi::schemaTranslate(const Base::Quantity& quant, double& factor, Q
|
||||
double UnitsApi::toDouble(PyObject* args, const Base::Unit& u)
|
||||
{
|
||||
if (PyUnicode_Check(args)) {
|
||||
QString str = QString::fromUtf8(PyUnicode_AsUTF8(args));
|
||||
std::string str(PyUnicode_AsUTF8(args));
|
||||
// Parse the string
|
||||
Quantity q = Quantity::parse(str);
|
||||
if (q.getUnit() == u) {
|
||||
@@ -207,7 +207,7 @@ Quantity UnitsApi::toQuantity(PyObject* args, const Base::Unit& u)
|
||||
{
|
||||
double d {};
|
||||
if (PyUnicode_Check(args)) {
|
||||
QString str = QString::fromUtf8(PyUnicode_AsUTF8(args));
|
||||
std::string str(PyUnicode_AsUTF8(args));
|
||||
// Parse the string
|
||||
Quantity q = Quantity::parse(str);
|
||||
d = q.getValue();
|
||||
|
||||
@@ -87,10 +87,10 @@ PyObject* UnitsApi::sParseQuantity(PyObject* /*self*/, PyObject* args)
|
||||
}
|
||||
|
||||
Quantity rtn;
|
||||
QString qstr = QString::fromUtf8(pstr);
|
||||
std::string str(pstr);
|
||||
PyMem_Free(pstr);
|
||||
try {
|
||||
rtn = Quantity::parse(qstr);
|
||||
rtn = Quantity::parse(str);
|
||||
}
|
||||
catch (const Base::ParserError&) {
|
||||
PyErr_Format(PyExc_ValueError, "invalid unit expression \n");
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <QTreeWidget>
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
@@ -242,12 +244,10 @@ void NumberRange::throwIfOutOfRange(const Base::Quantity& value) const
|
||||
if (value.getValue() < minimum || value.getValue() > maximum) {
|
||||
Base::Quantity minVal(minimum, value.getUnit());
|
||||
Base::Quantity maxVal(maximum, value.getUnit());
|
||||
QString valStr = value.getUserString();
|
||||
QString minStr = minVal.getUserString();
|
||||
QString maxStr = maxVal.getUserString();
|
||||
QString error = QString::fromLatin1("Value out of range (%1 out of [%2, %3])").arg(valStr, minStr, maxStr);
|
||||
|
||||
throw Base::ValueError(error.toStdString());
|
||||
auto valStr = value.getUserString();
|
||||
auto minStr = minVal.getUserString();
|
||||
auto maxStr = maxVal.getUserString();
|
||||
throw Base::ValueError(fmt::format("Value out of range ({} out of [{}, {}])", valStr, minStr, maxStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ void DlgExpressionInput::checkExpression(const QString& text)
|
||||
auto * n = Base::freecad_dynamic_cast<NumberExpression>(result.get());
|
||||
if (n) {
|
||||
Base::Quantity value = n->getQuantity();
|
||||
QString msg = value.getUserString();
|
||||
|
||||
if (!value.isValid()) {
|
||||
throw Base::ValueError("Not a number");
|
||||
}
|
||||
else if (!impliedUnit.isEmpty()) {
|
||||
|
||||
auto msg = value.getUserString();
|
||||
if (!impliedUnit.isEmpty()) {
|
||||
if (!value.getUnit().isEmpty() && value.getUnit() != impliedUnit)
|
||||
throw Base::UnitsMismatchError("Unit mismatch between result and required unit");
|
||||
|
||||
@@ -302,7 +302,7 @@ void DlgExpressionInput::checkExpression(const QString& text)
|
||||
|
||||
}
|
||||
else if (!value.getUnit().isEmpty()) {
|
||||
msg += QString::fromUtf8(" (Warning: unit discarded)");
|
||||
msg += " (Warning: unit discarded)";
|
||||
|
||||
QPalette p(ui->msg->palette());
|
||||
p.setColor(QPalette::WindowText, Qt::red);
|
||||
@@ -311,7 +311,7 @@ void DlgExpressionInput::checkExpression(const QString& text)
|
||||
|
||||
numberRange.throwIfOutOfRange(value);
|
||||
|
||||
ui->msg->setText(msg);
|
||||
ui->msg->setText(QString::fromStdString(msg));
|
||||
}
|
||||
else {
|
||||
ui->msg->setText(QString::fromStdString(result->toString()));
|
||||
|
||||
@@ -152,7 +152,7 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
|
||||
}
|
||||
else { // the unit is valid and has the same type
|
||||
double convertValue =
|
||||
Base::Quantity::parse(QString::fromLatin1("1") + ui->UnitInput->text()).getValue();
|
||||
Base::Quantity::parse("1" + ui->UnitInput->text().toStdString()).getValue();
|
||||
// we got now e.g. for "1 in" the value '25.4' because 1 in = 25.4 mm
|
||||
// the result is now just quant / convertValue because the input is always in a base
|
||||
// unit (an input of "1 cm" will immediately be converted to "10 mm" by Gui::InputField
|
||||
|
||||
@@ -180,10 +180,10 @@ void EditableDatumLabel::stopEdit()
|
||||
Base::Quantity quantity = spinBox->value();
|
||||
|
||||
double factor{};
|
||||
QString unitStr;
|
||||
QString valueStr;
|
||||
std::string unitStr;
|
||||
std::string valueStr;
|
||||
valueStr = quantity.getUserString(factor, unitStr);
|
||||
label->string = SbString(valueStr.toUtf8().constData());
|
||||
label->string = SbString(valueStr.c_str());
|
||||
|
||||
spinBox->deleteLater();
|
||||
spinBox = nullptr;
|
||||
|
||||
+35
-41
@@ -169,10 +169,10 @@ void InputField::updateText(const Base::Quantity& quant)
|
||||
}
|
||||
|
||||
double dFactor;
|
||||
QString unitStr;
|
||||
QString txt = quant.getUserString(dFactor, unitStr);
|
||||
std::string unitStr;
|
||||
std::string txt = quant.getUserString(dFactor, unitStr);
|
||||
actUnitValue = quant.getValue()/dFactor;
|
||||
setText(txt);
|
||||
setText(QString::fromStdString(txt));
|
||||
}
|
||||
|
||||
void InputField::resizeEvent(QResizeEvent *)
|
||||
@@ -256,7 +256,7 @@ void InputField::newInput(const QString & text)
|
||||
}
|
||||
}
|
||||
else
|
||||
res = Quantity::parse(input);
|
||||
res = Quantity::parse(input.toStdString());
|
||||
}
|
||||
catch(Base::Exception &e){
|
||||
QString errorText = QString::fromLatin1(e.what());
|
||||
@@ -292,7 +292,7 @@ void InputField::newInput(const QString & text)
|
||||
}
|
||||
|
||||
double dFactor;
|
||||
QString unitStr;
|
||||
std::string unitStr;
|
||||
res.getUserString(dFactor, unitStr);
|
||||
actUnitValue = res.getValue()/dFactor;
|
||||
// Preserve previous format
|
||||
@@ -456,7 +456,7 @@ const Base::Unit& InputField::getUnit() const
|
||||
/// get stored, valid quantity as a string
|
||||
QString InputField::getQuantityString() const
|
||||
{
|
||||
return actQuantity.getUserString();
|
||||
return QString::fromStdString(actQuantity.getUserString());
|
||||
}
|
||||
|
||||
/// set, validate and display quantity from a string. Must match existing units.
|
||||
@@ -471,18 +471,18 @@ void InputField::setQuantityString(const QString& text)
|
||||
QString InputField::rawText() const
|
||||
{
|
||||
double factor;
|
||||
QString unit;
|
||||
std::string unit;
|
||||
double value = actQuantity.getValue();
|
||||
actQuantity.getUserString(factor, unit);
|
||||
return QString::fromLatin1("%1 %2").arg(value / factor).arg(unit);
|
||||
return QString::fromLatin1("%1 %2").arg(value / factor).arg(QString::fromStdString(unit));
|
||||
}
|
||||
|
||||
/// expects the string in C locale and internally converts it into the OS-specific locale
|
||||
void InputField::setRawText(const QString& text)
|
||||
{
|
||||
Base::Quantity quant = Base::Quantity::parse(text);
|
||||
Base::Quantity quant = Base::Quantity::parse(text.toStdString());
|
||||
// Input and then format the quantity
|
||||
newInput(quant.getUserString());
|
||||
newInput(QString::fromStdString(quant.getUserString()));
|
||||
updateText(actQuantity);
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ void InputField::setMinimum(double m)
|
||||
void InputField::setUnitText(const QString& str)
|
||||
{
|
||||
try {
|
||||
Base::Quantity quant = Base::Quantity::parse(str);
|
||||
Base::Quantity quant = Base::Quantity::parse(str.toStdString());
|
||||
setUnit(quant.getUnit());
|
||||
}
|
||||
catch (...) {
|
||||
@@ -544,9 +544,9 @@ void InputField::setUnitText(const QString& str)
|
||||
QString InputField::getUnitText()
|
||||
{
|
||||
double dFactor;
|
||||
QString unitStr;
|
||||
std::string unitStr;
|
||||
actQuantity.getUserString(dFactor, unitStr);
|
||||
return unitStr;
|
||||
return QString::fromStdString(unitStr);
|
||||
}
|
||||
|
||||
int InputField::getPrecision() const
|
||||
@@ -632,11 +632,11 @@ void InputField::focusInEvent(QFocusEvent *event)
|
||||
void InputField::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
try {
|
||||
if (Quantity::parse(this->text()).getUnit().isEmpty()) {
|
||||
if (Quantity::parse(this->text().toStdString()).getUnit().isEmpty()) {
|
||||
// if user didn't enter a unit, we virtually compensate
|
||||
// the multiplication factor induced by user unit system
|
||||
double factor;
|
||||
QString unitStr;
|
||||
std::string unitStr;
|
||||
actQuantity.getUserString(factor, unitStr);
|
||||
actQuantity = actQuantity * factor;
|
||||
}
|
||||
@@ -644,7 +644,7 @@ void InputField::focusOutEvent(QFocusEvent *event)
|
||||
catch (const Base::ParserError&) {
|
||||
// do nothing, let apply the last known good value
|
||||
}
|
||||
this->setText(actQuantity.getUserString());
|
||||
this->setText(QString::fromStdString(actQuantity.getUserString()));
|
||||
QLineEdit::focusOutEvent(event);
|
||||
}
|
||||
|
||||
@@ -655,35 +655,29 @@ void InputField::keyPressEvent(QKeyEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
double val = actUnitValue;
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Up:
|
||||
{
|
||||
double val = actUnitValue + StepSize;
|
||||
if (val > Maximum)
|
||||
val = Maximum;
|
||||
double dFactor;
|
||||
QString unitStr;
|
||||
actQuantity.getUserString(dFactor, unitStr);
|
||||
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(unitStr));
|
||||
event->accept();
|
||||
}
|
||||
val += StepSize;
|
||||
if (val > Maximum)
|
||||
val = Maximum;
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
{
|
||||
double val = actUnitValue - StepSize;
|
||||
if (val < Minimum)
|
||||
val = Minimum;
|
||||
double dFactor;
|
||||
QString unitStr;
|
||||
actQuantity.getUserString(dFactor, unitStr);
|
||||
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(unitStr));
|
||||
event->accept();
|
||||
}
|
||||
val -= StepSize;
|
||||
if (val < Minimum)
|
||||
val = Minimum;
|
||||
break;
|
||||
default:
|
||||
QLineEdit::keyPressEvent(event);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
double dFactor;
|
||||
std::string unitStr;
|
||||
actQuantity.getUserString(dFactor, unitStr);
|
||||
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void InputField::wheelEvent (QWheelEvent * event)
|
||||
@@ -705,10 +699,10 @@ void InputField::wheelEvent (QWheelEvent * event)
|
||||
val = Minimum;
|
||||
|
||||
double dFactor;
|
||||
QString unitStr;
|
||||
std::string unitStr;
|
||||
actQuantity.getUserString(dFactor, unitStr);
|
||||
|
||||
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(unitStr));
|
||||
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
|
||||
selectNumber();
|
||||
event->accept();
|
||||
}
|
||||
@@ -737,10 +731,10 @@ QValidator::State InputField::validate(QString& input, int& pos) const
|
||||
Quantity res;
|
||||
QString text = input;
|
||||
fixup(text);
|
||||
res = Quantity::parse(text);
|
||||
res = Quantity::parse(text.toStdString());
|
||||
|
||||
double factor;
|
||||
QString unitStr;
|
||||
std::string unitStr;
|
||||
res.getUserString(factor, unitStr);
|
||||
double value = res.getValue()/factor;
|
||||
// disallow to enter numbers out of range
|
||||
|
||||
+13
-14
@@ -608,7 +608,7 @@ void QuantitySpinBox::setUnit(const Base::Unit &unit)
|
||||
void QuantitySpinBox::setUnitText(const QString& str)
|
||||
{
|
||||
try {
|
||||
Base::Quantity quant = Base::Quantity::parse(str);
|
||||
Base::Quantity quant = Base::Quantity::parse(str.toStdString());
|
||||
setUnit(quant.getUnit());
|
||||
}
|
||||
catch (const Base::ParserError&) {
|
||||
@@ -712,25 +712,26 @@ void QuantitySpinBox::clearSchema()
|
||||
QString QuantitySpinBox::getUserString(const Base::Quantity& val, double& factor, QString& unitString) const
|
||||
{
|
||||
Q_D(const QuantitySpinBox);
|
||||
if (d->scheme) {
|
||||
return val.getUserString(d->scheme.get(), factor, unitString);
|
||||
}
|
||||
else {
|
||||
return val.getUserString(factor, unitString);
|
||||
}
|
||||
std::string unitStr;
|
||||
std::string str = d->scheme ? val.getUserString(d->scheme.get(), factor, unitStr)
|
||||
: val.getUserString(factor, unitStr);
|
||||
unitString = QString::fromStdString(unitStr);
|
||||
return QString::fromStdString(str);
|
||||
}
|
||||
|
||||
QString QuantitySpinBox::getUserString(const Base::Quantity& val) const
|
||||
{
|
||||
Q_D(const QuantitySpinBox);
|
||||
std::string str;
|
||||
if (d->scheme) {
|
||||
double factor;
|
||||
QString unitString;
|
||||
return val.getUserString(d->scheme.get(), factor, unitString);
|
||||
std::string unitString;
|
||||
str = val.getUserString(d->scheme.get(), factor, unitString);
|
||||
}
|
||||
else {
|
||||
return val.getUserString();
|
||||
str = val.getUserString();
|
||||
}
|
||||
return QString::fromStdString(str);
|
||||
}
|
||||
|
||||
void QuantitySpinBox::setExpression(std::shared_ptr<Expression> expr)
|
||||
@@ -767,7 +768,7 @@ void QuantitySpinBox::stepBy(int steps)
|
||||
else if (val < d->minimum)
|
||||
val = d->minimum;
|
||||
|
||||
Quantity quant(val, d->unitStr);
|
||||
Quantity quant(val, d->unitStr.toStdString());
|
||||
updateText(quant);
|
||||
updateFromCache(true);
|
||||
update();
|
||||
@@ -909,9 +910,7 @@ void QuantitySpinBox::selectNumber()
|
||||
|
||||
QString QuantitySpinBox::textFromValue(const Base::Quantity& value) const
|
||||
{
|
||||
double factor;
|
||||
QString unitStr;
|
||||
QString str = getUserString(value, factor, unitStr);
|
||||
QString str = getUserString(value);
|
||||
if (qAbs(value.getValue()) >= 1000.0) {
|
||||
str.remove(locale().groupSeparator());
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ void TDragger::drag()
|
||||
Base::Unit::Length);
|
||||
|
||||
QString message =
|
||||
QString::fromLatin1("%1 %2").arg(QObject::tr("Translation:"), quantity.getUserString());
|
||||
QString::fromLatin1("%1 %2").arg(QObject::tr("Translation:"), QString::fromStdString(quantity.getUserString()));
|
||||
getMainWindow()->showMessage(message, 3000);
|
||||
}
|
||||
|
||||
@@ -614,8 +614,8 @@ void TPlanarDragger::drag()
|
||||
|
||||
QString message = QString::fromLatin1("%1 %2, %3")
|
||||
.arg(QObject::tr("Translation XY:"),
|
||||
quantityX.getUserString(),
|
||||
quantityY.getUserString());
|
||||
QString::fromStdString(quantityX.getUserString()),
|
||||
QString::fromStdString(quantityY.getUserString()));
|
||||
getMainWindow()->showMessage(message, 3000);
|
||||
}
|
||||
|
||||
@@ -940,7 +940,7 @@ void RDragger::drag()
|
||||
Base::Unit::Angle);
|
||||
|
||||
QString message =
|
||||
QString::fromLatin1("%1 %2").arg(QObject::tr("Rotation:"), quantity.getUserString());
|
||||
QString::fromLatin1("%1 %2").arg(QObject::tr("Rotation:"), QString::fromStdString(quantity.getUserString()));
|
||||
getMainWindow()->showMessage(message, 3000);
|
||||
}
|
||||
|
||||
|
||||
@@ -534,10 +534,10 @@ void InteractiveScale::setDistance(const SbVec3f& pos3d)
|
||||
|
||||
// Update the displayed distance
|
||||
double factor {};
|
||||
QString unitStr;
|
||||
QString valueStr;
|
||||
std::string unitStr;
|
||||
std::string valueStr;
|
||||
valueStr = quantity.getUserString(factor, unitStr);
|
||||
measureLabel->label->string = SbString(valueStr.toUtf8().constData());
|
||||
measureLabel->label->string = SbString(valueStr.c_str());
|
||||
measureLabel->label->setPoints(getCoordsOnImagePlane(points[0]), getCoordsOnImagePlane(pos3d));
|
||||
}
|
||||
|
||||
|
||||
@@ -1163,13 +1163,12 @@ PropertyUnitItem::PropertyUnitItem() = default;
|
||||
QVariant PropertyUnitItem::toString(const QVariant& prop) const
|
||||
{
|
||||
const Base::Quantity& unit = prop.value<Base::Quantity>();
|
||||
QString string = unit.getUserString();
|
||||
std::string str = unit.getUserString();
|
||||
if (hasExpression()) {
|
||||
string +=
|
||||
QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString()));
|
||||
str += fmt::format(" ( {} )", getExpressionString());
|
||||
}
|
||||
|
||||
return {string};
|
||||
return {QString::fromStdString(str)};
|
||||
}
|
||||
|
||||
QVariant PropertyUnitItem::value(const App::Property* prop) const
|
||||
@@ -1769,14 +1768,14 @@ PropertyVectorDistanceItem::PropertyVectorDistanceItem()
|
||||
QVariant PropertyVectorDistanceItem::toString(const QVariant& prop) const
|
||||
{
|
||||
const Base::Vector3d& value = prop.value<Base::Vector3d>();
|
||||
QString data = QString::fromLatin1("[")
|
||||
+ Base::Quantity(value.x, Base::Unit::Length).getUserString() + QString::fromLatin1(" ")
|
||||
+ Base::Quantity(value.y, Base::Unit::Length).getUserString() + QString::fromLatin1(" ")
|
||||
+ Base::Quantity(value.z, Base::Unit::Length).getUserString() + QString::fromLatin1("]");
|
||||
std::string str = fmt::format("[{} {} {}]",
|
||||
Base::Quantity(value.x, Base::Unit::Length).getUserString(),
|
||||
Base::Quantity(value.y, Base::Unit::Length).getUserString(),
|
||||
Base::Quantity(value.z, Base::Unit::Length).getUserString());
|
||||
if (hasExpression()) {
|
||||
data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString()));
|
||||
str += fmt::format(" ( {} )", getExpressionString());
|
||||
}
|
||||
return {data};
|
||||
return {QString::fromStdString(str)};
|
||||
}
|
||||
|
||||
|
||||
@@ -2515,12 +2514,13 @@ QVariant PropertyRotationItem::toolTip(const App::Property* prop) const
|
||||
angle = Base::toDegrees<double>(angle);
|
||||
|
||||
QLocale loc;
|
||||
QString data = QString::fromUtf8("Axis: (%1 %2 %3)\n"
|
||||
"Angle: %4")
|
||||
.arg(loc.toString(dir.x, 'f', decimals()),
|
||||
loc.toString(dir.y, 'f', decimals()),
|
||||
loc.toString(dir.z, 'f', decimals()),
|
||||
Base::Quantity(angle, Base::Unit::Angle).getUserString());
|
||||
QString data =
|
||||
QString::fromUtf8("Axis: (%1 %2 %3)\n"
|
||||
"Angle: %4")
|
||||
.arg(loc.toString(dir.x, 'f', decimals()),
|
||||
loc.toString(dir.y, 'f', decimals()),
|
||||
loc.toString(dir.z, 'f', decimals()),
|
||||
QString::fromStdString(Base::Quantity(angle, Base::Unit::Angle).getUserString()));
|
||||
return {data};
|
||||
}
|
||||
|
||||
@@ -2533,11 +2533,12 @@ QVariant PropertyRotationItem::toString(const QVariant& prop) const
|
||||
angle = Base::toDegrees<double>(angle);
|
||||
|
||||
QLocale loc;
|
||||
QString data = QString::fromUtf8("[(%1 %2 %3); %4]")
|
||||
.arg(loc.toString(dir.x, 'f', lowPrec),
|
||||
loc.toString(dir.y, 'f', lowPrec),
|
||||
loc.toString(dir.z, 'f', lowPrec),
|
||||
Base::Quantity(angle, Base::Unit::Angle).getUserString());
|
||||
QString data =
|
||||
QString::fromUtf8("[(%1 %2 %3); %4]")
|
||||
.arg(loc.toString(dir.x, 'f', lowPrec),
|
||||
loc.toString(dir.y, 'f', lowPrec),
|
||||
loc.toString(dir.z, 'f', lowPrec),
|
||||
QString::fromStdString(Base::Quantity(angle, Base::Unit::Angle).getUserString()));
|
||||
return {data};
|
||||
}
|
||||
|
||||
@@ -2817,16 +2818,17 @@ QVariant PropertyPlacementItem::toolTip(const App::Property* prop) const
|
||||
pos = p.getPosition();
|
||||
|
||||
QLocale loc;
|
||||
QString data = QString::fromUtf8("Axis: (%1 %2 %3)\n"
|
||||
"Angle: %4\n"
|
||||
"Position: (%5 %6 %7)")
|
||||
.arg(loc.toString(dir.x, 'f', decimals()),
|
||||
loc.toString(dir.y, 'f', decimals()),
|
||||
loc.toString(dir.z, 'f', decimals()),
|
||||
Base::Quantity(angle, Base::Unit::Angle).getUserString(),
|
||||
Base::Quantity(pos.x, Base::Unit::Length).getUserString(),
|
||||
Base::Quantity(pos.y, Base::Unit::Length).getUserString(),
|
||||
Base::Quantity(pos.z, Base::Unit::Length).getUserString());
|
||||
QString data =
|
||||
QString::fromUtf8("Axis: (%1 %2 %3)\n"
|
||||
"Angle: %4\n"
|
||||
"Position: (%5 %6 %7)")
|
||||
.arg(loc.toString(dir.x, 'f', decimals()),
|
||||
loc.toString(dir.y, 'f', decimals()),
|
||||
loc.toString(dir.z, 'f', decimals()),
|
||||
QString::fromStdString(Base::Quantity(angle, Base::Unit::Angle).getUserString()),
|
||||
QString::fromStdString(Base::Quantity(pos.x, Base::Unit::Length).getUserString()),
|
||||
QString::fromStdString(Base::Quantity(pos.y, Base::Unit::Length).getUserString()),
|
||||
QString::fromStdString(Base::Quantity(pos.z, Base::Unit::Length).getUserString()));
|
||||
return {data};
|
||||
}
|
||||
|
||||
@@ -2841,14 +2843,15 @@ QVariant PropertyPlacementItem::toString(const QVariant& prop) const
|
||||
pos = p.getPosition();
|
||||
|
||||
QLocale loc;
|
||||
QString data = QString::fromUtf8("[(%1 %2 %3); %4; (%5 %6 %7)]")
|
||||
.arg(loc.toString(dir.x, 'f', lowPrec),
|
||||
loc.toString(dir.y, 'f', lowPrec),
|
||||
loc.toString(dir.z, 'f', lowPrec),
|
||||
Base::Quantity(angle, Base::Unit::Angle).getUserString(),
|
||||
Base::Quantity(pos.x, Base::Unit::Length).getUserString(),
|
||||
Base::Quantity(pos.y, Base::Unit::Length).getUserString(),
|
||||
Base::Quantity(pos.z, Base::Unit::Length).getUserString());
|
||||
QString data =
|
||||
QString::fromUtf8("[(%1 %2 %3); %4; (%5 %6 %7)]")
|
||||
.arg(loc.toString(dir.x, 'f', lowPrec),
|
||||
loc.toString(dir.y, 'f', lowPrec),
|
||||
loc.toString(dir.z, 'f', lowPrec),
|
||||
QString::fromStdString(Base::Quantity(angle, Base::Unit::Angle).getUserString()),
|
||||
QString::fromStdString(Base::Quantity(pos.x, Base::Unit::Length).getUserString()),
|
||||
QString::fromStdString(Base::Quantity(pos.y, Base::Unit::Length).getUserString()),
|
||||
QString::fromStdString(Base::Quantity(pos.z, Base::Unit::Length).getUserString()));
|
||||
return {data};
|
||||
}
|
||||
|
||||
|
||||
@@ -473,12 +473,12 @@ const std::string TaskFemConstraintContact::getReferences() const
|
||||
|
||||
const std::string TaskFemConstraintContact::getSlope() const
|
||||
{
|
||||
return ui->spbSlope->value().getSafeUserString().toStdString();
|
||||
return ui->spbSlope->value().getSafeUserString();
|
||||
}
|
||||
|
||||
const std::string TaskFemConstraintContact::getAdjust() const
|
||||
{
|
||||
return ui->spbAdjust->value().getSafeUserString().toStdString();
|
||||
return ui->spbAdjust->value().getSafeUserString();
|
||||
}
|
||||
|
||||
bool TaskFemConstraintContact::getFriction() const
|
||||
@@ -493,7 +493,7 @@ double TaskFemConstraintContact::getFrictionCoeff() const
|
||||
|
||||
const std::string TaskFemConstraintContact::getStickSlope() const
|
||||
{
|
||||
return ui->spbStickSlope->value().getSafeUserString().toStdString();
|
||||
return ui->spbStickSlope->value().getSafeUserString();
|
||||
}
|
||||
|
||||
void TaskFemConstraintContact::changeEvent(QEvent*)
|
||||
|
||||
@@ -378,32 +378,32 @@ const std::string TaskFemConstraintDisplacement::getReferences() const
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_spinxDisplacement() const
|
||||
{
|
||||
return ui->spinxDisplacement->value().getSafeUserString().toStdString();
|
||||
return ui->spinxDisplacement->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_spinyDisplacement() const
|
||||
{
|
||||
return ui->spinyDisplacement->value().getSafeUserString().toStdString();
|
||||
return ui->spinyDisplacement->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_spinzDisplacement() const
|
||||
{
|
||||
return ui->spinzDisplacement->value().getSafeUserString().toStdString();
|
||||
return ui->spinzDisplacement->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_spinxRotation() const
|
||||
{
|
||||
return ui->spinxRotation->value().getSafeUserString().toStdString();
|
||||
return ui->spinxRotation->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_spinyRotation() const
|
||||
{
|
||||
return ui->spinyRotation->value().getSafeUserString().toStdString();
|
||||
return ui->spinyRotation->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_spinzRotation() const
|
||||
{
|
||||
return ui->spinzRotation->value().getSafeUserString().toStdString();
|
||||
return ui->spinzRotation->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintDisplacement::get_xFormula() const
|
||||
|
||||
@@ -338,7 +338,7 @@ void TaskFemConstraintForce::onCheckReverse(const bool pressed)
|
||||
|
||||
const std::string TaskFemConstraintForce::getForce() const
|
||||
{
|
||||
return ui->spinForce->value().getSafeUserString().toStdString();
|
||||
return ui->spinForce->value().getSafeUserString();
|
||||
}
|
||||
|
||||
const std::string TaskFemConstraintForce::getReferences() const
|
||||
|
||||
@@ -401,29 +401,24 @@ const std::string TaskFemConstraintHeatflux::getReferences() const
|
||||
|
||||
std::string TaskFemConstraintHeatflux::getAmbientTemp() const
|
||||
{
|
||||
std::string temp;
|
||||
if (ui->rb_convection->isChecked()) {
|
||||
temp = ui->qsb_ambienttemp_conv->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_ambienttemp_conv->value().getSafeUserString();
|
||||
}
|
||||
else if (ui->rb_radiation->isChecked()) {
|
||||
temp = ui->qsb_ambienttemp_rad->value().getSafeUserString().toStdString();
|
||||
if (ui->rb_radiation->isChecked()) {
|
||||
return ui->qsb_ambienttemp_rad->value().getSafeUserString();
|
||||
}
|
||||
else {
|
||||
auto obj = ConstraintView->getObject<Fem::ConstraintHeatflux>();
|
||||
temp = obj->AmbientTemp.getQuantityValue().getSafeUserString().toStdString();
|
||||
}
|
||||
|
||||
return temp;
|
||||
auto obj = ConstraintView->getObject<Fem::ConstraintHeatflux>();
|
||||
return obj->AmbientTemp.getQuantityValue().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintHeatflux::getFilmCoef() const
|
||||
{
|
||||
return ui->qsb_film_coef->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_film_coef->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintHeatflux::getDFlux() const
|
||||
{
|
||||
return ui->qsb_heat_flux->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_heat_flux->value().getSafeUserString();
|
||||
}
|
||||
|
||||
double TaskFemConstraintHeatflux::getEmissivity() const
|
||||
|
||||
@@ -70,7 +70,7 @@ TaskFemConstraintInitialTemperature::~TaskFemConstraintInitialTemperature() = de
|
||||
|
||||
std::string TaskFemConstraintInitialTemperature::get_temperature() const
|
||||
{
|
||||
return ui->if_temperature->value().getSafeUserString().toStdString();
|
||||
return ui->if_temperature->value().getSafeUserString();
|
||||
}
|
||||
|
||||
void TaskFemConstraintInitialTemperature::changeEvent(QEvent*)
|
||||
|
||||
@@ -250,7 +250,7 @@ const std::string TaskFemConstraintPressure::getReferences() const
|
||||
|
||||
std::string TaskFemConstraintPressure::getPressure() const
|
||||
{
|
||||
return ui->if_pressure->value().getSafeUserString().toStdString();
|
||||
return ui->if_pressure->value().getSafeUserString();
|
||||
}
|
||||
|
||||
bool TaskFemConstraintPressure::getReverse() const
|
||||
|
||||
@@ -116,7 +116,7 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
Base::Vector3d rotDir;
|
||||
double rotAngleRad;
|
||||
pcConstraint->Rotation.getValue().getValue(rotDir, rotAngleRad);
|
||||
Base::Quantity rotAngle(rotAngleRad, QString::fromUtf8("rad"));
|
||||
Base::Quantity rotAngle(rotAngleRad, "rad");
|
||||
Base::Quantity forceX = pcConstraint->ForceX.getQuantityValue();
|
||||
Base::Quantity forceY = pcConstraint->ForceY.getQuantityValue();
|
||||
Base::Quantity forceZ = pcConstraint->ForceZ.getQuantityValue();
|
||||
@@ -581,18 +581,18 @@ Base::Rotation TaskFemConstraintRigidBody::getRotation() const
|
||||
|
||||
std::vector<std::string> TaskFemConstraintRigidBody::getForce() const
|
||||
{
|
||||
std::string x = ui->qsb_force_x->value().getSafeUserString().toStdString();
|
||||
std::string y = ui->qsb_force_y->value().getSafeUserString().toStdString();
|
||||
std::string z = ui->qsb_force_z->value().getSafeUserString().toStdString();
|
||||
std::string x = ui->qsb_force_x->value().getSafeUserString();
|
||||
std::string y = ui->qsb_force_y->value().getSafeUserString();
|
||||
std::string z = ui->qsb_force_z->value().getSafeUserString();
|
||||
|
||||
return {x, y, z};
|
||||
}
|
||||
|
||||
std::vector<std::string> TaskFemConstraintRigidBody::getMoment() const
|
||||
{
|
||||
std::string x = ui->qsb_moment_x->value().getSafeUserString().toStdString();
|
||||
std::string y = ui->qsb_moment_y->value().getSafeUserString().toStdString();
|
||||
std::string z = ui->qsb_moment_z->value().getSafeUserString().toStdString();
|
||||
std::string x = ui->qsb_moment_x->value().getSafeUserString();
|
||||
std::string y = ui->qsb_moment_y->value().getSafeUserString();
|
||||
std::string z = ui->qsb_moment_z->value().getSafeUserString();
|
||||
|
||||
return std::vector<std::string>({x, y, z});
|
||||
}
|
||||
|
||||
@@ -248,12 +248,12 @@ const std::string TaskFemConstraintSpring::getReferences() const
|
||||
|
||||
std::string TaskFemConstraintSpring::getNormalStiffness() const
|
||||
{
|
||||
return ui->qsb_norm->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_norm->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintSpring::getTangentialStiffness() const
|
||||
{
|
||||
return ui->qsb_tan->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_tan->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintSpring::getElmerStiffness() const
|
||||
|
||||
@@ -306,12 +306,12 @@ const std::string TaskFemConstraintTemperature::getReferences() const
|
||||
|
||||
std::string TaskFemConstraintTemperature::get_temperature() const
|
||||
{
|
||||
return ui->qsb_temperature->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_temperature->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintTemperature::get_cflux() const
|
||||
{
|
||||
return ui->qsb_cflux->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_cflux->value().getSafeUserString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintTemperature::get_constraint_type() const
|
||||
|
||||
@@ -118,7 +118,7 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(
|
||||
ui->spb_rot_axis_x->setValue(axis.x);
|
||||
ui->spb_rot_axis_y->setValue(axis.y);
|
||||
ui->spb_rot_axis_z->setValue(axis.z);
|
||||
Base::Quantity rotAngle(angle, QString::fromUtf8("rad"));
|
||||
Base::Quantity rotAngle(angle, "rad");
|
||||
ui->qsb_rot_angle->setValue(rotAngle.getValueAs(Base::Quantity::Degree));
|
||||
|
||||
ui->spb_rot_axis_x->bind(
|
||||
@@ -406,7 +406,7 @@ void TaskFemConstraintTransform::addToSelection()
|
||||
ui->spb_rot_axis_x->setValue(axis.x);
|
||||
ui->spb_rot_axis_y->setValue(axis.y);
|
||||
ui->spb_rot_axis_z->setValue(axis.z);
|
||||
Base::Quantity rotAngle(angle, QString::fromUtf8("rad"));
|
||||
Base::Quantity rotAngle(angle, "rad");
|
||||
ui->qsb_rot_angle->setValue(rotAngle.getValueAs(Base::Quantity::Degree));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +115,7 @@ std::shared_ptr<Material2DArray> MaterialYamlEntry::read2DArray(const YAML::Node
|
||||
|
||||
auto row = std::make_shared<QList<QVariant>>();
|
||||
for (std::size_t j = 0; j < yamlRow.size(); j++) {
|
||||
Base::Quantity qq =
|
||||
Base::Quantity::parse(QString::fromStdString(yamlRow[j].as<std::string>()));
|
||||
Base::Quantity qq = Base::Quantity::parse(yamlRow[j].as<std::string>());
|
||||
qq.setFormat(MaterialValue::getQuantityFormat());
|
||||
row->push_back(QVariant::fromValue(qq));
|
||||
}
|
||||
@@ -142,10 +141,8 @@ std::shared_ptr<Material3DArray> MaterialYamlEntry::read3DArray(const YAML::Node
|
||||
for (std::size_t depth = 0; depth < yamlArray.size(); depth++) {
|
||||
auto yamlDepth = yamlArray[depth];
|
||||
for (auto it = yamlDepth.begin(); it != yamlDepth.end(); it++) {
|
||||
auto depthValue =
|
||||
Base::Quantity::parse(QString::fromStdString(it->first.as<std::string>()));
|
||||
auto depthValue = Base::Quantity::parse(it->first.as<std::string>());
|
||||
depthValue.setFormat(MaterialValue::getQuantityFormat());
|
||||
|
||||
array3d->addDepth(depth, depthValue);
|
||||
|
||||
auto yamlTable = it->second;
|
||||
@@ -154,8 +151,7 @@ std::shared_ptr<Material3DArray> MaterialYamlEntry::read3DArray(const YAML::Node
|
||||
|
||||
auto row = std::make_shared<QList<Base::Quantity>>();
|
||||
for (std::size_t j = 0; j < yamlRow.size(); j++) {
|
||||
auto qq = Base::Quantity::parse(
|
||||
QString::fromStdString(yamlRow[j].as<std::string>()));
|
||||
auto qq = Base::Quantity::parse(yamlRow[j].as<std::string>());
|
||||
qq.setFormat(MaterialValue::getQuantityFormat());
|
||||
row->push_back(qq);
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ QString MaterialValue::getYAMLString() const
|
||||
}
|
||||
if (getType() == MaterialValue::Quantity) {
|
||||
auto quantity = getValue().value<Base::Quantity>();
|
||||
yaml += quantity.getUserString();
|
||||
yaml += QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
else if (getType() == MaterialValue::Float) {
|
||||
auto value = getValue();
|
||||
@@ -500,7 +500,7 @@ QString Material2DArray::getYAMLString() const
|
||||
}
|
||||
yaml += QString::fromStdString("\"");
|
||||
auto quantity = column.value<Base::Quantity>();
|
||||
yaml += quantity.getUserString();
|
||||
yaml += QString::fromStdString(quantity.getUserString());
|
||||
yaml += QString::fromStdString("\"");
|
||||
}
|
||||
|
||||
@@ -814,7 +814,7 @@ QString Material3DArray::getYAMLString() const
|
||||
}
|
||||
|
||||
yaml += QString::fromStdString("\"");
|
||||
auto value = getDepthValue(depth).getUserString();
|
||||
auto value = QString::fromStdString(getDepthValue(depth).getUserString());
|
||||
yaml += value;
|
||||
yaml += QString::fromStdString("\": [");
|
||||
|
||||
@@ -844,7 +844,7 @@ QString Material3DArray::getYAMLString() const
|
||||
}
|
||||
yaml += QString::fromStdString("\"");
|
||||
// Base::Quantity quantity = column.value<Base::Quantity>();
|
||||
yaml += column.getUserString();
|
||||
yaml += QString::fromStdString(column.getUserString());
|
||||
yaml += QString::fromStdString("\"");
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ QString MaterialProperty::getString() const
|
||||
}
|
||||
if (getType() == MaterialValue::Quantity) {
|
||||
auto quantity = getValue().value<Base::Quantity>();
|
||||
return quantity.getUserString();
|
||||
return QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
if (getType() == MaterialValue::Float) {
|
||||
auto value = getValue();
|
||||
@@ -266,7 +266,7 @@ QVariant MaterialProperty::getColumnNull(int column) const
|
||||
|
||||
switch (valueType) {
|
||||
case MaterialValue::Quantity: {
|
||||
Base::Quantity quant = Base::Quantity(0, getColumnUnits(column));
|
||||
Base::Quantity quant = Base::Quantity(0, getColumnUnits(column).toStdString());
|
||||
return QVariant::fromValue(quant);
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ void MaterialProperty::setValue(const QString& value)
|
||||
}
|
||||
else if (_valuePtr->getType() == MaterialValue::Quantity) {
|
||||
try {
|
||||
setQuantity(Base::Quantity::parse(value));
|
||||
setQuantity(Base::Quantity::parse(value.toStdString()));
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
Base::Console().Log("MaterialProperty::setValue Error '%s' - '%s'\n",
|
||||
@@ -392,12 +392,12 @@ void MaterialProperty::setQuantity(const Base::Quantity& value)
|
||||
|
||||
void MaterialProperty::setQuantity(double value, const QString& units)
|
||||
{
|
||||
setQuantity(Base::Quantity(value, units));
|
||||
setQuantity(Base::Quantity(value, units.toStdString()));
|
||||
}
|
||||
|
||||
void MaterialProperty::setQuantity(const QString& value)
|
||||
{
|
||||
setQuantity(Base::Quantity::parse(value));
|
||||
setQuantity(Base::Quantity::parse(value.toStdString()));
|
||||
}
|
||||
|
||||
void MaterialProperty::setList(const QList<QVariant>& value)
|
||||
@@ -1038,7 +1038,7 @@ Material::getValueString(const std::map<QString, std::shared_ptr<MaterialPropert
|
||||
if (value.isNull()) {
|
||||
return {};
|
||||
}
|
||||
return value.value<Base::Quantity>().getUserString();
|
||||
return QString::fromStdString(value.value<Base::Quantity>().getUserString());
|
||||
}
|
||||
if (property->getType() == MaterialValue::Float) {
|
||||
auto value = property->getValue();
|
||||
|
||||
@@ -72,16 +72,13 @@ void ArrayDelegate::paint(QPainter* painter,
|
||||
auto* tableModel = dynamic_cast<const AbstractArrayModel*>(index.model());
|
||||
painter->save();
|
||||
|
||||
if (tableModel->newRow(index)) {
|
||||
painter->drawText(option.rect, 0, QString());
|
||||
}
|
||||
else {
|
||||
QString text;
|
||||
if (!tableModel->newRow(index)) {
|
||||
QVariant item = tableModel->data(index);
|
||||
auto quantity = item.value<Base::Quantity>();
|
||||
QString text = quantity.getUserString();
|
||||
painter->drawText(option.rect, 0, text);
|
||||
text = QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
|
||||
painter->drawText(option.rect, 0, text);
|
||||
painter->restore();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -93,7 +93,7 @@ QVariant Array2DModel::data(const QModelIndex& index, int role) const
|
||||
try {
|
||||
auto column = _property->getColumnType(index.column());
|
||||
if (column == Materials::MaterialValue::Quantity) {
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(index.column()));
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(index.column()).toStdString());
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return QVariant::fromValue(qq);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ QVariant Array3DDepthModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
|
||||
try {
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(0));
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(0).toStdString());
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return QVariant::fromValue(qq);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ bool Array3DDepthModel::insertRows(int row, int count, const QModelIndex& parent
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
auto qq = Base::Quantity(0, _property->getColumnUnits(0));
|
||||
auto qq = Base::Quantity(0, _property->getColumnUnits(0).toStdString());
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
_value->addDepth(row, qq);
|
||||
}
|
||||
@@ -395,7 +395,7 @@ QVariant Array3DModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
|
||||
try {
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(index.column() + 1));
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(index.column() + 1).toStdString());
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return QVariant::fromValue(qq);
|
||||
}
|
||||
|
||||
@@ -103,15 +103,13 @@ void BaseDelegate::paintQuantity(QPainter* painter,
|
||||
painter->drawText(option.rect, 0, QString());
|
||||
}
|
||||
else {
|
||||
QString text;
|
||||
QVariant item = getValue(index);
|
||||
auto quantity = item.value<Base::Quantity>();
|
||||
if (quantity.isValid()) {
|
||||
QString text = quantity.getUserString();
|
||||
painter->drawText(option.rect, 0, text);
|
||||
}
|
||||
else {
|
||||
painter->drawText(option.rect, 0, QString());
|
||||
text = QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
painter->drawText(option.rect, 0, text);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
|
||||
@@ -180,7 +180,8 @@ QString MeasureBase::getResultString()
|
||||
}
|
||||
|
||||
if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
|
||||
return static_cast<App::PropertyQuantity*>(prop)->getQuantityValue().getUserString();
|
||||
return QString::fromStdString(
|
||||
static_cast<App::PropertyQuantity*>(prop)->getQuantityValue().getUserString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -179,12 +179,23 @@ void QuickMeasure::addSelectionToMeasurement()
|
||||
}
|
||||
}
|
||||
|
||||
static QString areaStr(double value)
|
||||
{
|
||||
Base::Quantity area(value, Base::Unit::Area);
|
||||
return QString::fromStdString(area.getUserString());
|
||||
}
|
||||
|
||||
static QString lenghtStr(double value)
|
||||
{
|
||||
Base::Quantity dist(value, Base::Unit::Length);
|
||||
return QString::fromStdString(dist.getUserString());
|
||||
}
|
||||
|
||||
void QuickMeasure::printResult()
|
||||
{
|
||||
MeasureType mtype = measurement->getType();
|
||||
if (mtype == MeasureType::Surfaces) {
|
||||
Base::Quantity area(measurement->area(), Base::Unit::Area);
|
||||
print(tr("Total area: %1").arg(area.getUserString()));
|
||||
print(tr("Total area: %1").arg(areaStr(measurement->area())));
|
||||
}
|
||||
/* deactivated because computing the volumes/area of solids makes a significant
|
||||
slow down in selection of complex solids.
|
||||
@@ -195,48 +206,37 @@ void QuickMeasure::printResult()
|
||||
%2").arg(vol.getSafeUserString()).arg(area.getSafeUserString()));
|
||||
}*/
|
||||
else if (mtype == MeasureType::TwoPlanes) {
|
||||
Base::Quantity dist(measurement->planePlaneDistance(), Base::Unit::Length);
|
||||
print(tr("Nominal distance: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Nominal distance: %1").arg(lenghtStr(measurement->planePlaneDistance())));
|
||||
}
|
||||
else if (mtype == MeasureType::Cone || mtype == MeasureType::Plane) {
|
||||
Base::Quantity area(measurement->area(), Base::Unit::Area);
|
||||
print(tr("Area: %1").arg(area.getUserString()));
|
||||
print(tr("Area: %1").arg(areaStr(measurement->area())));
|
||||
}
|
||||
else if (mtype == MeasureType::Cylinder || mtype == MeasureType::Sphere
|
||||
|| mtype == MeasureType::Torus) {
|
||||
Base::Quantity area(measurement->area(), Base::Unit::Area);
|
||||
Base::Quantity rad(measurement->radius(), Base::Unit::Length);
|
||||
print(tr("Area: %1, Radius: %2").arg(area.getSafeUserString(), rad.getSafeUserString()));
|
||||
print(tr("Area: %1, Radius: %2")
|
||||
.arg(areaStr(measurement->area()), lenghtStr(measurement->radius())));
|
||||
}
|
||||
else if (mtype == MeasureType::Edges) {
|
||||
Base::Quantity dist(measurement->length(), Base::Unit::Length);
|
||||
print(tr("Total length: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Total length: %1").arg(lenghtStr(measurement->length())));
|
||||
}
|
||||
else if (mtype == MeasureType::TwoParallelLines) {
|
||||
Base::Quantity dist(measurement->lineLineDistance(), Base::Unit::Length);
|
||||
print(tr("Nominal distance: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Nominal distance: %1").arg(lenghtStr(measurement->lineLineDistance())));
|
||||
}
|
||||
else if (mtype == MeasureType::TwoLines) {
|
||||
Base::Quantity angle(measurement->angle(), Base::Unit::Length);
|
||||
Base::Quantity dist(measurement->length(), Base::Unit::Length);
|
||||
print(tr("Angle: %1, Total length: %2")
|
||||
.arg(angle.getSafeUserString(), dist.getSafeUserString()));
|
||||
.arg(lenghtStr(measurement->angle()), lenghtStr(measurement->length())));
|
||||
}
|
||||
else if (mtype == MeasureType::Line) {
|
||||
Base::Quantity dist(measurement->length(), Base::Unit::Length);
|
||||
print(tr("Length: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Length: %1").arg(lenghtStr(measurement->length())));
|
||||
}
|
||||
else if (mtype == MeasureType::Circle) {
|
||||
Base::Quantity dist(measurement->radius(), Base::Unit::Length);
|
||||
print(tr("Radius: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Radius: %1").arg(lenghtStr(measurement->radius())));
|
||||
}
|
||||
else if (mtype == MeasureType::PointToPoint) {
|
||||
Base::Quantity dist(measurement->length(), Base::Unit::Length);
|
||||
print(tr("Distance: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Distance: %1").arg(lenghtStr(measurement->length())));
|
||||
}
|
||||
else if (mtype == MeasureType::PointToEdge || mtype == MeasureType::PointToSurface) {
|
||||
Base::Quantity dist(measurement->length(), Base::Unit::Length);
|
||||
print(tr("Minimum distance: %1").arg(dist.getSafeUserString()));
|
||||
print(tr("Minimum distance: %1").arg(lenghtStr(measurement->length())));
|
||||
}
|
||||
else {
|
||||
print(QString::fromLatin1(""));
|
||||
|
||||
@@ -263,7 +263,7 @@ void ViewProviderMeasureBase::draggerChangedCallback(void* data, SoDragger*)
|
||||
|
||||
void ViewProviderMeasureBase::setLabelValue(const Base::Quantity& value)
|
||||
{
|
||||
pLabel->string.setValue(value.getUserString().toUtf8().constData());
|
||||
pLabel->string.setValue(value.getUserString().c_str());
|
||||
}
|
||||
|
||||
void ViewProviderMeasureBase::setLabelValue(const QString& value)
|
||||
|
||||
@@ -478,23 +478,23 @@ void ViewProviderMeasureDistance::redrawAnnotation()
|
||||
|
||||
auto propDistance =
|
||||
dynamic_cast<App::PropertyDistance*>(pcObject->getPropertyByName("Distance"));
|
||||
setLabelValue(propDistance->getQuantityValue().getUserString());
|
||||
setLabelValue(QString::fromStdString(propDistance->getQuantityValue().getUserString()));
|
||||
|
||||
// Set delta distance
|
||||
auto propDistanceX =
|
||||
static_cast<App::PropertyDistance*>(getMeasureObject()->getPropertyByName("DistanceX"));
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(0))
|
||||
->text.setValue("Δx: " + propDistanceX->getQuantityValue().getUserString().toUtf8());
|
||||
->text.setValue(("Δx: " + propDistanceX->getQuantityValue().getUserString()).c_str());
|
||||
|
||||
auto propDistanceY =
|
||||
static_cast<App::PropertyDistance*>(getMeasureObject()->getPropertyByName("DistanceY"));
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(1))
|
||||
->text.setValue("Δy: " + propDistanceY->getQuantityValue().getUserString().toUtf8());
|
||||
->text.setValue(("Δy: " + propDistanceY->getQuantityValue().getUserString()).c_str());
|
||||
|
||||
auto propDistanceZ =
|
||||
static_cast<App::PropertyDistance*>(getMeasureObject()->getPropertyByName("DistanceZ"));
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(2))
|
||||
->text.setValue("Δz: " + propDistanceZ->getQuantityValue().getUserString().toUtf8());
|
||||
->text.setValue(("Δz: " + propDistanceZ->getQuantityValue().getUserString()).c_str());
|
||||
|
||||
// Set matrix
|
||||
SbMatrix matrix = getMatrix();
|
||||
@@ -529,7 +529,6 @@ void ViewProviderMeasureDistance::onChanged(const App::Property* prop)
|
||||
->backgroundColor.setValue(bColor.r, bColor.g, bColor.g);
|
||||
}
|
||||
|
||||
|
||||
ViewProviderMeasureBase::onChanged(prop);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ QVariant FilletRadiusModel::data(const QModelIndex& index, int role) const
|
||||
QVariant value = QStandardItemModel::data(index, role);
|
||||
if (role == Qt::DisplayRole && index.column() >= 1) {
|
||||
Base::Quantity q = value.value<Base::Quantity>();
|
||||
QString str = q.getUserString();
|
||||
QString str = QString::fromStdString(q.getUserString());
|
||||
return str;
|
||||
}
|
||||
return value;
|
||||
|
||||
+137
-132
@@ -111,6 +111,11 @@ const char* gce_ErrorStatusText(gce_ErrorType et)
|
||||
}
|
||||
}
|
||||
|
||||
static QString safeQuantityQString(Gui::QuantitySpinBox *qs)
|
||||
{
|
||||
return QString::fromStdString(qs->value().getSafeUserString());
|
||||
}
|
||||
|
||||
void Picker::createPrimitive(QWidget* widget, const QString& descr, Gui::Document* doc)
|
||||
{
|
||||
try {
|
||||
@@ -268,8 +273,8 @@ QString PlanePrimitive::create(const QString& objectName, const QString& placeme
|
||||
"App.ActiveDocument.%1.Placement=%4\n"
|
||||
"App.ActiveDocument.%1.Label='%5'\n")
|
||||
.arg(objectName,
|
||||
ui->planeLength->value().getSafeUserString(),
|
||||
ui->planeWidth->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->planeLength),
|
||||
safeQuantityQString(ui->planeWidth),
|
||||
placement,
|
||||
DlgPrimitives::tr("Plane"));
|
||||
}
|
||||
@@ -281,8 +286,8 @@ QString PlanePrimitive::change(const QString& objectName, const QString& placeme
|
||||
"%1.Width='%3'\n"
|
||||
"%1.Placement=%4\n")
|
||||
.arg(objectName,
|
||||
ui->planeLength->value().getSafeUserString(),
|
||||
ui->planeWidth->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->planeLength),
|
||||
safeQuantityQString(ui->planeWidth),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -342,9 +347,9 @@ QString BoxPrimitive::create(const QString& objectName, const QString& placement
|
||||
"App.ActiveDocument.%1.Placement=%5\n"
|
||||
"App.ActiveDocument.%1.Label='%6'\n")
|
||||
.arg(objectName,
|
||||
ui->boxLength->value().getSafeUserString(),
|
||||
ui->boxWidth->value().getSafeUserString(),
|
||||
ui->boxHeight->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->boxLength),
|
||||
safeQuantityQString(ui->boxWidth),
|
||||
safeQuantityQString(ui->boxHeight),
|
||||
placement,
|
||||
DlgPrimitives::tr("Box"));
|
||||
}
|
||||
@@ -357,9 +362,9 @@ QString BoxPrimitive::change(const QString& objectName, const QString& placement
|
||||
"%1.Height='%4'\n"
|
||||
"%1.Placement=%5\n")
|
||||
.arg(objectName,
|
||||
ui->boxLength->value().getSafeUserString(),
|
||||
ui->boxWidth->value().getSafeUserString(),
|
||||
ui->boxHeight->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->boxLength),
|
||||
safeQuantityQString(ui->boxWidth),
|
||||
safeQuantityQString(ui->boxHeight),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -430,11 +435,11 @@ QString CylinderPrimitive::create(const QString& objectName, const QString& plac
|
||||
"App.ActiveDocument.%1.Placement=%7\n"
|
||||
"App.ActiveDocument.%1.Label='%8'\n")
|
||||
.arg(objectName,
|
||||
ui->cylinderRadius->value().getSafeUserString(),
|
||||
ui->cylinderHeight->value().getSafeUserString(),
|
||||
ui->cylinderAngle->value().getSafeUserString(),
|
||||
ui->cylinderXSkew->value().getSafeUserString(),
|
||||
ui->cylinderYSkew->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->cylinderRadius),
|
||||
safeQuantityQString(ui->cylinderHeight),
|
||||
safeQuantityQString(ui->cylinderAngle),
|
||||
safeQuantityQString(ui->cylinderXSkew),
|
||||
safeQuantityQString(ui->cylinderYSkew),
|
||||
placement,
|
||||
DlgPrimitives::tr("Cylinder"));
|
||||
}
|
||||
@@ -449,11 +454,11 @@ QString CylinderPrimitive::change(const QString& objectName, const QString& plac
|
||||
"%1.SecondAngle='%6'\n"
|
||||
"%1.Placement=%7\n")
|
||||
.arg(objectName,
|
||||
ui->cylinderRadius->value().getSafeUserString(),
|
||||
ui->cylinderHeight->value().getSafeUserString(),
|
||||
ui->cylinderAngle->value().getSafeUserString(),
|
||||
ui->cylinderXSkew->value().getSafeUserString(),
|
||||
ui->cylinderYSkew->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->cylinderRadius),
|
||||
safeQuantityQString(ui->cylinderHeight),
|
||||
safeQuantityQString(ui->cylinderAngle),
|
||||
safeQuantityQString(ui->cylinderXSkew),
|
||||
safeQuantityQString(ui->cylinderYSkew),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -527,10 +532,10 @@ QString ConePrimitive::create(const QString& objectName, const QString& placemen
|
||||
"App.ActiveDocument.%1.Placement=%6\n"
|
||||
"App.ActiveDocument.%1.Label='%7'\n")
|
||||
.arg(objectName,
|
||||
ui->coneRadius1->value().getSafeUserString(),
|
||||
ui->coneRadius2->value().getSafeUserString(),
|
||||
ui->coneHeight->value().getSafeUserString(),
|
||||
ui->coneAngle->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->coneRadius1),
|
||||
safeQuantityQString(ui->coneRadius2),
|
||||
safeQuantityQString(ui->coneHeight),
|
||||
safeQuantityQString(ui->coneAngle),
|
||||
placement,
|
||||
DlgPrimitives::tr("Cone"));
|
||||
}
|
||||
@@ -544,10 +549,10 @@ QString ConePrimitive::change(const QString& objectName, const QString& placemen
|
||||
"%1.Angle='%5'\n"
|
||||
"%1.Placement=%6\n")
|
||||
.arg(objectName,
|
||||
ui->coneRadius1->value().getSafeUserString(),
|
||||
ui->coneRadius2->value().getSafeUserString(),
|
||||
ui->coneHeight->value().getSafeUserString(),
|
||||
ui->coneAngle->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->coneRadius1),
|
||||
safeQuantityQString(ui->coneRadius2),
|
||||
safeQuantityQString(ui->coneHeight),
|
||||
safeQuantityQString(ui->coneAngle),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -618,10 +623,10 @@ QString SpherePrimitive::create(const QString& objectName, const QString& placem
|
||||
"App.ActiveDocument.%1.Placement=%6\n"
|
||||
"App.ActiveDocument.%1.Label='%7'\n")
|
||||
.arg(objectName,
|
||||
ui->sphereRadius->value().getSafeUserString(),
|
||||
ui->sphereAngle1->value().getSafeUserString(),
|
||||
ui->sphereAngle2->value().getSafeUserString(),
|
||||
ui->sphereAngle3->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->sphereRadius),
|
||||
safeQuantityQString(ui->sphereAngle1),
|
||||
safeQuantityQString(ui->sphereAngle2),
|
||||
safeQuantityQString(ui->sphereAngle3),
|
||||
placement,
|
||||
DlgPrimitives::tr("Sphere"));
|
||||
}
|
||||
@@ -635,10 +640,10 @@ QString SpherePrimitive::change(const QString& objectName, const QString& placem
|
||||
"%1.Angle3='%5'\n"
|
||||
"%1.Placement=%6\n")
|
||||
.arg(objectName,
|
||||
ui->sphereRadius->value().getSafeUserString(),
|
||||
ui->sphereAngle1->value().getSafeUserString(),
|
||||
ui->sphereAngle2->value().getSafeUserString(),
|
||||
ui->sphereAngle3->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->sphereRadius),
|
||||
safeQuantityQString(ui->sphereAngle1),
|
||||
safeQuantityQString(ui->sphereAngle2),
|
||||
safeQuantityQString(ui->sphereAngle3),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -720,12 +725,12 @@ QString EllipsoidPrimitive::create(const QString& objectName, const QString& pla
|
||||
"App.ActiveDocument.%1.Placement=%8\n"
|
||||
"App.ActiveDocument.%1.Label='%9'\n")
|
||||
.arg(objectName,
|
||||
ui->ellipsoidRadius1->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius2->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius3->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle1->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle2->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle3->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->ellipsoidRadius1),
|
||||
safeQuantityQString(ui->ellipsoidRadius2),
|
||||
safeQuantityQString(ui->ellipsoidRadius3),
|
||||
safeQuantityQString(ui->ellipsoidAngle1),
|
||||
safeQuantityQString(ui->ellipsoidAngle2),
|
||||
safeQuantityQString(ui->ellipsoidAngle3),
|
||||
placement,
|
||||
DlgPrimitives::tr("Ellipsoid"));
|
||||
}
|
||||
@@ -741,12 +746,12 @@ QString EllipsoidPrimitive::change(const QString& objectName, const QString& pla
|
||||
"%1.Angle3='%7'\n"
|
||||
"%1.Placement=%8\n")
|
||||
.arg(objectName,
|
||||
ui->ellipsoidRadius1->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius2->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius3->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle1->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle2->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle3->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->ellipsoidRadius1),
|
||||
safeQuantityQString(ui->ellipsoidRadius2),
|
||||
safeQuantityQString(ui->ellipsoidRadius3),
|
||||
safeQuantityQString(ui->ellipsoidAngle1),
|
||||
safeQuantityQString(ui->ellipsoidAngle2),
|
||||
safeQuantityQString(ui->ellipsoidAngle3),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -828,11 +833,11 @@ QString TorusPrimitive::create(const QString& objectName, const QString& placeme
|
||||
"App.ActiveDocument.%1.Placement=%7\n"
|
||||
"App.ActiveDocument.%1.Label='%8'\n")
|
||||
.arg(objectName,
|
||||
ui->torusRadius1->value().getSafeUserString(),
|
||||
ui->torusRadius2->value().getSafeUserString(),
|
||||
ui->torusAngle1->value().getSafeUserString(),
|
||||
ui->torusAngle2->value().getSafeUserString(),
|
||||
ui->torusAngle3->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->torusRadius1),
|
||||
safeQuantityQString(ui->torusRadius2),
|
||||
safeQuantityQString(ui->torusAngle1),
|
||||
safeQuantityQString(ui->torusAngle2),
|
||||
safeQuantityQString(ui->torusAngle3),
|
||||
placement,
|
||||
DlgPrimitives::tr("Torus"));
|
||||
}
|
||||
@@ -847,11 +852,11 @@ QString TorusPrimitive::change(const QString& objectName, const QString& placeme
|
||||
"%1.Angle3='%6'\n"
|
||||
"%1.Placement=%7\n")
|
||||
.arg(objectName,
|
||||
ui->torusRadius1->value().getSafeUserString(),
|
||||
ui->torusRadius2->value().getSafeUserString(),
|
||||
ui->torusAngle1->value().getSafeUserString(),
|
||||
ui->torusAngle2->value().getSafeUserString(),
|
||||
ui->torusAngle3->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->torusRadius1),
|
||||
safeQuantityQString(ui->torusRadius2),
|
||||
safeQuantityQString(ui->torusAngle1),
|
||||
safeQuantityQString(ui->torusAngle2),
|
||||
safeQuantityQString(ui->torusAngle3),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -927,10 +932,10 @@ QString PrismPrimitive::create(const QString& objectName, const QString& placeme
|
||||
"App.ActiveDocument.%1.Label='%8'\n")
|
||||
.arg(objectName,
|
||||
QString::number(ui->prismPolygon->value()),
|
||||
ui->prismCircumradius->value().getSafeUserString(),
|
||||
ui->prismHeight->value().getSafeUserString(),
|
||||
ui->prismXSkew->value().getSafeUserString(),
|
||||
ui->prismYSkew->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->prismCircumradius),
|
||||
safeQuantityQString(ui->prismHeight),
|
||||
safeQuantityQString(ui->prismXSkew),
|
||||
safeQuantityQString(ui->prismYSkew),
|
||||
placement,
|
||||
DlgPrimitives::tr("Prism"));
|
||||
}
|
||||
@@ -946,10 +951,10 @@ QString PrismPrimitive::change(const QString& objectName, const QString& placeme
|
||||
"%1.Placement=%7\n")
|
||||
.arg(objectName,
|
||||
QString::number(ui->prismPolygon->value()),
|
||||
ui->prismCircumradius->value().getSafeUserString(),
|
||||
ui->prismHeight->value().getSafeUserString(),
|
||||
ui->prismXSkew->value().getSafeUserString(),
|
||||
ui->prismYSkew->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->prismCircumradius),
|
||||
safeQuantityQString(ui->prismHeight),
|
||||
safeQuantityQString(ui->prismXSkew),
|
||||
safeQuantityQString(ui->prismYSkew),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1063,16 +1068,16 @@ QString WedgePrimitive::create(const QString& objectName, const QString& placeme
|
||||
"App.ActiveDocument.%1.Placement=%12\n"
|
||||
"App.ActiveDocument.%1.Label='%13'\n")
|
||||
.arg(objectName,
|
||||
ui->wedgeXmin->value().getSafeUserString(),
|
||||
ui->wedgeYmin->value().getSafeUserString(),
|
||||
ui->wedgeZmin->value().getSafeUserString(),
|
||||
ui->wedgeX2min->value().getSafeUserString(),
|
||||
ui->wedgeZ2min->value().getSafeUserString(),
|
||||
ui->wedgeXmax->value().getSafeUserString(),
|
||||
ui->wedgeYmax->value().getSafeUserString())
|
||||
.arg(ui->wedgeZmax->value().getSafeUserString(),
|
||||
ui->wedgeX2max->value().getSafeUserString(),
|
||||
ui->wedgeZ2max->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->wedgeXmin),
|
||||
safeQuantityQString(ui->wedgeYmin),
|
||||
safeQuantityQString(ui->wedgeZmin),
|
||||
safeQuantityQString(ui->wedgeX2min),
|
||||
safeQuantityQString(ui->wedgeZ2min),
|
||||
safeQuantityQString(ui->wedgeXmax),
|
||||
safeQuantityQString(ui->wedgeYmax))
|
||||
.arg(safeQuantityQString(ui->wedgeZmax),
|
||||
safeQuantityQString(ui->wedgeX2max),
|
||||
safeQuantityQString(ui->wedgeZ2max),
|
||||
placement,
|
||||
DlgPrimitives::tr("Wedge"));
|
||||
}
|
||||
@@ -1092,16 +1097,16 @@ QString WedgePrimitive::change(const QString& objectName, const QString& placeme
|
||||
"%1.Z2max='%11'\n"
|
||||
"%1.Placement=%12\n")
|
||||
.arg(objectName,
|
||||
ui->wedgeXmin->value().getSafeUserString(),
|
||||
ui->wedgeYmin->value().getSafeUserString(),
|
||||
ui->wedgeZmin->value().getSafeUserString(),
|
||||
ui->wedgeX2min->value().getSafeUserString(),
|
||||
ui->wedgeZ2min->value().getSafeUserString(),
|
||||
ui->wedgeXmax->value().getSafeUserString(),
|
||||
ui->wedgeYmax->value().getSafeUserString(),
|
||||
ui->wedgeZmax->value().getSafeUserString())
|
||||
.arg(ui->wedgeX2max->value().getSafeUserString(),
|
||||
ui->wedgeZ2max->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->wedgeXmin),
|
||||
safeQuantityQString(ui->wedgeYmin),
|
||||
safeQuantityQString(ui->wedgeZmin),
|
||||
safeQuantityQString(ui->wedgeX2min),
|
||||
safeQuantityQString(ui->wedgeZ2min),
|
||||
safeQuantityQString(ui->wedgeXmax),
|
||||
safeQuantityQString(ui->wedgeYmax),
|
||||
safeQuantityQString(ui->wedgeZmax))
|
||||
.arg(safeQuantityQString(ui->wedgeX2max),
|
||||
safeQuantityQString(ui->wedgeZ2max),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1194,10 +1199,10 @@ QString HelixPrimitive::create(const QString& objectName, const QString& placeme
|
||||
"App.ActiveDocument.%1.Placement=%7\n"
|
||||
"App.ActiveDocument.%1.Label='%8'\n")
|
||||
.arg(objectName,
|
||||
ui->helixPitch->value().getSafeUserString(),
|
||||
ui->helixHeight->value().getSafeUserString(),
|
||||
ui->helixRadius->value().getSafeUserString(),
|
||||
ui->helixAngle->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->helixPitch),
|
||||
safeQuantityQString(ui->helixHeight),
|
||||
safeQuantityQString(ui->helixRadius),
|
||||
safeQuantityQString(ui->helixAngle),
|
||||
QString::number(ui->helixLocalCS->currentIndex()),
|
||||
placement,
|
||||
DlgPrimitives::tr("Helix"));
|
||||
@@ -1213,10 +1218,10 @@ QString HelixPrimitive::change(const QString& objectName, const QString& placeme
|
||||
"%1.LocalCoord=%6\n"
|
||||
"%1.Placement=%7\n")
|
||||
.arg(objectName,
|
||||
ui->helixPitch->value().getSafeUserString(),
|
||||
ui->helixHeight->value().getSafeUserString(),
|
||||
ui->helixRadius->value().getSafeUserString(),
|
||||
ui->helixAngle->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->helixPitch),
|
||||
safeQuantityQString(ui->helixHeight),
|
||||
safeQuantityQString(ui->helixRadius),
|
||||
safeQuantityQString(ui->helixAngle),
|
||||
QString::number(ui->helixLocalCS->currentIndex()),
|
||||
placement);
|
||||
}
|
||||
@@ -1285,9 +1290,9 @@ QString SpiralPrimitive::create(const QString& objectName, const QString& placem
|
||||
"App.ActiveDocument.%1.Placement=%5\n"
|
||||
"App.ActiveDocument.%1.Label='%6'\n")
|
||||
.arg(objectName,
|
||||
ui->spiralGrowth->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->spiralGrowth),
|
||||
QString::number(ui->spiralRotation->value()),
|
||||
ui->spiralRadius->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->spiralRadius),
|
||||
placement,
|
||||
DlgPrimitives::tr("Spiral"));
|
||||
}
|
||||
@@ -1300,9 +1305,9 @@ QString SpiralPrimitive::change(const QString& objectName, const QString& placem
|
||||
"%1.Radius='%4'\n"
|
||||
"%1.Placement=%5\n")
|
||||
.arg(objectName,
|
||||
ui->spiralGrowth->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->spiralGrowth),
|
||||
QString::number(ui->spiralRotation->value()),
|
||||
ui->spiralRadius->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->spiralRadius),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1365,9 +1370,9 @@ QString CirclePrimitive::create(const QString& objectName, const QString& placem
|
||||
"App.ActiveDocument.%1.Placement=%5\n"
|
||||
"App.ActiveDocument.%1.Label='%6'\n")
|
||||
.arg(objectName,
|
||||
ui->circleRadius->value().getSafeUserString(),
|
||||
ui->circleAngle1->value().getSafeUserString(),
|
||||
ui->circleAngle2->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->circleRadius),
|
||||
safeQuantityQString(ui->circleAngle1),
|
||||
safeQuantityQString(ui->circleAngle2),
|
||||
placement,
|
||||
DlgPrimitives::tr("Circle"));
|
||||
}
|
||||
@@ -1380,9 +1385,9 @@ QString CirclePrimitive::change(const QString& objectName, const QString& placem
|
||||
"%1.Angle2='%4'\n"
|
||||
"%1.Placement=%5\n")
|
||||
.arg(objectName,
|
||||
ui->circleRadius->value().getSafeUserString(),
|
||||
ui->circleAngle1->value().getSafeUserString(),
|
||||
ui->circleAngle2->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->circleRadius),
|
||||
safeQuantityQString(ui->circleAngle1),
|
||||
safeQuantityQString(ui->circleAngle2),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1450,10 +1455,10 @@ QString EllipsePrimitive::create(const QString& objectName, const QString& place
|
||||
"App.ActiveDocument.%1.Placement=%6\n"
|
||||
"App.ActiveDocument.%1.Label='%7'\n")
|
||||
.arg(objectName,
|
||||
ui->ellipseMajorRadius->value().getSafeUserString(),
|
||||
ui->ellipseMinorRadius->value().getSafeUserString(),
|
||||
ui->ellipseAngle1->value().getSafeUserString(),
|
||||
ui->ellipseAngle2->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->ellipseMajorRadius),
|
||||
safeQuantityQString(ui->ellipseMinorRadius),
|
||||
safeQuantityQString(ui->ellipseAngle1),
|
||||
safeQuantityQString(ui->ellipseAngle2),
|
||||
placement,
|
||||
DlgPrimitives::tr("Ellipse"));
|
||||
}
|
||||
@@ -1467,10 +1472,10 @@ QString EllipsePrimitive::change(const QString& objectName, const QString& place
|
||||
"%1.Angle2='%5'\n"
|
||||
"%1.Placement=%6\n")
|
||||
.arg(objectName,
|
||||
ui->ellipseMajorRadius->value().getSafeUserString(),
|
||||
ui->ellipseMinorRadius->value().getSafeUserString(),
|
||||
ui->ellipseAngle1->value().getSafeUserString(),
|
||||
ui->ellipseAngle2->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->ellipseMajorRadius),
|
||||
safeQuantityQString(ui->ellipseMinorRadius),
|
||||
safeQuantityQString(ui->ellipseAngle1),
|
||||
safeQuantityQString(ui->ellipseAngle2),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1530,7 +1535,7 @@ QString PolygonPrimitive::create(const QString& objectName, const QString& place
|
||||
"App.ActiveDocument.%1.Label='%5'\n")
|
||||
.arg(objectName,
|
||||
QString::number(ui->regularPolygonPolygon->value()),
|
||||
ui->regularPolygonCircumradius->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->regularPolygonCircumradius),
|
||||
placement,
|
||||
DlgPrimitives::tr("Regular polygon"));
|
||||
}
|
||||
@@ -1543,7 +1548,7 @@ QString PolygonPrimitive::change(const QString& objectName, const QString& place
|
||||
"%1.Placement=%4\n")
|
||||
.arg(objectName,
|
||||
QString::number(ui->regularPolygonPolygon->value()),
|
||||
ui->regularPolygonCircumradius->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->regularPolygonCircumradius),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1624,12 +1629,12 @@ QString LinePrimitive::create(const QString& objectName, const QString& placemen
|
||||
"App.ActiveDocument.%1.Placement=%8\n"
|
||||
"App.ActiveDocument.%1.Label='%9'\n")
|
||||
.arg(objectName,
|
||||
ui->edgeX1->value().getSafeUserString(),
|
||||
ui->edgeY1->value().getSafeUserString(),
|
||||
ui->edgeZ1->value().getSafeUserString(),
|
||||
ui->edgeX2->value().getSafeUserString(),
|
||||
ui->edgeY2->value().getSafeUserString(),
|
||||
ui->edgeZ2->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->edgeX1),
|
||||
safeQuantityQString(ui->edgeY1),
|
||||
safeQuantityQString(ui->edgeZ1),
|
||||
safeQuantityQString(ui->edgeX2),
|
||||
safeQuantityQString(ui->edgeY2),
|
||||
safeQuantityQString(ui->edgeZ2),
|
||||
placement,
|
||||
DlgPrimitives::tr("Line"));
|
||||
}
|
||||
@@ -1645,12 +1650,12 @@ QString LinePrimitive::change(const QString& objectName, const QString& placemen
|
||||
"%1.Z2='%7'\n"
|
||||
"%1.Placement=%8\n")
|
||||
.arg(objectName,
|
||||
ui->edgeX1->value().getSafeUserString(),
|
||||
ui->edgeY1->value().getSafeUserString(),
|
||||
ui->edgeZ1->value().getSafeUserString(),
|
||||
ui->edgeX2->value().getSafeUserString(),
|
||||
ui->edgeY2->value().getSafeUserString(),
|
||||
ui->edgeZ2->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->edgeX1),
|
||||
safeQuantityQString(ui->edgeY1),
|
||||
safeQuantityQString(ui->edgeZ1),
|
||||
safeQuantityQString(ui->edgeX2),
|
||||
safeQuantityQString(ui->edgeY2),
|
||||
safeQuantityQString(ui->edgeZ2),
|
||||
placement);
|
||||
}
|
||||
|
||||
@@ -1725,9 +1730,9 @@ QString VertexPrimitive::create(const QString& objectName, const QString& placem
|
||||
"App.ActiveDocument.%1.Placement=%5\n"
|
||||
"App.ActiveDocument.%1.Label='%6'\n")
|
||||
.arg(objectName,
|
||||
ui->vertexX->value().getSafeUserString(),
|
||||
ui->vertexY->value().getSafeUserString(),
|
||||
ui->vertexZ->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->vertexX),
|
||||
safeQuantityQString(ui->vertexY),
|
||||
safeQuantityQString(ui->vertexZ),
|
||||
placement,
|
||||
DlgPrimitives::tr("Vertex"));
|
||||
}
|
||||
@@ -1740,9 +1745,9 @@ QString VertexPrimitive::change(const QString& objectName, const QString& placem
|
||||
"%1.Z='%4'\n"
|
||||
"%1.Placement=%5\n")
|
||||
.arg(objectName,
|
||||
ui->vertexX->value().getSafeUserString(),
|
||||
ui->vertexY->value().getSafeUserString(),
|
||||
ui->vertexZ->value().getSafeUserString(),
|
||||
safeQuantityQString(ui->vertexX),
|
||||
safeQuantityQString(ui->vertexY),
|
||||
safeQuantityQString(ui->vertexZ),
|
||||
placement);
|
||||
}
|
||||
|
||||
|
||||
@@ -811,103 +811,103 @@ void TaskBoxPrimitives::onWedgeZmaxChanged(double v)
|
||||
bool TaskBoxPrimitives::setPrimitive(App::DocumentObject* obj)
|
||||
{
|
||||
try {
|
||||
QString name(QString::fromLatin1(Gui::Command::getObjectCmd(obj).c_str()));
|
||||
QString cmd;
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
if (!doc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string cmd;
|
||||
std::string name(Gui::Command::getObjectCmd(obj));
|
||||
Base::QuantityFormat format(Base::QuantityFormat::Fixed, Base::UnitsApi::getDecimals());
|
||||
switch (ui->widgetStack->currentIndex()) {
|
||||
case 1: // box
|
||||
cmd = QString::fromLatin1("%1.Length='%2'\n"
|
||||
"%1.Width='%3'\n"
|
||||
"%1.Height='%4'\n")
|
||||
.arg(name,
|
||||
ui->boxLength->value().getSafeUserString(),
|
||||
ui->boxWidth->value().getSafeUserString(),
|
||||
ui->boxHeight->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Length='{1}'\n"
|
||||
"{0}.Width='{2}'\n"
|
||||
"{0}.Height='{3}'\n",
|
||||
name,
|
||||
ui->boxLength->value().getSafeUserString(),
|
||||
ui->boxWidth->value().getSafeUserString(),
|
||||
ui->boxHeight->value().getSafeUserString());
|
||||
break;
|
||||
|
||||
case 2: // cylinder
|
||||
cmd = QString::fromLatin1("%1.Radius='%2'\n"
|
||||
"%1.Height='%3'\n"
|
||||
"%1.Angle='%4'\n"
|
||||
"%1.FirstAngle='%5'\n"
|
||||
"%1.SecondAngle='%6'\n")
|
||||
.arg(name,
|
||||
ui->cylinderRadius->value().getSafeUserString(),
|
||||
ui->cylinderHeight->value().getSafeUserString(),
|
||||
ui->cylinderAngle->value().getSafeUserString(),
|
||||
ui->cylinderXSkew->value().getSafeUserString(),
|
||||
ui->cylinderYSkew->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Radius='{1}'\n"
|
||||
"{0}.Height='{2}'\n"
|
||||
"{0}.Angle='{3}'\n"
|
||||
"{0}.FirstAngle='{4}'\n"
|
||||
"{0}.SecondAngle='{5}'\n",
|
||||
name,
|
||||
ui->cylinderRadius->value().getSafeUserString(),
|
||||
ui->cylinderHeight->value().getSafeUserString(),
|
||||
ui->cylinderAngle->value().getSafeUserString(),
|
||||
ui->cylinderXSkew->value().getSafeUserString(),
|
||||
ui->cylinderYSkew->value().getSafeUserString());
|
||||
break;
|
||||
|
||||
case 3: // cone
|
||||
cmd = QString::fromLatin1("%1.Radius1='%2'\n"
|
||||
"%1.Radius2='%3'\n"
|
||||
"%1.Height='%4'\n"
|
||||
"%1.Angle='%5'\n")
|
||||
.arg(name,
|
||||
ui->coneRadius1->value().getSafeUserString(),
|
||||
ui->coneRadius2->value().getSafeUserString(),
|
||||
ui->coneHeight->value().getSafeUserString(),
|
||||
ui->coneAngle->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Radius1='{1}'\n"
|
||||
"{0}.Radius2='{2}'\n"
|
||||
"{0}.Height='{3}'\n"
|
||||
"{0}.Angle='{4}'\n",
|
||||
name,
|
||||
ui->coneRadius1->value().getSafeUserString(),
|
||||
ui->coneRadius2->value().getSafeUserString(),
|
||||
ui->coneHeight->value().getSafeUserString(),
|
||||
ui->coneAngle->value().getSafeUserString());
|
||||
break;
|
||||
|
||||
case 4: // sphere
|
||||
cmd = QString::fromLatin1("%1.Radius='%2'\n"
|
||||
"%1.Angle1='%3'\n"
|
||||
"%1.Angle2='%4'\n"
|
||||
"%1.Angle3='%5'\n")
|
||||
.arg(name,
|
||||
ui->sphereRadius->value().getSafeUserString(),
|
||||
ui->sphereAngle1->value().getSafeUserString(),
|
||||
ui->sphereAngle2->value().getSafeUserString(),
|
||||
ui->sphereAngle3->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Radius='{1}'\n"
|
||||
"{0}.Angle1='{2}'\n"
|
||||
"{0}.Angle2='{3}'\n"
|
||||
"{0}.Angle3='{4}'\n",
|
||||
name,
|
||||
ui->sphereRadius->value().getSafeUserString(),
|
||||
ui->sphereAngle1->value().getSafeUserString(),
|
||||
ui->sphereAngle2->value().getSafeUserString(),
|
||||
ui->sphereAngle3->value().getSafeUserString());
|
||||
break;
|
||||
case 5: // ellipsoid
|
||||
cmd = QString::fromLatin1("%1.Radius1='%2'\n"
|
||||
"%1.Radius2='%3'\n"
|
||||
"%1.Radius3='%4'\n"
|
||||
"%1.Angle1='%5'\n"
|
||||
"%1.Angle2='%6'\n"
|
||||
"%1.Angle3='%7'\n")
|
||||
.arg(name,
|
||||
ui->ellipsoidRadius1->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius2->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius3->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle1->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle2->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle3->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Radius1='{1}'\n"
|
||||
"{0}.Radius2='{2}'\n"
|
||||
"{0}.Radius3='{3}'\n"
|
||||
"{0}.Angle1='{4}'\n"
|
||||
"{0}.Angle2='{5}'\n"
|
||||
"{0}.Angle3='{6}'\n",
|
||||
name,
|
||||
ui->ellipsoidRadius1->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius2->value().getSafeUserString(),
|
||||
ui->ellipsoidRadius3->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle1->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle2->value().getSafeUserString(),
|
||||
ui->ellipsoidAngle3->value().getSafeUserString());
|
||||
break;
|
||||
|
||||
case 6: // torus
|
||||
cmd = QString::fromLatin1("%1.Radius1='%2'\n"
|
||||
"%1.Radius2='%3'\n"
|
||||
"%1.Angle1='%4'\n"
|
||||
"%1.Angle2='%5'\n"
|
||||
"%1.Angle3='%6'\n")
|
||||
.arg(name,
|
||||
ui->torusRadius1->value().getSafeUserString(),
|
||||
ui->torusRadius2->value().getSafeUserString(),
|
||||
ui->torusAngle1->value().getSafeUserString(),
|
||||
ui->torusAngle2->value().getSafeUserString(),
|
||||
ui->torusAngle3->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Radius1='{1}'\n"
|
||||
"{0}.Radius2='{2}'\n"
|
||||
"{0}.Angle1='{3}'\n"
|
||||
"{0}.Angle2='{4}'\n"
|
||||
"{0}.Angle3='{5}'\n",
|
||||
name,
|
||||
ui->torusRadius1->value().getSafeUserString(),
|
||||
ui->torusRadius2->value().getSafeUserString(),
|
||||
ui->torusAngle1->value().getSafeUserString(),
|
||||
ui->torusAngle2->value().getSafeUserString(),
|
||||
ui->torusAngle3->value().getSafeUserString());
|
||||
break;
|
||||
case 7: // prism
|
||||
cmd = QString::fromLatin1("%1.Polygon=%2\n"
|
||||
"%1.Circumradius='%3'\n"
|
||||
"%1.Height='%4'\n"
|
||||
"%1.FirstAngle='%5'\n"
|
||||
"%1.SecondAngle='%6'\n")
|
||||
.arg(name,
|
||||
QString::number(ui->prismPolygon->value()),
|
||||
ui->prismCircumradius->value().getSafeUserString(),
|
||||
ui->prismHeight->value().getSafeUserString(),
|
||||
ui->prismXSkew->value().getSafeUserString(),
|
||||
ui->prismYSkew->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Polygon={1}\n"
|
||||
"{0}.Circumradius='{2}'\n"
|
||||
"{0}.Height='{3}'\n"
|
||||
"{0}.FirstAngle='{4}'\n"
|
||||
"{0}.SecondAngle='{5}'\n",
|
||||
name,
|
||||
ui->prismPolygon->value(),
|
||||
ui->prismCircumradius->value().getSafeUserString(),
|
||||
ui->prismHeight->value().getSafeUserString(),
|
||||
ui->prismXSkew->value().getSafeUserString(),
|
||||
ui->prismYSkew->value().getSafeUserString());
|
||||
break;
|
||||
case 8: // wedge
|
||||
// Xmin/max, Ymin/max and Zmin/max must each not be equal
|
||||
@@ -929,27 +929,27 @@ bool TaskBoxPrimitives::setPrimitive(App::DocumentObject* obj)
|
||||
tr("Z min must not be equal to Z max!"));
|
||||
return false;
|
||||
}
|
||||
cmd = QString::fromLatin1("%1.Xmin='%2'\n"
|
||||
"%1.Ymin='%3'\n"
|
||||
"%1.Zmin='%4'\n"
|
||||
"%1.X2min='%5'\n"
|
||||
"%1.Z2min='%6'\n"
|
||||
"%1.Xmax='%7'\n"
|
||||
"%1.Ymax='%8'\n"
|
||||
"%1.Zmax='%9'\n"
|
||||
"%1.X2max='%10'\n"
|
||||
"%1.Z2max='%11'\n")
|
||||
.arg(name,
|
||||
ui->wedgeXmin->value().getSafeUserString(),
|
||||
ui->wedgeYmin->value().getSafeUserString(),
|
||||
ui->wedgeZmin->value().getSafeUserString(),
|
||||
ui->wedgeX2min->value().getSafeUserString(),
|
||||
ui->wedgeZ2min->value().getSafeUserString(),
|
||||
ui->wedgeXmax->value().getSafeUserString(),
|
||||
ui->wedgeYmax->value().getSafeUserString(),
|
||||
ui->wedgeZmax->value().getSafeUserString())
|
||||
.arg(ui->wedgeX2max->value().getSafeUserString(),
|
||||
ui->wedgeZ2max->value().getSafeUserString());
|
||||
cmd = fmt::format("{0}.Xmin='{1}'\n"
|
||||
"{0}.Ymin='{2}'\n"
|
||||
"{0}.Zmin='{3}'\n"
|
||||
"{0}.X2min='{4}'\n"
|
||||
"{0}.Z2min='{5}'\n"
|
||||
"{0}.Xmax='{6}'\n"
|
||||
"{0}.Ymax='{7}'\n"
|
||||
"{0}.Zmax='{8}'\n"
|
||||
"{0}.X2max='{9}'\n"
|
||||
"{0}.Z2max='{10}'\n",
|
||||
name,
|
||||
ui->wedgeXmin->value().getSafeUserString(),
|
||||
ui->wedgeYmin->value().getSafeUserString(),
|
||||
ui->wedgeZmin->value().getSafeUserString(),
|
||||
ui->wedgeX2min->value().getSafeUserString(),
|
||||
ui->wedgeZ2min->value().getSafeUserString(),
|
||||
ui->wedgeXmax->value().getSafeUserString(),
|
||||
ui->wedgeYmax->value().getSafeUserString(),
|
||||
ui->wedgeZmax->value().getSafeUserString(),
|
||||
ui->wedgeX2max->value().getSafeUserString(),
|
||||
ui->wedgeZ2max->value().getSafeUserString());
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -959,7 +959,7 @@ bool TaskBoxPrimitives::setPrimitive(App::DocumentObject* obj)
|
||||
// Execute the Python block
|
||||
// No need to open a transaction because this is already done in the command
|
||||
// class or when starting to edit a primitive.
|
||||
Gui::Command::runCommand(Gui::Command::Doc, cmd.toUtf8());
|
||||
Gui::Command::runCommand(Gui::Command::Doc, cmd.c_str());
|
||||
Gui::Command::runCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
}
|
||||
catch (const Base::PyException& e) {
|
||||
|
||||
@@ -765,8 +765,8 @@ PyObject* SketchObjectPy::setDatum(PyObject* args)
|
||||
str << "Cannot set the datum because the sketch contains conflicting constraints";
|
||||
}
|
||||
else if (err == -2) {
|
||||
str << "Datum " << (const char*)Quantity.getUserString().toUtf8()
|
||||
<< " for the constraint with index " << Index << " is invalid";
|
||||
str << "Datum " << Quantity.getUserString() << " for the constraint with index "
|
||||
<< Index << " is invalid";
|
||||
}
|
||||
else if (err == -4) {
|
||||
str << "Negative datum values are not valid for the constraint with index " << Index;
|
||||
@@ -778,8 +778,7 @@ PyObject* SketchObjectPy::setDatum(PyObject* args)
|
||||
str << "Cannot set the datum because of invalid geometry";
|
||||
}
|
||||
else {
|
||||
str << "Unexpected problem at setting datum "
|
||||
<< (const char*)Quantity.getUserString().toUtf8()
|
||||
str << "Unexpected problem at setting datum " << Quantity.getUserString()
|
||||
<< " for the constraint with index " << Index;
|
||||
}
|
||||
PyErr_SetString(PyExc_ValueError, str.str().c_str());
|
||||
|
||||
@@ -2095,11 +2095,10 @@ void EditModeConstraintCoinManager::rebuildConstraintNodes(
|
||||
|
||||
QString EditModeConstraintCoinManager::getPresentationString(const Constraint* constraint)
|
||||
{
|
||||
QString nameStr; // name parameter string
|
||||
std::string nameStr; // name parameter string
|
||||
QString valueStr; // dimensional value string
|
||||
QString presentationStr; // final return string
|
||||
QString unitStr; // the actual unit string
|
||||
QString baseUnitStr; // the expected base unit string
|
||||
std::string unitStr; // the actual unit string
|
||||
std::string baseUnitStr; // the expected base unit string
|
||||
double factor; // unit scaling factor, currently not used
|
||||
Base::UnitSystem unitSys; // current unit system
|
||||
|
||||
@@ -2108,10 +2107,11 @@ QString EditModeConstraintCoinManager::getPresentationString(const Constraint* c
|
||||
}
|
||||
|
||||
// Get the current name parameter string of the constraint
|
||||
nameStr = QString::fromStdString(constraint->Name);
|
||||
nameStr = constraint->Name;
|
||||
|
||||
// Get the current value string including units
|
||||
valueStr = constraint->getPresentationValue().getUserString(factor, unitStr);
|
||||
valueStr =
|
||||
QString::fromStdString(constraint->getPresentationValue().getUserString(factor, unitStr));
|
||||
|
||||
// Hide units if user has requested it, is being displayed in the base
|
||||
// units, and the schema being used has a clear base unit in the first
|
||||
@@ -2127,19 +2127,19 @@ QString EditModeConstraintCoinManager::getPresentationString(const Constraint* c
|
||||
switch (unitSys) {
|
||||
case Base::UnitSystem::SI1:
|
||||
case Base::UnitSystem::MmMin:
|
||||
baseUnitStr = QString::fromLatin1("mm");
|
||||
baseUnitStr = "mm";
|
||||
break;
|
||||
|
||||
case Base::UnitSystem::SI2:
|
||||
baseUnitStr = QString::fromLatin1("m");
|
||||
baseUnitStr = "m";
|
||||
break;
|
||||
|
||||
case Base::UnitSystem::ImperialDecimal:
|
||||
baseUnitStr = QString::fromLatin1("in");
|
||||
baseUnitStr = "in";
|
||||
break;
|
||||
|
||||
case Base::UnitSystem::Centimeters:
|
||||
baseUnitStr = QString::fromLatin1("cm");
|
||||
baseUnitStr = "cm";
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2147,9 +2147,9 @@ QString EditModeConstraintCoinManager::getPresentationString(const Constraint* c
|
||||
break;
|
||||
}
|
||||
|
||||
if (!baseUnitStr.isEmpty()) {
|
||||
if (!baseUnitStr.empty()) {
|
||||
// expected unit string matches actual unit string. remove.
|
||||
if (QString::compare(baseUnitStr, unitStr) == 0) {
|
||||
if (baseUnitStr.compare(unitStr) == 0) {
|
||||
// Example code from: Mod/TechDraw/App/DrawViewDimension.cpp:372
|
||||
QRegularExpression rxUnits(
|
||||
QString::fromUtf8(" \\D*$")); // space + any non digits at end of string
|
||||
@@ -2171,17 +2171,19 @@ QString EditModeConstraintCoinManager::getPresentationString(const Constraint* c
|
||||
%N - the constraint name parameter
|
||||
%V - the value of the dimensional constraint, including any unit characters
|
||||
*/
|
||||
if (constraintParameters.bShowDimensionalName && !nameStr.isEmpty()) {
|
||||
if (constraintParameters.bShowDimensionalName && !nameStr.empty()) {
|
||||
QString presentationStr;
|
||||
if (constraintParameters.sDimensionalStringFormat.contains(QLatin1String("%V"))
|
||||
|| constraintParameters.sDimensionalStringFormat.contains(QLatin1String("%N"))) {
|
||||
presentationStr = constraintParameters.sDimensionalStringFormat;
|
||||
presentationStr.replace(QLatin1String("%N"), nameStr);
|
||||
presentationStr.replace(QLatin1String("%N"), QString::fromStdString(nameStr));
|
||||
presentationStr.replace(QLatin1String("%V"), valueStr);
|
||||
}
|
||||
else {
|
||||
// user defined format string does not contain any valid parameter, using default format
|
||||
// "%N = %V"
|
||||
presentationStr = nameStr + QLatin1String(" = ") + valueStr;
|
||||
presentationStr =
|
||||
QString::fromStdString(nameStr) + QString::fromLatin1(" = ") + valueStr;
|
||||
}
|
||||
|
||||
return presentationStr;
|
||||
|
||||
@@ -50,8 +50,7 @@ PropertyConstraintListItem::~PropertyConstraintListItem()
|
||||
QVariant PropertyConstraintListItem::toString(const QVariant& prop) const
|
||||
{
|
||||
const QList<Base::Quantity>& value = prop.value<QList<Base::Quantity>>();
|
||||
QString str;
|
||||
QTextStream out(&str);
|
||||
std::stringstream out;
|
||||
out << "[";
|
||||
for (QList<Base::Quantity>::const_iterator it = value.begin(); it != value.end(); ++it) {
|
||||
if (it != value.begin()) {
|
||||
@@ -60,7 +59,7 @@ QVariant PropertyConstraintListItem::toString(const QVariant& prop) const
|
||||
out << it->getUserString();
|
||||
}
|
||||
out << "]";
|
||||
return QVariant(str);
|
||||
return QVariant(QString::fromStdString(out.str()));
|
||||
}
|
||||
|
||||
void PropertyConstraintListItem::initialize()
|
||||
|
||||
@@ -158,7 +158,8 @@ public:
|
||||
case Sketcher::Diameter:
|
||||
case Sketcher::Angle:
|
||||
name = QString::fromLatin1("%1 (%2)").arg(
|
||||
name, constraint->getPresentationValue().getUserString());
|
||||
name,
|
||||
QString::fromStdString(constraint->getPresentationValue().getUserString()));
|
||||
break;
|
||||
case Sketcher::SnellsLaw: {
|
||||
double v = constraint->getPresentationValue().getValue();
|
||||
|
||||
@@ -719,10 +719,10 @@ std::string SketcherGui::lengthToDisplayFormat(double value, int digits)
|
||||
Base::Quantity asQuantity;
|
||||
asQuantity.setValue(value);
|
||||
asQuantity.setUnit(Base::Unit::Length);
|
||||
QString qUserString = asQuantity.getUserString();
|
||||
std::string userString = asQuantity.getUserString();
|
||||
if (Base::UnitsApi::isMultiUnitLength() || (!hideUnits() && useSystemDecimals())) {
|
||||
// just return the user string
|
||||
return qUserString.toStdString();
|
||||
return userString;
|
||||
}
|
||||
|
||||
// find the unit of measure
|
||||
@@ -734,26 +734,26 @@ std::string SketcherGui::lengthToDisplayFormat(double value, int digits)
|
||||
// get the numeric part of the user string
|
||||
QRegularExpression rxNoUnits(
|
||||
QString::fromUtf8("(.*) \\D*$")); // text before space + any non digits at end of string
|
||||
QRegularExpressionMatch match = rxNoUnits.match(qUserString);
|
||||
QRegularExpressionMatch match = rxNoUnits.match(QString::fromStdString(userString));
|
||||
if (!match.hasMatch()) {
|
||||
// no units in userString?
|
||||
return qUserString.toStdString();
|
||||
return userString;
|
||||
}
|
||||
QString matched = match.captured(1); // matched is the numeric part of user string
|
||||
auto smatched = matched.toStdString();
|
||||
int dpPos = matched.indexOf(QLocale().decimalPoint());
|
||||
if (dpPos < 0) {
|
||||
auto ret = matched.toStdString();
|
||||
// no decimal separator (ie an integer), return all the digits
|
||||
if (!hideUnits()) {
|
||||
ret.append(unitPart.toStdString());
|
||||
smatched.append(unitPart.toStdString());
|
||||
}
|
||||
return ret;
|
||||
return smatched;
|
||||
}
|
||||
|
||||
// real number
|
||||
if (useSystemDecimals() && hideUnits()) {
|
||||
// return just the numeric part of the user string
|
||||
return matched.toStdString();
|
||||
return smatched;
|
||||
}
|
||||
|
||||
// real number and not using system decimals
|
||||
@@ -779,7 +779,7 @@ std::string SketcherGui::angleToDisplayFormat(double value, int digits)
|
||||
Base::Quantity asQuantity;
|
||||
asQuantity.setValue(value);
|
||||
asQuantity.setUnit(Base::Unit::Angle);
|
||||
QString qUserString = asQuantity.getUserString();
|
||||
QString qUserString = QString::fromStdString(asQuantity.getUserString());
|
||||
if (Base::UnitsApi::isMultiUnitAngle()) {
|
||||
// just return the user string
|
||||
// Coin SbString doesn't handle utf8 well, so we convert to ascii
|
||||
@@ -794,7 +794,7 @@ std::string SketcherGui::angleToDisplayFormat(double value, int digits)
|
||||
|
||||
// we always use use U+00B0 (°) as the unit of measure for angles in
|
||||
// single unit schema. Will need a change to support rads or grads.
|
||||
auto qUnitString = QString::fromUtf8("°");
|
||||
std::string unitString = "°";
|
||||
auto decimalSep = QLocale().decimalPoint();
|
||||
|
||||
// get the numeric part of the user string
|
||||
@@ -806,18 +806,12 @@ std::string SketcherGui::angleToDisplayFormat(double value, int digits)
|
||||
return qUserString.toStdString();
|
||||
}
|
||||
QString matched = match.captured(1); // matched is the numeric part of user string
|
||||
auto smatched = matched.toStdString();
|
||||
auto sUnitString = qUnitString.toStdString();
|
||||
int dpPos = matched.indexOf(decimalSep);
|
||||
if (dpPos < 0) {
|
||||
// no decimal separator (ie an integer), return all the digits
|
||||
return smatched + sUnitString;
|
||||
}
|
||||
|
||||
// real number
|
||||
if (useSystemDecimals()) {
|
||||
// return just the numeric part of the user string + degree symbol
|
||||
return smatched + sUnitString;
|
||||
if (dpPos < 0 || useSystemDecimals()) {
|
||||
// just the numeric part of the user string + degree symbol
|
||||
auto angle = matched.toStdString();
|
||||
angle.append(unitString);
|
||||
return angle;
|
||||
}
|
||||
|
||||
// real number and not using system decimals
|
||||
@@ -827,7 +821,7 @@ std::string SketcherGui::angleToDisplayFormat(double value, int digits)
|
||||
requiredLength = matched.size();
|
||||
}
|
||||
auto numericPart = matched.left(requiredLength).toStdString();
|
||||
numericPart.append(sUnitString);
|
||||
numericPart.append(unitString);
|
||||
return numericPart;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,7 @@ void ViewProviderSketch::ParameterObserver::updateGridSize(const std::string& st
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
|
||||
Client.GridSize.setValue(
|
||||
Base::Quantity::parse(
|
||||
QString::fromLatin1(hGrp->GetGroup("GridSize")->GetASCII("GridSize", "10.0").c_str()))
|
||||
Base::Quantity::parse(hGrp->GetGroup("GridSize")->GetASCII("GridSize", "10.0"))
|
||||
.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
|
||||
// When displaying a quantity then use the globally set scheme
|
||||
// See: https://forum.freecad.org/viewtopic.php?f=3&t=50078
|
||||
Base::Quantity value = floatProp->getQuantityValue();
|
||||
v = value.getUserString();
|
||||
v = QString::fromStdString(value.getUserString());
|
||||
}
|
||||
return formatCellDisplay(v, cell);
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ std::string DimensionFormatter::formatValue(const qreal value,
|
||||
asQuantity.setUnit(Base::Unit::Length);
|
||||
}
|
||||
|
||||
QString qUserString = asQuantity.getUserString(); // this handles mm to inch/km/parsec etc
|
||||
// and decimal positions but won't give more than
|
||||
// Global_Decimals precision
|
||||
// this handles mm to inch/km/parsec etc and decimal positions but
|
||||
// won't give more than Global_Decimals precision
|
||||
QString qUserString = QString::fromStdString(asQuantity.getUserString());
|
||||
|
||||
//get formatSpec prefix/suffix/specifier
|
||||
QStringList qsl = getPrefixSuffixSpec(qFormatSpec);
|
||||
@@ -132,7 +132,7 @@ std::string DimensionFormatter::formatValue(const qreal value,
|
||||
qBasicUnit = QString::fromUtf8("°");
|
||||
}
|
||||
else {
|
||||
double convertValue = Base::Quantity::parse(QString::fromLatin1("1") + qBasicUnit).getValue();
|
||||
double convertValue = Base::Quantity::parse("1" + qBasicUnit.toStdString()).getValue();
|
||||
userVal = asQuantity.getValue() / convertValue;
|
||||
if (areaMeasure) {
|
||||
userVal = userVal / convertValue; // divide again as area is length²
|
||||
|
||||
@@ -182,13 +182,13 @@ void DrawSVGTemplate::extractTemplateAttributes(QDomDocument& templateDocument)
|
||||
|
||||
// Obtain the width
|
||||
QString str = docElement.attribute(QString::fromLatin1("width"));
|
||||
quantity = Base::Quantity::parse(str);
|
||||
quantity = Base::Quantity::parse(str.toStdString());
|
||||
quantity.setUnit(Base::Unit::Length);
|
||||
|
||||
Width.setValue(quantity.getValue());
|
||||
|
||||
str = docElement.attribute(QString::fromLatin1("height"));
|
||||
quantity = Base::Quantity::parse(str);
|
||||
quantity = Base::Quantity::parse(str.toStdString());
|
||||
quantity.setUnit(Base::Unit::Length);
|
||||
|
||||
Height.setValue(quantity.getValue());
|
||||
|
||||
@@ -272,8 +272,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
|
||||
if (prop && cell) {
|
||||
if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
|
||||
auto contentAsQuantity = static_cast<App::PropertyQuantity*>(prop)->getQuantityValue();
|
||||
auto ustring = contentAsQuantity.getUserString();
|
||||
field << ustring.toStdString();
|
||||
field << contentAsQuantity.getUserString();
|
||||
} else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()) ||
|
||||
prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
|
||||
std::string temp = cell->getFormattedQuantity();
|
||||
|
||||
@@ -1840,7 +1840,7 @@ void CmdTechDrawExtensionAreaAnnotation::activated(int iMsg)
|
||||
asQuantity.setValue(totalArea);
|
||||
asQuantity.setUnit(Base::Unit::Area);
|
||||
|
||||
QString qUserString = asQuantity.getUserString();
|
||||
QString qUserString = QString::fromStdString(asQuantity.getUserString());
|
||||
if (qUserString.endsWith(QString::fromUtf8("^2"))) {
|
||||
qUserString.chop(2);
|
||||
qUserString.append(QString::fromUtf8("²"));
|
||||
|
||||
@@ -44,8 +44,8 @@ protected:
|
||||
}
|
||||
|
||||
Base::Quantity parse_quantity_text_as_quantity(const char* quantity_text) {
|
||||
auto quantity_qstr = QString::fromStdString(std::string(quantity_text));
|
||||
auto quantity_result = Base::Quantity::parse(quantity_qstr);
|
||||
auto quantity_str = std::string(quantity_text);
|
||||
auto quantity_result = Base::Quantity::parse(quantity_str);
|
||||
return quantity_result;
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ TEST_F(ExpressionParserTest, functionPARSEQUANT)
|
||||
EXPECT_EQ(expression_result, quantity_result) << "mismatch:"
|
||||
" expression_text='" + std::string(expression_text) + "'"
|
||||
" quantity_text='" + std::string(quantity_text) + "'"
|
||||
" expression_representation='" + expression_result.getUserString().toStdString() + "'"
|
||||
" quantity_representation='" + quantity_result.getUserString().toStdString() + "'"
|
||||
" expression_representation='" + expression_result.getUserString() + "'"
|
||||
" quantity_representation='" + quantity_result.getUserString() + "'"
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ TEST_F(PropertyExpressionEngineTest, executeCrossPropertyReference)
|
||||
auto target_value = target_quant.getValue();
|
||||
auto target_unit = target_quant.getUnit().getString();
|
||||
|
||||
auto verify_quant = Base::Quantity::parse(QString::fromStdString(target_text));
|
||||
auto verify_quant = Base::Quantity::parse(target_text);
|
||||
|
||||
EXPECT_EQ(target_quant, verify_quant) << ""
|
||||
"expecting equal: source_text='" + source_text + "' target_text='" + target_text + "'"
|
||||
|
||||
+11
-13
@@ -19,12 +19,10 @@ TEST(BaseQuantity, TestValid)
|
||||
|
||||
TEST(BaseQuantity, TestParse)
|
||||
{
|
||||
Base::Quantity q1 = Base::Quantity::parse(QString::fromLatin1("1,234 kg"));
|
||||
Base::Quantity q1 = Base::Quantity::parse("1,234 kg");
|
||||
|
||||
EXPECT_EQ(q1, Base::Quantity(1.2340, Base::Unit::Mass));
|
||||
EXPECT_THROW(
|
||||
boost::ignore_unused(Base::Quantity::parse(QString::fromLatin1("1,234,500.12 kg"))),
|
||||
Base::ParserError);
|
||||
EXPECT_THROW(boost::ignore_unused(Base::Quantity::parse("1,234,500.12 kg")), Base::ParserError);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestDim)
|
||||
@@ -74,10 +72,10 @@ TEST(BaseQuantity, TestPow3DIV2)
|
||||
|
||||
TEST(BaseQuantity, TestString)
|
||||
{
|
||||
Base::Quantity q1 {2, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q1 {2, "kg*m/s^2"};
|
||||
EXPECT_EQ(q1.getUnit(), Base::Unit::Force);
|
||||
|
||||
Base::Quantity q2 {2, QString::fromLatin1("kg*m^2/s^2")};
|
||||
Base::Quantity q2 {2, "kg*m^2/s^2"};
|
||||
EXPECT_EQ(q2.getUnit(), Base::Unit::Work);
|
||||
}
|
||||
|
||||
@@ -91,7 +89,7 @@ TEST(BaseQuantity, TestCopy)
|
||||
TEST(BaseQuantity, TestEqual)
|
||||
{
|
||||
Base::Quantity q1 {1.0, Base::Unit::Force};
|
||||
Base::Quantity q2 {1.0, QString::fromLatin1("kg*mm/s^2")};
|
||||
Base::Quantity q2 {1.0, "kg*mm/s^2"};
|
||||
|
||||
EXPECT_EQ(q1 == q1, true);
|
||||
EXPECT_EQ(q1 == q2, true);
|
||||
@@ -100,7 +98,7 @@ TEST(BaseQuantity, TestEqual)
|
||||
TEST(BaseQuantity, TestNotEqual)
|
||||
{
|
||||
Base::Quantity q1 {1.0, Base::Unit::Force};
|
||||
Base::Quantity q2 {2.0, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q2 {2.0, "kg*m/s^2"};
|
||||
Base::Quantity q3 {1.0, Base::Unit::Work};
|
||||
|
||||
EXPECT_EQ(q1 != q2, true);
|
||||
@@ -110,7 +108,7 @@ TEST(BaseQuantity, TestNotEqual)
|
||||
TEST(BaseQuantity, TestLessOrGreater)
|
||||
{
|
||||
Base::Quantity q1 {1.0, Base::Unit::Force};
|
||||
Base::Quantity q2 {2.0, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q2 {2.0, "kg*m/s^2"};
|
||||
Base::Quantity q3 {2.0, Base::Unit::Work};
|
||||
|
||||
EXPECT_EQ(q1 < q2, true);
|
||||
@@ -223,9 +221,9 @@ TEST_F(Quantity, TestSafeUserString)
|
||||
format.precision = 1;
|
||||
quantity.setFormat(format);
|
||||
|
||||
QString result = quantity.getSafeUserString();
|
||||
std::string result = quantity.getSafeUserString();
|
||||
|
||||
EXPECT_EQ(result.toStdString(), "1 mm");
|
||||
EXPECT_EQ(result, "1 mm");
|
||||
|
||||
Base::UnitsApi::setSchema(Base::UnitSystem::Imperial1);
|
||||
|
||||
@@ -234,13 +232,13 @@ TEST_F(Quantity, TestSafeUserString)
|
||||
|
||||
result = quantity.getSafeUserString();
|
||||
|
||||
EXPECT_EQ(result.toStdString(), "1.0 \\'");
|
||||
EXPECT_EQ(result, "1.0 \\'");
|
||||
|
||||
quantity = Base::Quantity {25.4, Base::Unit::Length};
|
||||
quantity.setFormat(format);
|
||||
|
||||
result = quantity.getSafeUserString();
|
||||
|
||||
EXPECT_EQ(result.toStdString(), "1.0 \\\"");
|
||||
EXPECT_EQ(result, "1.0 \\\"");
|
||||
}
|
||||
// NOLINTEND
|
||||
|
||||
@@ -32,19 +32,19 @@ private Q_SLOTS:
|
||||
void test_SimpleBaseUnit() // NOLINT
|
||||
{
|
||||
auto result = qsb->valueFromText("1mm");
|
||||
QCOMPARE(result, Base::Quantity(1, QLatin1String("mm")));
|
||||
QCOMPARE(result, Base::Quantity(1, "mm"));
|
||||
}
|
||||
|
||||
void test_UnitInNumerator() // NOLINT
|
||||
{
|
||||
auto result = qsb->valueFromText("1mm/10");
|
||||
QCOMPARE(result, Base::Quantity(0.1, QLatin1String("mm")));
|
||||
QCOMPARE(result, Base::Quantity(0.1, "mm"));
|
||||
}
|
||||
|
||||
void test_UnitInDenominator() // NOLINT
|
||||
{
|
||||
auto result = qsb->valueFromText("1/10mm");
|
||||
QCOMPARE(result, Base::Quantity(0.1, QLatin1String("mm")));
|
||||
QCOMPARE(result, Base::Quantity(0.1, "mm"));
|
||||
}
|
||||
|
||||
void test_KeepFormat() // NOLINT
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST_F(TestMaterialValue, TestQuantityType)
|
||||
EXPECT_EQ(variant.toString().size(), 0);
|
||||
auto quantity = variant.value<Base::Quantity>();
|
||||
EXPECT_FALSE(quantity.isValid());
|
||||
EXPECT_EQ(quantity.getUserString(), QString::fromStdString("nan "));
|
||||
EXPECT_EQ(quantity.getUserString(), "nan ");
|
||||
EXPECT_TRUE(std::isnan(quantity.getValue()));
|
||||
|
||||
// Test a copy
|
||||
@@ -146,7 +146,7 @@ TEST_F(TestMaterialValue, TestQuantityType)
|
||||
EXPECT_EQ(variant.toString().size(), 0);
|
||||
quantity = variant.value<Base::Quantity>();
|
||||
EXPECT_FALSE(quantity.isValid());
|
||||
EXPECT_EQ(quantity.getUserString(), QString::fromStdString("nan "));
|
||||
EXPECT_EQ(quantity.getUserString(), "nan ");
|
||||
EXPECT_TRUE(std::isnan(quantity.getValue()));
|
||||
}
|
||||
|
||||
@@ -246,27 +246,27 @@ TEST_F(TestMaterialValue, TestArray3DType)
|
||||
EXPECT_EQ(mat2.rows(1), 1);
|
||||
EXPECT_EQ(mat2.rows(2), 2);
|
||||
|
||||
quantity = Base::Quantity::parse(QString::fromStdString("32 C"));
|
||||
quantity = Base::Quantity::parse("32 C");
|
||||
mat2.setDepthValue(quantity);
|
||||
EXPECT_FALSE(mat2.getDepthValue(0).isValid());
|
||||
EXPECT_FALSE(mat2.getDepthValue(1).isValid());
|
||||
EXPECT_TRUE(mat2.getDepthValue(2).isValid());
|
||||
EXPECT_EQ(mat2.getDepthValue(2), Base::Quantity::parse(QString::fromStdString("32 C")));
|
||||
EXPECT_EQ(mat2.getDepthValue(2), Base::Quantity::parse("32 C"));
|
||||
|
||||
mat2.setDepthValue(0, Base::Quantity::parse(QString::fromStdString("9.8 m/s/s")));
|
||||
mat2.setDepthValue(0, Base::Quantity::parse("9.8 m/s/s"));
|
||||
EXPECT_TRUE(mat2.getDepthValue(0).isValid());
|
||||
EXPECT_FALSE(mat2.getDepthValue(1).isValid());
|
||||
EXPECT_TRUE(mat2.getDepthValue(2).isValid());
|
||||
EXPECT_EQ(mat2.getDepthValue(0), Base::Quantity::parse(QString::fromStdString("9.8 m/s/s")));
|
||||
EXPECT_EQ(mat2.getDepthValue(2), Base::Quantity::parse(QString::fromStdString("32 C")));
|
||||
EXPECT_EQ(mat2.getDepthValue(0), Base::Quantity::parse("9.8 m/s/s"));
|
||||
EXPECT_EQ(mat2.getDepthValue(2), Base::Quantity::parse("32 C"));
|
||||
|
||||
mat2.setDepthValue(1, Base::Quantity::parse(QString::fromStdString("120 MPa")));
|
||||
mat2.setDepthValue(1, Base::Quantity::parse("120 MPa"));
|
||||
EXPECT_TRUE(mat2.getDepthValue(0).isValid());
|
||||
EXPECT_TRUE(mat2.getDepthValue(1).isValid());
|
||||
EXPECT_TRUE(mat2.getDepthValue(2).isValid());
|
||||
EXPECT_EQ(mat2.getDepthValue(0), Base::Quantity::parse(QString::fromStdString("9.8 m/s/s")));
|
||||
EXPECT_EQ(mat2.getDepthValue(1), Base::Quantity::parse(QString::fromStdString("120 MPa")));
|
||||
EXPECT_EQ(mat2.getDepthValue(2), Base::Quantity::parse(QString::fromStdString("32 C")));
|
||||
EXPECT_EQ(mat2.getDepthValue(0), Base::Quantity::parse("9.8 m/s/s"));
|
||||
EXPECT_EQ(mat2.getDepthValue(1), Base::Quantity::parse("120 MPa"));
|
||||
EXPECT_EQ(mat2.getDepthValue(2), Base::Quantity::parse("32 C"));
|
||||
|
||||
// Rows are currently empty
|
||||
EXPECT_THROW(mat2.getValue(2, 0), Materials::InvalidIndex);
|
||||
@@ -275,12 +275,11 @@ TEST_F(TestMaterialValue, TestArray3DType)
|
||||
EXPECT_FALSE(mat2.getValue(0, 1).isValid());
|
||||
|
||||
// set to a valid quantity
|
||||
mat2.setValue(0, 0, Base::Quantity::parse(QString::fromStdString("120 MPa")));
|
||||
mat2.setValue(0, 0, Base::Quantity::parse("120 MPa"));
|
||||
EXPECT_TRUE(mat2.getValue(0, 0).isValid());
|
||||
mat2.setValue(0, 1, Base::Quantity::parse(QString::fromStdString("9.8 m/s/s")));
|
||||
mat2.setValue(0, 1, Base::Quantity::parse("9.8 m/s/s"));
|
||||
EXPECT_TRUE(mat2.getValue(0, 1).isValid());
|
||||
EXPECT_THROW(mat2.setValue(0, 2, Base::Quantity::parse(QString::fromStdString("32 C"))), Materials::InvalidIndex);
|
||||
|
||||
EXPECT_THROW(mat2.setValue(0, 2, Base::Quantity::parse("32 C")), Materials::InvalidIndex);
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
||||
@@ -221,12 +221,11 @@ TEST_F(TestMaterial, TestAddAppearanceModel)
|
||||
EXPECT_EQ(models->size(), 0);
|
||||
}
|
||||
|
||||
QString parseQuantity(const char *string)
|
||||
QString parseQuantity(const std::string& value)
|
||||
{
|
||||
QString value = QString::fromStdString(string);
|
||||
auto quantity = Base::Quantity::parse(value);
|
||||
quantity.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return quantity.getUserString();
|
||||
return QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
|
||||
TEST_F(TestMaterial, TestCalculiXSteel)
|
||||
@@ -343,12 +342,11 @@ TEST_F(TestMaterial, TestCalculiXSteel)
|
||||
EXPECT_EQ(steel->getAppearanceValue(QString::fromStdString("SpecularColor")), QString::fromStdString("(0.9800, 0.9800, 0.9800, 1.0)"));
|
||||
EXPECT_DOUBLE_EQ(steel->getAppearanceValue(QString::fromStdString("Transparency")).toDouble(), 0.0);
|
||||
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("Density")).getUserString(), parseQuantity("7900.00 kg/m^3"));
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("YoungsModulus")).getUserString(), parseQuantity("210.00 GPa"));
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("SpecificHeat")).getUserString(), parseQuantity("590.00 J/kg/K"));
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("ThermalConductivity")).getUserString(), parseQuantity("43.00 W/m/K"));
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("ThermalExpansionCoefficient")).getUserString(), parseQuantity("12.00 µm/m/K"));
|
||||
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("Density")).getUserString(), parseQuantity("7900.00 kg/m^3").toStdString());
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("YoungsModulus")).getUserString(), parseQuantity("210.00 GPa").toStdString());
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("SpecificHeat")).getUserString(), parseQuantity("590.00 J/kg/K").toStdString());
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("ThermalConductivity")).getUserString(), parseQuantity("43.00 W/m/K").toStdString());
|
||||
EXPECT_EQ(steel->getPhysicalQuantity(QString::fromStdString("ThermalExpansionCoefficient")).getUserString(), parseQuantity("12.00 µm/m/K").toStdString());
|
||||
}
|
||||
|
||||
TEST_F(TestMaterial, TestColumns)
|
||||
|
||||
Reference in New Issue
Block a user