Resolved issue #520. Improve Union tool. An option to select about original

pieces.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-06-30 19:48:46 +03:00
parent d429407c35
commit c89243a288
6 changed files with 38 additions and 14 deletions

View File

@ -33,6 +33,7 @@
- [#514] Read only setting not working properly. - [#514] Read only setting not working properly.
- [#480] New tool: Midpoint between two points. - [#480] New tool: Midpoint between two points.
- [#496] Selector for selecting which pieces to print. - [#496] Selector for selecting which pieces to print.
- [#520] Improve Union tool. An option to select about original pieces.
# Version 0.4.5 # Version 0.4.5
- [#435] Valentina doesn't change the cursor. - [#435] Valentina doesn't change the cursor.

View File

@ -51,6 +51,12 @@ DialogUnionDetails::~DialogUnionDetails()
delete ui; delete ui;
} }
//---------------------------------------------------------------------------------------------------------------------
bool DialogUnionDetails::RetainPieces() const
{
return ui->checkBox->isChecked();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ChoosedObject gets id and type of selected object. Save correct data and ignore wrong. * @brief ChoosedObject gets id and type of selected object. Save correct data and ignore wrong.

View File

@ -50,6 +50,8 @@ public:
quint32 getD2() const; quint32 getD2() const;
int getIndexD1() const; int getIndexD1() const;
int getIndexD2() const; int getIndexD2() const;
bool RetainPieces() const;
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
private: private:

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>300</width> <width>300</width>
<height>78</height> <height>96</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -24,13 +24,20 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter"> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Do you really want to unite details?&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Do you really want to unite details?&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Retain original pieces</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">

View File

@ -520,9 +520,10 @@ VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsSc
VDetail d2 = data->GetDetail(dialogTool->getD2()); VDetail d2 = data->GetDetail(dialogTool->getD2());
quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1()); quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1());
quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2()); quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2());
const bool retainPieces = dialogTool->RetainPieces();
qApp->getUndoStack()->beginMacro(tr("union details")); qApp->getUndoStack()->beginMacro(tr("union details"));
VToolUnionDetails* tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, VToolUnionDetails* tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene,
doc, data, Document::FullParse, Source::FromGui); doc, data, Document::FullParse, Source::FromGui, retainPieces);
qApp->getUndoStack()->endMacro(); qApp->getUndoStack()->endMacro();
return tool; return tool;
} }
@ -546,7 +547,8 @@ VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsSc
VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2, VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2,
const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1, const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1,
const quint32 &indexD2, VMainGraphicsScene *scene, VAbstractPattern *doc, const quint32 &indexD2, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation) VContainer *data, const Document &parse, const Source &typeCreation,
bool retainPieces)
{ {
VToolUnionDetails *unionDetails = 0; VToolUnionDetails *unionDetails = 0;
quint32 id = _id; quint32 id = _id;
@ -639,6 +641,8 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
QHash<quint32, VDataTool*>* tools = doc->getTools(); QHash<quint32, VDataTool*>* tools = doc->getTools();
SCASSERT(tools != nullptr); SCASSERT(tools != nullptr);
if (not retainPieces)
{
{ {
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d1id)); VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d1id));
SCASSERT(toolDet != nullptr); SCASSERT(toolDet != nullptr);
@ -646,10 +650,13 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
toolDet->Remove(ask); toolDet->Remove(ask);
} }
{
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d2id)); VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d2id));
SCASSERT(toolDet != nullptr); SCASSERT(toolDet != nullptr);
bool ask = false; const bool ask = false;
toolDet->Remove(ask); toolDet->Remove(ask);
}
}
SCASSERT(not children.isEmpty()) SCASSERT(not children.isEmpty())
SaveChildren(doc, id, children); SaveChildren(doc, id, children);

View File

@ -52,7 +52,8 @@ public:
const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Document &parse,
const Source &typeCreation); const Source &typeCreation,
bool retainPieces = false);
static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data); static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data);
static void FindIndexJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j); static void FindIndexJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j);
static QVector<VDetail> GetDetailFromFile(VAbstractPattern *doc, const QDomElement &domElement); static QVector<VDetail> GetDetailFromFile(VAbstractPattern *doc, const QDomElement &domElement);