Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
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 QWidgetcreateSubPanel ()
 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 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 27 of file DlgSettingsCoords.h.

Constructor & Destructor Documentation

◆ DlgSettingsCoords()

DlgSettingsCoords::DlgSettingsCoords ( MainWindow & mainWindow)

Single constructor.

Definition at line 75 of file DlgSettingsCoords.cpp.

75 :
76 DlgSettingsAbstractBase (tr ("Coordinates"),
77 "DlgSettingsCoords",
79 m_btnCartesian (nullptr),
80 m_btnPolar (nullptr),
81 m_validatorOriginRadius (nullptr),
82 m_cmbDate (nullptr),
83 m_cmbTime (nullptr),
84 m_scenePreview (nullptr),
85 m_viewPreview (nullptr),
86 m_modelCoordsBefore (nullptr),
87 m_modelCoordsAfter (nullptr)
88{
89 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::DlgSettingsCoords";
90
94}
const int MINIMUM_DIALOG_WIDTH_COORDS
const int INNER_RADIUS_MIN
log4cpp::Category * mainCat
Definition Logger.cpp:14
Abstract base class for all Settings dialogs.
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 96 of file DlgSettingsCoords.cpp.

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

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsCoords::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 349 of file DlgSettingsCoords.cpp.

350{
351}

◆ createSubPanel()

QWidget * DlgSettingsCoords::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 373 of file DlgSettingsCoords.cpp.

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

◆ handleOk()

void DlgSettingsCoords::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 544 of file DlgSettingsCoords.cpp.

545{
546 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::handleOk";
547
549 cmdMediator ().document(),
550 *m_modelCoordsBefore,
551 *m_modelCoordsAfter);
552 cmdMediator ().push (cmd);
553
554 hide ();
555}
Command for DlgSettingsCoords.
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 557 of file DlgSettingsCoords.cpp.

558{
559 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::load";
560
562
563 // Remove if coordinates are log so later constraints can be applied
564 bool isEmpty;
565 QPointF boundingRectGraphMin, boundingRectGraphMax;
566 boundingRectGraph (cmdMediator,
567 isEmpty,
568 boundingRectGraphMin,
569 boundingRectGraphMax);
570 bool xThetaGoesNegative = !isEmpty && (boundingRectGraphMin.x() <= 0);
571 bool yRGoesNegative = !isEmpty && (boundingRectGraphMin.y() <= 0);
572 m_xThetaLinear->setEnabled (!xThetaGoesNegative);
573 m_xThetaLog->setEnabled (!xThetaGoesNegative);
574 m_yRadiusLinear->setEnabled (!yRGoesNegative);
575 m_yRadiusLog->setEnabled (!yRGoesNegative);
576
577 // Flush old data
578 delete m_modelCoordsBefore;
579 delete m_modelCoordsAfter;
580
581 // Save new data
582 m_modelCoordsBefore = new DocumentModelCoords (cmdMediator.document().modelCoords());
583 m_modelCoordsAfter = new DocumentModelCoords (cmdMediator.document().modelCoords());
584
585 // Populate controls
587 m_validatorOriginRadius = dlgValidatorFactory.createWithNonPolar (m_modelCoordsAfter->coordScaleYRadius(),
588 m_modelCoordsAfter->coordUnitsRadius(),
589 m_modelCoordsAfter->coordUnitsDate(),
590 m_modelCoordsAfter->coordUnitsTime(),
591 mainWindow().modelMainWindow().locale());
592 m_editOriginRadius->setValidator (m_validatorOriginRadius); // Set before call to setText so validator is defined in updateControls
593 m_editOriginRadius->setText (QString::number (m_modelCoordsAfter->originRadius ()));
594
595 if (m_modelCoordsAfter->coordsType() == COORDS_TYPE_CARTESIAN) {
596 m_btnCartesian->setChecked (true);
597 } else {
598 m_btnPolar->setChecked (true);
599 }
600
601 updateCoordUnits(); // Call after checking m_btnCartesian or m_btnPolar
602 loadComboBoxDate();
603 loadComboBoxTime ();
604
605 m_xThetaLinear->setChecked (m_modelCoordsAfter->coordScaleXTheta() == COORD_SCALE_LINEAR);
606 m_xThetaLog->setChecked (m_modelCoordsAfter->coordScaleXTheta() == COORD_SCALE_LOG);
607 m_yRadiusLinear->setChecked (m_modelCoordsAfter->coordScaleYRadius() == COORD_SCALE_LINEAR);
608 m_yRadiusLog->setChecked (m_modelCoordsAfter->coordScaleYRadius() == COORD_SCALE_LOG);
609
610 updateControls (); // Probably redundant due to the setChecked just above
611 enableOk (false); // Disable Ok button since there not yet any changes
612 updatePreview();
613}
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
@ COORD_SCALE_LOG
Definition CoordScale.h:14
@ COORDS_TYPE_CARTESIAN
Definition CoordsType.h:13
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
Validator factory.
Model for DlgSettingsCoords and CmdSettingsCoords.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordUnitsNonPolarTheta coordUnitsRadius() const
Get method for radius units.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CoordUnitsTime coordUnitsTime() const
Get method for time format when used.
CoordsType coordsType() const
Get method for coordinates type.
double originRadius() const
Get method for origin radius in polar mode.
CoordUnitsDate coordUnitsDate() const
Get method for date format when used.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:695

◆ 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 732 of file DlgSettingsCoords.cpp.

733{
734 if (!smallDialogs) {
736 }
737}
const int MINIMUM_HEIGHT

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