diff --git a/ChangeLog.txt b/ChangeLog.txt
index 4ea913b1d..c3367696f 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -43,6 +43,7 @@
- Change default values for grainline length and pattern label size to 10 cm.
- Tool Point at distance and angle now allows negative length.
- Export pattern to DXF-ASTM.
+- [smart-pattern/valentina#18] Auto-created Visibility Group for group operation.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.
diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp
index 1c8daff83..fc2de00bf 100644
--- a/src/app/valentina/dialogs/vwidgetgroups.cpp
+++ b/src/app/valentina/dialogs/vwidgetgroups.cpp
@@ -148,9 +148,9 @@ void VWidgetGroups::RenameGroup(int row, int column)
}
const quint32 id = ui->tableWidget->item(row, 0)->data(Qt::UserRole).toUInt();
- doc->SetGroupName(id, ui->tableWidget->item(row, column)->text());
-
- UpdateGroups();
+ ::RenameGroup *renameGroup = new ::RenameGroup(doc, id, ui->tableWidget->item(row, column)->text());
+ connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
+ qApp->getUndoStack()->push(renameGroup);
}
//---------------------------------------------------------------------------------------------------------------------
@@ -209,9 +209,9 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
if (result == QDialog::Accepted)
{
- doc->SetGroupName(id, dialog->GetName());
- item = ui->tableWidget->item(row, 1);
- item->setText(dialog->GetName());
+ ::RenameGroup *renameGroup = new ::RenameGroup(doc, id, dialog->GetName());
+ connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
+ qApp->getUndoStack()->push(renameGroup);
}
}
else if (selectedAction == actionDelete)
diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc
index bf0597e5d..5d41d6883 100644
--- a/src/libs/ifc/schema.qrc
+++ b/src/libs/ifc/schema.qrc
@@ -58,6 +58,7 @@
schema/pattern/v0.8.4.xsd
schema/pattern/v0.8.5.xsd
schema/pattern/v0.8.6.xsd
+ schema/pattern/v0.8.7.xsd
schema/standard_measurements/v0.3.0.xsd
schema/standard_measurements/v0.4.0.xsd
schema/standard_measurements/v0.4.1.xsd
diff --git a/src/libs/ifc/schema/pattern/v0.8.7.xsd b/src/libs/ifc/schema/pattern/v0.8.7.xsd
new file mode 100644
index 000000000..7518ebdb6
--- /dev/null
+++ b/src/libs/ifc/schema/pattern/v0.8.7.xsd
@@ -0,0 +1,1253 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp
index 1f010cc0d..9fcd24466 100644
--- a/src/libs/ifc/xml/vabstractpattern.cpp
+++ b/src/libs/ifc/xml/vabstractpattern.cpp
@@ -1730,6 +1730,12 @@ void VAbstractPattern::SelectedDetail(quint32 id)
emit ShowDetail(id);
}
+//---------------------------------------------------------------------------------------------------------------------
+void VAbstractPattern::UpdateVisiblityGroups()
+{
+ emit UpdateGroups();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::ToolExists(const quint32 &id)
{
@@ -2422,7 +2428,8 @@ QDomElement VAbstractPattern::CreateGroups()
}
//---------------------------------------------------------------------------------------------------------------------
-QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap &groupData)
+QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap &groupData,
+ vidtype tool)
{
if (id == NULL_ID || groupData.isEmpty())
{
@@ -2433,6 +2440,7 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const
SetAttribute(group, AttrId, id);
SetAttribute(group, AttrName, name);
SetAttribute(group, AttrVisible, true);
+ SetAttributeOrRemoveIf(group, AttrTool, tool, tool == null_id);
auto i = groupData.constBegin();
while (i != groupData.constEnd())
@@ -2446,66 +2454,50 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const
return group;
}
+//---------------------------------------------------------------------------------------------------------------------
+vidtype VAbstractPattern::GroupLinkedToTool(vidtype toolId) const
+{
+ const QDomNodeList groups = elementsByTagName(TagGroup);
+ for (int i=0; i < groups.size(); ++i)
+ {
+ const QDomElement group = groups.at(i).toElement();
+ if (not group.isNull() && group.hasAttribute(AttrTool))
+ {
+ const quint32 id = GetParametrUInt(group, AttrTool, NULL_ID_STR);
+
+ if (toolId == id)
+ {
+ return GetParametrUInt(group, AttrId, NULL_ID_STR);
+ }
+ }
+ }
+
+ return null_id;
+}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetGroupName(quint32 id)
{
QString name = tr("New group");
- QDomElement groups = CreateGroups();
- if (not groups.isNull())
+ QDomElement group = elementById(id, TagGroup);
+ if (group.isElement())
{
- QDomElement group = elementById(id, TagGroup);
- if (group.isElement())
- {
- name = GetParametrString(group, AttrName, name);
- return name;
- }
- else
- {
- if (groups.childNodes().isEmpty())
- {
- QDomNode parent = groups.parentNode();
- parent.removeChild(groups);
- }
+ name = GetParametrString(group, AttrName, name);
- qDebug("Can't get group by id = %u.", id);
- return name;
- }
- }
- else
- {
- qDebug("Can't get tag Groups.");
- return name;
}
+
+ return name;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetGroupName(quint32 id, const QString &name)
{
- QDomElement groups = CreateGroups();
- if (not groups.isNull())
+ QDomElement group = elementById(id, TagGroup);
+ if (group.isElement())
{
- QDomElement group = elementById(id, TagGroup);
- if (group.isElement())
- {
- group.setAttribute(AttrName, name);
- modified = true;
- emit patternChanged(false);
- }
- else
- {
- if (groups.childNodes().isEmpty())
- {
- QDomNode parent = groups.parentNode();
- parent.removeChild(groups);
- }
-
- qDebug("Can't get group by id = %u.", id);
- }
- }
- else
- {
- qDebug("Can't get tag Groups.");
+ group.setAttribute(AttrName, name);
+ modified = true;
+ emit patternChanged(false);
}
}
diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h
index 55167d2d0..44899794e 100644
--- a/src/libs/ifc/xml/vabstractpattern.h
+++ b/src/libs/ifc/xml/vabstractpattern.h
@@ -200,7 +200,9 @@ public:
void ParseGroups(const QDomElement &domElement);
QDomElement CreateGroups();
- QDomElement CreateGroup(quint32 id, const QString &name, const QMap &groupData);
+ QDomElement CreateGroup(quint32 id, const QString &name, const QMap &groupData,
+ vidtype tool=null_id);
+ vidtype GroupLinkedToTool(vidtype toolId) const;
QString GetGroupName(quint32 id);
void SetGroupName(quint32 id, const QString &name);
QMap > GetGroups();
@@ -413,6 +415,7 @@ public slots:
void ClearScene();
void CheckInLayoutList();
void SelectedDetail(quint32 id);
+ void UpdateVisiblityGroups();
protected:
/** @brief nameActivDraw name current pattern peace. */
diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp
index 1c29121a5..a38a9dbfc 100644
--- a/src/libs/ifc/xml/vpatternconverter.cpp
+++ b/src/libs/ifc/xml/vpatternconverter.cpp
@@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
-const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.6");
-const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.6.xsd");
+const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.7");
+const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.7.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@@ -236,7 +236,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 8, 3), QStringLiteral("://schema/pattern/v0.8.3.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 4), QStringLiteral("://schema/pattern/v0.8.4.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 5), QStringLiteral("://schema/pattern/v0.8.5.xsd")),
- std::make_pair(FORMAT_VERSION(0, 8, 6), CurrentSchema)
+ std::make_pair(FORMAT_VERSION(0, 8, 6), QStringLiteral("://schema/pattern/v0.8.6.xsd")),
+ std::make_pair(FORMAT_VERSION(0, 8, 7), CurrentSchema)
};
if (schemas.contains(ver))
@@ -481,6 +482,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 6)));
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 6)):
+ ToV0_8_7();
+ ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 7)));
+ Q_FALLTHROUGH();
+ case (FORMAT_VERSION(0, 8, 7)):
break;
default:
InvalidVersion(m_ver);
@@ -498,7 +503,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
- Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 6),
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 7),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@@ -1128,6 +1133,16 @@ void VPatternConverter::ToV0_8_6()
Save();
}
+//---------------------------------------------------------------------------------------------------------------------
+void VPatternConverter::ToV0_8_7()
+{
+ // TODO. Delete if minimal supported version is 0.8.7
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 7),
+ "Time to refactor the code.");
+ SetVersion(QStringLiteral("0.8.7"));
+ Save();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{
diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h
index 944820654..1adaabee3 100644
--- a/src/libs/ifc/xml/vpatternconverter.h
+++ b/src/libs/ifc/xml/vpatternconverter.h
@@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
- static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 6);
+ static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 7);
protected:
virtual int MinVer() const override;
@@ -129,6 +129,7 @@ private:
void ToV0_8_4();
void ToV0_8_5();
void ToV0_8_6();
+ void ToV0_8_7();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();
diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp
index b9e746971..00b70fc59 100644
--- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp
@@ -67,6 +67,7 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolI
stage1(true),
m_suffix(),
flagName(true),
+ flagGroupName(true),
flagError(false)
{
ui->setupUi(this);
@@ -81,6 +82,7 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolI
ui->comboBoxOriginPoint->setCurrentIndex(-1);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByAxis::SuffixChanged);
+ connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogFlippingByAxis::GroupNameChanged);
connect(ui->comboBoxOriginPoint, &QComboBox::currentTextChanged,
this, &DialogFlippingByAxis::PointChanged);
@@ -147,6 +149,30 @@ QVector DialogFlippingByAxis::GetObjects() const
return ConvertToVector(objects);
}
+//---------------------------------------------------------------------------------------------------------------------
+QString DialogFlippingByAxis::GetVisibilityGroupName() const
+{
+ return ui->lineEditVisibilityGroup->text();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogFlippingByAxis::SetVisibilityGroupName(const QString &name)
+{
+ ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool DialogFlippingByAxis::HasLinkedVisibilityGroup() const
+{
+ return ui->groupBoxVisibilityGroup->isChecked();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogFlippingByAxis::SetHasLinkedVisibilityGroup(bool linked)
+{
+ ui->groupBoxVisibilityGroup->setChecked(linked);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowDialog(bool click)
{
@@ -277,6 +303,27 @@ void DialogFlippingByAxis::SuffixChanged()
CheckState();
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogFlippingByAxis::GroupNameChanged()
+{
+ QLineEdit* edit = qobject_cast(sender());
+ if (edit)
+ {
+ const QString name = edit->text();
+ if (name.isEmpty())
+ {
+ flagGroupName = false;
+ ChangeColor(ui->labelGroupName, errorColor);
+ CheckState();
+ return;
+ }
+
+ flagGroupName = true;
+ ChangeColor(ui->labelGroupName, OkColor(this));
+ }
+ CheckState();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowVisualization()
{
diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h
index 0b31ac1ce..680ceb517 100644
--- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h
+++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h
@@ -65,6 +65,12 @@ public:
QVector GetObjects() const;
+ QString GetVisibilityGroupName() const;
+ void SetVisibilityGroupName(const QString &name);
+
+ bool HasLinkedVisibilityGroup() const;
+ void SetHasLinkedVisibilityGroup(bool linked);
+
virtual void ShowDialog(bool click) override;
public slots:
@@ -73,6 +79,7 @@ public slots:
private slots:
void SuffixChanged();
+ void GroupNameChanged();
protected:
virtual void ShowVisualization() override;
@@ -96,6 +103,7 @@ private:
QString m_suffix;
bool flagName;
+ bool flagGroupName;
bool flagError;
static void FillComboBoxAxisType(QComboBox *box);
@@ -104,7 +112,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogFlippingByAxis::IsValid() const
{
- return flagError && flagName;
+ return flagError && flagName && flagGroupName;
}
#endif // DIALOGFLIPPINGBYAXIS_H
diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui
index d21839e55..fc4491b3c 100644
--- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui
+++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui
@@ -6,8 +6,8 @@
0
0
- 285
- 146
+ 304
+ 207
@@ -48,6 +48,41 @@
+ -
+
+
+ Enable to create a visibility gropup from original objects
+
+
+ Visibility Group
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+ Name:
+
+
+
+ -
+
+
+ Flipping by axis
+
+
+ true
+
+
+
+
+
+
-
diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp
index bf62e73c3..60044b33c 100644
--- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp
@@ -79,6 +79,7 @@ DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolI
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByLine::SuffixChanged);
+ connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogFlippingByLine::GroupNameChanged);
connect(ui->comboBoxFirstLinePoint, &QComboBox::currentTextChanged,
this, &DialogFlippingByLine::PointChanged);
connect(ui->comboBoxSecondLinePoint, &QComboBox::currentTextChanged,
@@ -142,6 +143,30 @@ QVector DialogFlippingByLine::GetObjects() const
return ConvertToVector(objects);
}
+//---------------------------------------------------------------------------------------------------------------------
+QString DialogFlippingByLine::GetVisibilityGroupName() const
+{
+ return ui->lineEditVisibilityGroup->text();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogFlippingByLine::SetVisibilityGroupName(const QString &name)
+{
+ ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool DialogFlippingByLine::HasLinkedVisibilityGroup() const
+{
+ return ui->groupBoxVisibilityGroup->isChecked();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogFlippingByLine::SetHasLinkedVisibilityGroup(bool linked)
+{
+ ui->groupBoxVisibilityGroup->setChecked(linked);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowDialog(bool click)
{
@@ -301,6 +326,27 @@ void DialogFlippingByLine::SuffixChanged()
CheckState();
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogFlippingByLine::GroupNameChanged()
+{
+ QLineEdit* edit = qobject_cast(sender());
+ if (edit)
+ {
+ const QString name = edit->text();
+ if (name.isEmpty())
+ {
+ flagGroupName = false;
+ ChangeColor(ui->labelGroupName, errorColor);
+ CheckState();
+ return;
+ }
+
+ flagGroupName = true;
+ ChangeColor(ui->labelGroupName, OkColor(this));
+ }
+ CheckState();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowVisualization()
{
diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.h b/src/libs/vtools/dialogs/tools/dialogflippingbyline.h
index b4334b4e7..be12128b6 100644
--- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.h
+++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.h
@@ -65,6 +65,12 @@ public:
QVector GetObjects() const;
+ QString GetVisibilityGroupName() const;
+ void SetVisibilityGroupName(const QString &name);
+
+ bool HasLinkedVisibilityGroup() const;
+ void SetHasLinkedVisibilityGroup(bool linked);
+
virtual void ShowDialog(bool click) override;
public slots:
@@ -73,6 +79,7 @@ public slots:
private slots:
void SuffixChanged();
+ void GroupNameChanged();
protected:
virtual void ShowVisualization() override;
@@ -96,13 +103,14 @@ private:
QString m_suffix;
bool flagName;
+ bool flagGroupName;
bool flagError;
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogFlippingByLine::IsValid() const
{
- return flagError && flagName;
+ return flagError && flagName && flagGroupName;
}
#endif // DIALOGFLIPPINGBYLINE_H
diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui b/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui
index fc76e9099..7fa0ffcc0 100644
--- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui
+++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui
@@ -6,8 +6,8 @@
0
0
- 285
- 146
+ 304
+ 207
@@ -52,6 +52,41 @@
+ -
+
+
+ Enable to create a visibility gropup from original objects
+
+
+ Visibility Group
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+ Name:
+
+
+
+ -
+
+
+ Flipping by line
+
+
+ true
+
+
+
+
+
+
-
diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp
index 2c9a3ee2a..2d84a78b8 100644
--- a/src/libs/vtools/dialogs/tools/dialogmove.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp
@@ -85,7 +85,8 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
flagAngle(false),
flagRotationAngle(false),
flagLength(false),
- flagName(true)
+ flagName(true),
+ flagGroupName(true)
{
ui->setupUi(this);
@@ -118,6 +119,7 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
ui->comboBoxRotationOriginPoint->blockSignals(false);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
+ connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogMove::GroupNameChanged);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogMove::FXAngle);
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogMove::FXRotationAngle);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogMove::FXLength);
@@ -257,6 +259,30 @@ QVector DialogMove::GetObjects() const
return ConvertToVector(objects);
}
+//---------------------------------------------------------------------------------------------------------------------
+QString DialogMove::GetVisibilityGroupName() const
+{
+ return ui->lineEditVisibilityGroup->text();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogMove::SetVisibilityGroupName(const QString &name)
+{
+ ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool DialogMove::HasLinkedVisibilityGroup() const
+{
+ return ui->groupBoxVisibilityGroup->isChecked();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogMove::SetHasLinkedVisibilityGroup(bool linked)
+{
+ ui->groupBoxVisibilityGroup->setChecked(linked);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowDialog(bool click)
{
@@ -481,6 +507,27 @@ void DialogMove::SuffixChanged()
CheckState();
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogMove::GroupNameChanged()
+{
+ QLineEdit* edit = qobject_cast(sender());
+ if (edit)
+ {
+ const QString name = edit->text();
+ if (name.isEmpty())
+ {
+ flagGroupName = false;
+ ChangeColor(ui->labelGroupName, errorColor);
+ CheckState();
+ return;
+ }
+
+ flagGroupName = true;
+ ChangeColor(ui->labelGroupName, OkColor(this));
+ }
+ CheckState();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowVisualization()
{
diff --git a/src/libs/vtools/dialogs/tools/dialogmove.h b/src/libs/vtools/dialogs/tools/dialogmove.h
index 632ad3b26..8a6c582a5 100644
--- a/src/libs/vtools/dialogs/tools/dialogmove.h
+++ b/src/libs/vtools/dialogs/tools/dialogmove.h
@@ -70,6 +70,12 @@ public:
QVector GetObjects() const;
+ QString GetVisibilityGroupName() const;
+ void SetVisibilityGroupName(const QString &name);
+
+ bool HasLinkedVisibilityGroup() const;
+ void SetHasLinkedVisibilityGroup(bool linked);
+
virtual void ShowDialog(bool click) override;
public slots:
@@ -87,6 +93,7 @@ private slots:
void FXLength();
void SuffixChanged();
+ void GroupNameChanged();
protected:
virtual void ShowVisualization() override;
@@ -129,6 +136,7 @@ private:
bool flagRotationAngle;
bool flagLength;
bool flagName;
+ bool flagGroupName;
void EvalAngle();
void EvalRotationAngle();
@@ -138,7 +146,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogMove::IsValid() const
{
- return flagAngle && flagRotationAngle && flagLength && flagName;
+ return flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName;
}
#endif // DIALOGMOVING_H
diff --git a/src/libs/vtools/dialogs/tools/dialogmove.ui b/src/libs/vtools/dialogs/tools/dialogmove.ui
index 2dcc1d530..d662c530e 100644
--- a/src/libs/vtools/dialogs/tools/dialogmove.ui
+++ b/src/libs/vtools/dialogs/tools/dialogmove.ui
@@ -6,8 +6,8 @@
0
0
- 292
- 332
+ 304
+ 402
@@ -591,6 +591,41 @@
+ -
+
+
+ Enable to create a visibility gropup from original objects
+
+
+ Visibility Group
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+ Name:
+
+
+
+ -
+
+
+ Move
+
+
+ true
+
+
+
+
+
+
-
diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp
index cc9d0404e..fd34ee534 100644
--- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp
@@ -77,6 +77,7 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
m_firstRelease(false),
flagAngle(false),
flagName(true),
+ flagGroupName(true),
flagError(false)
{
ui->setupUi(this);
@@ -94,6 +95,7 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
FillComboBoxPoints(ui->comboBoxOriginPoint);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogRotation::SuffixChanged);
+ connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogRotation::GroupNameChanged);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogRotation::FXAngle);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
{
@@ -170,6 +172,30 @@ QVector DialogRotation::GetObjects() const
return ConvertToVector(objects);
}
+//---------------------------------------------------------------------------------------------------------------------
+QString DialogRotation::GetVisibilityGroupName() const
+{
+ return ui->lineEditVisibilityGroup->text();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogRotation::SetVisibilityGroupName(const QString &name)
+{
+ ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool DialogRotation::HasLinkedVisibilityGroup() const
+{
+ return ui->groupBoxVisibilityGroup->isChecked();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogRotation::SetHasLinkedVisibilityGroup(bool linked)
+{
+ ui->groupBoxVisibilityGroup->setChecked(linked);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowDialog(bool click)
{
@@ -366,6 +392,27 @@ void DialogRotation::SuffixChanged()
CheckState();
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogRotation::GroupNameChanged()
+{
+ QLineEdit* edit = qobject_cast(sender());
+ if (edit)
+ {
+ const QString name = edit->text();
+ if (name.isEmpty())
+ {
+ flagGroupName = false;
+ ChangeColor(ui->labelGroupName, errorColor);
+ CheckState();
+ return;
+ }
+
+ flagGroupName = true;
+ ChangeColor(ui->labelGroupName, OkColor(this));
+ }
+ CheckState();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowVisualization()
{
diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.h b/src/libs/vtools/dialogs/tools/dialogrotation.h
index f26194389..285c3113f 100644
--- a/src/libs/vtools/dialogs/tools/dialogrotation.h
+++ b/src/libs/vtools/dialogs/tools/dialogrotation.h
@@ -63,6 +63,12 @@ public:
QVector GetObjects() const;
+ QString GetVisibilityGroupName() const;
+ void SetVisibilityGroupName(const QString &name);
+
+ bool HasLinkedVisibilityGroup() const;
+ void SetHasLinkedVisibilityGroup(bool linked);
+
virtual void ShowDialog(bool click) override;
public slots:
@@ -74,6 +80,7 @@ private slots:
void DeployAngleTextEdit();
void FXAngle();
void SuffixChanged();
+ void GroupNameChanged();
void EvalAngle();
protected:
@@ -111,13 +118,14 @@ private:
/** @brief flagAngle true if value of angle is correct */
bool flagAngle;
bool flagName;
+ bool flagGroupName;
bool flagError;
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogRotation::IsValid() const
{
- return flagAngle && flagName && flagError;
+ return flagAngle && flagName && flagError && flagGroupName;
}
#endif // DIALOGROTATION_H
diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.ui b/src/libs/vtools/dialogs/tools/dialogrotation.ui
index cae139a96..260c0e9e5 100644
--- a/src/libs/vtools/dialogs/tools/dialogrotation.ui
+++ b/src/libs/vtools/dialogs/tools/dialogrotation.ui
@@ -6,8 +6,8 @@
0
0
- 285
- 189
+ 392
+ 252
@@ -222,6 +222,41 @@
+ -
+
+
+ Enable to create a visibility gropup from original objects
+
+
+ Visibility Group
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+ Name:
+
+
+
+ -
+
+
+ Rotation
+
+
+ true
+
+
+
+
+
+
-
diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp
index e64036d7d..b41237eea 100644
--- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp
+++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp
@@ -74,6 +74,17 @@ void VToolFlippingByAxis::setDialog()
dialogTool->SetOriginPointId(m_originPointId);
dialogTool->SetAxisType(m_axisType);
dialogTool->SetSuffix(suffix);
+
+ vidtype group = doc->GroupLinkedToTool(m_id);
+ if (group != null_id)
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(true);
+ dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
+ }
+ else
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(false);
+ }
}
//---------------------------------------------------------------------------------------------------------------------
@@ -89,6 +100,8 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer &dia
initData.axisType = dialogTool->GetAxisType();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
+ initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
+ initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@@ -123,6 +136,11 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
if (initData.parse == Document::FullParse)
{
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ qApp->getUndoStack()->beginMacro(tr("Flipping by axis"));
+ }
+
VAbstractTool::AddRecord(initData.id, Tool::FlippingByAxis, initData.doc);
VToolFlippingByAxis *tool = new VToolFlippingByAxis(initData);
initData.scene->addItem(tool);
@@ -133,6 +151,13 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
+
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ VAbstractOperation::CreateVisibilityGroup(initData);
+ qApp->getUndoStack()->endMacro();
+ }
+
return tool;
}
return nullptr;
@@ -208,6 +233,10 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList &ol
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId()));
doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast(dialogTool->GetAxisType())));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
+
+ // Save for later use.
+ hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
+ groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp
index 97d161154..943e0d2b1 100644
--- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp
+++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp
@@ -74,6 +74,17 @@ void VToolFlippingByLine::setDialog()
dialogTool->SetFirstLinePointId(m_firstLinePointId);
dialogTool->SetSecondLinePointId(m_secondLinePointId);
dialogTool->SetSuffix(suffix);
+
+ vidtype group = doc->GroupLinkedToTool(m_id);
+ if (group != null_id)
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(true);
+ dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
+ }
+ else
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(false);
+ }
}
//---------------------------------------------------------------------------------------------------------------------
@@ -89,6 +100,8 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer &dia
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
+ initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
+ initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@@ -116,6 +129,11 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
if (initData.parse == Document::FullParse)
{
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ qApp->getUndoStack()->beginMacro(tr("flipping by line"));
+ }
+
VAbstractTool::AddRecord(initData.id, Tool::FlippingByLine, initData.doc);
VToolFlippingByLine *tool = new VToolFlippingByLine(initData);
initData.scene->addItem(tool);
@@ -127,6 +145,13 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
+
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ VAbstractOperation::CreateVisibilityGroup(initData);
+ qApp->getUndoStack()->endMacro();
+ }
+
return tool;
}
return nullptr;
@@ -195,6 +220,10 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList &ol
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
+
+ // Save for later use.
+ hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
+ groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp
index 9d1ad8a3f..5a3e9d086 100644
--- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp
+++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp
@@ -29,12 +29,42 @@
#include "vabstractoperation.h"
#include "../../../undocommands/label/operationmovelabel.h"
#include "../../../undocommands/label/operationshowlabel.h"
+#include "../../../undocommands/savetooloptions.h"
+#include "../../../undocommands/undogroup.h"
#include "../vgeometry/vpointf.h"
const QString VAbstractOperation::TagItem = QStringLiteral("item");
const QString VAbstractOperation::TagSource = QStringLiteral("source");
const QString VAbstractOperation::TagDestination = QStringLiteral("destination");
+namespace
+{
+/**
+ * @brief VisibilityGroupDataFromSource
+ * @param initData
+ * @return
+ */
+QMap VisibilityGroupDataFromSource(const VContainer *data, const QVector &source)
+{
+ QMap groupData;
+
+ for (auto &sId : source)
+ {
+ try
+ {
+ groupData.insert(sId, data->GetGObject(sId)->getIdTool());
+ }
+ catch (const VExceptionBadId &)
+ {
+ // ignore
+ }
+
+ }
+
+ return groupData;
+}
+}
+
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractOperation::getTagName() const
{
@@ -528,6 +558,66 @@ void VAbstractOperation::ChangeLabelVisibility(quint32 id, bool visible)
}
}
+//---------------------------------------------------------------------------------------------------------------------
+void VAbstractOperation::ApplyToolOptions(const QList &oldDependencies, const QList &newDependencies,
+ const QDomElement &oldDomElement, const QDomElement &newDomElement)
+{
+ bool updateToolOptions =
+ newDependencies != oldDependencies || not VDomDocument::Compare(newDomElement, oldDomElement);
+ bool updateVisibilityOptions = NeedUpdateVisibilityGroup();
+
+ if (updateToolOptions && updateVisibilityOptions)
+ {
+ qApp->getUndoStack()->beginMacro(tr("operation options"));
+ }
+
+ if (updateToolOptions)
+ {
+ SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies,
+ newDependencies, doc, m_id);
+ connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
+ qApp->getUndoStack()->push(saveOptions);
+ }
+
+ if (updateVisibilityOptions)
+ {
+ vidtype group = doc->GroupLinkedToTool(m_id);
+
+ if (hasLinkedGroup)
+ {
+ if (group != null_id)
+ {
+ RenameGroup *renameGroup = new RenameGroup(doc, group, groupName);
+ connect(renameGroup, &RenameGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
+ qApp->getUndoStack()->push(renameGroup);
+ }
+ else
+ {
+ VAbstractOperationInitData initData;
+ initData.id = m_id;
+ initData.hasLinkedVisibilityGroup = hasLinkedGroup;
+ initData.visibilityGroupName = groupName;
+ initData.data = &(VDataTool::data);
+ initData.doc = doc;
+ initData.source = source;
+
+ VAbstractOperation::CreateVisibilityGroup(initData);
+ }
+ }
+ else
+ {
+ DelGroup *delGroup = new DelGroup(doc, group);
+ connect(delGroup, &DelGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
+ qApp->getUndoStack()->push(delGroup);
+ }
+ }
+
+ if (updateToolOptions && updateVisibilityOptions)
+ {
+ qApp->getUndoStack()->endMacro();
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
{
@@ -641,6 +731,33 @@ void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type)
}
}
+//---------------------------------------------------------------------------------------------------------------------
+bool VAbstractOperation::NeedUpdateVisibilityGroup() const
+{
+ vidtype group = doc->GroupLinkedToTool(m_id);
+
+ if (hasLinkedGroup)
+ {
+ if (group != null_id)
+ {
+ if (groupName != doc->GetGroupName(group))
+ {
+ return true; // rename group
+ }
+ }
+ else
+ {
+ return true; // create group
+ }
+ }
+ else
+ {
+ return group != null_id; // remove group
+ }
+
+ return false;
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::InitOperatedObjects()
{
@@ -725,3 +842,24 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const
.arg(UnitsToStr(qApp->patternUnit(), true), MakeToolTip());
return toolTip;
}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VAbstractOperation::CreateVisibilityGroup(const VAbstractOperationInitData &initData)
+{
+ if (not initData.hasLinkedVisibilityGroup && not initData.visibilityGroupName.isEmpty())
+ {
+ return;
+ }
+
+ const QMap groupData = VisibilityGroupDataFromSource(initData.data, initData.source);
+ vidtype groupId = initData.data->getNextId();
+ const QDomElement group = initData.doc->CreateGroup(groupId, initData.visibilityGroupName, groupData, initData.id);
+ if (not group.isNull())
+ {
+ AddGroup *addGroup = new AddGroup(group, initData.doc);
+ connect(addGroup, &AddGroup::UpdateGroups, initData.doc, &VAbstractPattern::UpdateVisiblityGroups);
+ qApp->getUndoStack()->push(addGroup);
+ }
+
+ return;
+}
diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h
index 411b25d90..83ea6e69b 100644
--- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h
+++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h
@@ -53,15 +53,14 @@ struct DestinationItem
struct VAbstractOperationInitData : VAbstractToolInitData
{
VAbstractOperationInitData()
- : VAbstractToolInitData(),
- suffix(),
- source(),
- destination()
+ : VAbstractToolInitData()
{}
- QString suffix;
- QVector source;
- QVector destination;
+ QString suffix{};
+ QVector source{};
+ QVector destination{};
+ QString visibilityGroupName{};
+ bool hasLinkedVisibilityGroup{false};
};
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
@@ -133,12 +132,17 @@ protected:
QMap operatedObjects;
+ bool hasLinkedGroup{false};
+ QString groupName{};
+
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector &source, const QVector &destination,
QGraphicsItem *parent = nullptr);
virtual void AddToFile() override;
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
+ virtual void ApplyToolOptions(const QList &oldDependencies, const QList &newDependencies,
+ const QDomElement &oldDomElement, const QDomElement &newDomElement) override;
void UpdateNamePosition(quint32 id, const QPointF &pos);
void SaveSourceDestination(QDomElement &tag);
@@ -155,11 +159,15 @@ protected:
QString ComplexPointToolTip(quint32 itemId) const;
QString ComplexCurveToolTip(quint32 itemId) const;
+
+ static void CreateVisibilityGroup(const VAbstractOperationInitData & initData);
private:
Q_DISABLE_COPY(VAbstractOperation)
void AllowCurveHover(bool enabled, GOType type);
void AllowCurveSelecting(bool enabled, GOType type);
+
+ bool NeedUpdateVisibilityGroup() const;
};
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp
index c0bf390e3..818e59e66 100644
--- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp
+++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp
@@ -128,6 +128,17 @@ void VToolMove::setDialog()
dialogTool->SetLength(formulaLength);
dialogTool->SetSuffix(suffix);
dialogTool->SetRotationOrigPointId(origPointId);
+
+ vidtype group = doc->GroupLinkedToTool(m_id);
+ if (group != null_id)
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(true);
+ dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
+ }
+ else
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(false);
+ }
}
//---------------------------------------------------------------------------------------------------------------------
@@ -145,6 +156,8 @@ VToolMove *VToolMove::Create(const QPointer &dialog, VMainGraphicsSc
initData.rotationOrigin = dialogTool->GetRotationOrigPointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
+ initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
+ initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@@ -309,6 +322,11 @@ QT_WARNING_POP
if (initData.parse == Document::FullParse)
{
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ qApp->getUndoStack()->beginMacro(tr("move"));
+ }
+
VAbstractTool::AddRecord(initData.id, Tool::Move, initData.doc);
VToolMove *tool = new VToolMove(initData);
initData.scene->addItem(tool);
@@ -324,6 +342,13 @@ QT_WARNING_POP
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
+
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ VAbstractOperation::CreateVisibilityGroup(initData);
+ qApp->getUndoStack()->endMacro();
+ }
+
return tool;
}
return nullptr;
@@ -464,6 +489,10 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList &oldDependenc
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId()));
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
+
+ // Save for later use.
+ hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
+ groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp
index efbaf0083..09232a67b 100644
--- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp
+++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp
@@ -98,6 +98,17 @@ void VToolRotation::setDialog()
dialogTool->SetOrigPointId(origPointId);
dialogTool->SetAngle(formulaAngle);
dialogTool->SetSuffix(suffix);
+
+ vidtype group = doc->GroupLinkedToTool(m_id);
+ if (group != null_id)
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(true);
+ dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
+ }
+ else
+ {
+ dialogTool->SetHasLinkedVisibilityGroup(false);
+ }
}
//---------------------------------------------------------------------------------------------------------------------
@@ -113,6 +124,8 @@ VToolRotation *VToolRotation::Create(const QPointer &dialog, VMainGr
initData.angle = dialogTool->GetAngle();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
+ initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
+ initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@@ -251,6 +264,11 @@ QT_WARNING_POP
if (initData.parse == Document::FullParse)
{
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ qApp->getUndoStack()->beginMacro(tr("rotate"));
+ }
+
VAbstractTool::AddRecord(initData.id, Tool::Rotation, initData.doc);
VToolRotation *tool = new VToolRotation(initData);
initData.scene->addItem(tool);
@@ -261,6 +279,13 @@ QT_WARNING_POP
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
+
+ if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
+ {
+ VAbstractOperation::CreateVisibilityGroup(initData);
+ qApp->getUndoStack()->endMacro();
+ }
+
return tool;
}
return nullptr;
@@ -344,6 +369,10 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList &oldDepen
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId()));
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
+
+ // Save for later use.
+ hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
+ groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp
index 682a9c368..1abee64b1 100644
--- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp
+++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp
@@ -114,14 +114,7 @@ void VDrawTool::SaveDialogChange(const QString &undoText)
QList oldDependencies;
QList newDependencies;
SaveDialog(newDomElement, oldDependencies, newDependencies);
-
- if (newDependencies != oldDependencies || not VDomDocument::Compare(newDomElement, oldDomElement))
- {
- SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies,
- newDependencies, doc, m_id);
- connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
- qApp->getUndoStack()->push(saveOptions);
- }
+ ApplyToolOptions(oldDependencies, newDependencies, oldDomElement, newDomElement);
}
else
{
@@ -129,6 +122,19 @@ void VDrawTool::SaveDialogChange(const QString &undoText)
}
}
+//---------------------------------------------------------------------------------------------------------------------
+void VDrawTool::ApplyToolOptions(const QList &oldDependencies, const QList &newDependencies,
+ const QDomElement &oldDomElement, const QDomElement &newDomElement)
+{
+ if (newDependencies != oldDependencies || not VDomDocument::Compare(newDomElement, oldDomElement))
+ {
+ SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies,
+ newDependencies, doc, m_id);
+ connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
+ qApp->getUndoStack()->push(saveOptions);
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h
index 58333342a..b8de88334 100644
--- a/src/libs/vtools/tools/drawTools/vdrawtool.h
+++ b/src/libs/vtools/tools/drawTools/vdrawtool.h
@@ -99,6 +99,8 @@ protected:
virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies,
QList &newDependencies)=0;
virtual void SaveDialogChange(const QString &undoText = QString()) final;
+ virtual void ApplyToolOptions(const QList &oldDependencies, const QList &newDependencies,
+ const QDomElement &oldDomElement, const QDomElement &newDomElement);
virtual void AddToFile() override;
void SaveOption(QSharedPointer &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj);
diff --git a/src/libs/vtools/undocommands/undogroup.cpp b/src/libs/vtools/undocommands/undogroup.cpp
index a64ff98af..76f8ca088 100644
--- a/src/libs/vtools/undocommands/undogroup.cpp
+++ b/src/libs/vtools/undocommands/undogroup.cpp
@@ -117,6 +117,34 @@ void AddGroup::redo()
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
}
+//RenameGroup
+//---------------------------------------------------------------------------------------------------------------------
+RenameGroup::RenameGroup(VAbstractPattern *doc, quint32 id, const QString &name, QUndoCommand *parent)
+ : VUndoCommand(QDomElement(), doc, parent),
+ newName(name)
+{
+ setText(tr("rename group"));
+ nodeId = id;
+ oldName = doc->GetGroupName(nodeId);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void RenameGroup::undo()
+{
+ qCDebug(vUndo, "Undo.");
+ doc->SetGroupName(nodeId, oldName);
+ emit UpdateGroups();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void RenameGroup::redo()
+{
+ qCDebug(vUndo, "Redo.");
+
+ doc->SetGroupName(nodeId, newName);
+ emit UpdateGroups();
+}
+
//AddItemToGroup
//---------------------------------------------------------------------------------------------------------------------
AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)
diff --git a/src/libs/vtools/undocommands/undogroup.h b/src/libs/vtools/undocommands/undogroup.h
index 2a08f276e..791ff6dea 100644
--- a/src/libs/vtools/undocommands/undogroup.h
+++ b/src/libs/vtools/undocommands/undogroup.h
@@ -53,6 +53,22 @@ private:
const QString nameActivDraw;
};
+class RenameGroup : public VUndoCommand
+{
+ Q_OBJECT
+public:
+ RenameGroup(VAbstractPattern *doc, quint32 id, const QString &name, QUndoCommand *parent = nullptr);
+ virtual ~RenameGroup()=default;
+ virtual void undo() override;
+ virtual void redo() override;
+signals:
+ void UpdateGroups();
+private:
+ Q_DISABLE_COPY(RenameGroup)
+ QString newName;
+ QString oldName{};
+};
+
class AddItemToGroup : public VUndoCommand
{
Q_OBJECT