Seamly2D
Code documentation
movesplinepath.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
* *
3
* Copyright (C) 2017 Seamly, LLC *
4
* *
5
* https://github.com/fashionfreedom/seamly2d *
6
* *
7
***************************************************************************
8
**
9
** Seamly2D is free software: you can redistribute it and/or modify
10
** it under the terms of the GNU General Public License as published by
11
** the Free Software Foundation, either version 3 of the License, or
12
** (at your option) any later version.
13
**
14
** Seamly2D is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
18
**
19
** You should have received a copy of the GNU General Public License
20
** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21
**
22
**************************************************************************
23
24
************************************************************************
25
**
26
** @file movesplinepath.cpp
27
** @author Roman Telezhynskyi <dismine(at)gmail.com>
28
** @date 11 6, 2014
29
**
30
** @brief
31
** @copyright
32
** This source code is part of the Valentine project, a pattern making
33
** program, whose allow create and modeling patterns of clothing.
34
** Copyright (C) 2013-2015 Seamly2D project
35
** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36
**
37
** Seamly2D is free software: you can redistribute it and/or modify
38
** it under the terms of the GNU General Public License as published by
39
** the Free Software Foundation, either version 3 of the License, or
40
** (at your option) any later version.
41
**
42
** Seamly2D is distributed in the hope that it will be useful,
43
** but WITHOUT ANY WARRANTY; without even the implied warranty of
44
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45
** GNU General Public License for more details.
46
**
47
** You should have received a copy of the GNU General Public License
48
** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49
**
50
*************************************************************************/
51
52
#include "
movesplinepath.h
"
53
54
#include <QDomElement>
55
56
#include "../ifc/xml/vabstractpattern.h"
57
#include "../tools/drawTools/toolcurve/vtoolsplinepath.h"
58
#include "../vmisc/logging.h"
59
#include "../vmisc/vabstractapplication.h"
60
#include "../vmisc/def.h"
61
#include "../vwidgets/vmaingraphicsview.h"
62
#include "../vgeometry/vsplinepath.h"
63
#include "
vundocommand.h
"
64
65
//---------------------------------------------------------------------------------------------------------------------
66
MoveSplinePath::MoveSplinePath
(
VAbstractPattern
*doc,
const
VSplinePath
&oldSplPath,
const
VSplinePath
&newSplPath,
67
const
quint32 &
id
, QUndoCommand *parent)
68
:
VUndoCommand
(QDomElement(), doc, parent),
69
oldSplinePath(oldSplPath),
70
newSplinePath(newSplPath),
71
scene(
qApp
->getCurrentScene())
72
{
73
setText(tr(
"move spline path"
));
74
nodeId
=
id
;
75
76
SCASSERT
(
scene
!=
nullptr
)
77
}
78
79
//---------------------------------------------------------------------------------------------------------------------
80
MoveSplinePath::~MoveSplinePath
()
81
{}
82
83
//---------------------------------------------------------------------------------------------------------------------
84
void
MoveSplinePath::undo
()
85
{
86
qCDebug(vUndo,
"Undo."
);
87
88
Do
(
oldSplinePath
);
89
VMainGraphicsView::NewSceneRect
(
scene
,
qApp
->getSceneView());
90
}
91
92
//---------------------------------------------------------------------------------------------------------------------
93
void
MoveSplinePath::redo
()
94
{
95
qCDebug(vUndo,
"Redo."
);
96
97
Do
(
newSplinePath
);
98
VMainGraphicsView::NewSceneRect
(
scene
,
qApp
->getSceneView());
99
}
100
101
//---------------------------------------------------------------------------------------------------------------------
102
bool
MoveSplinePath::mergeWith
(
const
QUndoCommand *command)
103
{
104
const
MoveSplinePath
*moveCommand =
static_cast<
const
MoveSplinePath
*
>
(command);
105
SCASSERT
(moveCommand !=
nullptr
)
106
const
quint32
id
= moveCommand->
getSplinePathId
();
107
108
if
(
id
!=
nodeId
)
109
{
110
return
false
;
111
}
112
113
newSplinePath
= moveCommand->
getNewSplinePath
();
114
return
true
;
115
}
116
117
//---------------------------------------------------------------------------------------------------------------------
118
int
MoveSplinePath::id
()
const
119
{
120
return
static_cast<
int
>
(
UndoCommand::MoveSplinePath
);
121
}
122
123
//---------------------------------------------------------------------------------------------------------------------
124
void
MoveSplinePath::Do
(
const
VSplinePath
&
splPath
)
125
{
126
QDomElement domElement =
doc
->
elementById
(
nodeId
,
VAbstractPattern::TagSpline
);
127
if
(domElement.isElement())
128
{
129
VToolSplinePath::UpdatePathPoints
(
doc
, domElement,
splPath
);
130
131
emit
NeedLiteParsing
(
Document::LiteParse
);
132
}
133
else
134
{
135
qCDebug(vUndo,
"Can't find spline path with id = %u."
,
nodeId
);
136
return
;
137
}
138
}
MoveSplinePath
Definition:
movesplinepath.h:67
MoveSplinePath::scene
QGraphicsScene * scene
Definition:
movesplinepath.h:83
MoveSplinePath::~MoveSplinePath
virtual ~MoveSplinePath() Q_DECL_OVERRIDE
Definition:
movesplinepath.cpp:80
MoveSplinePath::MoveSplinePath
MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, const quint32 &id, QUndoCommand *parent=nullptr)
Definition:
movesplinepath.cpp:66
MoveSplinePath::redo
virtual void redo() Q_DECL_OVERRIDE
Definition:
movesplinepath.cpp:93
MoveSplinePath::undo
virtual void undo() Q_DECL_OVERRIDE
Definition:
movesplinepath.cpp:84
MoveSplinePath::Do
void Do(const VSplinePath &splPath)
Definition:
movesplinepath.cpp:124
MoveSplinePath::newSplinePath
VSplinePath newSplinePath
Definition:
movesplinepath.h:82
MoveSplinePath::getSplinePathId
quint32 getSplinePathId() const
Definition:
movesplinepath.h:88
MoveSplinePath::oldSplinePath
VSplinePath oldSplinePath
Definition:
movesplinepath.h:81
MoveSplinePath::mergeWith
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE
Definition:
movesplinepath.cpp:102
MoveSplinePath::getNewSplinePath
VSplinePath getNewSplinePath() const
Definition:
movesplinepath.h:94
MoveSplinePath::id
virtual int id() const Q_DECL_OVERRIDE
Definition:
movesplinepath.cpp:118
VAbstractPattern
Definition:
vabstractpattern.h:113
VAbstractPattern::TagSpline
static const QString TagSpline
Definition:
vabstractpattern.h:289
VDomDocument::elementById
QDomElement elementById(quint32 id, const QString &tagName=QString())
Definition:
vdomdocument.cpp:222
VMainGraphicsView::NewSceneRect
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QGraphicsItem *item=nullptr)
NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
Definition:
vmaingraphicsview.cpp:838
VSplinePath
The VSplinePath class keep information about splinePath.
Definition:
vsplinepath.h:72
VToolSplinePath::UpdatePathPoints
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VSplinePath &path)
UpdatePathPoints update spline path in pattern file.
Definition:
vtoolsplinepath.cpp:362
VUndoCommand
Definition:
vundocommand.h:93
VUndoCommand::doc
VAbstractPattern * doc
Definition:
vundocommand.h:106
VUndoCommand::NeedLiteParsing
void NeedLiteParsing(const Document &parse)
VUndoCommand::nodeId
quint32 nodeId
Definition:
vundocommand.h:107
SCASSERT
#define SCASSERT(cond)
Definition:
def.h:317
splPath
const QString splPath
Definition:
ifcdef.cpp:419
movesplinepath.h
Document::LiteParse
@ LiteParse
qApp
#define qApp
Definition:
vapplication.h:67
vundocommand.h
UndoCommand::MoveSplinePath
@ MoveSplinePath
src
libs
vtools
undocommands
movesplinepath.cpp
Generated by
1.9.1