Fixed issue 81.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-11 17:41:17 +03:00
parent 3af2859980
commit 7e75a18c1c
33 changed files with 576 additions and 347 deletions

View File

@ -473,7 +473,7 @@ const QMap<QString, VLengthArc *> VContainer::DataLengthArcs() const
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, VLineAngle *> VContainer::DataLineAngles() const
const QMap<QString, VLineAngle *> VContainer::DataAngleLines() const
{
return DataVar<VLineAngle>(VarType::LineAngle);
}

View File

@ -175,7 +175,7 @@ public:
const QMap<QString, VLengthLine *> DataLengthLines() const;
const QMap<QString, VLengthSpline *> DataLengthSplines() const;
const QMap<QString, VLengthArc *> DataLengthArcs() const;
const QMap<QString, VLineAngle *> DataLineAngles() const;
const QMap<QString, VLineAngle *> DataAngleLines() const;
private:

View File

@ -423,6 +423,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -34,6 +34,7 @@
#include "../../geometry/vpointf.h"
#include "../../container/vcontainer.h"
#include "../../xml/vdomdocument.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -229,7 +230,7 @@ void DialogArc::ValChenged(int row)
return;
}
QListWidgetItem *item = ui->listWidget->item( row );
if (ui->radioButtonLineAngles->isChecked())
if (ui->radioButtonAngleLine->isChecked())
{
qreal angle = *data->GetVariable<VLineAngle*>(item->text())->GetValue();
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(angle).arg(tr("Value of angle of line."));
@ -325,7 +326,8 @@ void DialogArc::CheckState()
void DialogArc::EvalRadius()
{
labelEditFormula = ui->labelEditRadius;
Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, timerRadius, ui->labelResultRadius);
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, timerRadius, ui->labelResultRadius, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
@ -335,7 +337,8 @@ void DialogArc::EvalRadius()
void DialogArc::EvalF1()
{
labelEditFormula = ui->labelEditF1;
Eval(ui->plainTextEditF1->toPlainText(), flagF1, timerF1, ui->labelResultF1, false);
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditF1->toPlainText(), flagF1, timerF1, ui->labelResultF1, postfix, false);
}
//---------------------------------------------------------------------------------------------------------------------
@ -345,7 +348,8 @@ void DialogArc::EvalF1()
void DialogArc::EvalF2()
{
labelEditFormula = ui->labelEditF2;
Eval(ui->plainTextEditF2->toPlainText(), flagF2, timerF2, ui->labelResultF2, false);
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditF2->toPlainText(), flagF2, timerF2, ui->labelResultF2, postfix, false);
}
//---------------------------------------------------------------------------------------------------------------------
@ -357,7 +361,7 @@ void DialogArc::ShowLineAngles()
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
ui->listWidget->blockSignals(false);
const QMap<QString, VLineAngle *> lineAnglesTable = data->DataLineAngles();
const QMap<QString, VLineAngle *> lineAnglesTable = data->DataAngleLines();
QMapIterator<QString, VLineAngle *> i(lineAnglesTable);
while (i.hasNext())
{

View File

@ -254,7 +254,7 @@
</palette>
</property>
<property name="text">
<string>First angle degree</string>
<string>First angle</string>
</property>
</widget>
</item>
@ -439,7 +439,7 @@
</palette>
</property>
<property name="text">
<string>Second angle degree</string>
<string>Second angle</string>
</property>
</widget>
</item>
@ -704,7 +704,7 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLineAngles">
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
@ -762,7 +762,7 @@
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonLineAngles</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonPutHereRadius</tabstop>
<tabstop>toolButtonPutHereF1</tabstop>

View File

@ -453,6 +453,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -384,6 +384,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -384,6 +384,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -384,6 +384,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -86,6 +86,15 @@ void DialogEditWrongFormula::DeployFormulaTextEdit()
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::EvalFormula()
{
SCASSERT(plainTextEditFormula != nullptr);
SCASSERT(labelResultCalculation != nullptr);
const QString postfix = QStringLiteral("");
Eval(plainTextEditFormula->toPlainText(), flagFormula, timerFormula, labelResultCalculation, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::CheckState()
{

View File

@ -59,7 +59,8 @@ public slots:
/**
* @brief DeployFormulaTextEdit grow or shrink formula input
*/
void DeployFormulaTextEdit();
void DeployFormulaTextEdit();
virtual void EvalFormula();
protected:
virtual void CheckState();
private:

View File

@ -319,7 +319,7 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLineAngles">
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>

View File

@ -43,13 +43,15 @@
*/
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)
formulaLength(QString()), formulaAngle(QString()), basePointId(0), formulaBaseHeight(0),
formulaBaseHeightAngle(0), line(nullptr), prepare(false)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
InitOkCancelApply(ui);
flagFormula = false;
@ -59,30 +61,73 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxTypeLine(ui->comboBoxLineType);
InitArrow(ui);
connect(ui->toolButtonPutHereLength, &QPushButton::clicked, this, &DialogEndLine::PutHere);
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogEndLine::PutAngle);
connect(ui->toolButtonEqualLength, &QPushButton::clicked, this, &DialogEndLine::EvalFormula);
connect(ui->toolButtonEqualAngle, &QPushButton::clicked, this, &DialogEndLine::EvalAngle);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEndLine::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEndLine::PutVal);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEndLine::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged);
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, &DialogEndLine::AngleTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit);
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogEndLine::DeployAngleTextEdit);
connect(timerFormula, &QTimer::timeout, this, &DialogEndLine::EvalAngle);
line = new VisToolEndLine(data);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PutAngle put variable into formula of angle
*/
void DialogEndLine::PutAngle()
{
PutValHere(ui->plainTextEditAngle, ui->listWidget);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief EvalAngle calculate value of angle
*/
void DialogEndLine::EvalAngle()
{
labelEditFormula = ui->labelEditAngle;
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditAngle->toPlainText(), flagError, timerFormula, ui->labelResultCalculationAngle, postfix,
false);
labelEditFormula = ui->labelEditFormula;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::FormulaTextChanged()
{
this->FormulaChangedPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::AngleTextChanged()
{
labelEditFormula = ui->labelEditAngle;
ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula);
labelEditFormula = ui->labelEditFormula;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::DeployAngleTextEdit()
{
DeployFormula(ui->plainTextEditAngle, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
@ -143,18 +188,15 @@ void DialogEndLine::setTypeLine(const QString &value)
*/
void DialogEndLine::setFormula(const QString &value)
{
formula = qApp->FormulaToUser(value);
formulaLength = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line
// of this PlainTextEdit to change 80 to this value
if (formula.length() > 80)
if (formulaLength.length() > 80)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
line->setLength(formula);
//QTextCursor cursor = ui->plainTextEditFormula->textCursor();
//cursor.insertText(value);
//ui->plainTextEditFormula->setCursor(cursor);
ui->plainTextEditFormula->setPlainText(formulaLength);
line->setLength(formulaLength);
}
//---------------------------------------------------------------------------------------------------------------------
@ -162,11 +204,17 @@ void DialogEndLine::setFormula(const QString &value)
* @brief setAngle set angle of line
* @param value angle in degree
*/
void DialogEndLine::setAngle(const qreal &value)
void DialogEndLine::setAngle(const QString &value)
{
angle = value;
ui->doubleSpinBoxAngle->setValue(angle);
line->setAngle(angle);
formulaAngle = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line
// of this PlainTextEdit to change 80 to this value
if (formulaAngle.length() > 80)
{
this->DeployAngleTextEdit();
}
ui->plainTextEditAngle->setPlainText(formulaAngle);
line->setAngle(formulaAngle);
}
//---------------------------------------------------------------------------------------------------------------------
@ -245,14 +293,18 @@ void DialogEndLine::SaveData()
{
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
angle = ui->doubleSpinBoxAngle->value();
formulaLength = ui->plainTextEditFormula->toPlainText();
formulaLength.replace("\n", " ");
formulaAngle = ui->plainTextEditAngle->toPlainText();
formulaAngle.replace("\n", " ");
basePointId = getCurrentObjectId(ui->comboBoxBasePoint);
line->setPoint1Id(basePointId);
line->setLength(formula);
line->setAngle(angle);
line->setLength(formulaLength);
line->setAngle(formulaAngle);
line->setLineStyle(VAbstractTool::LineStyle(typeLine));
line->RefreshGeometry();
}

View File

@ -57,8 +57,8 @@ public:
QString getFormula() const;
void setFormula(const QString &value);
qreal getAngle() const;
void setAngle(const qreal &value);
QString getAngle() const;
void setAngle(const QString &value);
quint32 getBasePointId() const;
void setBasePointId(const quint32 &value);
@ -73,11 +73,15 @@ public slots:
/**
* @brief DeployFormulaTextEdit grow or shrink formula input
*/
void DeployFormulaTextEdit();
void DeployFormulaTextEdit();
/**
* @brief FormulaTextChanged when formula text changes for validation and calc
*/
void FormulaTextChanged();
void FormulaTextChanged();
void PutAngle();
void EvalAngle();
void AngleTextChanged();
void DeployAngleTextEdit();
protected:
virtual void ShowVisualization();
private:
@ -93,16 +97,17 @@ private:
QString typeLine;
/** @brief formula formula */
QString formula;
QString formulaLength;
/** @brief angle angle of line */
qreal angle;
QString formulaAngle;
/** @brief basePointId id base point of line */
quint32 basePointId;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
int formulaBaseHeight;
int formulaBaseHeightAngle;
VisToolEndLine *line;
@ -142,17 +147,17 @@ inline QString DialogEndLine::getTypeLine() const
*/
inline QString DialogEndLine::getFormula() const
{
return qApp->FormulaFromUser(formula);
return qApp->FormulaFromUser(formulaLength);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getAngle return angle of line
* @return angle in degree
* @brief getAngle return formula angle of line
* @return angle formula
*/
inline qreal DialogEndLine::getAngle() const
inline QString DialogEndLine::getAngle() const
{
return angle;
return qApp->FormulaFromUser(formulaAngle);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>486</width>
<height>586</height>
<width>641</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
@ -93,7 +93,7 @@
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<widget class="QToolButton" name="toolButtonPutHereLength">
<property name="text">
<string>...</string>
</property>
@ -110,7 +110,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<widget class="QToolButton" name="toolButtonEqualLength">
<property name="toolTip">
<string>Calculate value</string>
</property>
@ -206,6 +206,185 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="labelEditAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Angle</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHereAngle">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqualAngle">
<property name="toolTip">
<string>Calculate value</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultCalculationAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value of length</string>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="baseSize">
<size>
<width>4</width>
<height>0</height>
</size>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthAngle">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -291,219 +470,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Degree of angle</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>28</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="2">
<widget class="QToolButton" name="toolButtonArrowRightUp">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowRightUp.png</normaloff>:/icon/32x32/arrowRightUp.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="toolButtonArrowLeftUp">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowLeftUp.png</normaloff>:/icon/32x32/arrowLeftUp.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="toolButtonArrowLeft">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowLeft.png</normaloff>:/icon/32x32/arrowLeft.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="toolButtonArrowRight">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowRight.png</normaloff>:/icon/32x32/arrowRight.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButtonArrowUp">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowUp.png</normaloff>:/icon/32x32/arrowUp.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1" alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButtonArrowDown">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowDown.png</normaloff>:/icon/32x32/arrowDown.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QToolButton" name="toolButtonArrowLeftDown">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowLeftDown.png</normaloff>:/icon/32x32/arrowLeftDown.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="toolButtonArrowRightDown">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrowRightDown.png</normaloff>:/icon/32x32/arrowRightDown.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignHCenter">
<widget class="QDoubleSpinBox" name="doubleSpinBoxAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>72</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Angle of line</string>
</property>
<property name="maximum">
<double>360.000000000000000</double>
</property>
<property name="value">
<double>360.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
@ -621,6 +587,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -665,15 +647,6 @@
<tabstops>
<tabstop>comboBoxBasePoint</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>doubleSpinBoxAngle</tabstop>
<tabstop>toolButtonArrowRight</tabstop>
<tabstop>toolButtonArrowRightUp</tabstop>
<tabstop>toolButtonArrowUp</tabstop>
<tabstop>toolButtonArrowLeftUp</tabstop>
<tabstop>toolButtonArrowLeft</tabstop>
<tabstop>toolButtonArrowLeftDown</tabstop>
<tabstop>toolButtonArrowDown</tabstop>
<tabstop>toolButtonArrowRightDown</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
@ -682,7 +655,7 @@
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>toolButtonEqualLength</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -628,6 +628,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -468,6 +468,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -495,6 +495,22 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -62,8 +62,8 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), lineStyles(VAbstractTool::Styles()), okColor(QColor(76, 76, 76)),
errorColor(Qt::red), associatedTool(nullptr), toolId(toolId)
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), lineStyles(VAbstractTool::Styles()),
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId)
{
SCASSERT(data != nullptr);
timerFormula = new QTimer(this);
@ -415,6 +415,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
ChangeColor(labelEditFormula, Qt::red);
return;
}
timer->setSingleShot(true);
timer->start(1000);
}
@ -425,9 +426,11 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
* @param flag flag state of formula
* @param timer timer of formula
* @param label label for signal error
* @param postfix unit name
* @param checkZero true - if formula can't be equal zero
*/
void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *label, bool checkZero)
void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *label, const QString& postfix,
bool checkZero)
{
SCASSERT(timer != nullptr);
SCASSERT(label != nullptr);
@ -457,16 +460,16 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
}
else
{
QLocale loc;
if (qApp->getSettings()->value("configuration/osSeparator", 1).toBool())
{
QLocale loc = QLocale::system();
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
loc = QLocale::system();
}
else
{
QLocale loc = QLocale(QLocale::C);
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
loc = QLocale(QLocale::C);
}
label->setText(loc.toString(result) + postfix);
flag = true;
ChangeColor(labelEditFormula, okColor);
emit ToolTip("");
@ -486,7 +489,7 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
}
}
CheckState();
timer->stop();
//timer->stop();
}
//---------------------------------------------------------------------------------------------------------------------
@ -822,7 +825,8 @@ void DialogTool::EvalFormula()
{
SCASSERT(plainTextEditFormula != nullptr);
SCASSERT(labelResultCalculation != nullptr);
Eval(plainTextEditFormula->toPlainText(), flagFormula, timerFormula, labelResultCalculation);
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());
Eval(plainTextEditFormula->toPlainText(), flagFormula, timerFormula, labelResultCalculation, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
@ -885,6 +889,12 @@ void DialogTool::LengthCurves()
ShowVariable(data->DataLengthSplines());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::AngleLines()
{
ShowVariable(data->DataAngleLines());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Increments show in list increment variables

View File

@ -103,12 +103,13 @@ public slots:
void ArrowLeftDown();
void ArrowRightUp();
void ArrowRightDown();
void EvalFormula();
virtual void EvalFormula();
void SizeHeight();
void Measurements();
void LengthLines();
void LengthArcs();
void LengthCurves();
void AngleLines();
void Increments();
void PutHere();
void PutVal(QListWidgetItem * item);
@ -184,6 +185,8 @@ protected:
/** @brief radioButtonLengthCurve radio button for lengths of curves variables */
QRadioButton *radioButtonLengthCurve;
QRadioButton *radioButtonAngleLine;
/** @brief lineStyles list supported line styles. */
QStringList lineStyles;
const QColor okColor;
@ -213,7 +216,8 @@ protected:
void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget);
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer);
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
void Eval(const QString &text, bool &flag, QTimer *timer, QLabel *label, bool checkZero = true);
void Eval(const QString &text, bool &flag, QTimer *timer, QLabel *label, const QString &postfix,
bool checkZero = true);
void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const;
void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
@ -249,6 +253,7 @@ protected:
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
radioButtonAngleLine = ui->radioButtonAngleLine;
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
@ -268,6 +273,7 @@ protected:
connect(radioButtonLengthLine, &QRadioButton::clicked, this, &DialogTool::LengthLines);
connect(radioButtonLengthArc, &QRadioButton::clicked, this, &DialogTool::LengthArcs);
connect(radioButtonLengthCurve, &QRadioButton::clicked, this, &DialogTool::LengthCurves);
connect(radioButtonAngleLine, &QRadioButton::clicked, this, &DialogTool::AngleLines);
}
template <typename T>
/**

View File

@ -74,7 +74,7 @@ void VToolAlongLine::FullUpdateFromFile()
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
@ -129,7 +129,7 @@ void VToolAlongLine::AddToFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
@ -150,7 +150,7 @@ void VToolAlongLine::RefreshDataInFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}
@ -193,7 +193,7 @@ void VToolAlongLine::setDialog()
SCASSERT(dialogTool != nullptr);
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogTool->setTypeLine(typeLine);
dialogTool->setFormula(formula);
dialogTool->setFormula(formulaLength);
dialogTool->setFirstPointId(basePointId);
dialogTool->setSecondPointId(secondPointId);
dialogTool->setPointName(p->name());

View File

@ -111,7 +111,7 @@ void VToolBisector::setDialog()
SCASSERT(dialogTool != nullptr);
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogTool->setTypeLine(typeLine);
dialogTool->setFormula(formula);
dialogTool->setFormula(formulaLength);
dialogTool->setFirstPointId(firstPointId);
dialogTool->setSecondPointId(basePointId);
dialogTool->setThirdPointId(thirdPointId);
@ -223,7 +223,7 @@ void VToolBisector::FullUpdateFromFile()
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
formulaLength = domElement.attribute(AttrLength, "");
firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt();
basePointId = domElement.attribute(AttrSecondPoint, "").toUInt();
thirdPointId = domElement.attribute(AttrThirdPoint, "").toUInt();
@ -278,7 +278,7 @@ void VToolBisector::AddToFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, basePointId);
doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId);
@ -300,7 +300,7 @@ void VToolBisector::RefreshDataInFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, basePointId);
doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId);

View File

@ -42,18 +42,17 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine");
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length of line.
* @param angle angle of line.
* @param formulaLength string with formula length of line.
* @param formulaAngle formula angle of line.
* @param basePointId id first point of line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &basePointId,
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent)
:VToolLinePoint(doc, data, id, typeLine, formulaLength, basePointId, 0, parent), formulaAngle(formulaAngle)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
@ -76,8 +75,8 @@ void VToolEndLine::setDialog()
SCASSERT(dialogTool != nullptr);
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogTool->setTypeLine(typeLine);
dialogTool->setFormula(formula);
dialogTool->setAngle(angle);
dialogTool->setFormula(formulaLength);
dialogTool->setAngle(formulaAngle);
dialogTool->setBasePointId(basePointId);
dialogTool->setPointName(p->name());
}
@ -98,13 +97,13 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
SCASSERT(dialogTool);
const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine();
QString formula = dialogTool->getFormula();
const qreal angle = dialogTool->getAngle();
QString formulaLength = dialogTool->getFormula();
QString formulaAngle = dialogTool->getAngle();
const quint32 basePointId = dialogTool->getBasePointId();
VToolEndLine *point = nullptr;
point=Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Source::FromGui);
point=Create(0, pointName, typeLine, formulaLength, formulaAngle, basePointId, 5, 10, scene, doc, data,
Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
@ -118,8 +117,8 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param typeLine line type.
* @param formula string with formula length of line.
* @param angle angle of line.
* @param formulaLength string with formula length of line.
* @param formulaAngle formula angle of line.
* @param basePointId id first point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
@ -131,15 +130,15 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
* @return the created tool
*/
VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const qreal &angle, const quint32 &basePointId,
QString &formulaLength, QString &formulaAngle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
const VPointF *basePoint = data->GeometricObject<const VPointF *>(basePointId);
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
line.setLength(qApp->toPixel(CheckFormula(_id, formula, data)));
line.setAngle(angle);
line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data)));
line.setAngle(CheckFormula(_id, formulaAngle, data));
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
@ -158,8 +157,8 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
VDrawTool::AddRecord(id, Tool::EndLineTool, doc);
if (parse == Document::FullParse)
{
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle,
basePointId, typeCreation);
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formulaLength, formulaAngle, basePointId,
typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
@ -181,9 +180,9 @@ void VToolEndLine::FullUpdateFromFile()
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
angle = domElement.attribute(AttrAngle, "").toDouble();
formulaAngle = domElement.attribute(AttrAngle, "");
}
RefreshGeometry();
}
@ -224,8 +223,8 @@ void VToolEndLine::AddToFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrAngle, angle);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, formulaAngle);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
AddToCalculation(domElement);
@ -245,8 +244,8 @@ void VToolEndLine::RefreshDataInFile()
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrAngle, angle);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, formulaAngle);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
}
}
@ -263,6 +262,6 @@ void VToolEndLine::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine());
doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula());
doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle()));
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId()));
}

