Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgSettingsGridDisplay.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 "CmdMediator.h"
10#include "EngaugeAssert.h"
11#include "GridInitializer.h"
12#include "GridLineFactory.h"
13#include "Logger.h"
14#include "MainWindow.h"
15#include <QCheckBox>
16#include <QComboBox>
17#include <QDoubleValidator>
18#include <QGraphicsScene>
19#include <QGridLayout>
20#include <QGroupBox>
21#include <QHBoxLayout>
22#include <QLabel>
23#include <QLineEdit>
24#include "ViewPreview.h"
25
26const int COUNT_MIN = 1;
27const int COUNT_DECIMALS = 0;
28const int MINIMUM_HEIGHT = 480;
29
31 DlgSettingsAbstractBase (tr ("Grid Display"),
32 "DlgSettingsGridDisplay",
33 mainWindow),
34 m_validatorCountX (nullptr),
35 m_validatorStartX (nullptr),
36 m_validatorStepX (nullptr),
37 m_validatorStopX (nullptr),
38 m_validatorCountY (nullptr),
39 m_validatorStartY (nullptr),
40 m_validatorStepY (nullptr),
41 m_validatorStopY (nullptr),
42 m_scenePreview (nullptr),
43 m_viewPreview (nullptr),
44 m_modelGridDisplayBefore (nullptr),
45 m_modelGridDisplayAfter (nullptr)
46{
47 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::DlgSettingsGridDisplay";
48
51}
52
54{
55 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::~DlgSettingsGridDisplay";
56
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;
65}
66
67void DlgSettingsGridDisplay::createDisplayCommon (QGridLayout *layout, int &row)
68{
69 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createDisplayCommon";
70
72 layout->addWidget (widgetCommon, row++, 2, 1, 2);
73
75 widgetCommon->setLayout (layoutCommon);
76 int rowCommon = 0;
77
78 m_labelLimitWarning = new QLabel;
79 m_labelLimitWarning->setStyleSheet ("QLabel { color: red; }");
80 layoutCommon->addWidget (m_labelLimitWarning, rowCommon++, 0, 1, 4, Qt::AlignCenter);
81
82 QLabel *labelColor = new QLabel (QString ("%1:").arg (tr ("Color")));
83 layoutCommon->addWidget (labelColor, rowCommon, 1);
84
85 m_cmbColor = new QComboBox;
86 m_cmbColor->setWhatsThis (tr ("Select a color for the lines"));
88 connect (m_cmbColor, SIGNAL (activated (const QString &)), this, SLOT (slotColor (const QString &))); // activated() ignores code changes
89 layoutCommon->addWidget (m_cmbColor, rowCommon++, 2);
90
91 // Make sure there is an empty column, for padding, on the left and right sides
92 layoutCommon->setColumnStretch (0, 1);
93 layoutCommon->setColumnStretch (1, 0);
94 layoutCommon->setColumnStretch (2, 0);
95 layoutCommon->setColumnStretch (3, 1);
96}
97
98void DlgSettingsGridDisplay::createDisplayGridLinesX (QGridLayout *layout, int &row)
99{
100 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createDisplayGridLinesX";
101
102 m_groupX = new QGroupBox; // Text is added at load time at which point current context is known
103 layout->addWidget (m_groupX, row, 2);
104
106 m_groupX->setLayout (layoutGroup);
107
108 QLabel *labelDisable = new QLabel (QString ("%1:").arg (tr ("Disable")));
109 layoutGroup->addWidget (labelDisable, 0, 0);
110
111 m_cmbDisableX = new QComboBox;
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"));
116 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
118 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
120 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
122 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
124 connect (m_cmbDisableX, SIGNAL (activated (const QString &)), this, SLOT (slotDisableX (const QString &))); // activated() ignores code changes
125 layoutGroup->addWidget (m_cmbDisableX, 0, 1);
126
127 QLabel *labelCount = new QLabel (QString ("%1:").arg (tr ("Count")));
128 layoutGroup->addWidget (labelCount, 1, 0);
129
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);
135 m_validatorCountX->setDecimals (COUNT_DECIMALS);
136 m_editCountX->setValidator (m_validatorCountX);
137 connect (m_editCountX, SIGNAL (textEdited (const QString &)), this, SLOT (slotCountX (const QString &)));
138 layoutGroup->addWidget (m_editCountX, 1, 1);
139
140 QLabel *labelStart = new QLabel (QString ("%1:").arg (tr ("Start")));
141 layoutGroup->addWidget (labelStart, 2, 0);
142
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);
148 connect (m_editStartX, SIGNAL (textEdited (const QString &)), this, SLOT (slotStartX (const QString &)));
149 layoutGroup->addWidget (m_editStartX, 2, 1);
150
151 QLabel *labelStep = new QLabel (QString ("%1:").arg (tr ("Step")));
152 layoutGroup->addWidget (labelStep, 3, 0);
153
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);
159 connect (m_editStepX, SIGNAL (textEdited (const QString &)), this, SLOT (slotStepX (const QString &)));
160 layoutGroup->addWidget (m_editStepX, 3, 1);
161
162 QLabel *labelStop = new QLabel (QString ("%1:").arg (tr ("Stop")));
163 layoutGroup->addWidget (labelStop, 4, 0);
164
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);
170 connect (m_editStopX, SIGNAL (textEdited (const QString &)), this, SLOT (slotStopX (const QString &)));
171 layoutGroup->addWidget (m_editStopX, 4, 1);
172}
173
174void DlgSettingsGridDisplay::createDisplayGridLinesY (QGridLayout *layout, int &row)
175{
176 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createDisplayGridLinesY";
177
178 m_groupY = new QGroupBox; // Text is added at load time at which point current context is known
179 layout->addWidget (m_groupY, row++, 3);
180
182 m_groupY->setLayout (layoutGroup);
183
184 QLabel *labelDisable = new QLabel (QString ("%1:").arg (tr ("Disable")));
185 layoutGroup->addWidget (labelDisable, 0, 0);
186
187 m_cmbDisableY = new QComboBox;
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"));
192 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
194 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
196 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
198 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
200 connect (m_cmbDisableY, SIGNAL (activated (const QString &)), this, SLOT (slotDisableY (const QString &))); // activated() ignores code changes
201 layoutGroup->addWidget (m_cmbDisableY, 0, 1);
202
203 QLabel *labelCount = new QLabel (QString ("%1:").arg (tr ("Count")));
204 layoutGroup->addWidget (labelCount, 1, 0);
205
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);
211 m_validatorCountY->setDecimals (COUNT_DECIMALS);
212 m_editCountY->setValidator (m_validatorCountY);
213 connect (m_editCountY, SIGNAL (textEdited (const QString &)), this, SLOT (slotCountY (const QString &)));
214 layoutGroup->addWidget (m_editCountY, 1, 1);
215
216 QLabel *labelStart = new QLabel (QString ("%1:").arg (tr ("Start")));
217 layoutGroup->addWidget (labelStart, 2, 0);
218
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);
224 connect (m_editStartY, SIGNAL (textEdited (const QString &)), this, SLOT (slotStartY (const QString &)));
225 layoutGroup->addWidget (m_editStartY, 2, 1);
226
227 QLabel *labelStep = new QLabel (QString ("%1:").arg (tr ("Step")));
228 layoutGroup->addWidget (labelStep, 3, 0);
229
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);
235 connect (m_editStepY, SIGNAL (textEdited (const QString &)), this, SLOT (slotStepY (const QString &)));
236 layoutGroup->addWidget (m_editStepY, 3, 1);
237
238 QLabel *labelStop = new QLabel (QString ("%1:").arg (tr ("Stop")));
239 layoutGroup->addWidget (labelStop, 4, 0);
240
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);
246 connect (m_editStopY, SIGNAL (textEdited (const QString &)), this, SLOT (slotStopY (const QString &)));
247 layoutGroup->addWidget (m_editStopY, 4, 1);
248}
249
253
254void DlgSettingsGridDisplay::createPreview (QGridLayout *layout, int &row)
255{
256 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createPreview";
257
258 QLabel *labelPreview = new QLabel (tr ("Preview"));
259 layout->addWidget (labelPreview, row++, 0, 1, 5);
260
261 m_scenePreview = new QGraphicsScene (this);
262 m_viewPreview = new ViewPreview (m_scenePreview,
264 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);
268 m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
269 layout->addWidget (m_viewPreview, row++, 0, 1, 5);
270}
271
273{
274 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createSubPanel";
275
276 QWidget *subPanel = new QWidget ();
278 subPanel->setLayout (layout);
279
280 layout->setColumnStretch(0, 1); // Empty first column
281 layout->setColumnStretch(1, 0); // Checkbox part of "section" checkboxes. In other rows this has empty space as indentation
282 layout->setColumnStretch(2, 0); // X
283 layout->setColumnStretch(3, 0); // Y
284 layout->setColumnStretch(4, 1); // Empty last column
285
286 int row = 0;
287 createDisplayGridLinesX (layout, row);
288 createDisplayGridLinesY (layout, row);
289 createDisplayCommon (layout, row);
290 createPreview (layout, row);
291
292 return subPanel;
293}
294
296{
297 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::handleOk";
298
299 // Set the stable flag
300 m_modelGridDisplayAfter->setStable (true);
301
303 cmdMediator ().document(),
304 *m_modelGridDisplayBefore,
305 *m_modelGridDisplayAfter);
306 cmdMediator ().push (cmd);
307
308 hide ();
309}
310
312{
313 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::load";
314
316
317 // Flush old data
318 delete m_modelGridDisplayBefore;
319 delete m_modelGridDisplayAfter;
320
321 // Display cartesian or polar headers as appropriate
322 QString titleX = tr ("X Grid Lines");
324 titleX = QString (QChar (0x98, 0x03)) + QString (" %1").arg (tr ("Grid Lines"));
325 }
326 m_groupX->setTitle (titleX);
327
328 QString titleY = tr ("Y Grid Lines");
330 titleY = QString (tr ("Radius Grid Lines"));
331 }
332 m_groupY->setTitle (titleY);
333
334 // Save new data
335 m_modelGridDisplayBefore = new DocumentModelGridDisplay (cmdMediator.document());
336 m_modelGridDisplayAfter = new DocumentModelGridDisplay (cmdMediator.document());
337
338 // Populate controls
339 int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridDisplayAfter->disableX()));
340 m_cmbDisableX->setCurrentIndex (indexDisableX);
341
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()));
346
347 int indexDisableY = m_cmbDisableY->findData (QVariant (m_modelGridDisplayAfter->disableY()));
348 m_cmbDisableY->setCurrentIndex (indexDisableY);
349
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()));
354
355 int indexColor = m_cmbColor->findData(QVariant(m_modelGridDisplayAfter->paletteColor()));
357 m_cmbColor->setCurrentIndex(indexColor);
358
359 m_scenePreview->addPixmap (cmdMediator.document().pixmap());
360
361 updateControls ();
362 enableOk (false); // Disable Ok button since there not yet any changes
363 updatePreview();
364}
365
367{
368 if (!smallDialogs) {
370 }
371}
372
373void DlgSettingsGridDisplay::slotColor (QString const &)
374{
375 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotColor";
376
377 m_modelGridDisplayAfter->setPaletteColor(static_cast<ColorPalette> (m_cmbColor->currentData().toInt()));
378 updateControls();
379 updatePreview();
380}
381
382void DlgSettingsGridDisplay::slotCountX(const QString &count)
383{
384 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotCountX";
385
386 m_modelGridDisplayAfter->setCountX(unsigned (count.toInt()));
387 updateDisplayedVariableX ();
388 updateControls ();
389 updatePreview();
390}
391
392void DlgSettingsGridDisplay::slotCountY(const QString &count)
393{
394 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotCountY";
395
396 m_modelGridDisplayAfter->setCountY(unsigned (count.toInt()));
397 updateDisplayedVariableY ();
398 updateControls ();
399 updatePreview();
400}
401
402void DlgSettingsGridDisplay::slotDisableX(const QString &)
403{
404 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotDisableX";
405
406 GridCoordDisable gridCoordDisable = static_cast<GridCoordDisable> (m_cmbDisableX->currentData().toInt());
407 m_modelGridDisplayAfter->setDisableX(gridCoordDisable);
408 updateDisplayedVariableX ();
409 updateControls();
410 updatePreview();
411}
412
413void DlgSettingsGridDisplay::slotDisableY(const QString &)
414{
415 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotDisableY";
416
417 GridCoordDisable gridCoordDisable = static_cast<GridCoordDisable> (m_cmbDisableY->currentData().toInt());
418 m_modelGridDisplayAfter->setDisableY(gridCoordDisable);
419 updateDisplayedVariableY ();
420 updateControls();
421 updatePreview();
422}
423
424void DlgSettingsGridDisplay::slotStartX(const QString &startX)
425{
426 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStartX";
427
428 m_modelGridDisplayAfter->setStartX(startX.toDouble());
429 updateDisplayedVariableX ();
430 updateControls();
431 updatePreview();
432}
433
434void DlgSettingsGridDisplay::slotStartY(const QString &startY)
435{
436 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStartY";
437
438 m_modelGridDisplayAfter->setStartY(startY.toDouble());
439 updateDisplayedVariableY ();
440 updateControls();
441 updatePreview();
442}
443
444void DlgSettingsGridDisplay::slotStepX(const QString &stepX)
445{
446 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStepX";
447
448 m_modelGridDisplayAfter->setStepX(stepX.toDouble());
449 updateDisplayedVariableX ();
450 updateControls();
451 updatePreview();
452}
453
454void DlgSettingsGridDisplay::slotStepY(const QString &stepY)
455{
456 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStepY";
457
458 m_modelGridDisplayAfter->setStepY(stepY.toDouble());
459 updateDisplayedVariableY ();
460 updateControls();
461 updatePreview();
462}
463
464void DlgSettingsGridDisplay::slotStopX(const QString &stopX)
465{
466 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStopX";
467
468 m_modelGridDisplayAfter->setStopX(stopX.toDouble());
469 updateDisplayedVariableX ();
470 updateControls();
471 updatePreview();
472}
473
474void DlgSettingsGridDisplay::slotStopY(const QString &stopY)
475{
476 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStopY";
477
478 m_modelGridDisplayAfter->setStopY(stopY.toDouble());
479 updateDisplayedVariableY ();
480 updateControls();
481 updatePreview();
482}
483
484bool DlgSettingsGridDisplay::textItemsAreValid () const
485{
486 QString textCountX = m_editCountX->text();
487 QString textCountY = m_editCountY->text();
488 QString textStartX = m_editStartX->text();
489 QString textStartY = m_editStartY->text();
490 QString textStepX = m_editStepX->text();
491 QString textStepY = m_editStepY->text();
492 QString textStopX = m_editStopX->text();
493 QString textStopY = m_editStopY->text();
494
495 // To prevent an infinite loop, skip if either:
496 // 1) a field is empty
497 // 2) value in a field is malformed
498 bool ok = false;
499 int pos;
500 if (
501 !textCountX.isEmpty() &&
502 !textCountY.isEmpty() &&
503 !textStartX.isEmpty() &&
504 !textStartY.isEmpty() &&
505 !textStepX.isEmpty() &&
506 !textStepY.isEmpty() &&
507 !textStopX.isEmpty() &&
508 !textStopY.isEmpty() &&
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) {
517
518 // Reject zero steps
519 double stepX = textCountX.toDouble ();
520 double stepY = textCountY.toDouble ();
521
522 if (qAbs (stepX) > 0 && qAbs (stepY) > 0) {
523
524 ok = true;
525 }
526 }
527
528 return ok;
529}
530
531bool DlgSettingsGridDisplay::textItemsDoNotBreakLineCountLimit ()
532{
533 if (textItemsAreValid ()) {
534 QString textCountX = m_editCountX->text();
535 QString textCountY = m_editCountY->text();
536 QString textStartX = m_editStartX->text();
537 QString textStartY = m_editStartY->text();
538 QString textStepX = m_editStepX->text();
539 QString textStepY = m_editStepY->text();
540 QString textStopX = m_editStopX->text();
541 QString textStopY = m_editStopY->text();
542
543 // Given that text fields have good values, now compare grid line counts to limit
545
548
549 int countX = textCountX.toInt ();
550 if (m_modelGridDisplayAfter->disableX() == GRID_COORD_DISABLE_COUNT) {
552 textStartX.toDouble (),
553 textStopX.toDouble (),
554 textStepX.toDouble ());
555 }
556 int countY = textCountY.toInt ();
557 if (m_modelGridDisplayAfter->disableY() == GRID_COORD_DISABLE_COUNT) {
558 countY = initializer.computeCount (linearAxisYRadius,
559 textStartY.toDouble (),
560 textStopY.toDouble (),
561 textStepY.toDouble ());
562 }
563
564 return (countX <= mainWindow ().modelMainWindow ().maximumGridLines() &&
566 }
567
568 return true;
569}
570
571void DlgSettingsGridDisplay::updateControls ()
572{
573 GridCoordDisable disableX = static_cast<GridCoordDisable> (m_cmbDisableX->currentData().toInt());
574 m_editCountX->setEnabled (disableX != GRID_COORD_DISABLE_COUNT);
575 m_editStartX->setEnabled (disableX != GRID_COORD_DISABLE_START);
576 m_editStepX->setEnabled (disableX != GRID_COORD_DISABLE_STEP);
577 m_editStopX->setEnabled (disableX != GRID_COORD_DISABLE_STOP);
578
579 GridCoordDisable disableY = static_cast<GridCoordDisable> (m_cmbDisableY->currentData().toInt());
580 m_editCountY->setEnabled (disableY != GRID_COORD_DISABLE_COUNT);
581 m_editStartY->setEnabled (disableY != GRID_COORD_DISABLE_START);
582 m_editStepY->setEnabled (disableY != GRID_COORD_DISABLE_STEP);
583 m_editStopY->setEnabled (disableY != GRID_COORD_DISABLE_STOP);
584
585 if (textItemsDoNotBreakLineCountLimit ()) {
586 m_labelLimitWarning->setText ("");
587 } else {
588 m_labelLimitWarning->setText (tr ("Grid line count exceeds limit set by Settings / Main Window."));
589 }
590
591 enableOk (textItemsAreValid () && textItemsDoNotBreakLineCountLimit ());
592}
593
594void DlgSettingsGridDisplay::updateDisplayedVariableX ()
595{
597
599
600 switch (m_modelGridDisplayAfter->disableX()) {
602 m_editCountX->setText (QString::number (initializer.computeCount (linearAxis,
603 m_modelGridDisplayAfter->startX (),
604 m_modelGridDisplayAfter->stopX (),
605 m_modelGridDisplayAfter->stepX ())));
606 break;
607
609 m_editStartX->setText (QString::number (initializer.computeStart (linearAxis,
610 m_modelGridDisplayAfter->stopX (),
611 m_modelGridDisplayAfter->stepX (),
612 signed (m_modelGridDisplayAfter->countX ()))));
613 break;
614
616 m_editStepX->setText (QString::number (initializer.computeStep (linearAxis,
617 m_modelGridDisplayAfter->startX (),
618 m_modelGridDisplayAfter->stopX (),
619 signed (m_modelGridDisplayAfter->countX ()))));
620 break;
621
623 m_editStopX->setText (QString::number (initializer.computeStop (linearAxis,
624 m_modelGridDisplayAfter->startX (),
625 m_modelGridDisplayAfter->stepX (),
626 signed (m_modelGridDisplayAfter->countX ()))));
627 break;
628 }
629}
630
631void DlgSettingsGridDisplay::updateDisplayedVariableY ()
632{
634
636
637 switch (m_modelGridDisplayAfter->disableY()) {
639 m_editCountY->setText (QString::number (initializer.computeCount (linearAxis,
640 m_modelGridDisplayAfter->startY (),
641 m_modelGridDisplayAfter->stopY (),
642 m_modelGridDisplayAfter->stepY ())));
643 break;
644
646 m_editStartY->setText (QString::number (initializer.computeStart (linearAxis,
647 m_modelGridDisplayAfter->stopY (),
648 m_modelGridDisplayAfter->stepY (),
649 signed (m_modelGridDisplayAfter->countY ()))));
650 break;
651
653 m_editStepY->setText (QString::number (initializer.computeStep (linearAxis,
654 m_modelGridDisplayAfter->startY (),
655 m_modelGridDisplayAfter->stopY (),
656 signed (m_modelGridDisplayAfter->countY ()))));
657 break;
658
660 m_editStopY->setText (QString::number (initializer.computeStop (linearAxis,
661 m_modelGridDisplayAfter->startY (),
662 m_modelGridDisplayAfter->stepY (),
663 signed (m_modelGridDisplayAfter->countY ()))));
664 break;
665 }
666}
667
668void DlgSettingsGridDisplay::updatePreview ()
669{
670 m_gridLines.clear ();
671
672 if (textItemsAreValid ()) {
673
674 GridLineFactory factory (*m_scenePreview,
675 cmdMediator ().document ().modelCoords());
676
677 factory.createGridLinesForEvenlySpacedGrid (*m_modelGridDisplayAfter,
678 cmdMediator ().document (),
679 mainWindow ().modelMainWindow(),
680 mainWindow ().transformation(),
681 m_gridLines);
682 }
683}
ColorPalette
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
@ COORDS_TYPE_POLAR
Definition CoordsType.h:14
const int MINIMUM_HEIGHT
const int INNER_RADIUS_MIN
const int COUNT_DECIMALS
const int COUNT_MIN
const int MINIMUM_HEIGHT
#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)
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 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 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.
Definition Document.cpp:817
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:695
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.
Definition GridLines.cpp:24
int maximumGridLines() const
Maximum number of grid lines.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:92
MainWindowModel modelMainWindow() const
Get method for main window model.
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