60 #include <QPlainTextEdit>
62 #include <QPushButton>
65 #include <QToolButton>
69 #include "../../tools/vabstracttool.h"
70 #include "../../visualization/visualization.h"
71 #include "../../visualization/path/vistoolspline.h"
72 #include "../ifc/xml/vdomdocument.h"
73 #include "../support/edit_formula_dialog.h"
74 #include "../vgeometry/vpointf.h"
75 #include "../vgeometry/vspline.h"
76 #include "../vmisc/vabstractapplication.h"
77 #include "../vmisc/vcommonsettings.h"
78 #include "../vpatterndb/vcontainer.h"
79 #include "../vwidgets/vmaingraphicsscene.h"
80 #include "ui_dialogspline.h"
94 , formulaBaseHeightAngle1(0)
95 , formulaBaseHeightAngle2(0)
96 , formulaBaseHeightLength1(0)
97 , formulaBaseHeightLength2(0)
98 , timerAngle1(new QTimer(this))
99 , timerAngle2(new QTimer(this))
100 , timerLength1(new QTimer(this))
101 , timerLength2(new QTimer(this))
108 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
109 setWindowIcon(QIcon(
":/toolicon/32x32/spline.png"));
118 ui->plainTextEditAngle1F->installEventFilter(
this);
119 ui->plainTextEditAngle2F->installEventFilter(
this);
120 ui->plainTextEditLength1F->installEventFilter(
this);
121 ui->plainTextEditLength2F->installEventFilter(
this);
136 ui->lineType_ComboBox->removeItem(index);
139 index =
ui->lineColor_ComboBox->findData(
qApp->getCurrentDocument()->getDefaultLineColor());
142 ui->lineColor_ComboBox->setCurrentIndex(index);
145 index =
ui->lineWeight_ComboBox->findData(
qApp->getCurrentDocument()->getDefaultLineWeight());
148 ui->lineWeight_ComboBox->setCurrentIndex(index);
151 index =
ui->lineType_ComboBox->findData(
qApp->getCurrentDocument()->getDefaultLineType());
154 ui->lineType_ComboBox->setCurrentIndex(index);
178 auto path = qobject_cast<VisToolSpline *>(
vis);
181 auto scene = qobject_cast<VMainGraphicsScene *>(
qApp->getCurrentScene());
205 auto *path = qobject_cast<VisToolSpline *>(
vis);
211 if (
SetObject(
id,
ui->comboBoxP1, tr(
"Select last point of curve")))
214 path->VisualMode(
id);
225 path->setObject4Id(
id);
226 path->RefreshGeometry();
247 auto path = qobject_cast<VisToolSpline *>(
vis);
250 path->setObject1Id(
GetP1()->
id());
251 path->setObject4Id(
GetP4()->
id());
258 path->RefreshGeometry();
264 ui->plainTextEditAngle1F->blockSignals(
true);
265 ui->plainTextEditAngle2F->blockSignals(
true);
266 ui->plainTextEditLength1F->blockSignals(
true);
267 ui->plainTextEditLength2F->blockSignals(
true);
333 dialog->setWindowTitle(tr(
"Edit first control point angle"));
334 QString angle1F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditAngle1F->toPlainText(),
335 qApp->Settings()->GetOsSeparator());
336 dialog->SetFormula(angle1F);
338 if (dialog->exec() == QDialog::Accepted)
340 angle1F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
342 if (angle1F.length() > 80)
346 ui->plainTextEditAngle1F->setPlainText(angle1F);
356 dialog->setWindowTitle(tr(
"Edit second control point angle"));
357 QString angle2F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditAngle2F->toPlainText(),
358 qApp->Settings()->GetOsSeparator());
359 dialog->SetFormula(angle2F);
361 if (dialog->exec() == QDialog::Accepted)
363 angle2F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
365 if (angle2F.length() > 80)
369 ui->plainTextEditAngle2F->setPlainText(angle2F);
379 dialog->setWindowTitle(tr(
"Edit first control point length"));
380 QString length1F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditLength1F->toPlainText(),
381 qApp->Settings()->GetOsSeparator());
382 dialog->SetFormula(length1F);
384 if (dialog->exec() == QDialog::Accepted)
386 length1F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
388 if (length1F.length() > 80)
392 ui->plainTextEditLength1F->setPlainText(length1F);
402 dialog->setWindowTitle(tr(
"Edit second control point length"));
403 QString length2F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditLength2F->toPlainText(),
404 qApp->Settings()->GetOsSeparator());
405 dialog->SetFormula(length2F);
407 if (dialog->exec() == QDialog::Accepted)
409 length2F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
411 if (length2F.length() > 80)
415 ui->plainTextEditLength2F->setPlainText(length2F);
452 const qreal length1 =
Eval(
ui->plainTextEditLength1F->toPlainText(),
flagLength1,
ui->labelResultLength1, postfix,
459 ui->labelResultLength1->setText(tr(
"Error") +
" (" + postfix +
")");
460 ui->labelResultLength1->setToolTip(tr(
"Length can't be negative"));
471 const qreal length2 =
Eval(
ui->plainTextEditLength2F->toPlainText(),
flagLength2,
ui->labelResultLength2, postfix,
478 ui->labelResultLength2->setText(tr(
"Error") +
" (" + postfix +
")");
479 ui->labelResultLength2->setToolTip(tr(
"Length can't be negative"));
488 QString angle1F =
ui->plainTextEditAngle1F->toPlainText();
489 angle1F.replace(
"\n",
" ");
491 QString angle2F =
ui->plainTextEditAngle2F->toPlainText();
492 angle2F.replace(
"\n",
" ");
494 QString length1F =
ui->plainTextEditLength1F->toPlainText();
495 length1F.replace(
"\n",
" ");
497 QString length2F =
ui->plainTextEditLength2F->toPlainText();
498 length2F.replace(
"\n",
" ");
507 const bool separator =
qApp->Settings()->GetOsSeparator();
509 angle1F =
qApp->TrVars()->TryFormulaFromUser(angle1F, separator);
510 angle2F =
qApp->TrVars()->TryFormulaFromUser(angle2F, separator);
511 length1F =
qApp->TrVars()->TryFormulaFromUser(length1F, separator);
512 length2F =
qApp->TrVars()->TryFormulaFromUser(length2F, separator);
514 VSpline spline(*
GetP1(), *
GetP4(), angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F);
532 ui->lineEditSplineName->setText(tr(
"Invalid spline"));
543 ui->lineEditSplineName->setText(
qApp->TrVars()->VarToUser(
spl.
name()));
555 ui->lineEditSplineName->setText(
qApp->TrVars()->VarToUser(spline.
name()));
569 auto *path = qobject_cast<VisToolSpline *>(
vis);
575 qApp->Settings()->GetOsSeparator());
577 qApp->Settings()->GetOsSeparator());
579 ui->plainTextEditAngle1F->setPlainText(angle1F);
580 ui->plainTextEditAngle2F->setPlainText(angle2F);
582 qApp->Settings()->GetOsSeparator()));
584 qApp->Settings()->GetOsSeparator()));
591 ui->lineEditSplineName->setText(
qApp->TrVars()->VarToUser(
spl.
name()));
612 AddVisualization<VisToolSpline>();
630 qApp->Settings()->GetOsSeparator());
632 qApp->Settings()->GetOsSeparator());
634 ui->plainTextEditAngle1F->setPlainText(angle1F);
635 ui->plainTextEditAngle2F->setPlainText(angle2F);
638 qApp->Settings()->GetOsSeparator());
640 qApp->Settings()->GetOsSeparator());
642 ui->plainTextEditLength1F->setPlainText(length1F);
643 ui->plainTextEditLength2F->setPlainText(length2F);
644 ui->lineEditSplineName->setText(
qApp->TrVars()->VarToUser(
spl.
name()));
646 auto path = qobject_cast<VisToolSpline *>(
vis);
700 vis->setLineWeight(value);
The DialogSpline class dialog for ToolSpline. Help create spline and edit option.
virtual void ShowVisualization() Q_DECL_OVERRIDE
void setPenStyle(const QString &value)
int formulaBaseHeightAngle1
formulaBaseHeight base height defined by dialogui
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent=nullptr)
DialogSpline create dialog.
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
virtual ~DialogSpline() Q_DECL_OVERRIDE
void DeployAngle2TextEdit()
const QSharedPointer< VPointF > GetP4() const
qint32 newDuplicate
spl spline
virtual void CheckState() Q_DECL_FINAL
CheckState enable, when all is correct, or disable, when something wrong, button ok.
bool flagAngle1
flagAngle1 true if value of first angle is correct
QString getLineWeight() const
getLineWeight return weight of the lines
VSpline CurrentSpline() const
QString getLineColor() const
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE
void setLineColor(const QString &value)
void SetSpline(const VSpline &spline)
QTimer * timerAngle1
timerAngle1 timer of check first angle formula
VSpline GetSpline() const
void setLineWeight(const QString &value)
setLineWeight set weight of the lines
const QSharedPointer< VPointF > GetP1() const
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE
ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
int formulaBaseHeightAngle2
virtual void SaveData() Q_DECL_OVERRIDE
SaveData Put dialog data in local variables.
virtual void PointNameChanged() Q_DECL_OVERRIDE
QString getPenStyle() const
void DeployAngle1TextEdit()
VSpline spl
ui keeps information about user interface
void DeployLength1TextEdit()
int formulaBaseHeightLength1
int formulaBaseHeightLength2
void DeployLength2TextEdit()
void SetDuplicate(quint32 number)
quint32 GetDuplicate() const
The VContainer class container of all variables.
static bool IsUnique(const QString &name)
const QHash< QString, QSharedPointer< VInternalVariable > > * DataVariables() const
const QSharedPointer< T > GeometricObject(const quint32 &id) const
virtual QString name() const
name return name graphical object.
quint32 id() const
id return id object.
The VPointF class keep data of point.
VSpline class that implements the spline.
virtual VPointF GetP4() const Q_DECL_OVERRIDE
GetP4 return last spline point.
QString GetC1LengthFormula() const
qreal GetKcurve() const
GetKcurve return coefficient of curvature spline.
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
GetAngle1 return first angle control line.
virtual VPointF GetP1() const Q_DECL_OVERRIDE
GetP1 return first spline point.
QString GetStartAngleFormula() const
QString GetEndAngleFormula() const
qreal GetKasm1() const
GetKasm1 return coefficient of length first control line.
QString GetC2LengthFormula() const
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
GetAngle2 return second angle control line.
qreal GetKasm2() const
GetKasm2 return coefficient of length second control line.
static qreal FindLength(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
static qreal FindVal(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
const QString degreeSymbol
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
const QString LineTypeSolidLine
const QString LineTypeNone