Alias support for group operations.

This commit is contained in:
Roman Telezhynskyi 2020-11-07 15:02:30 +02:00
parent 3feddb9ce9
commit 99985d43e0
37 changed files with 1513 additions and 383 deletions

View File

@ -183,6 +183,7 @@
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="alias" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>

View File

@ -145,6 +145,12 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref
VArc arc(center, GetRadius(), f1, f2);
arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
arc.SetColor(GetColor());
arc.SetPenStyle(GetPenStyle());
arc.SetFlipped(IsFlipped());
@ -165,6 +171,12 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const
VArc arc(center, GetRadius(), f1, f2);
arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
arc.SetColor(GetColor());
arc.SetPenStyle(GetPenStyle());
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);
arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
arc.SetColor(GetColor());
arc.SetPenStyle(GetPenStyle());
arc.SetFlipped(IsFlipped());

View File

@ -88,6 +88,12 @@ VCubicBezier VCubicBezier::Rotate(const QPointF &originPoint, qreal degrees, con
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -103,6 +109,12 @@ VCubicBezier VCubicBezier::Flip(const QLineF &axis, const QString &prefix) const
const VPointF p4 = GetP4().Flip(axis);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -118,6 +130,12 @@ VCubicBezier VCubicBezier::Move(qreal length, qreal angle, const QString &prefix
const VPointF p4 = GetP4().Move(length, angle);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());

View File

@ -104,6 +104,12 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr
curve.append(point.Rotate(originPoint, degrees));
}
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -120,6 +126,12 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi
curve.append(point.Flip(axis));
}
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -136,6 +148,12 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString
curve.append(point.Move(length, angle));
}
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());

View File

@ -153,6 +153,12 @@ VEllipticalArc VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle());
elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
elArc.SetColor(GetColor());
elArc.SetPenStyle(GetPenStyle());
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(),
VAbstractArc::GetEndAngle(), GetRotationAngle());
elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
elArc.SetColor(GetColor());
elArc.SetPenStyle(GetPenStyle());
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(),
VAbstractArc::GetEndAngle(), GetRotationAngle());
elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
elArc.SetColor(GetColor());
elArc.SetPenStyle(GetPenStyle());
elArc.SetFlipped(IsFlipped());

View File

@ -78,7 +78,7 @@ public:
quint32 id() const;
virtual void setId(const quint32 &id);
void SetAlias(const QString &alias);
virtual void SetAlias(const QString &alias);
QString GetAlias() const;
virtual void SetAliasSuffix(const QString &aliasSuffix);

View File

@ -147,6 +147,7 @@ VPointF VPointF::Move(qreal length, qreal angle, const QString &prefix) const
const QPointF p = MovePF(toQPointF(), length, angle);
VPointF moved(p, name() + prefix, mx(), my());
moved.SetShowLabel(IsShowLabel());
return moved;
}
@ -260,6 +261,20 @@ QJsonObject VPointF::ToJson() const
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)
{

View File

@ -85,6 +85,9 @@ public:
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 FlipPF(const QLineF &axis, const QPointF &point);
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);

View File

@ -122,6 +122,12 @@ VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
}
spl.SetColor(GetColor());
spl.SetPenStyle(GetPenStyle());
spl.SetApproximationScale(GetApproximationScale());
@ -139,6 +145,12 @@ VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
}
spl.SetColor(GetColor());
spl.SetPenStyle(GetPenStyle());
spl.SetApproximationScale(GetApproximationScale());
@ -156,6 +168,12 @@ VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
}
spl.SetColor(GetColor());
spl.SetPenStyle(GetPenStyle());
spl.SetApproximationScale(GetApproximationScale());

View File

@ -122,6 +122,12 @@ VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
}
splPath.SetColor(GetColor());
splPath.SetPenStyle(GetPenStyle());
splPath.SetApproximationScale(GetApproximationScale());
@ -147,6 +153,12 @@ VSplinePath VSplinePath::Flip(const QLineF &axis, const QString &prefix) const
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
}
splPath.SetColor(GetColor());
splPath.SetPenStyle(GetPenStyle());
splPath.SetApproximationScale(GetApproximationScale());
@ -172,6 +184,12 @@ VSplinePath VSplinePath::Move(qreal length, qreal angle, const QString &prefix)
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
}
splPath.SetColor(GetColor());
splPath.SetPenStyle(GetPenStyle());
splPath.SetApproximationScale(GetApproximationScale());

View File

