Alias support for tools Point of intersection curve and axis and Point of intersection curves.
This commit is contained in:
parent
b89be44a88
commit
6bfc5065bd
|
@ -11,6 +11,7 @@
|
|||
- Fix correct handle a final measurement formula error when exporting a pattern recipe.
|
||||
- Fix regression. Incorrect data caching.
|
||||
- Improve tool tooltip. Show segment names and aliases.
|
||||
- Alias support for tools Point of intersection curve and axis and Point of intersection curves.
|
||||
|
||||
# Version 0.7.46 Mar 31, 2021
|
||||
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
||||
|
|
|
@ -2282,6 +2282,8 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen
|
|||
initData.curveId = GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
|
||||
initData.formulaAngle = GetParametrString(domElement, AttrAngle, QStringLiteral("0.0"));
|
||||
const QString angleFix = initData.formulaAngle;
|
||||
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
|
||||
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
|
||||
|
||||
VToolCurveIntersectAxis::Create(initData);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
@ -2403,6 +2405,10 @@ void VPattern::ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDo
|
|||
initData.secondCurveId = GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR);
|
||||
initData.vCrossPoint = static_cast<VCrossCurvesPoint>(GetParametrUInt(domElement, AttrVCrossPoint, QChar('1')));
|
||||
initData.hCrossPoint = static_cast<HCrossCurvesPoint>(GetParametrUInt(domElement, AttrHCrossPoint, QChar('1')));
|
||||
initData.curve1AliasSuffix1 = GetParametrEmptyString(domElement, AttrCurve1Alias1);
|
||||
initData.curve1AliasSuffix2 = GetParametrEmptyString(domElement, AttrCurve1Alias2);
|
||||
initData.curve2AliasSuffix1 = GetParametrEmptyString(domElement, AttrCurve2Alias1);
|
||||
initData.curve2AliasSuffix2 = GetParametrEmptyString(domElement, AttrCurve2Alias2);
|
||||
|
||||
VToolPointOfIntersectionCurves::Create(initData);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,10 @@ const QString AttrNotes = QStringLiteral("notes");
|
|||
const QString AttrAlias = QStringLiteral("alias");
|
||||
const QString AttrAlias1 = QStringLiteral("alias1");
|
||||
const QString AttrAlias2 = QStringLiteral("alias2");
|
||||
const QString AttrCurve1Alias1 = QStringLiteral("curve1Alias1");
|
||||
const QString AttrCurve1Alias2 = QStringLiteral("curve1Alias2");
|
||||
const QString AttrCurve2Alias1 = QStringLiteral("curve2Alias1");
|
||||
const QString AttrCurve2Alias2 = QStringLiteral("curve2Alias2");
|
||||
|
||||
const QString TypeLineDefault = QStringLiteral("default");
|
||||
const QString TypeLineNone = QStringLiteral("none");
|
||||
|
|
|
@ -155,6 +155,10 @@ extern const QString AttrNotes;
|
|||
extern const QString AttrAlias;
|
||||
extern const QString AttrAlias1;
|
||||
extern const QString AttrAlias2;
|
||||
extern const QString AttrCurve1Alias1;
|
||||
extern const QString AttrCurve1Alias2;
|
||||
extern const QString AttrCurve2Alias1;
|
||||
extern const QString AttrCurve2Alias2;
|
||||
|
||||
extern const QString TypeLineDefault;
|
||||
extern const QString TypeLineNone;
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
<file>schema/pattern/v0.8.8.xsd</file>
|
||||
<file>schema/pattern/v0.8.9.xsd</file>
|
||||
<file>schema/pattern/v0.8.10.xsd</file>
|
||||
<file>schema/pattern/v0.8.11.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.4.1.xsd</file>
|
||||
|
|
1126
src/libs/ifc/schema/pattern/v0.8.11.xsd
Normal file
1126
src/libs/ifc/schema/pattern/v0.8.11.xsd
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -59,8 +59,8 @@ class QDomElement;
|
|||
*/
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.10");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.10.xsd");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.11");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.11.xsd");
|
||||
|
||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -240,7 +240,8 @@ QString VPatternConverter::XSDSchema(int ver) const
|
|||
std::make_pair(FORMAT_VERSION(0, 8, 7), QStringLiteral("://schema/pattern/v0.8.7.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 8, 8), QStringLiteral("://schema/pattern/v0.8.8.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 8, 9), QStringLiteral("://schema/pattern/v0.8.9.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 8, 10), CurrentSchema)
|
||||
std::make_pair(FORMAT_VERSION(0, 8, 10), QStringLiteral("://schema/pattern/v0.8.10.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 8, 11), CurrentSchema)
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
|
@ -501,6 +502,10 @@ void VPatternConverter::ApplyPatches()
|
|||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 10)));
|
||||
Q_FALLTHROUGH();
|
||||
case (FORMAT_VERSION(0, 8, 10)):
|
||||
ToV0_8_11();
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 11)));
|
||||
Q_FALLTHROUGH();
|
||||
case (FORMAT_VERSION(0, 8, 11)):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -518,7 +523,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VPatternConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute readOnly was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 10),
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 11),
|
||||
"Check attribute readOnly.");
|
||||
|
||||
// Possibly in future attribute readOnly will change position etc.
|
||||
|
@ -1189,6 +1194,16 @@ void VPatternConverter::ToV0_8_10()
|
|||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ToV0_8_11()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.8.11
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 11),
|
||||
"Time to refactor the code.");
|
||||
SetVersion(QStringLiteral("0.8.11"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnitToV0_2_0()
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 10);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 11);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const override;
|
||||
|
@ -133,6 +133,7 @@ private:
|
|||
void ToV0_8_8();
|
||||
void ToV0_8_9();
|
||||
void ToV0_8_10();
|
||||
void ToV0_8_11();
|
||||
|
||||
void TagUnitToV0_2_0();
|
||||
void TagIncrementToV0_2_0();
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
#include "../vpatterndb/variables/vcurvelength.h"
|
||||
#include "../ifc/exception/vexceptionbadid.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vgeometry/vellipticalarc.h"
|
||||
#include "../vgeometry/varc.h"
|
||||
#include "../vgeometry/vcubicbezier.h"
|
||||
#include "../vgeometry/vcubicbezierpath.h"
|
||||
#include "../vgeometry/vspline.h"
|
||||
#include "../vgeometry/vsplinepath.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
|
@ -106,7 +112,20 @@ bool DoubleCurve(const VPieceNode &firstNode, const VPieceNode &secondNode)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
auto CurveAliases(const QString &alias1, const QString &alias2) -> QPair<QString, QString>
|
||||
{
|
||||
T curve1;
|
||||
curve1.SetAliasSuffix(alias1);
|
||||
|
||||
T curve2;
|
||||
curve2.SetAliasSuffix(alias2);
|
||||
|
||||
return qMakePair(curve1.GetAlias(), curve2.GetAlias());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPieceNode RowNode(QListWidget *listWidget, int i)
|
||||
|
@ -527,3 +546,33 @@ QIcon LineColor(int size, const QString &color)
|
|||
pix.fill(QColor(color));
|
||||
return QIcon(pix);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
auto SegmentAliases(GOType curveType, const QString &alias1, const QString &alias2) -> QPair<QString, QString>
|
||||
{
|
||||
switch(curveType)
|
||||
{
|
||||
case GOType::EllipticalArc:
|
||||
return CurveAliases<VEllipticalArc>(alias1, alias2);
|
||||
case GOType::Arc:
|
||||
return CurveAliases<VArc>(alias1, alias2);
|
||||
case GOType::CubicBezier:
|
||||
return CurveAliases<VCubicBezier>(alias1, alias2);
|
||||
case GOType::Spline:
|
||||
return CurveAliases<VSpline>(alias1, alias2);
|
||||
case GOType::CubicBezierPath:
|
||||
return CurveAliases<VCubicBezierPath>(alias1, alias2);
|
||||
case GOType::SplinePath:
|
||||
return CurveAliases<VSplinePath>(alias1, alias2);
|
||||
case GOType::Point:
|
||||
case GOType::PlaceLabel:
|
||||
case GOType::Unknown:
|
||||
Q_UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "../vpatterndb/variables/vinternalvariable.h"
|
||||
#include "../vmisc/typedef.h"
|
||||
#include "../vgeometry/vgeometrydef.h"
|
||||
|
||||
class QPlainTextEdit;
|
||||
class QPushButton;
|
||||
|
@ -88,5 +89,6 @@ QFont NodeFont(QFont font, bool nodeExcluded = false);
|
|||
void CurrentCurveLength(vidtype curveId, VContainer *data);
|
||||
void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar=4);
|
||||
QIcon LineColor(int size, const QString &color);
|
||||
auto SegmentAliases(GOType curveType, const QString &alias1, const QString &alias2) -> QPair<QString, QString>;
|
||||
|
||||
#endif // DIALOGTOOLBOX_H
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#include "../support/dialogeditwrongformula.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
#include "../dialogtoolbox.h"
|
||||
#include "ui_dialogcurveintersectaxis.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -95,6 +97,8 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, quint
|
|||
});
|
||||
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit);
|
||||
connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle);
|
||||
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCurveIntersectAxis::ValidateAlias);
|
||||
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCurveIntersectAxis::ValidateAlias);
|
||||
|
||||
vis = new VisToolCurveIntersectAxis(data);
|
||||
|
||||
|
@ -352,6 +356,46 @@ void DialogCurveIntersectAxis::closeEvent(QCloseEvent *event)
|
|||
DialogTool::closeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCurveIntersectAxis::ValidateAlias()
|
||||
{
|
||||
QRegularExpression rx(NameRegExp());
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(getCurveId());
|
||||
QPair<QString, QString> alias = SegmentAliases(curve->getType(), GetAliasSuffix1(), GetAliasSuffix2());
|
||||
|
||||
|
||||
if (not GetAliasSuffix1().isEmpty() &&
|
||||
(not rx.match(alias.first).hasMatch() ||
|
||||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(alias.first)) ||
|
||||
alias.first == alias.second))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
ChangeColor(ui->labelAlias1, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias1 = true;
|
||||
ChangeColor(ui->labelAlias1, OkColor(this));
|
||||
}
|
||||
|
||||
if (not GetAliasSuffix2().isEmpty() &&
|
||||
(not rx.match(alias.second).hasMatch() ||
|
||||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(alias.second)) ||
|
||||
alias.first == alias.second))
|
||||
{
|
||||
flagAlias2 = false;
|
||||
ChangeColor(ui->labelAlias2, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias2 = true;
|
||||
ChangeColor(ui->labelAlias2, OkColor(this));
|
||||
}
|
||||
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCurveIntersectAxis::SetNotes(const QString ¬es)
|
||||
{
|
||||
|
@ -363,3 +407,31 @@ QString DialogCurveIntersectAxis::GetNotes() const
|
|||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCurveIntersectAxis::SetAliasSuffix1(const QString &alias)
|
||||
{
|
||||
originAliasSuffix1 = alias;
|
||||
ui->lineEditAlias1->setText(originAliasSuffix1);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCurveIntersectAxis::GetAliasSuffix1() const
|
||||
{
|
||||
return ui->lineEditAlias1->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCurveIntersectAxis::SetAliasSuffix2(const QString &alias)
|
||||
{
|
||||
originAliasSuffix2 = alias;
|
||||
ui->lineEditAlias2->setText(originAliasSuffix2);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCurveIntersectAxis::GetAliasSuffix2() const
|
||||
{
|
||||
return ui->lineEditAlias2->text();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,12 @@ public:
|
|||
void SetNotes(const QString ¬es);
|
||||
QString GetNotes() const;
|
||||
|
||||
void SetAliasSuffix1(const QString &alias);
|
||||
QString GetAliasSuffix1() const;
|
||||
|
||||
void SetAliasSuffix2(const QString &alias);
|
||||
QString GetAliasSuffix2() const;
|
||||
|
||||
virtual void ShowDialog(bool click) override;
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||
|
@ -86,6 +92,8 @@ protected:
|
|||
virtual void SaveData() override;
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual bool IsValid() const final;
|
||||
private slots:
|
||||
void ValidateAlias();
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogCurveIntersectAxis)
|
||||
Ui::DialogCurveIntersectAxis *ui;
|
||||
|
@ -101,12 +109,17 @@ private:
|
|||
|
||||
bool flagFormula;
|
||||
bool flagName;
|
||||
bool flagAlias1{true};
|
||||
bool flagAlias2{true};
|
||||
|
||||
QString originAliasSuffix1{};
|
||||
QString originAliasSuffix2{};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogCurveIntersectAxis::IsValid() const
|
||||
{
|
||||
return flagFormula && flagName;
|
||||
return flagFormula && flagName && flagAlias1 && flagAlias2;
|
||||
}
|
||||
|
||||
#endif // DIALOGCURVEINTERSECTAXIS_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>335</width>
|
||||
<height>331</height>
|
||||
<width>324</width>
|
||||
<height>394</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -320,6 +320,34 @@
|
|||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBoxLineColor"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelAlias1">
|
||||
<property name="text">
|
||||
<string>Alias1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias1">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="labelAlias2">
|
||||
<property name="text">
|
||||
<string>Alias2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias2">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -219,7 +219,7 @@ void DialogCutArc::ValidateAlias()
|
|||
|
||||
if (not GetAliasSuffix1().isEmpty() &&
|
||||
(not rx.match(arc1.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) ||
|
||||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) ||
|
||||
arc1.GetAlias() == arc2.GetAlias()))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
|
|
|
@ -227,7 +227,7 @@ void DialogCutSpline::ValidateAlias()
|
|||
|
||||
if (not GetAliasSuffix1().isEmpty() &&
|
||||
(not rx.match(spl1.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) ||
|
||||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) ||
|
||||
spl1.GetAlias() == spl2.GetAlias()))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
|
|
|
@ -227,7 +227,7 @@ void DialogCutSplinePath::ValidateAlias()
|
|||
|
||||
if (not GetAliasSuffix1().isEmpty() &&
|
||||
(not rx.match(path1.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) ||
|
||||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) ||
|
||||
path1.GetAlias() == path2.GetAlias()))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
#include "../../visualization/path/vistoolpointofintersectioncurves.h"
|
||||
#include "../../visualization/visualization.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "dialogtool.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
#include "../dialogtoolbox.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "ui_dialogpointofintersectioncurves.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -72,6 +74,10 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine
|
|||
this, &DialogPointOfIntersectionCurves::CurveChanged);
|
||||
connect(ui->comboBoxCurve2, &QComboBox::currentTextChanged,
|
||||
this, &DialogPointOfIntersectionCurves::CurveChanged);
|
||||
connect(ui->lineEditCurve1Alias1, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias);
|
||||
connect(ui->lineEditCurve1Alias2, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias);
|
||||
connect(ui->lineEditCurve2Alias1, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias);
|
||||
connect(ui->lineEditCurve2Alias2, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias);
|
||||
|
||||
vis = new VisToolPointOfIntersectionCurves(data);
|
||||
|
||||
|
@ -252,6 +258,65 @@ void DialogPointOfIntersectionCurves::CurveChanged()
|
|||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCurves::ValidateAlias()
|
||||
{
|
||||
QRegularExpression rx(NameRegExp());
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve1 = data->GeometricObject<VAbstractCurve>(GetFirstCurveId());
|
||||
QPair<QString, QString> curve1Alias = SegmentAliases(curve1->getType(), GetCurve1AliasSuffix1(),
|
||||
GetCurve1AliasSuffix2());
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve2 = data->GeometricObject<VAbstractCurve>(GetSecondCurveId());
|
||||
QPair<QString, QString> curve2Alias = SegmentAliases(curve2->getType(), GetCurve2AliasSuffix1(),
|
||||
GetCurve2AliasSuffix2());
|
||||
|
||||
QSet<QString> uniqueAliases;
|
||||
int countAliases = 0;
|
||||
|
||||
auto CountUniqueAliases = [&countAliases, &uniqueAliases](const QString &alias)
|
||||
{
|
||||
if (not alias.isEmpty())
|
||||
{
|
||||
uniqueAliases.insert(alias);
|
||||
++countAliases;
|
||||
}
|
||||
};
|
||||
|
||||
CountUniqueAliases(curve1Alias.first);
|
||||
CountUniqueAliases(curve1Alias.second);
|
||||
CountUniqueAliases(curve2Alias.first);
|
||||
CountUniqueAliases(curve2Alias.second);
|
||||
|
||||
auto Validate = [countAliases, uniqueAliases, rx, this](const QString &originalSuffix, const QString &suffix,
|
||||
const QString &alias, bool &flagAlias, QLabel *label)
|
||||
{
|
||||
if (not suffix.isEmpty() &&
|
||||
(not rx.match(alias).hasMatch() || (originalSuffix != suffix && not data->IsUnique(alias)) ||
|
||||
countAliases != uniqueAliases.size()))
|
||||
{
|
||||
flagAlias = false;
|
||||
ChangeColor(label, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias = true;
|
||||
ChangeColor(label, OkColor(this));
|
||||
}
|
||||
};
|
||||
|
||||
Validate(originCurve1AliasSuffix1, GetCurve1AliasSuffix1(), curve1Alias.first, flagCurve1Alias1,
|
||||
ui->labelCurve1Alias1);
|
||||
Validate(originCurve1AliasSuffix2, GetCurve1AliasSuffix2(), curve1Alias.second, flagCurve1Alias2,
|
||||
ui->labelCurve1Alias2);
|
||||
Validate(originCurve2AliasSuffix1, GetCurve2AliasSuffix1(), curve2Alias.first, flagCurve2Alias1,
|
||||
ui->labelCurve2Alias1);
|
||||
Validate(originCurve2AliasSuffix2, GetCurve2AliasSuffix2(), curve2Alias.second, flagCurve2Alias2,
|
||||
ui->labelCurve2Alias2);
|
||||
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCurves::SetNotes(const QString ¬es)
|
||||
{
|
||||
|
@ -263,3 +328,59 @@ QString DialogPointOfIntersectionCurves::GetNotes() const
|
|||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCurves::SetCurve1AliasSuffix1(const QString &alias)
|
||||
{
|
||||
originCurve1AliasSuffix1 = alias;
|
||||
ui->lineEditCurve1Alias1->setText(originCurve1AliasSuffix1);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCurves::GetCurve1AliasSuffix1() const
|
||||
{
|
||||
return ui->lineEditCurve1Alias1->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCurves::SetCurve1AliasSuffix2(const QString &alias)
|
||||
{
|
||||
originCurve1AliasSuffix2 = alias;
|
||||
ui->lineEditCurve1Alias2->setText(originCurve1AliasSuffix2);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCurves::GetCurve1AliasSuffix2() const
|
||||
{
|
||||
return ui->lineEditCurve1Alias2->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCurves::SetCurve2AliasSuffix1(const QString &alias)
|
||||
{
|
||||
originCurve2AliasSuffix1 = alias;
|
||||
ui->lineEditCurve2Alias1->setText(originCurve2AliasSuffix1);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCurves::GetCurve2AliasSuffix1() const
|
||||
{
|
||||
return ui->lineEditCurve2Alias1->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCurves::SetCurve2AliasSuffix2(const QString &alias)
|
||||
{
|
||||
originCurve2AliasSuffix2 = alias;
|
||||
ui->lineEditCurve2Alias2->setText(originCurve2AliasSuffix2);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCurves::GetCurve2AliasSuffix2() const
|
||||
{
|
||||
return ui->lineEditCurve2Alias2->text();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,18 @@ public:
|
|||
void SetNotes(const QString ¬es);
|
||||
QString GetNotes() const;
|
||||
|
||||
void SetCurve1AliasSuffix1(const QString &alias);
|
||||
QString GetCurve1AliasSuffix1() const;
|
||||
|
||||
void SetCurve1AliasSuffix2(const QString &alias);
|
||||
QString GetCurve1AliasSuffix2() const;
|
||||
|
||||
void SetCurve2AliasSuffix1(const QString &alias);
|
||||
QString GetCurve2AliasSuffix1() const;
|
||||
|
||||
void SetCurve2AliasSuffix2(const QString &alias);
|
||||
QString GetCurve2AliasSuffix2() const;
|
||||
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||
|
||||
|
@ -83,6 +95,7 @@ protected:
|
|||
|
||||
private slots:
|
||||
void CurveChanged();
|
||||
void ValidateAlias();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogPointOfIntersectionCurves)
|
||||
|
@ -93,12 +106,21 @@ private:
|
|||
|
||||
bool flagName;
|
||||
bool flagError;
|
||||
bool flagCurve1Alias1{true};
|
||||
bool flagCurve1Alias2{true};
|
||||
bool flagCurve2Alias1{true};
|
||||
bool flagCurve2Alias2{true};
|
||||
|
||||
QString originCurve1AliasSuffix1{};
|
||||
QString originCurve1AliasSuffix2{};
|
||||
QString originCurve2AliasSuffix1{};
|
||||
QString originCurve2AliasSuffix2{};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogPointOfIntersectionCurves::IsValid() const
|
||||
{
|
||||
return flagName && flagError;
|
||||
return flagName && flagError && flagCurve1Alias1 && flagCurve1Alias2 && flagCurve2Alias1 && flagCurve2Alias2;
|
||||
}
|
||||
|
||||
#endif // DIALOGPOINTOFINTERSECTIONCURVES_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>304</width>
|
||||
<height>242</height>
|
||||
<width>324</width>
|
||||
<height>463</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -17,7 +17,7 @@
|
|||
<iconset resource="../../../vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
|
@ -27,10 +27,9 @@
|
|||
<attribute name="title">
|
||||
<string>Tool</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelCurve1">
|
||||
<property name="sizePolicy">
|
||||
|
@ -117,6 +116,82 @@
|
|||
<widget class="QComboBox" name="comboBoxHCorrection"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Curve 1</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelCurve1Alias1">
|
||||
<property name="text">
|
||||
<string>Alias1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditCurve1Alias1">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCurve1Alias2">
|
||||
<property name="text">
|
||||
<string>Alias2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEditCurve1Alias2">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Curve 2</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelCurve2Alias1">
|
||||
<property name="text">
|
||||
<string>Alias1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditCurve2Alias1">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCurve2Alias2">
|
||||
<property name="text">
|
||||
<string>Alias2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEditCurve2Alias2">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
|
|
|
@ -200,6 +200,6 @@ void VToolCut::ReadToolAttributes(const QDomElement &domElement)
|
|||
{
|
||||
VToolSinglePoint::ReadToolAttributes(domElement);
|
||||
|
||||
m_aliasSuffix1 = doc->GetParametrEmptyString(domElement, AttrAlias1);
|
||||
m_aliasSuffix2 = doc->GetParametrEmptyString(domElement, AttrAlias2);
|
||||
m_aliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias1);
|
||||
m_aliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias2);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,9 @@ VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisIn
|
|||
initData.basePointId, 0, initData.notes, parent),
|
||||
formulaAngle(initData.formulaAngle),
|
||||
curveId(initData.curveId),
|
||||
m_segments(initData.segments)
|
||||
m_segments(initData.segments),
|
||||
m_aliasSuffix1(initData.aliasSuffix1),
|
||||
m_aliasSuffix2(initData.aliasSuffix2)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -97,6 +99,8 @@ void VToolCurveIntersectAxis::setDialog()
|
|||
dialogTool->setCurveId(curveId);
|
||||
dialogTool->SetPointName(p->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
dialogTool->SetAliasSuffix1(m_aliasSuffix1);
|
||||
dialogTool->SetAliasSuffix2(m_aliasSuffix2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -121,6 +125,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const QPointer<DialogTo
|
|||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.notes = dialogTool->GetNotes();
|
||||
initData.aliasSuffix1 = dialogTool->GetAliasSuffix1();
|
||||
initData.aliasSuffix2 = dialogTool->GetAliasSuffix2();
|
||||
|
||||
VToolCurveIntersectAxis *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
|
@ -162,7 +168,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
|
|||
initData.data->getNextId();
|
||||
initData.data->getNextId();
|
||||
initData.segments = VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId,
|
||||
initData.data);
|
||||
initData.data, initData.aliasSuffix1, initData.aliasSuffix2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -170,7 +176,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
|
|||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
|
||||
initData.segments = VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId,
|
||||
initData.data);
|
||||
initData.data, initData.aliasSuffix1, initData.aliasSuffix2);
|
||||
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
|
@ -189,6 +195,10 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
|
|||
initData.doc->IncrementReferens(curve->getIdTool());
|
||||
return point;
|
||||
}
|
||||
|
||||
auto *tool = qobject_cast<VToolCurveIntersectAxis *>(VAbstractPattern::getTool(initData.id));
|
||||
tool->SetSegments(initData.segments);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -267,6 +277,10 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList<quint32>
|
|||
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
|
||||
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
|
||||
doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId()));
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(),
|
||||
dialogTool->GetAliasSuffix1().isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(),
|
||||
dialogTool->GetAliasSuffix2().isEmpty());
|
||||
|
||||
const QString notes = dialogTool->GetNotes();
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||
|
@ -281,6 +295,8 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObj
|
|||
doc->SetAttribute(tag, AttrAngle, formulaAngle);
|
||||
doc->SetAttribute(tag, AttrBasePoint, basePointId);
|
||||
doc->SetAttribute(tag, AttrCurve, curveId);
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -288,11 +304,13 @@ void VToolCurveIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
|
|||
{
|
||||
VToolLinePoint::ReadToolAttributes(domElement);
|
||||
|
||||
m_lineType = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
||||
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
|
||||
basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
|
||||
curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
|
||||
formulaAngle = doc->GetParametrString(domElement, AttrAngle, QString());
|
||||
m_lineType = VAbstractPattern::GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
||||
lineColor = VAbstractPattern::GetParametrString(domElement, AttrLineColor, ColorBlack);
|
||||
basePointId = VAbstractPattern::GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
|
||||
curveId = VAbstractPattern::GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
|
||||
formulaAngle = VAbstractPattern::GetParametrString(domElement, AttrAngle, QString());
|
||||
m_aliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias1);
|
||||
m_aliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -300,7 +318,7 @@ void VToolCurveIntersectAxis::SetVisualization()
|
|||
{
|
||||
if (not vis.isNull())
|
||||
{
|
||||
VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis);
|
||||
auto *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setObject1Id(curveId);
|
||||
|
@ -336,3 +354,9 @@ QString VToolCurveIntersectAxis::MakeToolTip() const
|
|||
tr("Segment 2"), m_segments.second); /* 10, 11 */
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCurveIntersectAxis::SetSegments(const QPair<QString, QString> &segments)
|
||||
{
|
||||
m_segments = segments;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ struct VToolCurveIntersectAxisInitData : VToolLinePointInitData
|
|||
quint32 basePointId{NULL_ID};
|
||||
quint32 curveId{NULL_ID};
|
||||
QPair<QString, QString> segments{};
|
||||
QString aliasSuffix1{};
|
||||
QString aliasSuffix2{};
|
||||
};
|
||||
|
||||
class VToolCurveIntersectAxis : public VToolLinePoint
|
||||
|
@ -87,13 +89,17 @@ protected:
|
|||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||
virtual void SetVisualization() override;
|
||||
virtual auto MakeToolTip() const -> QString override;
|
||||
|
||||
void SetSegments(const QPair<QString, QString> &segments);
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolCurveIntersectAxis)
|
||||
QString formulaAngle;
|
||||
quint32 curveId;
|
||||
QPair<QString, QString> m_segments{};
|
||||
QString m_aliasSuffix1{};
|
||||
QString m_aliasSuffix2{};
|
||||
|
||||
VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
explicit VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
template <class Item>
|
||||
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
||||
|
|
|
@ -64,7 +64,11 @@ VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(const VToolPointO
|
|||
vCrossPoint(initData.vCrossPoint),
|
||||
hCrossPoint(initData.hCrossPoint),
|
||||
m_curve1Segments(initData.curve1Segments),
|
||||
m_curve2Segments(initData.curve2Segments)
|
||||
m_curve2Segments(initData.curve2Segments),
|
||||
m_curve1AliasSuffix1(initData.curve1AliasSuffix1),
|
||||
m_curve1AliasSuffix2(initData.curve1AliasSuffix2),
|
||||
m_curve2AliasSuffix1(initData.curve2AliasSuffix1),
|
||||
m_curve2AliasSuffix2(initData.curve2AliasSuffix2)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -82,6 +86,10 @@ void VToolPointOfIntersectionCurves::setDialog()
|
|||
dialogTool->SetHCrossPoint(hCrossPoint);
|
||||
dialogTool->SetPointName(p->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
dialogTool->SetCurve1AliasSuffix1(m_curve1AliasSuffix1);
|
||||
dialogTool->SetCurve1AliasSuffix2(m_curve1AliasSuffix2);
|
||||
dialogTool->SetCurve2AliasSuffix1(m_curve2AliasSuffix1);
|
||||
dialogTool->SetCurve2AliasSuffix2(m_curve2AliasSuffix2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -106,6 +114,10 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const QPo
|
|||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.notes = dialogTool->GetNotes();
|
||||
initData.curve1AliasSuffix1 = dialogTool->GetCurve1AliasSuffix1();
|
||||
initData.curve1AliasSuffix2 = dialogTool->GetCurve1AliasSuffix2();
|
||||
initData.curve2AliasSuffix1 = dialogTool->GetCurve2AliasSuffix1();
|
||||
initData.curve2AliasSuffix2 = dialogTool->GetCurve2AliasSuffix2();
|
||||
|
||||
VToolPointOfIntersectionCurves *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
|
@ -144,22 +156,31 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin
|
|||
initData.id = initData.data->AddGObject(p);
|
||||
|
||||
initData.curve1Segments = VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p,
|
||||
initData.firstCurveId, initData.data);
|
||||
initData.firstCurveId, initData.data,
|
||||
initData.curve1AliasSuffix1,
|
||||
initData.curve1AliasSuffix2);
|
||||
initData.curve2Segments = VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p,
|
||||
initData.secondCurveId, initData.data);
|
||||
initData.secondCurveId, initData.data,
|
||||
initData.curve2AliasSuffix1,
|
||||
initData.curve2AliasSuffix2);
|
||||
}
|
||||
else
|
||||
{
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
|
||||
initData.curve1Segments = VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p,
|
||||
initData.firstCurveId, initData.data);
|
||||
initData.firstCurveId, initData.data,
|
||||
initData.curve1AliasSuffix1,
|
||||
initData.curve1AliasSuffix2);
|
||||
initData.curve2Segments = VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p,
|
||||
initData.secondCurveId, initData.data);
|
||||
initData.secondCurveId, initData.data,
|
||||
initData.curve2AliasSuffix1,
|
||||
initData.curve2AliasSuffix2);
|
||||
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,6 +195,11 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin
|
|||
initData.doc->IncrementReferens(curve2->getIdTool());
|
||||
return point;
|
||||
}
|
||||
|
||||
auto *tool = qobject_cast<VToolPointOfIntersectionCurves *>(VAbstractPattern::getTool(initData.id));
|
||||
tool->SetCurve1Segments(initData.curve1Segments);
|
||||
tool->SetCurve2Segments(initData.curve2Segments);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -373,7 +399,7 @@ void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QList<q
|
|||
QList<quint32> &newDependencies)
|
||||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
auto dialogTool = qobject_cast<DialogPointOfIntersectionCurves*>(m_dialog);
|
||||
auto *dialogTool = qobject_cast<DialogPointOfIntersectionCurves*>(m_dialog);
|
||||
SCASSERT(dialogTool != nullptr)
|
||||
|
||||
AddDependence(oldDependencies, firstCurveId);
|
||||
|
@ -386,6 +412,14 @@ void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QList<q
|
|||
doc->SetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId()));
|
||||
doc->SetAttribute(domElement, AttrVCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetVCrossPoint())));
|
||||
doc->SetAttribute(domElement, AttrHCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetHCrossPoint())));
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias1, dialogTool->GetCurve1AliasSuffix1(),
|
||||
dialogTool->GetCurve1AliasSuffix1().isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias2, dialogTool->GetCurve1AliasSuffix2(),
|
||||
dialogTool->GetCurve1AliasSuffix2().isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias1, dialogTool->GetCurve2AliasSuffix1(),
|
||||
dialogTool->GetCurve2AliasSuffix1().isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias2, dialogTool->GetCurve2AliasSuffix2(),
|
||||
dialogTool->GetCurve2AliasSuffix2().isEmpty());
|
||||
|
||||
const QString notes = dialogTool->GetNotes();
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||
|
@ -401,6 +435,10 @@ void VToolPointOfIntersectionCurves::SaveOptions(QDomElement &tag, QSharedPointe
|
|||
doc->SetAttribute(tag, AttrCurve2, secondCurveId);
|
||||
doc->SetAttribute(tag, AttrVCrossPoint, static_cast<int>(vCrossPoint));
|
||||
doc->SetAttribute(tag, AttrHCrossPoint, static_cast<int>(hCrossPoint));
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias1, m_curve1AliasSuffix1, m_curve1AliasSuffix1.isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias2, m_curve1AliasSuffix2, m_curve1AliasSuffix2.isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias1, m_curve2AliasSuffix1, m_curve2AliasSuffix1.isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias2, m_curve2AliasSuffix2, m_curve2AliasSuffix2.isEmpty());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -408,10 +446,16 @@ void VToolPointOfIntersectionCurves::ReadToolAttributes(const QDomElement &domEl
|
|||
{
|
||||
VToolSinglePoint::ReadToolAttributes(domElement);
|
||||
|
||||
firstCurveId = doc->GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR);
|
||||
secondCurveId = doc->GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR);
|
||||
vCrossPoint = static_cast<VCrossCurvesPoint>(doc->GetParametrUInt(domElement, AttrVCrossPoint, QChar('1')));
|
||||
hCrossPoint = static_cast<HCrossCurvesPoint>(doc->GetParametrUInt(domElement, AttrHCrossPoint, QChar('1')));
|
||||
firstCurveId = VAbstractPattern::GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR);
|
||||
secondCurveId = VAbstractPattern::GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR);
|
||||
vCrossPoint = static_cast<VCrossCurvesPoint>(VAbstractPattern::GetParametrUInt(domElement, AttrVCrossPoint,
|
||||
QChar('1')));
|
||||
hCrossPoint = static_cast<HCrossCurvesPoint>(VAbstractPattern::GetParametrUInt(domElement, AttrHCrossPoint,
|
||||
QChar('1')));
|
||||
m_curve1AliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve1Alias1);
|
||||
m_curve1AliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve1Alias2);
|
||||
m_curve2AliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve2Alias1);
|
||||
m_curve2AliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve2Alias2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -450,3 +494,15 @@ auto VToolPointOfIntersectionCurves::MakeToolTip() const -> QString
|
|||
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCurves::SetCurve1Segments(const QPair<QString, QString> &segments)
|
||||
{
|
||||
m_curve1Segments = segments;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCurves::SetCurve2Segments(const QPair<QString, QString> &segments)
|
||||
{
|
||||
m_curve2Segments = segments;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ struct VToolPointOfIntersectionCurvesInitData : VToolSinglePointInitData
|
|||
HCrossCurvesPoint hCrossPoint{HCrossCurvesPoint::LeftmostPoint};
|
||||
QPair<QString, QString> curve1Segments{};
|
||||
QPair<QString, QString> curve2Segments{};
|
||||
QString curve1AliasSuffix1{};
|
||||
QString curve1AliasSuffix2{};
|
||||
QString curve2AliasSuffix1{};
|
||||
QString curve2AliasSuffix2{};
|
||||
};
|
||||
|
||||
class VToolPointOfIntersectionCurves : public VToolSinglePoint
|
||||
|
@ -89,6 +93,9 @@ protected:
|
|||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||
virtual void SetVisualization() override;
|
||||
virtual auto MakeToolTip() const -> QString override;
|
||||
|
||||
void SetCurve1Segments(const QPair<QString, QString> &segments);
|
||||
void SetCurve2Segments(const QPair<QString, QString> &segments);
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolPointOfIntersectionCurves)
|
||||
|
||||
|
@ -101,6 +108,11 @@ private:
|
|||
QPair<QString, QString> m_curve1Segments{};
|
||||
QPair<QString, QString> m_curve2Segments{};
|
||||
|
||||
QString m_curve1AliasSuffix1{};
|
||||
QString m_curve1AliasSuffix2{};
|
||||
QString m_curve2AliasSuffix1{};
|
||||
QString m_curve2AliasSuffix2{};
|
||||
|
||||
explicit VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
|
|
@ -396,14 +396,15 @@ void VToolSinglePoint::ToolSelectionType(const SelectionType &type)
|
|||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
auto VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId,
|
||||
VContainer *data) -> QPair<QString, QString>
|
||||
VContainer *data, const QString &alias1,
|
||||
const QString &alias2) -> QPair<QString, QString>
|
||||
{
|
||||
switch(curveType)
|
||||
{
|
||||
case GOType::EllipticalArc:
|
||||
return InitArc<VEllipticalArc>(data, segLength, p, curveId);
|
||||
return InitArc<VEllipticalArc>(data, segLength, p, curveId, alias1, alias2);
|
||||
case GOType::Arc:
|
||||
return InitArc<VArc>(data, segLength, p, curveId);
|
||||
return InitArc<VArc>(data, segLength, p, curveId, alias1, alias2);
|
||||
case GOType::CubicBezier:
|
||||
case GOType::Spline:
|
||||
{
|
||||
|
@ -442,12 +443,19 @@ auto VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo
|
|||
delete spl2;
|
||||
}
|
||||
|
||||
spline1->SetAliasSuffix(alias1);
|
||||
spline2->SetAliasSuffix(alias2);
|
||||
|
||||
data->RegisterUniqueName(spline1);
|
||||
data->AddSpline(spline1, NULL_ID, p->id());
|
||||
|
||||
data->RegisterUniqueName(spline2);
|
||||
data->AddSpline(spline2, NULL_ID, p->id());
|
||||
|
||||
// Because we don't store segments, but only data about them we must register the names manually
|
||||
data->RegisterUniqueName(spline1);
|
||||
data->RegisterUniqueName(spline2);
|
||||
|
||||
return qMakePair(spline1->ObjectName(), spline2->ObjectName());
|
||||
}
|
||||
case GOType::CubicBezierPath:
|
||||
|
@ -491,12 +499,19 @@ auto VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo
|
|||
delete splPath2;
|
||||
}
|
||||
|
||||
splP1->SetAliasSuffix(alias1);
|
||||
splP2->SetAliasSuffix(alias2);
|
||||
|
||||
data->RegisterUniqueName(splP1);
|
||||
data->AddSpline(splP1, NULL_ID, p->id());
|
||||
|
||||
data->RegisterUniqueName(splP2);
|
||||
data->AddSpline(splP2, NULL_ID, p->id());
|
||||
|
||||
// Because we don't store segments, but only data about them we must register the names manually
|
||||
data->RegisterUniqueName(splP1);
|
||||
data->RegisterUniqueName(splP2);
|
||||
|
||||
return qMakePair(splP1->ObjectName(), splP2->ObjectName());
|
||||
}
|
||||
case GOType::Point:
|
||||
|
|
|
@ -108,9 +108,10 @@ protected:
|
|||
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
|
||||
|
||||
template <class Item>
|
||||
static QPair<QString, QString> InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
||||
static QPair<QString, QString> InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId,
|
||||
const QString &alias1, const QString &alias2);
|
||||
static QPair<QString, QString> InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId,
|
||||
VContainer *data);
|
||||
VContainer *data, const QString &alias1, const QString &alias2);
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSinglePoint)
|
||||
};
|
||||
|
@ -118,7 +119,8 @@ private:
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class Item>
|
||||
inline auto VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const VPointF *p,
|
||||
quint32 curveId) -> QPair<QString, QString>
|
||||
quint32 curveId, const QString &alias1,
|
||||
const QString &alias2) -> QPair<QString, QString>
|
||||
{
|
||||
QSharedPointer<Item> a1;
|
||||
QSharedPointer<Item> a2;
|
||||
|
@ -140,6 +142,9 @@ inline auto VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const V
|
|||
arc1.setId(p->id() + 1);
|
||||
arc2.setId(p->id() + 2);
|
||||
|
||||
arc1.SetAliasSuffix(alias1);
|
||||
arc2.SetAliasSuffix(alias2);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(segLength, -1))
|
||||
{
|
||||
a1 = QSharedPointer<Item>(new Item(arc1));
|
||||
|
@ -158,6 +163,10 @@ inline auto VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const V
|
|||
data->AddArc(a1, arc1.id(), p->id());
|
||||
data->AddArc(a2, arc2.id(), p->id());
|
||||
|
||||
// Because we don't store segments, but only data about them we must register the names manually
|
||||
data->RegisterUniqueName(a1);
|
||||
data->RegisterUniqueName(a2);
|
||||
|
||||
return qMakePair(arc1.ObjectName(), arc2.ObjectName());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user