Engauge Digitizer  2
CmdSelectCoordSystem.cpp
Go to the documentation of this file.
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "CmdSelectCoordSystem.h"
8 #include "DataKey.h"
9 #include "Document.h"
10 #include "DocumentSerialize.h"
11 #include "EngaugeAssert.h"
12 #include "Logger.h"
13 #include "MainWindow.h"
14 #include <QApplication>
15 #include <QClipboard>
16 #include <QTextStream>
17 #include "QtToString.h"
18 #include <QXmlStreamReader>
19 
20 const QString CMD_DESCRIPTION ("Select Coordinate System");
21 
23  Document &document,
24  CoordSystemIndex coordSystemIndex) :
25  CmdAbstract(mainWindow,
26  document,
28  m_coordSystemIndexBefore (document.coordSystemIndex()),
29  m_coordSystemIndexAfter (coordSystemIndex)
30 {
31  LOG4CPP_INFO_S ((*mainCat)) << "CmdSelectCoordSystem::CmdSelectCoordSystem";
32 }
33 
35  Document &document,
36  const QString &cmdDescription,
37  QXmlStreamReader & /* reader */) :
38  CmdAbstract (mainWindow,
39  document,
40  cmdDescription)
41 {
42  LOG4CPP_INFO_S ((*mainCat)) << "CmdSelectCoordSystem::CmdSelectCoordSystem";
43 }
44 
46 {
47 }
48 
50 {
51  LOG4CPP_INFO_S ((*mainCat)) << "CmdSelectCoordSystem::cmdRedo"
52  << " index=" << m_coordSystemIndexBefore << "->" << m_coordSystemIndexAfter;
53 
55  mainWindow().updateCoordSystem (m_coordSystemIndexAfter);
57 }
58 
60 {
61  LOG4CPP_INFO_S ((*mainCat)) << "CmdSelectCoordSystem::cmdUndo"
62  << " index=" << m_coordSystemIndexAfter << "->" << m_coordSystemIndexBefore;
63 
65  mainWindow().updateCoordSystem (m_coordSystemIndexBefore);
67 }
68 
69 void CmdSelectCoordSystem::saveXml (QXmlStreamWriter &writer) const
70 {
71  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
72  writer.writeEndElement();
73 }
CmdAbstract::document
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
CmdSelectCoordSystem::CmdSelectCoordSystem
CmdSelectCoordSystem(MainWindow &mainWindow, Document &document, CoordSystemIndex coordSystem)
Constructor for normal creation.
Definition: CmdSelectCoordSystem.cpp:21
Document
Storage of one imported image and the data attached to that image.
Definition: Document.h:40
Document.h
EngaugeAssert.h
DocumentSerialize.h
CoordSystemIndex
unsigned int CoordSystemIndex
Zero-based index for identifying CoordSystem instantiations.
Definition: CoordSystemIndex.h:10
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:90
MainWindow::updateCoordSystem
void updateCoordSystem(CoordSystemIndex coordSystemIndex)
Select a different CoordSystem.
Definition: MainWindow.cpp:3416
Logger.h
CmdSelectCoordSystem.h
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
DataKey.h
CMD_DESCRIPTION
const QString CMD_DESCRIPTION("Select Coordinate System")
CmdSelectCoordSystem::cmdUndo
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
Definition: CmdSelectCoordSystem.cpp:58
CmdSelectCoordSystem::~CmdSelectCoordSystem
virtual ~CmdSelectCoordSystem()
Definition: CmdSelectCoordSystem.cpp:44
CmdAbstract::saveOrCheckPostCommandDocumentStateHash
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Definition: CmdAbstract.cpp:102
CmdSelectCoordSystem::cmdRedo
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
Definition: CmdSelectCoordSystem.cpp:48
CmdSelectCoordSystem::saveXml
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
Definition: CmdSelectCoordSystem.cpp:68
CmdAbstract::saveOrCheckPreCommandDocumentStateHash
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Definition: CmdAbstract.cpp:125
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
MainWindow.h
CmdAbstract::mainWindow
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
QtToString.h
DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD
CmdAbstract
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:18