Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CmdMediator Class Reference

Command queue stack. More...

#include <CmdMediator.h>

Inheritance diagram for CmdMediator:
Inheritance graph
Collaboration diagram for CmdMediator:
Collaboration graph

Public Member Functions

 CmdMediator (MainWindow &mainWindow, const QImage &image)
 Constructor for imported images and dragged images. Only one coordinate system is created but others can be added later.
 
 CmdMediator (MainWindow &mainWindow, const QString &fileName)
 Constructor for opened Documents and error report files. The specified xml file is opened and read.
 
 ~CmdMediator ()
 Destructor.
 
const CoordSystemcoordSystem () const
 Provide the current CoordSystem to commands with read-only access, primarily for undo/redo processing.
 
const CurvecurveAxes () const
 See Document::curveAxes.
 
QStringList curvesGraphsNames () const
 See CurvesGraphs::curvesGraphsNames.
 
int curvesGraphsNumPoints (const QString &curveName) const
 See CurvesGraphs::curvesGraphsNumPoints.
 
Documentdocument ()
 Provide the Document to commands, primarily for undo/redo processing.
 
const Documentdocument () const
 Provide the Document to commands with read-only access, primarily for undo/redo processing.
 
bool isModified () const
 Dirty flag.
 
void iterateThroughCurvePointsAxes (const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
 See Curve::iterateThroughCurvePoints, for the single axes curve.
 
void iterateThroughCurvePointsAxes (const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
 See Curve::iterateThroughCurvePoints, for the single axes curve.
 
void iterateThroughCurvesPointsGraphs (const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
 See Curve::iterateThroughCurvePoints, for all the graphs curves.
 
QPixmap pixmap () const
 See Document::pixmap.
 
QString reasonForUnsuccessfulRead () const
 See Document::reasonForUnsuccessfulRead.
 
void saveXml (QXmlStreamWriter &writer) const
 Serialize to xml.
 
QString selectedCurveName () const
 Currently selected curve name. This is used to set the selected curve combobox in MainWindow.
 
void setDocumentAxesPointsRequired (DocumentAxesPointsRequired documentAxesPointsRequired)
 Set the number of axes points required.
 
void setSelectedCurveName (const QString &selectedCurveName)
 Save curve name that is selected for the current coordinate system, for the next time the coordinate system reappears.
 
bool successfulRead () const
 Wrapper for Document::successfulRead.
 

Detailed Description

Command queue stack.

This class lies between the Document and the rest of the application. This approach is attractive because the command stack and Document are born together, work together, and deleted together. Also, wrapping this class around Document helps to encapsulate Document that much more.

Definition at line 23 of file CmdMediator.h.

Constructor & Destructor Documentation

◆ CmdMediator() [1/2]

CmdMediator::CmdMediator ( MainWindow & mainWindow,
const QImage & image )

Constructor for imported images and dragged images. Only one coordinate system is created but others can be added later.

Definition at line 25 of file CmdMediator.cpp.

26 :
27 m_document (image)
28{
29 LOG4CPP_INFO_S ((*mainCat)) << "CmdMediator::CmdMediator image=" << image.width() << "x" << image.height ();
30
31 connectSignals(mainWindow);
32}
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ CmdMediator() [2/2]

CmdMediator::CmdMediator ( MainWindow & mainWindow,
const QString & fileName )

Constructor for opened Documents and error report files. The specified xml file is opened and read.

Definition at line 34 of file CmdMediator.cpp.

35 :
36 m_document (fileName)
37{
38 LOG4CPP_INFO_S ((*mainCat)) << "CmdMediator::CmdMediator filename=" << fileName.toLatin1().data();
39
40 connectSignals(mainWindow);
41}
const int INNER_RADIUS_MIN

◆ ~CmdMediator()

CmdMediator::~CmdMediator ( )

Destructor.

Definition at line 43 of file CmdMediator.cpp.

44{
45}

Member Function Documentation

◆ coordSystem()

const CoordSystem & CmdMediator::coordSystem ( ) const

Provide the current CoordSystem to commands with read-only access, primarily for undo/redo processing.

Definition at line 52 of file CmdMediator.cpp.

53{
54 return m_document.coordSystem();
55}
const CoordSystem & coordSystem() const
Currently active CoordSystem.
Definition Document.cpp:300

◆ curveAxes()

const Curve & CmdMediator::curveAxes ( ) const

See Document::curveAxes.

Definition at line 57 of file CmdMediator.cpp.

58{
59 return m_document.curveAxes ();
60}
const Curve & curveAxes() const
Get method for axis curve.
Definition Document.cpp:321

◆ curvesGraphsNames()

QStringList CmdMediator::curvesGraphsNames ( ) const

See CurvesGraphs::curvesGraphsNames.

Definition at line 62 of file CmdMediator.cpp.

63{
64 return m_document.curvesGraphsNames();
65}
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Definition Document.cpp:349

◆ curvesGraphsNumPoints()

int CmdMediator::curvesGraphsNumPoints ( const QString & curveName) const

See CurvesGraphs::curvesGraphsNumPoints.

Definition at line 67 of file CmdMediator.cpp.

68{
69 return m_document.curvesGraphsNumPoints(curveName);
70}
int curvesGraphsNumPoints(const QString &curveName) const
See CurvesGraphs::curvesGraphsNumPoints.
Definition Document.cpp:356

◆ document() [1/2]

Document & CmdMediator::document ( )

Provide the Document to commands, primarily for undo/redo processing.

Definition at line 72 of file CmdMediator.cpp.

73{
74 return m_document;
75}

◆ document() [2/2]

const Document & CmdMediator::document ( ) const

Provide the Document to commands with read-only access, primarily for undo/redo processing.

Definition at line 77 of file CmdMediator.cpp.

78{
79 return m_document;
80}

◆ isModified()

bool CmdMediator::isModified ( ) const

Dirty flag.

Document is dirty if there are any unsaved changes. The dirty flag is pushed (rather than pulled from this method) through the QUndoStack::cleanChanged signal

Definition at line 82 of file CmdMediator.cpp.

83{
84 return !isClean();
85}

◆ iterateThroughCurvePointsAxes() [1/2]

void CmdMediator::iterateThroughCurvePointsAxes ( const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > & ftorWithCallback)

See Curve::iterateThroughCurvePoints, for the single axes curve.

Definition at line 87 of file CmdMediator.cpp.

88{
90}
void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the axes curve.
Definition Document.cpp:449

◆ iterateThroughCurvePointsAxes() [2/2]

void CmdMediator::iterateThroughCurvePointsAxes ( const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > & ftorWithCallback) const

See Curve::iterateThroughCurvePoints, for the single axes curve.

Definition at line 92 of file CmdMediator.cpp.

◆ iterateThroughCurvesPointsGraphs()

void CmdMediator::iterateThroughCurvesPointsGraphs ( const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > & ftorWithCallback)

See Curve::iterateThroughCurvePoints, for all the graphs curves.

Definition at line 97 of file CmdMediator.cpp.

98{
100}
void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
Definition Document.cpp:472

◆ pixmap()

QPixmap CmdMediator::pixmap ( ) const

See Document::pixmap.

Definition at line 102 of file CmdMediator.cpp.

103{
104 ENGAUGE_ASSERT (m_document.successfulRead ());
105
106 return m_document.pixmap ();
107}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
QPixmap pixmap() const
Return the image that is being digitized.
Definition Document.cpp:817
bool successfulRead() const
Return true if startup loading succeeded. If the loading failed then reasonForUnsuccessfulRed will ex...

◆ reasonForUnsuccessfulRead()

QString CmdMediator::reasonForUnsuccessfulRead ( ) const

See Document::reasonForUnsuccessfulRead.

Definition at line 109 of file CmdMediator.cpp.

110{
111 return m_document.reasonForUnsuccessfulRead ();
112}
QString reasonForUnsuccessfulRead() const
Return an informative text message explaining why startup loading failed. Applies if successfulRead r...
Definition Document.cpp:856

◆ saveXml()

void CmdMediator::saveXml ( QXmlStreamWriter & writer) const

Serialize to xml.

Definition at line 114 of file CmdMediator.cpp.

115{
116 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD_MEDIATOR);
117
118 for (int i = 0; i < index(); i++) {
119
120 const CmdAbstract *cmd = dynamic_cast<const CmdAbstract *>(command(i));
121 cmd->saveXml (writer);
122 }
123
124 writer.writeEndElement();
125}
const QString DOCUMENT_SERIALIZE_CMD_MEDIATOR
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition CmdAbstract.h:20
virtual void saveXml(QXmlStreamWriter &writer) const =0
Save commands as xml for later uploading.

◆ selectedCurveName()

QString CmdMediator::selectedCurveName ( ) const

Currently selected curve name. This is used to set the selected curve combobox in MainWindow.

Definition at line 127 of file CmdMediator.cpp.

128{
129 return m_document.selectedCurveName ();
130}
QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow.
Definition Document.cpp:913

◆ setDocumentAxesPointsRequired()

void CmdMediator::setDocumentAxesPointsRequired ( DocumentAxesPointsRequired documentAxesPointsRequired)

Set the number of axes points required.

This is called during the Document creation process, after imported images have been previewed or loaded files have had at least some xml parsing

Definition at line 132 of file CmdMediator.cpp.

133{
134 m_document.setDocumentAxesPointsRequired (documentAxesPointsRequired);
135}
void setDocumentAxesPointsRequired(DocumentAxesPointsRequired documentAxesPointsRequired)
Set the number of axes points required.
Definition Document.cpp:939

◆ setSelectedCurveName()

void CmdMediator::setSelectedCurveName ( const QString & selectedCurveName)

Save curve name that is selected for the current coordinate system, for the next time the coordinate system reappears.

Definition at line 137 of file CmdMediator.cpp.

138{
140}
QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow.
void setSelectedCurveName(const QString &selectedCurveName)
Save curve name that is selected for the current coordinate system, for the next time the coordinate ...

◆ successfulRead()

bool CmdMediator::successfulRead ( ) const

Wrapper for Document::successfulRead.

Definition at line 142 of file CmdMediator.cpp.

143{
144 return m_document.successfulRead();
145}

The documentation for this class was generated from the following files: