Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgSettingsGridRemoval.cpp
Go to the documentation of this file.
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 "ButtonWhatsThis.h"
8#include "CmdMediator.h"
11#include "EngaugeAssert.h"
12#include "GridInitializer.h"
13#include "GridRemoval.h"
14#include "Logger.h"
15#include "MainWindow.h"
16#include <QCheckBox>
17#include <QComboBox>
18#include <QDoubleValidator>
19#include <QGraphicsScene>
20#include <QGridLayout>
21#include <QGroupBox>
22#include <QHBoxLayout>
23#include <QLabel>
24#include <QLineEdit>
25#include <QPixmap>
26#include <QWhatsThis>
27#include "ViewPreview.h"
28
29const double CLOSE_DISTANCE_MAX = 64;
30const double CLOSE_DISTANCE_MIN = 0;
31const int CLOSE_DECIMALS = 1;
32const int COUNT_MIN = 1;
33const int COUNT_MAX = 100;
34const int COUNT_DECIMALS = 0;
35const int MINIMUM_HEIGHT = 520;
36
38 DlgSettingsAbstractBase (tr ("Grid Removal"),
39 "DlgSettingsGridRemoval",
41 m_validatorCloseDistance (nullptr),
42 m_validatorCountX (nullptr),
43 m_validatorStartX (nullptr),
44 m_validatorStepX (nullptr),
45 m_validatorStopX (nullptr),
46 m_validatorCountY (nullptr),
47 m_validatorStartY (nullptr),
48 m_validatorStepY (nullptr),
49 m_validatorStopY (nullptr),
50 m_scenePreview (nullptr),
51 m_viewPreview (nullptr),
52 m_modelGridRemovalBefore (nullptr),
53 m_modelGridRemovalAfter (nullptr)
54{
55 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::DlgSettingsGridRemoval";
56
57 QWidget *subPanel = createSubPanel ();
58 finishPanel (subPanel);
59}
60
62{
63 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::~DlgSettingsGridRemoval";
64
65 delete m_validatorCloseDistance;
66 delete m_validatorCountX;
67 delete m_validatorStartX;
68 delete m_validatorStepX;
69 delete m_validatorStopX;
70 delete m_validatorCountY;
71 delete m_validatorStartY;
72 delete m_validatorStepY;
73 delete m_validatorStopY;
74}
75
77{
78}
79
80void DlgSettingsGridRemoval::createPreview (QGridLayout *layout, int &row)
81{
82 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createPreview";
83
84 QLabel *labelPreview = new QLabel (tr ("Preview"));
85 layout->addWidget (labelPreview, row++, 0, 1, 5);
86
87 m_scenePreview = new QGraphicsScene (this);
88 m_viewPreview = new ViewPreview (m_scenePreview,
90 this);
91 m_viewPreview->setWhatsThis (tr ("Preview window that shows how current settings affect grid removal"));
92 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
93 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
94 m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
95 layout->addWidget (m_viewPreview, row++, 0, 1, 5);
96}
97
98void DlgSettingsGridRemoval::createRemoveGridLines (QGridLayout *layout, int &row)
99{
100 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createRemoveGridLines";
101
102 m_chkRemoveGridLines = new QCheckBox (tr ("Remove pixels close to defined grid lines"));
103 m_chkRemoveGridLines->setWhatsThis (tr ("Check this box to have pixels close to regularly spaced gridlines removed.\n\n"
104 "This option is only available when the axis points have all been defined."));
105 connect (m_chkRemoveGridLines, SIGNAL (stateChanged (int)), this, SLOT (slotRemoveGridLines (int)));
106 layout->addWidget (m_chkRemoveGridLines, row++, 1, 1, 3);
107
108 QLabel *labelCloseDistance = new QLabel (QString ("%1:").arg (tr ("Close distance (pixels)")));
109 layout->addWidget (labelCloseDistance, row, 2);
110
111 m_editCloseDistance = new QLineEdit;
112 m_editCloseDistance->setWhatsThis (tr ("Set closeness distance in pixels.\n\n"
113 "Pixels that are closer to the regularly spaced gridlines, than this distance, "
114 "will be removed.\n\n"
115 "This value cannot be negative. A zero value disables this feature. Decimal values are allowed"));
116 m_validatorCloseDistance = new QDoubleValidator (CLOSE_DISTANCE_MIN, CLOSE_DISTANCE_MAX, CLOSE_DECIMALS);
117 m_editCloseDistance->setValidator (m_validatorCloseDistance);
118 connect (m_editCloseDistance, SIGNAL (textChanged (const QString &)), this, SLOT (slotCloseDistance (const QString &)));
119 layout->addWidget (m_editCloseDistance, row++, 3);
120
121 createRemoveGridLinesX (layout, row);
122 createRemoveGridLinesY (layout, row);
123}
124
125void DlgSettingsGridRemoval::createRemoveGridLinesX (QGridLayout *layout, int &row)
126{
127 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createRemoveGridLinesX";
128
129 QString titleX = tr ("X Grid Lines");
130 if (false) {
131 titleX = QString (QChar (0x98, 0x03)) + QString (" %1").arg (tr ("Grid Lines"));
132 }
133 QGroupBox *groupX = new QGroupBox (titleX);
134 layout->addWidget (groupX, row, 2);
135
136 QGridLayout *layoutGroup = new QGridLayout;
137 groupX->setLayout (layoutGroup);
138
139 QLabel *labelDisable = new QLabel (QString ("%1:").arg (tr ("Disable")));
140 layoutGroup->addWidget (labelDisable, 0, 0);
141
142 m_cmbDisableX = new QComboBox;
143 m_cmbDisableX->setWhatsThis (tr ("Disabled value.\n\n"
144 "The X grid lines are specified using only three values at a time. For flexibility, four values "
145 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
146 "updated as the other values change"));
147 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
148 QVariant (GRID_COORD_DISABLE_COUNT));
149 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
150 QVariant (GRID_COORD_DISABLE_START));
151 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
152 QVariant (GRID_COORD_DISABLE_STEP));
153 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
154 QVariant (GRID_COORD_DISABLE_STOP));
155 connect (m_cmbDisableX, SIGNAL (activated (const QString &)), this, SLOT (slotDisableX (const QString &))); // activated() ignores code changes
156 layoutGroup->addWidget (m_cmbDisableX, 0, 1);
157
158 QLabel *labelCount = new QLabel (QString ("%1:").arg (tr ("Count")));
159 layoutGroup->addWidget (labelCount, 1, 0);
160
161 m_editCountX = new QLineEdit;
162 m_editCountX->setWhatsThis (tr ("Number of X grid lines.\n\n"
163 "The number of X grid lines must be entered as an integer greater than zero"));
164 m_validatorCountX = new QDoubleValidator (COUNT_MIN, COUNT_MAX, COUNT_DECIMALS);
165 m_editCountX->setValidator (m_validatorCountX);
166 connect (m_editCountX, SIGNAL (textChanged (const QString &)), this, SLOT (slotCountX (const QString &)));
167 layoutGroup->addWidget (m_editCountX, 1, 1);
168
169 QLabel *labelStart = new QLabel (QString ("%1:").arg (tr ("Start")));
170 layoutGroup->addWidget (labelStart, 2, 0);
171
172 m_editStartX = new QLineEdit;
173 m_editStartX->setWhatsThis (tr ("Value of the first X grid line.\n\n"
174 "The start value cannot be greater than the stop value"));
175 m_validatorStartX = new QDoubleValidator;
176 m_editStartX->setValidator (m_validatorStartX);
177 connect (m_editStartX, SIGNAL (textChanged (const QString &)), this, SLOT (slotStartX (const QString &)));
178 layoutGroup->addWidget (m_editStartX, 2, 1);
179
180 QLabel *labelStep = new QLabel (QString ("%1:").arg (tr ("Step")));
181 layoutGroup->addWidget (labelStep, 3, 0);
182
183 m_editStepX = new QLineEdit;
184 m_editStepX->setWhatsThis (tr ("Difference in value between two successive X grid lines.\n\n"
185 "The step value must be greater than zero (linear) or one (log)"));
186 m_validatorStepX = new QDoubleValidator;
187 m_editStepX->setValidator (m_validatorStepX);
188 connect (m_editStepX, SIGNAL (textChanged (const QString &)), this, SLOT (slotStepX (const QString &)));
189 layoutGroup->addWidget (m_editStepX, 3, 1);
190
191 QLabel *labelStop = new QLabel (QString ("%1:").arg (tr ("Stop")));
192 layoutGroup->addWidget (labelStop, 4, 0);
193
194 m_editStopX = new QLineEdit;
195 m_editStopX->setWhatsThis (tr ("Value of the last X grid line.\n\n"
196 "The stop value cannot be less than the start value"));
197 m_validatorStopX = new QDoubleValidator;
198 m_editStopX->setValidator (m_validatorStopX);
199 connect (m_editStopX, SIGNAL (textChanged (const QString &)), this, SLOT (slotStopX (const QString &)));
200 layoutGroup->addWidget (m_editStopX, 4, 1);
201}
202
203void DlgSettingsGridRemoval::createRemoveGridLinesY (QGridLayout *layout, int &row)
204{
205 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createRemoveGridLinesY";
206
207 QString titleY = tr ("Y Grid Lines");
208 if (false) {
209 titleY = QString (tr ("R Grid Lines"));
210 }
211 QGroupBox *groupY = new QGroupBox (titleY);
212 layout->addWidget (groupY, row++, 3);
213
214 QGridLayout *layoutGroup = new QGridLayout;
215 groupY->setLayout (layoutGroup);
216
217 QLabel *labelDisable = new QLabel (QString ("%1:").arg (tr ("Disable")));
218 layoutGroup->addWidget (labelDisable, 0, 0);
219
220 m_cmbDisableY = new QComboBox;
221 m_cmbDisableY->setWhatsThis (tr ("Disabled value.\n\n"
222 "The Y grid lines are specified using only three values at a time. For flexibility, four values "
223 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
224 "updated as the other values change"));
225 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
226 QVariant (GRID_COORD_DISABLE_COUNT));
227 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
228 QVariant (GRID_COORD_DISABLE_START));
229 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
230 QVariant (GRID_COORD_DISABLE_STEP));
231 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
232 QVariant (GRID_COORD_DISABLE_STOP));
233 connect (m_cmbDisableY, SIGNAL (activated (const QString &)), this, SLOT (slotDisableY (const QString &))); // activated() ignores code changes
234 layoutGroup->addWidget (m_cmbDisableY, 0, 1);
235
236 QLabel *labelCount = new QLabel (QString ("%1:").arg (tr ("Count")));
237 layoutGroup->addWidget (labelCount, 1, 0);
238
239 m_editCountY = new QLineEdit;
240 m_editCountY->setWhatsThis (tr ("Number of Y grid lines.\n\n"
241 "The number of Y grid lines must be entered as an integer greater than zero"));
242 m_validatorCountY = new QDoubleValidator (COUNT_MIN, COUNT_MAX, COUNT_DECIMALS);
243 m_editCountY->setValidator (m_validatorCountY);
244 connect (m_editCountY, SIGNAL (textChanged (const QString &)), this, SLOT (slotCountY (const QString &)));
245 layoutGroup->addWidget (m_editCountY, 1, 1);
246
247 QLabel *labelStart = new QLabel (QString ("%1:").arg (tr ("Start")));
248 layoutGroup->addWidget (labelStart, 2, 0);
249
250 m_editStartY = new QLineEdit;
251 m_editStartY->setWhatsThis (tr ("Value of the first Y grid line.\n\n"
252 "The start value cannot be greater than the stop value"));
253 m_validatorStartY = new QDoubleValidator;
254 m_editStartY->setValidator (m_validatorStartY);
255 connect (m_editStartY, SIGNAL (textChanged (const QString &)), this, SLOT (slotStartY (const QString &)));
256 layoutGroup->addWidget (m_editStartY, 2, 1);
257
258 QLabel *labelStep = new QLabel (QString ("%1:").arg (tr ("Step")));
259 layoutGroup->addWidget (labelStep, 3, 0);
260
261 m_editStepY = new QLineEdit;
262 m_editStepY->setWhatsThis (tr ("Difference in value between two successive Y grid lines.\n\n"
263 "The step value must be greater than zero (linear) or one (log)"));
264 m_validatorStepY = new QDoubleValidator;
265 m_editStepY->setValidator (m_validatorStepY);
266 connect (m_editStepY, SIGNAL (textChanged (const QString &)), this, SLOT (slotStepY (const QString &)));
267 layoutGroup->addWidget (m_editStepY, 3, 1);
268
269 QLabel *labelStop = new QLabel (QString ("%1:").arg (tr ("Stop")));
270 layoutGroup->addWidget (labelStop, 4, 0);
271
272 m_editStopY = new QLineEdit;
273 m_editStopY->setWhatsThis (tr ("Value of the last Y grid line.\n\n"
274 "The stop value cannot be less than the start value"));
275 m_validatorStopY = new QDoubleValidator;
276 m_editStopY->setValidator (m_validatorStopY);
277 connect (m_editStopY, SIGNAL (textChanged (const QString &)), this, SLOT (slotStopY (const QString &)));
278 layoutGroup->addWidget (m_editStopY, 4, 1);
279}
280
282{
283 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createSubPanel";
284
285 QWidget *subPanel = new QWidget ();
286 QGridLayout *layout = new QGridLayout (subPanel);
287 subPanel->setLayout (layout);
288
289 layout->setColumnStretch(0, 1); // Empty first column
290 layout->setColumnStretch(1, 0); // Checkbox part of "section" checkboxes. In other rows this has empty space as indentation
291 layout->setColumnStretch(2, 0); // X
292 layout->setColumnStretch(3, 0); // Y
293 layout->setColumnStretch(4, 1); // Empty last column
294
295 int row = 0;
296
297 createWhatsThis (layout,
298 m_btnWhatsThis,
299 row++,
300 4);
301
302 createRemoveGridLines (layout, row);
303 createPreview (layout, row);
304
305 return subPanel;
306}
307
309{
310 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::handleOk";
311
312 // Set the stable flag
313 m_modelGridRemovalAfter->setStable ();
314
316 cmdMediator ().document(),
317 *m_modelGridRemovalBefore,
318 *m_modelGridRemovalAfter);
319 cmdMediator ().push (cmd);
320
321 hide ();
322}
323
325{
326 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::load";
327
329
330 // Flush old data
331 delete m_modelGridRemovalBefore;
332 delete m_modelGridRemovalAfter;
333
334 // Save new data
335 m_modelGridRemovalBefore = new DocumentModelGridRemoval (cmdMediator.document());
336 m_modelGridRemovalAfter = new DocumentModelGridRemoval (cmdMediator.document());
337
338 // Sanity checks. Incoming defaults must be acceptable to the local limits
340 ENGAUGE_ASSERT (CLOSE_DISTANCE_MAX >= m_modelGridRemovalAfter->closeDistance());
341
342 // Populate controls
343 m_chkRemoveGridLines->setChecked (m_modelGridRemovalAfter->removeDefinedGridLines());
344
345 m_editCloseDistance->setText (QString::number (m_modelGridRemovalAfter->closeDistance()));
346
347 int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableX()));
348 m_cmbDisableX->setCurrentIndex (indexDisableX);
349
350 m_editCountX->setText(QString::number(m_modelGridRemovalAfter->countX()));
351 m_editStartX->setText(QString::number(m_modelGridRemovalAfter->startX()));
352 m_editStepX->setText(QString::number(m_modelGridRemovalAfter->stepX()));
353 m_editStopX->setText(QString::number(m_modelGridRemovalAfter->stopX()));
354
355 int indexDisableY = m_cmbDisableY->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableY()));
356 m_cmbDisableY->setCurrentIndex (indexDisableY);
357
358 m_editCountY->setText(QString::number(m_modelGridRemovalAfter->countY()));
359 m_editStartY->setText(QString::number(m_modelGridRemovalAfter->startY()));
360 m_editStepY->setText(QString::number(m_modelGridRemovalAfter->stepY()));
361 m_editStopY->setText(QString::number(m_modelGridRemovalAfter->stopY()));
362
363 updateControls ();
364 enableOk (false); // Disable Ok button since there not yet any changes
365 updatePreview();
366}
367
369{
370 if (!smallDialogs) {
371 setMinimumHeight (MINIMUM_HEIGHT);
372 }
373}
374
375void DlgSettingsGridRemoval::slotCloseDistance(const QString &)
376{
377 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotCloseDistance";
378
379 m_modelGridRemovalAfter->setCloseDistance(m_editCloseDistance->text().toDouble());
380 updateControls ();
381 updatePreview();
382}
383
384void DlgSettingsGridRemoval::slotCountX(const QString &count)
385{
386 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotCountX";
387
388 m_modelGridRemovalAfter->setCountX(count.toInt());
389 updateDisplayedVariableX ();
390 updateControls ();
391 updatePreview();
392}
393
394void DlgSettingsGridRemoval::slotCountY(const QString &count)
395{
396 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotCountY";
397
398 m_modelGridRemovalAfter->setCountY(count.toInt());
399 updateDisplayedVariableY ();
400 updateControls ();
401 updatePreview();
402}
403
404void DlgSettingsGridRemoval::slotDisableX(const QString &)
405{
406 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotDisableX";
407
408 GridCoordDisable gridCoordDisable = static_cast<GridCoordDisable> (m_cmbDisableX->currentData().toInt());
409 m_modelGridRemovalAfter->setGridCoordDisableX(gridCoordDisable);
410 updateDisplayedVariableX ();
411 updateControls();
412 updatePreview();
413}
414
415void DlgSettingsGridRemoval::slotDisableY(const QString &)
416{
417 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotDisableY";
418
419 GridCoordDisable gridCoordDisable = static_cast<GridCoordDisable> (m_cmbDisableY->currentData().toInt());
420 m_modelGridRemovalAfter->setGridCoordDisableY(gridCoordDisable);
421 updateDisplayedVariableY ();
422 updateControls();
423 updatePreview();
424}
425
426void DlgSettingsGridRemoval::slotRemoveGridLines (int state)
427{
428 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotRemoveGridLines";
429
430 m_modelGridRemovalAfter->setRemoveDefinedGridLines(state == Qt::Checked);
431 updateControls();
432 updatePreview();
433}
434
435void DlgSettingsGridRemoval::slotStartX(const QString &startX)
436{
437 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStartX";
438
439 m_modelGridRemovalAfter->setStartX(startX.toDouble());
440 updateDisplayedVariableX ();
441 updateControls();
442 updatePreview();
443}
444
445void DlgSettingsGridRemoval::slotStartY(const QString &startY)
446{
447 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStartY";
448
449 m_modelGridRemovalAfter->setStartY(startY.toDouble());
450 updateDisplayedVariableY ();
451 updateControls();
452 updatePreview();
453}
454
455void DlgSettingsGridRemoval::slotStepX(const QString &stepX)
456{
457 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStepX";
458
459 m_modelGridRemovalAfter->setStepX(stepX.toDouble());
460 updateDisplayedVariableX ();
461 updateControls();
462 updatePreview();
463}
464
465void DlgSettingsGridRemoval::slotStepY(const QString &stepY)
466{
467 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStepY";
468
469 m_modelGridRemovalAfter->setStepY(stepY.toDouble());
470 updateDisplayedVariableY ();
471 updateControls();
472 updatePreview();
473}
474
475void DlgSettingsGridRemoval::slotStopX(const QString &stopX)
476{
477 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStopX";
478
479 m_modelGridRemovalAfter->setStopX(stopX.toDouble());
480 updateDisplayedVariableX ();
481 updateControls();
482 updatePreview();
483}
484
485void DlgSettingsGridRemoval::slotStopY(const QString &stopY)
486{
487 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::slotStopY";
488
489 m_modelGridRemovalAfter->setStopY(stopY.toDouble());
490 updateDisplayedVariableY ();
491 updateControls();
492 updatePreview();
493}
494
495void DlgSettingsGridRemoval::slotWhatsThis ()
496{
497 QWhatsThis::enterWhatsThisMode();
498}
499
500void DlgSettingsGridRemoval::updateControls ()
501{
502 m_editCloseDistance->setEnabled (m_chkRemoveGridLines->isChecked ());
503
504 m_cmbDisableX->setEnabled (m_chkRemoveGridLines->isChecked ());
505
506 GridCoordDisable disableX = static_cast<GridCoordDisable> (m_cmbDisableX->currentData().toInt());
507 m_editCountX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_COUNT));
508 m_editStartX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_START));
509 m_editStepX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_STEP));
510 m_editStopX->setEnabled (m_chkRemoveGridLines->isChecked () && (disableX != GRID_COORD_DISABLE_STOP));
511
512 m_cmbDisableY->setEnabled (m_chkRemoveGridLines->isChecked ());
513
514 GridCoordDisable disableY = static_cast<GridCoordDisable> (m_cmbDisableY->currentData().toInt());
515 m_editCountY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_COUNT));
516 m_editStartY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_START));
517 m_editStepY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_STEP));
518 m_editStopY->setEnabled (m_chkRemoveGridLines->isChecked () && (disableY != GRID_COORD_DISABLE_STOP));
519
520 QString textCloseDistance = m_editCloseDistance->text();
521 QString textCountX = m_editCountX->text();
522 QString textStartX = m_editStartX->text();
523 QString textStepX = m_editStepX->text();
524 QString textStopX = m_editStopX->text();
525 QString textCountY = m_editCountY->text();
526 QString textStartY = m_editStartY->text();
527 QString textStepY = m_editStepY->text();
528 QString textStopY = m_editStopY->text();
529
530 int pos;
531 bool isOk = (m_validatorCloseDistance->validate (textCloseDistance, pos) == QValidator::Acceptable) &&
532 (m_validatorCountX->validate (textCountX, pos) == QValidator::Acceptable) &&
533 (m_validatorStartX->validate (textStartX, pos) == QValidator::Acceptable) &&
534 (m_validatorStepX->validate (textStepX, pos) == QValidator::Acceptable) &&
535 (m_validatorStopX->validate (textStopX, pos) == QValidator::Acceptable) &&
536 (m_validatorCountY->validate (textCountY, pos) == QValidator::Acceptable) &&
537 (m_validatorStartY->validate (textStartY, pos) == QValidator::Acceptable) &&
538 (m_validatorStepY->validate (textStepY, pos) == QValidator::Acceptable) &&
539 (m_validatorStopY->validate (textStopY, pos) == QValidator::Acceptable);
540 enableOk (isOk);
541}
542
543void DlgSettingsGridRemoval::updateDisplayedVariableX ()
544{
545 GridInitializer initializer;
546
547 bool linearAxis = (cmdMediator ().document ().modelCoords ().coordScaleXTheta() == COORD_SCALE_LINEAR);
548
549 switch (m_modelGridRemovalAfter->gridCoordDisableX()) {
551 m_editCountX->setText (QString::number (initializer.computeCount (linearAxis,
552 m_modelGridRemovalAfter->startX (),
553 m_modelGridRemovalAfter->stopX (),
554 m_modelGridRemovalAfter->stepX ())));
555 break;
556
558 m_editStartX->setText (QString::number (initializer.computeStart (linearAxis,
559 m_modelGridRemovalAfter->stopX (),
560 m_modelGridRemovalAfter->stepX (),
561 m_modelGridRemovalAfter->countX ())));
562 break;
563
565 m_editStepX->setText (QString::number (initializer.computeStep (linearAxis,
566 m_modelGridRemovalAfter->startX (),
567 m_modelGridRemovalAfter->stopX (),
568 m_modelGridRemovalAfter->countX ())));
569 break;
570
572 m_editStopX->setText (QString::number (initializer.computeStop (linearAxis,
573 m_modelGridRemovalAfter->startX (),
574 m_modelGridRemovalAfter->stepX (),
575 m_modelGridRemovalAfter->countX ())));
576 break;
577 }
578}
579
580void DlgSettingsGridRemoval::updateDisplayedVariableY ()
581{
582 GridInitializer initializer;
583
584 bool linearAxis = (cmdMediator ().document ().modelCoords ().coordScaleYRadius () == COORD_SCALE_LINEAR);
585
586 switch (m_modelGridRemovalAfter->gridCoordDisableY()) {
588 m_editCountY->setText (QString::number (initializer.computeCount (linearAxis,
589 m_modelGridRemovalAfter->startY (),
590 m_modelGridRemovalAfter->stopY (),
591 m_modelGridRemovalAfter->stepY ())));
592 break;
593
595 m_editStartY->setText (QString::number (initializer.computeStart (linearAxis,
596 m_modelGridRemovalAfter->stopY (),
597 m_modelGridRemovalAfter->stepY (),
598 m_modelGridRemovalAfter->countY ())));
599 break;
600
602 m_editStepY->setText (QString::number (initializer.computeStep (linearAxis,
603 m_modelGridRemovalAfter->startY (),
604 m_modelGridRemovalAfter->stopY (),
605 m_modelGridRemovalAfter->countY ())));
606 break;
607
609 m_editStopY->setText (QString::number (initializer.computeStop (linearAxis,
610 m_modelGridRemovalAfter->startY (),
611 m_modelGridRemovalAfter->stepY (),
612 m_modelGridRemovalAfter->countY ())));
613 break;
614 }
615}
616
617void DlgSettingsGridRemoval::updatePreview ()
618{
619 GridRemoval gridRemoval (mainWindow().isGnuplot());
620
621 QPixmap pixmap = gridRemoval.remove (mainWindow ().transformation(),
622 *m_modelGridRemovalAfter,
623 cmdMediator ().document().pixmap().toImage());
624
625 m_scenePreview->clear();
626 addPixmap (*m_scenePreview,
627 pixmap);
628}
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
const int MINIMUM_HEIGHT
const int COUNT_DECIMALS
const int COUNT_MIN
const int CLOSE_DECIMALS
const double CLOSE_DISTANCE_MIN
const double CLOSE_DISTANCE_MAX
const int COUNT_MAX
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
QString gridCoordDisableToString(GridCoordDisable gridCoordDisable)
GridCoordDisable
@ GRID_COORD_DISABLE_STOP
@ GRID_COORD_DISABLE_START
@ GRID_COORD_DISABLE_STEP
@ GRID_COORD_DISABLE_COUNT
log4cpp::Category * mainCat
Definition Logger.cpp:14
Command queue stack.
Definition CmdMediator.h:24
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Command for DlgSettingsGridRemoval.
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
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 createWhatsThis(QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
Create a WhatsThis button in a grid layout.
void addPixmap(QGraphicsScene &scene, const QPixmap &pixmap)
Adds pixmap to the scene.
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.
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.
void setCloseDistance(double closeDistance)
Set method for close distance.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:707
double computeStep(bool linearAxis, double start, double stop, int count) const
Compute axis scale step from the other axis parameters.
double computeStart(bool linearAxis, double stop, double step, int count) const
Compute axis scale start from the other axis parameters.
int computeCount(bool linearAxis, double start, double stop, double step) const
Compute axis scale count from the other axis parameters.
double computeStop(bool linearAxis, double start, double step, int count) const
Compute axis scale stop from the other axis parameters.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:95
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window,...
Definition ViewPreview.h:15
@ VIEW_ASPECT_RATIO_VARIABLE
Definition ViewPreview.h:22
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18