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