18#include <QGraphicsScene>
35const double TWOPI = 2.0 * 3.1415926535;
41 "DlgSettingsSegments",
45 m_modelSegmentsBefore (
nullptr),
60void DlgSettingsSegments::clearPoints ()
64 QList<GraphicsPoint*>::iterator
itrP;
65 for (
itrP = m_points.begin();
itrP != m_points.end();
itrP++) {
83 m_spinMinLength->setWhatsThis (
tr (
"Select a minimum number of points in a segment.\n\n"
84 "Only segments with more points will be created.\n\n"
85 "This value should be as large as possible to reduce memory usage. This value has "
88 layout->addWidget(m_spinMinLength,
row++, 2);
93 m_spinPointSeparation =
new QSpinBox;
95 m_spinPointSeparation->setWhatsThis (
tr (
"Select a point separation in pixels.\n\n"
96 "Successive points added to a segment will be separated by this number of pixels. "
97 "If Fill Corners is enabled, then additional points will be inserted at corners so some points "
99 "This value has a lower limit"));
101 layout->addWidget (m_spinPointSeparation,
row++, 2);
107 m_chkFillCorners->setWhatsThis (
tr (
"Fill corners.\n\n"
108 "In addition to the points placed at regular intervals, this option causes a point to be "
109 "placed at each corner. This option can capture important information in piecewise linear graphs, "
110 "but gradually curving graphs may not benefit from the additional points"));
112 layout->addWidget (m_chkFillCorners,
row++, 2);
118 m_spinLineWidth->setWhatsThis (
tr (
"Select a size for the lines drawn along a segment"));
119 m_spinLineWidth->setMinimum(1);
121 layout->addWidget (m_spinLineWidth,
row++, 2);
127 m_cmbLineColor->setWhatsThis (
tr (
"Select a color for the lines drawn along a segment"));
130 layout->addWidget (m_cmbLineColor,
row++, 2);
145 m_scenePreview =
new QGraphicsScene (
this);
149 m_viewPreview->setWhatsThis (
tr (
"Preview window shows the shortest line that can be segment filled, "
150 "and the effects of current settings on segments and points generated by segment fill"));
151 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
152 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
155 layout->addWidget (m_viewPreview,
row++, 0, 1, 4);
158QImage DlgSettingsSegments::createPreviewImage ()
const
164 QImage::Format_RGB32);
165 image.fill (Qt::white);
167 painter.setRenderHint(QPainter::Antialiasing);
199 }
else if (
s < 0.75) {
224 layout->setColumnStretch (0, 1);
225 layout->setColumnStretch (1, 0);
226 layout->setColumnStretch (2, 0);
227 layout->setColumnStretch (3, 1);
232 QPixmap pixmap = QPixmap::fromImage (createPreviewImage());
233 m_scenePreview->addPixmap (pixmap);
244 *m_modelSegmentsBefore,
245 *m_modelSegmentsAfter);
261 delete m_modelSegmentsBefore;
262 delete m_modelSegmentsAfter;
276 m_spinMinLength->setValue (
qFloor (m_modelSegmentsAfter->
minLength()));
277 m_chkFillCorners->setChecked (m_modelSegmentsAfter->
fillCorners ());
278 m_spinLineWidth->setValue (
qFloor (m_modelSegmentsAfter->
lineWidth()));
299void DlgSettingsSegments::slotFillCorners (
int state)
308void DlgSettingsSegments::slotLineColor (
const QString &)
317void DlgSettingsSegments::slotLineWidth (
int lineWidth)
326void DlgSettingsSegments::slotMinLength (
const QString &minLength)
330 m_modelSegmentsAfter->
setMinLength(minLength.toDouble());
335void DlgSettingsSegments::slotPointSeparation (
const QString &pointSeparation)
344void DlgSettingsSegments::updateControls()
349void DlgSettingsSegments::updatePreview()
352 <<
" loading=" << (m_loading ?
"true" :
"false");
370 *m_modelSegmentsAfter,
375 QList<Segment*>::iterator
itrS;
376 for (
itrS = m_segments.begin();
itrS != m_segments.end();
itrS++) {
386 QPolygonF polygon = pointStyle.polygon();
390 QList<QPoint>::iterator
itrP;
391 for (
itrP = points.begin();
itrP != points.end();
itrP++) {
const int INNER_RADIUS_MIN
const int POINT_SEPARATION_MIN
const int POINT_SEPARATION_MAX
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
log4cpp::Category * mainCat
Command for DlgSettingsSegments.
Abstract base class for all Settings dialogs.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
void populateColorComboWithTransparent(QComboBox &combo)
Add colors in color palette to combobox, with transparent entry at end.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
MainWindow & mainWindow()
Get method for MainWindow.
virtual void handleOk()
Process slotOk.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
virtual ~DlgSettingsSegments()
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
DlgSettingsSegments(MainWindow &mainWindow)
Single constructor.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
Model for DlgSettingsSegments and CmdSettingsSegments.
void setFillCorners(bool fillCorners)
Set method for fill corners.
void setPointSeparation(double pointSeparation)
Set method for point separation.
ColorPalette lineColor() const
Get method for line color.
double minLength() const
Get method for min length.
void setLineColor(ColorPalette lineColor)
Set method for line color.
bool fillCorners() const
Get method for fill corners.
void setLineWidth(double lineWidth)
Set method for line width.
double pointSeparation() const
Get method for point separation.
double lineWidth() const
Get method for line width.
void setMinLength(double minLength)
Set method for min length.
Window that displays the geometry information, as a table, for the current curve.
Graphics item for drawing a circular or polygonal Point.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Details for a specific Point.
Factory class for Segment objects.
Selectable piecewise-defined line that follows a filtered line in the image.
void slotHover(bool hover)
Slot for hover enter/leave events in the associated SegmentLines.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window,...
@ VIEW_ASPECT_RATIO_VARIABLE
#define LOG4CPP_INFO_S(logger)