Alias support for group operations.
This commit is contained in:
parent
3feddb9ce9
commit
99985d43e0
|
@ -183,6 +183,7 @@
|
||||||
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
|
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
||||||
|
<xs:attribute name="alias" type="xs:string"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
|
|
@ -145,6 +145,12 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref
|
||||||
|
|
||||||
VArc arc(center, GetRadius(), f1, f2);
|
VArc arc(center, GetRadius(), f1, f2);
|
||||||
arc.setName(name() + prefix);
|
arc.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
arc.SetColor(GetColor());
|
arc.SetColor(GetColor());
|
||||||
arc.SetPenStyle(GetPenStyle());
|
arc.SetPenStyle(GetPenStyle());
|
||||||
arc.SetFlipped(IsFlipped());
|
arc.SetFlipped(IsFlipped());
|
||||||
|
@ -165,6 +171,12 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const
|
||||||
|
|
||||||
VArc arc(center, GetRadius(), f1, f2);
|
VArc arc(center, GetRadius(), f1, f2);
|
||||||
arc.setName(name() + prefix);
|
arc.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
arc.SetColor(GetColor());
|
arc.SetColor(GetColor());
|
||||||
arc.SetPenStyle(GetPenStyle());
|
arc.SetPenStyle(GetPenStyle());
|
||||||
arc.SetFlipped(not IsFlipped());
|
arc.SetFlipped(not IsFlipped());
|
||||||
|
@ -185,6 +197,12 @@ VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const
|
||||||
|
|
||||||
VArc arc(center, GetRadius(), f1, f2);
|
VArc arc(center, GetRadius(), f1, f2);
|
||||||
arc.setName(name() + prefix);
|
arc.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
arc.SetColor(GetColor());
|
arc.SetColor(GetColor());
|
||||||
arc.SetPenStyle(GetPenStyle());
|
arc.SetPenStyle(GetPenStyle());
|
||||||
arc.SetFlipped(IsFlipped());
|
arc.SetFlipped(IsFlipped());
|
||||||
|
|
|
@ -88,6 +88,12 @@ VCubicBezier VCubicBezier::Rotate(const QPointF &originPoint, qreal degrees, con
|
||||||
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
|
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
|
||||||
VCubicBezier curve(p1, p2, p3, p4);
|
VCubicBezier curve(p1, p2, p3, p4);
|
||||||
curve.setName(name() + prefix);
|
curve.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
curve.SetColor(GetColor());
|
curve.SetColor(GetColor());
|
||||||
curve.SetPenStyle(GetPenStyle());
|
curve.SetPenStyle(GetPenStyle());
|
||||||
curve.SetApproximationScale(GetApproximationScale());
|
curve.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -103,6 +109,12 @@ VCubicBezier VCubicBezier::Flip(const QLineF &axis, const QString &prefix) const
|
||||||
const VPointF p4 = GetP4().Flip(axis);
|
const VPointF p4 = GetP4().Flip(axis);
|
||||||
VCubicBezier curve(p1, p2, p3, p4);
|
VCubicBezier curve(p1, p2, p3, p4);
|
||||||
curve.setName(name() + prefix);
|
curve.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
curve.SetColor(GetColor());
|
curve.SetColor(GetColor());
|
||||||
curve.SetPenStyle(GetPenStyle());
|
curve.SetPenStyle(GetPenStyle());
|
||||||
curve.SetApproximationScale(GetApproximationScale());
|
curve.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -118,6 +130,12 @@ VCubicBezier VCubicBezier::Move(qreal length, qreal angle, const QString &prefix
|
||||||
const VPointF p4 = GetP4().Move(length, angle);
|
const VPointF p4 = GetP4().Move(length, angle);
|
||||||
VCubicBezier curve(p1, p2, p3, p4);
|
VCubicBezier curve(p1, p2, p3, p4);
|
||||||
curve.setName(name() + prefix);
|
curve.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
curve.SetColor(GetColor());
|
curve.SetColor(GetColor());
|
||||||
curve.SetPenStyle(GetPenStyle());
|
curve.SetPenStyle(GetPenStyle());
|
||||||
curve.SetApproximationScale(GetApproximationScale());
|
curve.SetApproximationScale(GetApproximationScale());
|
||||||
|
|
|
@ -104,6 +104,12 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr
|
||||||
curve.append(point.Rotate(originPoint, degrees));
|
curve.append(point.Rotate(originPoint, degrees));
|
||||||
}
|
}
|
||||||
curve.setName(name() + prefix);
|
curve.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
curve.SetColor(GetColor());
|
curve.SetColor(GetColor());
|
||||||
curve.SetPenStyle(GetPenStyle());
|
curve.SetPenStyle(GetPenStyle());
|
||||||
curve.SetApproximationScale(GetApproximationScale());
|
curve.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -120,6 +126,12 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi
|
||||||
curve.append(point.Flip(axis));
|
curve.append(point.Flip(axis));
|
||||||
}
|
}
|
||||||
curve.setName(name() + prefix);
|
curve.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
curve.SetColor(GetColor());
|
curve.SetColor(GetColor());
|
||||||
curve.SetPenStyle(GetPenStyle());
|
curve.SetPenStyle(GetPenStyle());
|
||||||
curve.SetApproximationScale(GetApproximationScale());
|
curve.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -136,6 +148,12 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString
|
||||||
curve.append(point.Move(length, angle));
|
curve.append(point.Move(length, angle));
|
||||||
}
|
}
|
||||||
curve.setName(name() + prefix);
|
curve.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
curve.SetColor(GetColor());
|
curve.SetColor(GetColor());
|
||||||
curve.SetPenStyle(GetPenStyle());
|
curve.SetPenStyle(GetPenStyle());
|
||||||
curve.SetApproximationScale(GetApproximationScale());
|
curve.SetApproximationScale(GetApproximationScale());
|
||||||
|
|
|
@ -153,6 +153,12 @@ VEllipticalArc VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const
|
||||||
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
||||||
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
||||||
elArc.setName(name() + prefix);
|
elArc.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
elArc.SetColor(GetColor());
|
elArc.SetColor(GetColor());
|
||||||
elArc.SetPenStyle(GetPenStyle());
|
elArc.SetPenStyle(GetPenStyle());
|
||||||
elArc.SetFlipped(IsFlipped());
|
elArc.SetFlipped(IsFlipped());
|
||||||
|
@ -166,6 +172,12 @@ VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) c
|
||||||
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
||||||
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
||||||
elArc.setName(name() + prefix);
|
elArc.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
elArc.SetColor(GetColor());
|
elArc.SetColor(GetColor());
|
||||||
elArc.SetPenStyle(GetPenStyle());
|
elArc.SetPenStyle(GetPenStyle());
|
||||||
elArc.SetFlipped(not IsFlipped());
|
elArc.SetFlipped(not IsFlipped());
|
||||||
|
@ -188,6 +200,12 @@ VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &pr
|
||||||
VEllipticalArc elArc(oldCenter, GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
VEllipticalArc elArc(oldCenter, GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
||||||
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
||||||
elArc.setName(name() + prefix);
|
elArc.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
elArc.SetColor(GetColor());
|
elArc.SetColor(GetColor());
|
||||||
elArc.SetPenStyle(GetPenStyle());
|
elArc.SetPenStyle(GetPenStyle());
|
||||||
elArc.SetFlipped(IsFlipped());
|
elArc.SetFlipped(IsFlipped());
|
||||||
|
|
|
@ -78,11 +78,11 @@ public:
|
||||||
quint32 id() const;
|
quint32 id() const;
|
||||||
virtual void setId(const quint32 &id);
|
virtual void setId(const quint32 &id);
|
||||||
|
|
||||||
void SetAlias(const QString &alias);
|
virtual void SetAlias(const QString &alias);
|
||||||
QString GetAlias() const;
|
QString GetAlias() const;
|
||||||
|
|
||||||
virtual void SetAliasSuffix(const QString &aliasSuffix);
|
virtual void SetAliasSuffix(const QString &aliasSuffix);
|
||||||
QString GetAliasSuffix() const;
|
QString GetAliasSuffix() const;
|
||||||
|
|
||||||
QString ObjectName() const;
|
QString ObjectName() const;
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ VPointF VPointF::Move(qreal length, qreal angle, const QString &prefix) const
|
||||||
const QPointF p = MovePF(toQPointF(), length, angle);
|
const QPointF p = MovePF(toQPointF(), length, angle);
|
||||||
VPointF moved(p, name() + prefix, mx(), my());
|
VPointF moved(p, name() + prefix, mx(), my());
|
||||||
moved.SetShowLabel(IsShowLabel());
|
moved.SetShowLabel(IsShowLabel());
|
||||||
|
|
||||||
return moved;
|
return moved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +261,20 @@ QJsonObject VPointF::ToJson() const
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPointF::SetAlias(const QString &alias)
|
||||||
|
{
|
||||||
|
Q_UNUSED(alias);
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPointF::SetAliasSuffix(const QString &aliasSuffix)
|
||||||
|
{
|
||||||
|
Q_UNUSED(aliasSuffix);
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
|
QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,9 @@ public:
|
||||||
|
|
||||||
virtual QJsonObject ToJson() const override;
|
virtual QJsonObject ToJson() const override;
|
||||||
|
|
||||||
|
virtual void SetAlias(const QString &alias) override;
|
||||||
|
virtual void SetAliasSuffix(const QString &aliasSuffix) override;
|
||||||
|
|
||||||
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
|
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
|
||||||
static QPointF FlipPF(const QLineF &axis, const QPointF &point);
|
static QPointF FlipPF(const QLineF &axis, const QPointF &point);
|
||||||
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);
|
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);
|
||||||
|
|
|
@ -122,6 +122,12 @@ VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString
|
||||||
|
|
||||||
VSpline spl(p1, p2, p3, p4);
|
VSpline spl(p1, p2, p3, p4);
|
||||||
spl.setName(name() + prefix);
|
spl.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
spl.SetColor(GetColor());
|
spl.SetColor(GetColor());
|
||||||
spl.SetPenStyle(GetPenStyle());
|
spl.SetPenStyle(GetPenStyle());
|
||||||
spl.SetApproximationScale(GetApproximationScale());
|
spl.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -139,6 +145,12 @@ VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
|
||||||
|
|
||||||
VSpline spl(p1, p2, p3, p4);
|
VSpline spl(p1, p2, p3, p4);
|
||||||
spl.setName(name() + prefix);
|
spl.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
spl.SetColor(GetColor());
|
spl.SetColor(GetColor());
|
||||||
spl.SetPenStyle(GetPenStyle());
|
spl.SetPenStyle(GetPenStyle());
|
||||||
spl.SetApproximationScale(GetApproximationScale());
|
spl.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -156,6 +168,12 @@ VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const
|
||||||
|
|
||||||
VSpline spl(p1, p2, p3, p4);
|
VSpline spl(p1, p2, p3, p4);
|
||||||
spl.setName(name() + prefix);
|
spl.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
spl.SetColor(GetColor());
|
spl.SetColor(GetColor());
|
||||||
spl.SetPenStyle(GetPenStyle());
|
spl.SetPenStyle(GetPenStyle());
|
||||||
spl.SetApproximationScale(GetApproximationScale());
|
spl.SetApproximationScale(GetApproximationScale());
|
||||||
|
|
|
@ -122,6 +122,12 @@ VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const
|
||||||
|
|
||||||
VSplinePath splPath(newPoints);
|
VSplinePath splPath(newPoints);
|
||||||
splPath.setName(name() + prefix);
|
splPath.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
splPath.SetColor(GetColor());
|
splPath.SetColor(GetColor());
|
||||||
splPath.SetPenStyle(GetPenStyle());
|
splPath.SetPenStyle(GetPenStyle());
|
||||||
splPath.SetApproximationScale(GetApproximationScale());
|
splPath.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -147,6 +153,12 @@ VSplinePath VSplinePath::Flip(const QLineF &axis, const QString &prefix) const
|
||||||
|
|
||||||
VSplinePath splPath(newPoints);
|
VSplinePath splPath(newPoints);
|
||||||
splPath.setName(name() + prefix);
|
splPath.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
splPath.SetColor(GetColor());
|
splPath.SetColor(GetColor());
|
||||||
splPath.SetPenStyle(GetPenStyle());
|
splPath.SetPenStyle(GetPenStyle());
|
||||||
splPath.SetApproximationScale(GetApproximationScale());
|
splPath.SetApproximationScale(GetApproximationScale());
|
||||||
|
@ -172,6 +184,12 @@ VSplinePath VSplinePath::Move(qreal length, qreal angle, const QString &prefix)
|
||||||
|
|
||||||
VSplinePath splPath(newPoints);
|
VSplinePath splPath(newPoints);
|
||||||
splPath.setName(name() + prefix);
|
splPath.setName(name() + prefix);
|
||||||
|
|
||||||
|
if (not GetAliasSuffix().isEmpty())
|
||||||
|
{
|
||||||
|
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
|
||||||
|
}
|
||||||
|
|
||||||
splPath.SetColor(GetColor());
|
splPath.SetColor(GetColor());
|
||||||
splPath.SetPenStyle(GetPenStyle());
|
splPath.SetPenStyle(GetPenStyle());
|
||||||
splPath.SetApproximationScale(GetApproximationScale());
|
splPath.SetApproximationScale(GetApproximationScale());
|
||||||
|
|
|
@ -249,6 +249,10 @@ void DialogFlippingByAxis::SetSourceObjects(const QVector<SourceItem> &value)
|
||||||
{
|
{
|
||||||
sourceObjects = value;
|
sourceObjects = value;
|
||||||
FillSourceList();
|
FillSourceList();
|
||||||
|
|
||||||
|
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
|
||||||
|
SCASSERT(operation != nullptr)
|
||||||
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -392,21 +396,8 @@ void DialogFlippingByAxis::ShowSourceDetails(int row)
|
||||||
ui->lineEditAlias->setEnabled(true);
|
ui->lineEditAlias->setEnabled(true);
|
||||||
ui->lineEditAlias->blockSignals(false);
|
ui->lineEditAlias->blockSignals(false);
|
||||||
|
|
||||||
QRegularExpression rx(NameRegExp());
|
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
|
||||||
if (not rx.match(sourceItem.alias).hasMatch() || not data->IsUnique(sourceItem.alias))
|
OriginAlias(sourceItem.id, sourceObjects, obj)));
|
||||||
{
|
|
||||||
flagAlias = false;
|
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
|
||||||
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
|
|
||||||
CheckState();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
flagAlias = true;
|
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
|
||||||
CheckState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -515,8 +506,9 @@ void DialogFlippingByAxis::FillSourceList()
|
||||||
for (auto &sourceItem : sourceObjects)
|
for (auto &sourceItem : sourceObjects)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
|
||||||
|
|
||||||
auto *item = new QListWidgetItem(obj->ObjectName());
|
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
item->setToolTip(obj->ObjectName());
|
item->setToolTip(obj->ObjectName());
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
ui->listWidget->insertItem(++row, item);
|
ui->listWidget->insertItem(++row, item);
|
||||||
|
@ -535,8 +527,6 @@ void DialogFlippingByAxis::FillSourceList()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByAxis::ValidateSourceAliases()
|
void DialogFlippingByAxis::ValidateSourceAliases()
|
||||||
{
|
{
|
||||||
QRegularExpression rx(NameRegExp());
|
|
||||||
|
|
||||||
for (int i=0; i<ui->listWidget->count(); ++i)
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
{
|
{
|
||||||
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
@ -545,27 +535,39 @@ void DialogFlippingByAxis::ValidateSourceAliases()
|
||||||
|
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
QString name;
|
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
|
||||||
|
|
||||||
if (obj->getType() == GOType::Point)
|
|
||||||
{
|
|
||||||
name = sourceItem.alias;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const QString oldAlias = obj->GetAliasSuffix();
|
|
||||||
obj->SetAliasSuffix(sourceItem.alias);
|
|
||||||
name = obj->GetAlias();
|
|
||||||
obj->SetAliasSuffix(oldAlias);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
|
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
|
||||||
|
SetAliasValid(sourceItem.id, false);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAliasValid(sourceItem.id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flagAlias = true;
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByAxis::SetAliasValid(quint32 id, bool valid)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->currentRow() != -1)
|
||||||
|
{
|
||||||
|
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
if (id == sourceItem.id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
|
||||||
|
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
#include "../../tools/toolsdef.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -63,8 +64,6 @@ public:
|
||||||
QString GetSuffix() const;
|
QString GetSuffix() const;
|
||||||
void SetSuffix(const QString &value);
|
void SetSuffix(const QString &value);
|
||||||
|
|
||||||
QVector<quint32> GetObjects() const;
|
|
||||||
|
|
||||||
QString GetVisibilityGroupName() const;
|
QString GetVisibilityGroupName() const;
|
||||||
void SetVisibilityGroupName(const QString &name);
|
void SetVisibilityGroupName(const QString &name);
|
||||||
|
|
||||||
|
@ -81,6 +80,9 @@ public:
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
|
QVector<SourceItem> GetSourceObjects() const;
|
||||||
|
void SetSourceObjects(const QVector<SourceItem> &value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
||||||
|
@ -88,6 +90,8 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
void GroupNameChanged();
|
void GroupNameChanged();
|
||||||
|
void ShowSourceDetails(int row);
|
||||||
|
void AliasChanged(const QString &text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
@ -104,7 +108,7 @@ private:
|
||||||
|
|
||||||
Ui::DialogFlippingByAxis *ui;
|
Ui::DialogFlippingByAxis *ui;
|
||||||
|
|
||||||
QList<quint32> objects;
|
QVector<SourceItem> sourceObjects{};
|
||||||
|
|
||||||
bool stage1;
|
bool stage1;
|
||||||
|
|
||||||
|
@ -113,16 +117,16 @@ private:
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
bool flagError;
|
bool flagError;
|
||||||
|
bool flagAlias{true};
|
||||||
|
|
||||||
QStringList m_groupTags{};
|
QStringList m_groupTags{};
|
||||||
|
|
||||||
static void FillComboBoxAxisType(QComboBox *box);
|
static void FillComboBoxAxisType(QComboBox *box);
|
||||||
|
|
||||||
|
void FillSourceList();
|
||||||
|
|
||||||
|
void ValidateSourceAliases();
|
||||||
|
void SetAliasValid(quint32 id, bool valid);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline bool DialogFlippingByAxis::IsValid() const
|
|
||||||
{
|
|
||||||
return flagError && flagName && flagGroupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DIALOGFLIPPINGBYAXIS_H
|
#endif // DIALOGFLIPPINGBYAXIS_H
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>304</width>
|
<width>415</width>
|
||||||
<height>296</height>
|
<height>464</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -28,6 +28,35 @@
|
||||||
<string>Tool</string>
|
<string>Tool</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QListWidget" name="listWidget"/>
|
||||||
|
<widget class="QWidget" name="formLayoutWidget">
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelAlias">
|
||||||
|
<property name="text">
|
||||||
|
<string>Alias:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditAlias">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
@ -48,7 +77,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditSuffix"/>
|
<widget class="QLineEdit" name="lineEditSuffix">
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelAxisType">
|
<widget class="QLabel" name="labelAxisType">
|
||||||
|
@ -117,6 +150,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelStatus">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ready</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -64,7 +64,6 @@
|
||||||
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogFlippingByLine),
|
ui(new Ui::DialogFlippingByLine),
|
||||||
objects(),
|
|
||||||
stage1(true),
|
stage1(true),
|
||||||
m_suffix(),
|
m_suffix(),
|
||||||
flagName(true),
|
flagName(true),
|
||||||
|
@ -142,12 +141,6 @@ void DialogFlippingByLine::SetSuffix(const QString &value)
|
||||||
ui->lineEditSuffix->setText(value);
|
ui->lineEditSuffix->setText(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<quint32> DialogFlippingByLine::GetObjects() const
|
|
||||||
{
|
|
||||||
return ConvertToVector(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogFlippingByLine::GetVisibilityGroupName() const
|
QString DialogFlippingByLine::GetVisibilityGroupName() const
|
||||||
{
|
{
|
||||||
|
@ -196,7 +189,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
if (stage1 && not click)
|
if (stage1 && not click)
|
||||||
{
|
{
|
||||||
if (objects.isEmpty())
|
if (sourceObjects.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +202,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
|
||||||
|
|
||||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
operation->VisualMode();
|
operation->VisualMode();
|
||||||
|
|
||||||
scene->ToggleArcSelection(false);
|
scene->ToggleArcSelection(false);
|
||||||
|
@ -224,6 +217,8 @@ void DialogFlippingByLine::ShowDialog(bool click)
|
||||||
|
|
||||||
qApp->getSceneView()->AllowRubberBand(false);
|
qApp->getSceneView()->AllowRubberBand(false);
|
||||||
|
|
||||||
|
FillSourceList();
|
||||||
|
|
||||||
emit ToolTip(tr("Select first line point"));
|
emit ToolTip(tr("Select first line point"));
|
||||||
}
|
}
|
||||||
else if (not stage1 && prepare && click)
|
else if (not stage1 && prepare && click)
|
||||||
|
@ -234,6 +229,23 @@ void DialogFlippingByLine::ShowDialog(bool click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<SourceItem> DialogFlippingByLine::GetSourceObjects() const
|
||||||
|
{
|
||||||
|
return sourceObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::SetSourceObjects(const QVector<SourceItem> &value)
|
||||||
|
{
|
||||||
|
sourceObjects = value;
|
||||||
|
FillSourceList();
|
||||||
|
|
||||||
|
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||||
|
SCASSERT(operation != nullptr)
|
||||||
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
|
@ -241,10 +253,12 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
if (type == SceneObject::Point)
|
if (type == SceneObject::Point)
|
||||||
{
|
{
|
||||||
|
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[id](const SourceItem &sItem) { return sItem.id == id; });
|
||||||
switch (number)
|
switch (number)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (objects.contains(id))
|
if (obj != sourceObjects.end())
|
||||||
{
|
{
|
||||||
emit ToolTip(tr("Select first line point that is not part of the list of objects"));
|
emit ToolTip(tr("Select first line point that is not part of the list of objects"));
|
||||||
return;
|
return;
|
||||||
|
@ -260,7 +274,7 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (objects.contains(id))
|
if (obj != sourceObjects.end())
|
||||||
{
|
{
|
||||||
emit ToolTip(tr("Select second line point that is not part of the list of objects"));
|
emit ToolTip(tr("Select second line point that is not part of the list of objects"));
|
||||||
return;
|
return;
|
||||||
|
@ -296,16 +310,23 @@ void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32
|
||||||
Q_UNUSED(tool)
|
Q_UNUSED(tool)
|
||||||
if (stage1)
|
if (stage1)
|
||||||
{
|
{
|
||||||
|
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[object](const SourceItem &sItem) { return sItem.id == object; });
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
if (not objects.contains(object))
|
if (obj == sourceObjects.cend())
|
||||||
{
|
{
|
||||||
objects.append(object);
|
SourceItem item;
|
||||||
|
item.id = object;
|
||||||
|
sourceObjects.append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objects.removeOne(object);
|
if (obj != sourceObjects.end())
|
||||||
|
{
|
||||||
|
sourceObjects.erase(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,6 +342,7 @@ void DialogFlippingByLine::SuffixChanged()
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, errorColor);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid suffix"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -337,6 +359,7 @@ void DialogFlippingByLine::SuffixChanged()
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, errorColor);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid suffix"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -361,6 +384,7 @@ void DialogFlippingByLine::GroupNameChanged()
|
||||||
{
|
{
|
||||||
flagGroupName = false;
|
flagGroupName = false;
|
||||||
ChangeColor(ui->labelGroupName, errorColor);
|
ChangeColor(ui->labelGroupName, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid group name"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -371,6 +395,50 @@ void DialogFlippingByLine::GroupNameChanged()
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::ShowSourceDetails(int row)
|
||||||
|
{
|
||||||
|
ui->lineEditAlias->setDisabled(true);
|
||||||
|
|
||||||
|
if (ui->listWidget->count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
|
||||||
|
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
|
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
|
||||||
|
|
||||||
|
ui->lineEditAlias->blockSignals(true);
|
||||||
|
ui->lineEditAlias->setText(sourceItem.alias);
|
||||||
|
ui->lineEditAlias->setEnabled(true);
|
||||||
|
ui->lineEditAlias->blockSignals(false);
|
||||||
|
|
||||||
|
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
|
||||||
|
OriginAlias(sourceItem.id, sourceObjects, obj)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::AliasChanged(const QString &text)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto *item = ui->listWidget->currentItem())
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
sourceItem.alias = text;
|
||||||
|
|
||||||
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
|
|
||||||
|
ValidateSourceAliases();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByLine::ShowVisualization()
|
void DialogFlippingByLine::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -382,10 +450,22 @@ void DialogFlippingByLine::SaveData()
|
||||||
{
|
{
|
||||||
m_suffix = ui->lineEditSuffix->text();
|
m_suffix = ui->lineEditSuffix->text();
|
||||||
|
|
||||||
|
sourceObjects.clear();
|
||||||
|
sourceObjects.reserve(ui->listWidget->count());
|
||||||
|
|
||||||
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
sourceObjects.append(sourceItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
|
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
operation->SetFirstLinePointId(GetFirstLinePointId());
|
operation->SetFirstLinePointId(GetFirstLinePointId());
|
||||||
operation->SetSecondLinePointId(GetSecondLinePointId());
|
operation->SetSecondLinePointId(GetSecondLinePointId());
|
||||||
operation->RefreshGeometry();
|
operation->RefreshGeometry();
|
||||||
|
@ -411,29 +491,118 @@ void DialogFlippingByLine::PointChanged()
|
||||||
ChangeColor(ui->labelFirstLinePoint, color);
|
ChangeColor(ui->labelFirstLinePoint, color);
|
||||||
ChangeColor(ui->labelSecondLinePoint, color);
|
ChangeColor(ui->labelSecondLinePoint, color);
|
||||||
|
|
||||||
|
quint32 id1 = getCurrentObjectId(ui->comboBoxFirstLinePoint);
|
||||||
|
auto obj1 = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[id1](const SourceItem &sItem) { return sItem.id == id1; });
|
||||||
|
|
||||||
|
quint32 id2 = getCurrentObjectId(ui->comboBoxSecondLinePoint);
|
||||||
|
auto obj2 = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[id2](const SourceItem &sItem) { return sItem.id == id2; });
|
||||||
|
|
||||||
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) == getCurrentObjectId(ui->comboBoxSecondLinePoint))
|
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) == getCurrentObjectId(ui->comboBoxSecondLinePoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
ChangeColor(ui->labelFirstLinePoint, color);
|
ChangeColor(ui->labelFirstLinePoint, color);
|
||||||
ChangeColor(ui->labelSecondLinePoint, color);
|
ChangeColor(ui->labelSecondLinePoint, color);
|
||||||
|
ui->labelStatus->setText(tr("Invalid line points"));
|
||||||
}
|
}
|
||||||
else if (objects.contains(getCurrentObjectId(ui->comboBoxFirstLinePoint)))
|
else if (obj1 != sourceObjects.end())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
ChangeColor(ui->labelFirstLinePoint, color);
|
ChangeColor(ui->labelFirstLinePoint, color);
|
||||||
|
ui->labelStatus->setText(tr("Invalid first line point"));
|
||||||
}
|
}
|
||||||
else if (objects.contains(getCurrentObjectId(ui->comboBoxSecondLinePoint)))
|
else if (obj2 != sourceObjects.end())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
ChangeColor(ui->labelSecondLinePoint, color);
|
ChangeColor(ui->labelSecondLinePoint, color);
|
||||||
|
ui->labelStatus->setText(tr("Invalid second line point"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::FillSourceList()
|
||||||
|
{
|
||||||
|
ui->listWidget->blockSignals(true);
|
||||||
|
|
||||||
|
ui->listWidget->clear();
|
||||||
|
|
||||||
|
int row = -1;
|
||||||
|
|
||||||
|
for (auto &sourceItem : sourceObjects)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
|
||||||
|
|
||||||
|
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
item->setToolTip(obj->ObjectName());
|
||||||
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
|
ui->listWidget->insertItem(++row, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->listWidget->blockSignals(false);
|
||||||
|
|
||||||
|
if (ui->listWidget->count() > 0)
|
||||||
|
{
|
||||||
|
ui->listWidget->setCurrentRow(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidateSourceAliases();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::ValidateSourceAliases()
|
||||||
|
{
|
||||||
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
|
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
|
||||||
|
{
|
||||||
|
flagAlias = false;
|
||||||
|
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
|
||||||
|
SetAliasValid(sourceItem.id, false);
|
||||||
|
CheckState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAliasValid(sourceItem.id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flagAlias = true;
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::SetAliasValid(quint32 id, bool valid)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->currentRow() != -1)
|
||||||
|
{
|
||||||
|
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
if (id == sourceItem.id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
|
||||||
|
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByLine::SetNotes(const QString ¬es)
|
void DialogFlippingByLine::SetNotes(const QString ¬es)
|
||||||
{
|
{
|
||||||
|
@ -445,3 +614,16 @@ QString DialogFlippingByLine::GetNotes() const
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogFlippingByLine::IsValid() const
|
||||||
|
{
|
||||||
|
bool ready = flagError && flagName && flagGroupName && flagAlias;
|
||||||
|
|
||||||
|
if (ready)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Ready"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
#include "../../tools/toolsdef.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -63,8 +64,6 @@ public:
|
||||||
QString GetSuffix() const;
|
QString GetSuffix() const;
|
||||||
void SetSuffix(const QString &value);
|
void SetSuffix(const QString &value);
|
||||||
|
|
||||||
QVector<quint32> GetObjects() const;
|
|
||||||
|
|
||||||
QString GetVisibilityGroupName() const;
|
QString GetVisibilityGroupName() const;
|
||||||
void SetVisibilityGroupName(const QString &name);
|
void SetVisibilityGroupName(const QString &name);
|
||||||
|
|
||||||
|
@ -81,6 +80,9 @@ public:
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
|
QVector<SourceItem> GetSourceObjects() const;
|
||||||
|
void SetSourceObjects(const QVector<SourceItem> &value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
||||||
|
@ -88,6 +90,8 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
void GroupNameChanged();
|
void GroupNameChanged();
|
||||||
|
void ShowSourceDetails(int row);
|
||||||
|
void AliasChanged(const QString &text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
@ -104,7 +108,7 @@ private:
|
||||||
|
|
||||||
Ui::DialogFlippingByLine *ui;
|
Ui::DialogFlippingByLine *ui;
|
||||||
|
|
||||||
QList<quint32> objects;
|
QVector<SourceItem> sourceObjects{};
|
||||||
|
|
||||||
bool stage1;
|
bool stage1;
|
||||||
|
|
||||||
|
@ -113,14 +117,14 @@ private:
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
bool flagError;
|
bool flagError;
|
||||||
|
bool flagAlias{true};
|
||||||
|
|
||||||
QStringList m_groupTags{};
|
QStringList m_groupTags{};
|
||||||
|
|
||||||
|
void FillSourceList();
|
||||||
|
|
||||||
|
void ValidateSourceAliases();
|
||||||
|
void SetAliasValid(quint32 id, bool valid);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline bool DialogFlippingByLine::IsValid() const
|
|
||||||
{
|
|
||||||
return flagError && flagName && flagGroupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DIALOGFLIPPINGBYLINE_H
|
#endif // DIALOGFLIPPINGBYLINE_H
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>319</width>
|
<width>387</width>
|
||||||
<height>301</height>
|
<height>440</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -28,6 +28,35 @@
|
||||||
<string>Tool</string>
|
<string>Tool</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QListWidget" name="listWidget"/>
|
||||||
|
<widget class="QWidget" name="formLayoutWidget">
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelAlias">
|
||||||
|
<property name="text">
|
||||||
|
<string>Alias:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditAlias">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
@ -48,7 +77,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditSuffix"/>
|
<widget class="QLineEdit" name="lineEditSuffix">
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelSecondLinePoint">
|
<widget class="QLabel" name="labelSecondLinePoint">
|
||||||
|
@ -117,6 +150,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelStatus">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ready</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -78,7 +78,6 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
formulaBaseHeightAngle(0),
|
formulaBaseHeightAngle(0),
|
||||||
formulaBaseHeightRotationAngle(0),
|
formulaBaseHeightRotationAngle(0),
|
||||||
formulaBaseHeightLength(0),
|
formulaBaseHeightLength(0),
|
||||||
objects(),
|
|
||||||
stage1(true),
|
stage1(true),
|
||||||
stage2(false),
|
stage2(false),
|
||||||
m_suffix(),
|
m_suffix(),
|
||||||
|
@ -143,6 +142,9 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit);
|
connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit);
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
|
||||||
|
|
||||||
|
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogMove::ShowSourceDetails);
|
||||||
|
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogMove::AliasChanged);
|
||||||
|
|
||||||
vis = new VisToolMove(data);
|
vis = new VisToolMove(data);
|
||||||
|
|
||||||
SetRotationOrigPointId(NULL_ID);
|
SetRotationOrigPointId(NULL_ID);
|
||||||
|
@ -257,12 +259,6 @@ void DialogMove::SetRotationOrigPointId(const quint32 &value)
|
||||||
operation->SetRotationOriginPointId(value);
|
operation->SetRotationOriginPointId(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<quint32> DialogMove::GetObjects() const
|
|
||||||
{
|
|
||||||
return ConvertToVector(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogMove::GetVisibilityGroupName() const
|
QString DialogMove::GetVisibilityGroupName() const
|
||||||
{
|
{
|
||||||
|
@ -311,7 +307,7 @@ void DialogMove::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
if (stage1 && not click)
|
if (stage1 && not click)
|
||||||
{
|
{
|
||||||
if (objects.isEmpty())
|
if (sourceObjects.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +321,7 @@ void DialogMove::ShowDialog(bool click)
|
||||||
|
|
||||||
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
operation->VisualMode();
|
operation->VisualMode();
|
||||||
|
|
||||||
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
|
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
|
||||||
|
@ -343,6 +339,8 @@ void DialogMove::ShowDialog(bool click)
|
||||||
scene->ToggleSplinePathHover(false);
|
scene->ToggleSplinePathHover(false);
|
||||||
|
|
||||||
qApp->getSceneView()->AllowRubberBand(false);
|
qApp->getSceneView()->AllowRubberBand(false);
|
||||||
|
|
||||||
|
FillSourceList();
|
||||||
}
|
}
|
||||||
else if (not stage2 && not stage1 && prepare && click)
|
else if (not stage2 && not stage1 && prepare && click)
|
||||||
{
|
{
|
||||||
|
@ -416,16 +414,23 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||||
Q_UNUSED(tool)
|
Q_UNUSED(tool)
|
||||||
if (stage1)
|
if (stage1)
|
||||||
{
|
{
|
||||||
|
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[object](const SourceItem &sItem) { return sItem.id == object; });
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
if (not objects.contains(object))
|
if (obj == sourceObjects.cend())
|
||||||
{
|
{
|
||||||
objects.append(object);
|
SourceItem item;
|
||||||
|
item.id = object;
|
||||||
|
sourceObjects.append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objects.removeOne(object);
|
if (obj != sourceObjects.end())
|
||||||
|
{
|
||||||
|
sourceObjects.erase(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,6 +506,7 @@ void DialogMove::SuffixChanged()
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, errorColor);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid suffix"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -517,6 +523,7 @@ void DialogMove::SuffixChanged()
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, errorColor);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid suffix"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -541,6 +548,7 @@ void DialogMove::GroupNameChanged()
|
||||||
{
|
{
|
||||||
flagGroupName = false;
|
flagGroupName = false;
|
||||||
ChangeColor(ui->labelGroupName, errorColor);
|
ChangeColor(ui->labelGroupName, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid group name"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -551,6 +559,50 @@ void DialogMove::GroupNameChanged()
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::ShowSourceDetails(int row)
|
||||||
|
{
|
||||||
|
ui->lineEditAlias->setDisabled(true);
|
||||||
|
|
||||||
|
if (ui->listWidget->count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
|
||||||
|
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
|
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
|
||||||
|
|
||||||
|
ui->lineEditAlias->blockSignals(true);
|
||||||
|
ui->lineEditAlias->setText(sourceItem.alias);
|
||||||
|
ui->lineEditAlias->setEnabled(true);
|
||||||
|
ui->lineEditAlias->blockSignals(false);
|
||||||
|
|
||||||
|
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
|
||||||
|
OriginAlias(sourceItem.id, sourceObjects, obj)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::AliasChanged(const QString &text)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto *item = ui->listWidget->currentItem())
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
sourceItem.alias = text;
|
||||||
|
|
||||||
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
|
|
||||||
|
ValidateSourceAliases();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::ShowVisualization()
|
void DialogMove::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -565,10 +617,22 @@ void DialogMove::SaveData()
|
||||||
formulaRotationAngle = ui->plainTextEditRotationAngle->toPlainText();
|
formulaRotationAngle = ui->plainTextEditRotationAngle->toPlainText();
|
||||||
formulaLength = ui->plainTextEditLength->toPlainText();
|
formulaLength = ui->plainTextEditLength->toPlainText();
|
||||||
|
|
||||||
|
sourceObjects.clear();
|
||||||
|
sourceObjects.reserve(ui->listWidget->count());
|
||||||
|
|
||||||
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
sourceObjects.append(sourceItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
|
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
operation->SetAngle(formulaAngle);
|
operation->SetAngle(formulaAngle);
|
||||||
operation->SetLength(formulaLength);
|
operation->SetLength(formulaLength);
|
||||||
operation->SetRotationAngle(formulaRotationAngle);
|
operation->SetRotationAngle(formulaRotationAngle);
|
||||||
|
@ -597,6 +661,23 @@ void DialogMove::closeEvent(QCloseEvent *event)
|
||||||
DialogTool::closeEvent(event);
|
DialogTool::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<SourceItem> DialogMove::GetSourceObjects() const
|
||||||
|
{
|
||||||
|
return sourceObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::SetSourceObjects(const QVector<SourceItem> &value)
|
||||||
|
{
|
||||||
|
sourceObjects = value;
|
||||||
|
FillSourceList();
|
||||||
|
|
||||||
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
||||||
|
SCASSERT(operation != nullptr)
|
||||||
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::EvalAngle()
|
void DialogMove::EvalAngle()
|
||||||
{
|
{
|
||||||
|
@ -609,6 +690,11 @@ void DialogMove::EvalAngle()
|
||||||
formulaData.checkZero = false;
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
Eval(formulaData, flagAngle);
|
Eval(formulaData, flagAngle);
|
||||||
|
|
||||||
|
if (not flagAngle)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Invalid angle formula"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -623,6 +709,11 @@ void DialogMove::EvalRotationAngle()
|
||||||
formulaData.checkZero = false;
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
Eval(formulaData, flagRotationAngle);
|
Eval(formulaData, flagRotationAngle);
|
||||||
|
|
||||||
|
if (not flagRotationAngle)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Invalid rotation angle formula"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -636,6 +727,89 @@ void DialogMove::EvalLength()
|
||||||
formulaData.postfix = UnitsToStr(qApp->patternUnits(), true);
|
formulaData.postfix = UnitsToStr(qApp->patternUnits(), true);
|
||||||
|
|
||||||
Eval(formulaData, flagLength);
|
Eval(formulaData, flagLength);
|
||||||
|
|
||||||
|
if (not flagLength)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Invalid length formula"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::FillSourceList()
|
||||||
|
{
|
||||||
|
ui->listWidget->blockSignals(true);
|
||||||
|
|
||||||
|
ui->listWidget->clear();
|
||||||
|
|
||||||
|
int row = -1;
|
||||||
|
|
||||||
|
for (auto &sourceItem : sourceObjects)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
|
||||||
|
|
||||||
|
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
item->setToolTip(obj->ObjectName());
|
||||||
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
|
ui->listWidget->insertItem(++row, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->listWidget->blockSignals(false);
|
||||||
|
|
||||||
|
if (ui->listWidget->count() > 0)
|
||||||
|
{
|
||||||
|
ui->listWidget->setCurrentRow(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidateSourceAliases();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::ValidateSourceAliases()
|
||||||
|
{
|
||||||
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
|
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
|
||||||
|
{
|
||||||
|
flagAlias = false;
|
||||||
|
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
|
||||||
|
SetAliasValid(sourceItem.id, false);
|
||||||
|
CheckState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAliasValid(sourceItem.id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flagAlias = true;
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::SetAliasValid(quint32 id, bool valid)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->currentRow() != -1)
|
||||||
|
{
|
||||||
|
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
if (id == sourceItem.id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
|
||||||
|
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -649,3 +823,16 @@ QString DialogMove::GetNotes() const
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogMove::IsValid() const
|
||||||
|
{
|
||||||
|
bool ready = flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName && flagAlias;
|
||||||
|
|
||||||
|
if (ready)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Ready"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
|
#include "../../tools/toolsdef.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -68,8 +69,6 @@ public:
|
||||||
quint32 GetRotationOrigPointId() const;
|
quint32 GetRotationOrigPointId() const;
|
||||||
void SetRotationOrigPointId(const quint32 &value);
|
void SetRotationOrigPointId(const quint32 &value);
|
||||||
|
|
||||||
QVector<quint32> GetObjects() const;
|
|
||||||
|
|
||||||
QString GetVisibilityGroupName() const;
|
QString GetVisibilityGroupName() const;
|
||||||
void SetVisibilityGroupName(const QString &name);
|
void SetVisibilityGroupName(const QString &name);
|
||||||
|
|
||||||
|
@ -86,6 +85,9 @@ public:
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
|
QVector<SourceItem> GetSourceObjects() const;
|
||||||
|
void SetSourceObjects(const QVector<SourceItem> &value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
||||||
|
@ -103,6 +105,9 @@ private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
void GroupNameChanged();
|
void GroupNameChanged();
|
||||||
|
|
||||||
|
void ShowSourceDetails(int row);
|
||||||
|
void AliasChanged(const QString &text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
|
||||||
|
@ -130,7 +135,7 @@ private:
|
||||||
int formulaBaseHeightRotationAngle;
|
int formulaBaseHeightRotationAngle;
|
||||||
int formulaBaseHeightLength;
|
int formulaBaseHeightLength;
|
||||||
|
|
||||||
QList<quint32> objects;
|
QVector<SourceItem> sourceObjects{};
|
||||||
|
|
||||||
bool stage1;
|
bool stage1;
|
||||||
bool stage2;
|
bool stage2;
|
||||||
|
@ -145,18 +150,18 @@ private:
|
||||||
bool flagLength;
|
bool flagLength;
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
|
bool flagAlias{true};
|
||||||
|
|
||||||
QStringList m_groupTags{};
|
QStringList m_groupTags{};
|
||||||
|
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
void EvalRotationAngle();
|
void EvalRotationAngle();
|
||||||
void EvalLength();
|
void EvalLength();
|
||||||
|
|
||||||
|
void FillSourceList();
|
||||||
|
|
||||||
|
void ValidateSourceAliases();
|
||||||
|
void SetAliasValid(quint32 id, bool valid);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline bool DialogMove::IsValid() const
|
|
||||||
{
|
|
||||||
return flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DIALOGMOVING_H
|
#endif // DIALOGMOVING_H
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>DialogMove</class>
|
<class>DialogMove</class>
|
||||||
<widget class="QDialog" name="DialogMove">
|
<widget class="QDialog" name="DialogMove">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>411</width>
|
<width>536</width>
|
||||||
<height>498</height>
|
<height>669</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -28,6 +31,39 @@
|
||||||
<string>Tool</string>
|
<string>Tool</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QListWidget" name="listWidget">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::CurrentChanged</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="formLayoutWidget">
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelAlias">
|
||||||
|
<property name="text">
|
||||||
|
<string>Alias:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditAlias">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
|
@ -656,6 +692,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelStatus">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ready</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -72,7 +72,6 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
|
||||||
timerAngle(new QTimer(this)),
|
timerAngle(new QTimer(this)),
|
||||||
formulaAngle(),
|
formulaAngle(),
|
||||||
formulaBaseHeightAngle(0),
|
formulaBaseHeightAngle(0),
|
||||||
objects(),
|
|
||||||
stage1(true),
|
stage1(true),
|
||||||
m_suffix(),
|
m_suffix(),
|
||||||
m_firstRelease(false),
|
m_firstRelease(false),
|
||||||
|
@ -170,12 +169,6 @@ void DialogRotation::SetSuffix(const QString &value)
|
||||||
ui->lineEditSuffix->setText(value);
|
ui->lineEditSuffix->setText(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<quint32> DialogRotation::GetObjects() const
|
|
||||||
{
|
|
||||||
return ConvertToVector(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogRotation::GetVisibilityGroupName() const
|
QString DialogRotation::GetVisibilityGroupName() const
|
||||||
{
|
{
|
||||||
|
@ -224,7 +217,7 @@ void DialogRotation::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
if (stage1 && not click)
|
if (stage1 && not click)
|
||||||
{
|
{
|
||||||
if (objects.isEmpty())
|
if (sourceObjects.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +230,7 @@ void DialogRotation::ShowDialog(bool click)
|
||||||
|
|
||||||
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
operation->VisualMode();
|
operation->VisualMode();
|
||||||
|
|
||||||
scene->ToggleArcSelection(false);
|
scene->ToggleArcSelection(false);
|
||||||
|
@ -252,6 +245,8 @@ void DialogRotation::ShowDialog(bool click)
|
||||||
|
|
||||||
qApp->getSceneView()->AllowRubberBand(false);
|
qApp->getSceneView()->AllowRubberBand(false);
|
||||||
|
|
||||||
|
FillSourceList();
|
||||||
|
|
||||||
emit ToolTip(tr("Select origin point"));
|
emit ToolTip(tr("Select origin point"));
|
||||||
}
|
}
|
||||||
else if (not stage1 && prepare && click)
|
else if (not stage1 && prepare && click)
|
||||||
|
@ -294,6 +289,23 @@ void DialogRotation::ShowDialog(bool click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<SourceItem> DialogRotation::GetSourceObjects() const
|
||||||
|
{
|
||||||
|
return sourceObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetSourceObjects(const QVector<SourceItem> &value)
|
||||||
|
{
|
||||||
|
sourceObjects = value;
|
||||||
|
FillSourceList();
|
||||||
|
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr)
|
||||||
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
|
@ -304,14 +316,17 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
|
|
||||||
if (objects.contains(id))
|
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[id](const SourceItem &sItem) { return sItem.id == id; });
|
||||||
|
|
||||||
|
if (obj != sourceObjects.end())
|
||||||
{
|
{
|
||||||
if (objects.size() > 1)
|
if (sourceObjects.size() > 1)
|
||||||
{
|
{
|
||||||
// It's not really logical for a user that a center of rotation no need to select.
|
// It's not really logical for a user that a center of rotation no need to select.
|
||||||
// To fix this issue we just silently remove it from the list.
|
// To fix this issue we just silently remove it from the list.
|
||||||
objects.removeOne(id);
|
sourceObjects.erase(obj);
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -341,16 +356,23 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||||
Q_UNUSED(tool)
|
Q_UNUSED(tool)
|
||||||
if (stage1)
|
if (stage1)
|
||||||
{
|
{
|
||||||
|
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[object](const SourceItem &sItem) { return sItem.id == object; });
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
if (not objects.contains(object))
|
if (obj == sourceObjects.cend())
|
||||||
{
|
{
|
||||||
objects.append(object);
|
SourceItem item;
|
||||||
|
item.id = object;
|
||||||
|
sourceObjects.append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objects.removeOne(object);
|
if (obj != sourceObjects.end())
|
||||||
|
{
|
||||||
|
sourceObjects.erase(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,6 +408,7 @@ void DialogRotation::SuffixChanged()
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, errorColor);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid suffix"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -402,6 +425,7 @@ void DialogRotation::SuffixChanged()
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, errorColor);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid suffix"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -426,6 +450,7 @@ void DialogRotation::GroupNameChanged()
|
||||||
{
|
{
|
||||||
flagGroupName = false;
|
flagGroupName = false;
|
||||||
ChangeColor(ui->labelGroupName, errorColor);
|
ChangeColor(ui->labelGroupName, errorColor);
|
||||||
|
ui->labelStatus->setText(tr("Invalid group name"));
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -448,10 +473,22 @@ void DialogRotation::SaveData()
|
||||||
m_suffix = ui->lineEditSuffix->text();
|
m_suffix = ui->lineEditSuffix->text();
|
||||||
formulaAngle = ui->plainTextEditFormula->toPlainText();
|
formulaAngle = ui->plainTextEditFormula->toPlainText();
|
||||||
|
|
||||||
|
sourceObjects.clear();
|
||||||
|
sourceObjects.reserve(ui->listWidget->count());
|
||||||
|
|
||||||
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
sourceObjects.append(sourceItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
SCASSERT(operation != nullptr)
|
SCASSERT(operation != nullptr)
|
||||||
|
|
||||||
operation->SetObjects(ConvertToVector(objects));
|
operation->SetObjects(SourceToObjects(sourceObjects));
|
||||||
operation->SetOriginPointId(GetOrigPointId());
|
operation->SetOriginPointId(GetOrigPointId());
|
||||||
operation->SetAngle(formulaAngle);
|
operation->SetAngle(formulaAngle);
|
||||||
operation->RefreshGeometry();
|
operation->RefreshGeometry();
|
||||||
|
@ -479,11 +516,17 @@ void DialogRotation::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::PointChanged()
|
void DialogRotation::PointChanged()
|
||||||
{
|
{
|
||||||
|
quint32 id = getCurrentObjectId(ui->comboBoxOriginPoint);
|
||||||
|
|
||||||
|
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
|
||||||
|
[id](const SourceItem &sItem) { return sItem.id == id; });
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
|
if (obj != sourceObjects.end())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
|
ui->labelStatus->setText(tr("Invalid rotation point"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -494,6 +537,84 @@ void DialogRotation::PointChanged()
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::FillSourceList()
|
||||||
|
{
|
||||||
|
ui->listWidget->blockSignals(true);
|
||||||
|
|
||||||
|
ui->listWidget->clear();
|
||||||
|
|
||||||
|
int row = -1;
|
||||||
|
|
||||||
|
for (auto &sourceItem : sourceObjects)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
|
||||||
|
|
||||||
|
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
item->setToolTip(obj->ObjectName());
|
||||||
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
|
ui->listWidget->insertItem(++row, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->listWidget->blockSignals(false);
|
||||||
|
|
||||||
|
if (ui->listWidget->count() > 0)
|
||||||
|
{
|
||||||
|
ui->listWidget->setCurrentRow(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidateSourceAliases();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::ValidateSourceAliases()
|
||||||
|
{
|
||||||
|
for (int i=0; i<ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
if (const QListWidgetItem *item = ui->listWidget->item(i))
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
|
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
|
||||||
|
{
|
||||||
|
flagAlias = false;
|
||||||
|
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
|
||||||
|
SetAliasValid(sourceItem.id, false);
|
||||||
|
CheckState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAliasValid(sourceItem.id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flagAlias = true;
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetAliasValid(quint32 id, bool valid)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->currentRow() != -1)
|
||||||
|
{
|
||||||
|
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
|
if (id == sourceItem.id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
|
||||||
|
|
||||||
|
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::EvalAngle()
|
void DialogRotation::EvalAngle()
|
||||||
{
|
{
|
||||||
|
@ -506,6 +627,55 @@ void DialogRotation::EvalAngle()
|
||||||
formulaData.checkZero = false;
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
Eval(formulaData, flagAngle);
|
Eval(formulaData, flagAngle);
|
||||||
|
|
||||||
|
if (not flagAngle)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Invalid angle formula"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::ShowSourceDetails(int row)
|
||||||
|
{
|
||||||
|
ui->lineEditAlias->setDisabled(true);
|
||||||
|
|
||||||
|
if (ui->listWidget->count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
|
||||||
|
|
||||||
|
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
|
||||||
|
|
||||||
|
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
|
||||||
|
|
||||||
|
ui->lineEditAlias->blockSignals(true);
|
||||||
|
ui->lineEditAlias->setText(sourceItem.alias);
|
||||||
|
ui->lineEditAlias->setEnabled(true);
|
||||||
|
ui->lineEditAlias->blockSignals(false);
|
||||||
|
|
||||||
|
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
|
||||||
|
OriginAlias(sourceItem.id, sourceObjects, obj)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::AliasChanged(const QString &text)
|
||||||
|
{
|
||||||
|
if (ui->listWidget->count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto *item = ui->listWidget->currentItem())
|
||||||
|
{
|
||||||
|
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
|
||||||
|
sourceItem.alias = text;
|
||||||
|
|
||||||
|
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
|
||||||
|
|
||||||
|
ValidateSourceAliases();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -519,3 +689,16 @@ QString DialogRotation::GetNotes() const
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogRotation::IsValid() const
|
||||||
|
{
|
||||||
|
bool ready = flagAngle && flagName && flagError && flagGroupName && flagAlias;
|
||||||
|
|
||||||
|
if (ready)
|
||||||
|
{
|
||||||
|
ui->labelStatus->setText(tr("Ready"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
|
#include "../../tools/toolsdef.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -61,8 +62,6 @@ public:
|
||||||
QString GetSuffix() const;
|
QString GetSuffix() const;
|
||||||
void SetSuffix(const QString &value);
|
void SetSuffix(const QString &value);
|
||||||
|
|
||||||
QVector<quint32> GetObjects() const;
|
|
||||||
|
|
||||||
QString GetVisibilityGroupName() const;
|
QString GetVisibilityGroupName() const;
|
||||||
void SetVisibilityGroupName(const QString &name);
|
void SetVisibilityGroupName(const QString &name);
|
||||||
|
|
||||||
|
@ -79,6 +78,9 @@ public:
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
|
QVector<SourceItem> GetSourceObjects() const;
|
||||||
|
void SetSourceObjects(const QVector<SourceItem> &value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
||||||
|
@ -90,6 +92,8 @@ private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
void GroupNameChanged();
|
void GroupNameChanged();
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
|
void ShowSourceDetails(int row);
|
||||||
|
void AliasChanged(const QString &text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
@ -115,7 +119,7 @@ private:
|
||||||
/** @brief formulaBaseHeightAngle base height defined by dialogui */
|
/** @brief formulaBaseHeightAngle base height defined by dialogui */
|
||||||
int formulaBaseHeightAngle;
|
int formulaBaseHeightAngle;
|
||||||
|
|
||||||
QList<quint32> objects;
|
QVector<SourceItem> sourceObjects{};
|
||||||
|
|
||||||
bool stage1;
|
bool stage1;
|
||||||
|
|
||||||
|
@ -128,14 +132,14 @@ private:
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
bool flagError;
|
bool flagError;
|
||||||
|
bool flagAlias{true};
|
||||||
|
|
||||||
QStringList m_groupTags{};
|
QStringList m_groupTags{};
|
||||||
|
|
||||||
|
void FillSourceList();
|
||||||
|
|
||||||
|
void ValidateSourceAliases();
|
||||||
|
void SetAliasValid(quint32 id, bool valid);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline bool DialogRotation::IsValid() const
|
|
||||||
{
|
|
||||||
return flagAngle && flagName && flagError && flagGroupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DIALOGROTATION_H
|
#endif // DIALOGROTATION_H
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>304</width>
|
<width>410</width>
|
||||||
<height>338</height>
|
<height>485</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -28,6 +28,35 @@
|
||||||
<string>Tool</string>
|
<string>Tool</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QListWidget" name="listWidget"/>
|
||||||
|
<widget class="QWidget" name="formLayoutWidget">
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelAlias">
|
||||||
|
<property name="text">
|
||||||
|
<string>Alias</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditAlias">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
|
@ -287,6 +316,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelStatus">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ready</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -38,12 +38,9 @@
|
||||||
#include "../vgeometry/vsplinepath.h"
|
#include "../vgeometry/vsplinepath.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
VAbstractFlipping::VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent)
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
: VAbstractOperation(initData, parent)
|
||||||
const QString ¬es, QGraphicsItem *parent)
|
{}
|
||||||
: VAbstractOperation(doc, data, id, suffix, source, destination, notes, parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint,
|
void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint,
|
||||||
|
@ -55,9 +52,9 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData,
|
||||||
|
|
||||||
initData.id = initData.data->getNextId();//Just reserve id for tool
|
initData.id = initData.data->getNextId();//Just reserve id for tool
|
||||||
|
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -67,32 +64,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
initData.destination.append(CreatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
initData.destination.append(CreatePoint(initData.id, object, fPoint, sPoint, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
initData.destination.append(CreateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
initData.destination.append(CreateArc<VArc>(initData.id, object, fPoint, sPoint, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint,
|
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, object, fPoint, sPoint,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, fPoint, sPoint,
|
initData.destination.append(CreateCurve<VSpline>(initData.id, object, fPoint, sPoint,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint,
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, fPoint,
|
||||||
sPoint, initData.suffix,
|
sPoint, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint,
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, fPoint, sPoint,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint,
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object, fPoint,
|
||||||
sPoint, initData.suffix,
|
sPoint, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
|
@ -108,8 +105,8 @@ QT_WARNING_POP
|
||||||
{
|
{
|
||||||
for (int i = 0; i < initData.source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = initData.source.at(i);
|
const SourceItem object = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -121,31 +118,31 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
{
|
{
|
||||||
const DestinationItem &item = initData.destination.at(i);
|
const DestinationItem &item = initData.destination.at(i);
|
||||||
UpdatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, item);
|
UpdatePoint(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
UpdateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
UpdateArc<VArc>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
UpdateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
UpdateArc<VEllipticalArc>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
UpdateCurve<VSpline>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
UpdateCurveWithSegments<VSplinePath>(initData.id, object, fPoint, sPoint, initData.suffix,
|
||||||
initData.data, initData.destination.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
UpdateCurve<VCubicBezier>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, fPoint, sPoint, initData.suffix,
|
||||||
initData.data, initData.destination.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
|
@ -163,13 +160,18 @@ QT_WARNING_POP
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
|
||||||
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
|
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.setName(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
DestinationItem item;
|
DestinationItem item;
|
||||||
item.mx = rotated.mx();
|
item.mx = rotated.mx();
|
||||||
item.my = rotated.my();
|
item.my = rotated.my();
|
||||||
|
@ -180,33 +182,39 @@ DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, c
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data);
|
||||||
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractFlipping::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
void VAbstractFlipping::UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
||||||
const DestinationItem &item)
|
const DestinationItem &item)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
|
||||||
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
|
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
rotated.setMx(item.mx);
|
rotated.setMx(item.mx);
|
||||||
rotated.setMy(item.my);
|
rotated.setMy(item.my);
|
||||||
rotated.SetShowLabel(item.showLabel);
|
rotated.SetShowLabel(item.showLabel);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.setName(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
data->UpdateGObject(item.id, new VPointF(rotated));
|
data->UpdateGObject(item.id, new VPointF(rotated));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VAbstractFlipping::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
void VAbstractFlipping::UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QString &suffix, VContainer *data, quint32 id)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data, id);
|
||||||
data->AddArc(data->GeometricObject<Item>(id), id);
|
data->AddArc(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,41 +39,40 @@ class VAbstractFlipping : public VAbstractOperation
|
||||||
public:
|
public:
|
||||||
virtual ~VAbstractFlipping() Q_DECL_EQ_DEFAULT;
|
virtual ~VAbstractFlipping() Q_DECL_EQ_DEFAULT;
|
||||||
protected:
|
protected:
|
||||||
VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
explicit VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination, const QString ¬es,
|
|
||||||
QGraphicsItem *parent = nullptr);
|
|
||||||
|
|
||||||
static void CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, const QPointF &sPoint);
|
static void CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, const QPointF &sPoint);
|
||||||
|
|
||||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
static void UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QString &suffix, VContainer *data, const DestinationItem &item);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
||||||
|
const DestinationItem &item);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
static void UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
static void UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
static void UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
||||||
quint32 id);
|
quint32 id);
|
||||||
private:
|
private:
|
||||||
|
@ -82,13 +81,18 @@ private:
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
|
||||||
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
|
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.SetAliasSuffix(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
DestinationItem item;
|
DestinationItem item;
|
||||||
item.mx = INT_MAX;
|
item.mx = INT_MAX;
|
||||||
item.my = INT_MAX;
|
item.my = INT_MAX;
|
||||||
|
@ -98,52 +102,58 @@ DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, co
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data);
|
||||||
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem,
|
||||||
const QPointF &secondPoint, const QString &suffix,
|
const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
VContainer *data)
|
const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VAbstractFlipping::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
void VAbstractFlipping::UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
|
||||||
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
|
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.SetAliasSuffix(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
data->UpdateGObject(id, new Item(rotated));
|
data->UpdateGObject(id, new Item(rotated));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VAbstractFlipping::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
void VAbstractFlipping::UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
|
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data, id);
|
||||||
data->AddSpline(data->GeometricObject<Item>(id), id);
|
data->AddSpline(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
||||||
quint32 id)
|
quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data, id);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ void VToolFlippingByAxis::setDialog()
|
||||||
dialogTool->SetAxisType(m_axisType);
|
dialogTool->SetAxisType(m_axisType);
|
||||||
dialogTool->SetSuffix(suffix);
|
dialogTool->SetSuffix(suffix);
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
|
dialogTool->SetSourceObjects(source);
|
||||||
|
|
||||||
SetDialogVisibilityGroupData(dialogTool);
|
SetDialogVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +92,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer<DialogTool> &dia
|
||||||
initData.originPointId = dialogTool->GetOriginPointId();
|
initData.originPointId = dialogTool->GetOriginPointId();
|
||||||
initData.axisType = dialogTool->GetAxisType();
|
initData.axisType = dialogTool->GetAxisType();
|
||||||
initData.suffix = dialogTool->GetSuffix();
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetSourceObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
|
@ -141,9 +142,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
|
||||||
InitOperationToolConnections(initData.scene, tool);
|
InitOperationToolConnections(initData.scene, tool);
|
||||||
VAbstractPattern::AddTool(initData.id, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
initData.doc->IncrementReferens(originPoint.getIdTool());
|
initData.doc->IncrementReferens(originPoint.getIdTool());
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
||||||
|
@ -206,7 +207,7 @@ void VToolFlippingByAxis::SetVisualization()
|
||||||
VisToolFlippingByAxis *visual = qobject_cast<VisToolFlippingByAxis *>(vis);
|
VisToolFlippingByAxis *visual = qobject_cast<VisToolFlippingByAxis *>(vis);
|
||||||
SCASSERT(visual != nullptr)
|
SCASSERT(visual != nullptr)
|
||||||
|
|
||||||
visual->SetObjects(source);
|
visual->SetObjects(SourceToObjects(source));
|
||||||
visual->SetOriginPointId(m_originPointId);
|
visual->SetOriginPointId(m_originPointId);
|
||||||
visual->SetAxisType(m_axisType);
|
visual->SetAxisType(m_axisType);
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
@ -231,6 +232,9 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList<quint32> &ol
|
||||||
const QString notes = dialogTool->GetNotes();
|
const QString notes = dialogTool->GetNotes();
|
||||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||||
|
|
||||||
|
source = dialogTool->GetSourceObjects();
|
||||||
|
SaveSourceDestination(domElement);
|
||||||
|
|
||||||
// Save visibility data for later use
|
// Save visibility data for later use
|
||||||
SaveVisibilityGroupData(dialogTool);
|
SaveVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +246,6 @@ void VToolFlippingByAxis::ReadToolAttributes(const QDomElement &domElement)
|
||||||
|
|
||||||
m_originPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
m_originPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
||||||
m_axisType = static_cast<AxisType>(doc->GetParametrUInt(domElement, AttrAxisType, QChar('1')));
|
m_axisType = static_cast<AxisType>(doc->GetParametrUInt(domElement, AttrAxisType, QChar('1')));
|
||||||
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -253,9 +256,6 @@ void VToolFlippingByAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
||||||
doc->SetAttribute(tag, AttrType, ToolType);
|
doc->SetAttribute(tag, AttrType, ToolType);
|
||||||
doc->SetAttribute(tag, AttrCenter, QString().setNum(m_originPointId));
|
doc->SetAttribute(tag, AttrCenter, QString().setNum(m_originPointId));
|
||||||
doc->SetAttribute(tag, AttrAxisType, QString().setNum(static_cast<int>(m_axisType)));
|
doc->SetAttribute(tag, AttrAxisType, QString().setNum(static_cast<int>(m_axisType)));
|
||||||
doc->SetAttribute(tag, AttrSuffix, suffix);
|
|
||||||
|
|
||||||
SaveSourceDestination(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -269,8 +269,7 @@ QString VToolFlippingByAxis::MakeToolTip() const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
|
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
: VAbstractFlipping(initData, parent),
|
||||||
initData.destination, initData.notes, parent),
|
|
||||||
m_originPointId(initData.originPointId),
|
m_originPointId(initData.originPointId),
|
||||||
m_axisType(initData.axisType)
|
m_axisType(initData.axisType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,7 @@ void VToolFlippingByLine::setDialog()
|
||||||
dialogTool->SetSecondLinePointId(m_secondLinePointId);
|
dialogTool->SetSecondLinePointId(m_secondLinePointId);
|
||||||
dialogTool->SetSuffix(suffix);
|
dialogTool->SetSuffix(suffix);
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
|
dialogTool->SetSourceObjects(source);
|
||||||
|
|
||||||
SetDialogVisibilityGroupData(dialogTool);
|
SetDialogVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +92,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer<DialogTool> &dia
|
||||||
initData.firstLinePointId = dialogTool->GetFirstLinePointId();
|
initData.firstLinePointId = dialogTool->GetFirstLinePointId();
|
||||||
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
|
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
|
||||||
initData.suffix = dialogTool->GetSuffix();
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetSourceObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
|
@ -135,9 +136,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
|
||||||
VAbstractPattern::AddTool(initData.id, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
initData.doc->IncrementReferens(firstPoint.getIdTool());
|
initData.doc->IncrementReferens(firstPoint.getIdTool());
|
||||||
initData.doc->IncrementReferens(secondPoint.getIdTool());
|
initData.doc->IncrementReferens(secondPoint.getIdTool());
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
||||||
|
@ -191,7 +192,7 @@ void VToolFlippingByLine::SetVisualization()
|
||||||
VisToolFlippingByLine *visual = qobject_cast<VisToolFlippingByLine *>(vis);
|
VisToolFlippingByLine *visual = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||||
SCASSERT(visual != nullptr)
|
SCASSERT(visual != nullptr)
|
||||||
|
|
||||||
visual->SetObjects(source);
|
visual->SetObjects(SourceToObjects(source));
|
||||||
visual->SetFirstLinePointId(m_firstLinePointId);
|
visual->SetFirstLinePointId(m_firstLinePointId);
|
||||||
visual->SetSecondLinePointId(m_secondLinePointId);
|
visual->SetSecondLinePointId(m_secondLinePointId);
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
@ -218,6 +219,9 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList<quint32> &ol
|
||||||
const QString notes = dialogTool->GetNotes();
|
const QString notes = dialogTool->GetNotes();
|
||||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||||
|
|
||||||
|
source = dialogTool->GetSourceObjects();
|
||||||
|
SaveSourceDestination(domElement);
|
||||||
|
|
||||||
// Save visibility data for later use
|
// Save visibility data for later use
|
||||||
SaveVisibilityGroupData(dialogTool);
|
SaveVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +233,6 @@ void VToolFlippingByLine::ReadToolAttributes(const QDomElement &domElement)
|
||||||
|
|
||||||
m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
||||||
m_secondLinePointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
m_secondLinePointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
||||||
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -240,9 +243,6 @@ void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
||||||
doc->SetAttribute(tag, AttrType, ToolType);
|
doc->SetAttribute(tag, AttrType, ToolType);
|
||||||
doc->SetAttribute(tag, AttrP1Line, QString().setNum(m_firstLinePointId));
|
doc->SetAttribute(tag, AttrP1Line, QString().setNum(m_firstLinePointId));
|
||||||
doc->SetAttribute(tag, AttrP2Line, QString().setNum(m_secondLinePointId));
|
doc->SetAttribute(tag, AttrP2Line, QString().setNum(m_secondLinePointId));
|
||||||
doc->SetAttribute(tag, AttrSuffix, suffix);
|
|
||||||
|
|
||||||
SaveSourceDestination(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -258,8 +258,7 @@ QString VToolFlippingByLine::MakeToolTip() const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
|
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
: VAbstractFlipping(initData, parent),
|
||||||
initData.destination, initData.notes, parent),
|
|
||||||
m_firstLinePointId(initData.firstLinePointId),
|
m_firstLinePointId(initData.firstLinePointId),
|
||||||
m_secondLinePointId(initData.secondLinePointId)
|
m_secondLinePointId(initData.secondLinePointId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,15 +46,15 @@ namespace
|
||||||
* @param source list with source objects
|
* @param source list with source objects
|
||||||
* @return visibility group data
|
* @return visibility group data
|
||||||
*/
|
*/
|
||||||
QMap<quint32, quint32> VisibilityGroupDataFromSource(const VContainer *data, const QVector<quint32> &source)
|
QMap<quint32, quint32> VisibilityGroupDataFromSource(const VContainer *data, const QVector<SourceItem> &source)
|
||||||
{
|
{
|
||||||
QMap<quint32, quint32> groupData;
|
QMap<quint32, quint32> groupData;
|
||||||
|
|
||||||
for (auto &sId : source)
|
for (auto &sItem : source)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
groupData.insert(sId, data->GetGObject(sId)->getIdTool());
|
groupData.insert(sItem.id, data->GetGObject(sItem.id)->getIdTool());
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &)
|
catch (const VExceptionBadId &)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ QVector<QString> VAbstractOperation::SourceItems() const
|
||||||
{
|
{
|
||||||
for (auto &item : source)
|
for (auto &item : source)
|
||||||
{
|
{
|
||||||
itemNames.append(VAbstractTool::data.GetGObject(item)->name());
|
itemNames.append(VAbstractTool::data.GetGObject(item.id)->ObjectName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
|
@ -201,27 +201,49 @@ void VAbstractOperation::SetLabelVisible(quint32 id, bool visible)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData)
|
void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData)
|
||||||
{
|
{
|
||||||
|
initData.source = ExtractSourceData(domElement);
|
||||||
|
initData.destination = ExtractDestinationData(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<SourceItem> VAbstractOperation::ExtractSourceData(const QDomElement &domElement)
|
||||||
|
{
|
||||||
|
QVector<SourceItem> source;
|
||||||
const QDomNodeList nodeList = domElement.childNodes();
|
const QDomNodeList nodeList = domElement.childNodes();
|
||||||
for (qint32 i = 0; i < nodeList.size(); ++i)
|
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||||
{
|
{
|
||||||
const QDomElement dataElement = nodeList.at(i).toElement();
|
const QDomElement dataElement = nodeList.at(i).toElement();
|
||||||
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
||||||
{
|
{
|
||||||
initData.source.clear();
|
|
||||||
const QDomNodeList srcList = dataElement.childNodes();
|
const QDomNodeList srcList = dataElement.childNodes();
|
||||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||||
{
|
{
|
||||||
const QDomElement element = srcList.at(j).toElement();
|
const QDomElement element = srcList.at(j).toElement();
|
||||||
if (not element.isNull())
|
if (not element.isNull())
|
||||||
{
|
{
|
||||||
initData.source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
SourceItem item;
|
||||||
|
item.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
|
||||||
|
item.alias = VDomDocument::GetParametrEmptyString(element, AttrAlias);
|
||||||
|
source.append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return source;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<DestinationItem> VAbstractOperation::ExtractDestinationData(const QDomElement &domElement)
|
||||||
|
{
|
||||||
|
QVector<DestinationItem> destination;
|
||||||
|
const QDomNodeList nodeList = domElement.childNodes();
|
||||||
|
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement dataElement = nodeList.at(i).toElement();
|
||||||
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
||||||
{
|
{
|
||||||
initData.destination.clear();
|
|
||||||
const QDomNodeList srcList = dataElement.childNodes();
|
const QDomNodeList srcList = dataElement.childNodes();
|
||||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||||
{
|
{
|
||||||
|
@ -233,11 +255,15 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOpe
|
||||||
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
||||||
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
||||||
d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr);
|
d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr);
|
||||||
initData.destination.append(d);
|
destination.append(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return destination;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -520,17 +546,15 @@ void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
VAbstractOperation::VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent)
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
: VDrawTool(initData.doc, initData.data, initData.id, initData.notes),
|
||||||
const QString ¬es, QGraphicsItem *parent)
|
|
||||||
: VDrawTool(doc, data, id, notes),
|
|
||||||
QGraphicsLineItem(parent),
|
QGraphicsLineItem(parent),
|
||||||
suffix(suffix),
|
suffix(initData.suffix),
|
||||||
source(source),
|
source(initData.source),
|
||||||
destination(destination),
|
destination(initData.destination),
|
||||||
operatedObjects()
|
operatedObjects()
|
||||||
{
|
{
|
||||||
connect(doc, &VAbstractPattern::UpdateToolTip, this, [this]()
|
connect(initData.doc, &VAbstractPattern::UpdateToolTip, this, [this]()
|
||||||
{
|
{
|
||||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
|
@ -669,6 +693,26 @@ void VAbstractOperation::PerformDelete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractOperation::ReadToolAttributes(const QDomElement &domElement)
|
||||||
|
{
|
||||||
|
VDrawTool::ReadToolAttributes(domElement);
|
||||||
|
|
||||||
|
source = ExtractSourceData(domElement);
|
||||||
|
destination = ExtractDestinationData(domElement);
|
||||||
|
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractOperation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||||
|
{
|
||||||
|
VDrawTool::SaveOptions(tag, obj);
|
||||||
|
|
||||||
|
doc->SetAttribute(tag, AttrSuffix, suffix);
|
||||||
|
|
||||||
|
SaveSourceDestination(tag);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
|
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
|
||||||
{
|
{
|
||||||
|
@ -695,10 +739,11 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
|
||||||
doc->RemoveAllChildren(tag);
|
doc->RemoveAllChildren(tag);
|
||||||
|
|
||||||
QDomElement tagObjects = doc->createElement(TagSource);
|
QDomElement tagObjects = doc->createElement(TagSource);
|
||||||
for (auto id : qAsConst(source))
|
for (auto sItem : qAsConst(source))
|
||||||
{
|
{
|
||||||
QDomElement item = doc->createElement(TagItem);
|
QDomElement item = doc->createElement(TagItem);
|
||||||
doc->SetAttribute(item, AttrIdObject, id);
|
doc->SetAttribute(item, AttrIdObject, sItem.id);
|
||||||
|
doc->SetAttributeOrRemoveIf(item, AttrAlias, sItem.alias, sItem.alias.isEmpty());
|
||||||
tagObjects.appendChild(item);
|
tagObjects.appendChild(item);
|
||||||
}
|
}
|
||||||
tag.appendChild(tagObjects);
|
tag.appendChild(tagObjects);
|
||||||
|
@ -709,13 +754,13 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
|
||||||
QDomElement item = doc->createElement(TagItem);
|
QDomElement item = doc->createElement(TagItem);
|
||||||
doc->SetAttribute(item, AttrIdObject, dItem.id);
|
doc->SetAttribute(item, AttrIdObject, dItem.id);
|
||||||
|
|
||||||
if (not VFuzzyComparePossibleNulls(dItem.mx, INT_MAX) &&
|
VAbstractSimple *obj = operatedObjects.value(dItem.id);
|
||||||
not VFuzzyComparePossibleNulls(dItem.my, INT_MAX))
|
|
||||||
{
|
doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx),
|
||||||
doc->SetAttribute(item, AttrMx, qApp->fromPixel(dItem.mx));
|
obj && obj->GetType() != GOType::Point);
|
||||||
doc->SetAttribute(item, AttrMy, qApp->fromPixel(dItem.my));
|
doc->SetAttributeOrRemoveIf(item, AttrMy, qApp->fromPixel(dItem.my),
|
||||||
doc->SetAttribute<bool>(item, AttrShowLabel, dItem.showLabel);
|
obj && obj->GetType() != GOType::Point);
|
||||||
}
|
doc->SetAttributeOrRemoveIf<bool>(item, AttrShowLabel, dItem.showLabel, dItem.showLabel);
|
||||||
|
|
||||||
tagObjects.appendChild(item);
|
tagObjects.appendChild(item);
|
||||||
}
|
}
|
||||||
|
@ -888,7 +933,7 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const
|
||||||
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
|
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
|
||||||
"%6"
|
"%6"
|
||||||
"</table>")
|
"</table>")
|
||||||
.arg(tr("Label"), curve->name(), tr("Length"))
|
.arg(tr("Label"), curve->ObjectName(), tr("Length"))
|
||||||
.arg(qApp->fromPixel(curve->GetLength()))
|
.arg(qApp->fromPixel(curve->GetLength()))
|
||||||
.arg(UnitsToStr(qApp->patternUnits(), true), MakeToolTip());
|
.arg(UnitsToStr(qApp->patternUnits(), true), MakeToolTip());
|
||||||
return toolTip;
|
return toolTip;
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "../vdrawtool.h"
|
#include "../vdrawtool.h"
|
||||||
#include "../vwidgets/vsimplecurve.h"
|
#include "../vwidgets/vsimplecurve.h"
|
||||||
#include "../vwidgets/vsimplepoint.h"
|
#include "../vwidgets/vsimplepoint.h"
|
||||||
|
#include "../../toolsdef.h"
|
||||||
|
|
||||||
struct DestinationItem
|
struct DestinationItem
|
||||||
{
|
{
|
||||||
|
@ -57,7 +58,7 @@ struct VAbstractOperationInitData : VDrawToolInitData
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString suffix{};
|
QString suffix{};
|
||||||
QVector<quint32> source{};
|
QVector<SourceItem> source{};
|
||||||
QVector<DestinationItem> destination{};
|
QVector<DestinationItem> destination{};
|
||||||
QString visibilityGroupName{};
|
QString visibilityGroupName{};
|
||||||
QStringList visibilityGroupTags{};
|
QStringList visibilityGroupTags{};
|
||||||
|
@ -95,6 +96,8 @@ public:
|
||||||
virtual void SetLabelVisible(quint32 id, bool visible) override;
|
virtual void SetLabelVisible(quint32 id, bool visible) override;
|
||||||
|
|
||||||
static void ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData);
|
static void ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData);
|
||||||
|
static QVector<SourceItem> ExtractSourceData(const QDomElement &domElement);
|
||||||
|
static QVector<DestinationItem> ExtractDestinationData(const QDomElement &domElement);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile() override;
|
virtual void FullUpdateFromFile() override;
|
||||||
|
|
||||||
|
@ -128,7 +131,7 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
QString suffix;
|
QString suffix;
|
||||||
|
|
||||||
QVector<quint32> source;
|
QVector<SourceItem> source;
|
||||||
QVector<DestinationItem> destination;
|
QVector<DestinationItem> destination;
|
||||||
|
|
||||||
QMap<quint32, VAbstractSimple *> operatedObjects;
|
QMap<quint32, VAbstractSimple *> operatedObjects;
|
||||||
|
@ -137,15 +140,15 @@ protected:
|
||||||
QString groupName{};
|
QString groupName{};
|
||||||
QStringList groupTags{};
|
QStringList groupTags{};
|
||||||
|
|
||||||
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
explicit VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
|
||||||
const QString ¬es, QGraphicsItem *parent = nullptr);
|
|
||||||
|
|
||||||
virtual void AddToFile() override;
|
virtual void AddToFile() override;
|
||||||
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
|
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
|
||||||
virtual void ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
|
virtual void ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
|
||||||
const QDomElement &oldDomElement, const QDomElement &newDomElement) override;
|
const QDomElement &oldDomElement, const QDomElement &newDomElement) override;
|
||||||
virtual void PerformDelete() override;
|
virtual void PerformDelete() override;
|
||||||
|
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||||
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
||||||
|
|
||||||
void UpdateNamePosition(quint32 id, const QPointF &pos);
|
void UpdateNamePosition(quint32 id, const QPointF &pos);
|
||||||
void SaveSourceDestination(QDomElement &tag);
|
void SaveSourceDestination(QDomElement &tag);
|
||||||
|
|
|
@ -78,13 +78,13 @@ namespace
|
||||||
{
|
{
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
QPointF GetOriginPoint(const QVector<quint32> objects, const VContainer *data, qreal calcLength, qreal calcAngle)
|
QPointF GetOriginPoint(const QVector<SourceItem> &objects, const VContainer *data, qreal calcLength, qreal calcAngle)
|
||||||
{
|
{
|
||||||
QPolygonF originObjects;
|
QPolygonF originObjects;
|
||||||
|
|
||||||
for (auto id : objects)
|
for (auto object : objects)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(id);
|
const QSharedPointer<VGObject> obj = data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -92,7 +92,7 @@ QPointF GetOriginPoint(const QVector<quint32> objects, const VContainer *data, q
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
originObjects.append(data->GeometricObject<VPointF>(id)->toQPointF());
|
originObjects.append(data->GeometricObject<VPointF>(object.id)->toQPointF());
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
|
@ -100,7 +100,7 @@ QPointF GetOriginPoint(const QVector<quint32> objects, const VContainer *data, q
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
AppendTo(originObjects, data->GeometricObject<VAbstractCurve>(id)->GetPoints());
|
AppendTo(originObjects, data->GeometricObject<VAbstractCurve>(object.id)->GetPoints());
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
case GOType::PlaceLabel:
|
case GOType::PlaceLabel:
|
||||||
|
@ -129,6 +129,7 @@ void VToolMove::setDialog()
|
||||||
dialogTool->SetSuffix(suffix);
|
dialogTool->SetSuffix(suffix);
|
||||||
dialogTool->SetRotationOrigPointId(origPointId);
|
dialogTool->SetRotationOrigPointId(origPointId);
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
|
dialogTool->SetSourceObjects(source);
|
||||||
|
|
||||||
SetDialogVisibilityGroupData(dialogTool);
|
SetDialogVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +148,7 @@ VToolMove *VToolMove::Create(const QPointer<DialogTool> &dialog, VMainGraphicsSc
|
||||||
initData.formulaLength = dialogTool->GetLength();
|
initData.formulaLength = dialogTool->GetLength();
|
||||||
initData.rotationOrigin = dialogTool->GetRotationOrigPointId();
|
initData.rotationOrigin = dialogTool->GetRotationOrigPointId();
|
||||||
initData.suffix = dialogTool->GetSuffix();
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetSourceObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
|
@ -196,9 +197,9 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData)
|
||||||
|
|
||||||
initData.id = initData.data->getNextId();//Just reserve id for tool
|
initData.id = initData.data->getNextId();//Just reserve id for tool
|
||||||
|
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -208,38 +209,38 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
initData.destination.append(CreatePoint(initData.id, idObject, calcAngle, calcLength,
|
initData.destination.append(CreatePoint(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin, initData.suffix,
|
calcRotationAngle, rotationOrigin, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
initData.destination.append(CreateArc<VArc>(initData.id, idObject, calcAngle, calcLength,
|
initData.destination.append(CreateArc<VArc>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin, initData.suffix,
|
calcRotationAngle, rotationOrigin, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength,
|
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin,
|
calcRotationAngle, rotationOrigin,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, calcAngle, calcLength,
|
initData.destination.append(CreateCurve<VSpline>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin, initData.suffix,
|
calcRotationAngle, rotationOrigin, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle,
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle,
|
||||||
calcLength, calcRotationAngle,
|
calcLength, calcRotationAngle,
|
||||||
rotationOrigin, initData.suffix,
|
rotationOrigin, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength,
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin,
|
calcRotationAngle, rotationOrigin,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject,
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object,
|
||||||
calcAngle, calcLength,
|
calcAngle, calcLength,
|
||||||
calcRotationAngle,
|
calcRotationAngle,
|
||||||
rotationOrigin,
|
rotationOrigin,
|
||||||
|
@ -258,8 +259,8 @@ QT_WARNING_POP
|
||||||
{
|
{
|
||||||
for (int i = 0; i < initData.source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = initData.source.at(i);
|
const SourceItem object = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -269,34 +270,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
UpdatePoint(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
UpdatePoint(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
||||||
initData.suffix, initData.data, initData.destination.at(i));
|
initData.suffix, initData.data, initData.destination.at(i));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
UpdateArc<VArc>(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
UpdateArc<VArc>(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
||||||
initData.suffix, initData.data, initData.destination.at(i).id);
|
initData.suffix, initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
UpdateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength, calcRotationAngle,
|
UpdateArc<VEllipticalArc>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
||||||
rotationOrigin, initData.suffix, initData.data,
|
rotationOrigin, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(initData.id, idObject, calcAngle, calcLength, calcRotationAngle,
|
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
||||||
rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id);
|
rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle, calcLength,
|
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin,initData.suffix,
|
calcRotationAngle, rotationOrigin,initData.suffix,
|
||||||
initData.data, initData.destination.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength, calcRotationAngle,
|
UpdateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
||||||
rotationOrigin,initData.suffix, initData.data,
|
rotationOrigin,initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, calcAngle, calcLength,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin,
|
calcRotationAngle, rotationOrigin,
|
||||||
initData.suffix, initData.data,
|
initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
|
@ -332,9 +333,9 @@ QT_WARNING_POP
|
||||||
initData.doc->IncrementReferens(originPoint->getIdTool());
|
initData.doc->IncrementReferens(originPoint->getIdTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
||||||
|
@ -458,7 +459,7 @@ void VToolMove::SetVisualization()
|
||||||
VisToolMove *visual = qobject_cast<VisToolMove *>(vis);
|
VisToolMove *visual = qobject_cast<VisToolMove *>(vis);
|
||||||
SCASSERT(visual != nullptr)
|
SCASSERT(visual != nullptr)
|
||||||
|
|
||||||
visual->SetObjects(source);
|
visual->SetObjects(SourceToObjects(source));
|
||||||
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
|
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
|
||||||
visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle,
|
visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle,
|
||||||
qApp->Settings()->GetOsSeparator()));
|
qApp->Settings()->GetOsSeparator()));
|
||||||
|
@ -487,6 +488,9 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
|
||||||
const QString notes = dialogTool->GetNotes();
|
const QString notes = dialogTool->GetNotes();
|
||||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||||
|
|
||||||
|
source = dialogTool->GetSourceObjects();
|
||||||
|
SaveSourceDestination(domElement);
|
||||||
|
|
||||||
// Save visibility data for later use
|
// Save visibility data for later use
|
||||||
SaveVisibilityGroupData(dialogTool);
|
SaveVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +504,6 @@ void VToolMove::ReadToolAttributes(const QDomElement &domElement)
|
||||||
formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0'));
|
formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0'));
|
||||||
formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, QChar('0'));
|
formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, QChar('0'));
|
||||||
formulaLength = doc->GetParametrString(domElement, AttrLength, QChar('0'));
|
formulaLength = doc->GetParametrString(domElement, AttrLength, QChar('0'));
|
||||||
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -512,10 +515,7 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||||
doc->SetAttribute(tag, AttrAngle, formulaAngle);
|
doc->SetAttribute(tag, AttrAngle, formulaAngle);
|
||||||
doc->SetAttribute(tag, AttrRotationAngle, formulaRotationAngle);
|
doc->SetAttribute(tag, AttrRotationAngle, formulaRotationAngle);
|
||||||
doc->SetAttribute(tag, AttrLength, formulaLength);
|
doc->SetAttribute(tag, AttrLength, formulaLength);
|
||||||
doc->SetAttribute(tag, AttrSuffix, suffix);
|
|
||||||
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
|
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
|
||||||
|
|
||||||
SaveSourceDestination(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -530,7 +530,7 @@ QString VToolMove::MakeToolTip() const
|
||||||
.arg(GetFormulaAngle().getDoubleValue()) // 2
|
.arg(GetFormulaAngle().getDoubleValue()) // 2
|
||||||
.arg(tr("Length")) // 3
|
.arg(tr("Length")) // 3
|
||||||
.arg(GetFormulaLength().getDoubleValue()) // 4
|
.arg(GetFormulaLength().getDoubleValue()) // 4
|
||||||
.arg(UnitsToStr(qApp->patternUnits(), true), // 5
|
.arg(UnitsToStr(qApp->patternUnits(), true), // 5
|
||||||
tr("Rotation angle")) // 6
|
tr("Rotation angle")) // 6
|
||||||
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
|
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
|
||||||
.arg(tr("Rotation origin point"), // 8
|
.arg(tr("Rotation origin point"), // 8
|
||||||
|
@ -540,8 +540,7 @@ QString VToolMove::MakeToolTip() const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
: VAbstractOperation(initData, parent),
|
||||||
initData.destination, initData.notes, parent),
|
|
||||||
formulaAngle(initData.formulaAngle),
|
formulaAngle(initData.formulaAngle),
|
||||||
formulaRotationAngle(initData.formulaRotationAngle),
|
formulaRotationAngle(initData.formulaRotationAngle),
|
||||||
formulaLength(initData.formulaLength),
|
formulaLength(initData.formulaLength),
|
||||||
|
@ -552,14 +551,19 @@ VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal angle,
|
DestinationItem VToolMove::CreatePoint(quint32 idTool, const SourceItem &sItem, qreal angle,
|
||||||
qreal length, qreal rotationAngle, const QPointF &rotationOrigin,
|
qreal length, qreal rotationAngle, const QPointF &rotationOrigin,
|
||||||
const QString &suffix, VContainer *data)
|
const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
|
||||||
VPointF moved = point->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
VPointF moved = point->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
||||||
moved.setIdObject(idTool);
|
moved.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
moved.setName(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
DestinationItem item;
|
DestinationItem item;
|
||||||
item.mx = moved.mx();
|
item.mx = moved.mx();
|
||||||
item.my = moved.my();
|
item.my = moved.my();
|
||||||
|
@ -570,47 +574,60 @@ DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal ang
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolMove::CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
DestinationItem VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
|
VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
||||||
data);
|
data);
|
||||||
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolMove::UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
void VToolMove::UpdatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
|
||||||
const DestinationItem &item)
|
const DestinationItem &item)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
|
||||||
VPointF moved = point->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
VPointF moved = point->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
||||||
moved.setIdObject(idTool);
|
moved.setIdObject(idTool);
|
||||||
moved.setMx(item.mx);
|
moved.setMx(item.mx);
|
||||||
moved.setMy(item.my);
|
moved.setMy(item.my);
|
||||||
moved.SetShowLabel(item.showLabel);
|
moved.SetShowLabel(item.showLabel);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
moved.setName(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
data->UpdateGObject(item.id, new VPointF(moved));
|
data->UpdateGObject(item.id, new VPointF(moved));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolMove::UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
void VToolMove::UpdateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id);
|
||||||
data->AddArc(data->GeometricObject<Item>(id), id);
|
data->AddArc(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
DestinationItem VToolMove::CreateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
|
VContainer *data)
|
||||||
{
|
{
|
||||||
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
|
||||||
Item moved = i->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
Item moved = i->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
||||||
moved.setIdObject(idTool);
|
moved.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
moved.SetAliasSuffix(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
DestinationItem item;
|
DestinationItem item;
|
||||||
item.mx = INT_MAX;
|
item.mx = INT_MAX;
|
||||||
item.my = INT_MAX;
|
item.my = INT_MAX;
|
||||||
|
@ -620,10 +637,11 @@ DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angl
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
DestinationItem VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
|
VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
||||||
data);
|
data);
|
||||||
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
|
@ -631,12 +649,12 @@ DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal ang
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle,
|
DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle,
|
||||||
qreal length, qreal rotationAngle,
|
qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix,
|
const QPointF &rotationOrigin, const QString &suffix,
|
||||||
VContainer *data)
|
VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
||||||
data);
|
data);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
|
@ -644,30 +662,36 @@ DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, quint32 idIte
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolMove::UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
void VToolMove::UpdateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
|
||||||
Item moved = i->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
Item moved = i->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle);
|
||||||
moved.setIdObject(idTool);
|
moved.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
moved.SetAliasSuffix(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
data->UpdateGObject(id, new Item(moved));
|
data->UpdateGObject(id, new Item(moved));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolMove::UpdateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
void VToolMove::UpdateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id);
|
||||||
data->AddSpline(data->GeometricObject<Item>(id), id);
|
data->AddSpline(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolMove::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
void VToolMove::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
quint32 id)
|
VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,41 +104,45 @@ private:
|
||||||
QString formulaLength;
|
QString formulaLength;
|
||||||
quint32 origPointId;
|
quint32 origPointId;
|
||||||
|
|
||||||
VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr);
|
explicit VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
|
VContainer *data);
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
|
VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
|
VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin,const QString &suffix, VContainer *data);
|
qreal rotationAngle, const QPointF &rotationOrigin,const QString &suffix,
|
||||||
|
VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length,
|
static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
qreal rotationAngle, const QPointF &rotationOrigin,
|
qreal rotationAngle, const QPointF &rotationOrigin,
|
||||||
const QString &suffix, VContainer *data);
|
const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
static void UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static void UpdatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
|
||||||
const DestinationItem &item);
|
const DestinationItem &item);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static void UpdateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static void UpdateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static void UpdateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
|
static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
quint32 id);
|
VContainer *data, quint32 id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLMOVING_H
|
#endif // VTOOLMOVING_H
|
||||||
|
|
|
@ -80,8 +80,7 @@ const QString VToolRotation::ToolType = QStringLiteral("rotation");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolRotation::VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent)
|
VToolRotation::VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
: VAbstractOperation(initData, parent),
|
||||||
initData.destination, initData.notes, parent),
|
|
||||||
origPointId(initData.origin),
|
origPointId(initData.origin),
|
||||||
formulaAngle(initData.angle)
|
formulaAngle(initData.angle)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +98,7 @@ void VToolRotation::setDialog()
|
||||||
dialogTool->SetAngle(formulaAngle);
|
dialogTool->SetAngle(formulaAngle);
|
||||||
dialogTool->SetSuffix(suffix);
|
dialogTool->SetSuffix(suffix);
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
|
dialogTool->SetSourceObjects(source);
|
||||||
|
|
||||||
SetDialogVisibilityGroupData(dialogTool);
|
SetDialogVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ VToolRotation *VToolRotation::Create(const QPointer<DialogTool> &dialog, VMainGr
|
||||||
initData.origin = dialogTool->GetOrigPointId();
|
initData.origin = dialogTool->GetOrigPointId();
|
||||||
initData.angle = dialogTool->GetAngle();
|
initData.angle = dialogTool->GetAngle();
|
||||||
initData.suffix = dialogTool->GetSuffix();
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetSourceObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
|
@ -150,9 +150,9 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
|
||||||
|
|
||||||
initData.id = initData.data->getNextId();//Just reserve id for tool
|
initData.id = initData.data->getNextId();//Just reserve id for tool
|
||||||
|
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -162,32 +162,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
initData.destination.append(CreatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
initData.destination.append(CreatePoint(initData.id, object, oPoint, calcAngle, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
initData.destination.append(CreateArc<VArc>(initData.id, idObject, oPoint, calcAngle,
|
initData.destination.append(CreateArc<VArc>(initData.id, object, oPoint, calcAngle,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, oPoint, calcAngle,
|
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, object, oPoint, calcAngle,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, oPoint, calcAngle,
|
initData.destination.append(CreateCurve<VSpline>(initData.id, object, oPoint, calcAngle,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint,
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, oPoint,
|
||||||
calcAngle, initData.suffix,
|
calcAngle, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, oPoint, calcAngle,
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, oPoint, calcAngle,
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint,
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object, oPoint,
|
||||||
calcAngle, initData.suffix,
|
calcAngle, initData.suffix,
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
|
@ -203,8 +203,8 @@ QT_WARNING_POP
|
||||||
{
|
{
|
||||||
for (int i = 0; i < initData.source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = initData.source.at(i);
|
const SourceItem object = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
@ -215,32 +215,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
{
|
{
|
||||||
UpdatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
UpdatePoint(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
initData.destination.at(i));
|
initData.destination.at(i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
UpdateArc<VArc>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
UpdateArc<VArc>(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
UpdateArc<VEllipticalArc>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
UpdateArc<VEllipticalArc>(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
UpdateCurve<VSpline>(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
UpdateCurveWithSegments<VSplinePath>(initData.id, object, oPoint, calcAngle, initData.suffix,
|
||||||
initData.data, initData.destination.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
UpdateCurve<VCubicBezier>(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, oPoint, calcAngle, initData.suffix,
|
||||||
initData.data, initData.destination.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
|
@ -269,9 +269,9 @@ QT_WARNING_POP
|
||||||
InitOperationToolConnections(initData.scene, tool);
|
InitOperationToolConnections(initData.scene, tool);
|
||||||
VAbstractPattern::AddTool(initData.id, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
initData.doc->IncrementReferens(originPoint.getIdTool());
|
initData.doc->IncrementReferens(originPoint.getIdTool());
|
||||||
for (auto idObject : qAsConst(initData.source))
|
for (auto object : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
|
||||||
|
@ -342,7 +342,7 @@ void VToolRotation::SetVisualization()
|
||||||
VisToolRotation *visual = qobject_cast<VisToolRotation *>(vis);
|
VisToolRotation *visual = qobject_cast<VisToolRotation *>(vis);
|
||||||
SCASSERT(visual != nullptr)
|
SCASSERT(visual != nullptr)
|
||||||
|
|
||||||
visual->SetObjects(source);
|
visual->SetObjects(SourceToObjects(source));
|
||||||
visual->SetOriginPointId(origPointId);
|
visual->SetOriginPointId(origPointId);
|
||||||
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
|
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
@ -367,6 +367,9 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
|
||||||
const QString notes = dialogTool->GetNotes();
|
const QString notes = dialogTool->GetNotes();
|
||||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||||
|
|
||||||
|
source = dialogTool->GetSourceObjects();
|
||||||
|
SaveSourceDestination(domElement);
|
||||||
|
|
||||||
// Save visibility data for later use
|
// Save visibility data for later use
|
||||||
SaveVisibilityGroupData(dialogTool);
|
SaveVisibilityGroupData(dialogTool);
|
||||||
}
|
}
|
||||||
|
@ -378,7 +381,6 @@ void VToolRotation::ReadToolAttributes(const QDomElement &domElement)
|
||||||
|
|
||||||
origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
||||||
formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0'));
|
formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0'));
|
||||||
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -389,9 +391,6 @@ void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||||
doc->SetAttribute(tag, AttrType, ToolType);
|
doc->SetAttribute(tag, AttrType, ToolType);
|
||||||
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
|
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
|
||||||
doc->SetAttribute(tag, AttrAngle, formulaAngle);
|
doc->SetAttribute(tag, AttrAngle, formulaAngle);
|
||||||
doc->SetAttribute(tag, AttrSuffix, suffix);
|
|
||||||
|
|
||||||
SaveSourceDestination(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -406,13 +405,18 @@ QString VToolRotation::MakeToolTip() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
DestinationItem VToolRotation::CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data)
|
const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
|
||||||
VPointF rotated = point->Rotate(origin, angle, suffix);
|
VPointF rotated = point->Rotate(origin, angle, suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.setName(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
DestinationItem item;
|
DestinationItem item;
|
||||||
item.mx = rotated.mx();
|
item.mx = rotated.mx();
|
||||||
item.my = rotated.my();
|
item.my = rotated.my();
|
||||||
|
@ -423,13 +427,18 @@ DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
DestinationItem VToolRotation::CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data)
|
const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
|
||||||
Item rotated = i->Rotate(origin, angle, suffix);
|
Item rotated = i->Rotate(origin, angle, suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.SetAliasSuffix(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
DestinationItem item;
|
DestinationItem item;
|
||||||
item.mx = INT_MAX;
|
item.mx = INT_MAX;
|
||||||
item.my = INT_MAX;
|
item.my = INT_MAX;
|
||||||
|
@ -439,81 +448,93 @@ DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolRotation::CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
DestinationItem VToolRotation::CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data)
|
const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, origin, angle, suffix, data);
|
||||||
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolRotation::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
DestinationItem VToolRotation::CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data)
|
const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, origin, angle, suffix, data);
|
||||||
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
DestinationItem VToolRotation::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin,
|
DestinationItem VToolRotation::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin,
|
||||||
qreal angle, const QString &suffix, VContainer *data)
|
qreal angle, const QString &suffix, VContainer *data)
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
|
const DestinationItem item = CreateItem<Item>(idTool, sItem, origin, angle, suffix, data);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolRotation::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
void VToolRotation::UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, const DestinationItem &item)
|
const QString &suffix, VContainer *data, const DestinationItem &item)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
|
||||||
VPointF rotated = point->Rotate(origin, angle, suffix);
|
VPointF rotated = point->Rotate(origin, angle, suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
rotated.setMx(item.mx);
|
rotated.setMx(item.mx);
|
||||||
rotated.setMy(item.my);
|
rotated.setMy(item.my);
|
||||||
rotated.SetShowLabel(item.showLabel);
|
rotated.SetShowLabel(item.showLabel);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.setName(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
data->UpdateGObject(item.id, new VPointF(rotated));
|
data->UpdateGObject(item.id, new VPointF(rotated));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolRotation::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
void VToolRotation::UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id)
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
|
||||||
Item rotated = i->Rotate(origin, angle, suffix);
|
Item rotated = i->Rotate(origin, angle, suffix);
|
||||||
rotated.setIdObject(idTool);
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
if (not sItem.alias.isEmpty())
|
||||||
|
{
|
||||||
|
rotated.SetAliasSuffix(sItem.alias);
|
||||||
|
}
|
||||||
|
|
||||||
data->UpdateGObject(id, new Item(rotated));
|
data->UpdateGObject(id, new Item(rotated));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolRotation::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
void VToolRotation::UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id)
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, origin, angle, suffix, data, id);
|
||||||
data->AddArc(data->GeometricObject<Item>(id), id);
|
data->AddArc(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolRotation::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
void VToolRotation::UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id)
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, origin, angle, suffix, data, id);
|
||||||
data->AddSpline(data->GeometricObject<Item>(id), id);
|
data->AddSpline(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class Item>
|
template <class Item>
|
||||||
void VToolRotation::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
void VToolRotation::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id)
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
{
|
{
|
||||||
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
|
UpdateItem<Item>(idTool, sItem, origin, angle, suffix, data, id);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,35 +95,35 @@ private:
|
||||||
|
|
||||||
VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent = nullptr);
|
VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data);
|
const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data);
|
const QString &suffix, VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data);
|
const QString &suffix, VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data);
|
const QString &suffix, VContainer *data);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin,
|
static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin,
|
||||||
qreal angle, const QString &suffix, VContainer *data);
|
qreal angle, const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static void UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, const DestinationItem &item);
|
const QString &suffix, VContainer *data, const DestinationItem &item);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static void UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static void UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static void UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data, quint32 id);
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# This need for corect working file translations.pro
|
# This need for corect working file translations.pro
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
$$PWD/toolsdef.h \
|
||||||
$$PWD/vdatatool.h \
|
$$PWD/vdatatool.h \
|
||||||
$$PWD/vabstracttool.h \
|
$$PWD/vabstracttool.h \
|
||||||
$$PWD/tools.h \
|
$$PWD/tools.h \
|
||||||
|
@ -64,6 +65,7 @@ HEADERS += \
|
||||||
$$PWD/nodeDetails/vtoolplacelabel.h
|
$$PWD/nodeDetails/vtoolplacelabel.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
$$PWD/toolsdef.cpp \
|
||||||
$$PWD/vdatatool.cpp \
|
$$PWD/vdatatool.cpp \
|
||||||
$$PWD/vabstracttool.cpp \
|
$$PWD/vabstracttool.cpp \
|
||||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp \
|
$$PWD/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp \
|
||||||
|
|
105
src/libs/vtools/tools/toolsdef.cpp
Normal file
105
src/libs/vtools/tools/toolsdef.cpp
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file toolsdef.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 11, 2020
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2020 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "toolsdef.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "../vgeometry/vgobject.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<quint32> SourceToObjects(const QVector<SourceItem> &source)
|
||||||
|
{
|
||||||
|
QVector<quint32> ids;
|
||||||
|
ids.reserve(source.size());
|
||||||
|
|
||||||
|
for (auto s: source)
|
||||||
|
{
|
||||||
|
ids.append(s.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool SourceAliasValid(const SourceItem &item, const QSharedPointer<VGObject> &obj, const VContainer *data,
|
||||||
|
const QString &originAlias)
|
||||||
|
{
|
||||||
|
SCASSERT(data != nullptr)
|
||||||
|
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
|
|
||||||
|
QString alias;
|
||||||
|
|
||||||
|
if (obj->getType() == GOType::Point)
|
||||||
|
{
|
||||||
|
alias = item.alias;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString oldAlias = obj->GetAliasSuffix();
|
||||||
|
obj->SetAliasSuffix(item.alias);
|
||||||
|
alias = obj->GetAlias();
|
||||||
|
obj->SetAliasSuffix(oldAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not alias.isEmpty() && originAlias != alias &&
|
||||||
|
(not rx.match(alias).hasMatch() || not data->IsUnique(alias)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString OriginAlias(quint32 id, const QVector<SourceItem> &source, const QSharedPointer<VGObject> &obj)
|
||||||
|
{
|
||||||
|
auto item = std::find_if(source.begin(), source.end(),
|
||||||
|
[id](const SourceItem &sItem) { return sItem.id == id; });
|
||||||
|
if (item != source.end())
|
||||||
|
{
|
||||||
|
if (obj->getType() == GOType::Point)
|
||||||
|
{
|
||||||
|
return item->alias;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString oldAlias = obj->GetAliasSuffix();
|
||||||
|
obj->SetAliasSuffix(item->alias);
|
||||||
|
QString alias = obj->GetAlias();
|
||||||
|
obj->SetAliasSuffix(oldAlias);
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
53
src/libs/vtools/tools/toolsdef.h
Normal file
53
src/libs/vtools/tools/toolsdef.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file toolsdef.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 11, 2020
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2020 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#ifndef TOOLSDEF_H
|
||||||
|
#define TOOLSDEF_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
class VGObject;
|
||||||
|
class VContainer;
|
||||||
|
|
||||||
|
struct SourceItem
|
||||||
|
{
|
||||||
|
quint32 id{0};
|
||||||
|
QString alias{};
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(SourceItem)
|
||||||
|
Q_DECLARE_TYPEINFO(SourceItem, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
|
QVector<quint32> SourceToObjects(const QVector<SourceItem> &source);
|
||||||
|
|
||||||
|
QString OriginAlias(quint32 id, const QVector<SourceItem> &source, const QSharedPointer<VGObject> &obj);
|
||||||
|
|
||||||
|
bool SourceAliasValid(const SourceItem &item, const QSharedPointer<VGObject> &obj, const VContainer *data,
|
||||||
|
const QString &originAlias);
|
||||||
|
|
||||||
|
#endif // TOOLSDEF_H
|
|
@ -57,7 +57,7 @@ VisOperation::~VisOperation()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisOperation::SetObjects(QVector<quint32> objects)
|
void VisOperation::SetObjects(const QVector<quint32> &objects)
|
||||||
{
|
{
|
||||||
this->objects = objects;
|
this->objects = objects;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr);
|
explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||||
virtual ~VisOperation();
|
virtual ~VisOperation();
|
||||||
|
|
||||||
void SetObjects(QVector<quint32> objects);
|
void SetObjects(const QVector<quint32> &objects);
|
||||||
|
|
||||||
virtual void VisualMode(const quint32 &pointId = NULL_ID) override;
|
virtual void VisualMode(const quint32 &pointId = NULL_ID) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user