View File

@ -39,15 +39,15 @@ class VToolEndLine : public VToolLinePoint
Q_OBJECT
public:
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
const qreal &angle, const quint32 &basePointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const qreal &angle, const quint32 &basePointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formulaLength, QString &formulaAngle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
virtual void FullUpdateFromFile();
@ -57,6 +57,8 @@ protected:
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
private:
QString formulaAngle;
};
#endif // VTOOLENDLINE_H

View File

@ -36,7 +36,7 @@
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with length formula.
* @param formulaLength string with length formula.
* @param basePointId id base line point.
* @param angle line angle.
* @param parent parent object.
@ -44,7 +44,8 @@
VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id,
const QString &typeLine, const QString &formula, const quint32 &basePointId,
const qreal &angle, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), formula(formula), angle(angle), basePointId(basePointId), mainLine(nullptr)
:VToolPoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId),
mainLine(nullptr)
{
this->typeLine = typeLine;
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");

View File

@ -45,7 +45,7 @@ public slots:
virtual void SetFactor(qreal factor);
protected:
/** @brief formula string with length formula. */
QString formula;
QString formulaLength;
/** @brief angle line angle. */
qreal angle;

View File

@ -75,7 +75,7 @@ void VToolNormal::setDialog()
SCASSERT(dialogTool != nullptr);
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogTool->setTypeLine(typeLine);
dialogTool->setFormula(formula);
dialogTool->setFormula(formulaLength);
dialogTool->setAngle(angle);
dialogTool->setFirstPointId(basePointId);
dialogTool->setSecondPointId(secondPointId);
@ -203,7 +203,7 @@ void VToolNormal::FullUpdateFromFile()
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
angle = domElement.attribute(AttrAngle, "").toDouble();
@ -258,7 +258,7 @@ void VToolNormal::AddToFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, angle);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
@ -280,7 +280,7 @@ void VToolNormal::RefreshDataInFile()
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, angle);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);

