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