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