View File

@ -74,7 +74,7 @@ void VToolShoulderPoint::setDialog()
SCASSERT(dialogTool != nullptr);
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogTool->setTypeLine(typeLine);
dialogTool->setFormula(formula);
dialogTool->setFormula(formulaLength);
dialogTool->setP1Line(basePointId);
dialogTool->setP2Line(p2Line);
dialogTool->setPShoulder(pShoulder);
@ -226,7 +226,7 @@ void VToolShoulderPoint::FullUpdateFromFile()
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrP1Line, "").toUInt();
p2Line = domElement.attribute(AttrP2Line, "").toUInt();
pShoulder = domElement.attribute(AttrPShoulder, "").toUInt();
@ -281,7 +281,7 @@ void VToolShoulderPoint::AddToFile()
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrP1Line, basePointId);
doc->SetAttribute(domElement, AttrP2Line, p2Line);
doc->SetAttribute(domElement, AttrPShoulder, pShoulder);
@ -303,7 +303,7 @@ void VToolShoulderPoint::RefreshDataInFile()
doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrP1Line, basePointId);
doc->SetAttribute(domElement, AttrP2Line, p2Line);
doc->SetAttribute(domElement, AttrPShoulder, pShoulder);

View File

@ -109,7 +109,41 @@ qreal VisLine::FindLength(const QString &expression)
<< "--------------------------------------";
}
}
return qApp->toPixel(length);
return qApp->toPixel(FindVal(expression));
}
//---------------------------------------------------------------------------------------------------------------------
qreal VisLine::FindVal(const QString &expression)
{
qreal val = 0;
if (expression.isEmpty())
{
val = 0;
}
else
{
try
{
// Replace line return with spaces for calc if exist
QString formula = expression;
formula.replace("\n", " ");
formula = qApp->FormulaFromUser(formula);
Calculator *cal = new Calculator(data);
val = cal->EvalFormula(formula);
delete cal;
}
catch (qmu::QmuParserError &e)
{
val = 0;
qDebug() << "\nMath parser error:\n"
<< "--------------------------------------\n"
<< "Message: " << e.GetMsg() << "\n"
<< "Expression: " << e.GetExpr() << "\n"
<< "--------------------------------------";
}
}
return val;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -64,6 +64,7 @@ protected:
QString toolTip;
QRectF PointRect();
qreal FindLength(const QString &expression);
qreal FindVal(const QString &expression);
void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
Qt::PenStyle style = Qt::SolidLine);
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color);

