Don't show internal variable if we created her.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-29 15:19:11 +03:00
parent 484f149929
commit 10ba3eacbb
65 changed files with 165 additions and 161 deletions

View File

@ -154,16 +154,16 @@ void Calculator::InitVariables(const VContainer *data)
num +=2;
}
const QMap<QString, qreal> lengthLines = data->DataLengthLines();
const QMap<QString, VLengthLine *> lengthLines = data->DataLengthLines();
num += lengthLines.size();
const QMap<QString, qreal> lengthSplines = data->DataLengthSplines();
const QMap<QString, VLengthSpline *> lengthSplines = data->DataLengthSplines();
num += lengthSplines.size();
const QMap<QString, qreal> lengthArcs = data->DataLengthArcs();
const QMap<QString, VLengthArc *> lengthArcs = data->DataLengthArcs();
num += lengthArcs.size();
const QMap<QString, qreal> lineAngles = data->DataLineAngles();
const QMap<QString, VLineAngle *> lineAngles = data->DataLineAngles();
num += lineAngles.size();
const QMap<QString, VMeasurement*> measurements = data->DataMeasurements();
@ -187,10 +187,10 @@ void Calculator::InitVariables(const VContainer *data)
}
{
QMap<QString, qreal>::const_iterator i = lengthLines.constBegin();
QMap<QString, VLengthLine *>::const_iterator i = lengthLines.constBegin();
while (i != lengthLines.constEnd())
{
vVarVal[j] = i.value();
vVarVal[j] = *i.value()->GetValue();
DefineVar(i.key(), &vVarVal[j]);
++j;
++i;
@ -198,10 +198,10 @@ void Calculator::InitVariables(const VContainer *data)
}
{
QMap<QString, qreal>::const_iterator i = lengthSplines.constBegin();
QMap<QString, VLengthSpline *>::const_iterator i = lengthSplines.constBegin();
while (i != lengthSplines.constEnd())
{
vVarVal[j] = i.value();
vVarVal[j] = *i.value()->GetValue();
DefineVar(i.key(), &vVarVal[j]);
++j;
++i;
@ -209,10 +209,10 @@ void Calculator::InitVariables(const VContainer *data)
}
{
QMap<QString, qreal>::const_iterator i = lengthArcs.constBegin();
QMap<QString, VLengthArc *>::const_iterator i = lengthArcs.constBegin();
while (i != lengthArcs.constEnd())
{
vVarVal[j] = i.value();
vVarVal[j] = *i.value()->GetValue();
DefineVar(i.key(), &vVarVal[j]);
++j;
++i;
@ -220,10 +220,10 @@ void Calculator::InitVariables(const VContainer *data)
}
{
QMap<QString, qreal>::const_iterator i = lineAngles.constBegin();
QMap<QString, VLineAngle *>::const_iterator i = lineAngles.constBegin();
while (i != lineAngles.constEnd())
{
vVarVal[j] = i.value();
vVarVal[j] = *i.value()->GetValue();
DefineVar(i.key(), &vVarVal[j]);
++j;
++i;

View File

@ -445,37 +445,37 @@ void VContainer::RemoveIncrement(const QString &name)
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, VMeasurement*> VContainer::DataMeasurements() const
{
return DataTableVar<VMeasurement>(VarType::Measurement);
return DataVar<VMeasurement>(VarType::Measurement);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, VIncrement *> VContainer::DataIncrements() const
{
return DataTableVar<VIncrement>(VarType::Increment);
return DataVar<VIncrement>(VarType::Increment);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, qreal> VContainer::DataLengthLines() const
const QMap<QString, VLengthLine *> VContainer::DataLengthLines() const
{
return DataVar(VarType::LengthLine);
return DataVar<VLengthLine>(VarType::LengthLine);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, qreal> VContainer::DataLengthSplines() const
const QMap<QString, VLengthSpline *> VContainer::DataLengthSplines() const
{
return DataVar(VarType::LengthSpline);
return DataVar<VLengthSpline>(VarType::LengthSpline);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, qreal> VContainer::DataLengthArcs() const
const QMap<QString, VLengthArc *> VContainer::DataLengthArcs() const
{
return DataVar(VarType::LengthArc);
return DataVar<VLengthArc>(VarType::LengthArc);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, qreal> VContainer::DataLineAngles() const
const QMap<QString, VLineAngle *> VContainer::DataLineAngles() const
{
return DataVar(VarType::LineAngle);
return DataVar<VLineAngle>(VarType::LineAngle);
}
//---------------------------------------------------------------------------------------------------------------------
@ -505,26 +505,9 @@ void VContainer::CopyVar(const VContainer &data, const QString &name)
AddVariable(name, var);
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, qreal> VContainer::DataVar(const VarType &type) const
{
QHashIterator<QString, VInternalVariable*> i(variables);
QMap<QString, qreal> map;
//Sorting QHash by id
while (i.hasNext())
{
i.next();
if(i.value()->GetType() == type)
{
map.insert(qApp->VarToUser(i.key()), *i.value()->GetValue());
}
}
return map;
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
const QMap<QString, T *> VContainer::DataTableVar(const VarType &type) const
const QMap<QString, T *> VContainer::DataVar(const VarType &type) const
{
QHashIterator<QString, VInternalVariable*> i(variables);
QMap<QString, T*> map;

View File

@ -170,12 +170,12 @@ public:
const QHash<quint32, VDetail> *DataDetails() const;
const QHash<QString, VInternalVariable*> *DataVariables() const;
const QMap<QString, VMeasurement *> DataMeasurements() const;
const QMap<QString, VIncrement *> DataIncrements() const;
const QMap<QString, qreal> DataLengthLines() const;
const QMap<QString, qreal> DataLengthSplines() const;
const QMap<QString, qreal> DataLengthArcs() const;
const QMap<QString, qreal> DataLineAngles() const;
const QMap<QString, VMeasurement *> DataMeasurements() const;
const QMap<QString, VIncrement *> DataIncrements() const;
const QMap<QString, VLengthLine *> DataLengthLines() const;
const QMap<QString, VLengthSpline *> DataLengthSplines() const;
const QMap<QString, VLengthArc *> DataLengthArcs() const;
const QMap<QString, VLineAngle *> DataLineAngles() const;
private:
@ -217,10 +217,8 @@ private:
template <typename T>
void CopyVar(const VContainer &data, const QString &name);
QMap<QString, qreal> DataVar(const VarType &type) const;
template <typename T>
const QMap<QString, T*> DataTableVar(const VarType &type) const;
const QMap<QString, T*> DataVar(const VarType &type) const;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -45,7 +45,7 @@
* @param parent parent widget
*/
DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
:DialogTool(data, 0, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
cursorToolRecordRow(0)
{
ui->setupUi(this);

View File

@ -49,7 +49,7 @@
* @param parent parent widget
*/
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0), m(nullptr)
:DialogTool(data, 0, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0), m(nullptr)
{
ui->setupUi(this);
@ -287,16 +287,17 @@ void DialogIncrements::FillIncrements()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::FillTable(const QMap<QString, qreal> varTable, QTableWidget *table)
template <typename T>
void DialogIncrements::FillTable(const QMap<QString, T> varTable, QTableWidget *table)
{
SCASSERT(table != nullptr);
qint32 currentRow = -1;
QMapIterator<QString, qreal> i(varTable);
QMapIterator<QString, T> i(varTable);
while (i.hasNext())
{
i.next();
qreal length = i.value();
qreal length = *i.value()->GetValue();
currentRow++;
table->setRowCount ( varTable.size() );

View File

@ -94,7 +94,8 @@ private:
void FillMeasurements();
void FillIncrements();
void FillTable(const QMap<QString, qreal> varTable, QTableWidget *table);
template <typename T>
void FillTable(const QMap<QString, T> varTable, QTableWidget *table);
void FillLengthLines();
void FillLengthSplines();
void FillLengthArcs();

View File

@ -40,9 +40,10 @@
* @param data container with data
* @param parent parent widget
*/
DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), typeLine(QString()),
formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr), prepare(false)
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr),
prepare(false)
{
ui->setupUi(this);
InitVariables(ui);

View File

@ -45,7 +45,7 @@ class DialogAlongLine : public DialogTool
{
Q_OBJECT
public:
DialogAlongLine(const VContainer *data, QWidget *parent = nullptr);
DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogAlongLine();
QString getPointName() const;
void setPointName(const QString &value);

View File

@ -41,8 +41,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogArc::DialogArc(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(0), radius(QString()), f1(QString()),
f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0)
{
@ -357,8 +357,8 @@ void DialogArc::ShowLineAngles()
disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
ui->listWidget->clear();
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
const QMap<QString, qreal> lineAnglesTable = data->DataLineAngles();
QMapIterator<QString, qreal> i(lineAnglesTable);
const QMap<QString, VLineAngle *> lineAnglesTable = data->DataLineAngles();
QMapIterator<QString, VLineAngle *> i(lineAnglesTable);
while (i.hasNext())
{
i.next();

View File

@ -43,7 +43,7 @@ class DialogArc : public DialogTool
{
Q_OBJECT
public:
DialogArc(const VContainer *data, QWidget *parent = nullptr);
DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogArc();
quint32 GetCenter() const;

View File

@ -41,8 +41,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogBisector::DialogBisector(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), typeLine(QString()),
DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), typeLine(QString()),
formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0), formulaBaseHeight(0), line(nullptr),
prepare(false)
{

View File

@ -46,7 +46,7 @@ class DialogBisector : public DialogTool
Q_OBJECT
public:
DialogBisector(const VContainer *data, QWidget *parent = nullptr);
DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogBisector();
QString getPointName() const;

View File

@ -38,8 +38,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent)
: DialogTool(data, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()), arcId(0),
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()), arcId(0),
formulaBaseHeight(0)
{
ui->setupUi(this);

View File

@ -44,7 +44,7 @@ class DialogCutArc : public DialogTool
Q_OBJECT
public:
DialogCutArc(const VContainer *data, QWidget *parent = nullptr);
DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutArc();
QString getPointName() const;

View File

@ -38,9 +38,9 @@
* @param data container with data
* @param parent parent widget
*/
DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()), splineId(0),
formulaBaseHeight(0)
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()),
splineId(0), formulaBaseHeight(0)
{
ui->setupUi(this);
InitVariables(ui);

View File

@ -43,7 +43,7 @@ class DialogCutSpline : public DialogTool
{
Q_OBJECT
public:
DialogCutSpline(const VContainer *data, QWidget *parent = nullptr);
DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutSpline();
QString getPointName() const;

View File

@ -38,8 +38,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
splinePathId(0), formulaBaseHeight(0)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogCutSplinePath : public DialogTool
{
Q_OBJECT
public:
DialogCutSplinePath(const VContainer *data, QWidget *parent = nullptr);
DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutSplinePath();
QString getPointName() const;

View File

@ -42,8 +42,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(), details(VDetail()), supplement(true), closed(true)
DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(), details(VDetail()), supplement(true), closed(true)
{
ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;

View File

@ -40,7 +40,7 @@ class DialogDetail : public DialogTool
{
Q_OBJECT
public:
DialogDetail(const VContainer *data, QWidget *parent = nullptr);
DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
VDetail getDetails() const;
void setDetails(const VDetail &value);

View File

@ -30,8 +30,8 @@
#include "ui_dialogeditwrongformula.h"
//---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0)
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitVariables(ui);

View File

@ -48,7 +48,7 @@ class DialogEditWrongFormula : public DialogTool
{
Q_OBJECT
public:
explicit DialogEditWrongFormula(const VContainer *data, QWidget *parent = nullptr);
explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogEditWrongFormula();
QString getFormula() const;

View File

@ -41,9 +41,9 @@
* @param data container with data
* @param parent parent widget
*/
DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), formula(QString()),
angle(0), basePointId(0), formulaBaseHeight(0), line(nullptr), prepare(false)
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), basePointId(0), formulaBaseHeight(0), line(nullptr), prepare(false)
{
ui->setupUi(this);
InitVariables(ui);

View File

@ -45,7 +45,7 @@ class DialogEndLine : public DialogTool
{
Q_OBJECT
public:
DialogEndLine(const VContainer *data, QWidget *parent = nullptr);
DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogEndLine();
QString getPointName() const;

View File

@ -39,8 +39,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogHeight::DialogHeight(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogHeight : public DialogTool
{
Q_OBJECT
public:
DialogHeight(const VContainer *data, QWidget *parent = nullptr);
DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogHeight();
QString getPointName() const;

View File

@ -42,9 +42,9 @@
* @param data container with data
* @param parent parent widget
*/
DialogLine::DialogLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString()),
line(nullptr)
DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0),
typeLine(QString()), line(nullptr)
{
ui->setupUi(this);
InitOkCancelApply(ui);

View File

@ -45,7 +45,7 @@ class DialogLine : public DialogTool
{
Q_OBJECT
public:
DialogLine(const VContainer *data, QWidget *parent = nullptr);
DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLine();
quint32 getFirstPoint() const;

View File

@ -38,8 +38,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogLineIntersect : public DialogTool
{
Q_OBJECT
public:
DialogLineIntersect(const VContainer *data, QWidget *parent = nullptr);
DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLineIntersect();
quint32 getP1Line1() const;

View File

@ -35,8 +35,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogNormal::DialogNormal(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), firstPointId(0), secondPointId(0), formulaBaseHeight(0)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogNormal : public DialogTool
{
Q_OBJECT
public:
DialogNormal(const VContainer *data, QWidget *parent = nullptr);
DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogNormal();
QString getPointName() const;

View File

@ -37,9 +37,9 @@
* @param data container with data
* @param parent parent widget
*/
DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogPointOfContact), number(0), pointName(QString()), radius(QString()),
center(0), firstPoint(0), secondPoint(0), formulaBaseHeight(0)
DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0), pointName(QString()),
radius(QString()), center(0), firstPoint(0), secondPoint(0), formulaBaseHeight(0)
{
ui->setupUi(this);
InitVariables(ui);

View File

@ -43,7 +43,7 @@ class DialogPointOfContact : public DialogTool
{
Q_OBJECT
public:
DialogPointOfContact(const VContainer *data, QWidget *parent = nullptr);
DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
QString getPointName() const;
void setPointName(const QString &value);

View File

@ -38,8 +38,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
firstPointId(0), secondPointId(0)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogPointOfIntersection : public DialogTool
{
Q_OBJECT
public:
DialogPointOfIntersection(const VContainer *data, QWidget *parent = nullptr);
DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogPointOfIntersection();
QString getPointName() const;

View File

@ -41,8 +41,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0), formulaBaseHeight(0), line (nullptr),
prepare(false)
{

View File

@ -45,7 +45,7 @@ class DialogShoulderPoint : public DialogTool
{
Q_OBJECT
public:
DialogShoulderPoint(const VContainer *data, QWidget *parent = nullptr);
DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogShoulderPoint();
QString getPointName() const;

View File

@ -35,8 +35,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogSinglePoint), name(QString()), point(QPointF())
DialogSinglePoint::DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSinglePoint), name(QString()), point(QPointF())
{
ui->setupUi(this);
ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize));

View File

@ -43,7 +43,7 @@ class DialogSinglePoint : public DialogTool
{
Q_OBJECT
public:
DialogSinglePoint(const VContainer *data, QWidget *parent = nullptr);
DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSinglePoint();
void setData(const QString &name, const QPointF &point);
QString getName()const;

View File

@ -38,9 +38,9 @@
* @param data container with data
* @param parent parent widget
*/
DialogSpline::DialogSpline(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), kAsm1(1),
kAsm2(1), kCurve(1)
DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
kAsm1(1), kAsm2(1), kCurve(1)
{
ui->setupUi(this);
InitOkCancel(ui);

View File

@ -43,7 +43,7 @@ class DialogSpline : public DialogTool
{
Q_OBJECT
public:
DialogSpline(const VContainer *data, QWidget *parent = nullptr);
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSpline();
quint32 getP1() const;

View File

@ -37,8 +37,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogSplinePath::DialogSplinePath(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
{
ui->setupUi(this);
InitOkCancel(ui);

View File

@ -44,7 +44,7 @@ class DialogSplinePath : public DialogTool
{
Q_OBJECT
public:
DialogSplinePath(const VContainer *data, QWidget *parent = nullptr);
DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSplinePath();
VSplinePath GetPath() const;

View File

@ -56,21 +56,18 @@
* @param data container with data
* @param parent parent widget
*/
DialogTool::DialogTool(const VContainer *data, QWidget *parent)
DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), flagError(true),
timerFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr),
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), okColor(QColor(76, 76, 76)), errorColor(Qt::red),
associatedTool(nullptr)
radioButtonLengthCurve(nullptr), lineStyles(VAbstractTool::Styles()), okColor(QColor(76, 76, 76)),
errorColor(Qt::red), associatedTool(nullptr), toolId(toolId)
{
SCASSERT(data != nullptr);
timerFormula = new QTimer(this);
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
//Keep synchronize with VAbstractTool styles list!!!
lineStyles<<tr("No line")<<tr("Line")<<tr("Dash Line")<<tr("Dot Line")<<tr("Dash Dot Line")
<<tr("Dash Dot Dot Line");
this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint);
}
@ -1046,6 +1043,18 @@ void DialogTool::UpdateList()
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogTool::GetToolId() const
{
return toolId;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::SetToolId(const quint32 &value)
{
toolId = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowVariable show variables in list
@ -1062,9 +1071,12 @@ void DialogTool::ShowVariable(const QMap<key, val> var)
while (iMap.hasNext())
{
iMap.next();
QListWidgetItem *item = new QListWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item);
if (iMap.value()->Filter(toolId) == false)
{// If we create this variable don't show
QListWidgetItem *item = new QListWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item);
}
}
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->setCurrentRow (0);
@ -1086,5 +1098,5 @@ void DialogTool::ShowDialog(bool click)
void DialogTool::SetAssociatedTool(VAbstractTool *tool)
{
this->associatedTool=tool;
this->data = tool->getData();
SetToolId(tool->getId());
}

View File

@ -55,11 +55,16 @@ class DialogTool : public QDialog
{
Q_OBJECT
public:
DialogTool(const VContainer *data, QWidget *parent = nullptr);
DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogTool() {}
VAbstractTool* GetAssociatedTool();
void SetAssociatedTool(VAbstractTool* tool);
virtual void ShowDialog(bool click);
quint32 GetToolId() const;
void SetToolId(const quint32 &value);
signals:
/**
* @brief DialogClosed signal dialog closed
@ -183,6 +188,11 @@ protected:
QStringList lineStyles;
const QColor okColor;
const QColor errorColor;
/**
* @brief associatedTool vdrawtool associated with opened dialog.
*/
VAbstractTool *associatedTool;
quint32 toolId;
virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event );
@ -300,10 +310,7 @@ protected:
plainTextEditFormula = ui->plainTextEditFormula;
labelEditFormula = ui->labelEditFormula;
}
/**
* @brief associatedTool vdrawtool associated with opened dialog.
*/
VAbstractTool* associatedTool;
void ChangeColor(QWidget *widget, const QColor &color);
void setPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id);
virtual void ShowVisualization(){}

View File

@ -37,8 +37,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogTriangle::DialogTriangle(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0),
DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0),
axisP2Id(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogTriangle : public DialogTool
{
Q_OBJECT
public:
DialogTriangle(const VContainer *data, QWidget *parent = nullptr);
DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogTriangle();
quint32 getAxisP1Id() const;

View File

@ -37,8 +37,8 @@
* @param data container with data
* @param parent parent widget
*/
DialogUnionDetails::DialogUnionDetails(const VContainer *data, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogUnionDetails), indexD1(0), indexD2(0), d1(0), d2(0), numberD(0),
DialogUnionDetails::DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogUnionDetails), indexD1(0), indexD2(0), d1(0), d2(0), numberD(0),
numberP(0), p1(0), p2(0)
{
ui->setupUi(this);

View File

@ -43,7 +43,7 @@ class DialogUnionDetails : public DialogTool
{
Q_OBJECT
public:
DialogUnionDetails(const VContainer *data, QWidget *parent = nullptr);
DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogUnionDetails();
quint32 getD1() const;

View File

@ -259,7 +259,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
QCursor cur(pixmap, 2, 3);
view->setCursor(cur);
helpLabel->setText(toolTip);
dialogTool = new Dialog(pattern, this);
dialogTool = new Dialog(pattern, 0, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
@ -297,7 +297,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
QCursor cur(pixmap, 2, 3);
view->setCursor(cur);
helpLabel->setText(toolTip);
dialogTool = new Dialog(pattern, this);
dialogTool = new Dialog(pattern, 0, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot);

View File

@ -173,12 +173,14 @@ void VDrawTool::SetFactor(qreal factor)
*
* Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In
* successes case return result calculation and fixed formula string. If formula ok don't touch formula.
*
* @param toolId[in] tool's id.
* @param formula [in|out] string with formula.
* @param data [in] container with variables. Need for math parser.
* @throw QmuParserError.
* @return result of calculation formula.
*/
qreal VDrawTool::CheckFormula(QString &formula, VContainer *data)
qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContainer *data)
{
SCASSERT(data != nullptr)
qreal result = 0;
@ -206,7 +208,7 @@ qreal VDrawTool::CheckFormula(QString &formula, VContainer *data)
delete dialogUndo;
if (resultUndo == UndoButton::Fix)
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, qApp->getMainWindow());
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
dialog->setFormula(formula);
if (dialog->exec() == QDialog::Accepted)
{

View File

@ -55,7 +55,7 @@ public:
virtual void setDialog() {}
virtual void DialogLinkDestroy();
void ignoreContextMenu(bool enable);
static qreal CheckFormula(QString &formula, VContainer *data);
static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data);
public slots:
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
virtual void ChangedActivDraw(const QString &newName);
@ -118,7 +118,7 @@ protected:
QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction == actionOption)
{
dialog = new Dialog(getData(), qApp->getMainWindow());
dialog = new Dialog(getData(), id, qApp->getMainWindow());
dialog->setModal(true);
connect(dialog, &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGuiOk);

View File

@ -253,7 +253,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF());
line.setLength(qApp->toPixel(CheckFormula(formula, data)));
line.setLength(qApp->toPixel(CheckFormula(_id, formula, data)));
quint32 id = _id;
if (typeCreation == Source::FromGui)

View File

@ -129,10 +129,10 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
{
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
calcRadius = qApp->toPixel(CheckFormula(radius, data));
calcRadius = qApp->toPixel(CheckFormula(_id, radius, data));
calcF1 = CheckFormula(f1, data);
calcF2 = CheckFormula(f2, data);
calcF1 = CheckFormula(_id, f1, data);
calcF2 = CheckFormula(_id, f2, data);
VPointF c = *data->GeometricObject<const VPointF *>(center);
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );

View File

@ -176,7 +176,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
const VPointF *thirdPoint = data->GeometricObject<const VPointF *>(thirdPointId);
const qreal result = CheckFormula(formula, data);
const qreal result = CheckFormula(_id, formula, data);
QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
thirdPoint->toQPointF(), qApp->toPixel(result));

View File

@ -127,7 +127,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
{
const VArc *arc = data->GeometricObject<const VArc *>(arcId);
const qreal result = CheckFormula(formula, data);
const qreal result = CheckFormula(_id, formula, data);
VArc arc1;
VArc arc2;

View File

@ -121,7 +121,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
{
const VSpline *spl = data->GeometricObject<const VSpline *>(splineId);
const qreal result = CheckFormula(formula, data);
const qreal result = CheckFormula(_id, formula, data);
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);

View File

@ -125,7 +125,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
SCASSERT(splPath != nullptr);
const qreal result = CheckFormula(formula, data);
const qreal result = CheckFormula(_id, formula, data);
quint32 id = _id;
QPointF spl1p2, spl1p3, spl2p2, spl2p3;

View File

@ -138,7 +138,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
const VPointF *basePoint = data->GeometricObject<const VPointF *>(basePointId);
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
line.setLength(qApp->toPixel(CheckFormula(formula, data)));
line.setLength(qApp->toPixel(CheckFormula(_id, formula, data)));
line.setAngle(angle);
quint32 id = _id;
if (typeCreation == Source::FromGui)

View File

@ -138,7 +138,7 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
const qreal result = CheckFormula(formula, data);
const qreal result = CheckFormula(_id, formula, data);
QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
qApp->toPixel(result), angle);

View File

@ -171,7 +171,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
const VPointF *firstP = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondP = data->GeometricObject<const VPointF *>(secondPointId);
const qreal result = CheckFormula(radius, data);
const qreal result = CheckFormula(_id, radius, data);
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(),
firstP->toQPointF(), secondP->toQPointF());

View File

@ -176,7 +176,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(p2Line);
const VPointF *shoulderPoint = data->GeometricObject<const VPointF *>(pShoulder);
const qreal result = CheckFormula(formula, data);
const qreal result = CheckFormula(_id, formula, data);
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
shoulderPoint->toQPointF(), qApp->toPixel(result));

View File

@ -326,7 +326,6 @@ void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qre
*/
const QStringList VAbstractTool::Styles()
{
//Keep synchronize with DialogTool lineStyles list!!!
QStringList styles{TypeLineNone, TypeLineLine, TypeLineDashLine, TypeLineDotLine, TypeLineDashDotLine,
TypeLineDashDotDotLine};
return styles;

View File

@ -405,7 +405,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction == actionOption)
{
dialog = new DialogDetail(getData(), qApp->getMainWindow());
dialog = new DialogDetail(getData(), id, qApp->getMainWindow());
dialog->setModal(true);
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
dialog, &DialogTool::ChosenObject);