00001
00002
00003
00004
00005
00006
00007 #include "CmdMediator.h"
00008 #include "CmdSettingsGridDisplay.h"
00009 #include "DlgSettingsGridDisplay.h"
00010 #include "EngaugeAssert.h"
00011 #include "GridInitializer.h"
00012 #include "GridLineFactory.h"
00013 #include "Logger.h"
00014 #include "MainWindow.h"
00015 #include <QCheckBox>
00016 #include <QComboBox>
00017 #include <QDoubleValidator>
00018 #include <QGraphicsScene>
00019 #include <QGridLayout>
00020 #include <QGroupBox>
00021 #include <QHBoxLayout>
00022 #include <QLabel>
00023 #include <QLineEdit>
00024 #include "ViewPreview.h"
00025
00026 const int COUNT_MIN = 1;
00027 const int COUNT_MAX = 100;
00028 const int COUNT_DECIMALS = 0;
00029 const int MINIMUM_HEIGHT = 480;
00030
00031 DlgSettingsGridDisplay::DlgSettingsGridDisplay(MainWindow &mainWindow) :
00032 DlgSettingsAbstractBase (tr ("Grid Display"),
00033 "DlgSettingsGridDisplay",
00034 mainWindow),
00035 m_scenePreview (0),
00036 m_viewPreview (0),
00037 m_modelGridDisplayBefore (0),
00038 m_modelGridDisplayAfter (0)
00039 {
00040 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::DlgSettingsGridDisplay";
00041
00042 QWidget *subPanel = createSubPanel ();
00043 finishPanel (subPanel);
00044 }
00045
00046 DlgSettingsGridDisplay::~DlgSettingsGridDisplay()
00047 {
00048 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::~DlgSettingsGridDisplay";
00049 }
00050
00051 void DlgSettingsGridDisplay::createDisplayCommon (QGridLayout *layout, int &row)
00052 {
00053 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createDisplayCommon";
00054
00055 QWidget *widgetCommon = new QWidget;
00056 layout->addWidget (widgetCommon, row++, 2, 1, 2);
00057
00058 QGridLayout *layoutCommon = new QGridLayout;
00059 widgetCommon->setLayout (layoutCommon);
00060 int rowCommon = 0;
00061
00062 QLabel *labelColor = new QLabel (tr ("Color:"));
00063 layoutCommon->addWidget (labelColor, rowCommon, 1);
00064
00065 m_cmbColor = new QComboBox;
00066 m_cmbColor->setWhatsThis (tr ("Select a color for the lines"));
00067 populateColorComboWithoutTransparent (*m_cmbColor);
00068 connect (m_cmbColor, SIGNAL (activated (const QString &)), this, SLOT (slotColor (const QString &)));
00069 layoutCommon->addWidget (m_cmbColor, rowCommon++, 2);
00070
00071
00072 layoutCommon->setColumnStretch (0, 1);
00073 layoutCommon->setColumnStretch (1, 0);
00074 layoutCommon->setColumnStretch (2, 0);
00075 layoutCommon->setColumnStretch (3, 1);
00076 }
00077
00078 void DlgSettingsGridDisplay::createDisplayGridLinesX (QGridLayout *layout, int &row)
00079 {
00080 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createDisplayGridLinesX";
00081
00082 m_groupX = new QGroupBox;
00083 layout->addWidget (m_groupX, row, 2);
00084
00085 QGridLayout *layoutGroup = new QGridLayout;
00086 m_groupX->setLayout (layoutGroup);
00087
00088 QLabel *labelDisable = new QLabel (tr ("Disable:"));
00089 layoutGroup->addWidget (labelDisable, 0, 0);
00090
00091 m_cmbDisableX = new QComboBox;
00092 m_cmbDisableX->setWhatsThis (tr ("Disabled value.\n\n"
00093 "The X grid lines are specified using only three values at a time. For flexibility, four values "
00094 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
00095 "updated as the other values change"));
00096 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
00097 QVariant (GRID_COORD_DISABLE_COUNT));
00098 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
00099 QVariant (GRID_COORD_DISABLE_START));
00100 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
00101 QVariant (GRID_COORD_DISABLE_STEP));
00102 m_cmbDisableX->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
00103 QVariant (GRID_COORD_DISABLE_STOP));
00104 connect (m_cmbDisableX, SIGNAL (activated (const QString &)), this, SLOT (slotDisableX (const QString &)));
00105 layoutGroup->addWidget (m_cmbDisableX, 0, 1);
00106
00107 QLabel *labelCount = new QLabel (tr ("Count:"));
00108 layoutGroup->addWidget (labelCount, 1, 0);
00109
00110 m_editCountX = new QLineEdit;
00111 m_editCountX->setWhatsThis (tr ("Number of X grid lines.\n\n"
00112 "The number of X grid lines must be entered as an integer greater than zero"));
00113 m_validatorCountX = new QDoubleValidator (COUNT_MIN, COUNT_MAX, COUNT_DECIMALS);
00114 m_editCountX->setValidator (m_validatorCountX);
00115 connect (m_editCountX, SIGNAL (textEdited (const QString &)), this, SLOT (slotCountX (const QString &)));
00116 layoutGroup->addWidget (m_editCountX, 1, 1);
00117
00118 QLabel *labelStart = new QLabel (tr ("Start:"));
00119 layoutGroup->addWidget (labelStart, 2, 0);
00120
00121 m_editStartX = new QLineEdit;
00122 m_editStartX->setWhatsThis (tr ("Value of the first X grid line.\n\n"
00123 "The start value cannot be greater than the stop value"));
00124 m_validatorStartX = new QDoubleValidator;
00125 m_editStartX->setValidator (m_validatorStartX);
00126 connect (m_editStartX, SIGNAL (textEdited (const QString &)), this, SLOT (slotStartX (const QString &)));
00127 layoutGroup->addWidget (m_editStartX, 2, 1);
00128
00129 QLabel *labelStep = new QLabel (tr ("Step:"));
00130 layoutGroup->addWidget (labelStep, 3, 0);
00131
00132 m_editStepX = new QLineEdit;
00133 m_editStepX->setWhatsThis (tr ("Difference in value between two successive X grid lines.\n\n"
00134 "The step value must be greater than zero"));
00135 m_validatorStepX = new QDoubleValidator;
00136 m_editStepX->setValidator (m_validatorStepX);
00137 connect (m_editStepX, SIGNAL (textEdited (const QString &)), this, SLOT (slotStepX (const QString &)));
00138 layoutGroup->addWidget (m_editStepX, 3, 1);
00139
00140 QLabel *labelStop = new QLabel (tr ("Stop:"));
00141 layoutGroup->addWidget (labelStop, 4, 0);
00142
00143 m_editStopX = new QLineEdit;
00144 m_editStopX->setWhatsThis (tr ("Value of the last X grid line.\n\n"
00145 "The stop value cannot be less than the start value"));
00146 m_validatorStopX = new QDoubleValidator;
00147 m_editStopX->setValidator (m_validatorStopX);
00148 connect (m_editStopX, SIGNAL (textEdited (const QString &)), this, SLOT (slotStopX (const QString &)));
00149 layoutGroup->addWidget (m_editStopX, 4, 1);
00150 }
00151
00152 void DlgSettingsGridDisplay::createDisplayGridLinesY (QGridLayout *layout, int &row)
00153 {
00154 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createDisplayGridLinesY";
00155
00156 m_groupY = new QGroupBox;
00157 layout->addWidget (m_groupY, row++, 3);
00158
00159 QGridLayout *layoutGroup = new QGridLayout;
00160 m_groupY->setLayout (layoutGroup);
00161
00162 QLabel *labelDisable = new QLabel (tr ("Disable:"));
00163 layoutGroup->addWidget (labelDisable, 0, 0);
00164
00165 m_cmbDisableY = new QComboBox;
00166 m_cmbDisableY->setWhatsThis (tr ("Disabled value.\n\n"
00167 "The Y grid lines are specified using only three values at a time. For flexibility, four values "
00168 "are offered so you must chose which value is disabled. Once disabled, that value is simply "
00169 "updated as the other values change"));
00170 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_COUNT),
00171 QVariant (GRID_COORD_DISABLE_COUNT));
00172 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_START),
00173 QVariant (GRID_COORD_DISABLE_START));
00174 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STEP),
00175 QVariant (GRID_COORD_DISABLE_STEP));
00176 m_cmbDisableY->addItem(gridCoordDisableToString (GRID_COORD_DISABLE_STOP),
00177 QVariant (GRID_COORD_DISABLE_STOP));
00178 connect (m_cmbDisableY, SIGNAL (activated (const QString &)), this, SLOT (slotDisableY (const QString &)));
00179 layoutGroup->addWidget (m_cmbDisableY, 0, 1);
00180
00181 QLabel *labelCount = new QLabel (tr ("Count:"));
00182 layoutGroup->addWidget (labelCount, 1, 0);
00183
00184 m_editCountY = new QLineEdit;
00185 m_editCountY->setWhatsThis (tr ("Number of Y grid lines.\n\n"
00186 "The number of Y grid lines must be entered as an integer greater than zero"));
00187 m_validatorCountY = new QDoubleValidator (COUNT_MIN, COUNT_MAX, COUNT_DECIMALS);
00188 m_editCountY->setValidator (m_validatorCountY);
00189 connect (m_editCountY, SIGNAL (textEdited (const QString &)), this, SLOT (slotCountY (const QString &)));
00190 layoutGroup->addWidget (m_editCountY, 1, 1);
00191
00192 QLabel *labelStart = new QLabel (tr ("Start:"));
00193 layoutGroup->addWidget (labelStart, 2, 0);
00194
00195 m_editStartY = new QLineEdit;
00196 m_editStartY->setWhatsThis (tr ("Value of the first Y grid line.\n\n"
00197 "The start value cannot be greater than the stop value"));
00198 m_validatorStartY = new QDoubleValidator;
00199 m_editStartY->setValidator (m_validatorStartY);
00200 connect (m_editStartY, SIGNAL (textEdited (const QString &)), this, SLOT (slotStartY (const QString &)));
00201 layoutGroup->addWidget (m_editStartY, 2, 1);
00202
00203 QLabel *labelStep = new QLabel (tr ("Step:"));
00204 layoutGroup->addWidget (labelStep, 3, 0);
00205
00206 m_editStepY = new QLineEdit;
00207 m_editStepY->setWhatsThis (tr ("Difference in value between two successive Y grid lines.\n\n"
00208 "The step value must be greater than zero"));
00209 m_validatorStepY = new QDoubleValidator;
00210 m_editStepY->setValidator (m_validatorStepY);
00211 connect (m_editStepY, SIGNAL (textEdited (const QString &)), this, SLOT (slotStepY (const QString &)));
00212 layoutGroup->addWidget (m_editStepY, 3, 1);
00213
00214 QLabel *labelStop = new QLabel (tr ("Stop:"));
00215 layoutGroup->addWidget (labelStop, 4, 0);
00216
00217 m_editStopY = new QLineEdit;
00218 m_editStopY->setWhatsThis (tr ("Value of the last Y grid line.\n\n"
00219 "The stop value cannot be less than the start value"));
00220 m_validatorStopY = new QDoubleValidator;
00221 m_editStopY->setValidator (m_validatorStopY);
00222 connect (m_editStopY, SIGNAL (textEdited (const QString &)), this, SLOT (slotStopY (const QString &)));
00223 layoutGroup->addWidget (m_editStopY, 4, 1);
00224 }
00225
00226 void DlgSettingsGridDisplay::createOptionalSaveDefault (QHBoxLayout * )
00227 {
00228 }
00229
00230 void DlgSettingsGridDisplay::createPreview (QGridLayout *layout, int &row)
00231 {
00232 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createPreview";
00233
00234 QLabel *labelPreview = new QLabel (tr ("Preview"));
00235 layout->addWidget (labelPreview, row++, 0, 1, 5);
00236
00237 m_scenePreview = new QGraphicsScene (this);
00238 m_viewPreview = new ViewPreview (m_scenePreview,
00239 ViewPreview::VIEW_ASPECT_RATIO_VARIABLE,
00240 this);
00241 m_viewPreview->setWhatsThis (tr ("Preview window that shows how current settings affect grid display"));
00242 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
00243 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
00244 m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
00245 layout->addWidget (m_viewPreview, row++, 0, 1, 5);
00246 }
00247
00248 QWidget *DlgSettingsGridDisplay::createSubPanel ()
00249 {
00250 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::createSubPanel";
00251
00252 const int COLUMN_CHECKBOX_WIDTH = 60;
00253
00254 QWidget *subPanel = new QWidget ();
00255 QGridLayout *layout = new QGridLayout (subPanel);
00256 subPanel->setLayout (layout);
00257
00258 layout->setColumnStretch(0, 1);
00259 layout->setColumnStretch(1, 0);
00260 layout->setColumnMinimumWidth(1, COLUMN_CHECKBOX_WIDTH);
00261 layout->setColumnStretch(2, 0);
00262 layout->setColumnStretch(3, 0);
00263 layout->setColumnStretch(4, 1);
00264
00265 int row = 0;
00266 createDisplayGridLinesX (layout, row);
00267 createDisplayGridLinesY (layout, row);
00268 createDisplayCommon (layout, row);
00269 createPreview (layout, row);
00270
00271 return subPanel;
00272 }
00273
00274 void DlgSettingsGridDisplay::handleOk ()
00275 {
00276 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::handleOk";
00277
00278
00279 m_modelGridDisplayAfter->setStable (true);
00280
00281 CmdSettingsGridDisplay *cmd = new CmdSettingsGridDisplay (mainWindow (),
00282 cmdMediator ().document(),
00283 *m_modelGridDisplayBefore,
00284 *m_modelGridDisplayAfter);
00285 cmdMediator ().push (cmd);
00286
00287 hide ();
00288 }
00289
00290 void DlgSettingsGridDisplay::load (CmdMediator &cmdMediator)
00291 {
00292 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::load";
00293
00294 setCmdMediator (cmdMediator);
00295
00296
00297 if (m_modelGridDisplayBefore != 0) {
00298 delete m_modelGridDisplayBefore;
00299 }
00300 if (m_modelGridDisplayAfter != 0) {
00301 delete m_modelGridDisplayAfter;
00302 }
00303
00304
00305 QString titleX = tr ("X Grid Lines");
00306 if (cmdMediator.document ().modelCoords().coordsType() == COORDS_TYPE_POLAR) {
00307 titleX = QString (QChar (0x98, 0x03)) + QString (" %1").arg (tr ("Grid Lines"));
00308 }
00309 m_groupX->setTitle (titleX);
00310
00311 QString titleY = tr ("Y Grid Lines");
00312 if (cmdMediator.document ().modelCoords().coordsType() == COORDS_TYPE_POLAR) {
00313 titleY = QString (tr ("Radius Grid Lines"));
00314 }
00315 m_groupY->setTitle (titleY);
00316
00317
00318 m_modelGridDisplayBefore = new DocumentModelGridDisplay (cmdMediator.document());
00319 m_modelGridDisplayAfter = new DocumentModelGridDisplay (cmdMediator.document());
00320
00321
00322 int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridDisplayAfter->disableX()));
00323 m_cmbDisableX->setCurrentIndex (indexDisableX);
00324
00325 m_editCountX->setText(QString::number(m_modelGridDisplayAfter->countX()));
00326 m_editStartX->setText(QString::number(m_modelGridDisplayAfter->startX()));
00327 m_editStepX->setText(QString::number(m_modelGridDisplayAfter->stepX()));
00328 m_editStopX->setText(QString::number(m_modelGridDisplayAfter->stopX()));
00329
00330 int indexDisableY = m_cmbDisableY->findData (QVariant (m_modelGridDisplayAfter->disableY()));
00331 m_cmbDisableY->setCurrentIndex (indexDisableY);
00332
00333 m_editCountY->setText(QString::number(m_modelGridDisplayAfter->countY()));
00334 m_editStartY->setText(QString::number(m_modelGridDisplayAfter->startY()));
00335 m_editStepY->setText(QString::number(m_modelGridDisplayAfter->stepY()));
00336 m_editStopY->setText(QString::number(m_modelGridDisplayAfter->stopY()));
00337
00338 int indexColor = m_cmbColor->findData(QVariant(m_modelGridDisplayAfter->paletteColor()));
00339 ENGAUGE_ASSERT (indexColor >= 0);
00340 m_cmbColor->setCurrentIndex(indexColor);
00341
00342 m_scenePreview->addPixmap (cmdMediator.document().pixmap());
00343
00344 updateControls ();
00345 enableOk (false);
00346 updatePreview();
00347 }
00348
00349 void DlgSettingsGridDisplay::setSmallDialogs(bool smallDialogs)
00350 {
00351 if (!smallDialogs) {
00352 setMinimumHeight (MINIMUM_HEIGHT);
00353 }
00354 }
00355
00356 void DlgSettingsGridDisplay::slotColor (QString const &)
00357 {
00358 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotColor";
00359
00360 m_modelGridDisplayAfter->setPaletteColor((ColorPalette) m_cmbColor->currentData().toInt());
00361 updateControls();
00362 updatePreview();
00363 }
00364
00365 void DlgSettingsGridDisplay::slotCountX(const QString &count)
00366 {
00367 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotCountX";
00368
00369 m_modelGridDisplayAfter->setCountX(count.toInt());
00370 updateDisplayedVariableX ();
00371 updateControls ();
00372 updatePreview();
00373 }
00374
00375 void DlgSettingsGridDisplay::slotCountY(const QString &count)
00376 {
00377 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotCountY";
00378
00379 m_modelGridDisplayAfter->setCountY(count.toInt());
00380 updateDisplayedVariableY ();
00381 updateControls ();
00382 updatePreview();
00383 }
00384
00385 void DlgSettingsGridDisplay::slotDisableX(const QString &)
00386 {
00387 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotDisableX";
00388
00389 GridCoordDisable gridCoordDisable = (GridCoordDisable) m_cmbDisableX->currentData().toInt();
00390 m_modelGridDisplayAfter->setDisableX(gridCoordDisable);
00391 updateDisplayedVariableX ();
00392 updateControls();
00393 updatePreview();
00394 }
00395
00396 void DlgSettingsGridDisplay::slotDisableY(const QString &)
00397 {
00398 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotDisableY";
00399
00400 GridCoordDisable gridCoordDisable = (GridCoordDisable) m_cmbDisableY->currentData().toInt();
00401 m_modelGridDisplayAfter->setDisableY(gridCoordDisable);
00402 updateDisplayedVariableY ();
00403 updateControls();
00404 updatePreview();
00405 }
00406
00407 void DlgSettingsGridDisplay::slotStartX(const QString &startX)
00408 {
00409 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStartX";
00410
00411 m_modelGridDisplayAfter->setStartX(startX.toDouble());
00412 updateDisplayedVariableX ();
00413 updateControls();
00414 updatePreview();
00415 }
00416
00417 void DlgSettingsGridDisplay::slotStartY(const QString &startY)
00418 {
00419 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStartY";
00420
00421 m_modelGridDisplayAfter->setStartY(startY.toDouble());
00422 updateDisplayedVariableY ();
00423 updateControls();
00424 updatePreview();
00425 }
00426
00427 void DlgSettingsGridDisplay::slotStepX(const QString &stepX)
00428 {
00429 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStepX";
00430
00431 m_modelGridDisplayAfter->setStepX(stepX.toDouble());
00432 updateDisplayedVariableX ();
00433 updateControls();
00434 updatePreview();
00435 }
00436
00437 void DlgSettingsGridDisplay::slotStepY(const QString &stepY)
00438 {
00439 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStepY";
00440
00441 m_modelGridDisplayAfter->setStepY(stepY.toDouble());
00442 updateDisplayedVariableY ();
00443 updateControls();
00444 updatePreview();
00445 }
00446
00447 void DlgSettingsGridDisplay::slotStopX(const QString &stopX)
00448 {
00449 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStopX";
00450
00451 m_modelGridDisplayAfter->setStopX(stopX.toDouble());
00452 updateDisplayedVariableX ();
00453 updateControls();
00454 updatePreview();
00455 }
00456
00457 void DlgSettingsGridDisplay::slotStopY(const QString &stopY)
00458 {
00459 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridDisplay::slotStopY";
00460
00461 m_modelGridDisplayAfter->setStopY(stopY.toDouble());
00462 updateDisplayedVariableY ();
00463 updateControls();
00464 updatePreview();
00465 }
00466
00467 bool DlgSettingsGridDisplay::textItemsAreValid () const
00468 {
00469 QString textCountX = m_editCountX->text();
00470 QString textCountY = m_editCountY->text();
00471 QString textStartX = m_editStartX->text();
00472 QString textStartY = m_editStartY->text();
00473 QString textStepX = m_editStepX->text();
00474 QString textStepY = m_editStepY->text();
00475 QString textStopX = m_editStopX->text();
00476 QString textStopY = m_editStopY->text();
00477
00478
00479
00480
00481 int pos;
00482 return (!textCountX.isEmpty() &&
00483 !textCountY.isEmpty() &&
00484 !textStartX.isEmpty() &&
00485 !textStartY.isEmpty() &&
00486 !textStepX.isEmpty() &&
00487 !textStepY.isEmpty() &&
00488 !textStopX.isEmpty() &&
00489 !textStopY.isEmpty() &&
00490 m_validatorCountX->validate(textCountX, pos) == QValidator::Acceptable &&
00491 m_validatorCountY->validate(textCountY, pos) == QValidator::Acceptable &&
00492 m_validatorStartX->validate(textStartX, pos) == QValidator::Acceptable &&
00493 m_validatorStartY->validate(textStartY, pos) == QValidator::Acceptable &&
00494 m_validatorStepX->validate(textStepX, pos) == QValidator::Acceptable &&
00495 m_validatorStepY->validate(textStepY, pos) == QValidator::Acceptable &&
00496 m_validatorStopX->validate(textStopX, pos) == QValidator::Acceptable &&
00497 m_validatorStopY->validate(textStopY, pos) == QValidator::Acceptable);
00498 }
00499
00500 void DlgSettingsGridDisplay::updateControls ()
00501 {
00502 GridCoordDisable disableX = (GridCoordDisable) m_cmbDisableX->currentData().toInt();
00503 m_editCountX->setEnabled (disableX != GRID_COORD_DISABLE_COUNT);
00504 m_editStartX->setEnabled (disableX != GRID_COORD_DISABLE_START);
00505 m_editStepX->setEnabled (disableX != GRID_COORD_DISABLE_STEP);
00506 m_editStopX->setEnabled (disableX != GRID_COORD_DISABLE_STOP);
00507
00508 GridCoordDisable disableY = (GridCoordDisable) m_cmbDisableY->currentData().toInt();
00509 m_editCountY->setEnabled (disableY != GRID_COORD_DISABLE_COUNT);
00510 m_editStartY->setEnabled (disableY != GRID_COORD_DISABLE_START);
00511 m_editStepY->setEnabled (disableY != GRID_COORD_DISABLE_STEP);
00512 m_editStopY->setEnabled (disableY != GRID_COORD_DISABLE_STOP);
00513
00514 enableOk (textItemsAreValid ());
00515 }
00516
00517 void DlgSettingsGridDisplay::updateDisplayedVariableX ()
00518 {
00519 GridInitializer initializer;
00520
00521 bool linearAxis = (cmdMediator ().document ().modelCoords ().coordScaleXTheta() == COORD_SCALE_LINEAR);
00522
00523 switch (m_modelGridDisplayAfter->disableX()) {
00524 case GRID_COORD_DISABLE_COUNT:
00525 m_editCountX->setText (QString::number (initializer.computeCount (linearAxis,
00526 m_modelGridDisplayAfter->startX (),
00527 m_modelGridDisplayAfter->stopX (),
00528 m_modelGridDisplayAfter->stepX ())));
00529 break;
00530
00531 case GRID_COORD_DISABLE_START:
00532 m_editStartX->setText (QString::number (initializer.computeStart (linearAxis,
00533 m_modelGridDisplayAfter->stopX (),
00534 m_modelGridDisplayAfter->stepX (),
00535 m_modelGridDisplayAfter->countX ())));
00536 break;
00537
00538 case GRID_COORD_DISABLE_STEP:
00539 m_editStepX->setText (QString::number (initializer.computeStep (linearAxis,
00540 m_modelGridDisplayAfter->startX (),
00541 m_modelGridDisplayAfter->stopX (),
00542 m_modelGridDisplayAfter->countX ())));
00543 break;
00544
00545 case GRID_COORD_DISABLE_STOP:
00546 m_editStopX->setText (QString::number (initializer.computeStop (linearAxis,
00547 m_modelGridDisplayAfter->startX (),
00548 m_modelGridDisplayAfter->stepX (),
00549 m_modelGridDisplayAfter->countX ())));
00550 break;
00551
00552 default:
00553 LOG4CPP_ERROR_S ((*mainCat)) << "DlgSettingsGridDisplay::updateDisplayedVariableX";
00554 break;
00555 }
00556 }
00557
00558 void DlgSettingsGridDisplay::updateDisplayedVariableY ()
00559 {
00560 GridInitializer initializer;
00561
00562 bool linearAxis = (cmdMediator ().document ().modelCoords ().coordScaleYRadius () == COORD_SCALE_LINEAR);
00563
00564 switch (m_modelGridDisplayAfter->disableY()) {
00565 case GRID_COORD_DISABLE_COUNT:
00566 m_editCountY->setText (QString::number (initializer.computeCount (linearAxis,
00567 m_modelGridDisplayAfter->startY (),
00568 m_modelGridDisplayAfter->stopY (),
00569 m_modelGridDisplayAfter->stepY ())));
00570 break;
00571
00572 case GRID_COORD_DISABLE_START:
00573 m_editStartY->setText (QString::number (initializer.computeStart (linearAxis,
00574 m_modelGridDisplayAfter->stopY (),
00575 m_modelGridDisplayAfter->stepY (),
00576 m_modelGridDisplayAfter->countY ())));
00577 break;
00578
00579 case GRID_COORD_DISABLE_STEP:
00580 m_editStepY->setText (QString::number (initializer.computeStep (linearAxis,
00581 m_modelGridDisplayAfter->startY (),
00582 m_modelGridDisplayAfter->stopY (),
00583 m_modelGridDisplayAfter->countY ())));
00584 break;
00585
00586 case GRID_COORD_DISABLE_STOP:
00587 m_editStopY->setText (QString::number (initializer.computeStop (linearAxis,
00588 m_modelGridDisplayAfter->startY (),
00589 m_modelGridDisplayAfter->stepY (),
00590 m_modelGridDisplayAfter->countY ())));
00591 break;
00592
00593 default:
00594 LOG4CPP_ERROR_S ((*mainCat)) << "DlgSettingsGridDisplay::updateDisplayedVariableY";
00595 break;
00596 }
00597 }
00598
00599 void DlgSettingsGridDisplay::updatePreview ()
00600 {
00601 m_gridLines.clear ();
00602
00603 if (textItemsAreValid ()) {
00604
00605 GridLineFactory factory (*m_scenePreview,
00606 cmdMediator ().document ().modelCoords());
00607
00608 factory.createGridLinesForEvenlySpacedGrid (*m_modelGridDisplayAfter,
00609 cmdMediator ().document (),
00610 mainWindow ().modelMainWindow(),
00611 mainWindow ().transformation(),
00612 m_gridLines);
00613 }
00614 }