MCPcopy Create free account
hub / github.com/KDE/labplot / finishRun

Method finishRun

src/backend/datapicker/Segments.cpp:199–229  ·  view source on GitHub ↗

! process a run of pixels. if there are fewer than two adjacent pixel runs on either side, this run will be added to an existing segment, or the start of a new segment */

Source from the content-addressed store, hash-verified

197 a new segment
198*/
199void Segments::finishRun(const bool* lastBool, const bool* nextBool, Segment** lastSegment, Segment** currSegment, int x, int yStart, int yStop, int height) {
200 // count runs that touch on the left
201 if (adjacentRuns(lastBool, yStart, yStop, height) > 1)
202 return;
203
204 // count runs that touch on the right
205 if (adjacentRuns(nextBool, yStart, yStop, height) > 1)
206 return;
207
208 Segment* seg;
209 int yLast = (int)((yStart + yStop) / 2);
210 if (adjacentSegments(lastSegment, yStart, yStop, height) == 0) {
211 seg = new Segment(m_image);
212 QLine* line = new QLine(QPoint(x, yLast), QPoint(x, yLast));
213 seg->path.append(line);
214 seg->yLast = yLast;
215 segments.append(seg);
216 } else {
217 // this is the continuation of an existing segment
218 seg = adjacentSegment(lastSegment, yStart, yStop, height);
219 QLine* line = new QLine(QPoint(x - 1, seg->yLast), QPoint(x, yLast));
220 seg->length += abs(1 + (seg->yLast - yLast) * (seg->yLast - yLast));
221 seg->path.append(line);
222 seg->yLast = yLast;
223 }
224
225 seg->retransform();
226
227 for (int y = yStart; y <= yStop; ++y)
228 currSegment[y] = seg;
229}
230
231/*!
232 return the number of runs adjacent to the pixels from yStart to yStop (inclusive)

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
retransformMethod · 0.45

Tested by

no test coverage detected