F(x)button for tool "Point at distance along line".

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-04-29 19:35:38 +03:00
parent 356f1f2e85
commit ce101c10f5
4 changed files with 121 additions and 261 deletions

View File

@ -1803,6 +1803,10 @@ QString VApplication::PostfixOperator(const QString &name) const
*/ */
QString VApplication::FormulaFromUser(const QString &formula) QString VApplication::FormulaFromUser(const QString &formula)
{ {
if (formula.isEmpty())
{
return formula;
}
QString newFormula = formula;// Local copy for making changes QString newFormula = formula;// Local copy for making changes
Calculator *cal = new Calculator(formula);// Eval formula Calculator *cal = new Calculator(formula);// Eval formula
@ -1901,6 +1905,11 @@ QString VApplication::FormulaFromUser(const QString &formula)
*/ */
QString VApplication::FormulaToUser(const QString &formula) QString VApplication::FormulaToUser(const QString &formula)
{ {
if (formula.isEmpty())
{
return formula;
}
QString newFormula = formula;// Local copy for making changes QString newFormula = formula;// Local copy for making changes
QMap<int, QString> tokens; QMap<int, QString> tokens;

View File

@ -31,6 +31,7 @@
#include "../../visualization/vistoolalongline.h" #include "../../visualization/vistoolalongline.h"
#include "../../tools/vabstracttool.h" #include "../../tools/vabstracttool.h"
#include "../../widgets/vmaingraphicsscene.h" #include "../../widgets/vmaingraphicsscene.h"
#include "dialogeditwrongformula.h"
#include <QPushButton> #include <QPushButton>
@ -45,7 +46,6 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
formula(QString()), formulaBaseHeight(0), line(nullptr) formula(QString()), formulaBaseHeight(0), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
@ -62,11 +62,10 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxLineColors(ui->comboBoxLineColor); FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogAlongLine::FXLength);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal);
connect(ui->comboBoxFirstPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(ui->comboBoxFirstPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogAlongLine::PointChanged); this, &DialogAlongLine::PointChanged);
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
@ -100,6 +99,19 @@ void DialogAlongLine::PointChanged()
CheckState(); CheckState();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::FXLength()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
if (dialog->exec() == QDialog::Accepted)
{
SetFormula(dialog->GetFormula());
}
delete dialog;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::ShowVisualization() void DialogAlongLine::ShowVisualization()
{ {

View File

@ -75,6 +75,8 @@ public slots:
*/ */
void FormulaTextChanged(); void FormulaTextChanged();
void PointChanged(); void PointChanged();
void FXLength();
protected: protected:
virtual void ShowVisualization(); virtual void ShowVisualization();
/** /**

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>428</width> <width>412</width>
<height>532</height> <height>284</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -87,16 +87,13 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonPutHere"> <widget class="QToolButton" name="toolButtonExprLength">
<property name="toolTip">
<string>Insert variable into the formula</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../share/resources/icon.qrc"> <iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset> <normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -165,6 +162,9 @@
<property name="tabChangesFocus"> <property name="tabChangesFocus">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="plainText">
<string notr="true"/>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -206,251 +206,98 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QFormLayout" name="formLayout">
<item> <property name="fieldGrowthPolicy">
<layout class="QVBoxLayout" name="verticalLayout_2"> <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<item> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <item row="0" column="0">
<item> <widget class="QLabel" name="labelEditNamePoint">
<layout class="QFormLayout" name="formLayout"> <property name="text">
<property name="fieldGrowthPolicy"> <string>Point label</string>
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> </property>
</property> </widget>
<item row="0" column="0">
<widget class="QLabel" name="labelEditNamePoint">
<property name="text">
<string>Point label</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelFirstPoint">
<property name="text">
<string>First point</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxFirstPoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSecondPoint">
<property name="text">
<string>Second point</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxSecondPoint">
<property name="toolTip">
<string>Second point of line</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Type of line</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxLineType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Show line from first point to this point</string>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>14</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_7">
<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>Measurements</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="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="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>
</item> </item>
<item> <item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout"> <widget class="QLabel" name="labelFirstPoint">
<item> <property name="text">
<widget class="QCheckBox" name="checkBoxHideEmpty"> <string>First point</string>
<property name="text"> </property>
<string>Hide empty measurements</string> </widget>
</property> </item>
<property name="checked"> <item row="1" column="1">
<bool>true</bool> <widget class="QComboBox" name="comboBoxFirstPoint">
</property> <property name="toolTip">
</widget> <string>First point of line</string>
</item> </property>
<item> </widget>
<widget class="QListWidget" name="listWidget"> </item>
<property name="toolTip"> <item row="2" column="0">
<string>Variables - Click twice to insert into formula</string> <widget class="QLabel" name="labelSecondPoint">
</property> <property name="text">
</widget> <string>Second point</string>
</item> </property>
</layout> </widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxSecondPoint">
<property name="toolTip">
<string>Second point of line</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Type of line</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxLineType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Show line from first point to this point</string>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>14</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
@ -465,21 +312,11 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>plainTextEditFormula</tabstop> <tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>pushButtonGrowLength</tabstop> <tabstop>pushButtonGrowLength</tabstop>
<tabstop>lineEditNamePoint</tabstop> <tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxFirstPoint</tabstop> <tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop> <tabstop>comboBoxSecondPoint</tabstop>
<tabstop>comboBoxLineType</tabstop> <tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>