Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgSettingsCoords Class Reference

Dialog for editing coordinates settings. More...

#include <DlgSettingsCoords.h>

Inheritance diagram for DlgSettingsCoords:
Inheritance graph
Collaboration diagram for DlgSettingsCoords:
Collaboration graph

Public Member Functions

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

Protected Member Functions

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

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.
static int MINIMUM_PREVIEW_HEIGHT = 100
 Dialog layout constant that guarantees preview has sufficent room.

Detailed Description

Dialog for editing coordinates settings.

Definition at line 28 of file DlgSettingsCoords.h.

Constructor & Destructor Documentation

◆ DlgSettingsCoords()

DlgSettingsCoords::DlgSettingsCoords ( MainWindow & mainWindow)

Single constructor.

Definition at line 74 of file DlgSettingsCoords.cpp.

74 :
75 DlgSettingsAbstractBase (tr ("Coordinates"),
76 "DlgSettingsCoords",
78 m_btnCartesian (nullptr),
79 m_btnPolar (nullptr),
80 m_validatorOriginRadius (nullptr),
81 m_cmbDate (nullptr),
82 m_cmbTime (nullptr),
83 m_scenePreview (nullptr),
84 m_viewPreview (nullptr),
85 m_modelCoordsBefore (nullptr),
86 m_modelCoordsAfter (nullptr)
87{
88 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::DlgSettingsCoords";
89
90 QWidget *subPanel = createSubPanel ();
91 finishPanel (subPanel,
93}
const int MINIMUM_DIALOG_WIDTH_COORDS
log4cpp::Category * mainCat
Definition Logger.cpp:14
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
MainWindow & mainWindow()
Get method for MainWindow.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~DlgSettingsCoords()

DlgSettingsCoords::~DlgSettingsCoords ( )
virtual

Definition at line 95 of file DlgSettingsCoords.cpp.

96{
97 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::~DlgSettingsCoords";
98}

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsCoords::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 353 of file DlgSettingsCoords.cpp.

354{
355}

◆ createSubPanel()

QWidget * DlgSettingsCoords::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 377 of file DlgSettingsCoords.cpp.

378{
379 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createSubPanel";
380
381 QWidget *subPanel = new QWidget ();
382
383 QGridLayout *layout = new QGridLayout (subPanel);
384 subPanel->setLayout (layout);
385
386 layout->setColumnStretch(0, 1); // Empty first column
387 layout->setColumnStretch(1, 0); // Labels
388 layout->setColumnStretch(2, 0); // User controls
389 layout->setColumnStretch(3, 1); // Empty last column
390
391 int row = 0;
392 createGroupCoordsType(layout, row);
393 createGroupXTheta (layout, row);
394 createGroupYRadius (layout, row);
395 createDateTime (layout, row);
396 createPreview (layout, row);
397
398 return subPanel;
399}

◆ handleOk()

void DlgSettingsCoords::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 548 of file DlgSettingsCoords.cpp.

549{
550 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::handleOk";
551
552 CmdSettingsCoords *cmd = new CmdSettingsCoords (mainWindow (),
553 cmdMediator ().document(),
554 *m_modelCoordsBefore,
555 *m_modelCoordsAfter);
556 cmdMediator ().push (cmd);
557
558 hide ();
559}
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ load()

void DlgSettingsCoords::load ( CmdMediator & cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 561 of file DlgSettingsCoords.cpp.

562{
563 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::load";
564
566
567 // Remove if coordinates are log so later constraints can be applied
568 bool isEmpty;
569 QPointF boundingRectGraphMin, boundingRectGraphMax;
570 boundingRectGraph (cmdMediator,
571 isEmpty,
572 boundingRectGraphMin,
573 boundingRectGraphMax);
574 bool xThetaGoesNegative = !isEmpty && (boundingRectGraphMin.x() <= 0);
575 bool yRGoesNegative = !isEmpty && (boundingRectGraphMin.y() <= 0);
576 m_xThetaLinear->setEnabled (!xThetaGoesNegative);
577 m_xThetaLog->setEnabled (!xThetaGoesNegative);
578 m_yRadiusLinear->setEnabled (!yRGoesNegative);
579 m_yRadiusLog->setEnabled (!yRGoesNegative);
580
581 // Flush old data
582 delete m_modelCoordsBefore;
583 delete m_modelCoordsAfter;
584
585 // Save new data
586 m_modelCoordsBefore = new DocumentModelCoords (cmdMediator.document().modelCoords());
587 m_modelCoordsAfter = new DocumentModelCoords (cmdMediator.document().modelCoords());
588
589 // Populate controls
590 DlgValidatorFactory dlgValidatorFactory;
591 m_validatorOriginRadius = dlgValidatorFactory.createWithNonPolar (m_modelCoordsAfter->coordScaleYRadius(),
592 m_modelCoordsAfter->coordUnitsRadius(),
593 m_modelCoordsAfter->coordUnitsDate(),
594 m_modelCoordsAfter->coordUnitsTime(),
595 mainWindow().modelMainWindow().locale());
596 m_editOriginRadius->setValidator (m_validatorOriginRadius); // Set before call to setText so validator is defined in updateControls
597 m_editOriginRadius->setText (QString::number (m_modelCoordsAfter->originRadius ()));
598
599 if (m_modelCoordsAfter->coordsType() == COORDS_TYPE_CARTESIAN) {
600 m_btnCartesian->setChecked (true);
601 } else {
602 m_btnPolar->setChecked (true);
603 }
604
605 updateCoordUnits(); // Call after checking m_btnCartesian or m_btnPolar
606 loadComboBoxDate();
607 loadComboBoxTime ();
608
609 m_xThetaLinear->setChecked (m_modelCoordsAfter->coordScaleXTheta() == COORD_SCALE_LINEAR);
610 m_xThetaLog->setChecked (m_modelCoordsAfter->coordScaleXTheta() == COORD_SCALE_LOG);
611 m_yRadiusLinear->setChecked (m_modelCoordsAfter->coordScaleYRadius() == COORD_SCALE_LINEAR);
612 m_yRadiusLog->setChecked (m_modelCoordsAfter->coordScaleYRadius() == COORD_SCALE_LOG);
613
614 updateControls (); // Probably redundant due to the setChecked just above
615 enableOk (false); // Disable Ok button since there not yet any changes
616 updatePreview();
617}
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
@ COORD_SCALE_LOG
Definition CoordScale.h:14
@ COORDS_TYPE_CARTESIAN
Definition CoordsType.h:13
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
DlgValidatorAbstract * createWithNonPolar(CoordScale coordScale, CoordUnitsNonPolarTheta coordUnits, CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QLocale &locale) const
Factory method for generating validators when cartesian/polar case handling is handled externally,...

◆ setSmallDialogs()

void DlgSettingsCoords::setSmallDialogs ( bool smallDialogs)
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 737 of file DlgSettingsCoords.cpp.

738{
739 if (!smallDialogs) {
740 setMinimumHeight (MINIMUM_HEIGHT);
741 }
742}
const int MINIMUM_HEIGHT

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