@ -249,6 +249,10 @@ void DialogFlippingByAxis::SetSourceObjects(const QVector<SourceItem> &value)
{
sourceObjects = value;
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->blockSignals(false);
QRegularExpression rx(NameRegExp());
if (not rx.match(sourceItem.alias).hasMatch() || not data->IsUnique(sourceItem.alias))
{
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();
}
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
OriginAlias(sourceItem.id, sourceObjects, obj)));
}
//---------------------------------------------------------------------------------------------------------------------
@ -515,8 +506,9 @@ void DialogFlippingByAxis::FillSourceList()
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(obj->ObjectName());
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);
@ -535,8 +527,6 @@ void DialogFlippingByAxis::FillSourceList()
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ValidateSourceAliases()
{
QRegularExpression rx(NameRegExp());
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
@ -545,27 +535,39 @@ void DialogFlippingByAxis::ValidateSourceAliases()
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
QString name;
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))
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 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);
}
}
}

View File

@ -40,6 +40,7 @@
#include <QtGlobal>
#include "../vmisc/def.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -63,8 +64,6 @@ public:
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -81,6 +80,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -88,6 +90,8 @@ public slots:
private slots:
void SuffixChanged();
void GroupNameChanged();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -104,7 +108,7 @@ private:
Ui::DialogFlippingByAxis *ui;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
@ -113,16 +117,16 @@ private:
bool flagName;
bool flagGroupName;
bool flagError;
bool flagAlias{true};
QStringList m_groupTags{};
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

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>296</height>
<width>415</width>
<height>464</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +28,35 @@
<string>Tool</string>
</attribute>
<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>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
@ -48,7 +77,11 @@
</widget>
</item>
<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 row="1" column="0">
<widget class="QLabel" name="labelAxisType">
@ -117,6 +150,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -64,7 +64,6 @@
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogFlippingByLine),
objects(),
stage1(true),
m_suffix(),
flagName(true),
@ -142,12 +141,6 @@ void DialogFlippingByLine::SetSuffix(const QString &value)
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByLine::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByLine::GetVisibilityGroupName() const
{
@ -196,7 +189,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -209,7 +202,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
scene->ToggleArcSelection(false);
@ -224,6 +217,8 @@ void DialogFlippingByLine::ShowDialog(bool click)
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
emit ToolTip(tr("Select first line point"));
}
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)
{
@ -241,10 +253,12 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
switch (number)
{
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"));
return;
@ -260,7 +274,7 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
}
break;
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"));
return;
@ -296,16 +310,23 @@ void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -321,6 +342,7 @@ void DialogFlippingByLine::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -337,6 +359,7 @@ void DialogFlippingByLine::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -361,6 +384,7 @@ void DialogFlippingByLine::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -371,6 +395,50 @@ void DialogFlippingByLine::GroupNameChanged()
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()
{
@ -382,10 +450,22 @@ void DialogFlippingByLine::SaveData()
{
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);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetFirstLinePointId(GetFirstLinePointId());
operation->SetSecondLinePointId(GetSecondLinePointId());
operation->RefreshGeometry();
@ -411,29 +491,118 @@ void DialogFlippingByLine::PointChanged()
ChangeColor(ui->labelFirstLinePoint, 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))
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelFirstLinePoint, 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;
color = errorColor;
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;
color = errorColor;
ChangeColor(ui->labelSecondLinePoint, color);
ui->labelStatus->setText(tr("Invalid second line point"));
}
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 &notes)
{
@ -445,3 +614,16 @@ QString DialogFlippingByLine::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogFlippingByLine::IsValid() const
{
bool ready = flagError && flagName && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -40,6 +40,7 @@
#include <QtGlobal>
#include "../vmisc/def.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -63,8 +64,6 @@ public:
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -81,6 +80,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -88,6 +90,8 @@ public slots:
private slots:
void SuffixChanged();
void GroupNameChanged();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -104,7 +108,7 @@ private:
Ui::DialogFlippingByLine *ui;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
@ -113,14 +117,14 @@ private:
bool flagName;
bool flagGroupName;
bool flagError;
bool flagAlias{true};
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

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>319</width>
<height>301</height>
<width>387</width>
<height>440</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +28,35 @@
<string>Tool</string>
</attribute>
<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>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
@ -48,7 +77,11 @@
</widget>
</item>
<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 row="1" column="0">
<widget class="QLabel" name="labelSecondLinePoint">
@ -117,6 +150,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -78,7 +78,6 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
formulaBaseHeightAngle(0),
formulaBaseHeightRotationAngle(0),
formulaBaseHeightLength(0),
objects(),
stage1(true),
stage2(false),
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->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);
SetRotationOrigPointId(NULL_ID);
@ -257,12 +259,6 @@ void DialogMove::SetRotationOrigPointId(const quint32 &value)
operation->SetRotationOriginPointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogMove::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogMove::GetVisibilityGroupName() const
{
@ -311,7 +307,7 @@ void DialogMove::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -325,7 +321,7 @@ void DialogMove::ShowDialog(bool click)
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
@ -343,6 +339,8 @@ void DialogMove::ShowDialog(bool click)
scene->ToggleSplinePathHover(false);
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
}
else if (not stage2 && not stage1 && prepare && click)
{
@ -416,16 +414,23 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -501,6 +506,7 @@ void DialogMove::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -517,6 +523,7 @@ void DialogMove::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -541,6 +548,7 @@ void DialogMove::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -551,6 +559,50 @@ void DialogMove::GroupNameChanged()
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()
{
@ -565,10 +617,22 @@ void DialogMove::SaveData()
formulaRotationAngle = ui->plainTextEditRotationAngle->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);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetAngle(formulaAngle);
operation->SetLength(formulaLength);
operation->SetRotationAngle(formulaRotationAngle);
@ -597,6 +661,23 @@ void DialogMove::closeEvent(QCloseEvent *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()
{
@ -609,6 +690,11 @@ void DialogMove::EvalAngle()
formulaData.checkZero = false;
Eval(formulaData, flagAngle);
if (not flagAngle)
{
ui->labelStatus->setText(tr("Invalid angle formula"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -623,6 +709,11 @@ void DialogMove::EvalRotationAngle()
formulaData.checkZero = false;
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);
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();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogMove::IsValid() const
{
bool ready = flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -39,6 +39,7 @@
#include "../vmisc/def.h"
#include "dialogtool.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -68,8 +69,6 @@ public:
quint32 GetRotationOrigPointId() const;
void SetRotationOrigPointId(const quint32 &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -86,6 +85,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -103,6 +105,9 @@ private slots:
void SuffixChanged();
void GroupNameChanged();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -130,7 +135,7 @@ private:
int formulaBaseHeightRotationAngle;
int formulaBaseHeightLength;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
bool stage2;
@ -145,18 +150,18 @@ private:
bool flagLength;
bool flagName;
bool flagGroupName;
bool flagAlias{true};
QStringList m_groupTags{};
void EvalAngle();
void EvalRotationAngle();
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

View File

@ -2,12 +2,15 @@
<ui version="4.0">
<class>DialogMove</class>
<widget class="QDialog" name="DialogMove">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>498</height>
<width>536</width>
<height>669</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +31,39 @@
<string>Tool</string>
</attribute>
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
@ -656,6 +692,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -72,7 +72,6 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
timerAngle(new QTimer(this)),
formulaAngle(),
formulaBaseHeightAngle(0),
objects(),
stage1(true),
m_suffix(),
m_firstRelease(false),
@ -170,12 +169,6 @@ void DialogRotation::SetSuffix(const QString &value)
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogRotation::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogRotation::GetVisibilityGroupName() const
{
@ -224,7 +217,7 @@ void DialogRotation::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -237,7 +230,7 @@ void DialogRotation::ShowDialog(bool click)
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
scene->ToggleArcSelection(false);
@ -252,6 +245,8 @@ void DialogRotation::ShowDialog(bool click)
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
emit ToolTip(tr("Select origin point"));
}
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)
{
@ -304,14 +316,17 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
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.
// To fix this issue we just silently remove it from the list.
objects.removeOne(id);
operation->SetObjects(ConvertToVector(objects));
sourceObjects.erase(obj);
operation->SetObjects(SourceToObjects(sourceObjects));
}
else
{
@ -341,16 +356,23 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -386,6 +408,7 @@ void DialogRotation::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -402,6 +425,7 @@ void DialogRotation::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -426,6 +450,7 @@ void DialogRotation::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -448,10 +473,22 @@ void DialogRotation::SaveData()
m_suffix = ui->lineEditSuffix->text();
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);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetOriginPointId(GetOrigPointId());
operation->SetAngle(formulaAngle);
operation->RefreshGeometry();
@ -479,11 +516,17 @@ void DialogRotation::closeEvent(QCloseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
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;
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
if (obj != sourceObjects.end())
{
flagError = false;
color = errorColor;
ui->labelStatus->setText(tr("Invalid rotation point"));
}
else
{
@ -494,6 +537,84 @@ void DialogRotation::PointChanged()
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()
{
@ -506,6 +627,55 @@ void DialogRotation::EvalAngle()
formulaData.checkZero = false;
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();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogRotation::IsValid() const
{
bool ready = flagAngle && flagName && flagError && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -39,6 +39,7 @@
#include "../vmisc/def.h"
#include "dialogtool.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -61,8 +62,6 @@ public:
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -79,6 +78,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -90,6 +92,8 @@ private slots:
void SuffixChanged();
void GroupNameChanged();
void EvalAngle();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -115,7 +119,7 @@ private:
/** @brief formulaBaseHeightAngle base height defined by dialogui */
int formulaBaseHeightAngle;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
@ -128,14 +132,14 @@ private:
bool flagName;
bool flagGroupName;
bool flagError;
bool flagAlias{true};
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

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>338</height>
<width>410</width>
<height>485</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +28,35 @@
<string>Tool</string>
</attribute>
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
@ -287,6 +316,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -38,12 +38,9 @@
#include "../vgeometry/vsplinepath.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const QString &notes, QGraphicsItem *parent)
: VAbstractOperation(doc, data, id, suffix, source, destination, notes, parent)
{
}
VAbstractFlipping::VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent)
: VAbstractOperation(initData, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
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
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
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()))
{
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));
break;
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));
break;
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));
break;
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));
break;
case GOType::SplinePath:
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint,
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, fPoint,
sPoint, initData.suffix,
initData.data));
break;
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));
break;
case GOType::CubicBezierPath:
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint,
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object, fPoint,
sPoint, initData.suffix,
initData.data));
break;
@ -108,8 +105,8 @@ QT_WARNING_POP
{
for (int i = 0; i < initData.source.size(); ++i)
{
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
const SourceItem object = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
// 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.");
@ -121,31 +118,31 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case GOType::Point:
{
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;
}
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);
break;
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);
break;
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);
break;
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);
break;
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);
break;
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);
break;
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 QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.setName(sItem.alias);
}
DestinationItem item;
item.mx = rotated.mx();
item.my = rotated.my();
@ -180,33 +182,39 @@ DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, c
//---------------------------------------------------------------------------------------------------------------------
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 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);
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 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);
rotated.setIdObject(idTool);
rotated.setMx(item.mx);
rotated.setMy(item.my);
rotated.SetShowLabel(item.showLabel);
if (not sItem.alias.isEmpty())
{
rotated.setName(sItem.alias);
}
data->UpdateGObject(item.id, new VPointF(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id)
void VAbstractFlipping::UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
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);
}

