17#include <QDoubleValidator>
18#include <QGraphicsScene>
32 "DlgSettingsGridDisplay",
44 m_modelGridDisplayBefore (
nullptr),
45 m_modelGridDisplayAfter (
nullptr)
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;
78 m_labelLimitWarning =
new QLabel;
79 m_labelLimitWarning->setStyleSheet (
"QLabel { color: red; }");
86 m_cmbColor->setWhatsThis (
tr (
"Select a color for the lines"));
112 m_cmbDisableX->setWhatsThis (
tr (
"Disabled value.\n\n"
113 "The X grid lines are specified using only three values at a time. For flexibility, four values "
114 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
115 "updated as the other values change"));
130 m_editCountX =
new QLineEdit;
131 m_editCountX->setWhatsThis (
tr (
"Number of X grid lines.\n\n"
132 "The number of X grid lines must be entered as an integer greater than zero"));
133 m_validatorCountX =
new QDoubleValidator;
134 m_validatorCountX->setBottom (
COUNT_MIN);
136 m_editCountX->setValidator (m_validatorCountX);
143 m_editStartX =
new QLineEdit;
144 m_editStartX->setWhatsThis (
tr (
"Value of the first X grid line.\n\n"
145 "The start value cannot be greater than the stop value"));
146 m_validatorStartX =
new QDoubleValidator;
147 m_editStartX->setValidator (m_validatorStartX);
154 m_editStepX =
new QLineEdit;
155 m_editStepX->setWhatsThis (
tr (
"Difference in value between two successive X grid lines.\n\n"
156 "The step value must be greater than zero (linear) or one (log)"));
157 m_validatorStepX =
new QDoubleValidator;
158 m_editStepX->setValidator (m_validatorStepX);
165 m_editStopX =
new QLineEdit;
166 m_editStopX->setWhatsThis (
tr (
"Value of the last X grid line.\n\n"
167 "The stop value cannot be less than the start value"));
168 m_validatorStopX =
new QDoubleValidator;
169 m_editStopX->setValidator (m_validatorStopX);
188 m_cmbDisableY->setWhatsThis (
tr (
"Disabled value.\n\n"
189 "The Y grid lines are specified using only three values at a time. For flexibility, four values "
190 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
191 "updated as the other values change"));
206 m_editCountY =
new QLineEdit;
207 m_editCountY->setWhatsThis (
tr (
"Number of Y grid lines.\n\n"
208 "The number of Y grid lines must be entered as an integer greater than zero"));
209 m_validatorCountY =
new QDoubleValidator;
210 m_validatorCountY->setBottom (
COUNT_MIN);
212 m_editCountY->setValidator (m_validatorCountY);
219 m_editStartY =
new QLineEdit;
220 m_editStartY->setWhatsThis (
tr (
"Value of the first Y grid line.\n\n"
221 "The start value cannot be greater than the stop value"));
222 m_validatorStartY =
new QDoubleValidator;
223 m_editStartY->setValidator (m_validatorStartY);
230 m_editStepY =
new QLineEdit;
231 m_editStepY->setWhatsThis (
tr (
"Difference in value between two successive Y grid lines.\n\n"
232 "The step value must be greater than zero (linear) or one (log)"));
233 m_validatorStepY =
new QDoubleValidator;
234 m_editStepY->setValidator (m_validatorStepY);
241 m_editStopY =
new QLineEdit;
242 m_editStopY->setWhatsThis (
tr (
"Value of the last Y grid line.\n\n"
243 "The stop value cannot be less than the start value"));
244 m_validatorStopY =
new QDoubleValidator;
245 m_editStopY->setValidator (m_validatorStopY);
261 m_scenePreview =
new QGraphicsScene (
this);
265 m_viewPreview->setWhatsThis (
tr (
"Preview window that shows how current settings affect grid display"));
266 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
267 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
269 layout->addWidget (m_viewPreview,
row++, 0, 1, 5);
280 layout->setColumnStretch(0, 1);
281 layout->setColumnStretch(1, 0);
282 layout->setColumnStretch(2, 0);
283 layout->setColumnStretch(3, 0);
284 layout->setColumnStretch(4, 1);
300 m_modelGridDisplayAfter->
setStable (
true);
304 *m_modelGridDisplayBefore,
305 *m_modelGridDisplayAfter);
318 delete m_modelGridDisplayBefore;
319 delete m_modelGridDisplayAfter;
326 m_groupX->setTitle (
titleX);
332 m_groupY->setTitle (
titleY);
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()));
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()));
373void DlgSettingsGridDisplay::slotColor (
QString const &)
382void DlgSettingsGridDisplay::slotCountX(
const QString &count)
386 m_modelGridDisplayAfter->
setCountX(
unsigned (count.toInt()));
387 updateDisplayedVariableX ();
392void DlgSettingsGridDisplay::slotCountY(
const QString &count)
396 m_modelGridDisplayAfter->
setCountY(
unsigned (count.toInt()));
397 updateDisplayedVariableY ();
402void DlgSettingsGridDisplay::slotDisableX(
const QString &)
408 updateDisplayedVariableX ();
413void DlgSettingsGridDisplay::slotDisableY(
const QString &)
419 updateDisplayedVariableY ();
424void DlgSettingsGridDisplay::slotStartX(
const QString &startX)
428 m_modelGridDisplayAfter->
setStartX(startX.toDouble());
429 updateDisplayedVariableX ();
434void DlgSettingsGridDisplay::slotStartY(
const QString &startY)
438 m_modelGridDisplayAfter->
setStartY(startY.toDouble());
439 updateDisplayedVariableY ();
444void DlgSettingsGridDisplay::slotStepX(
const QString &stepX)
448 m_modelGridDisplayAfter->
setStepX(stepX.toDouble());
449 updateDisplayedVariableX ();
454void DlgSettingsGridDisplay::slotStepY(
const QString &stepY)
458 m_modelGridDisplayAfter->
setStepY(stepY.toDouble());
459 updateDisplayedVariableY ();
464void DlgSettingsGridDisplay::slotStopX(
const QString &stopX)
468 m_modelGridDisplayAfter->
setStopX(stopX.toDouble());
469 updateDisplayedVariableX ();
474void DlgSettingsGridDisplay::slotStopY(
const QString &stopY)
478 m_modelGridDisplayAfter->
setStopY(stopY.toDouble());
479 updateDisplayedVariableY ();
484bool DlgSettingsGridDisplay::textItemsAreValid ()
const
509 m_validatorCountX->validate(
textCountX, pos) == QValidator::Acceptable &&
510 m_validatorCountY->validate(
textCountY, pos) == QValidator::Acceptable &&
511 m_validatorStartX->validate(
textStartX, pos) == QValidator::Acceptable &&
512 m_validatorStartY->validate(
textStartY, pos) == QValidator::Acceptable &&
513 m_validatorStepX->validate(
textStepX, pos) == QValidator::Acceptable &&
514 m_validatorStepY->validate(
textStepY, pos) == QValidator::Acceptable &&
515 m_validatorStopX->validate(
textStopX, pos) == QValidator::Acceptable &&
516 m_validatorStopY->validate(
textStopY, pos) == QValidator::Acceptable) {
522 if (
qAbs (stepX) > 0 &&
qAbs (stepY) > 0) {
531bool DlgSettingsGridDisplay::textItemsDoNotBreakLineCountLimit ()
533 if (textItemsAreValid ()) {
571void DlgSettingsGridDisplay::updateControls ()
585 if (textItemsDoNotBreakLineCountLimit ()) {
586 m_labelLimitWarning->setText (
"");
588 m_labelLimitWarning->setText (
tr (
"Grid line count exceeds limit set by Settings / Main Window."));
591 enableOk (textItemsAreValid () && textItemsDoNotBreakLineCountLimit ());
594void DlgSettingsGridDisplay::updateDisplayedVariableX ()
600 switch (m_modelGridDisplayAfter->
disableX()) {
603 m_modelGridDisplayAfter->
startX (),
604 m_modelGridDisplayAfter->
stopX (),
605 m_modelGridDisplayAfter->
stepX ())));
610 m_modelGridDisplayAfter->
stopX (),
611 m_modelGridDisplayAfter->
stepX (),
617 m_modelGridDisplayAfter->
startX (),
618 m_modelGridDisplayAfter->
stopX (),
624 m_modelGridDisplayAfter->
startX (),
625 m_modelGridDisplayAfter->
stepX (),
631void DlgSettingsGridDisplay::updateDisplayedVariableY ()
637 switch (m_modelGridDisplayAfter->
disableY()) {
640 m_modelGridDisplayAfter->
startY (),
641 m_modelGridDisplayAfter->
stopY (),
642 m_modelGridDisplayAfter->
stepY ())));
647 m_modelGridDisplayAfter->
stopY (),
648 m_modelGridDisplayAfter->
stepY (),
654 m_modelGridDisplayAfter->
startY (),
655 m_modelGridDisplayAfter->
stopY (),
661 m_modelGridDisplayAfter->
startY (),
662 m_modelGridDisplayAfter->
stepY (),
668void DlgSettingsGridDisplay::updatePreview ()
670 m_gridLines.
clear ();
672 if (textItemsAreValid ()) {
677 factory.createGridLinesForEvenlySpacedGrid (*m_modelGridDisplayAfter,
const int INNER_RADIUS_MIN
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
QString gridCoordDisableToString(GridCoordDisable gridCoordDisable)
@ GRID_COORD_DISABLE_STOP
@ GRID_COORD_DISABLE_START
@ GRID_COORD_DISABLE_STEP
@ GRID_COORD_DISABLE_COUNT
log4cpp::Category * mainCat
Command for DlgSettingsGridDisplay.
Abstract base class for all Settings dialogs.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void populateColorComboWithoutTransparent(QComboBox &combo)
Add colors in color palette to combobox, without transparent entry at end.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
MainWindow & mainWindow()
Get method for MainWindow.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual ~DlgSettingsGridDisplay()
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.
DlgSettingsGridDisplay(MainWindow &mainWindow)
Single constructor.
virtual void handleOk()
Process slotOk.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CoordsType coordsType() const
Get method for coordinates type.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
GridCoordDisable disableY() const
Get method for y grid line disabled variable.
unsigned int countX() const
Get method for x grid line count.
void setPaletteColor(ColorPalette paletteColor)
Set method for color.
double startX() const
Get method for x grid line lower bound (inclusive).
GridCoordDisable disableX() const
Get method for x grid line disabled variable.
unsigned int countY() const
Get method for y grid line count.
double stepX() const
Get method for x grid line increment.
void setStepX(double stepX)
Set method for x grid line increment.
double stopX() const
Get method for x grid line upper bound (inclusive).
double stopY() const
Get method for y grid line upper bound (inclusive).
void setStepY(double yStep)
Set method for y grid line increment.
void setStopX(double stopX)
Set method for x grid line upper bound (inclusive).
void setDisableX(GridCoordDisable disableX)
Set method for x grid line disabled variable.
ColorPalette paletteColor() const
Get method for color.
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
void setDisableY(GridCoordDisable disableY)
Set method for y grid line disabled variable.
double stepY() const
Get method for y grid line increment.
void setCountX(unsigned int countX)
Set method for x grid line count.
void setStartX(double startX)
Set method for x grid line lower bound (inclusive).
void setStable(bool stable)
Set method for stable flag.
double startY() const
Get method for y grid line lower bound (inclusive).
void setStartY(double yStart)
Set method for y grid line lower bound (inclusive).
void setCountY(unsigned int countY)
Set method for y grid line count.
QPixmap pixmap() const
Return the image that is being digitized.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
This class initializes the count, start, step and stop parameters for one coordinate (either x/theta ...
int computeCount(bool linearAxis, double start, double stop, double step) const
Compute axis scale count from the other axis parameters.
Factory class for generating the points, composed of QGraphicsItem objects, along a GridLine.
void clear()
Deallocate and remove all grid lines.
int maximumGridLines() const
Maximum number of grid lines.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
MainWindowModel modelMainWindow() const
Get method for main window model.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window,...
@ VIEW_ASPECT_RATIO_VARIABLE
#define LOG4CPP_INFO_S(logger)