17#include <QDoubleValidator>
18#include <QGraphicsScene>
37 "DlgSettingsGridRemoval",
39 m_validatorCloseDistance (
nullptr),
50 m_modelGridRemovalBefore (
nullptr),
51 m_modelGridRemovalAfter (
nullptr)
63 delete m_validatorCloseDistance;
64 delete m_validatorCountX;
65 delete m_validatorStartX;
66 delete m_validatorStepX;
67 delete m_validatorStopX;
68 delete m_validatorCountY;
69 delete m_validatorStartY;
70 delete m_validatorStepY;
71 delete m_validatorStopY;
85 m_scenePreview =
new QGraphicsScene (
this);
89 m_viewPreview->setWhatsThis (
tr (
"Preview window that shows how current settings affect grid removal"));
90 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
91 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
93 layout->addWidget (m_viewPreview,
row++, 0, 1, 5);
100 m_chkRemoveGridLines =
new QCheckBox (
tr (
"Remove pixels close to defined grid lines"));
101 m_chkRemoveGridLines->setWhatsThis (
tr (
"Check this box to have pixels close to regularly spaced gridlines removed.\n\n"
102 "This option is only available when the axis points have all been defined."));
104 layout->addWidget (m_chkRemoveGridLines,
row++, 1, 1, 3);
109 m_editCloseDistance =
new QLineEdit;
110 m_editCloseDistance->setWhatsThis (
tr (
"Set closeness distance in pixels.\n\n"
111 "Pixels that are closer to the regularly spaced gridlines, than this distance, "
112 "will be removed.\n\n"
113 "This value cannot be negative. A zero value disables this feature. Decimal values are allowed"));
115 m_editCloseDistance->setValidator (m_validatorCloseDistance);
117 layout->addWidget (m_editCloseDistance,
row++, 3);
141 m_cmbDisableX->setWhatsThis (
tr (
"Disabled value.\n\n"
142 "The X grid lines are specified using only three values at a time. For flexibility, four values "
143 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
144 "updated as the other values change"));
159 m_editCountX =
new QLineEdit;
160 m_editCountX->setWhatsThis (
tr (
"Number of X grid lines.\n\n"
161 "The number of X grid lines must be entered as an integer greater than zero"));
163 m_editCountX->setValidator (m_validatorCountX);
170 m_editStartX =
new QLineEdit;
171 m_editStartX->setWhatsThis (
tr (
"Value of the first X grid line.\n\n"
172 "The start value cannot be greater than the stop value"));
173 m_validatorStartX =
new QDoubleValidator;
174 m_editStartX->setValidator (m_validatorStartX);
181 m_editStepX =
new QLineEdit;
182 m_editStepX->setWhatsThis (
tr (
"Difference in value between two successive X grid lines.\n\n"
183 "The step value must be greater than zero (linear) or one (log)"));
184 m_validatorStepX =
new QDoubleValidator;
185 m_editStepX->setValidator (m_validatorStepX);
192 m_editStopX =
new QLineEdit;
193 m_editStopX->setWhatsThis (
tr (
"Value of the last X grid line.\n\n"
194 "The stop value cannot be less than the start value"));
195 m_validatorStopX =
new QDoubleValidator;
196 m_editStopX->setValidator (m_validatorStopX);
219 m_cmbDisableY->setWhatsThis (
tr (
"Disabled value.\n\n"
220 "The Y grid lines are specified using only three values at a time. For flexibility, four values "
221 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
222 "updated as the other values change"));
237 m_editCountY =
new QLineEdit;
238 m_editCountY->setWhatsThis (
tr (
"Number of Y grid lines.\n\n"
239 "The number of Y grid lines must be entered as an integer greater than zero"));
241 m_editCountY->setValidator (m_validatorCountY);
248 m_editStartY =
new QLineEdit;
249 m_editStartY->setWhatsThis (
tr (
"Value of the first Y grid line.\n\n"
250 "The start value cannot be greater than the stop value"));
251 m_validatorStartY =
new QDoubleValidator;
252 m_editStartY->setValidator (m_validatorStartY);
259 m_editStepY =
new QLineEdit;
260 m_editStepY->setWhatsThis (
tr (
"Difference in value between two successive Y grid lines.\n\n"
261 "The step value must be greater than zero (linear) or one (log)"));
262 m_validatorStepY =
new QDoubleValidator;
263 m_editStepY->setValidator (m_validatorStepY);
270 m_editStopY =
new QLineEdit;
271 m_editStopY->setWhatsThis (
tr (
"Value of the last Y grid line.\n\n"
272 "The stop value cannot be less than the start value"));
273 m_validatorStopY =
new QDoubleValidator;
274 m_editStopY->setValidator (m_validatorStopY);
287 layout->setColumnStretch(0, 1);
288 layout->setColumnStretch(1, 0);
289 layout->setColumnStretch(2, 0);
290 layout->setColumnStretch(3, 0);
291 layout->setColumnStretch(4, 1);
309 *m_modelGridRemovalBefore,
310 *m_modelGridRemovalAfter);
323 delete m_modelGridRemovalBefore;
324 delete m_modelGridRemovalAfter;
337 m_editCloseDistance->setText (QString::number (m_modelGridRemovalAfter->
closeDistance()));
342 m_editCountX->setText(QString::number(m_modelGridRemovalAfter->
countX()));
343 m_editStartX->setText(QString::number(m_modelGridRemovalAfter->
startX()));
344 m_editStepX->setText(QString::number(m_modelGridRemovalAfter->
stepX()));
345 m_editStopX->setText(QString::number(m_modelGridRemovalAfter->
stopX()));
350 m_editCountY->setText(QString::number(m_modelGridRemovalAfter->
countY()));
351 m_editStartY->setText(QString::number(m_modelGridRemovalAfter->
startY()));
352 m_editStepY->setText(QString::number(m_modelGridRemovalAfter->
stepY()));
353 m_editStopY->setText(QString::number(m_modelGridRemovalAfter->
stopY()));
367void DlgSettingsGridRemoval::slotCloseDistance(
const QString &)
371 m_modelGridRemovalAfter->
setCloseDistance(m_editCloseDistance->text().toDouble());
376void DlgSettingsGridRemoval::slotCountX(
const QString &count)
380 m_modelGridRemovalAfter->
setCountX(count.toInt());
381 updateDisplayedVariableX ();
386void DlgSettingsGridRemoval::slotCountY(
const QString &count)
390 m_modelGridRemovalAfter->
setCountY(count.toInt());
391 updateDisplayedVariableY ();
396void DlgSettingsGridRemoval::slotDisableX(
const QString &)
402 updateDisplayedVariableX ();
407void DlgSettingsGridRemoval::slotDisableY(
const QString &)
413 updateDisplayedVariableY ();
418void DlgSettingsGridRemoval::slotRemoveGridLines (
int state)
427void DlgSettingsGridRemoval::slotStartX(
const QString &startX)
431 m_modelGridRemovalAfter->
setStartX(startX.toDouble());
432 updateDisplayedVariableX ();
437void DlgSettingsGridRemoval::slotStartY(
const QString &startY)
441 m_modelGridRemovalAfter->
setStartY(startY.toDouble());
442 updateDisplayedVariableY ();
447void DlgSettingsGridRemoval::slotStepX(
const QString &stepX)
451 m_modelGridRemovalAfter->
setStepX(stepX.toDouble());
452 updateDisplayedVariableX ();
457void DlgSettingsGridRemoval::slotStepY(
const QString &stepY)
461 m_modelGridRemovalAfter->
setStepY(stepY.toDouble());
462 updateDisplayedVariableY ();
467void DlgSettingsGridRemoval::slotStopX(
const QString &stopX)
471 m_modelGridRemovalAfter->
setStopX(stopX.toDouble());
472 updateDisplayedVariableX ();
477void DlgSettingsGridRemoval::slotStopY(
const QString &stopY)
481 m_modelGridRemovalAfter->
setStopY(stopY.toDouble());
482 updateDisplayedVariableY ();
487void DlgSettingsGridRemoval::updateControls ()
489 m_editCloseDistance->setEnabled (m_chkRemoveGridLines->isChecked ());
491 m_cmbDisableX->setEnabled (m_chkRemoveGridLines->isChecked ());
499 m_cmbDisableY->setEnabled (m_chkRemoveGridLines->isChecked ());
518 bool isOk = (m_validatorCloseDistance->validate (
textCloseDistance, pos) == QValidator::Acceptable) &&
519 (m_validatorCountX->validate (
textCountX, pos) == QValidator::Acceptable) &&
520 (m_validatorStartX->validate (
textStartX, pos) == QValidator::Acceptable) &&
521 (m_validatorStepX->validate (
textStepX, pos) == QValidator::Acceptable) &&
522 (m_validatorStopX->validate (
textStopX, pos) == QValidator::Acceptable) &&
523 (m_validatorCountY->validate (
textCountY, pos) == QValidator::Acceptable) &&
524 (m_validatorStartY->validate (
textStartY, pos) == QValidator::Acceptable) &&
525 (m_validatorStepY->validate (
textStepY, pos) == QValidator::Acceptable) &&
526 (m_validatorStopY->validate (
textStopY, pos) == QValidator::Acceptable);
530void DlgSettingsGridRemoval::updateDisplayedVariableX ()
539 m_modelGridRemovalAfter->
startX (),
540 m_modelGridRemovalAfter->
stopX (),
541 m_modelGridRemovalAfter->
stepX ())));
546 m_modelGridRemovalAfter->
stopX (),
547 m_modelGridRemovalAfter->
stepX (),
548 m_modelGridRemovalAfter->
countX ())));
553 m_modelGridRemovalAfter->
startX (),
554 m_modelGridRemovalAfter->
stopX (),
555 m_modelGridRemovalAfter->
countX ())));
560 m_modelGridRemovalAfter->
startX (),
561 m_modelGridRemovalAfter->
stepX (),
562 m_modelGridRemovalAfter->
countX ())));
567void DlgSettingsGridRemoval::updateDisplayedVariableY ()
576 m_modelGridRemovalAfter->
startY (),
577 m_modelGridRemovalAfter->
stopY (),
578 m_modelGridRemovalAfter->
stepY ())));
583 m_modelGridRemovalAfter->
stopY (),
584 m_modelGridRemovalAfter->
stepY (),
585 m_modelGridRemovalAfter->
countY ())));
590 m_modelGridRemovalAfter->
startY (),
591 m_modelGridRemovalAfter->
stopY (),
592 m_modelGridRemovalAfter->
countY ())));
597 m_modelGridRemovalAfter->
startY (),
598 m_modelGridRemovalAfter->
stepY (),
599 m_modelGridRemovalAfter->
countY ())));
604void DlgSettingsGridRemoval::updatePreview ()
609 *m_modelGridRemovalAfter,
612 m_scenePreview->clear();
613 m_scenePreview->addPixmap (pixmap);
const int INNER_RADIUS_MIN
const double CLOSE_DISTANCE_MIN
const double CLOSE_DISTANCE_MAX
#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 DlgSettingsGridRemoval.
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 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 load(CmdMediator &cmdMediator)
Load settings from Document.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
virtual void handleOk()
Process slotOk.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
virtual ~DlgSettingsGridRemoval()
DlgSettingsGridRemoval(MainWindow &mainWindow)
Single constructor.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
double closeDistance() const
Get method for close distance.
GridCoordDisable gridCoordDisableX() const
Get method for x coord parameter to disable.
bool removeDefinedGridLines() const
Get method for removing defined grid lines.
double stopX() const
Get method for x stop.
GridCoordDisable gridCoordDisableY() const
Get method for y coord parameter to disable.
void setCloseDistance(double closeDistance)
Set method for close distance.
void setStopY(double stopY)
Set method for y stop.
double startX() const
Get method for x start.
void setCountX(int countX)
Set method for x count.
double stopY() const
Get method for y stop.
void setGridCoordDisableY(GridCoordDisable gridCoordDisable)
Set method for y coord parameter to disable.
double stepX() const
Get method for x step.
void setStable()
Set the stable flag to true. This public version has no argument since it cannot be undone.
void setGridCoordDisableX(GridCoordDisable gridCoordDisable)
Set method for x coord parameter to disable.
void setStepX(double stepX)
Set method for x step.
void setStopX(double stopX)
Set method for x stop.
void setStartY(double startY)
Set method for y start.
double stepY() const
Get method for y step.
int countY() const
Get method for y count.
int countX() const
Get method for x count.
double startY() const
Get method for y start.
void setRemoveDefinedGridLines(bool removeDefinedGridLines)
Set method for removing defined grid lines.
void setStepY(double stepY)
Set method for y step.
void setStartX(double startX)
Set method for x start.
void setCountY(int countY)
Set method for y count.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
This class initializes the count, start, step and stop parameters for one coordinate (either x/theta ...
Strategy class for grid removal.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window,...
@ VIEW_ASPECT_RATIO_VARIABLE
#define LOG4CPP_INFO_S(logger)