57 #include <QDialogButtonBox>
60 #include <QLatin1String>
62 #include <QListWidget>
63 #include <QListWidgetItem>
64 #include <QPlainTextEdit>
66 #include <QPushButton>
67 #include <QSharedPointer>
68 #include <QToolButton>
73 #include "../../tools/vabstracttool.h"
74 #include "../../visualization/visualization.h"
75 #include "../../visualization/path/vistoolsplinepath.h"
76 #include "../ifc/xml/vdomdocument.h"
77 #include "../qmuparser/qmuparsererror.h"
78 #include "../support/edit_formula_dialog.h"
79 #include "../vgeometry/../ifc/ifcdef.h"
80 #include "../vgeometry/vpointf.h"
81 #include "../vgeometry/vsplinepoint.h"
82 #include "../vmisc/vabstractapplication.h"
83 #include "../vmisc/vcommonsettings.h"
84 #include "../vpatterndb/vcontainer.h"
85 #include "../vwidgets/vabstractmainwindow.h"
86 #include "../vwidgets/vmaingraphicsscene.h"
87 #include "ui_dialogsplinepath.h"
101 , formulaBaseHeightAngle1(0)
102 , formulaBaseHeightAngle2(0)
103 , formulaBaseHeightLength1(0)
104 , formulaBaseHeightLength2(0)
111 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
112 setWindowIcon(QIcon(
":/toolicon/32x32/splinePath.png"));
121 ui->plainTextEditAngle1F->installEventFilter(
this);
122 ui->plainTextEditAngle2F->installEventFilter(
this);
123 ui->plainTextEditLength1F->installEventFilter(
this);
124 ui->plainTextEditLength2F->installEventFilter(
this);
134 ui->lineType_ComboBox->removeItem(index);
137 index =
ui->lineColor_ComboBox->findData(
qApp->getCurrentDocument()->getDefaultLineColor());
140 ui->lineColor_ComboBox->setCurrentIndex(index);
143 index =
ui->lineWeight_ComboBox->findData(
qApp->getCurrentDocument()->getDefaultLineWeight());
146 ui->lineWeight_ComboBox->setCurrentIndex(index);
149 index =
ui->lineType_ComboBox->findData(
qApp->getCurrentDocument()->getDefaultLineType());
152 ui->lineType_ComboBox->setCurrentIndex(index);
156 connect(
ui->comboBoxPoint,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
175 auto path = qobject_cast<VisToolSplinePath *>(
vis);
178 auto scene = qobject_cast<VMainGraphicsScene *>(
qApp->getCurrentScene());
203 ui->listWidget->blockSignals(
true);
204 ui->listWidget->clear();
209 ui->listWidget->setFocus(Qt::OtherFocusReason);
210 ui->lineEditSplPathName->setText(
qApp->TrVars()->VarToUser(
path.
name()));
212 auto visPath = qobject_cast<VisToolSplinePath *>(
vis);
214 visPath->setPath(
path);
215 ui->listWidget->blockSignals(
false);
272 if (
AllIds().contains(
id))
281 emit
ToolTip(tr(
"Select point of curve path"));
285 auto visPath = qobject_cast<VisToolSplinePath *>(
vis);
287 visPath->setPath(
path);
300 visPath->RefreshGeometry();
315 auto visPath = qobject_cast<VisToolSplinePath *>(
vis);
317 visPath->setPath(
path);
319 visPath->RefreshGeometry();
327 bool fAngle1 =
true, fAngle2 =
true, fLength1 =
true, fLength2 =
true;
329 for (qint32 i = 0; i <
ui->listWidget->count(); ++i)
348 ui->plainTextEditAngle1F->blockSignals(
true);
349 ui->plainTextEditAngle2F->blockSignals(
true);
350 ui->plainTextEditLength1F->blockSignals(
true);
351 ui->plainTextEditLength2F->blockSignals(
true);
394 const int row =
ui->listWidget->currentRow();
402 QListWidgetItem *item =
ui->listWidget->item(row);
404 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
406 const QString angle1F =
ui->plainTextEditAngle1F->toPlainText().replace(
"\n",
" ");
411 p.
SetAngle1(angle1,
qApp->TrVars()->FormulaFromUser(angle1F,
qApp->Settings()->GetOsSeparator()));
419 item->setData(Qt::UserRole, QVariant::fromValue(p));
423 if (row !=
ui->listWidget->count()-1)
425 ui->plainTextEditAngle2F->blockSignals(
true);
427 qApp->Settings()->GetOsSeparator()));
429 ui->plainTextEditAngle2F->blockSignals(
false);
437 const int row =
ui->listWidget->currentRow();
443 if (row !=
ui->listWidget->count()-1)
445 QListWidgetItem *item =
ui->listWidget->item(row);
447 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
449 const QString angle2F =
ui->plainTextEditAngle2F->toPlainText().replace(
"\n",
" ");
454 p.
SetAngle2(angle2,
qApp->TrVars()->FormulaFromUser(angle2F,
qApp->Settings()->GetOsSeparator()));
462 item->setData(Qt::UserRole, QVariant::fromValue(p));
468 ui->plainTextEditAngle1F->blockSignals(
true);
470 qApp->Settings()->GetOsSeparator()));
472 ui->plainTextEditAngle1F->blockSignals(
false);
480 const int row =
ui->listWidget->currentRow();
488 QListWidgetItem *item =
ui->listWidget->item(row);
490 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
492 const QString length1F =
ui->plainTextEditLength1F->toPlainText().replace(
"\n",
" ");
497 p.
SetLength1(length1,
qApp->TrVars()->FormulaFromUser(length1F,
qApp->Settings()->GetOsSeparator()));
505 item->setData(Qt::UserRole, QVariant::fromValue(p));
514 const int row =
ui->listWidget->currentRow();
520 if (row !=
ui->listWidget->count()-1)
522 QListWidgetItem *item =
ui->listWidget->item(row);
524 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
526 const QString length2F =
ui->plainTextEditLength2F->toPlainText().replace(
"\n",
" ");
531 p.
SetLength2(length2,
qApp->TrVars()->FormulaFromUser(length2F,
qApp->Settings()->GetOsSeparator()));
539 item->setData(Qt::UserRole, QVariant::fromValue(p));
549 dialog->setWindowTitle(tr(
"Edit first control point angle"));
551 QString angle1F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditAngle1F->toPlainText().replace(
"\n",
" "),
552 qApp->Settings()->GetOsSeparator());
554 dialog->SetFormula(angle1F);
556 if (dialog->exec() == QDialog::Accepted)
558 angle1F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
560 if (angle1F.length() > 80)
564 ui->plainTextEditAngle1F->setPlainText(angle1F);
574 dialog->setWindowTitle(tr(
"Edit second control point angle"));
576 QString angle2F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditAngle2F->toPlainText().replace(
"\n",
" "),
577 qApp->Settings()->GetOsSeparator());
579 dialog->SetFormula(angle2F);
581 if (dialog->exec() == QDialog::Accepted)
583 angle2F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
585 if (angle2F.length() > 80)
589 ui->plainTextEditAngle2F->setPlainText(angle2F);
599 dialog->setWindowTitle(tr(
"Edit first control point length"));
601 QString length1F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditLength1F->toPlainText().replace(
"\n",
" "),
602 qApp->Settings()->GetOsSeparator());
604 dialog->SetFormula(length1F);
606 if (dialog->exec() == QDialog::Accepted)
608 length1F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
610 if (length1F.length() > 80)
614 ui->plainTextEditLength1F->setPlainText(length1F);
624 dialog->setWindowTitle(tr(
"Edit second control point length"));
626 QString length2F =
qApp->TrVars()->TryFormulaFromUser(
ui->plainTextEditLength2F->toPlainText().replace(
"\n",
" "),
627 qApp->Settings()->GetOsSeparator());
629 dialog->SetFormula(length2F);
631 if (dialog->exec() == QDialog::Accepted)
633 length2F =
qApp->TrVars()->FormulaToUser(dialog->GetFormula(),
qApp->Settings()->GetOsSeparator());
635 if (length2F.length() > 80)
639 ui->plainTextEditLength2F->setPlainText(length2F);
648 const int row =
ui->listWidget->currentRow();
657 QListWidgetItem *item =
ui->listWidget->item(row);
659 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
667 const int row =
ui->listWidget->currentRow();
676 QListWidgetItem *item =
ui->listWidget->item(row);
678 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
686 const int row =
ui->listWidget->currentRow();
694 const qreal length1 =
Eval(
ui->plainTextEditLength1F->toPlainText(),
flagLength1[row],
ui->labelResultLength1,
701 ui->labelResultLength1->setText(tr(
"Error") + QLatin1String(
" (") + postfix + QLatin1String(
")"));
702 ui->labelResultLength1->setToolTip(tr(
"Length can't be negative"));
707 QListWidgetItem *item =
ui->listWidget->item(row);
709 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
717 const int row =
ui->listWidget->currentRow();
725 const qreal length2 =
Eval(
ui->plainTextEditLength2F->toPlainText(),
flagLength2[row],
ui->labelResultLength2,
732 ui->labelResultLength2->setText(tr(
"Error") + QLatin1String(
" (") + postfix + QLatin1String(
")"));
733 ui->labelResultLength2->setToolTip(tr(
"Length can't be negative"));
738 QListWidgetItem *item =
ui->listWidget->item(row);
740 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
752 if (
ui->listWidget->count() == 0)
757 const auto p = qvariant_cast<VSplinePoint>(
ui->listWidget->item(row)->data(Qt::UserRole));
768 const quint32
id = qvariant_cast<quint32>(
ui->comboBoxPoint->itemData(index));
769 QListWidgetItem *item =
ui->listWidget->item(
ui->listWidget->currentRow() );
770 VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
774 item->setData(Qt::UserRole, QVariant::fromValue(p));
783 ui->lineEditSplPathName->setText(tr(
"Invalid spline path"));
790 auto first = qvariant_cast<VSplinePoint>(
ui->listWidget->item(0)->data(Qt::UserRole));
791 auto last = qvariant_cast<VSplinePoint>(
ui->listWidget->item(
ui->listWidget->count()-1)->data(Qt::UserRole));
796 ui->lineEditSplPathName->setText(
qApp->TrVars()->VarToUser(
path.
name()));
808 ui->lineEditSplPathName->setText(
qApp->TrVars()->VarToUser(newPath.
name()));
844 AddVisualization<VisToolSplinePath>();
859 auto item =
new QListWidgetItem(point.
P().
name());
860 item->setData(Qt::UserRole, QVariant::fromValue(point));
862 ui->listWidget->addItem(item);
863 ui->listWidget->setCurrentItem(item);
864 if (
ui->listWidget->count() >= 2)
866 ok_Button =
ui->buttonBox->button(QDialogButtonBox::Ok);
880 ui->comboBoxPoint->blockSignals(
true);
882 ui->comboBoxPoint->blockSignals(
false);
884 int row =
ui->listWidget->currentRow();
885 const QString notUsed = tr(
"Not used");
886 const QString result = tr(
"Result value");
887 const QString emptyResult = QString(
"NA");
891 ui->toolButtonExprAngle1->setEnabled(
false);
892 ui->labelResultAngle1->setText(emptyResult);
893 ui->labelResultAngle1->setToolTip(result);
895 ui->plainTextEditAngle1F->blockSignals(
true);
896 ui->plainTextEditAngle1F->setPlainText(notUsed);
897 ui->plainTextEditAngle1F->setEnabled(
false);
898 ui->pushButtonGrowAngle1->setEnabled(
false);
899 ui->plainTextEditAngle1F->blockSignals(
false);
901 ui->toolButtonExprLength1->setEnabled(
false);
902 ui->labelResultLength1->setText(emptyResult);
903 ui->labelResultLength1->setToolTip(result);
905 ui->plainTextEditLength1F->blockSignals(
true);
906 ui->plainTextEditLength1F->setPlainText(notUsed);
907 ui->plainTextEditLength1F->setEnabled(
false);
908 ui->pushButtonGrowLength1->setEnabled(
false);
909 ui->plainTextEditLength1F->blockSignals(
false);
911 ui->plainTextEditAngle2F->setEnabled(
true);
912 ui->plainTextEditLength2F->setEnabled(
true);
914 ui->toolButtonExprAngle2->setEnabled(
true);
915 ui->toolButtonExprLength2->setEnabled(
true);
917 ui->plainTextEditAngle2F->blockSignals(
true);
918 ui->plainTextEditLength2F->blockSignals(
true);
920 qApp->Settings()->GetOsSeparator()));
923 qApp->Settings()->GetOsSeparator()));
925 ui->plainTextEditAngle2F->blockSignals(
false);
926 ui->plainTextEditLength2F->blockSignals(
false);
928 else if (row ==
ui->listWidget->count()-1)
930 ui->toolButtonExprAngle2->setEnabled(
false);
931 ui->labelResultAngle2->setText(emptyResult);
932 ui->labelResultAngle2->setToolTip(result);
934 ui->plainTextEditAngle2F->blockSignals(
true);
935 ui->plainTextEditAngle2F->setPlainText(notUsed);
936 ui->plainTextEditAngle2F->setEnabled(
false);
937 ui->pushButtonGrowAngle2->setEnabled(
false);
938 ui->plainTextEditAngle2F->blockSignals(
false);
940 ui->toolButtonExprLength2->setEnabled(
false);
941 ui->labelResultLength2->setText(emptyResult);
942 ui->labelResultLength2->setToolTip(result);
944 ui->plainTextEditLength2F->blockSignals(
true);
945 ui->plainTextEditLength2F->setPlainText(notUsed);
946 ui->plainTextEditLength2F->setEnabled(
false);
947 ui->pushButtonGrowLength2->setEnabled(
false);
948 ui->plainTextEditLength2F->blockSignals(
false);
950 ui->plainTextEditAngle1F->setEnabled(
true);
951 ui->plainTextEditLength1F->setEnabled(
true);
953 ui->toolButtonExprAngle1->setEnabled(
true);
954 ui->toolButtonExprLength1->setEnabled(
true);
956 ui->plainTextEditAngle1F->blockSignals(
true);
957 ui->plainTextEditLength1F->blockSignals(
true);
959 qApp->Settings()->GetOsSeparator()));
962 qApp->Settings()->GetOsSeparator()));
964 ui->plainTextEditAngle1F->blockSignals(
false);
965 ui->plainTextEditLength1F->blockSignals(
false);
969 ui->pushButtonGrowAngle1->setEnabled(
true);
970 ui->pushButtonGrowAngle2->setEnabled(
true);
971 ui->pushButtonGrowLength1->setEnabled(
true);
972 ui->pushButtonGrowLength2->setEnabled(
true);
974 ui->toolButtonExprAngle1->setEnabled(
true);
975 ui->toolButtonExprLength1->setEnabled(
true);
976 ui->toolButtonExprAngle2->setEnabled(
true);
977 ui->toolButtonExprLength2->setEnabled(
true);
979 ui->plainTextEditAngle1F->setEnabled(
true);
980 ui->plainTextEditLength1F->setEnabled(
true);
981 ui->plainTextEditAngle2F->setEnabled(
true);
982 ui->plainTextEditLength2F->setEnabled(
true);
984 ui->plainTextEditAngle1F->blockSignals(
true);
985 ui->plainTextEditLength1F->blockSignals(
true);
986 ui->plainTextEditAngle2F->blockSignals(
true);
987 ui->plainTextEditLength2F->blockSignals(
true);
990 qApp->Settings()->GetOsSeparator()));
992 qApp->Settings()->GetOsSeparator()));
994 qApp->Settings()->GetOsSeparator()));
996 qApp->Settings()->GetOsSeparator()));
1003 ui->plainTextEditAngle1F->blockSignals(
false);
1004 ui->plainTextEditLength1F->blockSignals(
false);
1005 ui->plainTextEditAngle2F->blockSignals(
false);
1006 ui->plainTextEditLength2F->blockSignals(
false);
1021 for (qint32 i = 0; i <
ui->listWidget->count(); ++i)
1023 ids.insert(qvariant_cast<VSplinePoint>(
ui->listWidget->item(i)->data(Qt::UserRole)).P().id());
1044 for (qint32 i = 0; i <
ui->listWidget->count(); ++i)
1046 points.append(qvariant_cast<VSplinePoint>(
ui->listWidget->item(i)->data(Qt::UserRole)));
1054 const int row =
ui->listWidget->currentRow();
1060 QListWidgetItem *item =
ui->listWidget->item(row);
1065 item->setText(pName);
1069 item->setText(pName + QLatin1String(
"(!)"));
1079 const QTextCursor cursor = textEdit->textCursor();
1081 setMaximumWidth(260);
1082 textEdit->setFixedHeight(height);
1083 pushButton->setIcon(QIcon::fromTheme(
"go-down", QIcon(
":/icons/win.icon.theme/16x16/actions/go-down.png")));
1084 setUpdatesEnabled(
false);
1086 setUpdatesEnabled(
true);
1087 textEdit->setFocus();
1088 textEdit->setTextCursor(cursor);
The DialogSplinePath class dialog for ToolSplinePath. Help create spline path and edit option.
QVector< bool > flagAngle2
QSet< quint32 > AllIds() const
int formulaBaseHeightLength2
QVector< bool > flagLength2
void DeployAngle1TextEdit()
QVector< bool > flagAngle1
flagAngle1 true if value of first angle is correct
QString getPenStyle() const
virtual ~DialogSplinePath() Q_DECL_OVERRIDE
QVector< bool > flagLength1
Ui::DialogSplinePath * ui
ui keeps information about user interface
virtual void SaveData() Q_DECL_OVERRIDE
SaveData Put dialog data in local variables.
virtual void CheckState() Q_DECL_FINAL
CheckState enable, when all is correct, or disable, when something wrong, button ok.
void PointChanged(int row)
PointChanged selected another point in list.
void SetPath(const VSplinePath &value)
SetPath set spline path.
void NewItem(const VSplinePoint &point)
NewItem add point to list.
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
void collapseFormula(QPlainTextEdit *textEdit, QPushButton *pushButton, int height)
void setPenStyle(const QString &value)
DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent=nullptr)
DialogSplinePath create dialog.
void setLineColor(const QString &value)
QString getLineColor() 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 formulaBaseHeightAngle1
formulaBaseHeight base height defined by dialogui
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE
void DeployLength1TextEdit()
void setLineWeight(const QString &value)
setLineWeight set weight of the lines
virtual void ShowVisualization() Q_DECL_OVERRIDE
void currentPointChanged(int index)
currentPointChanged changed point in combo box
int formulaBaseHeightAngle2
void PathUpdated(const VSplinePath &path)
void ShowPointIssue(const QString &pName)
void DeployLength2TextEdit()
void DeployAngle2TextEdit()
QString getLineWeight() const
getLineWeight return weight of the lines
int formulaBaseHeightLength1
void DataPoint(const VSplinePoint &p)
dataPoint show data of point in fields
VSplinePath path
path spline path
VSplinePath ExtractPath() const
void SetDuplicate(quint32 number)
quint32 GetDuplicate() const
virtual void ShowToolTip(const QString &toolTip)=0
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.
The VSplinePath class keep information about splinePath.
const VSplinePoint & at(int indx) const
at return spline point by index.
virtual qint32 CountPoints() const Q_DECL_OVERRIDE
CountPoints return count of points.
virtual void Clear() Q_DECL_OVERRIDE
Clear clear list of points.
The VSplinePoint class keep information about point in spline path. Each point have two angles and tw...
QString Length1Formula() const
void SetAngle1(const qreal &value, const QString &angle1F)
QString Angle2Formula() const
void SetP(const VPointF &value)
void SetLength1(const qreal &value, const QString &length1F)
QString Length2Formula() const
QString Angle1Formula() const
void SetLength2(const qreal &value, const QString &length2F)
void SetAngle2(const qreal &value, const QString &angle2F)
void ToolTip(const QString &toolTip)
static qreal FindLength(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
static qreal FindVal(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
Error class of the parser.
const QString degreeSymbol
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
const QString LineTypeSolidLine
const QString LineTypeNone