-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsgradientcolorrampdialog.h
145 lines (117 loc) · 4.36 KB
/
qgsgradientcolorrampdialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/***************************************************************************
qgsgradientcolorrampdialog.h
----------------------------
begin : December 2009
copyright : (C) 2009 by Martin Dobias
email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSGRADIENTCOLORRAMPDIALOG_H
#define QGSGRADIENTCOLORRAMPDIALOG_H
#include <QDialog>
#include "qgis.h"
#include "ui_qgsgradientcolorrampdialogbase.h"
#include "qgshelp.h"
#include "qgis_gui.h"
class QgsGradientColorRamp;
class QwtPlot;
class QwtPlotCurve;
class QwtPlotMarker;
class QgsGradientPlotEventFilter;
/** \ingroup gui
* \class QgsGradientColorRampDialog
* A dialog which allows users to modify the properties of a QgsGradientColorRamp.
* \since QGIS 3.0
*/
class GUI_EXPORT QgsGradientColorRampDialog : public QDialog, private Ui::QgsGradientColorRampDialogBase
{
Q_OBJECT
Q_PROPERTY( QgsGradientColorRamp ramp READ ramp WRITE setRamp )
public:
/** Constructor for QgsGradientColorRampDialog.
* \param ramp initial ramp to show in dialog
* \param parent parent widget
*/
QgsGradientColorRampDialog( const QgsGradientColorRamp &ramp, QWidget *parent SIP_TRANSFERTHIS = 0 );
~QgsGradientColorRampDialog();
/** Returns a color ramp representing the current settings from the dialog.
* \see setRamp()
*/
QgsGradientColorRamp ramp() const { return mRamp; }
/** Sets the color ramp to show in the dialog.
* \param ramp color ramp
* \see ramp()
*/
void setRamp( const QgsGradientColorRamp &ramp );
signals:
//! Emitted when the dialog settings change
void changed();
public slots:
/** Sets the start color for the gradient ramp.
* \see setColor2()
*/
void setColor1( const QColor &color );
/** Sets the end color for the gradient ramp.
* \see setColor1()
*/
void setColor2( const QColor &color );
private slots:
void on_cboType_currentIndexChanged( int index );
void on_btnInformation_pressed();
void updateRampFromStopEditor();
void updateColorButtons();
void updateStopEditor();
void selectedStopChanged( const QgsGradientStop &stop );
void colorWidgetChanged( const QColor &color );
void on_mPositionSpinBox_valueChanged( double val );
void on_mPlotHueCheckbox_toggled( bool checked );
void on_mPlotLightnessCheckbox_toggled( bool checked );
void on_mPlotSaturationCheckbox_toggled( bool checked );
void on_mPlotAlphaCheckbox_toggled( bool checked );
void plotMousePress( QPointF point );
void plotMouseRelease( QPointF point );
void plotMouseMove( QPointF point );
void showHelp();
private:
QgsGradientColorRamp mRamp;
QwtPlotCurve *mLightnessCurve = nullptr;
QwtPlotCurve *mSaturationCurve = nullptr;
QwtPlotCurve *mHueCurve = nullptr;
QwtPlotCurve *mAlphaCurve = nullptr;
QList< QwtPlotMarker * > mMarkers;
QgsGradientPlotEventFilter *mPlotFilter = nullptr;
int mCurrentPlotColorComponent;
int mCurrentPlotMarkerIndex;
void updatePlot();
void addPlotMarker( double x, double y, const QColor &color, bool isSelected = false );
void addMarkersForColor( double x, const QColor &color, bool isSelected = false );
};
#ifndef SIP_RUN
//
// NOTE:
// For private only, not part of stable api or exposed to Python bindings
//
/// @cond PRIVATE
class GUI_EXPORT QgsGradientPlotEventFilter: public QObject
{
Q_OBJECT
public:
QgsGradientPlotEventFilter( QwtPlot *plot );
virtual bool eventFilter( QObject *object, QEvent *event ) override;
signals:
void mousePress( QPointF );
void mouseRelease( QPointF );
void mouseMove( QPointF );
private:
QwtPlot *mPlot = nullptr;
QPointF mapPoint( QPointF point ) const;
};
///@endcond
#endif
#endif