View File

@ -39,41 +39,40 @@ class VAbstractFlipping : public VAbstractOperation
public:
virtual ~VAbstractFlipping() Q_DECL_EQ_DEFAULT;
protected:
VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination, const QString &notes,
QGraphicsItem *parent = nullptr);
explicit VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr);
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);
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);
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);
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);
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);
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, const DestinationItem &item);
static void UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
const DestinationItem &item);
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
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,
quint32 id);
private:
@ -82,13 +81,18 @@ private:
//---------------------------------------------------------------------------------------------------------------------
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 QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.SetAliasSuffix(sItem.alias);
}
DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
@ -98,52 +102,58 @@ DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, co
//---------------------------------------------------------------------------------------------------------------------
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 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);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix,
VContainer *data)
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem,
const QPointF &firstPoint, 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->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return 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 QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.SetAliasSuffix(sItem.alias);
}
data->UpdateGObject(id, new Item(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
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,
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);
}

View File

@ -75,6 +75,7 @@ void VToolFlippingByAxis::setDialog()
dialogTool->SetAxisType(m_axisType);
dialogTool->SetSuffix(suffix);
dialogTool->SetNotes(m_notes);
dialogTool->SetSourceObjects(source);
SetDialogVisibilityGroupData(dialogTool);
}
@ -91,7 +92,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer<DialogTool> &dia
initData.originPointId = dialogTool->GetOriginPointId();
initData.axisType = dialogTool->GetAxisType();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.source = dialogTool->GetSourceObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
@ -141,9 +142,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
InitOperationToolConnections(initData.scene, tool);
VAbstractPattern::AddTool(initData.id, tool);
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)
@ -206,7 +207,7 @@ void VToolFlippingByAxis::SetVisualization()
VisToolFlippingByAxis *visual = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(visual != nullptr)
visual->SetObjects(source);
visual->SetObjects(SourceToObjects(source));
visual->SetOriginPointId(m_originPointId);
visual->SetAxisType(m_axisType);
visual->RefreshGeometry();
@ -231,6 +232,9 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList<quint32> &ol
const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
// Save visibility data for later use
SaveVisibilityGroupData(dialogTool);
}
@ -242,7 +246,6 @@ void VToolFlippingByAxis::ReadToolAttributes(const QDomElement &domElement)
m_originPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
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, AttrCenter, QString().setNum(m_originPointId));
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)
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
initData.destination, initData.notes, parent),
: VAbstractFlipping(initData, parent),
m_originPointId(initData.originPointId),
m_axisType(initData.axisType)
{

View File

@ -75,6 +75,7 @@ void VToolFlippingByLine::setDialog()
dialogTool->SetSecondLinePointId(m_secondLinePointId);
dialogTool->SetSuffix(suffix);
dialogTool->SetNotes(m_notes);
dialogTool->SetSourceObjects(source);
SetDialogVisibilityGroupData(dialogTool);
}
@ -91,7 +92,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer<DialogTool> &dia
initData.firstLinePointId = dialogTool->GetFirstLinePointId();
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.source = dialogTool->GetSourceObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
@ -135,9 +136,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
VAbstractPattern::AddTool(initData.id, tool);
initData.doc->IncrementReferens(firstPoint.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)
@ -191,7 +192,7 @@ void VToolFlippingByLine::SetVisualization()
VisToolFlippingByLine *visual = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(visual != nullptr)
visual->SetObjects(source);
visual->SetObjects(SourceToObjects(source));
visual->SetFirstLinePointId(m_firstLinePointId);
visual->SetSecondLinePointId(m_secondLinePointId);
visual->RefreshGeometry();
@ -218,6 +219,9 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList<quint32> &ol
const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
// Save visibility data for later use
SaveVisibilityGroupData(dialogTool);
}
@ -229,7 +233,6 @@ void VToolFlippingByLine::ReadToolAttributes(const QDomElement &domElement)
m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, 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, AttrP1Line, QString().setNum(m_firstLinePointId));
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)
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
initData.destination, initData.notes, parent),
: VAbstractFlipping(initData, parent),
m_firstLinePointId(initData.firstLinePointId),
m_secondLinePointId(initData.secondLinePointId)
{

View File

@ -46,15 +46,15 @@ namespace
* @param source list with source objects
* @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;
for (auto &sId : source)
for (auto &sItem : source)
{
try
{
groupData.insert(sId, data->GetGObject(sId)->getIdTool());
groupData.insert(sItem.id, data->GetGObject(sItem.id)->getIdTool());
}
catch (const VExceptionBadId &)
{
@ -98,7 +98,7 @@ QVector<QString> VAbstractOperation::SourceItems() const
{
for (auto &item : source)
{
itemNames.append(VAbstractTool::data.GetGObject(item)->name());
itemNames.append(VAbstractTool::data.GetGObject(item.id)->ObjectName());
}
}
catch (const VExceptionBadId &e)
@ -201,27 +201,49 @@ void VAbstractOperation::SetLabelVisible(quint32 id, bool visible)
//---------------------------------------------------------------------------------------------------------------------
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();
for (qint32 i = 0; i < nodeList.size(); ++i)
{
const QDomElement dataElement = nodeList.at(i).toElement();
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
{
initData.source.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
const QDomElement element = srcList.at(j).toElement();
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)
{
initData.destination.clear();
const QDomNodeList srcList = dataElement.childNodes();
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.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
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,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const QString &notes, QGraphicsItem *parent)
: VDrawTool(doc, data, id, notes),
VAbstractOperation::VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent)
: VDrawTool(initData.doc, initData.data, initData.id, initData.notes),
QGraphicsLineItem(parent),
suffix(suffix),
source(source),
destination(destination),
suffix(initData.suffix),
source(initData.source),
destination(initData.destination),
operatedObjects()
{
connect(doc, &VAbstractPattern::UpdateToolTip, this, [this]()
connect(initData.doc, &VAbstractPattern::UpdateToolTip, this, [this]()
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
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)
{
@ -695,10 +739,11 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
doc->RemoveAllChildren(tag);
QDomElement tagObjects = doc->createElement(TagSource);
for (auto id : qAsConst(source))
for (auto sItem : qAsConst(source))
{
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);
}
tag.appendChild(tagObjects);
@ -709,13 +754,13 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, dItem.id);
if (not VFuzzyComparePossibleNulls(dItem.mx, INT_MAX) &&
not VFuzzyComparePossibleNulls(dItem.my, INT_MAX))
{
doc->SetAttribute(item, AttrMx, qApp->fromPixel(dItem.mx));
doc->SetAttribute(item, AttrMy, qApp->fromPixel(dItem.my));
doc->SetAttribute<bool>(item, AttrShowLabel, dItem.showLabel);
}
VAbstractSimple *obj = operatedObjects.value(dItem.id);
doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx),
obj && obj->GetType() != GOType::Point);
doc->SetAttributeOrRemoveIf(item, AttrMy, qApp->fromPixel(dItem.my),
obj && obj->GetType() != GOType::Point);
doc->SetAttributeOrRemoveIf<bool>(item, AttrShowLabel, dItem.showLabel, dItem.showLabel);
tagObjects.appendChild(item);
}
@ -888,7 +933,7 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
"%6"
"</table>")
.arg(tr("Label"), curve->name(), tr("Length"))
.arg(tr("Label"), curve->ObjectName(), tr("Length"))
.arg(qApp->fromPixel(curve->GetLength()))
.arg(UnitsToStr(qApp->patternUnits(), true), MakeToolTip());
return toolTip;

