Refactoring. Delete repetitive code. Replace lineEdit by plainTextEdit.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-19 12:29:56 +03:00
parent e01b8b2164
commit 1884e302b4
37 changed files with 906 additions and 641 deletions

View file

@ -66,9 +66,6 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent)
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
InitVariables(ui); InitVariables(ui);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -80,20 +77,7 @@ void DialogAlongLine::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::DeployFormulaTextEdit() void DialogAlongLine::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGALONLINE_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGALONLINE_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,7 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGALONLINE_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogAlongLine; class DialogAlongLine;

View file

@ -160,6 +160,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -189,8 +195,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../share/resources/theme.qrc"> <iconset theme="go-down"/>
<normaloff>:/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png</normaloff>:/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -468,7 +473,6 @@
</tabstops> </tabstops>
<resources> <resources>
<include location="../../share/resources/icon.qrc"/> <include location="../../share/resources/icon.qrc"/>
<include location="../../share/resources/theme.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View file

@ -44,10 +44,14 @@
DialogArc::DialogArc(const VContainer *data, QWidget *parent) DialogArc::DialogArc(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), :DialogTool(data, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(0), radius(QString()), f1(QString()), timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(0), radius(QString()), f1(QString()),
f2(QString()), formulaBaseHeight(0) f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui);
plainTextEditFormula = ui->plainTextEditFormula;
timerRadius = new QTimer(this); timerRadius = new QTimer(this);
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius); connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);
@ -60,13 +64,13 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent)
InitOkCancelApply(ui); InitOkCancelApply(ui);
this->formulaBaseHeight=ui->plainTextEditFormula->height(); this->formulaBaseHeight=ui->plainTextEditFormula->height();
this->formulaBaseHeightF1=ui->plainTextEditF1->height();
this->formulaBaseHeightF2=ui->plainTextEditF2->height();
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
CheckState(); CheckState();
InitVariables(ui);
connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius);
connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1);
connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2); connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2);
@ -76,31 +80,30 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent)
connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2); connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged);
connect(ui->lineEditF1, &QLineEdit::textChanged, this, &DialogArc::F1Changed); connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArc::F1Changed);
connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed); connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, &DialogArc::F2Changed);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::DeployFormulaTextEdit() void DialogArc::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGARC_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{ }
ui->plainTextEditFormula->setFixedHeight(DIALOGARC_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system) //---------------------------------------------------------------------------------------------------------------------
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", void DialogArc::DeployF1TextEdit()
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); {
} DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
else }
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); //---------------------------------------------------------------------------------------------------------------------
//Set icon from theme (internal for Windows system) void DialogArc::DeployF2TextEdit()
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", {
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); DeployFormula(ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -127,8 +130,13 @@ void DialogArc::SetCenter(const quint32 &value)
*/ */
void DialogArc::SetF2(const QString &value) void DialogArc::SetF2(const QString &value)
{ {
f2 = value; f2 = qApp->FormulaToUser(value);
ui->lineEditF2->setText(f2); // increase height if needed.
if (f2.length() > 80)
{
this->DeployF2TextEdit();
}
ui->plainTextEditF2->setPlainText(f2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -138,8 +146,13 @@ void DialogArc::SetF2(const QString &value)
*/ */
void DialogArc::SetF1(const QString &value) void DialogArc::SetF1(const QString &value)
{ {
f1 = value; f1 = qApp->FormulaToUser(value);
ui->lineEditF1->setText(f1); // increase height if needed.
if (f1.length() > 80)
{
this->DeployF1TextEdit();
}
ui->plainTextEditF1->setPlainText(f1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -197,8 +210,10 @@ void DialogArc::SaveData()
{ {
radius = ui->plainTextEditFormula->toPlainText(); radius = ui->plainTextEditFormula->toPlainText();
radius.replace("\n", " "); radius.replace("\n", " ");
f1 = ui->lineEditF1->text(); f1 = ui->plainTextEditF1->toPlainText();
f2 = ui->lineEditF2->text(); f1.replace("\n", " ");
f2 = ui->plainTextEditF2->toPlainText();
f2.replace("\n", " ");
center = getCurrentObjectId(ui->comboBoxBasePoint); center = getCurrentObjectId(ui->comboBoxBasePoint);
} }
@ -239,7 +254,7 @@ void DialogArc::PutRadius()
*/ */
void DialogArc::PutF1() void DialogArc::PutF1()
{ {
PutValHere(ui->lineEditF1, ui->listWidget); PutValHere(ui->plainTextEditF1, ui->listWidget);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -248,7 +263,7 @@ void DialogArc::PutF1()
*/ */
void DialogArc::PutF2() void DialogArc::PutF2()
{ {
PutValHere(ui->lineEditF2, ui->listWidget); PutValHere(ui->plainTextEditF2, ui->listWidget);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -278,7 +293,7 @@ void DialogArc::RadiusChanged()
void DialogArc::F1Changed() void DialogArc::F1Changed()
{ {
labelEditFormula = ui->labelEditF1; labelEditFormula = ui->labelEditF1;
ValFormulaChanged(flagF1, ui->lineEditF1, timerF1); ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -288,7 +303,7 @@ void DialogArc::F1Changed()
void DialogArc::F2Changed() void DialogArc::F2Changed()
{ {
labelEditFormula = ui->labelEditF2; labelEditFormula = ui->labelEditF2;
ValFormulaChanged(flagF2, ui->lineEditF2, timerF2); ValFormulaChanged(flagF2, ui->plainTextEditF2, timerF2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -320,7 +335,7 @@ void DialogArc::EvalRadius()
void DialogArc::EvalF1() void DialogArc::EvalF1()
{ {
labelEditFormula = ui->labelEditF1; labelEditFormula = ui->labelEditF1;
Eval(ui->lineEditF1->text(), flagF1, timerF1, ui->labelResultF1); Eval(ui->plainTextEditF1->toPlainText(), flagF1, timerF1, ui->labelResultF1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -330,7 +345,7 @@ void DialogArc::EvalF1()
void DialogArc::EvalF2() void DialogArc::EvalF2()
{ {
labelEditFormula = ui->labelEditF2; labelEditFormula = ui->labelEditF2;
Eval(ui->lineEditF2->text(), flagF2, timerF2, ui->labelResultF2); Eval(ui->plainTextEditF2->toPlainText(), flagF2, timerF2, ui->labelResultF2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,7 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGARC_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogArc; class DialogArc;
@ -69,6 +68,8 @@ public slots:
* @brief DeployFormulaTextEdit grow or shrink formula input * @brief DeployFormulaTextEdit grow or shrink formula input
*/ */
void DeployFormulaTextEdit(); void DeployFormulaTextEdit();
void DeployF1TextEdit();
void DeployF2TextEdit();
virtual void ValChenged(int row); virtual void ValChenged(int row);
void PutRadius(); void PutRadius();
void PutF1(); void PutF1();
@ -118,6 +119,8 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
int formulaBaseHeightF1;
int formulaBaseHeightF2;
void EvalRadius(); void EvalRadius();
void EvalF1(); void EvalF1();

View file

@ -23,9 +23,6 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item> <item>
<widget class="QLabel" name="labelEditRadius"> <widget class="QLabel" name="labelEditRadius">
<property name="sizePolicy"> <property name="sizePolicy">
@ -77,50 +74,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <spacer name="horizontalSpacer">
<property name="maximumSize"> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size> <size>
<width>16777215</width> <width>40</width>
<height>24</height> <height>20</height>
</size> </size>
</property> </property>
</widget> </spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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.png">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonPutHereRadius"> <widget class="QToolButton" name="toolButtonPutHereRadius">
@ -186,6 +150,60 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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"/>
</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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
@ -239,17 +257,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditF1"> <spacer name="horizontalSpacer_2">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="toolTip"> <property name="sizeHint" stdset="0">
<string>First angle of arc counterclockwise</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonPutHereF1"> <widget class="QToolButton" name="toolButtonPutHereF1">
@ -315,6 +333,60 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditF1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthF1">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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"/>
</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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
@ -368,17 +440,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditF2"> <spacer name="horizontalSpacer_3">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="toolTip"> <property name="sizeHint" stdset="0">
<string>Second angle of arc counterclockwise</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonPutHereF2"> <widget class="QToolButton" name="toolButtonPutHereF2">
@ -444,6 +516,60 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPlainTextEdit" name="plainTextEditF2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthF2">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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"/>
</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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
@ -623,8 +749,6 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>lineEditF1</tabstop>
<tabstop>lineEditF2</tabstop>
<tabstop>comboBoxBasePoint</tabstop> <tabstop>comboBoxBasePoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop> <tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop> <tabstop>radioButtonStandardTable</tabstop>

View file

@ -68,9 +68,6 @@ DialogBisector::DialogBisector(const VContainer *data, QWidget *parent)
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogBisector::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogBisector::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -82,20 +79,7 @@ void DialogBisector::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogBisector::DeployFormulaTextEdit() void DialogBisector::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGBISECTOR_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGBISECTOR_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,7 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGBISECTOR_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogBisector; class DialogBisector;

View file

@ -151,6 +151,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_formula"> <layout class="QHBoxLayout" name="horizontalLayout_formula">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -180,7 +186,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down.png"/> <iconset theme="go-down"/>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -64,9 +64,6 @@ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent)
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -78,20 +75,7 @@ void DialogCutArc::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::DeployFormulaTextEdit() void DialogCutArc::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGCUTARC_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGCUTARC_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,7 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGCUTARC_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogCutArc; class DialogCutArc;

View file

@ -144,6 +144,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_formula"> <layout class="QHBoxLayout" name="horizontalLayout_formula">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -173,9 +179,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down.png"> <iconset theme="go-down"/>
<normaloff/>
</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -39,12 +39,13 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent) DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()), splineId(0) :DialogTool(data, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()), splineId(0),
formulaBaseHeight(0)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
labelResultCalculation = ui->labelResultCalculation; labelResultCalculation = ui->labelResultCalculation;
lineEditFormula = ui->lineEditFormula; plainTextEditFormula = ui->plainTextEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancel(ui); InitOkCancel(ui);
@ -53,13 +54,16 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent)
flagName = false; flagName = false;
CheckState(); CheckState();
this->formulaBaseHeight=ui->plainTextEditFormula->height();
FillComboBoxSplines(ui->comboBoxSpline); FillComboBoxSplines(ui->comboBoxSpline);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSpline::EvalFormula); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSpline::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutSpline::FormulaChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -87,7 +91,13 @@ void DialogCutSpline::setPointName(const QString &value)
void DialogCutSpline::setFormula(const QString &value) void DialogCutSpline::setFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
ui->lineEditFormula->setText(formula); // 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)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -125,7 +135,14 @@ void DialogCutSpline::ChoosedObject(quint32 id, const SceneObject &type)
void DialogCutSpline::DialogAccepted() void DialogCutSpline::DialogAccepted()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
formula = ui->lineEditFormula->text(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
splineId = getCurrentObjectId(ui->comboBoxSpline); splineId = getCurrentObjectId(ui->comboBoxSpline);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}

View file

@ -61,6 +61,10 @@ public slots:
* @brief DialogApply apply data and emit signal about applied dialog. * @brief DialogApply apply data and emit signal about applied dialog.
*/ */
virtual void DialogApply(){} virtual void DialogApply(){}
/**
* @brief DeployFormulaTextEdit grow or shrink formula input
*/
void DeployFormulaTextEdit();
private: private:
Q_DISABLE_COPY(DialogCutSpline) Q_DISABLE_COPY(DialogCutSpline)
@ -75,6 +79,9 @@ private:
/** @brief splineId keep id of spline */ /** @brief splineId keep id of spline */
quint32 splineId; quint32 splineId;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>520</width> <width>665</width>
<height>546</height> <height>546</height>
</rect> </rect>
</property> </property>
@ -67,17 +67,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditFormula"> <spacer name="horizontalSpacer">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="toolTip"> <property name="sizeHint" stdset="0">
<string>Formula for the calculation of the spline</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonPutHere"> <widget class="QToolButton" name="toolButtonPutHere">
@ -140,6 +140,60 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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"/>
</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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>

View file

@ -40,12 +40,12 @@
*/ */
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent) DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()), :DialogTool(data, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
splinePathId(0) splinePathId(0), formulaBaseHeight(0)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
labelResultCalculation = ui->labelResultCalculation; labelResultCalculation = ui->labelResultCalculation;
lineEditFormula = ui->lineEditFormula; plainTextEditFormula = ui->plainTextEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
@ -53,6 +53,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent
flagFormula = false; flagFormula = false;
flagName = false; flagName = false;
CheckState(); CheckState();
this->formulaBaseHeight=ui->plainTextEditFormula->height();
FillComboBoxSplinesPath(ui->comboBoxSplinePath); FillComboBoxSplinesPath(ui->comboBoxSplinePath);
@ -60,7 +61,8 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSplinePath::EvalFormula); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSplinePath::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -88,7 +90,13 @@ void DialogCutSplinePath::setPointName(const QString &value)
void DialogCutSplinePath::setFormula(const QString &value) void DialogCutSplinePath::setFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
ui->lineEditFormula->setText(formula); // 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)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -126,7 +134,14 @@ void DialogCutSplinePath::ChoosedObject(quint32 id, const SceneObject &type)
void DialogCutSplinePath::DialogAccepted() void DialogCutSplinePath::DialogAccepted()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
formula = ui->lineEditFormula->text(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
splinePathId = getCurrentObjectId(ui->comboBoxSplinePath); splinePathId = getCurrentObjectId(ui->comboBoxSplinePath);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}

View file

@ -61,6 +61,10 @@ public slots:
* @brief DialogApply apply data and emit signal about applied dialog. * @brief DialogApply apply data and emit signal about applied dialog.
*/ */
virtual void DialogApply(){} virtual void DialogApply(){}
/**
* @brief DeployFormulaTextEdit grow or shrink formula input
*/
void DeployFormulaTextEdit();
private: private:
Q_DISABLE_COPY(DialogCutSplinePath) Q_DISABLE_COPY(DialogCutSplinePath)
@ -75,6 +79,9 @@ private:
/** @brief splinePathId keep id of splinePath */ /** @brief splinePathId keep id of splinePath */
quint32 splinePathId; quint32 splinePathId;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>605</width> <width>464</width>
<height>499</height> <height>499</height>
</rect> </rect>
</property> </property>
@ -67,17 +67,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditFormula"> <spacer name="horizontalSpacer">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="toolTip"> <property name="sizeHint" stdset="0">
<string>Formula for the calculation of the curve length</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonPutHere"> <widget class="QToolButton" name="toolButtonPutHere">
@ -140,6 +140,60 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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"/>
</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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>

View file

@ -31,24 +31,26 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent) DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()) :DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
labelResultCalculation = ui->labelResult; labelResultCalculation = ui->labelResult;
lineEditFormula = ui->lineEditFormula; plainTextEditFormula = ui->plainTextEditFormula;
labelEditFormula = ui->labelFormula; labelEditFormula = ui->labelFormula;
InitOkCancel(ui); InitOkCancel(ui);
flagFormula = false; flagFormula = false;
CheckState(); CheckState();
this->formulaBaseHeight=ui->plainTextEditFormula->height();
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit);
//Disable Qt::WaitCursor //Disable Qt::WaitCursor
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
@ -68,7 +70,8 @@ DialogEditWrongFormula::~DialogEditWrongFormula()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::DialogAccepted() void DialogEditWrongFormula::DialogAccepted()
{ {
formula = ui->lineEditFormula->text(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
accepted(); accepted();
} }
@ -80,6 +83,12 @@ void DialogEditWrongFormula::DialogRejected()
rejected(); rejected();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::CheckState() void DialogEditWrongFormula::CheckState()
{ {
@ -91,7 +100,13 @@ void DialogEditWrongFormula::CheckState()
void DialogEditWrongFormula::setFormula(const QString &value) void DialogEditWrongFormula::setFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
ui->lineEditFormula->setText(formula); // 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)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -56,6 +56,10 @@ public:
public slots: public slots:
virtual void DialogAccepted(); virtual void DialogAccepted();
virtual void DialogRejected(); virtual void DialogRejected();
/**
* @brief DeployFormulaTextEdit grow or shrink formula input
*/
void DeployFormulaTextEdit();
protected: protected:
virtual void CheckState(); virtual void CheckState();
private: private:
@ -64,6 +68,9 @@ private:
/** @brief formula string with formula */ /** @brief formula string with formula */
QString formula; QString formula;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
}; };

View file

@ -6,305 +6,357 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>607</width> <width>507</width>
<height>535</height> <height>535</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Edit wrong formula</string> <string>Edit wrong formula</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QLabel" name="labelFormula">
<item> <property name="sizePolicy">
<widget class="QLabel" name="labelFormula"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<property name="sizePolicy"> <horstretch>0</horstretch>
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <verstretch>0</verstretch>
<horstretch>0</horstretch> </sizepolicy>
<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>Formula</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>First angle of arc counterclockwise</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="toolTip">
<string>Insert variable into formula</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHereLeft.png</normaloff>:/icon/24x24/putHereLeft.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<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="labelResult">
<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 first angle</string>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Input data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<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>Length of lines</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<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>Length of arcs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<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>Length of curves</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLineAngles">
<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>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="toolTip">
<string>Variables</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property> </property>
<property name="wordWrap"> <property name="palette">
<bool>true</bool> <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>Formula</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons"> <property name="sizeHint" stdset="0">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="toolTip">
<string>Insert variable into formula</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHereLeft.png</normaloff>:/icon/24x24/putHereLeft.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<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="labelResult">
<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 first angle</string>
</property>
<property name="text">
<string>_</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Input data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<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>Length of lines</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<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>Length of arcs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<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>Length of curves</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLineAngles">
<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>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="toolTip">
<string>Variables</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>

View file

@ -67,10 +67,6 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent)
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -82,20 +78,7 @@ void DialogEndLine::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::DeployFormulaTextEdit() void DialogEndLine::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGENDLINE_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGENDLINE_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,8 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGENDLINE_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogEndLine; class DialogEndLine;

View file

@ -189,8 +189,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../share/resources/theme.qrc"> <iconset theme="go-down"/>
<normaloff>:/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png</normaloff>:/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -677,7 +676,6 @@
</tabstops> </tabstops>
<resources> <resources>
<include location="../../share/resources/icon.qrc"/> <include location="../../share/resources/icon.qrc"/>
<include location="../../share/resources/theme.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View file

@ -65,9 +65,6 @@ DialogNormal::DialogNormal(const VContainer *data, QWidget *parent)
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogNormal::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogNormal::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -79,18 +76,7 @@ void DialogNormal::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogNormal::DeployFormulaTextEdit() void DialogNormal::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGNORMAL_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGNORMAL_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next"));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down"));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,7 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGNORMAL_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogNormal; class DialogNormal;

View file

@ -154,6 +154,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_formula"> <layout class="QHBoxLayout" name="horizontalLayout_formula">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -183,9 +189,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down.png"> <iconset theme="go-down"/>
<normaloff/>
</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -97,9 +97,6 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogPointOfContact::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogPointOfContact::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -111,20 +108,7 @@ void DialogPointOfContact::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::DeployFormulaTextEdit() void DialogPointOfContact::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -32,7 +32,6 @@
#include "ui_dialogpointofcontact.h" #include "ui_dialogpointofcontact.h"
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogPointOfContact; class DialogPointOfContact;

View file

@ -154,6 +154,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_formula"> <layout class="QHBoxLayout" name="horizontalLayout_formula">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -183,9 +189,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down.png"> <iconset theme="go-down"/>
<normaloff/>
</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -68,9 +68,6 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogShoulderPoint::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogShoulderPoint::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -82,20 +79,7 @@ void DialogShoulderPoint::FormulaTextChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::DeployFormulaTextEdit() void DialogShoulderPoint::DeployFormulaTextEdit()
{ {
if (ui->plainTextEditFormula->height() < DIALOGSHOULDERPOINT_MAX_FORMULA_HEIGHT) DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
{
ui->plainTextEditFormula->setFixedHeight(DIALOGSHOULDERPOINT_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -31,7 +31,6 @@
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGSHOULDERPOINT_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogShoulderPoint; class DialogShoulderPoint;

View file

@ -154,6 +154,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_formula"> <layout class="QHBoxLayout" name="horizontalLayout_formula">
<item> <item>
<widget class="QPlainTextEdit" name="plainTextEditFormula"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
@ -183,9 +189,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down.png"> <iconset theme="go-down"/>
<normaloff/>
</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -41,7 +41,6 @@
#include <QShowEvent> #include <QShowEvent>
#include <QComboBox> #include <QComboBox>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QLineEdit>
#include <QTextCursor> #include <QTextCursor>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QLabel> #include <QLabel>
@ -51,6 +50,8 @@
#include <QListWidget> #include <QListWidget>
#include <QRadioButton> #include <QRadioButton>
#define DIALOGARC_MAX_FORMULA_HEIGHT 64
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief DialogTool create dialog * @brief DialogTool create dialog
@ -59,7 +60,7 @@
*/ */
DialogTool::DialogTool(const VContainer *data, QWidget *parent) DialogTool::DialogTool(const VContainer *data, QWidget *parent)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr), :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr),
bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr),
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr), listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
@ -385,12 +386,6 @@ void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidg
QTextCursor cursor = plainTextEdit->textCursor(); QTextCursor cursor = plainTextEdit->textCursor();
cursor.insertText(item->text()); cursor.insertText(item->text());
plainTextEdit->setTextCursor(cursor); plainTextEdit->setTextCursor(cursor);
/*
int pos = lineEdit->cursorPosition();
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
lineEdit->setFocus();
lineEdit->setCursorPosition(pos + item->text().size());
*/
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -601,6 +596,27 @@ bool DialogTool::ChoosedPoint(const quint32 &id, QComboBox *box, const QString &
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight)
{
SCASSERT(formula != nullptr);
SCASSERT(buttonGrowLength != nullptr)
if (formula->height() < DIALOGARC_MAX_FORMULA_HEIGHT)
{
formula->setFixedHeight(DIALOGARC_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
buttonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
formula->setFixedHeight(formulaBaseHeight);
//Set icon from theme (internal for Windows system)
buttonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief FillList fill combobox list * @brief FillList fill combobox list
@ -700,7 +716,7 @@ void DialogTool::DialogRejected()
*/ */
void DialogTool::FormulaChanged() void DialogTool::FormulaChanged()
{ {
QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(sender());
if (edit) if (edit)
{ {
ValFormulaChanged(flagFormula, edit, timerFormula); ValFormulaChanged(flagFormula, edit, timerFormula);
@ -897,12 +913,6 @@ void DialogTool::PutVal(QListWidgetItem *item)
QTextCursor cursor = plainTextEditFormula->textCursor(); QTextCursor cursor = plainTextEditFormula->textCursor();
cursor.insertText(item->text()); cursor.insertText(item->text());
plainTextEditFormula->setTextCursor(cursor); plainTextEditFormula->setTextCursor(cursor);
/*int pos = plainTextEditFormula->cursorPosition();
lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(),
item->text()));
lineEditFormula->setFocus();
lineEditFormula->setCursorPosition(pos + item->text().size());
*/
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -39,7 +39,6 @@ class QLabel;
class QRadioButton; class QRadioButton;
class QComboBox; class QComboBox;
class QListWidgetItem; class QListWidgetItem;
class QLineEdit;
class QListWidget; class QListWidget;
class VContainer; class VContainer;
class QPlainTextEdit; class QPlainTextEdit;
@ -134,8 +133,7 @@ protected:
/** @brief spinBoxAngle spinbox for angle */ /** @brief spinBoxAngle spinbox for angle */
QDoubleSpinBox *spinBoxAngle; QDoubleSpinBox *spinBoxAngle;
/** @brief lineEditFormula linEdit for formula */ /** @brief plainTextEditFormula formula */
QLineEdit *lineEditFormula;
QPlainTextEdit *plainTextEditFormula; QPlainTextEdit *plainTextEditFormula;
/** @brief listWidget listWidget with variables */ /** @brief listWidget listWidget with variables */
QListWidget *listWidget; QListWidget *listWidget;
@ -205,6 +203,7 @@ protected:
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
quint32 getCurrentObjectId(QComboBox *box) const; quint32 getCurrentObjectId(QComboBox *box) const;
bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip); bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip);
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
template <typename T> template <typename T>
void InitArrow(T *ui) void InitArrow(T *ui)
{ {

View file

@ -40,5 +40,8 @@
<file alias="24x24/actions/edit-redo.png">icons/win.icon.theme/24x24/actions/edit-redo.png</file> <file alias="24x24/actions/edit-redo.png">icons/win.icon.theme/24x24/actions/edit-redo.png</file>
<file alias="32x32/actions/edit-redo.png">icons/win.icon.theme/32x32/actions/edit-redo.png</file> <file alias="32x32/actions/edit-redo.png">icons/win.icon.theme/32x32/actions/edit-redo.png</file>
<file alias="32x32/actions/edit-undo.png">icons/win.icon.theme/32x32/actions/edit-undo.png</file> <file alias="32x32/actions/edit-undo.png">icons/win.icon.theme/32x32/actions/edit-undo.png</file>
<file alias="16x16/actions/go-down.png">icons/win.icon.theme/16x16/actions/go-down.png</file>
<file alias="24x24/actions/go-down.png">icons/win.icon.theme/24x24/actions/go-down.png</file>
<file alias="32x32/actions/go-down.png">icons/win.icon.theme/32x32/actions/go-down.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -164,41 +164,51 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
VSplinePath *splPath1 = new VSplinePath(); VSplinePath *splPath1 = new VSplinePath();
VSplinePath *splPath2 = new VSplinePath(); VSplinePath *splPath2 = new VSplinePath();
for (qint32 i = 0; i < splPath->CountPoint(); i++)
{
if (i <= p1 && i < p2)
{
if (i == p1)
{
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
spl1.GetAngle1()));
VSplinePoint cutPoint;
if (typeCreation == Source::FromGui)
{
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl1.GetAngle2()+180,
spl1.GetAngle2());
}
else
{
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(),
spl1.GetAngle2()+180);
}
splPath1->append(cutPoint);
continue;
}
splPath1->append(splPath->at(i));
}
else
{
if (i == p2)
{
const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180,
spl2.GetKasm1(), spl2.GetAngle1());
splPath2->append(cutPoint);
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(),
spl2.GetAngle2()+180));
continue;
}
splPath2->append(splPath->at(i));
}
}
splPath1->setMaxCountPoints(splPath->CountPoint());
splPath2->setMaxCountPoints(splPath->CountPoint());
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
{ {
for (qint32 i = 0; i < splPath->CountPoint(); i++)
{
if (i <= p1 && i < p2)
{
if (i == p1)
{
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
spl1.GetAngle1()));
const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(),
spl1.GetAngle2()+180, spl1.GetAngle2());
splPath1->append(cutPoint);
continue;
}
splPath1->append(splPath->at(i));
}
else
{
if (i == p2)
{
const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180,
spl2.GetKasm1(), spl2.GetAngle1());
splPath2->append(cutPoint);
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(),
spl2.GetAngle2()+180));
continue;
}
splPath2->append(splPath->at(i));
}
}
splPath1->setMaxCountPoints(splPath->CountPoint());
splPath2->setMaxCountPoints(splPath->CountPoint());
splPath1id = data->AddGObject(splPath1); splPath1id = data->AddGObject(splPath1);
data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength())); data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength()));
@ -207,39 +217,6 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
} }
else else
{ {
for (qint32 i = 0; i < splPath->CountPoint(); i++)
{
if (i <= p1 && i < p2)
{
if (i == p1)
{
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
spl1.GetAngle1()));
const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(),
spl2.GetKasm1(), spl1.GetAngle2()+180);
splPath1->append(cutPoint);
continue;
}
splPath1->append(splPath->at(i));
}
else
{
if (i == p2)
{
const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180,
spl2.GetKasm1(), spl2.GetAngle1());
splPath2->append(cutPoint);
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(),
spl2.GetAngle2()+180));
continue;
}
splPath2->append(splPath->at(i));
}
}
splPath1->setMaxCountPoints(splPath->CountPoint());
splPath2->setMaxCountPoints(splPath->CountPoint());
data->UpdateGObject(splPath1id, splPath1); data->UpdateGObject(splPath1id, splPath1);
data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength())); data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength()));
@ -251,6 +228,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc); VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {