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