QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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  int mBlockChanges = 0;
121 
122  void updatePlot();
123  void addPlotMarker( double x, double y, const QColor &color, bool isSelected = false );
124  void addMarkersForColor( double x, const QColor &color, bool isSelected = false );
125 };
126 
127 
128 #ifndef SIP_RUN
129 //
130 // NOTE:
131 // For private only, not part of stable api or exposed to Python bindings
132 //
134 class GUI_EXPORT QgsGradientPlotEventFilter: public QObject
135 {
136  Q_OBJECT
137 
138  public:
139 
140  QgsGradientPlotEventFilter( QwtPlot *plot );
141 
142  bool eventFilter( QObject *object, QEvent *event ) override;
143 
144  signals:
145 
146  void mousePress( QPointF );
147  void mouseRelease( QPointF );
148  void mouseMove( QPointF );
149 
150  private:
151 
152  QwtPlot *mPlot = nullptr;
153  QPointF mapPoint( QPointF point ) const;
154 };
156 #endif
157 
158 #endif
A dialog which allows users to modify the properties of a QgsGradientColorRamp.
QgsGradientColorRamp ramp() const
Returns a color ramp representing the current settings from the dialog.
void changed()
Emitted when the dialog settings change.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
Represents a color stop within a QgsGradientColorRamp color ramp.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53