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();
61 QString (
"%1 %2 %3 %4")
62 .arg (QObject::tr (
"Missing attribute(s)"))
64 .arg (QObject::tr (
"and/or"))
81 <<
" moving=" << m_movedPoints.
count ();
85 moveBy (m_deltaScreen);
94 <<
" deltaScreen=" <<
QPointFToString (-1.0 * m_deltaScreen).toLatin1().data()
95 <<
" moving=" << m_movedPoints.
count ();
104 void CmdMoveBy::moveBy (
const QPointF &deltaScreen)
109 for (
int i = 0; i < m_movedPoints.
count(); i++) {
111 QString pointIdentifier = m_movedPoints.
getKey (i);
118 QList<QGraphicsItem *>::iterator itrS;
119 for (itrS = items.begin (); itrS != items.end (); itrS++) {
121 QGraphicsItem *item = *itrS;
126 if (m_movedPoints.
contains (pointIdentifier)) {
131 if (item->pos () != posScreen) {
134 item->setPos (posScreen);
153 m_movedPoints.
saveXml (writer);
154 writer.writeEndElement();
const QString DOCUMENT_SERIALIZE_CMD_MOVE_BY
const QString DOCUMENT_SERIALIZE_SCREEN_X_DELTA
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
CmdMoveBy(MainWindow &mainWindow, Document &document, const QPointF &deltaScreen, const QString &moveText, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
QString getKey(int i) const
Get key for index.
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.
#define LOG4CPP_INFO_S(logger)
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
Unique identifier for QGraphicsItem object
void setKeyValue(const QString &pointIdentifier, bool value)
Set key/value pair.
void saveXml(QXmlStreamWriter &writer) const
Serialize table to xml.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
QString QPointFToString(const QPointF &pos)
const QString DOCUMENT_SERIALIZE_CMD_TYPE
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml.
log4cpp::Category * mainCat
bool contains(const QString &pointIdentifier) const
True if specified entry exists in the table.
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Document & document()
Return the Document that this command will modify during redo and undo.
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set...
const QString DOCUMENT_SERIALIZE_SCREEN_Y_DELTA
const QString DOCUMENT_SERIALIZE_CMD
void updateGraphicsLinesToMatchGraphicsPoints()
Update the graphics lines so they follow the graphics points, after a drag, addition, removal, and such.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
int count() const
Number of entries.