View File

@ -41,6 +41,7 @@
#include "../vdrawtool.h"
#include "../vwidgets/vsimplecurve.h"
#include "../vwidgets/vsimplepoint.h"
#include "../../toolsdef.h"
struct DestinationItem
{
@ -57,7 +58,7 @@ struct VAbstractOperationInitData : VDrawToolInitData
{}
QString suffix{};
QVector<quint32> source{};
QVector<SourceItem> source{};
QVector<DestinationItem> destination{};
QString visibilityGroupName{};
QStringList visibilityGroupTags{};
@ -95,6 +96,8 @@ public:
virtual void SetLabelVisible(quint32 id, bool visible) override;
static void ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData);
static QVector<SourceItem> ExtractSourceData(const QDomElement &domElement);
static QVector<DestinationItem> ExtractDestinationData(const QDomElement &domElement);
public slots:
virtual void FullUpdateFromFile() override;
@ -128,7 +131,7 @@ public slots:
protected:
QString suffix;
QVector<quint32> source;
QVector<SourceItem> source;
QVector<DestinationItem> destination;
QMap<quint32, VAbstractSimple *> operatedObjects;
@ -137,15 +140,15 @@ protected:
QString groupName{};
QStringList groupTags{};
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const QString &notes, QGraphicsItem *parent = nullptr);
explicit VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr);
virtual void AddToFile() override;
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
virtual void ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
const QDomElement &oldDomElement, const QDomElement &newDomElement) 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 SaveSourceDestination(QDomElement &tag);

