Engauge Digitizer  2
Public Member Functions | Protected Member Functions | List of all members
DlgSettingsGridDisplay Class Reference

Dialog for editing grid display settings. More...

#include <DlgSettingsGridDisplay.h>

Inheritance diagram for DlgSettingsGridDisplay:
Inheritance graph
Collaboration diagram for DlgSettingsGridDisplay:
Collaboration graph

Public Member Functions

 DlgSettingsGridDisplay (MainWindow &mainWindow)
 Single constructor. More...
 
virtual ~DlgSettingsGridDisplay ()
 
virtual void createOptionalSaveDefault (QHBoxLayout *layout)
 Let subclass define an optional Save As Default button. More...
 
virtual QWidget * createSubPanel ()
 Create dialog-specific panel to which base class will add Ok and Cancel buttons. More...
 
virtual void load (CmdMediator &cmdMediator)
 Load settings from Document. More...
 
virtual void setSmallDialogs (bool smallDialogs)
 If false then dialogs have a minimum size so all controls are visible. More...
 
- Public Member Functions inherited from DlgSettingsAbstractBase
 DlgSettingsAbstractBase (const QString &title, const QString &dialogName, MainWindow &mainWindow)
 Single constructor. More...
 
virtual ~DlgSettingsAbstractBase ()
 

Protected Member Functions

virtual void handleOk ()
 Process slotOk. More...
 
- Protected Member Functions inherited from DlgSettingsAbstractBase
CmdMediatorcmdMediator ()
 Provide access to Document information wrapped inside CmdMediator. More...
 
void enableOk (bool enable)
 Let leaf subclass control the Ok button. More...
 
