QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsgradientstopeditor.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsgradientstopeditor.h
3
-----------------------
4
begin : April 2016
5
copyright : (C) 2016 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSGRADIENTSTOPEDITOR_H
17
#define QGSGRADIENTSTOPEDITOR_H
18
19
#include "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
#include "
qgscolorrampimpl.h
"
22
23
#include <QWidget>
24
31
32
class
GUI_EXPORT
QgsGradientStopEditor
:
public
QWidget
33
{
34
Q_OBJECT
35
36
public
:
42
QgsGradientStopEditor
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
,
QgsGradientColorRamp
*ramp =
nullptr
);
43
49
void
setGradientRamp
(
const
QgsGradientColorRamp
&ramp );
50
55
QgsGradientColorRamp
gradientRamp
()
const
{
return
mGradient; }
56
62
void
selectStop(
int
index );
63
68
QgsGradientStop
selectedStop()
const
;
69
70
QSize sizeHint()
const override
;
71
void
paintEvent( QPaintEvent *event )
override
;
72
73
public
slots:
74
83
void
setSelectedStopColor(
const
QColor &color );
84
92
void
setSelectedStopOffset(
double
offset );
93
99
void
setSelectedStopColorSpec( QColor::Spec spec );
100
106
void
setSelectedStopDirection(
Qgis::AngularDirection
direction );
107
115
void
setSelectedStopDetails(
const
QColor &color,
double
offset );
116
121
void
deleteSelectedStop();
122
129
void
setColor1(
const
QColor &color );
130
137
void
setColor2(
const
QColor &color );
138
139
signals:
140
142
void
changed
();
143
148
void
selectedStopChanged
(
const
QgsGradientStop
&stop );
149
150
protected
:
151
void
mouseMoveEvent
( QMouseEvent *event )
override
;
152
void
mousePressEvent
( QMouseEvent *event )
override
;
153
void
mouseDoubleClickEvent
( QMouseEvent *event )
override
;
154
void
keyPressEvent
( QKeyEvent *event )
override
;
155
156
//Reimplemented to accept dragged colors
157
void
dragEnterEvent
( QDragEnterEvent *e )
override
;
158
159
//Reimplemented to accept dropped colors
160
void
dropEvent
( QDropEvent *e )
override
;
161
162
private
:
167
QPixmap transparentBackground();
168
176
void
drawStopMarker( QPainter &painter, QPoint topMiddle,
const
QColor &color,
bool
selected =
false
);
177
179
double
pointToRelativePosition(
int
x )
const
;
180
182
int
relativePositionToPoint(
double
position )
const
;
183
185
bool
selectedStopIsMovable()
const
;
186
188
int
findClosestStop(
int
x,
int
threshold = -1 )
const
;
189
190
QgsGradientColorRamp
mGradient;
191
193
QgsGradientStopsList
mStops;
194
196
int
mSelectedStop = 0;
197
199
QPolygonF sOuterTriangle;
200
202
QPolygonF sInnerTriangle;
203
204
static
constexpr
int
FRAME_MARGIN_PX = 2;
205
static
constexpr
int
MARKER_WIDTH = 11;
206
static
constexpr
int
MARKER_HEIGHT = 14;
207
static
constexpr
double
MARKER_GAP = 1.5;
208
static
constexpr
int
MARGIN_BOTTOM = MARKER_HEIGHT + 2;
209
static
constexpr
int
MARGIN_X = MARKER_WIDTH / 2;
210
static
constexpr
int
CLICK_THRESHOLD = MARKER_WIDTH / 2 + 3;
211
};
212
213
#endif
// QGSGRADIENTSTOPEDITOR_H
Qgis::AngularDirection
AngularDirection
Angular directions.
Definition
qgis.h:3670
QgsGradientColorRamp
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
Definition
qgscolorrampimpl.h:131
QgsGradientStopEditor::gradientRamp
QgsGradientColorRamp gradientRamp() const
Returns the current ramp created by the editor.
Definition
qgsgradientstopeditor.h:55
QgsGradientStopEditor::changed
void changed()
Emitted when the gradient ramp is changed by a user.
QgsGradientStopEditor::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition
qgsgradientstopeditor.cpp:353
QgsGradientStopEditor::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition
qgsgradientstopeditor.cpp:368
QgsGradientStopEditor::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
Definition
qgsgradientstopeditor.cpp:383
QgsGradientStopEditor::selectedStopChanged
void selectedStopChanged(const QgsGradientStop &stop)
Emitted when the current selected stop changes.
QgsGradientStopEditor::QgsGradientStopEditor
QgsGradientStopEditor(QWidget *parent=nullptr, QgsGradientColorRamp *ramp=nullptr)
Constructor for QgsGradientStopEditor.
Definition
qgsgradientstopeditor.cpp:31
QgsGradientStopEditor::dropEvent
void dropEvent(QDropEvent *e) override
Definition
qgsgradientstopeditor.cpp:492
QgsGradientStopEditor::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition
qgsgradientstopeditor.cpp:293
QgsGradientStopEditor::setGradientRamp
void setGradientRamp(const QgsGradientColorRamp &ramp)
Sets the current ramp shown in the editor.
Definition
qgsgradientstopeditor.cpp:63
QgsGradientStopEditor::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *e) override
Definition
qgsgradientstopeditor.cpp:479
QgsGradientStop
Represents a color stop within a QgsGradientColorRamp color ramp.
Definition
qgscolorrampimpl.h:42
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
qgscolorrampimpl.h
QgsGradientStopsList
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
Definition
qgscolorrampimpl.h:117
Generated on
for QGIS API Documentation by
1.17.0