View File

@ -78,13 +78,13 @@ namespace
{
QT_WARNING_PUSH
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;
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
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()))
{
case GOType::Point:
originObjects.append(data->GeometricObject<VPointF>(id)->toQPointF());
originObjects.append(data->GeometricObject<VPointF>(object.id)->toQPointF());
break;
case GOType::Arc:
case GOType::EllipticalArc:
@ -100,7 +100,7 @@ QPointF GetOriginPoint(const QVector<quint32> objects, const VContainer *data, q
case GOType::SplinePath:
case GOType::CubicBezier:
case GOType::CubicBezierPath:
AppendTo(originObjects, data->GeometricObject<VAbstractCurve>(id)->GetPoints());
AppendTo(originObjects, data->GeometricObject<VAbstractCurve>(object.id)->GetPoints());
break;
case GOType::Unknown:
case GOType::PlaceLabel:
@ -129,6 +129,7 @@ void VToolMove::setDialog()
dialogTool->SetSuffix(suffix);
dialogTool->SetRotationOrigPointId(origPointId);
dialogTool->SetNotes(m_notes);
dialogTool->SetSourceObjects(source);
SetDialogVisibilityGroupData(dialogTool);
}
@ -147,7 +148,7 @@ VToolMove *VToolMove::Create(const QPointer<DialogTool> &dialog, VMainGraphicsSc
initData.formulaLength = dialogTool->GetLength();
initData.rotationOrigin = dialogTool->GetRotationOrigPointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.source = dialogTool->GetSourceObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
@ -196,9 +197,9 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData)
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
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()))
{
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,
initData.data));
break;
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,
initData.data));
break;
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,
initData.suffix, initData.data));
break;
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,
initData.data));
break;
case GOType::SplinePath:
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle,
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle,
calcLength, calcRotationAngle,
rotationOrigin, initData.suffix,
initData.data));
break;
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,
initData.suffix, initData.data));
break;
case GOType::CubicBezierPath:
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject,
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object,
calcAngle, calcLength,
calcRotationAngle,
rotationOrigin,
@ -258,8 +259,8 @@ QT_WARNING_POP
{
for (int i = 0; i < initData.source.size(); ++i)
{
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
const SourceItem object = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
// 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.");
@ -269,34 +270,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
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));
break;
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);
break;
case GOType::EllipticalArc:
UpdateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength, calcRotationAngle,
UpdateArc<VEllipticalArc>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
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);
break;
case GOType::SplinePath:
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle, calcLength,
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength,
calcRotationAngle, rotationOrigin,initData.suffix,
initData.data, initData.destination.at(i).id);
break;
case GOType::CubicBezier:
UpdateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength, calcRotationAngle,
UpdateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin,initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::CubicBezierPath:
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, calcAngle, calcLength,
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, calcAngle, calcLength,
calcRotationAngle, rotationOrigin,
initData.suffix, initData.data,
initData.destination.at(i).id);
@ -332,9 +333,9 @@ QT_WARNING_POP
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)
@ -458,7 +459,7 @@ void VToolMove::SetVisualization()
VisToolMove *visual = qobject_cast<VisToolMove *>(vis);
SCASSERT(visual != nullptr)
visual->SetObjects(source);
visual->SetObjects(SourceToObjects(source));
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle,
qApp->Settings()->GetOsSeparator()));
@ -487,6 +488,9 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
// Save visibility data for later use
SaveVisibilityGroupData(dialogTool);
}
@ -500,7 +504,6 @@ void VToolMove::ReadToolAttributes(const QDomElement &domElement)
formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0'));
formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, 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, AttrRotationAngle, formulaRotationAngle);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrSuffix, suffix);
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
@ -540,8 +540,7 @@ QString VToolMove::MakeToolTip() const
//---------------------------------------------------------------------------------------------------------------------
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
initData.destination, initData.notes, parent),
: VAbstractOperation(initData, parent),
formulaAngle(initData.formulaAngle),
formulaRotationAngle(initData.formulaRotationAngle),
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,
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);
moved.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
moved.setName(sItem.alias);
}
DestinationItem item;
item.mx = moved.mx();
item.my = moved.my();
@ -570,47 +574,60 @@ DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal ang
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
DestinationItem VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
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->AddArc(data->GeometricObject<Item>(item.id), item.id);
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 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);
moved.setIdObject(idTool);
moved.setMx(item.mx);
moved.setMy(item.my);
moved.SetShowLabel(item.showLabel);
if (not sItem.alias.isEmpty())
{
moved.setName(sItem.alias);
}
data->UpdateGObject(item.id, new VPointF(moved));
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
DestinationItem VToolMove::CreateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
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);
moved.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
moved.SetAliasSuffix(sItem.alias);
}
DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
@ -620,10 +637,11 @@ DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angl
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
DestinationItem VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
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->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
@ -631,12 +649,12 @@ DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal ang
//---------------------------------------------------------------------------------------------------------------------
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,
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->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return item;
@ -644,30 +662,36 @@ DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, quint32 idIte
//---------------------------------------------------------------------------------------------------------------------
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 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);
moved.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
moved.SetAliasSuffix(sItem.alias);
}
data->UpdateGObject(id, new Item(moved));
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolMove::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
quint32 id)
void VToolMove::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
qreal rotationAngle, 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->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
}

