QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
qgsbeziermarker.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsbeziermarker.h - Visualization for Poly-Bézier curve digitizing
3 ---------------------
4 begin : December 2025
5 copyright : (C) 2025 by Loïc Bartoletti
6 Adapted from BezierEditing plugin work by Takayuki Mizutani
7 email : loic dot bartoletti at oslandia dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSBEZIERMARKER_H
18#define QGSBEZIERMARKER_H
19
20#include <memory>
21#include <vector>
22
23#include "qgis_gui.h"
24#include "qgsbezierdata.h"
25#include "qobjectuniqueptr.h"
26
27#include <QObject>
28
29class QgsMapCanvas;
30class QgsRubberBand;
31class QgsVertexMarker;
32
33#define SIP_NO_FILE
34
36
45class GUI_EXPORT QgsBezierMarker : public QObject
46{
47 Q_OBJECT
48
49 public:
53 struct MarkerConfig
54 {
55 static constexpr int AnchorMarkerSize = 10;
56 static constexpr int HandleMarkerSize = 8;
57 static constexpr int MarkerPenWidth = 2;
58 static constexpr int HandleLineWidth = 1;
59 static constexpr int FillAlpha = 100;
60 static constexpr int HandleLineAlpha = 150;
61 static constexpr int SelectionAlpha = 150;
62 };
63
69 explicit QgsBezierMarker( QgsMapCanvas *canvas, QObject *parent = nullptr );
70
71 ~QgsBezierMarker() override;
72
77 void updateFromData( const QgsBezierData &data );
78
83 void updateCurve( const QgsBezierData &data );
84
89 void setVisible( bool visible );
90
95 void setHandlesVisible( bool visible );
96
98 void clear();
99
104 void setHighlightedAnchor( int idx );
105
110 void setHighlightedHandle( int idx );
111
112 private:
113 QgsMapCanvas *mCanvas = nullptr;
114
115 std::vector<QgsVertexMarker *> mAnchorMarkers;
116 std::vector<QgsVertexMarker *> mHandleMarkers;
117 std::vector<QObjectUniquePtr<QgsRubberBand>> mHandleLines;
118 QObjectUniquePtr<QgsRubberBand> mCurveRubberBand;
119
120 int mHighlightedAnchor = -1;
121 int mHighlightedHandle = -1;
122
123 bool mVisible = true;
124 bool mHandlesVisible = true;
125
127 QgsVertexMarker *createAnchorMarker();
128
130 QgsVertexMarker *createHandleMarker();
131
133 QObjectUniquePtr<QgsRubberBand> createHandleLine();
134
136 void updateAnchorMarkers( const QgsBezierData &data );
137
139 void updateHandleMarkers( const QgsBezierData &data );
140
142 void updateHandleLines( const QgsBezierData &data );
143};
144
146
147#endif // QGSBEZIERMARKER_H
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
Map canvas is a class for displaying all GIS data types on a canvas.
Responsible for drawing transient features (e.g.
A map canvas item for marking vertices of features using e.g.