Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Segment
Segment.h
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#ifndef SEGMENT_H
8
#define SEGMENT_H
9
10
#include <QList>
11
#include <QObject>
12
#include <QPointF>
13
14
class
DocumentModelSegments
;
15
class
QGraphicsScene;
16
class
QTextStream;
17
class
SegmentLine
;
18
21
class
Segment
:
public
QObject
22
{
23
Q_OBJECT;
24
25
public
:
27
Segment
(QGraphicsScene &scene,
28
int
yLast,
29
bool
isGnuplot);
30
~Segment
();
31
33
void
appendColumn
(
int
x,
int
y,
const
DocumentModelSegments
&modelSegments);
34
36
QList<QPoint>
fillPoints
(
const
DocumentModelSegments
&modelSegments);
37
40
QPointF
firstPoint
()
const
;
41
43
void
forwardMousePress
();
44
46
double
length
()
const
;
47
49
int
lineCount
()
const
;
50
52
void
lockHoverState
();
53
58
void
removeUnneededLines
(
int
*foldedLines);
59
61
void
updateModelSegment
(
const
DocumentModelSegments
&modelSegments);
62
63
public
slots:
64
66
void
slotHover
(
bool
hover);
67
68
signals:
69
71
void
signalMouseClickOnSegment
(QPointF posSegmentStart);
72
73
private
:
74
Segment
();
75
76
// While filling corners, create a point if any of the following are true:
77
// -it is the first point of the any line segment
78
// -it is different than the previous point
79
// While not filling corners, create a point if any of the following are true:
80
// -it is the first point of the first line segment
81
// -it is different than the previous point
82
void
createAcceptablePoint(
bool
*pFirst,
83
QList<QPoint> *pList,
84
double
*xPrev,
85
double
*yPrev,
86
double
x,
87
double
y);
88
95
void
dumpToGnuplot (QTextStream &strDump,
96
int
xInt,
97
int
yInt,
98
const
SegmentLine
*lineOld,
99
const
SegmentLine
*lineNew)
const
;
100
101
// Create evenly spaced points along the segment, with extra points to fill in corners.This algorithm is the
102
// same as fillPointsWithoutFillingCorners except extra points are inserted at the corners
103
QList<QPoint> fillPointsFillingCorners(
const
DocumentModelSegments
&modelSegments);
104
105
// Create evenly spaced points along the segment, without extra points in corners
106
QList<QPoint> fillPointsWithoutFillingCorners(
const
DocumentModelSegments
&modelSegments);
107
108
// A corner is defined as a point where the incoming slope is positive and the outgoing slope is zero
109
// or negative, or incoming slope is negative and the outgoing slope is zero or positive
110
bool
isCorner (
double
yLast,
111
double
yPrev,
112
double
yNext)
const
;
113
114
// Return true if point are a half pixel or less away from a line
115
bool
pointIsCloseToLine(
double
xLeft,
double
yLeft,
double
xInt,
double
yInt,
116
double
xRight,
double
yRight);
117
118
// Return true if points are a half pixel or less away from a line
119
bool
pointsAreCloseToLine(
double
xLeft,
double
yLeft, QList<QPoint> removedPoints,
120
double
xRight,
double
yRight);
121
122
QGraphicsScene &m_scene;
123
124
// Y value of last point which is in previous column
125
int
m_yLast;
126
127
// Total length of lines owned by this segment, as floating point to allow fractional increments
128
double
m_length;
129
130
// This segment is drawn as a series of line segments
131
QList<SegmentLine*> m_lines;
132
133
// True for gnuplot input files for debugging
134
bool
m_isGnuplot;
135
};
136
137
#endif
// SEGMENT_H
DocumentModelSegments
Model for DlgSettingsSegments and CmdSettingsSegments.
Definition
DocumentModelSegments.h:19
SegmentLine
This class is a special case of the standard QGraphicsLineItem for segments.
Definition
SegmentLine.h:18
Segment::lockHoverState
void lockHoverState()
Disable hover events. This is used only by DlgSettingsSegments to stop hover events in the preview wi...
Definition
Segment.cpp:386
Segment::signalMouseClickOnSegment
void signalMouseClickOnSegment(QPointF posSegmentStart)
Pass mouse press event, with coordinates of first point in the Segment since that info uniquely ident...
Segment::length
double length() const
Get method for length in pixels.
Definition
Segment.cpp:376
Segment::lineCount
int lineCount() const
Get method for number of lines.
Definition
Segment.cpp:381
Segment::fillPoints
QList< QPoint > fillPoints(const DocumentModelSegments &modelSegments)
Create evenly spaced points along the segment.
Definition
Segment.cpp:206
Segment::Segment
Segment(QGraphicsScene &scene, int yLast, bool isGnuplot)
Single constructor.
Definition
Segment.cpp:23
Segment::forwardMousePress
void forwardMousePress()
Forward mouse press event from a component SegmentLine that was just clicked on.
Definition
Segment.cpp:299
Segment::slotHover
void slotHover(bool hover)
Slot for hover enter/leave events in the associated SegmentLines.
Definition
Segment.cpp:539
Segment::updateModelSegment
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment given the new settings.
Definition
Segment.cpp:551
Segment::~Segment
~Segment()
Definition
Segment.cpp:33
Segment::appendColumn
void appendColumn(int x, int y, const DocumentModelSegments &modelSegments)
Add some more pixels in a new column to an active segment.
Definition
Segment.cpp:43
Segment::firstPoint
QPointF firstPoint() const
Coordinates of first point in Segment.
Definition
Segment.cpp:282
Segment::removeUnneededLines
void removeUnneededLines(int *foldedLines)
Try to compress a segment that was just completed, by folding together line from point i to point i+1...
Definition
Segment.cpp:432
Generated on
for Engauge Digitizer by
1.17.0