View File

@ -104,41 +104,45 @@ private:
QString formulaLength;
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,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin,const QString &suffix, VContainer *data);
static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
qreal rotationAngle, const QPointF &rotationOrigin,const QString &suffix,
VContainer *data);
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,
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 DestinationItem &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);
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);
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);
template <class Item>
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
quint32 id);
static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length,
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
VContainer *data, quint32 id);
};
#endif // VTOOLMOVING_H

View File

@ -80,8 +80,7 @@ const QString VToolRotation::ToolType = QStringLiteral("rotation");
//---------------------------------------------------------------------------------------------------------------------
VToolRotation::VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent)
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
initData.destination, initData.notes, parent),
: VAbstractOperation(initData, parent),
origPointId(initData.origin),
formulaAngle(initData.angle)
{
@ -99,6 +98,7 @@ void VToolRotation::setDialog()
dialogTool->SetAngle(formulaAngle);
dialogTool->SetSuffix(suffix);
dialogTool->SetNotes(m_notes);
dialogTool->SetSourceObjects(source);
SetDialogVisibilityGroupData(dialogTool);
}
@ -115,7 +115,7 @@ VToolRotation *VToolRotation::Create(const QPointer<DialogTool> &dialog, VMainGr
initData.origin = dialogTool->GetOrigPointId();
initData.angle = dialogTool->GetAngle();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.source = dialogTool->GetSourceObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
@ -150,9 +150,9 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
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
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()))
{
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));
break;
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));
break;
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));
break;
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));
break;
case GOType::SplinePath:
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint,
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, oPoint,
calcAngle, initData.suffix,
initData.data));
break;
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));
break;
case GOType::CubicBezierPath:
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint,
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object, oPoint,
calcAngle, initData.suffix,
initData.data));
break;
@ -203,8 +203,8 @@ QT_WARNING_POP
{
for (int i = 0; i < initData.source.size(); ++i)
{
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
const SourceItem object = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
// 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.");
@ -215,32 +215,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
{
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));
break;
}
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);
break;
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);
break;
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);
break;
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);
break;
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);
break;
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);
break;
case GOType::Unknown:
@ -269,9 +269,9 @@ QT_WARNING_POP
InitOperationToolConnections(initData.scene, tool);
VAbstractPattern::AddTool(initData.id, tool);
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)
@ -342,7 +342,7 @@ void VToolRotation::SetVisualization()
VisToolRotation *visual = qobject_cast<VisToolRotation *>(vis);
SCASSERT(visual != nullptr)
visual->SetObjects(source);
visual->SetObjects(SourceToObjects(source));
visual->SetOriginPointId(origPointId);
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
visual->RefreshGeometry();
@ -367,6 +367,9 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
// Save visibility data for later use
SaveVisibilityGroupData(dialogTool);
}
@ -378,7 +381,6 @@ void VToolRotation::ReadToolAttributes(const QDomElement &domElement)
origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
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, AttrCenter, QString().setNum(origPointId));
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 QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
VPointF rotated = point->Rotate(origin, angle, suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.setName(sItem.alias);
}
DestinationItem item;
item.mx = rotated.mx();
item.my = rotated.my();
@ -423,13 +427,18 @@ DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const
//---------------------------------------------------------------------------------------------------------------------
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 QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
Item rotated = i->Rotate(origin, angle, suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.SetAliasSuffix(sItem.alias);
}
DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
@ -439,81 +448,93 @@ DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const
//---------------------------------------------------------------------------------------------------------------------
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 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);
return 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 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);
return 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)
{
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);
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 QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
VPointF rotated = point->Rotate(origin, angle, suffix);
rotated.setIdObject(idTool);
rotated.setMx(item.mx);
rotated.setMy(item.my);
rotated.SetShowLabel(item.showLabel);
if (not sItem.alias.isEmpty())
{
rotated.setName(sItem.alias);
}
data->UpdateGObject(item.id, new VPointF(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
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 QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
Item rotated = i->Rotate(origin, angle, suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.SetAliasSuffix(sItem.alias);
}
data->UpdateGObject(id, new Item(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
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);
}

View File

@ -95,35 +95,35 @@ private:
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
};

View File

@ -2,6 +2,7 @@
# This need for corect working file translations.pro
HEADERS += \
$$PWD/toolsdef.h \
$$PWD/vdatatool.h \
$$PWD/vabstracttool.h \
$$PWD/tools.h \
@ -64,6 +65,7 @@ HEADERS += \
$$PWD/nodeDetails/vtoolplacelabel.h
SOURCES += \
$$PWD/toolsdef.cpp \
$$PWD/vdatatool.cpp \
$$PWD/vabstracttool.cpp \
$$PWD/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp \

View 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();
}

View 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

View File

@ -57,7 +57,7 @@ VisOperation::~VisOperation()
}
//---------------------------------------------------------------------------------------------------------------------
void VisOperation::SetObjects(QVector<quint32> objects)
void VisOperation::SetObjects(const QVector<quint32> &objects)
{
this->objects = objects;
}

View File

@ -41,7 +41,7 @@ public:
explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisOperation();
void SetObjects(QVector<quint32> objects);
void SetObjects(const QVector<quint32> &objects);
virtual void VisualMode(const quint32 &pointId = NULL_ID) override;