QGIS API Documentation 3.99.0-Master (7d2ca374f2d)
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
29#define SIP_NO_FILE
30
31class QgsMapCanvas;
32class QgsRubberBand;
33class QgsVertexMarker;
34
35
37
46class GUI_EXPORT QgsBezierMarker : public QObject
47{
48 Q_OBJECT
49
50 public:
54 struct MarkerConfig
55 {
56 static constexpr int AnchorMarkerSize = 10;
57 static constexpr int HandleMarkerSize = 8;
58 static constexpr int MarkerPenWidth = 2;
59 static constexpr int HandleLineWidth = 1;
60 static constexpr int FillAlpha = 100;
61 static constexpr int HandleLineAlpha = 150;
62 static constexpr int SelectionAlpha = 150;
63 };
64
70 explicit QgsBezierMarker( QgsMapCanvas *canvas, QObject *parent = nullptr );
71
72 ~QgsBezierMarker() override;
73
78 void updateFromData( const QgsBezierData &data );
79
84 void updateCurve( const QgsBezierData &data );
85
90 void setVisible( bool visible );
91
96 void setHandlesVisible( bool visible );
97
99 void clear();
100
105 void setHighlightedAnchor( int idx );
106
111 void setHighlightedHandle( int idx );
112
113 private:
114 QgsMapCanvas *mCanvas = nullptr;
115
116 std::vector<QgsVertexMarker *> mAnchorMarkers;
117 std::vector<QgsVertexMarker *> mHandleMarkers;
118 std::vector<QObjectUniquePtr<QgsRubberBand>> mHandleLines;
119 QObjectUniquePtr<QgsRubberBand> mCurveRubberBand;
120
121 int mHighlightedAnchor = -1;
122 int mHighlightedHandle = -1;
123
124 bool mVisible = true;
125 bool mHandlesVisible = true;
126
128 QgsVertexMarker *createAnchorMarker();
129
131 QgsVertexMarker *createHandleMarker();
132
134 QObjectUniquePtr<QgsRubberBand> createHandleLine();
135
137 void updateAnchorMarkers( const QgsBezierData &data );
138
140 void updateHandleMarkers( const QgsBezierData &data );
141
143 void updateHandleLines( const QgsBezierData &data );
144};
145
147
148#endif // QGSBEZIERMARKER_H
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.