View File

@ -77,15 +77,15 @@ void VisToolEndLine::RefreshGeometry()
}
//---------------------------------------------------------------------------------------------------------------------
qreal VisToolEndLine::Angle() const
QString VisToolEndLine::Angle() const
{
return this->line().angle();
return QString("%1").arg(this->line().angle());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::setAngle(const qreal &value)
void VisToolEndLine::setAngle(const QString &expression)
{
angle = value;
angle = FindVal(expression);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -41,8 +41,8 @@ public:
virtual ~VisToolEndLine();
virtual void RefreshGeometry();
qreal Angle() const;
void setAngle(const qreal &value);
QString Angle() const;
void setAngle(const QString &expression);
void setLength(const QString &expression);
private:
Q_DISABLE_COPY(VisToolEndLine)

View File

@ -1124,18 +1124,22 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
try
{
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolEndLine::Create(id, name, typeLine, f, angle, basePointId,
mx, my, scene, this, data, parse, Source::FromFile);
const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0");
QString angleFix = angle;
VToolEndLine::Create(id, name, typeLine, f, angleFix, basePointId, mx, my, scene, this, data, parse,
Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
if (f != formula || angleFix != angle)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
SetAttribute(domElement, VAbstractTool::AttrRadius, f);
SetAttribute(domElement, VAbstractTool::AttrAngle, angleFix);
haveLiteChange();
}
}