Engauge Digitizer  2
DlgSettingsGridRemoval.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "CmdMediator.h"
8 #include "CmdSettingsGridRemoval.h"
9 #include "DlgSettingsGridRemoval.h"
10 #include "EngaugeAssert.h"
11 #include "Logger.h"
12 #include "MainWindow.h"
13 #include <QCheckBox>
14 #include <QComboBox>
15 #include <QDoubleValidator>
16 #include <QGraphicsScene>
17 #include <QGridLayout>
18 #include <QGroupBox>
19 #include <QHBoxLayout>
20 #include <QLabel>
21 #include <QLineEdit>
22 #include "ViewPreview.h"
23 
24 const double CLOSE_DISTANCE_MAX = 64;
25 const double CLOSE_DISTANCE_MIN = 0;
26 const int CLOSE_DECIMALS = 1;
27 const int COUNT_MIN = 1;
28 const int COUNT_MAX = 100;
29 const int COUNT_DECIMALS = 0;
30 
32  DlgSettingsAbstractBase (tr ("Grid Removal"),
33  "DlgSettingsGridRemoval",
34  mainWindow),
35  m_scenePreview (0),
36  m_viewPreview (0),
37  m_modelGridRemovalBefore (0),
38  m_modelGridRemovalAfter (0)
39 {
40  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::DlgSettingsGridRemoval";
41 
42  QWidget *subPanel = createSubPanel ();
43  finishPanel (subPanel);
44 }
45 
46 DlgSettingsGridRemoval::~DlgSettingsGridRemoval()
47 {
48  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::~DlgSettingsGridRemoval";
49 }
50 
51 void DlgSettingsGridRemoval::createOptionalSaveDefault (QHBoxLayout * /* layout */)
52 {
53 }
54 
55 void DlgSettingsGridRemoval::createPreview (QGridLayout *layout, int &row)
56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createPreview";
58 
59  QLabel *labelPreview = new QLabel (tr ("Preview"));
60  layout->addWidget (labelPreview, row++, 0, 1, 5);
61 
62  m_scenePreview = new QGraphicsScene (this);
63  m_viewPreview = new ViewPreview (m_scenePreview,
64  ViewPreview::VIEW_ASPECT_RATIO_VARIABLE,
65  this);
66  m_viewPreview->setWhatsThis (tr ("Preview window that shows how current settings affect grid removal"));
67  m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
68  m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
69  m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
70  layout->addWidget (m_viewPreview, row++, 0, 1, 5);
71 }
72 
73 void DlgSettingsGridRemoval::createRemoveGridLines (QGridLayout *layout, int &row)
74 {
75  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createRemoveGridLines";
76 
77  m_chkRemoveGridLines = new QCheckBox (tr ("Remove pixels close to defined grid lines"));
78  m_chkRemoveGridLines->setWhatsThis (tr ("Check this box to have pixels close to regularly spaced gridlines removed.\n\n"
79  "This option is only available when the axis points have all been defined."));
80  connect (m_chkRemoveGridLines, SIGNAL (stateChanged (int)), this, SLOT (slotRemoveGridLines (int)));
81  layout->addWidget (m_chkRemoveGridLines, row++, 1, 1, 3);
82 
83  QLabel *labelCloseDistance = new QLabel (tr ("Close distance (pixels):"));
84  layout->addWidget (labelCloseDistance, row, 2);
85 
86  m_editCloseDistance = new QLineEdit;
87  m_editCloseDistance->setWhatsThis (tr ("Set closeness distance in pixels.\n\n"
88  "Pixels that are closer to the regularly spaced gridlines, than this distance, "
89  "will be removed.\n\n"
90  "This value cannot be negative. A zero value disables this feature. Decimal values are allowed"));
91  m_validatorCloseDistance = new QDoubleValidator (CLOSE_DISTANCE_MIN, CLOSE_DISTANCE_MAX, CLOSE_DECIMALS);
92  m_editCloseDistance->setValidator (m_validatorCloseDistance);
93  connect (m_editCloseDistance, SIGNAL (textChanged (const QString &)), this, SLOT (slotCloseDistance (const QString &)));
94  layout->addWidget (m_editCloseDistance, row++, 3);
95 
96  createRemoveGridLinesX (layout, row);
97  createRemoveGridLinesY (layout, row);
98 }
99 
100 void DlgSettingsGridRemoval::createRemoveGridLinesX (QGridLayout *layout, int &row)
101 {
102  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createRemoveGridLinesX";
103 
104  QString titleX = tr ("X Grid Lines");
105  if (false) {
106  titleX = QString (QChar (0x98, 0x03)) + QString (" %1").arg (tr ("Grid Lines"));
107  }
108  QGroupBox *groupX = new QGroupBox (titleX);
109  layout->addWidget (groupX, row, 2);
110 
111  QGridLayout *layoutGroup = new QGridLayout;
112  groupX->setLayout (layoutGroup);
113 
114  QLabel *labelDisable = new QLabel (tr ("Disable:"));
115  layoutGroup->addWidget (labelDisable, 0, 0);
116 
117  m_cmbDisableX = new QComboBox;
118  m_cmbDisableX->setWhatsThis (tr ("Disabled value.\n\n"
119  "The X grid lines are specified using only three values at a time. For flexibility, four values "
120  "are offered so you must chose which value is disabled. Once disabled, that value is simply "
121  "updated as the other values change"));
122  m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
123  QVariant (GRID_COORD_DISABLE_COUNT));
124  m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
125  QVariant (GRID_COORD_DISABLE_START));
126  m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
127  QVariant (GRID_COORD_DISABLE_STEP));
128  m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
129  QVariant (GRID_COORD_DISABLE_STOP));
130  connect (m_cmbDisableX, SIGNAL (activated (const QString &)), this, SLOT (slotDisableX (const QString &))); // activated() ignores code changes
131  layoutGroup->addWidget (m_cmbDisableX, 0, 1);
132 
133  QLabel *labelCount = new QLabel (tr ("Count:"));
134  layoutGroup->addWidget (labelCount, 1, 0);
135 
136  m_editCountX = new QLineEdit;
137  m_editCountX->setWhatsThis (tr ("Number of X grid lines.\n\n"
138  "The number of X grid lines must be entered as an integer greater than zero"));
139  m_validatorCountX = new QDoubleValidator (COUNT_MIN, COUNT_MAX, COUNT_DECIMALS);
140  m_editCountX->setValidator (m_validatorCountX);
141  connect (m_editCountX, SIGNAL (textChanged (const QString &)), this, SLOT (slotCountX (const QString &)));
142  layoutGroup->addWidget (m_editCountX, 1, 1);
143 
144  QLabel *labelStart = new QLabel (tr ("Start:"));
145  layoutGroup->addWidget (labelStart, 2, 0);
146 
147  m_editStartX = new QLineEdit;
148  m_editStartX->setWhatsThis (tr ("Value of the first X grid line.\n\n"
149  "The start value cannot be greater than the stop value"));
150  m_validatorStartX = new QDoubleValidator;
151  m_editStartX->setValidator (m_validatorStartX);
152  connect (m_editStartX, SIGNAL (textChanged (const QString &)), this, SLOT (slotStartX (const QString &)));
153  layoutGroup->addWidget (m_editStartX, 2, 1);
154 
155  QLabel *labelStep = new QLabel (tr ("Step:"));
156  layoutGroup->addWidget (labelStep, 3, 0);
157 
158  m_editStepX = new QLineEdit;
159  m_editStepX->setWhatsThis (tr ("Difference in value between two successive X grid lines.\n\n"
160  "The step value must be greater than zero"));
161  m_validatorStepX = new QDoubleValidator;
162  m_editStepX->setValidator (m_validatorStepX);
163  connect (m_editStepX, SIGNAL (textChanged (const QString &)), this, SLOT (slotStepX (const QString &)));
164  layoutGroup->addWidget (m_editStepX, 3, 1);
165 
166  QLabel *labelStop = new QLabel (tr ("Stop:"));
167  layoutGroup->addWidget (labelStop, 4, 0);
168 
169  m_editStopX = new QLineEdit;
170  m_editStopX->setWhatsThis (tr ("Value of the last X grid line.\n\n"
171  "The stop value cannot be less than the start value"));
172  m_validatorStopX = new QDoubleValidator;
173  m_editStopX->setValidator (m_validatorStopX);
174  connect (m_editStopX, SIGNAL (textChanged (const QString &)), this, SLOT (slotStopX (const QString &)));
175  layoutGroup->addWidget (m_editStopX, 4, 1);
176 }
177 
178 void DlgSettingsGridRemoval::createRemoveGridLinesY (QGridLayout *layout, int &row)
179 {
180  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createRemoveGridLinesY";
181 
182  QString titleY = tr ("Y Grid Lines");
183  if (false) {
184  titleY = QString (tr ("R Grid Lines"));
185  }
186  QGroupBox *groupY = new QGroupBox (titleY);
187  layout->addWidget (groupY, row++, 3);
188 
189  QGridLayout *layoutGroup = new QGridLayout;
190  groupY->setLayout (layoutGroup);
191 
192  QLabel *labelDisable = new QLabel (tr ("Disable:"));
193  layoutGroup->addWidget (labelDisable, 0, 0);
194 
195  m_cmbDisableY = new QComboBox;
196  m_cmbDisableY->setWhatsThis (tr ("Disabled value.\n\n"
197  "The Y grid lines are specified using only three values at a time. For flexibility, four values "
198  "are offered so you must chose which value is disabled. Once disabled, that value is simply "
199  "updated as the other values change"));
200  m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
201  QVariant (GRID_COORD_DISABLE_COUNT));
202  m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
203  QVariant (GRID_COORD_DISABLE_START));
204  m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
205  QVariant (GRID_COORD_DISABLE_STEP));
206  m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
207  QVariant (GRID_COORD_DISABLE_STOP));
208  connect (m_cmbDisableY, SIGNAL (activated (const QString &)), this, SLOT (slotDisableY (const QString &))); // activated() ignores code changes
209  layoutGroup->addWidget (m_cmbDisableY, 0, 1);
210 
211  QLabel *labelCount = new QLabel (tr ("Count:"));
212  layoutGroup->addWidget (labelCount, 1, 0);
213 
214  m_editCountY = new QLineEdit;
215  m_editCountY->setWhatsThis (tr ("Number of Y grid lines.\n\n"
216  "The number of Y grid lines must be entered as an integer greater than zero"));
217  m_validatorCountY = new QDoubleValidator (COUNT_MIN, COUNT_MAX, COUNT_DECIMALS);
218  m_editCountY->setValidator (m_validatorCountY);
219  connect (m_editCountY, SIGNAL (textChanged (const QString &)), this, SLOT (slotCountY (const QString &)));
220  layoutGroup->addWidget (m_editCountY, 1, 1);
221 
222  QLabel *labelStart = new QLabel (tr ("Start:"));
223  layoutGroup->addWidget (labelStart, 2, 0);
224 
225  m_editStartY = new QLineEdit;
226  m_editStartY->setWhatsThis (tr ("Value of the first Y grid line.\n\n"
227  "The start value cannot be greater than the stop value"));
228  m_validatorStartY = new QDoubleValidator;
229  m_editStartY->setValidator (m_validatorStartY);
230  connect (m_editStartY, SIGNAL (textChanged (const QString &)), this, SLOT (slotStartY (const QString &)));
231  layoutGroup->addWidget (m_editStartY, 2, 1);
232 
233  QLabel *labelStep = new QLabel (tr ("Step:"));
234  layoutGroup->addWidget (labelStep, 3, 0);
235 
236  m_editStepY = new QLineEdit;
237  m_editStepY->setWhatsThis (tr ("Difference in value between two successive Y grid lines.\n\n"
238  "The step value must be greater than zero"));
239  m_validatorStepY = new QDoubleValidator;
240  m_editStepY->setValidator (m_validatorStepY);
241  connect (m_editStepY, SIGNAL (textChanged (const QString &)), this, SLOT (slotStepY (const QString &)));
242  layoutGroup->addWidget (m_editStepY, 3, 1);
243 
244  QLabel *labelStop = new QLabel (tr ("Stop:"));
245  layoutGroup->addWidget (labelStop, 4, 0);
246 
247  m_editStopY = new QLineEdit;
248  m_editStopY->setWhatsThis (tr ("Value of the last Y grid line.\n\n"
249  "The stop value cannot be less than the start value"));
250  m_validatorStopY = new QDoubleValidator;
251  m_editStopY->setValidator (m_validatorStopY);
252  connect (m_editStopY, SIGNAL (textChanged (const QString &)), this, SLOT (slotStopY (const QString &)));
253  layoutGroup->addWidget (m_editStopY, 4, 1);
254 }
255 
257 {
258  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createSubPanel";
259 
260  const int COLUMN_CHECKBOX_WIDTH = 60;
261 
262  QWidget *subPanel = new QWidget ();
263  QGridLayout *layout = new QGridLayout (subPanel);
264  subPanel->setLayout (layout);
265 
266  layout->setColumnStretch(0, 1); // Empty first column
267  layout->setColumnStretch(1, 0); // Checkbox part of "section" checkboxes. In other rows this has empty space as indentation
268  layout->setColumnMinimumWidth(1, COLUMN_CHECKBOX_WIDTH);
269  layout->setColumnStretch(2, 0); // X
270  layout->setColumnStretch(3, 0); // Y
271  layout->setColumnStretch(4, 1); // Empty last column
272 
273  int row = 0;
274  createRemoveGridLines (layout, row);
275  createPreview (layout, row);
276 
277  return subPanel;
278 }
279 
281 {
282  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::handleOk";
283 
284  // Set the stable flag
285  m_modelGridRemovalAfter->setStable ();
286 
288  cmdMediator ().document(),
289  *m_modelGridRemovalBefore,
290  *m_modelGridRemovalAfter);
291  cmdMediator ().push (cmd);
292 
293  hide ();
294 }
295 
297 {
298  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::load";
299 
300  setCmdMediator (cmdMediator);
301 
302  // Flush old data
303  if (m_modelGridRemovalBefore != 0) {
304  delete m_modelGridRemovalBefore;
305  }
306  if (m_modelGridRemovalAfter != 0) {
307  delete m_modelGridRemovalAfter;
308  }
309 
310  // Save new data
311  m_modelGridRemovalBefore = new DocumentModelGridRemoval (cmdMediator.document());
312  m_modelGridRemovalAfter = new DocumentModelGridRemoval (cmdMediator.document());
313 
314  // Sanity checks. Incoming defaults must be acceptable to the local limits
315  ENGAUGE_ASSERT (CLOSE_DISTANCE_MIN <= m_modelGridRemovalAfter->closeDistance());
316  ENGAUGE_ASSERT (CLOSE_DISTANCE_MAX >= m_modelGridRemovalAfter->closeDistance());
317 
318  // Populate controls
319  m_chkRemoveGridLines->setChecked (m_modelGridRemovalAfter->removeDefinedGridLines());
320 
321  m_editCloseDistance->setText (QString::number (m_modelGridRemovalAfter->closeDistance()));
322 
323  int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableX()));
324  m_cmbDisableX->setCurrentIndex (indexDisableX);
325 
326  m_editCountX->setText(QString::number(m_modelGridRemovalAfter->countX()));
327  m_editStartX->setText(QString::number(m_modelGridRemovalAfter->startX()));
328  m_editStepX->setText(QString::number(m_modelGridRemovalAfter->stepX()));
329  m_editStopX->setText(QString::number(m_modelGridRemovalAfter->stopX()));
330 
331  int indexDisableY = m_cmbDisableX->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableY()));
332  m_cmbDisableY->setCurrentIndex (indexDisableY);
333 
334  m_editCountY->setText(QString::number(m_modelGridRemovalAfter->countY()));
335  m_editStartY->setText(QString::number(m_modelGridRemovalAfter->startY()));
336  m_editStepY->setText(QString::number(m_modelGridRemovalAfter->stepY()));
337  m_editStopY->setText(QString::number(m_modelGridRemovalAfter->stopY()));
338 
339  m_scenePreview->clear();
340  m_scenePreview->addPixmap (cmdMediator.document().pixmap());
341 
342  updateControls ();
343  enableOk (false); // Disable Ok button since there not yet any changes
344  updatePreview();
345 }
346 
347 void DlgSettingsGridRemoval::slotCloseDistance(const QString &)
348 {
349  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotCloseDistance";
350 
351  m_modelGridRemovalAfter->setCloseDistance(m_editCloseDistance->text().toDouble());
352  updateControls ();
353  updatePreview();
354 }
355 
356 void DlgSettingsGridRemoval::slotCountX(const QString &count)
357 {
358  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotCountX";
359 
360  m_modelGridRemovalAfter->setCountX(count.toInt());
361  updateControls ();
362  updatePreview();
363 }
364 
365 void DlgSettingsGridRemoval::slotCountY(const QString &count)
366 {
367  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotCountY";
368 
369  m_modelGridRemovalAfter->setCountY(count.toInt());
370  updateControls ();
371  updatePreview();
372 }
373 
374 void DlgSettingsGridRemoval::slotDisableX(const QString &)
375 {
376  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotDisableX";
377 
378  GridCoordDisable gridCoordDisable = (GridCoordDisable) m_cmbDisableX->currentData().toInt();
379  m_modelGridRemovalAfter->setGridCoordDisableX(gridCoordDisable);
380  updateControls();
381  updatePreview();
382 }
383 
384 void DlgSettingsGridRemoval::slotDisableY(const QString &)
385 {
386  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotDisableY";
387 
388  GridCoordDisable gridCoordDisable = (GridCoordDisable) m_cmbDisableY->currentData().toInt();
389  m_modelGridRemovalAfter->setGridCoordDisableY(gridCoordDisable);
390  updateControls();
391  updatePreview();
392 }
393 
394 void DlgSettingsGridRemoval::slotRemoveGridLines (int state)
395 {
396  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotRemoveGridLines";
397 
398  m_modelGridRemovalAfter->setRemoveDefinedGridLines(state == Qt::Checked);
399  updateControls();
400  updatePreview();
401 }
402 
403 void DlgSettingsGridRemoval::slotStartX(const QString &startX)
404 {
405  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStartX";
406 
407  m_modelGridRemovalAfter->setStartX(startX.toDouble());
408  updateControls();
409  updatePreview();
410 }
411 
412 void DlgSettingsGridRemoval::slotStartY(const QString &startY)
413 {
414  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStartY";
415 
416  m_modelGridRemovalAfter->setStartY(startY.toDouble());
417  updateControls();
418  updatePreview();
419 }
420 
421 void DlgSettingsGridRemoval::slotStepX(const QString &stepX)
422 {
423  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStepX";
424 
425  m_modelGridRemovalAfter->setStepX(stepX.toDouble());
426  updateControls();
427  updatePreview();
428 }
429 
430 void DlgSettingsGridRemoval::slotStepY(const QString &stepY)
431 {
432  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStepY";
433 
434  m_modelGridRemovalAfter->setStepY(stepY.toDouble());
435  updateControls();
436  updatePreview();
437 }
438 
439 void DlgSettingsGridRemoval::slotStopX(const QString &stopX)
440 {
441  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStopX";
442 
443  m_modelGridRemovalAfter->setStopX(stopX.toDouble());
444  updateControls();
445  updatePreview();
446 }
447 
448 void DlgSettingsGridRemoval::slotStopY(const QString &stopY)
449 {
450  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStopY";
451 
452  m_modelGridRemovalAfter->setStopY(stopY.toDouble());
453  updateControls();
454  updatePreview();
455 }
456 
457 void DlgSettingsGridRemoval::updateControls ()
458 {
459  m_editCloseDistance->setEnabled (m_chkRemoveGridLines->isChecked ());
460 
461  m_cmbDisableX->setEnabled (m_chkRemoveGridLines->isChecked ());
462 
463  GridCoordDisable disableX = (GridCoordDisable) m_cmbDisableX->currentData().toInt();
464  m_editCountX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_COUNT));
465  m_editStartX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_START));
466  m_editStepX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_STEP));
467  m_editStopX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_STOP));
468 
469  m_cmbDisableY->setEnabled (m_chkRemoveGridLines->isChecked ());
470 
471  GridCoordDisable disableY = (GridCoordDisable) m_cmbDisableY->currentData().toInt();
472  m_editCountY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_COUNT));
473  m_editStartY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_START));
474  m_editStepY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_STEP));
475  m_editStopY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_STOP));
476 
477  QString textCloseDistance = m_editCloseDistance->text();
478  QString textCountX = m_editCountX->text();
479  QString textStartX = m_editStartX->text();
480  QString textStepX = m_editStepX->text();
481  QString textStopX = m_editStopX->text();
482  QString textCountY = m_editCountY->text();
483  QString textStartY = m_editStartY->text();
484  QString textStepY = m_editStepY->text();
485  QString textStopY = m_editStopY->text();
486 
487  int pos;
488  bool isOk = (m_validatorCloseDistance->validate (textCloseDistance, pos) == QValidator::Acceptable) &&
489  (m_validatorCountX->validate (textCountX, pos) == QValidator::Acceptable) &&
490  (m_validatorStartX->validate (textStartX, pos) == QValidator::Acceptable) &&
491  (m_validatorStepX->validate (textStepX, pos) == QValidator::Acceptable) &&
492  (m_validatorStopX->validate (textStopX, pos) == QValidator::Acceptable) &&
493  (m_validatorCountY->validate (textCountY, pos) == QValidator::Acceptable) &&
494  (m_validatorStartY->validate (textStartY, pos) == QValidator::Acceptable) &&
495  (m_validatorStepY->validate (textStepY, pos) == QValidator::Acceptable) &&
496  (m_validatorStopY->validate (textStopY, pos) == QValidator::Acceptable);
497  enableOk (isOk);
498 }
499 
500 void DlgSettingsGridRemoval::updatePreview ()
501 {
502 
503 }
double closeDistance() const
Get method for close distance.
bool removeDefinedGridLines() const
Get method for removing defined grid lines.
void setCloseDistance(double closeDistance)
Set method for close distance.
double startY() const
Get method for y start.
void setCountX(int countX)
Set method for x count.
void setStopY(double stopY)
Set method for y stop.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void setStartY(double startY)
Set method for y start.
GridCoordDisable gridCoordDisableX() const
Get method for x coord parameter to disable.
void setStepY(double stepY)
Set method for y step.
QPixmap pixmap() const
Return the image that is being digitized.
Definition: Document.cpp:681
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
double stepY() const
Get method for y step.
GridCoordDisable gridCoordDisableY() const
Get method for y coord parameter to disable.
void setStartX(double startX)
Set method for x start.
virtual void handleOk()
Process slotOk.
void setCountY(int countY)
Set method for y count.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
DlgSettingsGridRemoval(MainWindow &mainWindow)
Single constructor.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
Definition: ViewPreview.h:14
void setStepX(double stepX)
Set method for x step.
double stopX() const
Get method for x stop.
void setRemoveDefinedGridLines(bool removeDefinedGridLines)
Set method for removing defined grid lines.
double startX() const
Get method for x start.
double stopY() const
Get method for y stop.
void setGridCoordDisableY(GridCoordDisable gridCoordDisable)
Set method for y coord parameter to disable.
Command for DlgSettingsGridRemoval.
void setGridCoordDisableX(GridCoordDisable gridCoordDisable)
Set method for x coord parameter to disable.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
int countX() const
Get method for x count.
int countY() const
Get method for y count.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
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 enableOk(bool enable)
Let leaf subclass control the Ok button.
Command queue stack.
Definition: CmdMediator.h:23
Abstract base class for all Settings dialogs.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:77
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void setStopX(double stopX)
Set method for x stop.