Fixed bug in Tape. Each Window should has own size and height values.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-08-04 20:29:43 +03:00
parent 825b0b1431
commit 3999ebd82e
51 changed files with 364 additions and 290 deletions

View File

@ -83,6 +83,8 @@ TMainWindow::TMainWindow(QWidget *parent)
mUnit(Unit::Cm),
pUnit(Unit::Cm),
mType(MeasurementsType::Individual),
currentSize(0),
currentHeight(0),
curFile(),
gradationHeights(nullptr),
gradationSizes(nullptr),
@ -179,7 +181,7 @@ void TMainWindow::SetBaseMHeight(int height)
if (mType == MeasurementsType::Multisize)
{
const int row = ui->tableWidget->currentRow();
VContainer::SetHeight(UnitConvertor(height, Unit::Cm, mUnit));
currentHeight = UnitConvertor(height, Unit::Cm, mUnit);
RefreshData();
ui->tableWidget->selectRow(row);
}
@ -194,7 +196,7 @@ void TMainWindow::SetBaseMSize(int size)
if (mType == MeasurementsType::Multisize)
{
const int row = ui->tableWidget->currentRow();
VContainer::SetSize(UnitConvertor(size, Unit::Cm, mUnit));
currentSize = UnitConvertor(size, Unit::Cm, mUnit);
RefreshData();
ui->tableWidget->selectRow(row);
}
@ -250,6 +252,8 @@ bool TMainWindow::LoadFile(const QString &path)
data = new VContainer(qApp->TrVars(), &mUnit);
m = new VMeasurements(data);
m->SetSize(&currentSize);
m->SetHeight(&currentHeight);
m->setXMLContent(path);
mType = m->Type();
@ -284,8 +288,8 @@ bool TMainWindow::LoadFile(const QString &path)
mUnit = m->MUnit();
pUnit = mUnit;
VContainer::SetHeight(m->BaseHeight());
VContainer::SetSize(m->BaseSize());
currentSize = m->BaseSize();
currentHeight = m->BaseHeight();
ui->labelToolTip->setVisible(false);
ui->tabWidget->setVisible(true);
@ -358,12 +362,14 @@ void TMainWindow::FileNew()
mType = measurements.Type();
data = new VContainer(qApp->TrVars(), &mUnit);
VContainer::SetHeight(measurements.BaseHeight());
VContainer::SetSize(measurements.BaseSize());
currentHeight = measurements.BaseHeight();
currentSize = measurements.BaseSize();
if (mType == MeasurementsType::Multisize)
{
m = new VMeasurements(mUnit, measurements.BaseSize(), measurements.BaseHeight(), data);
m->SetSize(&currentSize);
m->SetHeight(&currentHeight);
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
}
@ -1416,7 +1422,7 @@ void TMainWindow::ImportFromPattern()
void TMainWindow::ChangedSize(const QString &text)
{
const int row = ui->tableWidget->currentRow();
VContainer::SetSize(text.toInt());
currentSize = text.toInt();
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row);
@ -1426,7 +1432,7 @@ void TMainWindow::ChangedSize(const QString &text)
void TMainWindow::ChangedHeight(const QString &text)
{
const int row = ui->tableWidget->currentRow();
VContainer::SetHeight(text.toInt());
currentHeight = text.toInt();
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row);
@ -1489,7 +1495,8 @@ void TMainWindow::ShowNewMData(bool fresh)
ui->doubleSpinBoxInHeights->blockSignals(true);
const QString postfix = UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch)
const qreal value = UnitConvertor(data->GetTableValue(meash->GetName(), mType), mUnit, pUnit);
const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit,
pUnit);
ui->labelCalculatedValue->setText(qApp->LocaleToString(value) + " " +postfix);
if (fresh)
@ -2353,7 +2360,7 @@ void TMainWindow::SetDefaultHeight(int value)
}
else
{
VContainer::SetHeight(gradationHeights->currentText().toInt());
currentHeight = gradationHeights->currentText().toInt();
}
}
@ -2367,7 +2374,7 @@ void TMainWindow::SetDefaultSize(int value)
}
else
{
VContainer::SetSize(gradationSizes->currentText().toInt());
currentSize = gradationSizes->currentText().toInt();
}
}
@ -2453,7 +2460,8 @@ void TMainWindow::RefreshTable(bool freshCall)
AddCell(qApp->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, Qt::AlignVCenter);
}
const qreal value = UnitConvertor(data->GetTableValue(meash->GetName(), mType), mUnit, pUnit);
const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit,
pUnit);
AddCell(locale().toString(value), currentRow, ColumnCalcValue,
Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value
@ -2669,7 +2677,7 @@ bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer
}
f.replace("\n", " ");
QScopedPointer<Calculator> cal(new Calculator());
qreal result = cal->EvalFormula(data->PlainVariables(), f);
qreal result = cal->EvalFormula(data->DataVariables(), f);
if (qIsInf(result) || qIsNaN(result))
{
@ -2836,6 +2844,8 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
data = new VContainer(qApp->TrVars(), &mUnit);
m = new VMeasurements(data);
m->SetSize(&currentSize);
m->SetHeight(&currentHeight);
m->setXMLContent(path);
mType = m->Type();
@ -2868,8 +2878,8 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
mUnit = m->MUnit();
pUnit = mUnit;
VContainer::SetHeight(m->BaseHeight());
VContainer::SetSize(m->BaseSize());
currentHeight = m->BaseHeight();
currentSize = m->BaseSize();
ui->labelToolTip->setVisible(false);
ui->tabWidget->setVisible(true);

View File

@ -135,6 +135,8 @@ private:
Unit mUnit;
Unit pUnit;
MeasurementsType mType;
qreal currentSize;
qreal currentHeight;
QString curFile;
QComboBox *gradationHeights;
QComboBox *gradationSizes;

View File

@ -352,7 +352,7 @@ bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse
}
f.replace("\n", " ");
QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(data->PlainVariables(), f);
const qreal result = cal->EvalFormula(data->DataVariables(), f);
if (qIsInf(result) || qIsNaN(result))
{

View File

@ -377,6 +377,8 @@ QSharedPointer<VMeasurements> MainWindow::OpenMeasurementFile(const QString &pat
try
{
m = QSharedPointer<VMeasurements>(new VMeasurements(pattern));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
m->setXMLContent(path);
if (m->Type() == MeasurementsType::Unknown)
@ -451,8 +453,8 @@ bool MainWindow::LoadMeasurements(const QString &path)
if (m->Type() == MeasurementsType::Multisize)
{
m->SetDataSize();
m->SetDataHeight();
VContainer::SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
VContainer::SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
}
try
@ -4127,6 +4129,8 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
// Here comes undocumented Valentina's feature.
// Because app bundle in Mac OS X doesn't allow setup assosiation for Tape we must do this through Valentina
VMeasurements m(pattern);
m.SetSize(VContainer::rsize());
m.SetHeight(VContainer::rheight());
m.setXMLContent(fileName);
if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual)
@ -4626,6 +4630,8 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
else
{
QScopedPointer<VMeasurements> m(new VMeasurements(pattern));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
m->setXMLContent(mPath);
patternType = m->Type();

View File

@ -3015,7 +3015,7 @@ qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok)
QString f = formula;
f.replace("\n", " ");
QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(data->PlainVariables(), f);
const qreal result = cal->EvalFormula(data->DataVariables(), f);
(qIsInf(result) || qIsNaN(result)) ? *ok = false : *ok = true;
return result;

View File

@ -98,7 +98,9 @@ QString FileComment()
VMeasurements::VMeasurements(VContainer *data)
:VDomDocument(),
data(data),
type(MeasurementsType::Unknown)
type(MeasurementsType::Unknown),
m_currentSize(nullptr),
m_currentHeight(nullptr)
{
SCASSERT(data != nullptr)
}
@ -107,7 +109,9 @@ VMeasurements::VMeasurements(VContainer *data)
VMeasurements::VMeasurements(Unit unit, VContainer *data)
:VDomDocument(),
data(data),
type(MeasurementsType::Individual)
type(MeasurementsType::Individual),
m_currentSize(nullptr),
m_currentHeight(nullptr)
{
SCASSERT(data != nullptr)
@ -118,7 +122,9 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
VMeasurements::VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data)
:VDomDocument(),
data(data),
type(MeasurementsType::Multisize)
type(MeasurementsType::Multisize),
m_currentSize(nullptr),
m_currentHeight(nullptr)
{
SCASSERT(data != nullptr)
@ -294,6 +300,9 @@ void VMeasurements::ReadMeasurements() const
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, BaseSize(),
BaseHeight(), base, ksize, kheight));
tempMeash->SetSize(m_currentSize);
tempMeash->SetHeight(m_currentHeight);
tempMeash->SetUnit(data->GetPatternUnit());
base = UnitConvertor(base, MUnit(), *data->GetPatternUnit());
ksize = UnitConvertor(ksize, MUnit(), *data->GetPatternUnit());
@ -304,6 +313,9 @@ void VMeasurements::ReadMeasurements() const
meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
base, ksize, kheight, fullName, description));
meash->SetSize(m_currentSize);
meash->SetHeight(m_currentHeight);
meash->SetUnit(data->GetPatternUnit());
}
else
{
@ -497,6 +509,18 @@ void VMeasurements::SetReadOnly(bool ro)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetSize(qreal *size)
{
m_currentSize = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetHeight(qreal *height)
{
m_currentHeight = height;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMName(const QString &name, const QString &text)
{
@ -684,15 +708,9 @@ bool VMeasurements::IsDefinedKnownNamesValid() const
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetDataSize()
VContainer *VMeasurements::GetData() const
{
VContainer::SetSize(UnitConvertor(BaseSize(), MUnit(), *data->GetPatternUnit()));
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetDataHeight()
{
VContainer::SetHeight(UnitConvertor(BaseHeight(), MUnit(), *data->GetPatternUnit()));
return data;
}
//---------------------------------------------------------------------------------------------------------------------
@ -901,7 +919,7 @@ qreal VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool
QString f = formula;
f.replace("\n", " ");
QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(data->PlainVariables(), f);
const qreal result = cal->EvalFormula(data->DataVariables(), f);
(qIsInf(result) || qIsNaN(result)) ? *ok = false : *ok = true;
return result;

View File

@ -93,6 +93,9 @@ public:
bool IsReadOnly() const;
void SetReadOnly(bool ro);
void SetSize(qreal *size);
void SetHeight(qreal *height);
void SetMName(const QString &name, const QString &text);
void SetMValue(const QString &name, const QString &text);
void SetMBaseValue(const QString &name, double value);
@ -137,8 +140,7 @@ public:
bool IsDefinedKnownNamesValid() const;
void SetDataSize();
void SetDataHeight();
VContainer *GetData() const;
private:
Q_DISABLE_COPY(VMeasurements)
@ -147,6 +149,9 @@ private:
VContainer *data;
MeasurementsType type;
qreal *m_currentSize;
qreal *m_currentHeight;
void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight);
void CreateEmptyIndividualFile(Unit unit);

View File

@ -83,7 +83,7 @@ bool FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
try
{
Calculator cal1;
rotationAngle = cal1.EvalFormula(pattern->PlainVariables(), labelData.GetRotation());
rotationAngle = cal1.EvalFormula(pattern->DataVariables(), labelData.GetRotation());
}
catch(qmu::QmuParserError &e)
{
@ -119,10 +119,10 @@ bool FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
try
{
Calculator cal1;
labelWidth = cal1.EvalFormula(pattern->PlainVariables(), labelData.GetLabelWidth());
labelWidth = cal1.EvalFormula(pattern->DataVariables(), labelData.GetLabelWidth());
Calculator cal2;
labelHeight = cal2.EvalFormula(pattern->PlainVariables(), labelData.GetLabelHeight());
labelHeight = cal2.EvalFormula(pattern->DataVariables(), labelData.GetLabelHeight());
}
catch(qmu::QmuParserError &e)
{
@ -194,11 +194,11 @@ bool FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern
try
{
Calculator cal1;
rotationAngle = cal1.EvalFormula(pattern->PlainVariables(), geom.GetRotation());
rotationAngle = cal1.EvalFormula(pattern->DataVariables(), geom.GetRotation());
rotationAngle = qDegreesToRadians(rotationAngle);
Calculator cal2;
length = cal2.EvalFormula(pattern->PlainVariables(), geom.GetLength());
length = cal2.EvalFormula(pattern->DataVariables(), geom.GetLength());
length = ToPixel(length, *pattern->GetPatternUnit());
}
catch(qmu::QmuParserError &e)

View File

@ -35,6 +35,7 @@
#include "../vmisc/def.h"
#include "../qmuparser/qmuparsererror.h"
#include "variables/vinternalvariable.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -69,7 +70,7 @@ Calculator::Calculator()
* @param formula string of formula.
* @return value of formula.
*/
qreal Calculator::EvalFormula(const QHash<QString, qreal *> &vars, const QString &formula)
qreal Calculator::EvalFormula(const QHash<QString, QSharedPointer<VInternalVariable>> *vars, const QString &formula)
{
// Parser doesn't know any variable on this stage. So, we just use variable factory that for each unknown variable
// set value to 0.
@ -115,16 +116,16 @@ qreal Calculator::EvalFormula(const QHash<QString, qreal *> &vars, const QString
* @param tokens all tokens (measurements names, variables with lengths) that parser have found in expression.
* @param formula expression, need for throwing better error message.
*/
void Calculator::InitVariables(const QHash<QString, qreal *> &vars, const QMap<int, QString> &tokens,
const QString &formula)
void Calculator::InitVariables(const QHash<QString, QSharedPointer<VInternalVariable> > *vars,
const QMap<int, QString> &tokens, const QString &formula)
{
QMap<int, QString>::const_iterator i = tokens.constBegin();
while (i != tokens.constEnd())
{
bool found = false;
if (vars.contains(i.value()))
if (vars->contains(i.value()))
{
DefineVar(i.value(), vars.value(i.value()));
DefineVar(i.value(), vars->value(i.value())->GetValue());
found = true;
}

View File

@ -37,6 +37,8 @@
#include "../qmuparser/qmuformulabase.h"
class VInternalVariable;
/**
* @brief The Calculator class for calculation formula.
*
@ -61,11 +63,12 @@ public:
Calculator();
virtual ~Calculator() Q_DECL_EQ_DEFAULT;
qreal EvalFormula(const QHash<QString, qreal *> &vars, const QString &formula);
qreal EvalFormula(const QHash<QString, QSharedPointer<VInternalVariable> > *vars, const QString &formula);
private:
Q_DISABLE_COPY(Calculator)
void InitVariables(const QHash<QString, qreal *> &vars, const QMap<int, QString> &tokens, const QString &formula);
void InitVariables(const QHash<QString, QSharedPointer<VInternalVariable> > *vars, const QMap<int, QString> &tokens,
const QString &formula);
};
#endif // CALCULATOR_H

View File

@ -51,9 +51,10 @@ VIncrement::VIncrement()
*/
VIncrement::VIncrement(VContainer *data, const QString &name, quint32 index, qreal base, const QString &formula,
bool ok, const QString &description)
:VVariable(name, base, description), d(new VIncrementData(data, index, formula, ok))
:VVariable(name, description), d(new VIncrementData(data, index, formula, ok))
{
SetType(VarType::Increment);
VInternalVariable::SetValue(base);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -79,6 +79,7 @@ qreal *VInternalVariable::GetValue()
return &d->value;
}
//---------------------------------------------------------------------------------------------------------------------
void VInternalVariable::SetValue(const qreal &value)
{
d->value = value;

View File

@ -54,9 +54,8 @@ public:
void Swap(VInternalVariable &var) Q_DECL_NOTHROW
{ std::swap(d, var.d); }
qreal GetValue() const;
qreal* GetValue();
void SetValue(const qreal &value);
virtual qreal GetValue() const;
virtual qreal* GetValue();
QString GetName() const;
void SetName(const QString &name);
@ -67,6 +66,8 @@ public:
virtual bool Filter(quint32 id);
virtual bool IsNotUsed() const;
protected:
void SetValue(const qreal &value);
private:
QSharedDataPointer<VInternalVariableData> d;
};

View File

@ -50,10 +50,11 @@
VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseSize, qreal baseHeight, const qreal &base,
const qreal &ksize, const qreal &kheight, const QString &gui_text,
const QString &description, const QString &tagName)
:VVariable(name, baseSize, baseHeight, base, ksize, kheight, description),
d(new VMeasurementData(index, gui_text, tagName))
:VVariable(name, description),
d(new VMeasurementData(index, gui_text, tagName, baseSize, baseHeight, base, ksize, kheight))
{
SetType(VarType::Measurement);
VInternalVariable::SetValue(d->base);
}
//---------------------------------------------------------------------------------------------------------------------
@ -68,9 +69,10 @@ VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseSize, q
VMeasurement::VMeasurement(VContainer *data, quint32 index, const QString &name, const qreal &base,
const QString &formula, bool ok, const QString &gui_text, const QString &description,
const QString &tagName)
:VVariable(name, base, description), d(new VMeasurementData(data, index, formula, ok, gui_text, tagName))
:VVariable(name, description), d(new VMeasurementData(data, index, formula, ok, gui_text, tagName, base))
{
SetType(VarType::Measurement);
VInternalVariable::SetValue(base);
}
//---------------------------------------------------------------------------------------------------------------------
@ -212,6 +214,29 @@ bool VMeasurement::IsGradationHeightValid(const QString &height)
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::CalcValue() const
{
if (d->currentUnit == nullptr || d->currentSize == nullptr || d->currentHeight == nullptr)
{
return VInternalVariable::GetValue();
}
if (*d->currentUnit == Unit::Inch)
{
qWarning("Gradation doesn't support inches");
return 0;
}
const qreal sizeIncrement = UnitConvertor(2.0, Unit::Cm, *d->currentUnit);
const qreal heightIncrement = UnitConvertor(6.0, Unit::Cm, *d->currentUnit);
// Formula for calculation gradation
const qreal k_size = ( *d->currentSize - d->baseSize ) / sizeIncrement;
const qreal k_height = ( *d->currentHeight - d->baseHeight ) / heightIncrement;
return d->base + k_size * d->ksize + k_height * d->kheight;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::ListValue(QStringList &list, qreal value, Unit patternUnit)
{
@ -251,14 +276,7 @@ QString VMeasurement::GetFormula() const
//---------------------------------------------------------------------------------------------------------------------
bool VMeasurement::IsCustom() const
{
if (GetName().indexOf(CustomMSign) == 0)
{
return true;
}
else
{
return false;
}
return GetName().indexOf(CustomMSign) == 0;
}
//---------------------------------------------------------------------------------------------------------------------
@ -273,8 +291,95 @@ bool VMeasurement::IsFormulaOk() const
return d->formulaOk;
}
//---------------------------------------------------------------------------------------------------------------------
bool VMeasurement::IsNotUsed() const
{
return qFuzzyIsNull(d->base) && qFuzzyIsNull(d->ksize) && qFuzzyIsNull(d->kheight);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetValue() const
{
return CalcValue();
}
//---------------------------------------------------------------------------------------------------------------------
qreal *VMeasurement::GetValue()
{
VInternalVariable::SetValue(CalcValue());
return VInternalVariable::GetValue();
}
//---------------------------------------------------------------------------------------------------------------------
VContainer *VMeasurement::GetData()
{
return &d->data;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetSize(qreal *size)
{
d->currentSize = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetHeight(qreal *height)
{
d->currentHeight = height;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetUnit(const Unit *unit)
{
d->currentUnit = unit;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetBase return value in base size and height
* @return value
*/
qreal VMeasurement::GetBase() const
{
return d->base;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetBase(const qreal &value)
{
d->base = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKsize return increment in sizes
* @return increment
*/
qreal VMeasurement::GetKsize() const
{
return d->ksize;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VMeasurement::SetKsize(const qreal &value)
{
d->ksize = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKheight return increment in heights
* @return increment
*/
qreal VMeasurement::GetKheight() const
{
return d->kheight;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VMeasurement::SetKheight(const qreal &value)
{
d->kheight = value;
}

View File

@ -80,8 +80,26 @@ public:
int Index() const;
bool IsFormulaOk() const;
virtual bool IsNotUsed() const Q_DECL_OVERRIDE;
virtual qreal GetValue() const Q_DECL_OVERRIDE;
virtual qreal* GetValue() Q_DECL_OVERRIDE;
VContainer *GetData();
void SetSize(qreal *size);
void SetHeight(qreal *height);
void SetUnit(const Unit *unit);
qreal GetBase() const;
void SetBase(const qreal &value);
qreal GetKsize() const;
void SetKsize(const qreal &value);
qreal GetKheight() const;
void SetKheight(const qreal &value);
static QStringList ListHeights(QMap<GHeights, bool> heights, Unit patternUnit);
static QStringList ListSizes(QMap<GSizes, bool> sizes, Unit patternUnit);
static QStringList WholeListHeights(Unit patternUnit);
@ -91,6 +109,8 @@ public:
private:
QSharedDataPointer<VMeasurementData> d;
qreal CalcValue() const;
static void ListValue(QStringList &list, qreal value, Unit patternUnit);
};

View File

@ -42,19 +42,58 @@ class VMeasurementData : public QSharedData
{
public:
VMeasurementData(quint32 index, const QString &gui_text, const QString &tagName)
:data(VContainer(nullptr, nullptr)), index(index), formula(), gui_text(gui_text), _tagName(tagName),
formulaOk(true)
VMeasurementData(quint32 index, const QString &gui_text, const QString &tagName, qreal baseSize, qreal baseHeight,
qreal base, qreal ksize, qreal kheight )
: data(VContainer(nullptr, nullptr)),
index(index),
formula(),
gui_text(gui_text),
_tagName(tagName),
formulaOk(true),
currentSize(nullptr),
currentHeight(nullptr),
currentUnit(nullptr),
base(base),
ksize(ksize),
kheight(kheight),
baseSize(baseSize),
baseHeight(baseHeight)
{}
VMeasurementData(VContainer *data, quint32 index, const QString &formula, bool ok, const QString &gui_text,
const QString &tagName)
:data(*data), index(index), formula(formula), gui_text(gui_text), _tagName(tagName), formulaOk(ok)
const QString &tagName, qreal base)
: data(*data),
index(index),
formula(formula),
gui_text(gui_text),
_tagName(tagName),
formulaOk(ok),
currentSize(nullptr),
currentHeight(nullptr),
currentUnit(nullptr),
base(base),
ksize(0),
kheight(0),
baseSize(0),
baseHeight(0)
{}
VMeasurementData(const VMeasurementData &m)
:QSharedData(m), data(m.data), index(m.index), formula(m.formula), gui_text(m.gui_text), _tagName(m._tagName),
formulaOk(m.formulaOk)
: QSharedData(m),
data(m.data),
index(m.index),
formula(m.formula),
gui_text(m.gui_text),
_tagName(m._tagName),
formulaOk(m.formulaOk),
currentSize(m.currentSize),
currentHeight(m.currentHeight),
currentUnit(m.currentUnit),
base(m.base),
ksize(m.ksize),
kheight(m.kheight),
baseSize(m.baseSize),
baseHeight(m.baseHeight)
{}
virtual ~VMeasurementData();
@ -66,6 +105,22 @@ public:
QString _tagName;
bool formulaOk;
qreal *currentSize;
qreal *currentHeight;
const Unit *currentUnit;
/** @brief base value in base size and height */
qreal base;
/** @brief ksize increment in sizes */
qreal ksize;
/** @brief kgrowth increment in heights */
qreal kheight;
qreal baseSize;
qreal baseHeight;
private:
VMeasurementData &operator=(const VMeasurementData &) Q_DECL_EQ_DELETE;
};

View File

@ -37,24 +37,12 @@
//---------------------------------------------------------------------------------------------------------------------
VVariable::VVariable()
:VInternalVariable(), d(new VVariableData)
{
VInternalVariable::SetValue(d->base);
}
{}
//---------------------------------------------------------------------------------------------------------------------
VVariable::VVariable(const QString &name, qreal baseSize, qreal baseHeight, const qreal &base, const qreal &ksize,
const qreal &kheight, const QString &description)
:VInternalVariable(), d(new VVariableData(baseSize, baseHeight, base, ksize, kheight, description))
VVariable::VVariable(const QString &name, const QString &description)
:VInternalVariable(), d(new VVariableData(description))
{
VInternalVariable::SetValue(d->base);
SetName(name);
}
//---------------------------------------------------------------------------------------------------------------------
VVariable::VVariable(const QString &name, const qreal &base, const QString &description)
:d(new VVariableData(base, description))
{
VInternalVariable::SetValue(base);
SetName(name);
}
@ -79,87 +67,6 @@ VVariable &VVariable::operator=(const VVariable &var)
VVariable::~VVariable()
{}
//---------------------------------------------------------------------------------------------------------------------
void VVariable::SetValue(const qreal &size, const qreal &height, Unit patternUnit)
{
if (patternUnit == Unit::Inch)
{
qWarning("Gradation doesn't support inches");
return;
}
const qreal sizeIncrement = UnitConvertor(2.0, Unit::Cm, patternUnit);
const qreal heightIncrement = UnitConvertor(6.0, Unit::Cm, patternUnit);
// Formula for calculation gradation
const qreal k_size = ( size - d->baseSize ) / sizeIncrement;
const qreal k_height = ( height - d->baseHeight ) / heightIncrement;
VInternalVariable::SetValue(d->base + k_size * d->ksize + k_height * d->kheight);
}
//---------------------------------------------------------------------------------------------------------------------
bool VVariable::IsNotUsed() const
{
if (qFuzzyIsNull(d->base) && qFuzzyIsNull(d->ksize) && qFuzzyIsNull(d->kheight))
{
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetBase return value in base size and height
* @return value
*/
qreal VVariable::GetBase() const
{
return d->base;
}
//---------------------------------------------------------------------------------------------------------------------
void VVariable::SetBase(const qreal &value)
{
d->base = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKsize return increment in sizes
* @return increment
*/
qreal VVariable::GetKsize() const
{
return d->ksize;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VVariable::SetKsize(const qreal &value)
{
d->ksize = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKheight return increment in heights
* @return increment
*/
qreal VVariable::GetKheight() const
{
return d->kheight;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VVariable::SetKheight(const qreal &value)
{
d->kheight = value;
}
//---------------------------------------------------------------------------------------------------------------------
QString VVariable::GetDescription() const
{

View File

@ -45,9 +45,7 @@ class VVariable :public VInternalVariable
{
public:
VVariable();
VVariable(const QString &name, qreal baseSize, qreal baseHeight, const qreal &base, const qreal &ksize = 0,
const qreal &kheight = 0, const QString &description = QString());
VVariable(const QString &name, const qreal &base, const QString &description = QString());
VVariable(const QString &name, const QString &description = QString());
VVariable(const VVariable &var);
virtual ~VVariable() Q_DECL_OVERRIDE;
@ -60,21 +58,9 @@ public:
void Swap(VVariable &var) Q_DECL_NOTHROW
{ VInternalVariable::Swap(var); std::swap(d, var.d); }
qreal GetBase() const;
void SetBase(const qreal &value);
qreal GetKsize() const;
void SetKsize(const qreal &value);
qreal GetKheight() const;
void SetKheight(const qreal &value);
QString GetDescription() const;
void SetDescription(const QString &desc);
void SetValue(const qreal &size, const qreal &height, Unit patternUnit);
virtual bool IsNotUsed() const Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VVariableData> d;
};

View File

@ -42,41 +42,23 @@ class VVariableData : public QSharedData
public:
VVariableData()
:base(0), ksize(0), kheight(0), description(QString()), baseSize(0), baseHeight(0)
: description()
{}
VVariableData(qreal baseSize, qreal baseHeight, const qreal &base, const qreal &ksize, const qreal &kheight,
const QString &description)
:base(base), ksize(ksize), kheight(kheight), description(description), baseSize(baseSize),
baseHeight(baseHeight)
{}
VVariableData(const qreal &base, const QString &description)
:base(base), ksize(0), kheight(0), description(description), baseSize(0), baseHeight(0)
VVariableData(const QString &description)
: description(description)
{}
VVariableData(const VVariableData &var)
:QSharedData(var), base(var.base), ksize(var.ksize), kheight(var.kheight), description(var.description),
baseSize(var.baseSize), baseHeight(var.baseHeight)
: QSharedData(var),
description(var.description)
{}
virtual ~VVariableData();
/** @brief base value in base size and height */
qreal base;
/** @brief ksize increment in sizes */
qreal ksize;
/** @brief kgrowth increment in heights */
qreal kheight;
/** @brief description description of increment */
QString description;
qreal baseSize;
qreal baseHeight;
private:
VVariableData &operator=(const VVariableData &) Q_DECL_EQ_DELETE;
};

View File

@ -538,17 +538,6 @@ void VContainer::UpdatePiecePath(quint32 id, const VPiecePath &path)
UpdateId(id);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VContainer::GetTableValue(const QString &name, MeasurementsType patternType) const
{
QSharedPointer<VVariable> m = GetVariable<VVariable>(name);
if (patternType == MeasurementsType::Multisize)
{
m->SetValue(size(), height(), *GetPatternUnit());
}
return *m->GetValue();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveIncrement remove increment by name from increment table
@ -608,28 +597,6 @@ const QMap<QString, QSharedPointer<VCurveAngle> > VContainer::DataAnglesCurves()
return DataVar<VCurveAngle>(VarType::CurveAngle);
}
//---------------------------------------------------------------------------------------------------------------------
const QHash<QString, qreal *> VContainer::PlainVariables() const
{
QHash<QString, qreal *> vars;
auto i = d->variables.constBegin();
while (i != d->variables.constEnd())
{
QSharedPointer<VInternalVariable> var = i.value();
if (qApp->patternType() == MeasurementsType::Multisize && var->GetType() == VarType::Measurement)
{
QSharedPointer<VVariable> m = GetVariable<VVariable>(i.key());
m->SetValue(size(), height(), qApp->patternUnit());
}
vars.insert(i.key(), var->GetValue());
++i;
}
return vars;
}
//---------------------------------------------------------------------------------------------------------------------
bool VContainer::IsUnique(const QString &name)
{

View File

@ -136,7 +136,6 @@ public:
static const QSharedPointer<VGObject> GetFakeGObject(quint32 id);
VPiece GetPiece(quint32 id) const;
VPiecePath GetPiecePath(quint32 id) const;
qreal GetTableValue(const QString& name, MeasurementsType patternType) const;
template <typename T>
QSharedPointer<T> GetVariable(QString name) const;
static quint32 getId();
@ -196,8 +195,6 @@ public:
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
const QMap<QString, QSharedPointer<VCurveAngle> > DataAnglesCurves() const;
const QHash<QString, qreal *> PlainVariables() const;
static bool IsUnique(const QString &name);
static QStringList AllUniqueNames();

View File

@ -242,7 +242,7 @@ void VFormula::Eval()
{
QScopedPointer<Calculator> cal(new Calculator());
QString expression = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
const qreal result = cal->EvalFormula(data->PlainVariables(), expression);
const qreal result = cal->EvalFormula(data->DataVariables(), expression);
if (qIsInf(result) || qIsNaN(result))
{

View File

@ -50,7 +50,7 @@ qreal EvalFormula(const VContainer *data, QString formula)
// Replace line return character with spaces for calc if exist
formula.replace("\n", " ");
QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(data->PlainVariables(), formula);
const qreal result = cal->EvalFormula(data->DataVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{

View File

@ -173,14 +173,14 @@ void DialogEditWrongFormula::ValChanged(int row)
{
const QString name = qApp->TrVars()->VarFromUser(item->text());
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
SetDescription(item->text(), data->GetTableValue(name, qApp->patternType()),
SetDescription(item->text(), *data->DataVariables()->value(name)->GetValue(),
UnitsToStr(qApp->patternUnit(), true), stable->GetGuiText());
return;
}
if (ui->radioButtonIncrements->isChecked())
{
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
SetDescription(item->text(), data->GetTableValue(item->text(), qApp->patternType()),
SetDescription(item->text(), *data->DataVariables()->value(item->text())->GetValue(),
UnitsToStr(qApp->patternUnit(), true), incr->GetDescription());
return;
}

View File

@ -452,7 +452,7 @@ VSpline DialogSpline::CurrentSpline() const
QString length2F = ui->plainTextEditLength2F->toPlainText();
length2F.replace("\n", " ");
const QHash<QString, qreal *> vars = data->PlainVariables();
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
const qreal angle1 = Visualization::FindVal(angle1F, vars);
const qreal angle2 = Visualization::FindVal(angle2F, vars);

View File

@ -325,7 +325,7 @@ void DialogSplinePath::Angle1Changed()
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
const QString angle1F = ui->plainTextEditAngle1F->toPlainText().replace("\n", " ");
const qreal angle1 = Visualization::FindVal(angle1F, data->PlainVariables());
const qreal angle1 = Visualization::FindVal(angle1F, data->DataVariables());
try
{
@ -368,7 +368,7 @@ void DialogSplinePath::Angle2Changed()
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
const QString angle2F = ui->plainTextEditAngle2F->toPlainText().replace("\n", " ");
const qreal angle2 = Visualization::FindVal(angle2F, data->PlainVariables());
const qreal angle2 = Visualization::FindVal(angle2F, data->DataVariables());
try
{
@ -411,7 +411,7 @@ void DialogSplinePath::Length1Changed()
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
const QString length1F = ui->plainTextEditLength1F->toPlainText().replace("\n", " ");
const qreal length1 = Visualization::FindLength(length1F, data->PlainVariables());
const qreal length1 = Visualization::FindLength(length1F, data->DataVariables());
try
{
@ -445,7 +445,7 @@ void DialogSplinePath::Length2Changed()
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
const QString length2F = ui->plainTextEditLength2F->toPlainText().replace("\n", " ");
const qreal length2 = Visualization::FindLength(length2F, data->PlainVariables());
const qreal length2 = Visualization::FindLength(length2F, data->DataVariables());
try
{

View File

@ -781,7 +781,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
// Translate to internal look.
formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
QScopedPointer<Calculator> cal(new Calculator());
result = cal->EvalFormula(data->PlainVariables(), formula);
result = cal->EvalFormula(data->DataVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{

View File

@ -1317,7 +1317,7 @@ void DialogSeamAllowance::UpdateGrainlineValues()
qsFormula.replace("\n", " ");
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
Calculator cal;
qreal dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula);
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
{
throw qmu::QmuParserError(tr("Infinite/undefined result"));
@ -1399,7 +1399,7 @@ void DialogSeamAllowance::UpdateDetailLabelValues()
qsFormula.replace("\n", " ");
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
Calculator cal;
qreal dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula);
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
{
throw qmu::QmuParserError(tr("Infinite/undefined result"));
@ -1484,7 +1484,7 @@ void DialogSeamAllowance::UpdatePatternLabelValues()
qsFormula.replace("\n", " ");
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
Calculator cal;
qreal dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula);
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
{
throw qmu::QmuParserError(tr("Infinite/undefined result"));

View File

@ -162,7 +162,7 @@ qreal VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VCont
try
{
QScopedPointer<Calculator> cal(new Calculator());
result = cal->EvalFormula(data->PlainVariables(), formula);
result = cal->EvalFormula(data->DataVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
@ -198,7 +198,7 @@ qreal VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VCont
* parsing here. */
delete dialog;
QScopedPointer<Calculator> cal1(new Calculator());
result = cal1->EvalFormula(data->PlainVariables(), formula);
result = cal1->EvalFormula(data->DataVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{

View File

@ -1254,7 +1254,7 @@ VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelD
}
Calculator cal1;
rotationAngle = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetRotation());
rotationAngle = cal1.EvalFormula(VAbstractTool::data.DataVariables(), labelData.GetRotation());
}
catch(qmu::QmuParserError &e)
{
@ -1295,12 +1295,12 @@ VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelD
const bool widthIsSingle = qmu::QmuTokenParser::IsSingle(labelData.GetLabelWidth());
Calculator cal1;
labelWidth = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetLabelWidth());
labelWidth = cal1.EvalFormula(VAbstractTool::data.DataVariables(), labelData.GetLabelWidth());
const bool heightIsSingle = qmu::QmuTokenParser::IsSingle(labelData.GetLabelHeight());
Calculator cal2;
labelHeight = cal2.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetLabelHeight());
labelHeight = cal2.EvalFormula(VAbstractTool::data.DataVariables(), labelData.GetLabelHeight());
if (not widthIsSingle || not heightIsSingle)
{
@ -1381,7 +1381,7 @@ VPieceItem::MoveTypes VToolSeamAllowance::FindGrainlineGeometry(const VGrainline
}
Calculator cal1;
rotationAngle = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), geom.GetRotation());
rotationAngle = cal1.EvalFormula(VAbstractTool::data.DataVariables(), geom.GetRotation());
if (not qmu::QmuTokenParser::IsSingle(geom.GetLength()))
{
@ -1389,7 +1389,7 @@ VPieceItem::MoveTypes VToolSeamAllowance::FindGrainlineGeometry(const VGrainline
}
Calculator cal2;
length = cal2.EvalFormula(VAbstractTool::data.PlainVariables(), geom.GetLength());
length = cal2.EvalFormula(VAbstractTool::data.DataVariables(), geom.GetLength());
}
catch(qmu::QmuParserError &e)
{

View File

@ -137,7 +137,7 @@ QString VisToolMove::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetAngle(const QString &expression)
{
angle = FindVal(expression, Visualization::data->PlainVariables());
angle = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
@ -155,7 +155,7 @@ qreal VisToolMove::LengthValue() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -205,7 +205,7 @@ QString VisToolRotation::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::SetAngle(const QString &expression)
{
angle = FindVal(expression, Visualization::data->PlainVariables());
angle = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -66,7 +66,7 @@ void VisToolAlongLine::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -72,7 +72,7 @@ void VisToolBisector::setObject3Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -105,7 +105,7 @@ QString VisToolCurveIntersectAxis::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolCurveIntersectAxis::SetAngle(const QString &expression)
{
angle = FindVal(expression, Visualization::data->PlainVariables());
angle = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -96,7 +96,7 @@ QString VisToolEndLine::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::SetAngle(const QString &expression)
{
angle = FindVal(expression, Visualization::data->PlainVariables());
angle = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
@ -108,5 +108,5 @@ QString VisToolEndLine::Length() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -118,7 +118,7 @@ QString VisToolLineIntersectAxis::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::SetAngle(const QString &expression)
{
angle = FindVal(expression, Visualization::data->PlainVariables());
angle = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -110,7 +110,7 @@ void VisToolNormal::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -92,7 +92,7 @@ void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::setCRadius(const QString &value)
{
cRadius = FindLength(value, Visualization::data->PlainVariables());
cRadius = FindLength(value, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -112,5 +112,5 @@ void VisToolPointOfContact::setRadiusId(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfContact::setRadius(const QString &expression)
{
radius = FindLength(expression, Visualization::data->PlainVariables());
radius = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -111,13 +111,13 @@ void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::setC1Radius(const QString &value)
{
c1Radius = FindLength(value, Visualization::data->PlainVariables());
c1Radius = FindLength(value, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value)
{
c2Radius = FindLength(value, Visualization::data->PlainVariables());
c2Radius = FindLength(value, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -129,5 +129,5 @@ void VisToolShoulderPoint::setLineP2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolShoulderPoint::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -69,17 +69,17 @@ void VisToolArc::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setRadius(const QString &expression)
{
radius = FindLength(expression, Visualization::data->PlainVariables());
radius = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setF1(const QString &expression)
{
f1 = FindVal(expression, Visualization::data->PlainVariables());
f1 = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setF2(const QString &expression)
{
f2 = FindVal(expression, Visualization::data->PlainVariables());
f2 = FindVal(expression, Visualization::data->DataVariables());
}

View File

@ -68,17 +68,17 @@ void VisToolArcWithLength::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setRadius(const QString &expression)
{
radius = FindLength(expression, Visualization::data->PlainVariables());
radius = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setF1(const QString &expression)
{
f1 = FindVal(expression, Visualization::data->PlainVariables());
f1 = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -82,5 +82,5 @@ void VisToolCutArc::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutArc::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -90,5 +90,5 @@ void VisToolCutSpline::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutSpline::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -91,5 +91,5 @@ void VisToolCutSplinePath::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutSplinePath::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
length = FindLength(expression, Visualization::data->DataVariables());
}

View File

@ -65,29 +65,29 @@ void VisToolEllipticalArc::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setRadius1(const QString &expression)
{
radius1 = FindLength(expression, Visualization::data->PlainVariables());
radius1 = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setRadius2(const QString &expression)
{
radius2 = FindLength(expression, Visualization::data->PlainVariables());
radius2 = FindLength(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setF1(const QString &expression)
{
f1 = FindVal(expression, Visualization::data->PlainVariables());
f1 = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setF2(const QString &expression)
{
f2 = FindVal(expression, Visualization::data->PlainVariables());
f2 = FindVal(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setRotationAngle(const QString &expression)
{
rotationAngle = FindVal(expression, Visualization::data->PlainVariables());
rotationAngle = FindVal(expression, Visualization::data->DataVariables());
}

View File

@ -143,13 +143,15 @@ VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *par
}
//---------------------------------------------------------------------------------------------------------------------
qreal Visualization::FindLength(const QString &expression, const QHash<QString, qreal *> &vars)
qreal Visualization::FindLength(const QString &expression,
const QHash<QString, QSharedPointer<VInternalVariable> > *vars)
{
return qApp->toPixel(FindVal(expression, vars));
}
//---------------------------------------------------------------------------------------------------------------------
qreal Visualization::FindVal(const QString &expression, const QHash<QString, qreal *> &vars)
qreal Visualization::FindVal(const QString &expression,
const QHash<QString, QSharedPointer<VInternalVariable> > *vars)
{
qreal val = 0;
if (expression.isEmpty())

View File

@ -47,6 +47,7 @@ Q_DECLARE_LOGGING_CATEGORY(vVis)
class VScaledEllipse;
class VScaledLine;
class VContainer;
class VInternalVariable;
enum class Mode : char {Creation, Show};
@ -71,8 +72,8 @@ public:
Mode GetMode() const;
void SetMode(const Mode &value);
static qreal FindLength(const QString &expression, const QHash<QString, qreal *> &vars);
static qreal FindVal(const QString &expression, const QHash<QString, qreal *> &vars);
static qreal FindLength(const QString &expression, const QHash<QString, QSharedPointer<VInternalVariable> > *vars);
static qreal FindVal(const QString &expression, const QHash<QString, QSharedPointer<VInternalVariable> > *vars);
signals:
void ToolTip(const QString &toolTip);
public slots:

View File

@ -56,6 +56,8 @@ void TST_VMeasurements::CreateEmptyMultisizeFile()
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
QTemporaryFile file;
QString fileName;
@ -144,6 +146,8 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile()
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
const QStringList listSystems = ListPMSystems();
for (int i = 0; i < listSystems.size(); ++i)