Changeset View
Changeset View
Standalone View
Standalone View
src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp
Show First 20 Lines • Show All 247 Lines • ▼ Show 20 Line(s) | 226 | for (const auto* yScale : d->yScales) { | |||
---|---|---|---|---|---|
248 | } | 248 | } | ||
249 | } | 249 | } | ||
250 | } | 250 | } | ||
251 | 251 | | |||
252 | return result; | 252 | return result; | ||
253 | } | 253 | } | ||
254 | 254 | | |||
255 | /*! | 255 | /*! | ||
256 | Maps the points in logical coordinates from \c points and fills the \c visiblePoints with the points in logical coordinates restricted to the current intervals. | 256 | Maps the points in logical coordinates from @p points and fills the @p visiblePoints with the points in logical coordinates restricted to the current intervals. | ||
257 | \param logicalPoints List of points in logical coordinates | 257 | @param logicalPoints List of points in logical coordinates | ||
258 | \param scenePoints List for the points in scene coordinates | 258 | @param scenePoints List for the points in scene coordinates | ||
259 | \param visiblePoints List for the logical coordinates restricted to the current region of the coordinate system | 259 | @param visiblePoints List for the logical coordinates restricted to the current region of the coordinate system | ||
260 | \param flags | 260 | @param flags | ||
261 | */ | 261 | */ | ||
262 | void CartesianCoordinateSystem::mapLogicalToScene(const QVector<QPointF>& logicalPoints, | 262 | void CartesianCoordinateSystem::mapLogicalToScene(const QVector<QPointF>& logicalPoints, | ||
263 | QVector<QPointF>& scenePoints, std::vector<bool>& visiblePoints, MappingFlags flags) const { | 263 | QVector<QPointF>& scenePoints, std::vector<bool>& visiblePoints, MappingFlags flags) const { | ||
264 | const QRectF pageRect = d->plot->dataRect(); | 264 | const QRectF pageRect = d->plot->dataRect(); | ||
265 | const bool noPageClipping = pageRect.isNull() || (flags & SuppressPageClipping); | 265 | const bool noPageClipping = pageRect.isNull() || (flags & SuppressPageClipping); | ||
266 | 266 | | |||
267 | for (const auto* xScale : d->xScales) { | 267 | for (const auto* xScale : d->xScales) { | ||
268 | if (!xScale) continue; | 268 | if (!xScale) continue; | ||
Show All 23 Lines | 291 | if (noPageClipping || rectContainsPoint(pageRect, mappedPoint)) { | |||
292 | scenePoints.append(mappedPoint); | 292 | scenePoints.append(mappedPoint); | ||
293 | visiblePoints[i].flip(); | 293 | visiblePoints[i].flip(); | ||
294 | } | 294 | } | ||
295 | } | 295 | } | ||
296 | } | 296 | } | ||
297 | } | 297 | } | ||
298 | } | 298 | } | ||
299 | 299 | | |||
300 | /*! | ||||
301 | Maps the points in logical coordinates from \c points and fills the \c visiblePoints with the points in logical coordinates restricted to the current intervals. | ||||
302 | If there are points, which lies on another the point will not be added a second time. | ||||
303 | @param logicalPoints List of points in logical coordinates | ||||
304 | @param scenePoints List for the points in scene coordinates | ||||
305 | @param visiblePoints List for the logical coordinates restricted to the current region of the coordinate system | ||||
306 | @param scenePointsUsed List of bools which scene point was already used | ||||
307 | */ | ||||
308 | void CartesianCoordinateSystem::mapLogicalToScene(int startIndex, int endIndex, const QVector<QPointF>& logicalPoints, | ||||
309 | QVector<QPointF>& scenePoints, std::vector<bool>& visiblePoints, QVector<QVector<bool>>& scenePointsUsed, double minLogicalDiffX, double minLogicalDiffY, MappingFlags flags) const { | ||||
310 | const QRectF pageRect = d->plot->dataRect(); | ||||
311 | const bool noPageClipping = pageRect.isNull() || (flags & SuppressPageClipping); | ||||
312 | | ||||
313 | for (const auto* xScale : d->xScales) { | ||||
314 | if (!xScale) continue; | ||||
315 | | ||||
316 | for (const auto* yScale : d->yScales) { | ||||
317 | if (!yScale) continue; | ||||
318 | | ||||
319 | for (int i = startIndex; i <= endIndex; ++i) { | ||||
320 | const QPointF& point = logicalPoints.at(i); | ||||
321 | | ||||
322 | double x = point.x(); | ||||
323 | if (!xScale->contains(x)) | ||||
324 | continue; | ||||
325 | | ||||
326 | if (!xScale->map(&x)) | ||||
327 | continue; | ||||
328 | | ||||
329 | double y = point.y(); | ||||
330 | if (!yScale->contains(y)) | ||||
331 | continue; | ||||
332 | | ||||
333 | if (!yScale->map(&y)) | ||||
334 | continue; | ||||
335 | | ||||
336 | const QPointF mappedPoint(x, y); | ||||
337 | if (noPageClipping || rectContainsPoint(pageRect, mappedPoint)) { | ||||
338 | | ||||
339 | int indexX = (int)((mappedPoint.x() - d->plot->dataRect().x())*minLogicalDiffX); | ||||
340 | int indexY = (int)((mappedPoint.y() - d->plot->dataRect().y())*minLogicalDiffY); | ||||
341 | if (scenePointsUsed[indexX][indexY]) | ||||
342 | continue; | ||||
343 | | ||||
344 | scenePointsUsed[indexX][indexY] = true; | ||||
345 | scenePoints.append(mappedPoint); | ||||
346 | visiblePoints[i].flip(); | ||||
347 | } | ||||
348 | } | ||||
349 | } | ||||
350 | } | ||||
351 | } | ||||
352 | | ||||
300 | QPointF CartesianCoordinateSystem::mapLogicalToScene(QPointF logicalPoint, MappingFlags flags) const { | 353 | QPointF CartesianCoordinateSystem::mapLogicalToScene(QPointF logicalPoint, MappingFlags flags) const { | ||
301 | const QRectF pageRect = d->plot->dataRect(); | 354 | const QRectF pageRect = d->plot->dataRect(); | ||
302 | bool noPageClipping = pageRect.isNull() || (flags & SuppressPageClipping); | 355 | bool noPageClipping = pageRect.isNull() || (flags & SuppressPageClipping); | ||
303 | 356 | | |||
304 | double x = logicalPoint.x(); | 357 | double x = logicalPoint.x(); | ||
305 | double y = logicalPoint.y(); | 358 | double y = logicalPoint.y(); | ||
306 | 359 | | |||
307 | for (const auto* xScale : d->xScales) { | 360 | for (const auto* xScale : d->xScales) { | ||
▲ Show 20 Lines • Show All 371 Lines • Show Last 20 Lines |