Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
DlgSettingsCurveProperties.cpp
1 #include "CmdMediator.h"
2 #include "CmdSettingsCurveProperties.h"
3 #include "ColorPalette.h"
4 #include "DlgSettingsCurveProperties.h"
5 #include "EngaugeAssert.h"
6 #include "EnumsToQt.h"
7 #include "GraphicsPoint.h"
8 #include "GraphicsPointFactory.h"
9 #include "GraphicsView.h"
10 #include "Logger.h"
11 #include "MainWindow.h"
12 #include <QComboBox>
13 #include <QDebug>
14 #include <QGraphicsRectItem>
15 #include <QGraphicsScene>
16 #include <QGridLayout>
17 #include <QGroupBox>
18 #include <QLabel>
19 #include <QLineEdit>
20 #include <QListWidget>
21 #include <QPen>
22 #include <QPushButton>
23 #include <QSpinBox>
24 #include <QTransform>
25 #include "Spline.h"
26 #include "SplinePair.h"
27 #include <vector>
28 #include "ViewPreview.h"
29 
30 using namespace std;
31 
32 const QString CONNECT_AS_FUNCTION_SMOOTH_STR ("Function - Smooth");
33 const QString CONNECT_AS_FUNCTION_STRAIGHT_STR ("Function - Straight");
34 const QString CONNECT_AS_RELATION_SMOOTH_STR ("Relation - Smooth");
35 const QString CONNECT_AS_RELATION_STRAIGHT_STR ("Relation - Straight");
36 
37 const double PREVIEW_WIDTH = 100.0;
38 const double PREVIEW_HEIGHT = 100.0;
39 
40 const QPointF POS_LEFT (PREVIEW_WIDTH / 3.0,
41  PREVIEW_HEIGHT * 2.0 / 3.0);
42 const QPointF POS_CENTER (PREVIEW_WIDTH / 2.0,
43  PREVIEW_HEIGHT / 3.0);
44 const QPointF POS_RIGHT (2.0 * PREVIEW_WIDTH / 3.0,
45  PREVIEW_HEIGHT * 2.0 / 3.0);
46 
48  DlgSettingsAbstractBase ("Curve Properties",
49  "DlgSettingsCurveProperties",
50  mainWindow),
51  m_scenePreview (0),
52  m_viewPreview (0),
53  m_modelCurveStylesBefore (0),
54  m_modelCurveStylesAfter (0)
55 {
56  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::DlgSettingsCurveProperties";
57 
58  QWidget *subPanel = createSubPanel ();
59  finishPanel (subPanel);
60 
61  setMinimumWidth (740); // Override finishPanel width for room for m_cmbLineType and preview to be completely visible
62 }
63 
64 DlgSettingsCurveProperties::~DlgSettingsCurveProperties()
65 {
66  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::~DlgSettingsCurveProperties";
67 }
68 
69 void DlgSettingsCurveProperties::createCurveName (QGridLayout *layout,
70  int &row)
71 {
72  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createCurveName";
73 
74  QLabel *labelCurveName = new QLabel ("Curve Name:");
75  layout->addWidget (labelCurveName, row, 1);
76 
77  m_cmbCurveName = new QComboBox ();
78  m_cmbCurveName->setWhatsThis (tr ("Name of the curve that is currently selected for editing"));
79  connect (m_cmbCurveName, SIGNAL (activated (const QString &)), this, SLOT (slotCurveName (const QString &))); // activated() ignores code changes
80  layout->addWidget (m_cmbCurveName, row++, 2);
81 }
82 
83 void DlgSettingsCurveProperties::createLine (QGridLayout *layout,
84  int &row)
85 {
86  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createLine";
87 
88  m_groupLine = new QGroupBox ("Line");
89  layout->addWidget (m_groupLine, row++, 2);
90 
91  QGridLayout *layoutGroup = new QGridLayout;
92  m_groupLine->setLayout (layoutGroup);
93 
94  QLabel *labelLineWidth = new QLabel ("Width:");
95  layoutGroup->addWidget (labelLineWidth, 0, 0);
96 
97  m_spinLineWidth = new QSpinBox (m_groupLine);
98  m_spinLineWidth->setWhatsThis (tr ("Select a width for the lines drawn between points.\n\n"
99  "This applies only to graph curves. No lines are ever drawn between axis points."));
100  m_spinLineWidth->setMinimum(1);
101  connect (m_spinLineWidth, SIGNAL (valueChanged (int)), this, SLOT (slotLineWidth (int)));
102  layoutGroup->addWidget (m_spinLineWidth, 0, 1);
103 
104  QLabel *labelLineColor = new QLabel ("Color:");
105  layoutGroup->addWidget (labelLineColor, 1, 0);
106 
107  m_cmbLineColor = new QComboBox (m_groupLine);
108  m_cmbLineColor->setWhatsThis (tr ("Select a color for the lines drawn between points.\n\n"
109  "This applies only to graph curves. No lines are ever drawn between axis points."));
110  populateColorComboWithTransparent (*m_cmbLineColor);
111  connect (m_cmbLineColor, SIGNAL (activated (const QString &)), this, SLOT (slotLineColor (const QString &))); // activated() ignores code changes
112  layoutGroup->addWidget (m_cmbLineColor, 1, 1);
113 
114  QLabel *labelLineType = new QLabel ("Connect as:");
115  layoutGroup->addWidget (labelLineType, 2, 0);
116 
117  m_cmbLineType = new QComboBox (m_groupLine);
118  m_cmbLineType->addItem (CONNECT_AS_FUNCTION_STRAIGHT_STR, QVariant (CONNECT_AS_FUNCTION_STRAIGHT));
119  m_cmbLineType->addItem (CONNECT_AS_FUNCTION_SMOOTH_STR, QVariant (CONNECT_AS_FUNCTION_SMOOTH));
120  m_cmbLineType->addItem (CONNECT_AS_RELATION_STRAIGHT_STR, QVariant (CONNECT_AS_RELATION_STRAIGHT));
121  m_cmbLineType->addItem (CONNECT_AS_RELATION_SMOOTH_STR, QVariant (CONNECT_AS_RELATION_SMOOTH));
122  m_cmbLineType->setWhatsThis (tr ("Select rule for connecting points with lines.\n\n"
123  "If the curve is connected as a single-valued function then the points are ordered by "
124  "increasing value of the independent variable.\n\n"
125  "If the curve is connected as a closed contour, then the points are ordered by age, except for "
126  "points placed along an existing line. Any point placed on top of any existing line is inserted "
127  "between the two endpoints of that line - as if its age was between the ages of the two "
128  "endpoints.\n\n"
129  "Lines are drawn between successively ordered points.\n\n"
130  "Straight curves are drawn with straight lines between successive points. Smooth curves are drawn "
131  "with smooth lines between successive points.\n\n"
132  "This applies only to graph curves. No lines are ever drawn between axis points."));
133  connect (m_cmbLineType, SIGNAL (activated (const QString &)), this, SLOT (slotLineType (const QString &))); // activated() ignores code changes
134  layoutGroup->addWidget (m_cmbLineType, 2, 1);
135 }
136 
137 void DlgSettingsCurveProperties::createPoint (QGridLayout *layout,
138  int &row)
139 {
140  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createPoint";
141 
142  m_groupPoint = new QGroupBox ("Point");
143  layout->addWidget (m_groupPoint, row++, 1);
144 
145  QGridLayout *layoutGroup = new QGridLayout;
146  m_groupPoint->setLayout (layoutGroup);
147 
148  QLabel *labelPointShape = new QLabel("Shape:");
149  layoutGroup->addWidget (labelPointShape, 0, 0);
150 
151  m_cmbPointShape = new QComboBox (m_groupPoint);
152  m_cmbPointShape->setWhatsThis (tr ("Select a shape for the points"));
153  m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_CIRCLE),
154  POINT_SHAPE_CIRCLE);
155  m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_CROSS),
156  POINT_SHAPE_CROSS);
157  m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_DIAMOND),
158  POINT_SHAPE_DIAMOND);
159  m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_SQUARE),
160  POINT_SHAPE_SQUARE);
161  m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_TRIANGLE),
162  POINT_SHAPE_TRIANGLE);
163  m_cmbPointShape->addItem (pointShapeToString (POINT_SHAPE_X),
164  POINT_SHAPE_X);
165  connect (m_cmbPointShape, SIGNAL (activated (const QString &)), this, SLOT (slotPointShape (const QString &))); // activated() ignores code changes
166  layoutGroup->addWidget (m_cmbPointShape, 0, 1);
167 
168  QLabel *labelPointRadius = new QLabel ("Radius:");
169  layoutGroup->addWidget (labelPointRadius, 1, 0);
170 
171  m_spinPointRadius = new QSpinBox (m_groupPoint);
172  m_spinPointRadius->setWhatsThis (tr ("Select a radius, in pixels, for the points"));
173  m_spinPointRadius->setMinimum (1);
174  connect (m_spinPointRadius, SIGNAL (valueChanged (int)), this, SLOT (slotPointRadius (int)));
175  layoutGroup->addWidget (m_spinPointRadius, 1, 1);
176 
177  QLabel *labelPointLineWidth = new QLabel ("Line width:");
178  layoutGroup->addWidget (labelPointLineWidth, 2, 0);
179 
180  m_spinPointLineWidth = new QSpinBox (m_groupPoint);
181  m_spinPointLineWidth->setWhatsThis (tr ("Select a line width, in pixels, for the points.\n\n"
182  "A larger width results in a thicker line, with the exception of a value of zero "
183  "which always results in a line that is one pixel wide (which is easy to see even "
184  "when zoomed far out)"));
185  m_spinPointLineWidth->setMinimum (0);
186  connect (m_spinPointLineWidth, SIGNAL (valueChanged (int)), this, SLOT (slotPointLineWidth (int)));
187  layoutGroup->addWidget (m_spinPointLineWidth, 2, 1);
188 
189  QLabel *labelPointColor = new QLabel ("Color:");
190  layoutGroup->addWidget (labelPointColor, 3, 0);
191 
192  m_cmbPointColor = new QComboBox (m_groupPoint);
193  m_cmbPointColor->setWhatsThis (tr ("Select a color for the line used to draw the point shapes"));
194  populateColorComboWithoutTransparent (*m_cmbPointColor);
195  connect (m_cmbPointColor, SIGNAL (activated (const QString &)), this, SLOT (slotPointColor (const QString &))); // activated() ignores code changes
196  layoutGroup->addWidget (m_cmbPointColor, 3, 1);
197 }
198 
199 void DlgSettingsCurveProperties::createPreview (QGridLayout *layout,
200  int &row)
201 {
202  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createPreview";
203 
204  QLabel *labelPreview = new QLabel ("Preview");
205  layout->addWidget (labelPreview, row++, 0, 1, 4);
206 
207  m_scenePreview = new QGraphicsScene (this);
208  m_viewPreview = new ViewPreview (m_scenePreview,
209  ViewPreview::VIEW_ASPECT_RATIO_ONE_TO_ONE,
210  this);
211  m_viewPreview->setWhatsThis (tr ("Preview window that shows how current settings affect the points and line of the selected curve.\n\n"
212  "The X coordinate is in the horizontal direction, and the Y coordinate is in the vertical direction. A "
213  "function can have only one Y value, at most, for any X value, but a relation can have multiple Y values "
214  "for one X value."));
215  m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
216  m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
217  m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
218  m_viewPreview->setRenderHint (QPainter::Antialiasing);
219 
220  layout->addWidget (m_viewPreview, row++, 0, 1, 4);
221 }
222 
224 {
225  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::createSubPanel";
226 
227  QWidget *subPanel = new QWidget ();
228  QGridLayout *layout = new QGridLayout (subPanel);
229  subPanel->setLayout (layout);
230 
231  int row = 0;
232  createCurveName (layout, row);
233 
234  int rowLeft = row, rowRight = row;
235  createPoint (layout, rowLeft);
236  createLine (layout, rowRight);
237 
238  row = qMax (rowLeft, rowRight);
239  createPreview (layout, row);
240 
241  layout->setColumnStretch(0, 1); // Empty first column
242  layout->setColumnStretch(1, 0); // Point group
243  layout->setColumnStretch(2, 0); // Line group
244  layout->setColumnStretch(3, 1); // Empty last column
245 
246  layout->setRowStretch (0, 1); // Expand empty first row
247 
248  return subPanel;
249 }
250 
251 void DlgSettingsCurveProperties::drawLine (bool isRelation,
252  const LineStyle &lineStyle)
253 {
254  const double Z_LINE = -1.0; // Looks nicer if line goes under the points, so points are unobscured
255 
256  // Line between points. Start with function connection
257  QPainterPath path;
258  QPointF p0 (POS_LEFT), p1 (POS_CENTER), p2 (POS_RIGHT);
259  if (isRelation) {
260 
261  // Relation connection
262  p1 = POS_RIGHT;
263  p2 = POS_CENTER;
264  }
265 
266  // Draw straight or smooth
267  if (lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_SMOOTH ||
268  lineStyle.curveConnectAs() == CONNECT_AS_RELATION_SMOOTH) {
269 
270  vector<double> t;
271  vector<SplinePair> xy;
272  t.push_back(0);
273  t.push_back(1);
274  t.push_back(2);
275  xy.push_back (SplinePair (p0.x(), p0.y()));
276  xy.push_back (SplinePair (p1.x(), p1.y()));
277  xy.push_back (SplinePair (p2.x(), p2.y()));
278  Spline spline (t, xy);
279  path.moveTo (p0);
280  path.cubicTo (QPointF (spline.p1(0).x(),
281  spline.p1(0).y()),
282  QPointF (spline.p2(0).x(),
283  spline.p2(0).y()),
284  p1);
285  path.cubicTo (QPointF (spline.p1(1).x(),
286  spline.p1(1).y()),
287  QPointF (spline.p2(1).x(),
288  spline.p2(1).y()),
289  p2);
290  } else {
291  path.moveTo (p0);
292  path.lineTo (p1);
293  path.lineTo (p2);
294  }
295 
296  QGraphicsPathItem *line = new QGraphicsPathItem (path);
297  line->setPen (QPen (QBrush (ColorPaletteToQColor (lineStyle.paletteColor())),
298  lineStyle.width()));
299  line->setZValue (Z_LINE);
300  m_scenePreview->addItem (line);
301 }
302 
303 void DlgSettingsCurveProperties::drawPoints (const PointStyle &pointStyle)
304 {
305  const QString NULL_IDENTIFIER;
306 
307  GraphicsPointFactory pointFactory;
308 
309  // Left point
310  GraphicsPoint *pointLeft = pointFactory.createPoint (*m_scenePreview,
311  NULL_IDENTIFIER,
312  POS_LEFT,
313  pointStyle);
314  pointLeft->setPointStyle (pointStyle);
315 
316  // Center point
317  GraphicsPoint *pointCenter = pointFactory.createPoint (*m_scenePreview,
318  NULL_IDENTIFIER,
319  POS_CENTER,
320  pointStyle);
321  pointCenter->setPointStyle (pointStyle);
322 
323  // Right point
324  GraphicsPoint *pointRight = pointFactory.createPoint (*m_scenePreview,
325  NULL_IDENTIFIER,
326  POS_RIGHT,
327  pointStyle);
328  pointRight->setPointStyle (pointStyle);
329 }
330 
332 {
333  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::handleOk";
334 
335  ENGAUGE_CHECK_PTR (m_modelCurveStylesBefore);
336  ENGAUGE_CHECK_PTR (m_modelCurveStylesAfter);
337 
339  cmdMediator ().document(),
340  *m_modelCurveStylesBefore,
341  *m_modelCurveStylesAfter);
342  cmdMediator ().push (cmd);
343 
344  hide ();
345 }
346 
348 {
349  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::load";
350 
351  setCmdMediator (cmdMediator);
352 
353  // Flush old data
354  if (m_modelCurveStylesBefore != 0) {
355  delete m_modelCurveStylesBefore;
356  }
357  if (m_modelCurveStylesAfter != 0) {
358  delete m_modelCurveStylesAfter;
359  }
360 
361  // Save new data
362  m_modelCurveStylesBefore = new CurveStyles (cmdMediator.document());
363  m_modelCurveStylesAfter = new CurveStyles (cmdMediator.document());
364 
365  // Populate controls. First load curve name combobox. The curve-specific controls get loaded in slotCurveName
366  m_cmbCurveName->clear ();
367  m_cmbCurveName->addItem (AXIS_CURVE_NAME);
368  QStringList curveNames = cmdMediator.curvesGraphsNames();
369  QStringList::const_iterator itr;
370  for (itr = curveNames.begin (); itr != curveNames.end (); itr++) {
371 
372  QString curveName = *itr;
373  m_cmbCurveName->addItem (curveName);
374  }
375 
376  loadForCurveName (mainWindow().selectedGraphCurve());
377 
378  m_isDirty = false;
379  enableOk (false); // Disable Ok button since there not yet any changes
380 }
381 
382 void DlgSettingsCurveProperties::loadForCurveName (const QString &curveName)
383 {
384  int indexCurveName = m_cmbCurveName->findText(curveName);
385  ENGAUGE_ASSERT (indexCurveName >= 0);
386  m_cmbCurveName->setCurrentIndex(indexCurveName);
387 
388  int indexPointShape = m_cmbPointShape->findData (QVariant (m_modelCurveStylesAfter->pointShape (curveName)));
389  ENGAUGE_ASSERT (indexPointShape >= 0);
390  m_cmbPointShape->setCurrentIndex (indexPointShape);
391 
392  m_spinPointRadius->setValue (m_modelCurveStylesAfter->pointRadius(curveName));
393  m_spinPointLineWidth->setValue (m_modelCurveStylesAfter->pointLineWidth(curveName));
394 
395  int indexPointColor = m_cmbPointColor->findData (QVariant (m_modelCurveStylesAfter->pointColor(curveName)));
396  ENGAUGE_ASSERT (indexPointColor >= 0);
397  m_cmbPointColor->setCurrentIndex (indexPointColor);
398 
399  int indexLineColor = m_cmbLineColor->findData (QVariant (m_modelCurveStylesAfter->lineColor(curveName)));
400  ENGAUGE_ASSERT (indexLineColor >= 0);
401  m_cmbLineColor->setCurrentIndex (indexLineColor);
402 
403  m_spinLineWidth->setValue (m_modelCurveStylesAfter->lineWidth(curveName));
404 
405  int indexCurveConnectAs = m_cmbLineType->findData (QVariant (m_modelCurveStylesAfter->lineConnectAs (curveName)));
406  if (indexCurveConnectAs >= 0) {
407  // Value is not CONNECT_SKIP_FOR_AXIS_CURVE
408  m_cmbLineType->setCurrentIndex (indexCurveConnectAs);
409  }
410 
411  // Disable line controls for axis curve since connecting with visible lines is better handled by Checker class
412  m_cmbLineColor->setEnabled (curveName != AXIS_CURVE_NAME);
413  m_spinLineWidth->setEnabled (curveName != AXIS_CURVE_NAME);
414  m_cmbLineType->setEnabled (curveName != AXIS_CURVE_NAME);
415 
416  updateControls();
417  updatePreview();
418 }
419 
420 void DlgSettingsCurveProperties::resetSceneRectangle ()
421 {
422 
423  QRect rect (0.0,
424  0.0,
425  PREVIEW_WIDTH,
426  PREVIEW_HEIGHT);
427 
428  QGraphicsRectItem *itemPerimeter = new QGraphicsRectItem(rect);
429  itemPerimeter->setVisible(false);
430  m_scenePreview->addItem (itemPerimeter);
431  m_viewPreview->centerOn (QPointF (0.0, 0.0));
432 }
433 
434 void DlgSettingsCurveProperties::setCurveName (const QString &curveName)
435 {
436  m_cmbCurveName->setCurrentText (curveName);
437  loadForCurveName (curveName);
438 }
439 
440 void DlgSettingsCurveProperties::slotCurveName(const QString &curveName)
441 {
442  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotCurveName";
443 
444  // Dirty flag is not set when simply changing to new curve
445 
446  // Do nothing if combobox is getting cleared, or load has not been called yet
447  if (!curveName.isEmpty () && (m_modelCurveStylesAfter != 0)) {
448 
449  loadForCurveName (curveName);
450  }
451 }
452 
453 void DlgSettingsCurveProperties::slotLineColor(const QString &lineColor)
454 {
455  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotLineColor color=" << lineColor.toLatin1().data();
456 
457  m_isDirty = true;
458 
459  m_modelCurveStylesAfter->setLineColor(m_cmbCurveName->currentText(),
460  (ColorPalette) m_cmbLineColor->currentData().toInt());
461  updateControls();
462  updatePreview();
463 }
464 
465 void DlgSettingsCurveProperties::slotLineWidth(int width)
466 {
467  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotLineWidth width=" << width;
468 
469  m_isDirty = true;
470 
471  m_modelCurveStylesAfter->setLineWidth(m_cmbCurveName->currentText(),
472  width);
473  updateControls ();
474  updatePreview();
475 }
476 
477 void DlgSettingsCurveProperties::slotLineType(const QString &lineType)
478 {
479  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotLineType lineType=" << lineType.toLatin1().data();
480 
481  m_isDirty = true;
482 
483  m_modelCurveStylesAfter->setLineConnectAs(m_cmbCurveName->currentText(),
484  (CurveConnectAs) m_cmbLineType->currentData().toInt ());
485  updateControls();
486  updatePreview();
487 }
488 
489 void DlgSettingsCurveProperties::slotPointColor(const QString &pointColor)
490 {
491  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointColor pointColor=" << pointColor.toLatin1().data();
492 
493  m_isDirty = true;
494 
495  m_modelCurveStylesAfter->setPointColor(m_cmbCurveName->currentText(),
496  (ColorPalette) m_cmbPointColor->currentData().toInt ());
497  updateControls();
498  updatePreview();
499 }
500 
501 void DlgSettingsCurveProperties::slotPointLineWidth(int lineWidth)
502 {
503  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointLineWidth lineWidth=" << lineWidth;
504 
505  m_isDirty = true;
506 
507  m_modelCurveStylesAfter->setPointLineWidth(m_cmbCurveName->currentText(),
508  lineWidth);
509  updateControls();
510  updatePreview();
511 }
512 
513 void DlgSettingsCurveProperties::slotPointRadius(int radius)
514 {
515  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointRadius radius=" << radius;
516 
517  m_isDirty = true;
518 
519  m_modelCurveStylesAfter->setPointRadius(m_cmbCurveName->currentText(),
520  radius);
521  updateControls();
522  updatePreview();
523 }
524 
525 void DlgSettingsCurveProperties::slotPointShape(const QString &)
526 {
527  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsCurveProperties::slotPointShape";
528 
529  m_isDirty = true;
530 
531  m_modelCurveStylesAfter->setPointShape(m_cmbCurveName->currentText(),
532  (PointShape) m_cmbPointShape->currentData().toInt ());
533  updateControls();
534  updatePreview();
535 }
536 
537 void DlgSettingsCurveProperties::updateControls()
538 {
539  bool isGoodState = !m_spinPointRadius->text().isEmpty () &&
540  !m_spinPointLineWidth->text().isEmpty () &&
541  !m_spinLineWidth->text().isEmpty ();
542  m_cmbCurveName->setEnabled (isGoodState); // User needs to fix state before switching curves
543  enableOk (isGoodState && m_isDirty);
544 }
545 
546 void DlgSettingsCurveProperties::updatePreview()
547 {
548  m_scenePreview->clear();
549 
550  QString currentCurve = m_cmbCurveName->currentText();
551 
552  const PointStyle pointStyle = m_modelCurveStylesAfter->curveStyle (currentCurve).pointStyle();
553  const LineStyle lineStyle = m_modelCurveStylesAfter->curveStyle (currentCurve).lineStyle();
554 
555  // Function or relation?
556  bool isRelation = (lineStyle.curveConnectAs() == CONNECT_AS_RELATION_SMOOTH ||
557  lineStyle.curveConnectAs() == CONNECT_AS_RELATION_STRAIGHT);
558 
559  drawPoints (pointStyle);
560  drawLine (isRelation,
561  lineStyle);
562 
563  resetSceneRectangle();
564 }
void setLineColor(const QString &curveName, ColorPalette lineColor)
Set method for line color in specified curve.
Factor for generating GraphicsPointAbstractBase class objects.
void setLineConnectAs(const QString &curveName, CurveConnectAs curveConnectAs)
Set method for connect as method for lines in specified curve.
void setCurveName(const QString &curveName)
Load information for the specified curve name. When called externally, the load method must have been...
void setLineWidth(const QString &curveName, int width)
Set method for line width in specified curve.
unsigned int width() const
Width of line.
Definition: LineStyle.cpp:131
Cubic interpolation given independent and dependent value vectors.
Definition: Spline.h:15
void setPointLineWidth(const QString &curveName, int width)
Set method for curve point perimeter line width.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
Definition: CurveStyles.h:16
GraphicsPoint * createPoint(QGraphicsScene &scene, const QString &identifier, const QPointF &posScreen, const PointStyle &pointStyle)
Create circle or polygon point according to the PointStyle.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
LineStyle lineStyle() const
Get method for LineStyle.
Definition: CurveStyle.cpp:20
int pointRadius(const QString &curveName) const
Get method for curve point radius.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
Command for DlgSettingsCurveProperties.
PointStyle pointStyle() const
Get method for PointStyle.
Definition: CurveStyle.cpp:69
DlgSettingsCurveProperties(MainWindow &mainWindow)
Single constructor.
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:61
virtual void handleOk()
Process slotOk.
void setPointStyle(const PointStyle &pointStyle)
Update the point style.
int lineWidth(const QString &curveName) const
Get method for line width in specified curve.
Definition: CurveStyles.cpp:95
ColorPalette lineColor(const QString &curveName) const
Get method for line color in specified curve.
Definition: CurveStyles.cpp:78
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
Definition: ViewPreview.h:8
Details for a specific Point.
Definition: PointStyle.h:14
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
CurveConnectAs lineConnectAs(const QString &curveName) const
Get method for connect as method for lines in specified curve.
Definition: CurveStyles.cpp:84
void populateColorComboWithoutTransparent(QComboBox &combo)
Add colors in color palette to combobox, without transparent entry at end.
Details for a specific Line.
Definition: LineStyle.h:13
PointShape pointShape(const QString &curveName) const
Get method for curve point shape.
Graphics item for drawing a circular or polygonal Point.
Definition: GraphicsPoint.h:33
ColorPalette pointColor(const QString &curveName) const
Get method for curve point color in specified curve.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
void setPointRadius(const QString &curveName, int radius)
Set method for curve point radius.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
int pointLineWidth(const QString &curveName) const
Get method for curve point line width.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
ColorPalette paletteColor() const
Line color.
Definition: LineStyle.cpp:86
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
Definition: CurveStyles.cpp:72
Command queue stack.
Definition: CmdMediator.h:16
void populateColorComboWithTransparent(QComboBox &combo)
Add colors in color palette to combobox, with transparent entry at end.
Abstract base class for all Settings dialogs.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Definition: LineStyle.cpp:43
void setPointShape(const QString &curveName, PointShape shape)
Set method for curve point shape in specified curve.
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:60
Single X/Y pair for cubic spline interpolation initialization and calculations.
Definition: SplinePair.h:5
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Definition: CmdMediator.cpp:51
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void setPointColor(const QString &curveName, ColorPalette curveColor)
Set method curve point color in specified curve.