void finishPanel (QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
 Add Ok and Cancel buttons to subpanel to get the whole dialog. More...
 
MainWindowmainWindow ()
 Get method for MainWindow. More...
 
const MainWindowmainWindow () const
 Const get method for MainWindow. More...
 
void populateColorComboWithoutTransparent (QComboBox &combo)
 Add colors in color palette to combobox, without transparent entry at end. More...
 
void populateColorComboWithTransparent (QComboBox &combo)
 Add colors in color palette to combobox, with transparent entry at end. More...
 
void setCmdMediator (CmdMediator &cmdMediator)
 Store CmdMediator for easy access by the leaf class. More...
 
void setDisableOkAtStartup (bool disableOkAtStartup)
 Override the default Ok button behavior applied in showEvent. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from DlgSettingsAbstractBase
static int MINIMUM_DIALOG_WIDTH = 380
 Dialog layout constant that guarantees every widget has sufficient room. Can be increased by finishPanel. More...
 
static int MINIMUM_PREVIEW_HEIGHT = 100
 Dialog layout constant that guarantees preview has sufficent room. More...
 

Detailed Description

Dialog for editing grid display settings.

Definition at line 26 of file DlgSettingsGridDisplay.h.

Constructor & Destructor Documentation

◆ DlgSettingsGridDisplay()

DlgSettingsGridDisplay::DlgSettingsGridDisplay ( MainWindow mainWindow)

Single constructor.

Definition at line 30 of file DlgSettingsGridDisplay.cpp.

30  :
31  DlgSettingsAbstractBase (tr ("Grid Display"),
32  "DlgSettingsGridDisplay",
33  mainWindow),
34  m_validatorCountX (nullptr),
35  m_validatorStartX (nullptr),
36  m_validatorStepX (nullptr),
37  m_validatorStopX (nullptr),
38  m_validatorCountY (nullptr),
39  m_validatorStartY (nullptr),
40  m_validatorStepY (nullptr),
41  m_validatorStopY (nullptr),
42  m_scenePreview (nullptr),
43  m_viewPreview (nullptr),
44  m_modelGridDisplayBefore (nullptr),
45  m_modelGridDisplayAfter (nullptr)
46 {
47  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::DlgSettingsGridDisplay";
48 
49  QWidget *subPanel = createSubPanel ();
50  finishPanel (subPanel);
51 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Abstract base class for all Settings dialogs.
MainWindow & mainWindow()
Get method for MainWindow.

◆ ~DlgSettingsGridDisplay()

DlgSettingsGridDisplay::~DlgSettingsGridDisplay ( )
virtual

Definition at line 53 of file DlgSettingsGridDisplay.cpp.

54 {
55  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::~DlgSettingsGridDisplay";
56 
57  delete m_validatorCountX;
58  delete m_validatorStartX;
59  delete m_validatorStepX;
60  delete m_validatorStopX;
61  delete m_validatorCountY;
62  delete m_validatorStartY;
63  delete m_validatorStepY;
64  delete m_validatorStopY;
65 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsGridDisplay::createOptionalSaveDefault ( QHBoxLayout *  layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 250 of file DlgSettingsGridDisplay.cpp.

251 {
252 }

◆ createSubPanel()

QWidget * DlgSettingsGridDisplay::createSubPanel ( )
virtual

Create dialog-specific panel to which base class will add Ok and Cancel buttons.

Implements DlgSettingsAbstractBase.

Definition at line 272 of file DlgSettingsGridDisplay.cpp.

273 {
274  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createSubPanel";
275 
276  QWidget *subPanel = new QWidget ();
277  QGridLayout *layout = new QGridLayout (subPanel);
278  subPanel->setLayout (layout);
279 
280  layout->setColumnStretch(0, 1); // Empty first column
281  layout->setColumnStretch(1, 0); // Checkbox part of "section" checkboxes. In other rows this has empty space as indentation
282  layout->setColumnStretch(2, 0); // X
283  layout->setColumnStretch(3, 0); // Y
284  layout->setColumnStretch(4, 1); // Empty last column
285 
286  int row = 0;
287  createDisplayGridLinesX (layout, row);
288  createDisplayGridLinesY (layout, row);
289  createDisplayCommon (layout, row);
290  createPreview (layout, row);
291 
292  return subPanel;
293 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ handleOk()

void DlgSettingsGridDisplay::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 295 of file DlgSettingsGridDisplay.cpp.

296 {
297  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::handleOk";
298 
299  // Set the stable flag
300  m_modelGridDisplayAfter->setStable (true);
301 
303  cmdMediator ().document(),
304  *m_modelGridDisplayBefore,
305  *m_modelGridDisplayAfter);
306  cmdMediator ().push (cmd);
307 
308  hide ();
309 }
Command for DlgSettingsGridDisplay.
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void setStable(bool stable)
Set method for stable flag.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
MainWindow & mainWindow()
Get method for MainWindow.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ load()

void DlgSettingsGridDisplay::load ( CmdMediator cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 311 of file DlgSettingsGridDisplay.cpp.

312 {
313  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::load";
314 
316 
317  // Flush old data
318  delete m_modelGridDisplayBefore;
319  delete m_modelGridDisplayAfter;
320 
321  // Display cartesian or polar headers as appropriate
322  QString titleX = tr ("X Grid Lines");
324  titleX = QString (QChar (0x98, 0x03)) + QString (" %1").arg (tr ("Grid Lines"));
325  }
326  m_groupX->setTitle (titleX);
327 
328  QString titleY = tr ("Y Grid Lines");
330  titleY = QString (tr ("Radius Grid Lines"));
331  }
332  m_groupY->setTitle (titleY);
333 
334  // Save new data
335  m_modelGridDisplayBefore = new DocumentModelGridDisplay (cmdMediator.document());
336  m_modelGridDisplayAfter = new DocumentModelGridDisplay (cmdMediator.document());
337 
338  // Populate controls
339  int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridDisplayAfter->disableX()));
340  m_cmbDisableX->setCurrentIndex (indexDisableX);
341 
342  m_editCountX->setText(QString::number(m_modelGridDisplayAfter->countX()));
343  m_editStartX->setText(QString::number(m_modelGridDisplayAfter->startX()));
344  m_editStepX->setText(QString::number(m_modelGridDisplayAfter->stepX()));
345  m_editStopX->setText(QString::number(m_modelGridDisplayAfter->stopX()));
346 
347  int indexDisableY = m_cmbDisableY->findData (QVariant (m_modelGridDisplayAfter->disableY()));
348  m_cmbDisableY->setCurrentIndex (indexDisableY);
349 
350  m_editCountY->setText(QString::number(m_modelGridDisplayAfter->countY()));
351  m_editStartY->setText(QString::number(m_modelGridDisplayAfter->startY()));
352  m_editStepY->setText(QString::number(m_modelGridDisplayAfter->stepY()));
353  m_editStopY->setText(QString::number(m_modelGridDisplayAfter->stopY()));
354 
355  int indexColor = m_cmbColor->findData(QVariant(m_modelGridDisplayAfter->paletteColor()));
356  ENGAUGE_ASSERT (indexColor >= 0);
357  m_cmbColor->setCurrentIndex(indexColor);
358 
359  m_scenePreview->addPixmap (cmdMediator.document().pixmap());
360 
361  updateControls ();
362  enableOk (false); // Disable Ok button since there not yet any changes
363  updatePreview();
364 }
GridCoordDisable disableY() const
Get method for y grid line disabled variable.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
unsigned int countX() const
Get method for x grid line count.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
unsigned int countY() const
Get method for y grid line count.
GridCoordDisable disableX() const
Get method for x grid line disabled variable.
double stopY() const
Get method for y grid line upper bound (inclusive).
double stopX() const
Get method for x grid line upper bound (inclusive).
ColorPalette paletteColor() const
Get method for color.
double startY() const
Get method for y grid line lower bound (inclusive).
log4cpp::Category * mainCat
Definition: Logger.cpp:14
CoordsType coordsType() const
Get method for coordinates type.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
double stepY() const
Get method for y grid line increment.
double startX() const
Get method for x grid line lower bound (inclusive).
QPixmap pixmap() const
Return the image that is being digitized.
Definition: Document.cpp:817
double stepX() const
Get method for x grid line increment.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition: Document.cpp:695
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20

◆ setSmallDialogs()

void DlgSettingsGridDisplay::setSmallDialogs ( bool  smallDialogs)
virtual

If false then dialogs have a minimum size so all controls are visible.

Implements DlgSettingsAbstractBase.

Definition at line 366 of file DlgSettingsGridDisplay.cpp.

367 {
368  if (!smallDialogs) {
369  setMinimumHeight (MINIMUM_HEIGHT);
370  }
371 }
const int MINIMUM_HEIGHT

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