16#include <QGraphicsItem>
18#include <QXmlStreamReader>
23 const QPointF &deltaScreen,
24 const QString &moveText,
25 const QStringList &selectedPointIdentifiers) :
29 m_deltaScreen (deltaScreen)
32 QStringList::const_iterator itr;
33 for (itr = selectedPointIdentifiers.begin (); itr != selectedPointIdentifiers.end (); itr++) {
35 QString selectedPointIdentifier = *itr;
37 selected << selectedPointIdentifier;
38 m_movedPoints.setKeyValue (selectedPointIdentifier, true);
43 <<
" selected=" << selected.join (
", ").toLatin1 ().data () <<
")";
48 const QString &cmdDescription,
49 QXmlStreamReader &reader) :
56 QXmlStreamAttributes attributes = reader.attributes();
58 QStringList requiredAttributesLeaf;
62 requiredAttributesLeaf,
67 m_movedPoints.loadXml (reader);
78 <<
" moving=" << m_movedPoints.count ();
83 moveBy (m_deltaScreen);
92 <<
" deltaScreen=" <<
QPointFToString (-1.0 * m_deltaScreen).toLatin1().data()
93 <<
" moving=" << m_movedPoints.count ();
103void CmdMoveBy::moveBy (
const QPointF &deltaScreen)
108 for (
int i = 0; i < m_movedPoints.
count(); i++) {
110 QString pointIdentifier = m_movedPoints.
getKey (i);
117 QList<QGraphicsItem *>::iterator itrS;
118 for (itrS = items.begin (); itrS != items.end (); itrS++) {
120 QGraphicsItem *item = *itrS;
125 if (m_movedPoints.contains (pointIdentifier)) {
130 if (item->pos () != posScreen) {
133 item->setPos (posScreen);
152 m_movedPoints.saveXml (writer);
154 writer.writeEndElement();
@ DATA_KEY_GRAPHICS_ITEM_TYPE
const QString DOCUMENT_SERIALIZE_CMD_MOVE_BY
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_SCREEN_Y_DELTA
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_SCREEN_X_DELTA
@ GRAPHICS_ITEM_TYPE_POINT
log4cpp::Category * mainCat
QString QPointFToString(const QPointF &pos)
Document & document()
Return the Document that this command will modify during redo and undo.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void restoreState()
Before any other operations associated with a Cmd class are performed, this method is called to resto...
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Call this (for consistency) after writing leaf class attributes, to write the base class attributes.
void leafAndBaseAttributes(const QXmlStreamAttributes &attributes, const QStringList &requiredAttributesLeaf, QXmlStreamReader &reader)
Before reading leaf class attributes, check all required attributes from leaf and this base class are...
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
CmdMoveBy(MainWindow &mainWindow, Document &document, const QPointF &deltaScreen, const QString &moveText, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
CmdPointChangeBase(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
Storage of one imported image and the data attached to that image.
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
void updateGraphicsLinesToMatchGraphicsPoints()
Update the graphics lines so they follow the graphics points, after a drag, addition,...
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
QString getKey(int i) const
Get key for index.
int count() const
Number of entries.
#define LOG4CPP_INFO_S(logger)