00001
00002
00003
00004
00005
00006
00007 #include "CallbackBoundingRects.h"
00008 #include "CmdMediator.h"
00009 #include "CmdSettingsCoords.h"
00010 #include "CoordUnitsDate.h"
00011 #include "CoordUnitsTime.h"
00012 #include "DlgSettingsCoords.h"
00013 #include "DlgValidatorAbstract.h"
00014 #include "DlgValidatorFactory.h"
00015 #include "DocumentModelCoords.h"
00016 #include "EngaugeAssert.h"
00017 #include "Logger.h"
00018 #include "MainWindow.h"
00019 #include <math.h>
00020 #include <QComboBox>
00021 #include <QDebug>
00022 #include <QDoubleValidator>
00023 #include <QGraphicsRectItem>
00024 #include <QGridLayout>
00025 #include <QGroupBox>
00026 #include <QGraphicsScene>
00027 #include <QLabel>
00028 #include <QLineEdit>
00029 #include <QPalette>
00030 #include <QRadioButton>
00031 #include <QStackedWidget>
00032 #include <QVBoxLayout>
00033 #include "Transformation.h"
00034 #include "ViewPreview.h"
00035
00036 const QString OVERRIDDEN_VALUE("");
00037
00038 const int COLUMN_0 = 0;
00039 const int COLUMN_1 = 1;
00040
00041 const int STEPS_PER_CYCLE = 4;
00042 const int STEPS_CYCLE_COUNT = 4;
00043 const int NUM_COORD_STEPS = 1 + STEPS_PER_CYCLE * STEPS_CYCLE_COUNT;
00044
00045 const int MAX_WIDTH_EDIT_ORIGIN_RADIUS = 140;
00046
00047 const int CARTESIAN_COORD_MAX = 100;
00048 const int CARTESIAN_COORD_MIN = -100;
00049 const double CARTESIAN_COORD_STEP = (CARTESIAN_COORD_MAX - CARTESIAN_COORD_MIN) / (NUM_COORD_STEPS - 1.0);
00050
00051 const int POLAR_RADIUS = CARTESIAN_COORD_MAX;
00052 const double POLAR_STEP = POLAR_RADIUS / (NUM_COORD_STEPS - 1.0);
00053
00054 const int POLAR_THETA_MAX = 360;
00055 const int POLAR_THETA_MIN = 0;
00056 const double POLAR_THETA_STEP = (POLAR_THETA_MAX - POLAR_THETA_MIN) / (NUM_COORD_STEPS - 1.0);
00057
00058 const double XCENTER = (CARTESIAN_COORD_MIN + CARTESIAN_COORD_MAX) / 2.0;
00059 const double YCENTER = (CARTESIAN_COORD_MIN + CARTESIAN_COORD_MAX) / 2.0;
00060
00061 const double LINE_WIDTH_THIN = 0.0;
00062 const double LINE_WIDTH_THICK = 2.0;
00063
00064 const double PI = 3.1415926535;
00065 const double DEG_2_RAD = PI / 180.0;
00066
00067 const int FONT_SIZE = 6;
00068
00069 const double POWER_FOR_LOG = 10.0;
00070
00071 const int MINIMUM_DIALOG_WIDTH_COORDS = 800;
00072 const int MINIMUM_HEIGHT = 540;
00073
00074 DlgSettingsCoords::DlgSettingsCoords(MainWindow &mainWindow) :
00075 DlgSettingsAbstractBase (tr ("Coordinates"),
00076 "DlgSettingsCoords",
00077 mainWindow),
00078 m_btnCartesian (0),
00079 m_btnPolar (0),
00080 m_validatorOriginRadius (0),
00081 m_cmbDate (0),
00082 m_cmbTime (0),
00083 m_scenePreview (0),
00084 m_viewPreview (0),
00085 m_modelCoordsBefore (0),
00086 m_modelCoordsAfter (0)
00087 {
00088 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::DlgSettingsCoords";
00089
00090 QWidget *subPanel = createSubPanel ();
00091 finishPanel (subPanel,
00092 MINIMUM_DIALOG_WIDTH_COORDS);
00093 }
00094
00095 DlgSettingsCoords::~DlgSettingsCoords()
00096 {
00097 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::~DlgSettingsCoords";
00098 }
00099
00100 void DlgSettingsCoords::annotateAngles (const QFont &defaultFont) {
00101
00102
00103 for (int direction = 0; direction < 4; direction++) {
00104
00105 QString angle;
00106 CoordUnitsPolarTheta thetaUnits = (CoordUnitsPolarTheta) m_cmbXThetaUnits->currentData().toInt();
00107
00108 switch (thetaUnits) {
00109 case COORD_UNITS_POLAR_THETA_DEGREES:
00110 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
00111 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
00112 angle = QString::number (90.0 * direction);
00113 break;
00114
00115 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
00116 angle = QString::number (90.0 * direction);
00117 if (direction == 1) {
00118 angle = "90E";
00119 } else if (direction == 3) {
00120 angle = "90W";
00121 }
00122 break;
00123
00124 case COORD_UNITS_POLAR_THETA_GRADIANS:
00125 angle = QString::number (100.0 * direction);
00126 break;
00127
00128 case COORD_UNITS_POLAR_THETA_RADIANS:
00129 {
00130 static QString radiansUnits [] = {"0", "PI / 2", "PI", "3 * PI / 2"};
00131 ENGAUGE_ASSERT (direction < 4);
00132 angle = radiansUnits [direction];
00133 }
00134 break;
00135
00136 case COORD_UNITS_POLAR_THETA_TURNS:
00137 {
00138 static QString turnsUnits [] = {"0", "1 / 4", "1 / 2", "3 / 4"};
00139 ENGAUGE_ASSERT (direction < 4);
00140 angle = turnsUnits [direction];
00141 }
00142 break;
00143
00144 default:
00145 break;
00146 }
00147
00148 QGraphicsTextItem *textAngle = m_scenePreview->addText (angle);
00149 textAngle->setFont (QFont (defaultFont.defaultFamily(), FONT_SIZE));
00150 double x = 0, y = 0;
00151 switch (direction) {
00152 case 0:
00153 x = CARTESIAN_COORD_MAX - textAngle->boundingRect().width ();
00154 break;
00155 case 1:
00156 case 3:
00157 x = XCENTER - textAngle->boundingRect().width () / 2.0;
00158 break;
00159 case 2:
00160 x = CARTESIAN_COORD_MIN;
00161 break;
00162 }
00163 switch (direction) {
00164 case 0:
00165 case 2:
00166 y = YCENTER;
00167 break;
00168 case 1:
00169 y = CARTESIAN_COORD_MIN;
00170 break;
00171 case 3:
00172 y = CARTESIAN_COORD_MAX - textAngle->boundingRect().height ();
00173 break;
00174 }
00175
00176 textAngle->setPos (x, y);
00177 }
00178 }
00179
00180 void DlgSettingsCoords::annotateRadiusAtOrigin(const QFont &defaultFont) {
00181
00182 QGraphicsTextItem *textRadius = m_scenePreview->addText (m_editOriginRadius->text());
00183 textRadius->setFont (QFont (defaultFont.defaultFamily(), FONT_SIZE));
00184 textRadius->setPos (XCENTER - textRadius->boundingRect().width () / 2.0,
00185 YCENTER);
00186 }
00187
00188 QRectF DlgSettingsCoords::boundingRectGraph (CmdMediator &cmdMediator,
00189 bool &isEmpty) const
00190 {
00191 CallbackBoundingRects ftor (mainWindow().transformation());
00192
00193 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
00194 &CallbackBoundingRects::callback);
00195
00196
00197
00198 cmdMediator.iterateThroughCurvePointsAxes (ftorWithCallback);
00199
00200
00201
00202 if (mainWindow().transformIsDefined()) {
00203 cmdMediator.iterateThroughCurvesPointsGraphs (ftorWithCallback);
00204 }
00205
00206 return ftor.boundingRectGraph(isEmpty);
00207 }
00208
00209 void DlgSettingsCoords::createDateTime (QGridLayout *layout,
00210 int &row)
00211 {
00212 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createDateTime";
00213
00214 QLabel *label = new QLabel(tr ("Date/Time:"));
00215 layout->addWidget (label, row, 1);
00216
00217 QWidget *widgetCombos = new QWidget;
00218 layout->addWidget (widgetCombos, row++, 2);
00219 QHBoxLayout *layoutCombos = new QHBoxLayout;
00220 widgetCombos->setLayout (layoutCombos);
00221
00222
00223 m_cmbDate = new QComboBox;
00224 m_cmbDate->setWhatsThis (tr ("Date format to be used for date values, and date portion of mixed date/time values, "
00225 "during input and output.\n\n"
00226 "Setting the format to an empty value results in just the time portion appearing in output."));
00227 connect (m_cmbDate, SIGNAL (activated (const QString &)), this, SLOT (slotDate (const QString &)));
00228 layoutCombos->addWidget (m_cmbDate);
00229
00230 m_cmbTime = new QComboBox;
00231 m_cmbTime->setWhatsThis (tr ("Time format to be used for time values, and time portion of mixed date/time values, "
00232 "during input and output.\n\n"
00233 "Setting the format to an empty value results in just the date portion appearing in output."));
00234 connect (m_cmbTime, SIGNAL (activated (const QString &)), this, SLOT (slotTime (const QString &)));
00235 layoutCombos->addWidget (m_cmbTime);
00236 }
00237
00238 void DlgSettingsCoords::createGroupCoordsType (QGridLayout *layout,
00239 int &row)
00240 {
00241 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createGroupCoordsType";
00242
00243 m_boxCoordsType = new QGroupBox(tr ("Coordinates Types"));
00244 layout->addWidget (m_boxCoordsType, row++, 1, 1, 2);
00245
00246 QVBoxLayout *layoutGroup = new QVBoxLayout (m_boxCoordsType);
00247
00248 QString polarButtonText = QString(tr ("Polar") + " (") + THETA + QString(", " + tr ("R") + ")");
00249
00250 m_btnCartesian = new QRadioButton (tr ("Cartesian (X, Y)"), m_boxCoordsType);
00251 m_btnCartesian->setWhatsThis (QString(tr("Select cartesian coordinates.\n\n"
00252 "The X and Y coordinates will be used")));
00253 connect (m_btnCartesian, SIGNAL (toggled(bool)), this, SLOT (slotCartesianPolar (bool)));
00254 layoutGroup->addWidget (m_btnCartesian);
00255
00256 m_btnPolar = new QRadioButton (polarButtonText, m_boxCoordsType);
00257 m_btnPolar->setWhatsThis (QString(tr("Select polar coordinates.\n\n"
00258 "The Theta and R coordinates will be used.\n\n"
00259 "Polar coordinates are not allowed with log scale for Theta")));
00260 connect (m_btnPolar, SIGNAL (toggled(bool)), this, SLOT (slotCartesianPolar (bool)));
00261 layoutGroup->addWidget (m_btnPolar);
00262 }
00263
00264 void DlgSettingsCoords::createGroupXTheta (QGridLayout *layout,
00265 int &row)
00266 {
00267 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createGroupXTheta";
00268
00269 m_boxXTheta = new QGroupBox(OVERRIDDEN_VALUE);
00270 layout->addWidget (m_boxXTheta, row, 1, 1, 1);
00271
00272 QGridLayout *layoutXTheta = new QGridLayout (m_boxXTheta);
00273 m_boxXTheta->setLayout (layoutXTheta);
00274 int rowGroup = 0;
00275
00276 QLabel *labelScale = new QLabel (tr ("Scale:"));
00277 layoutXTheta->addWidget (labelScale, rowGroup++, COLUMN_0);
00278
00279 m_xThetaLinear = new QRadioButton (tr ("Linear"), m_boxXTheta);
00280 m_xThetaLinear->setWhatsThis (QString(tr("Specifies linear scale for the X or Theta coordinate")));
00281 connect (m_xThetaLinear, SIGNAL (released ()), this, SLOT (slotXThetaLinear()));
00282 layoutXTheta->addWidget (m_xThetaLinear, rowGroup++, COLUMN_0);
00283
00284 m_xThetaLog = new QRadioButton (tr ("Log"), m_boxXTheta);
00285 m_xThetaLog->setWhatsThis (QString(tr("Specifies logarithmic scale for the X or Theta coordinate.\n\n"
00286 "Log scale is not allowed if there are negative coordinates.\n\n"
00287 "Log scale is not allowed for the Theta coordinate.")));
00288 connect (m_xThetaLog, SIGNAL (released ()), this, SLOT (slotXThetaLog()));
00289 layoutXTheta->addWidget (m_xThetaLog, rowGroup++, COLUMN_0);
00290
00291 QLabel *labelThetaUnits = new QLabel(tr ("Units:"));
00292 layoutXTheta->addWidget (labelThetaUnits, rowGroup++, COLUMN_0);
00293
00294 m_cmbXThetaUnits = new QComboBox;
00295 connect (m_cmbXThetaUnits, SIGNAL (activated (const QString &)), this, SLOT (slotUnitsXTheta(const QString &)));
00296 layoutXTheta->addWidget (m_cmbXThetaUnits, rowGroup++, COLUMN_0, 1, 2);
00297 }
00298
00299 void DlgSettingsCoords::createGroupYRadius (QGridLayout *layout,
00300 int &row)
00301 {
00302 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createGroupYRadius";
00303
00304 m_boxYRadius = new QGroupBox (OVERRIDDEN_VALUE);
00305 layout->addWidget (m_boxYRadius, row++, 2, 1, 1);
00306
00307 QGridLayout *layoutYRadius = new QGridLayout (m_boxYRadius);
00308 m_boxYRadius->setLayout (layoutYRadius);
00309 int rowGroup = 0;
00310
00311 QLabel *labelScale = new QLabel (tr ("Scale:"));
00312 layoutYRadius->addWidget (labelScale, rowGroup++, COLUMN_0);
00313
00314 m_yRadiusLinear = new QRadioButton (tr ("Linear"), m_boxYRadius);
00315 m_yRadiusLinear->setWhatsThis (QString(tr("Specifies linear scale for the Y or R coordinate")));
00316 connect (m_yRadiusLinear, SIGNAL(released()), this, SLOT (slotYRadiusLinear()));
00317 layoutYRadius->addWidget (m_yRadiusLinear, rowGroup, COLUMN_0);
00318
00319 QLabel *labelOriginRadius = new QLabel(tr ("Origin radius value:"));
00320 layoutYRadius->addWidget (labelOriginRadius, rowGroup++, COLUMN_1);
00321
00322 m_yRadiusLog = new QRadioButton (tr ("Log"), m_boxYRadius);
00323 m_yRadiusLog->setWhatsThis (QString(tr("Specifies logarithmic scale for the Y or R coordinate\n\n"
00324 "Log scale is not allowed if there are negative coordinates.")));
00325 connect (m_yRadiusLog, SIGNAL(released ()), this, SLOT (slotYRadiusLog ()));
00326 layoutYRadius->addWidget (m_yRadiusLog, rowGroup, COLUMN_0);
00327
00328 m_editOriginRadius = new QLineEdit (m_boxYRadius);
00329 m_editOriginRadius->setMaximumWidth (MAX_WIDTH_EDIT_ORIGIN_RADIUS);
00330 m_editOriginRadius->setWhatsThis (QString(tr("Specify radius value at origin.\n\n"
00331 "Normally the radius at the origin is 0, but a nonzero value may be applied in other cases "
00332 "(like when the radial units are decibels).")));
00333 connect (m_editOriginRadius, SIGNAL (textChanged (const QString &)), this, SLOT (slotPolarOriginRadius(const QString &)));
00334 layoutYRadius->addWidget (m_editOriginRadius, rowGroup++, COLUMN_1);
00335
00336 QLabel *labelUnits = new QLabel(tr ("Units:"));
00337 layoutYRadius->addWidget (labelUnits, rowGroup++, COLUMN_0);
00338
00339 m_cmbYRadiusUnits = new QComboBox;
00340 connect (m_cmbYRadiusUnits, SIGNAL (activated (const QString &)), this, SLOT (slotUnitsYRadius(const QString &)));
00341 layoutYRadius->addWidget (m_cmbYRadiusUnits, rowGroup++, COLUMN_0, 1, 2);
00342 }
00343
00344 void DlgSettingsCoords::createOptionalSaveDefault (QHBoxLayout * )
00345 {
00346 }
00347
00348 void DlgSettingsCoords::createPreview (QGridLayout *layout,
00349 int &row)
00350 {
00351 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createPreview";
00352
00353 QLabel *labelPreview = new QLabel (tr ("Preview"));
00354 layout->addWidget (labelPreview, row++, 0, 1, 4);
00355
00356 m_scenePreview = new QGraphicsScene (this);
00357 m_viewPreview = new ViewPreview (m_scenePreview,
00358 ViewPreview::VIEW_ASPECT_RATIO_VARIABLE,
00359 this);
00360 m_viewPreview->setWhatsThis (tr ("Preview window that shows how current settings affect the coordinate system."));
00361 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
00362 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
00363 m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
00364
00365 layout->addWidget (m_viewPreview, row++, 0, 1, 4);
00366 }
00367
00368 QWidget *DlgSettingsCoords::createSubPanel ()
00369 {
00370 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::createSubPanel";
00371
00372 QWidget *subPanel = new QWidget ();
00373
00374 QGridLayout *layout = new QGridLayout (subPanel);
00375 subPanel->setLayout (layout);
00376
00377 layout->setColumnStretch(0, 1);
00378 layout->setColumnStretch(1, 0);
00379 layout->setColumnStretch(2, 0);
00380 layout->setColumnStretch(3, 1);
00381
00382 int row = 0;
00383 createGroupCoordsType(layout, row);
00384 createGroupXTheta (layout, row);
00385 createGroupYRadius (layout, row);
00386 createDateTime (layout, row);
00387 createPreview (layout, row);
00388
00389 return subPanel;
00390 }
00391
00392 void DlgSettingsCoords::drawCartesianLinearX ()
00393 {
00394 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawCartesianLinearX";
00395
00396 bool isAxis = true;
00397 for (int step = 0; step < NUM_COORD_STEPS; step++) {
00398 double x = CARTESIAN_COORD_MIN + step * CARTESIAN_COORD_STEP;
00399 QGraphicsLineItem *line = m_scenePreview->addLine (x, CARTESIAN_COORD_MIN, x, CARTESIAN_COORD_MAX);
00400 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00401 line->setPen(QPen (QBrush ((isHighlighted ? Qt::gray : Qt::lightGray)),
00402 LINE_WIDTH_THIN,
00403 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00404 if (isAxis) {
00405 line = m_scenePreview->addLine (x, CARTESIAN_COORD_MIN, x, CARTESIAN_COORD_MAX);
00406 line->setPen(QPen (QBrush (Qt::black),
00407 LINE_WIDTH_THICK));
00408 }
00409 isAxis = false;
00410 }
00411 }
00412
00413 void DlgSettingsCoords::drawCartesianLinearY ()
00414 {
00415 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawCartesianLinearY";
00416
00417 bool isAxis = true;
00418 for (int step = NUM_COORD_STEPS - 1; step >= 0; step--) {
00419 double y = CARTESIAN_COORD_MIN + step * CARTESIAN_COORD_STEP;
00420 QGraphicsLineItem *line = m_scenePreview->addLine (CARTESIAN_COORD_MIN, y, CARTESIAN_COORD_MAX, y);
00421 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00422 line->setPen(QPen (QBrush (isHighlighted ? Qt::gray : Qt::lightGray),
00423 LINE_WIDTH_THIN,
00424 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00425 if (isAxis) {
00426 line = m_scenePreview->addLine (CARTESIAN_COORD_MIN, y, CARTESIAN_COORD_MAX, y);
00427 line->setPen(QPen (QBrush (Qt::black),
00428 LINE_WIDTH_THICK));
00429 }
00430 isAxis = false;
00431 }
00432 }
00433
00434 void DlgSettingsCoords::drawCartesianLogX ()
00435 {
00436 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawCartesianLogX";
00437
00438 bool isAxis = true;
00439 for (int step = 0; step < NUM_COORD_STEPS; step++) {
00440 double s = (exp (step / (NUM_COORD_STEPS - 1.0)) - 1.0) /
00441 (exp (1.0) - 1.0);
00442 double x = (1.0 - s) * CARTESIAN_COORD_MIN + s * CARTESIAN_COORD_MAX;
00443 QGraphicsLineItem *line = m_scenePreview->addLine (x, CARTESIAN_COORD_MIN, x, CARTESIAN_COORD_MAX);
00444 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00445 line->setPen(QPen (QBrush (isHighlighted ? Qt::gray : Qt::lightGray),
00446 LINE_WIDTH_THIN,
00447 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00448 if (isAxis) {
00449 line = m_scenePreview->addLine (x, CARTESIAN_COORD_MIN, x, CARTESIAN_COORD_MAX);
00450 line->setPen(QPen (QBrush (Qt::black),
00451 LINE_WIDTH_THICK));
00452 }
00453 isAxis = false;
00454 }
00455 }
00456
00457 void DlgSettingsCoords::drawCartesianLogY ()
00458 {
00459 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawCartesianLogY";
00460
00461 bool isAxis = true;
00462 for (int step = 0; step < NUM_COORD_STEPS; step++) {
00463 double s = (pow (POWER_FOR_LOG, step / (NUM_COORD_STEPS - 1.0)) - 1.0) /
00464 (pow (POWER_FOR_LOG, 1.0) - 1.0);
00465 double y = (1.0 - s) * CARTESIAN_COORD_MAX + s * CARTESIAN_COORD_MIN;
00466 QGraphicsLineItem *line = m_scenePreview->addLine (CARTESIAN_COORD_MIN, y, CARTESIAN_COORD_MAX, y);
00467 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00468 line->setPen(QPen (QBrush (isHighlighted ? Qt::gray : Qt::lightGray),
00469 LINE_WIDTH_THIN,
00470 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00471 if (isAxis) {
00472 line = m_scenePreview->addLine (CARTESIAN_COORD_MIN, y, CARTESIAN_COORD_MAX, y);
00473 line->setPen(QPen (QBrush (Qt::black),
00474 LINE_WIDTH_THICK));
00475 }
00476 isAxis = false;
00477 }
00478 }
00479
00480 void DlgSettingsCoords::drawPolarLinearRadius ()
00481 {
00482 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawPolarLinearRadius";
00483
00484 for (int step = 0; step < NUM_COORD_STEPS; step++) {
00485 double radius = step * POLAR_STEP;
00486 QGraphicsEllipseItem *line = m_scenePreview->addEllipse (XCENTER - radius,
00487 YCENTER - radius,
00488 2.0 * radius,
00489 2.0 * radius);
00490 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00491 line->setPen(QPen (QBrush (isHighlighted ? Qt::gray : Qt::lightGray),
00492 LINE_WIDTH_THIN,
00493 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00494 }
00495 }
00496
00497 void DlgSettingsCoords::drawPolarLogRadius ()
00498 {
00499 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawPolarLogRadius";
00500
00501 for (int step = 0; step < NUM_COORD_STEPS; step++) {
00502 double s = (pow (POWER_FOR_LOG, step / (NUM_COORD_STEPS - 1.0)) - 1.0) /
00503 (pow (POWER_FOR_LOG, 1.0) - 1.0);
00504 double radius = (s * (NUM_COORD_STEPS - 1.0)) * POLAR_STEP;
00505 QGraphicsEllipseItem *line = m_scenePreview->addEllipse (XCENTER - radius,
00506 YCENTER - radius,
00507 2.0 * radius,
00508 2.0 * radius);
00509 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00510 line->setPen(QPen (QBrush (isHighlighted ? Qt::gray : Qt::lightGray),
00511 LINE_WIDTH_THIN,
00512 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00513 }
00514 }
00515
00516 void DlgSettingsCoords::drawPolarTheta ()
00517 {
00518 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::drawPolarTheta";
00519
00520 bool isAxis = true;
00521 for (int step = 0; step < NUM_COORD_STEPS; step++) {
00522 double theta = POLAR_THETA_MIN + step * POLAR_THETA_STEP;
00523 double x = POLAR_RADIUS * cos (theta * DEG_2_RAD);
00524 double y = POLAR_RADIUS * sin (theta * DEG_2_RAD);
00525 QGraphicsLineItem *line = m_scenePreview->addLine (XCENTER, YCENTER, XCENTER + x, YCENTER + y);
00526 bool isHighlighted = (step % STEPS_PER_CYCLE == 0);
00527 line->setPen(QPen (QBrush (isHighlighted ? Qt::gray : Qt::lightGray),
00528 LINE_WIDTH_THIN,
00529 (isHighlighted ? Qt::SolidLine : Qt::DashLine)));
00530 if (isAxis) {
00531 line = m_scenePreview->addLine (XCENTER, YCENTER, XCENTER + x, YCENTER + y);
00532 line->setPen(QPen (QBrush (Qt::black),
00533 LINE_WIDTH_THICK));
00534 }
00535 isAxis = false;
00536 }
00537 }
00538
00539 void DlgSettingsCoords::handleOk ()
00540 {
00541 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::handleOk";
00542
00543 CmdSettingsCoords *cmd = new CmdSettingsCoords (mainWindow (),
00544 cmdMediator ().document(),
00545 *m_modelCoordsBefore,
00546 *m_modelCoordsAfter);
00547 cmdMediator ().push (cmd);
00548
00549 hide ();
00550 }
00551
00552 void DlgSettingsCoords::load (CmdMediator &cmdMediator)
00553 {
00554 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::load";
00555
00556 setCmdMediator (cmdMediator);
00557
00558
00559 bool isEmpty;
00560 QRectF rectGraph = boundingRectGraph (cmdMediator,
00561 isEmpty);
00562 bool xThetaGoesNegative = !isEmpty && (rectGraph.x() <= 0);
00563 bool yRGoesNegative = !isEmpty && (rectGraph.y() <= 0);
00564 m_xThetaLinear->setEnabled (!xThetaGoesNegative);
00565 m_xThetaLog->setEnabled (!xThetaGoesNegative);
00566 m_yRadiusLinear->setEnabled (!yRGoesNegative);
00567 m_yRadiusLog->setEnabled (!yRGoesNegative);
00568
00569
00570 if (m_modelCoordsBefore != 0) {
00571 delete m_modelCoordsBefore;
00572 }
00573 if (m_modelCoordsAfter != 0) {
00574 delete m_modelCoordsAfter;
00575 }
00576
00577
00578 m_modelCoordsBefore = new DocumentModelCoords (cmdMediator.document().modelCoords());
00579 m_modelCoordsAfter = new DocumentModelCoords (cmdMediator.document().modelCoords());
00580
00581
00582 DlgValidatorFactory dlgValidatorFactory;
00583 m_validatorOriginRadius = dlgValidatorFactory.createWithNonPolar (m_modelCoordsAfter->coordScaleYRadius(),
00584 m_modelCoordsAfter->coordUnitsRadius(),
00585 m_modelCoordsAfter->coordUnitsDate(),
00586 m_modelCoordsAfter->coordUnitsTime(),
00587 mainWindow().modelMainWindow().locale());
00588 m_editOriginRadius->setValidator (m_validatorOriginRadius);
00589 m_editOriginRadius->setText (QString::number (m_modelCoordsAfter->originRadius ()));
00590
00591 if (m_modelCoordsAfter->coordsType() == COORDS_TYPE_CARTESIAN) {
00592 m_btnCartesian->setChecked (true);
00593 } else {
00594 m_btnPolar->setChecked (true);
00595 }
00596
00597 updateCoordUnits();
00598 loadComboBoxDate();
00599 loadComboBoxTime ();
00600
00601 m_xThetaLinear->setChecked (m_modelCoordsAfter->coordScaleXTheta() == COORD_SCALE_LINEAR);
00602 m_xThetaLog->setChecked (m_modelCoordsAfter->coordScaleXTheta() == COORD_SCALE_LOG);
00603 m_yRadiusLinear->setChecked (m_modelCoordsAfter->coordScaleYRadius() == COORD_SCALE_LINEAR);
00604 m_yRadiusLog->setChecked (m_modelCoordsAfter->coordScaleYRadius() == COORD_SCALE_LOG);
00605
00606 updateControls ();
00607 enableOk (false);
00608 updatePreview();
00609 }
00610
00611 void DlgSettingsCoords::loadComboBoxDate()
00612 {
00613 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::loadComboBoxDate";
00614
00615 m_cmbDate->clear ();
00616
00617 m_cmbDate->addItem (coordUnitsDateToString (COORD_UNITS_DATE_SKIP),
00618 QVariant (COORD_UNITS_DATE_SKIP));
00619 m_cmbDate->addItem (coordUnitsDateToString (COORD_UNITS_DATE_MONTH_DAY_YEAR),
00620 QVariant (COORD_UNITS_DATE_MONTH_DAY_YEAR));
00621 m_cmbDate->addItem (coordUnitsDateToString (COORD_UNITS_DATE_DAY_MONTH_YEAR),
00622 QVariant (COORD_UNITS_DATE_DAY_MONTH_YEAR));
00623 m_cmbDate->addItem (coordUnitsDateToString (COORD_UNITS_DATE_YEAR_MONTH_DAY),
00624 QVariant (COORD_UNITS_DATE_YEAR_MONTH_DAY));
00625
00626 ENGAUGE_ASSERT (m_cmbDate->count() == NUM_COORD_UNITS_DATE);
00627
00628 int index = m_cmbDate->findData (QVariant (m_modelCoordsAfter->coordUnitsDate()));
00629 m_cmbDate->setCurrentIndex (index);
00630 }
00631
00632 void DlgSettingsCoords::loadComboBoxTime()
00633 {
00634 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::loadComboBoxTime";
00635
00636 m_cmbTime->clear ();
00637
00638 m_cmbTime->addItem (coordUnitsTimeToString (COORD_UNITS_TIME_SKIP),
00639 QVariant (COORD_UNITS_TIME_SKIP));
00640 m_cmbTime->addItem (coordUnitsTimeToString (COORD_UNITS_TIME_HOUR_MINUTE),
00641 QVariant (COORD_UNITS_TIME_HOUR_MINUTE));
00642 m_cmbTime->addItem (coordUnitsTimeToString (COORD_UNITS_TIME_HOUR_MINUTE_SECOND),
00643 QVariant (COORD_UNITS_TIME_HOUR_MINUTE_SECOND));
00644
00645 ENGAUGE_ASSERT (m_cmbTime->count() == NUM_COORD_UNITS_TIME);
00646
00647 int index = m_cmbTime->findData (QVariant (m_modelCoordsAfter->coordUnitsTime()));
00648 m_cmbTime->setCurrentIndex (index);
00649 }
00650
00651 void DlgSettingsCoords::loadComboBoxUnitsNonPolar (QComboBox &cmb,
00652 CoordUnitsNonPolarTheta coordUnits)
00653 {
00654 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::loadComboBoxUnitsNonPolar";
00655
00656 cmb.clear();
00657
00658 cmb.addItem (coordUnitsNonPolarThetaToString (COORD_UNITS_NON_POLAR_THETA_NUMBER),
00659 QVariant (COORD_UNITS_NON_POLAR_THETA_NUMBER));
00660 cmb.addItem (coordUnitsNonPolarThetaToString (COORD_UNITS_NON_POLAR_THETA_DATE_TIME),
00661 QVariant (COORD_UNITS_NON_POLAR_THETA_DATE_TIME));
00662 cmb.addItem (coordUnitsNonPolarThetaToString (COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS),
00663 QVariant (COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS));
00664 cmb.addItem (coordUnitsNonPolarThetaToString (COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW),
00665 QVariant (COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW));
00666
00667 ENGAUGE_ASSERT (cmb.count() == NUM_COORD_UNITS_NON_POLAR_THETA);
00668
00669 cmb.setWhatsThis (QString (tr ("Numbers have the simplest and most general format.\n\n"
00670 "Date and time values have date and/or time components.\n\n"
00671 "Degrees Minutes Seconds (DDD MM SS.S) format uses two integer number for degrees and minutes, and a real number for "
00672 "seconds. There are 60 seconds per minute. During input, spaces must be inserted between the three numbers.")));
00673
00674 int index = cmb.findData (coordUnits);
00675 cmb.setCurrentIndex (index);
00676 }
00677
00678 void DlgSettingsCoords::loadComboBoxUnitsPolar (QComboBox &cmb,
00679 CoordUnitsPolarTheta coordUnits)
00680 {
00681 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::loadComboBoxUnitsPolar";
00682
00683 cmb.clear();
00684
00685 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_DEGREES),
00686 QVariant (COORD_UNITS_POLAR_THETA_DEGREES));
00687 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_DEGREES_MINUTES),
00688 QVariant (COORD_UNITS_POLAR_THETA_DEGREES_MINUTES));
00689 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS),
00690 QVariant (COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS));
00691 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW),
00692 QVariant (COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW));
00693 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_GRADIANS),
00694 QVariant (COORD_UNITS_POLAR_THETA_GRADIANS));
00695 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_RADIANS),
00696 QVariant (COORD_UNITS_POLAR_THETA_RADIANS));
00697 cmb.addItem (coordUnitsPolarThetaToString (COORD_UNITS_POLAR_THETA_TURNS),
00698 QVariant (COORD_UNITS_POLAR_THETA_TURNS));
00699
00700 ENGAUGE_ASSERT (cmb.count() == NUM_COORD_UNITS_POLAR_THETA);
00701
00702 cmb.setWhatsThis (QString (tr ("Degrees (DDD.DDDDD) format uses a single real number. One complete revolution is 360 degrees.\n\n"
00703 "Degrees Minutes (DDD MM.MMM) format uses one integer number for degrees, and a real number for minutes. There are "
00704 "60 minutes per degree. During input, a space must be inserted between the two numbers.\n\n"
00705 "Degrees Minutes Seconds (DDD MM SS.S) format uses two integer number for degrees and minutes, and a real number for "
00706 "seconds. There are 60 seconds per minute. During input, spaces must be inserted between the three numbers.\n\n"
00707 "Gradians format uses a single real number. One complete revolution is 400 gradians.\n\n"
00708 "Radians format uses a single real number. One complete revolution is 2*pi radians.\n\n"
00709 "Turns format uses a single real number. One complete revolution is one turn.")));
00710
00711 int index = cmb.findData (coordUnits);
00712 cmb.setCurrentIndex (index);
00713 }
00714
00715 void DlgSettingsCoords::resetSceneRectangle ()
00716 {
00717 QRect rect (CARTESIAN_COORD_MIN - CARTESIAN_COORD_STEP / 2.0,
00718 CARTESIAN_COORD_MIN - CARTESIAN_COORD_STEP / 2.0,
00719 CARTESIAN_COORD_MAX - CARTESIAN_COORD_MIN + CARTESIAN_COORD_STEP,
00720 CARTESIAN_COORD_MAX - CARTESIAN_COORD_MIN + CARTESIAN_COORD_STEP);
00721
00722 QGraphicsRectItem *itemPerimeter = new QGraphicsRectItem(rect);
00723 itemPerimeter->setVisible(false);
00724 m_scenePreview->addItem (itemPerimeter);
00725 m_viewPreview->centerOn (QPointF (0.0, 0.0));
00726 }
00727
00728 void DlgSettingsCoords::setSmallDialogs(bool smallDialogs)
00729 {
00730 if (!smallDialogs) {
00731 setMinimumHeight (MINIMUM_HEIGHT);
00732 }
00733 }
00734
00735 void DlgSettingsCoords::slotCartesianPolar (bool)
00736 {
00737 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotCartesian";
00738
00739 if (m_btnCartesian->isChecked ()) {
00740 m_modelCoordsAfter->setCoordsType (COORDS_TYPE_CARTESIAN);
00741 } else {
00742 m_modelCoordsAfter->setCoordsType(COORDS_TYPE_POLAR);
00743 }
00744 updateCoordUnits();
00745 updateControls();
00746 updatePreview();
00747 }
00748
00749 void DlgSettingsCoords::slotDate(const QString &)
00750 {
00751 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotDate";
00752
00753 CoordUnitsDate coordUnits = (CoordUnitsDate) m_cmbDate->currentData ().toInt();
00754 m_modelCoordsAfter->setCoordUnitsDate(coordUnits);
00755 updateControls();
00756 updatePreview();
00757 }
00758
00759 void DlgSettingsCoords::slotPolarOriginRadius(const QString &)
00760 {
00761 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotPolarOriginRadius";
00762
00763 QString numberText = m_editOriginRadius->text();
00764
00765 m_modelCoordsAfter->setOriginRadius(numberText.toDouble ());
00766 updateControls();
00767 updatePreview();
00768 }
00769
00770 void DlgSettingsCoords::slotTime(const QString &)
00771 {
00772 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotTime";
00773
00774 CoordUnitsTime coordUnits = (CoordUnitsTime) m_cmbTime->currentData ().toInt();
00775 m_modelCoordsAfter->setCoordUnitsTime(coordUnits);
00776 updateControls();
00777 updatePreview();
00778 }
00779
00780 void DlgSettingsCoords::slotUnitsXTheta(const QString &)
00781 {
00782 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotUnitsXTheta";
00783
00784 if (m_modelCoordsAfter->coordsType() == COORDS_TYPE_CARTESIAN) {
00785 CoordUnitsNonPolarTheta coordUnits = (CoordUnitsNonPolarTheta) m_cmbXThetaUnits->currentData ().toInt ();
00786 m_modelCoordsAfter->setCoordUnitsX(coordUnits);
00787 } else {
00788 CoordUnitsPolarTheta coordUnits = (CoordUnitsPolarTheta) m_cmbXThetaUnits->currentData ().toInt ();
00789 m_modelCoordsAfter->setCoordUnitsTheta(coordUnits);
00790 }
00791 updateControls ();
00792 updatePreview();
00793 }
00794
00795 void DlgSettingsCoords::slotUnitsYRadius(const QString &)
00796 {
00797 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotUnitsYRadius";
00798
00799 CoordUnitsNonPolarTheta coordUnits = (CoordUnitsNonPolarTheta) m_cmbYRadiusUnits->currentData ().toInt ();
00800 if (m_modelCoordsAfter->coordsType() == COORDS_TYPE_CARTESIAN) {
00801 m_modelCoordsAfter->setCoordUnitsY(coordUnits);
00802 } else {
00803 m_modelCoordsAfter->setCoordUnitsRadius(coordUnits);
00804 }
00805 updateControls ();
00806 updatePreview();
00807 }
00808
00809 void DlgSettingsCoords::slotXThetaLinear()
00810 {
00811 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotXThetaLinear";
00812
00813 m_modelCoordsAfter->setCoordScaleXTheta(COORD_SCALE_LINEAR);
00814 updateControls ();
00815 updatePreview();
00816 }
00817
00818 void DlgSettingsCoords::slotXThetaLog()
00819 {
00820 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotXThetaLog";
00821
00822 m_modelCoordsAfter->setCoordScaleXTheta(COORD_SCALE_LOG);
00823 updateControls ();
00824 updatePreview();
00825 }
00826
00827 void DlgSettingsCoords::slotYRadiusLinear()
00828 {
00829 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotYRadiusLinear";
00830
00831 delete m_validatorOriginRadius;
00832
00833 DlgValidatorFactory dlgValidatorFactory;
00834 m_validatorOriginRadius = dlgValidatorFactory.createWithNonPolar (COORD_SCALE_LINEAR,
00835 m_modelCoordsAfter->coordUnitsRadius(),
00836 m_modelCoordsAfter->coordUnitsDate(),
00837 m_modelCoordsAfter->coordUnitsTime(),
00838 mainWindow().modelMainWindow().locale());
00839 m_editOriginRadius->setValidator (m_validatorOriginRadius);
00840
00841 m_modelCoordsAfter->setCoordScaleYRadius((COORD_SCALE_LINEAR));
00842 updateControls ();
00843 updatePreview();
00844 }
00845
00846 void DlgSettingsCoords::slotYRadiusLog()
00847 {
00848 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::slotYRadiusLog";
00849
00850 delete m_validatorOriginRadius;
00851
00852 DlgValidatorFactory dlgValidatorFactory;
00853 m_validatorOriginRadius = dlgValidatorFactory.createWithNonPolar (COORD_SCALE_LOG,
00854 m_modelCoordsAfter->coordUnitsRadius(),
00855 m_modelCoordsAfter->coordUnitsDate(),
00856 m_modelCoordsAfter->coordUnitsTime(),
00857 mainWindow().modelMainWindow().locale());
00858 m_editOriginRadius->setValidator (m_validatorOriginRadius);
00859
00860 m_modelCoordsAfter->setCoordScaleYRadius(COORD_SCALE_LOG);
00861 updateControls ();
00862 updatePreview();
00863 }
00864
00865 void DlgSettingsCoords::updateControls ()
00866 {
00867
00868
00869 QString textOriginRadius = m_editOriginRadius->text();
00870 int posOriginRadius = 0;
00871
00872 bool goodOriginRadius = true;
00873 if (m_editOriginRadius->isEnabled ()) {
00874
00875
00876 goodOriginRadius = (m_validatorOriginRadius->validate (textOriginRadius,
00877 posOriginRadius) == QValidator::Acceptable);
00878 }
00879
00880 enableOk (goodOriginRadius);
00881
00882 m_boxCoordsType->setEnabled (!m_xThetaLog->isChecked ());
00883
00884 m_xThetaLinear->setEnabled (!m_btnPolar->isChecked ());
00885 m_xThetaLog->setEnabled (!m_btnPolar->isChecked ());
00886 if (m_btnCartesian->isChecked()) {
00887 m_yRadiusLinear->setEnabled (true);
00888 m_yRadiusLog->setEnabled (true);
00889 } else {
00890
00891
00892 DlgValidatorFactory dlgValidatorFactory;
00893 DlgValidatorAbstract *dlg = dlgValidatorFactory.createWithNonPolar (m_yRadiusLinear->isChecked () ? COORD_SCALE_LOG : COORD_SCALE_LINEAR,
00894 m_modelCoordsAfter->coordUnitsRadius(),
00895 m_modelCoordsAfter->coordUnitsDate(),
00896 m_modelCoordsAfter->coordUnitsTime(),
00897 mainWindow().modelMainWindow().locale());
00898 int posOriginRadiusOther;
00899 bool goodOriginRadiusOther = (dlg->validate (textOriginRadius, posOriginRadiusOther) == QValidator::Acceptable);
00900
00901 delete dlg;
00902
00903 m_yRadiusLinear->setEnabled (goodOriginRadius && goodOriginRadiusOther);
00904 m_yRadiusLog->setEnabled (goodOriginRadius && goodOriginRadiusOther);
00905 }
00906 m_editOriginRadius->setEnabled (m_btnPolar->isChecked ());
00907
00908 QString captionXTheta = (m_btnCartesian->isChecked () ?
00909 QString (tr ("X")) :
00910 THETA) + QString (" %1")
00911 .arg (tr ("Coordinates"));
00912 QString captionYRadius = (m_btnCartesian->isChecked () ?
00913 QString (tr ("Y")) :
00914 QString (tr ("R"))) + QString (" %1")
00915 .arg (tr ("Coordinates"));
00916
00917 if (m_boxXTheta->title() != captionXTheta) {
00918 m_boxXTheta->setTitle (captionXTheta);
00919 }
00920
00921 if (m_boxYRadius->title () != captionYRadius) {
00922 m_boxYRadius->setTitle (captionYRadius);
00923 }
00924
00925 bool enableDateTime;
00926 if (m_btnCartesian->isChecked()) {
00927 enableDateTime = (((CoordUnitsNonPolarTheta) m_cmbXThetaUnits->currentData ().toInt() == COORD_UNITS_NON_POLAR_THETA_DATE_TIME) ||
00928 ((CoordUnitsNonPolarTheta) m_cmbYRadiusUnits->currentData ().toInt() == COORD_UNITS_NON_POLAR_THETA_DATE_TIME));
00929 } else {
00930 enableDateTime = ((CoordUnitsNonPolarTheta) m_cmbYRadiusUnits->currentData ().toInt() == COORD_UNITS_NON_POLAR_THETA_DATE_TIME);
00931 }
00932 m_cmbDate->setEnabled (enableDateTime);
00933 m_cmbTime->setEnabled (enableDateTime);
00934
00935 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCoords::updateControls"
00936 << " textOriginRadius=" << textOriginRadius.toLatin1().data()
00937 << " goodOriginRadius=" << (goodOriginRadius ? "true" : "false")
00938 << " originRadius=" << posOriginRadius
00939 << " btnPolarChecked=" << (m_btnPolar->isChecked() ? "true" : "false")
00940 << " enableDateTime=" << (enableDateTime ? "true" : "false");
00941 }
00942
00943 void DlgSettingsCoords::updateCoordUnits()
00944 {
00945
00946 if (m_btnCartesian->isChecked()) {
00947 loadComboBoxUnitsNonPolar (*m_cmbXThetaUnits,
00948 m_modelCoordsAfter->coordUnitsX());
00949 loadComboBoxUnitsNonPolar (*m_cmbYRadiusUnits,
00950 m_modelCoordsAfter->coordUnitsY());
00951 } else {
00952 loadComboBoxUnitsPolar (*m_cmbXThetaUnits,
00953 m_modelCoordsAfter->coordUnitsTheta());
00954 loadComboBoxUnitsNonPolar (*m_cmbYRadiusUnits,
00955 m_modelCoordsAfter->coordUnitsRadius());
00956 }
00957 }
00958
00959 void DlgSettingsCoords::updatePreview()
00960 {
00961 m_scenePreview->clear();
00962
00963
00964
00965
00966
00967
00968
00969 if (m_btnCartesian->isChecked()) {
00970
00971
00972 if (m_xThetaLinear->isChecked()) {
00973 drawCartesianLinearX ();
00974 } else {
00975 drawCartesianLogX ();
00976 }
00977
00978 if (m_yRadiusLinear->isChecked()) {
00979 drawCartesianLinearY ();
00980 } else {
00981 drawCartesianLogY ();
00982 }
00983
00984 } else {
00985
00986
00987 drawPolarTheta ();
00988 if (m_yRadiusLinear->isChecked()) {
00989 drawPolarLinearRadius ();
00990 } else {
00991 drawPolarLogRadius ();
00992 }
00993
00994 QFont defaultFont;
00995 annotateRadiusAtOrigin (defaultFont);
00996 annotateAngles (defaultFont);
00997 }
00998
00999 resetSceneRectangle();
01000 }