QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsgradientcolorrampdialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgradientcolorrampdialog.h
3  ----------------------------
4  begin : December 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk 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 QGSGRADIENTCOLORRAMPDIALOG_H
17 #define QGSGRADIENTCOLORRAMPDIALOG_H
18 
19 #include <QDialog>
20 #include "qgis_sip.h"
21 
22 #include "ui_qgsgradientcolorrampdialogbase.h"
23 #include "qgshelp.h"
24 #include "qgis_gui.h"
25 
27 class QwtPlot;
28 class QwtPlotCurve;
29 class QwtPlotMarker;
30 class QgsGradientPlotEventFilter;
31 
38 class GUI_EXPORT QgsGradientColorRampDialog : public QDialog, private Ui::QgsGradientColorRampDialogBase
39 {
40  Q_OBJECT
41  Q_PROPERTY( QgsGradientColorRamp ramp READ ramp WRITE setRamp )
42 
43  public:
44 
50  QgsGradientColorRampDialog( const QgsGradientColorRamp &ramp, QWidget *parent SIP_TRANSFERTHIS = nullptr );
51  ~QgsGradientColorRampDialog() override;
52 
57  QgsGradientColorRamp ramp() const { return mRamp; }
58 
64  void setRamp( const QgsGradientColorRamp &ramp );
65 
70  QDialogButtonBox *buttonBox() const;
71 
72  signals:
73 
75  void changed();
76 
77  public slots:
78 
83  void setColor1( const QColor &color );
84 
89  void setColor2( const QColor &color );
90 
91  private slots:
92  void cboType_currentIndexChanged( int index );
93  void btnInformation_pressed();
94  void updateRampFromStopEditor();
95  void updateColorButtons();
96  void updateStopEditor();
97  void selectedStopChanged( const QgsGradientStop &stop );
98  void colorWidgetChanged( const QColor &color );
99  void mPositionSpinBox_valueChanged( double val );
100  void mPlotHueCheckbox_toggled( bool checked );
101  void mPlotLightnessCheckbox_toggled( bool checked );
102  void mPlotSaturationCheckbox_toggled( bool checked );
103  void mPlotAlphaCheckbox_toggled( bool checked );
104  void plotMousePress( QPointF point );
105  void plotMouseRelease( QPointF point );
106  void plotMouseMove( QPointF point );
107  void showHelp();
108 
109  private:
110 
111  QgsGradientColorRamp mRamp;
112  QwtPlotCurve *mLightnessCurve = nullptr;
113  QwtPlotCurve *mSaturationCurve = nullptr;
114  QwtPlotCurve *mHueCurve = nullptr;
115  QwtPlotCurve *mAlphaCurve = nullptr;
116  QList< QwtPlotMarker * > mMarkers;
117  QgsGradientPlotEventFilter *mPlotFilter = nullptr;
118  int mCurrentPlotColorComponent;
119  int mCurrentPlotMarkerIndex;
120 
121  void updatePlot();
122  void addPlotMarker( double x, double y, const QColor &color, bool isSelected = false );
123  void addMarkersForColor( double x, const QColor &color, bool isSelected = false );
124 };
125 
126 
127 #ifndef SIP_RUN
128 //
129 // NOTE:
130 // For private only, not part of stable api or exposed to Python bindings
131 //
133 class GUI_EXPORT QgsGradientPlotEventFilter: public QObject
134 {
135  Q_OBJECT
136 
137  public:
138 
139  QgsGradientPlotEventFilter( QwtPlot *plot );
140 
141  bool eventFilter( QObject *object, QEvent *event ) override;
142 
143  signals:
144 
145  void mousePress( QPointF );
146  void mouseRelease( QPointF );
147  void mouseMove( QPointF );
148 
149  private:
150 
151  QwtPlot *mPlot = nullptr;
152  QPointF mapPoint( QPointF point ) const;
153 };
155 #endif
156 
157 #endif
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Represents a color stop within a QgsGradientColorRamp color ramp.
Definition: qgscolorramp.h:101
A dialog which allows users to modify the properties of a QgsGradientColorRamp.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
Definition: qgscolorramp.h:139
QgsGradientColorRamp ramp() const
Returns a color ramp representing the current settings from the dialog.