00001
00002
00003
00004
00005
00006
00007 #include "CmdMediator.h"
00008 #include "CmdSettingsCurveProperties.h"
00009 #include "ColorPalette.h"
00010 #include "DlgSettingsCurveProperties.h"
00011 #include "EngaugeAssert.h"
00012 #include "EnumsToQt.h"
00013 #include "GraphicsPoint.h"
00014 #include "GraphicsPointFactory.h"
00015 #include "GraphicsView.h"
00016 #include "Logger.h"
00017 #include "MainWindow.h"
00018 #include <QCheckBox>
00019 #include <QComboBox>
00020 #include <QDebug>
00021 #include <QGraphicsRectItem>
00022 #include <QGraphicsScene>
00023 #include <QGridLayout>
00024 #include <QGroupBox>
00025 #include <QLabel>
00026 #include <QLineEdit>
00027 #include <QListWidget>
00028 #include <QPen>
00029 #include <QPushButton>
00030 #include <QSettings>
00031 #include <QSpacerItem>
00032 #include <QSpinBox>
00033 #include <QTransform>
00034 #include "Settings.h"
00035 #include "SettingsForGraph.h"
00036 #include "Spline.h"
00037 #include "SplinePair.h"
00038 #include <vector>
00039 #include "ViewPreview.h"
00040
00041 using namespace std;
00042
00043 const QString CONNECT_AS_FUNCTION_SMOOTH_STR ("Function - Smooth");
00044 const QString CONNECT_AS_FUNCTION_STRAIGHT_STR ("Function - Straight");
00045 const QString CONNECT_AS_RELATION_SMOOTH_STR ("Relation - Smooth");
00046 const QString CONNECT_AS_RELATION_STRAIGHT_STR ("Relation - Straight");
00047
00048 const double PREVIEW_WIDTH = 100.0;
00049 const double PREVIEW_HEIGHT = 100.0;
00050
00051 const QPointF POS_LEFT (PREVIEW_WIDTH / 3.0,
00052 PREVIEW_HEIGHT * 2.0 / 3.0);
00053 const QPointF POS_CENTER (PREVIEW_WIDTH / 2.0,
00054 PREVIEW_HEIGHT / 3.0);
00055 const QPointF POS_RIGHT (2.0 * PREVIEW_WIDTH / 3.0,
00056 PREVIEW_HEIGHT * 2.0 / 3.0);
00057
00058 DlgSettingsCurveProperties::DlgSettingsCurveProperties(MainWindow &mainWindow) :
00059 DlgSettingsAbstractBase (tr ("Curve Properties"),
00060 "DlgSettingsCurveProperties",
00061 mainWindow),
00062 m_scenePreview (0),
00063 m_viewPreview (0),
00064 m_modelCurveStylesBefore (0),
00065 m_modelCurveStylesAfter (0)
00066 {
00067 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::DlgSettingsCurveProperties";
00068
00069 QWidget *subPanel = createSubPanel ();
00070 finishPanel (subPanel);
00071
00072 setMinimumWidth (740);
00073 }
00074
00075 DlgSettingsCurveProperties::~DlgSettingsCurveProperties()
00076 {
00077 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::~DlgSettingsCurveProperties";
00078 }
00079
00080 void DlgSettingsCurveProperties::createCurveName (QGridLayout *layout,
00081 int &row)
00082 {
00083 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createCurveName";
00084
00085 QLabel *labelCurveName = new QLabel (tr ("Curve Name:"));
00086 layout->addWidget (labelCurveName, row, 1);
00087
00088 m_cmbCurveName = new QComboBox ();
00089 m_cmbCurveName->setWhatsThis (tr ("Name of the curve that is currently selected for editing"));
00090 connect (m_cmbCurveName, SIGNAL (activated (const QString &)), this, SLOT (slotCurveName (const QString &)));
00091 layout->addWidget (m_cmbCurveName, row++, 2);
00092 }
00093
00094 void DlgSettingsCurveProperties::createLine (QGridLayout *layout,
00095 int &row)
00096 {
00097 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createLine";
00098
00099 m_groupLine = new QGroupBox (tr ("Line"));
00100 layout->addWidget (m_groupLine, row++, 2);
00101
00102 QGridLayout *layoutGroup = new QGridLayout;
00103 m_groupLine->setLayout (layoutGroup);
00104
00105 QLabel *labelLineWidth = new QLabel (tr ("Width:"));
00106 layoutGroup->addWidget (labelLineWidth, 0, 0);
00107
00108 m_spinLineWidth = new QSpinBox (m_groupLine);
00109 m_spinLineWidth->setWhatsThis (tr ("Select a width for the lines drawn between points.\n\n"
00110 "This applies only to graph curves. No lines are ever drawn between axis points."));
00111 m_spinLineWidth->setMinimum(1);
00112 connect (m_spinLineWidth, SIGNAL (valueChanged (int)), this, SLOT (slotLineWidth (int)));
00113 layoutGroup->addWidget (m_spinLineWidth, 0, 1);
00114
00115 QLabel *labelLineColor = new QLabel (tr ("Color:"));
00116 layoutGroup->addWidget (labelLineColor, 1, 0);
00117
00118 m_cmbLineColor = new QComboBox (m_groupLine);
00119 m_cmbLineColor->setWhatsThis (tr ("Select a color for the lines drawn between points.\n\n"
00120 "This applies only to graph curves. No lines are ever drawn between axis points."));
00121 populateColorComboWithTransparent (*m_cmbLineColor);
00122 connect (m_cmbLineColor, SIGNAL (activated (const QString &)), this, SLOT (slotLineColor (const QString &)));
00123 layoutGroup->addWidget (m_cmbLineColor, 1, 1);
00124
00125 QLabel *labelLineType = new QLabel (tr ("Connect as:"));
00126 layoutGroup->addWidget (labelLineType, 2, 0);
00127
00128 m_cmbLineType = new QComboBox (m_groupLine);
00129 m_cmbLineType->addItem (CONNECT_AS_FUNCTION_STRAIGHT_STR, QVariant (CONNECT_AS_FUNCTION_STRAIGHT));
00130 m_cmbLineType->addItem (CONNECT_AS_FUNCTION_SMOOTH_STR, QVariant (CONNECT_AS_FUNCTION_SMOOTH));
00131 m_cmbLineType->addItem (CONNECT_AS_RELATION_STRAIGHT_STR, QVariant (CONNECT_AS_RELATION_STRAIGHT));
00132 m_cmbLineType->addItem (CONNECT_AS_RELATION_SMOOTH_STR, QVariant (CONNECT_AS_RELATION_SMOOTH));
00133 m_cmbLineType->setWhatsThis (tr ("Select rule for connecting points with lines.\n\n"
00134 "If the curve is connected as a single-valued function then the points are ordered by "
00135 "increasing value of the independent variable.\n\n"
00136 "If the curve is connected as a closed contour, then the points are ordered by age, except for "
00137 "points placed along an existing line. Any point placed on top of any existing line is inserted "
00138 "between the two endpoints of that line - as if its age was between the ages of the two "
00139 "endpoints.\n\n"
00140 "Lines are drawn between successively ordered points.\n\n"
00141 "Straight curves are drawn with straight lines between successive points. Smooth curves are drawn "
00142 "with smooth lines between successive points.\n\n"
00143 "This applies only to graph curves. No lines are ever drawn between axis points."));
00144 connect (m_cmbLineType, SIGNAL (activated (const QString &)), this, SLOT (slotLineType (const QString &)));
00145 layoutGroup->addWidget (m_cmbLineType, 2, 1);
00146 }
00147
00148 void DlgSettingsCurveProperties::createPoint (QGridLayout *layout,
00149 int &row)
00150 {
00151 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createPoint";
00152
00153 m_groupPoint = new QGroupBox (tr ("Point"));
00154 layout->addWidget (m_groupPoint, row++, 1);
00155
00156 QGridLayout *layoutGroup = new QGridLayout;
00157 m_groupPoint->setLayout (layoutGroup);
00158
00159 QLabel *labelPointShape = new QLabel(tr ("Shape:"));
00160 layoutGroup->addWidget (labelPointShape, 0, 0);
00161
00162 m_cmbPointShape = new QComboBox (m_groupPoint);
00163 m_cmbPointShape->setWhatsThis (tr ("Select a shape for the points"));
00164 m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_CIRCLE),
00165 POINT_SHAPE_CIRCLE);
00166 m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_CROSS),
00167 POINT_SHAPE_CROSS);
00168 m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_DIAMOND),
00169 POINT_SHAPE_DIAMOND);
00170 m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_SQUARE),
00171 POINT_SHAPE_SQUARE);
00172 m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_TRIANGLE),
00173 POINT_SHAPE_TRIANGLE);
00174 m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_X),
00175 POINT_SHAPE_X);
00176 connect (m_cmbPointShape, SIGNAL (activated (const QString &)), this, SLOT (slotPointShape (const QString &)));
00177 layoutGroup->addWidget (m_cmbPointShape, 0, 1);
00178
00179 QLabel *labelPointRadius = new QLabel (tr ("Radius:"));
00180 layoutGroup->addWidget (labelPointRadius, 1, 0);
00181
00182 m_spinPointRadius = new QSpinBox (m_groupPoint);
00183 m_spinPointRadius->setWhatsThis (tr ("Select a radius, in pixels, for the points"));
00184 m_spinPointRadius->setMinimum (1);
00185 connect (m_spinPointRadius, SIGNAL (valueChanged (int)), this, SLOT (slotPointRadius (int)));
00186 layoutGroup->addWidget (m_spinPointRadius, 1, 1);
00187
00188 QLabel *labelPointLineWidth = new QLabel (tr ("Line width:"));
00189 layoutGroup->addWidget (labelPointLineWidth, 2, 0);
00190
00191 m_spinPointLineWidth = new QSpinBox (m_groupPoint);
00192 m_spinPointLineWidth->setWhatsThis (tr ("Select a line width, in pixels, for the points.\n\n"
00193 "A larger width results in a thicker line, with the exception of a value of zero "
00194 "which always results in a line that is one pixel wide (which is easy to see even "
00195 "when zoomed far out)"));
00196 m_spinPointLineWidth->setMinimum (0);
00197 connect (m_spinPointLineWidth, SIGNAL (valueChanged (int)), this, SLOT (slotPointLineWidth (int)));
00198 layoutGroup->addWidget (m_spinPointLineWidth, 2, 1);
00199
00200 QLabel *labelPointColor = new QLabel (tr ("Color:"));
00201 layoutGroup->addWidget (labelPointColor, 3, 0);
00202
00203 m_cmbPointColor = new QComboBox (m_groupPoint);
00204 m_cmbPointColor->setWhatsThis (tr ("Select a color for the line used to draw the point shapes"));
00205 populateColorComboWithoutTransparent (*m_cmbPointColor);
00206 connect (m_cmbPointColor, SIGNAL (activated (const QString &)), this, SLOT (slotPointColor (const QString &)));
00207 layoutGroup->addWidget (m_cmbPointColor, 3, 1);
00208 }
00209
00210 void DlgSettingsCurveProperties::createOptionalSaveDefault (QHBoxLayout *layout)
00211 {
00212 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createOptionalSaveDefault";
00213
00214 m_btnSaveDefault = new QPushButton ("Save As Default");
00215 m_btnSaveDefault->setWhatsThis (tr ("Save the visible curve settings for use as future defaults, according to the curve name selection.\n\n"
00216 "If the visible settings are for the axes curve, then they will be used for future "
00217 "axes curves, until new settings are saved as the defaults.\n\n"
00218 "If the visible settings are for the Nth graph curve in the curve list, then they will be used for future "
00219 "graph curves that are also the Nth graph curve in their curve list, until new settings are saved as the defaults."));
00220 connect (m_btnSaveDefault, SIGNAL (released ()), this, SLOT (slotSaveDefault ()));
00221 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
00222 }
00223
00224 void DlgSettingsCurveProperties::createPreview (QGridLayout *layout,
00225 int &row)
00226 {
00227 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createPreview";
00228
00229 QLabel *labelPreview = new QLabel (tr ("Preview"));
00230 layout->addWidget (labelPreview, row++, 0, 1, 4);
00231
00232 m_scenePreview = new QGraphicsScene (this);
00233 m_viewPreview = new ViewPreview (m_scenePreview,
00234 ViewPreview::VIEW_ASPECT_RATIO_ONE_TO_ONE,
00235 this);
00236 m_viewPreview->setWhatsThis (tr ("Preview window that shows how current settings affect the points and line of the selected curve.\n\n"
00237 "The X coordinate is in the horizontal direction, and the Y coordinate is in the vertical direction. A "
00238 "function can have only one Y value, at most, for any X value, but a relation can have multiple Y values "
00239 "for one X value."));
00240 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
00241 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
00242 m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
00243 m_viewPreview->setRenderHint (QPainter::Antialiasing);
00244
00245 layout->addWidget (m_viewPreview, row++, 0, 1, 4);
00246 }
00247
00248 QWidget *DlgSettingsCurveProperties::createSubPanel ()
00249 {
00250 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createSubPanel";
00251
00252 QWidget *subPanel = new QWidget ();
00253 QGridLayout *layout = new QGridLayout (subPanel);
00254 subPanel->setLayout (layout);
00255
00256 int row = 0;
00257 createCurveName (layout, row);
00258
00259 int rowLeft = row, rowRight = row++;
00260 createPoint (layout, rowLeft);
00261 createLine (layout, rowRight);
00262 createPreview (layout, row);
00263
00264 layout->setColumnStretch(0, 1);
00265 layout->setColumnStretch(1, 0);
00266 layout->setColumnStretch(2, 0);
00267 layout->setColumnStretch(3, 1);
00268
00269 layout->setRowStretch (0, 1);
00270
00271 return subPanel;
00272 }
00273
00274 void DlgSettingsCurveProperties::drawLine (bool isRelation,
00275 const LineStyle &lineStyle)
00276 {
00277 const double Z_LINE = -1.0;
00278
00279
00280 QPainterPath path;
00281 QPointF p0 (POS_LEFT), p1 (POS_CENTER), p2 (POS_RIGHT);
00282 if (isRelation) {
00283
00284
00285 p1 = POS_RIGHT;
00286 p2 = POS_CENTER;
00287 }
00288
00289
00290 if (lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_SMOOTH ||
00291 lineStyle.curveConnectAs() == CONNECT_AS_RELATION_SMOOTH) {
00292
00293 vector<double> t;
00294 vector<SplinePair> xy;
00295 t.push_back(0);
00296 t.push_back(1);
00297 t.push_back(2);
00298 xy.push_back (SplinePair (p0.x(), p0.y()));
00299 xy.push_back (SplinePair (p1.x(), p1.y()));
00300 xy.push_back (SplinePair (p2.x(), p2.y()));
00301 Spline spline (t, xy);
00302 path.moveTo (p0);
00303 path.cubicTo (QPointF (spline.p1(0).x(),
00304 spline.p1(0).y()),
00305 QPointF (spline.p2(0).x(),
00306 spline.p2(0).y()),
00307 p1);
00308 path.cubicTo (QPointF (spline.p1(1).x(),
00309 spline.p1(1).y()),
00310 QPointF (spline.p2(1).x(),
00311 spline.p2(1).y()),
00312 p2);
00313 } else {
00314 path.moveTo (p0);
00315 path.lineTo (p1);
00316 path.lineTo (p2);
00317 }
00318
00319 QGraphicsPathItem *line = new QGraphicsPathItem (path);
00320 line->setPen (QPen (QBrush (ColorPaletteToQColor (lineStyle.paletteColor())),
00321 lineStyle.width()));
00322 line->setZValue (Z_LINE);
00323 m_scenePreview->addItem (line);
00324 }
00325
00326 void DlgSettingsCurveProperties::drawPoints (const PointStyle &pointStyle)
00327 {
00328 const QString NULL_IDENTIFIER;
00329
00330 GraphicsPointFactory pointFactory;
00331
00332
00333 GraphicsPoint *pointLeft = pointFactory.createPoint (*m_scenePreview,
00334 NULL_IDENTIFIER,
00335 POS_LEFT,
00336 pointStyle);
00337 pointLeft->setPointStyle (pointStyle);
00338
00339
00340 GraphicsPoint *pointCenter = pointFactory.createPoint (*m_scenePreview,
00341 NULL_IDENTIFIER,
00342 POS_CENTER,
00343 pointStyle);
00344 pointCenter->setPointStyle (pointStyle);
00345
00346
00347 GraphicsPoint *pointRight = pointFactory.createPoint (*m_scenePreview,
00348 NULL_IDENTIFIER,
00349 POS_RIGHT,
00350 pointStyle);
00351 pointRight->setPointStyle (pointStyle);
00352 }
00353
00354 void DlgSettingsCurveProperties::handleOk ()
00355 {
00356 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::handleOk";
00357
00358 ENGAUGE_CHECK_PTR (m_modelCurveStylesBefore);
00359 ENGAUGE_CHECK_PTR (m_modelCurveStylesAfter);
00360
00361 CmdSettingsCurveProperties *cmd = new CmdSettingsCurveProperties (mainWindow (),
00362 cmdMediator ().document(),
00363 *m_modelCurveStylesBefore,
00364 *m_modelCurveStylesAfter);
00365 cmdMediator ().push (cmd);
00366
00367 hide ();
00368 }
00369
00370 void DlgSettingsCurveProperties::load (CmdMediator &cmdMediator)
00371 {
00372 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::load";
00373
00374 setCmdMediator (cmdMediator);
00375
00376
00377 if (m_modelCurveStylesBefore != 0) {
00378 delete m_modelCurveStylesBefore;
00379 }
00380 if (m_modelCurveStylesAfter != 0) {
00381 delete m_modelCurveStylesAfter;
00382 }
00383
00384
00385 m_modelCurveStylesBefore = new CurveStyles (cmdMediator.coordSystem());
00386 m_modelCurveStylesAfter = new CurveStyles (cmdMediator.coordSystem());
00387
00388
00389 m_cmbCurveName->clear ();
00390 m_cmbCurveName->addItem (AXIS_CURVE_NAME);
00391 QStringList curveNames = cmdMediator.curvesGraphsNames();
00392 QStringList::const_iterator itr;
00393 for (itr = curveNames.begin (); itr != curveNames.end (); itr++) {
00394
00395 QString curveName = *itr;
00396 m_cmbCurveName->addItem (curveName);
00397 }
00398
00399 loadForCurveName (mainWindow().selectedGraphCurve());
00400
00401 m_isDirty = false;
00402 enableOk (false);
00403 }
00404
00405 void DlgSettingsCurveProperties::loadForCurveName (const QString &curveName)
00406 {
00407 int indexCurveName = m_cmbCurveName->findText(curveName);
00408 ENGAUGE_ASSERT (indexCurveName >= 0);
00409 m_cmbCurveName->setCurrentIndex(indexCurveName);
00410
00411 int indexPointShape = m_cmbPointShape->findData (QVariant (m_modelCurveStylesAfter->pointShape (curveName)));
00412 ENGAUGE_ASSERT (indexPointShape >= 0);
00413 m_cmbPointShape->setCurrentIndex (indexPointShape);
00414
00415 m_spinPointRadius->setValue (m_modelCurveStylesAfter->pointRadius(curveName));
00416 m_spinPointLineWidth->setValue (m_modelCurveStylesAfter->pointLineWidth(curveName));
00417
00418 int indexPointColor = m_cmbPointColor->findData (QVariant (m_modelCurveStylesAfter->pointColor(curveName)));
00419 ENGAUGE_ASSERT (indexPointColor >= 0);
00420 m_cmbPointColor->setCurrentIndex (indexPointColor);
00421
00422 int indexLineColor = m_cmbLineColor->findData (QVariant (m_modelCurveStylesAfter->lineColor(curveName)));
00423 ENGAUGE_ASSERT (indexLineColor >= 0);
00424 m_cmbLineColor->setCurrentIndex (indexLineColor);
00425
00426 m_spinLineWidth->setValue (m_modelCurveStylesAfter->lineWidth(curveName));
00427
00428 int indexCurveConnectAs = m_cmbLineType->findData (QVariant (m_modelCurveStylesAfter->lineConnectAs (curveName)));
00429 if (indexCurveConnectAs >= 0) {
00430
00431 m_cmbLineType->setCurrentIndex (indexCurveConnectAs);
00432 }
00433
00434
00435 m_cmbLineColor->setEnabled (curveName != AXIS_CURVE_NAME);
00436 m_spinLineWidth->setEnabled (curveName != AXIS_CURVE_NAME);
00437 m_cmbLineType->setEnabled (curveName != AXIS_CURVE_NAME);
00438
00439 updateControls();
00440 updatePreview();
00441 }
00442
00443 void DlgSettingsCurveProperties::resetSceneRectangle ()
00444 {
00445
00446 QRect rect (0.0,
00447 0.0,
00448 PREVIEW_WIDTH,
00449 PREVIEW_HEIGHT);
00450
00451 QGraphicsRectItem *itemPerimeter = new QGraphicsRectItem(rect);
00452 itemPerimeter->setVisible(false);
00453 m_scenePreview->addItem (itemPerimeter);
00454 m_viewPreview->centerOn (QPointF (0.0, 0.0));
00455 }
00456
00457 void DlgSettingsCurveProperties::setCurveName (const QString &curveName)
00458 {
00459 m_cmbCurveName->setCurrentText (curveName);
00460 loadForCurveName (curveName);
00461 }
00462
00463 void DlgSettingsCurveProperties::slotCurveName(const QString &curveName)
00464 {
00465 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotCurveName";
00466
00467
00468
00469
00470 if (!curveName.isEmpty () && (m_modelCurveStylesAfter != 0)) {
00471
00472 loadForCurveName (curveName);
00473 }
00474 }
00475
00476 void DlgSettingsCurveProperties::slotLineColor(const QString &lineColor)
00477 {
00478 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotLineColor color=" << lineColor.toLatin1().data();
00479
00480 m_isDirty = true;
00481
00482 m_modelCurveStylesAfter->setLineColor(m_cmbCurveName->currentText(),
00483 (ColorPalette) m_cmbLineColor->currentData().toInt());
00484 updateControls();
00485 updatePreview();
00486 }
00487
00488 void DlgSettingsCurveProperties::slotLineWidth(int width)
00489 {
00490 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotLineWidth width=" << width;
00491
00492 m_isDirty = true;
00493
00494 m_modelCurveStylesAfter->setLineWidth(m_cmbCurveName->currentText(),
00495 width);
00496 updateControls ();
00497 updatePreview();
00498 }
00499
00500 void DlgSettingsCurveProperties::slotLineType(const QString &lineType)
00501 {
00502 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotLineType lineType=" << lineType.toLatin1().data();
00503
00504 m_isDirty = true;
00505
00506 m_modelCurveStylesAfter->setLineConnectAs(m_cmbCurveName->currentText(),
00507 (CurveConnectAs) m_cmbLineType->currentData().toInt ());
00508 updateControls();
00509 updatePreview();
00510 }
00511
00512 void DlgSettingsCurveProperties::slotPointColor(const QString &pointColor)
00513 {
00514 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointColor pointColor=" << pointColor.toLatin1().data();
00515
00516 m_isDirty = true;
00517
00518 m_modelCurveStylesAfter->setPointColor(m_cmbCurveName->currentText(),
00519 (ColorPalette) m_cmbPointColor->currentData().toInt ());
00520 updateControls();
00521 updatePreview();
00522 }
00523
00524 void DlgSettingsCurveProperties::slotPointLineWidth(int lineWidth)
00525 {
00526 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointLineWidth lineWidth=" << lineWidth;
00527
00528 m_isDirty = true;
00529
00530 m_modelCurveStylesAfter->setPointLineWidth(m_cmbCurveName->currentText(),
00531 lineWidth);
00532 updateControls();
00533 updatePreview();
00534 }
00535
00536 void DlgSettingsCurveProperties::slotPointRadius(int radius)
00537 {
00538 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointRadius radius=" << radius;
00539
00540 m_isDirty = true;
00541
00542 m_modelCurveStylesAfter->setPointRadius(m_cmbCurveName->currentText(),
00543 radius);
00544 updateControls();
00545 updatePreview();
00546 }
00547
00548 void DlgSettingsCurveProperties::slotPointShape(const QString &)
00549 {
00550 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointShape";
00551
00552 m_isDirty = true;
00553
00554 m_modelCurveStylesAfter->setPointShape(m_cmbCurveName->currentText(),
00555 (PointShape) m_cmbPointShape->currentData().toInt ());
00556 updateControls();
00557 updatePreview();
00558 }
00559
00560 void DlgSettingsCurveProperties::slotSaveDefault()
00561 {
00562 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotSaveDefault";
00563
00564 QString curve = m_cmbCurveName->currentText ();
00565
00566 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
00567 if (curve == AXIS_CURVE_NAME) {
00568
00569 settings.beginGroup (SETTINGS_GROUP_CURVE_AXES);
00570
00571 } else {
00572
00573 SettingsForGraph settingsForGraph;
00574 QString groupName = settingsForGraph.groupNameForNthCurve(m_cmbCurveName->currentIndex());
00575 settings.beginGroup (groupName);
00576
00577 }
00578
00579 settings.setValue (SETTINGS_CURVE_POINT_SHAPE,
00580 m_modelCurveStylesAfter->pointShape(curve));
00581 settings.setValue (SETTINGS_CURVE_LINE_COLOR,
00582 m_modelCurveStylesAfter->lineColor(curve));
00583 settings.setValue (SETTINGS_CURVE_LINE_CONNECT_AS,
00584 m_modelCurveStylesAfter->lineConnectAs(curve));
00585 settings.setValue (SETTINGS_CURVE_LINE_WIDTH,
00586 m_modelCurveStylesAfter->lineWidth(curve));
00587 settings.setValue (SETTINGS_CURVE_POINT_COLOR,
00588 m_modelCurveStylesAfter->pointColor (curve));
00589 settings.setValue (SETTINGS_CURVE_POINT_LINE_WIDTH,
00590 m_modelCurveStylesAfter->pointLineWidth(curve));
00591 settings.setValue (SETTINGS_CURVE_POINT_RADIUS,
00592 m_modelCurveStylesAfter->pointRadius(curve));
00593 settings.endGroup ();
00594 }
00595
00596 void DlgSettingsCurveProperties::updateControls()
00597 {
00598 bool isGoodState = !m_spinPointRadius->text().isEmpty () &&
00599 !m_spinPointLineWidth->text().isEmpty () &&
00600 !m_spinLineWidth->text().isEmpty ();
00601 m_cmbCurveName->setEnabled (isGoodState);
00602 enableOk (isGoodState && m_isDirty);
00603 }
00604
00605 void DlgSettingsCurveProperties::updatePreview()
00606 {
00607 m_scenePreview->clear();
00608
00609 QString currentCurve = m_cmbCurveName->currentText();
00610
00611 const PointStyle pointStyle = m_modelCurveStylesAfter->curveStyle (currentCurve).pointStyle();
00612 const LineStyle lineStyle = m_modelCurveStylesAfter->curveStyle (currentCurve).lineStyle();
00613
00614
00615 bool isRelation = (lineStyle.curveConnectAs() == CONNECT_AS_RELATION_SMOOTH ||
00616 lineStyle.curveConnectAs() == CONNECT_AS_RELATION_STRAIGHT);
00617
00618 drawPoints (pointStyle);
00619 drawLine (isRelation,
00620 lineStyle);
00621
00622 resetSceneRectangle();
00623 }