QGIS API Documentation  3.2.0-Bonn (bc43194)
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.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 
66  signals:
67 
69  void changed();
70 
71  public slots:
72 
77  void setColor1( const QColor &color );
78 
83  void setColor2( const QColor &color );
84 
85  private slots:
86  void cboType_currentIndexChanged( int index );
87  void btnInformation_pressed();
88  void updateRampFromStopEditor();
89  void updateColorButtons();
90  void updateStopEditor();
91  void selectedStopChanged( const QgsGradientStop &stop );
92  void colorWidgetChanged( const QColor &color );
93  void mPositionSpinBox_valueChanged( double val );
94  void mPlotHueCheckbox_toggled( bool checked );
95  void mPlotLightnessCheckbox_toggled( bool checked );
96  void mPlotSaturationCheckbox_toggled( bool checked );
97  void mPlotAlphaCheckbox_toggled( bool checked );
98  void plotMousePress( QPointF point );
99  void plotMouseRelease( QPointF point );
100  void plotMouseMove( QPointF point );
101  void showHelp();
102 
103  private:
104 
105  QgsGradientColorRamp mRamp;
106  QwtPlotCurve *mLightnessCurve = nullptr;
107  QwtPlotCurve *mSaturationCurve = nullptr;
108  QwtPlotCurve *mHueCurve = nullptr;
109  QwtPlotCurve *mAlphaCurve = nullptr;
110  QList< QwtPlotMarker * > mMarkers;
111  QgsGradientPlotEventFilter *mPlotFilter = nullptr;
112  int mCurrentPlotColorComponent;
113  int mCurrentPlotMarkerIndex;
114 
115  void updatePlot();
116  void addPlotMarker( double x, double y, const QColor &color, bool isSelected = false );
117  void addMarkersForColor( double x, const QColor &color, bool isSelected = false );
118 };
119 
120 
121 #ifndef SIP_RUN
122 //
123 // NOTE:
124 // For private only, not part of stable api or exposed to Python bindings
125 //
127 class GUI_EXPORT QgsGradientPlotEventFilter: public QObject
128 {
129  Q_OBJECT
130 
131  public:
132 
133  QgsGradientPlotEventFilter( QwtPlot *plot );
134 
135  bool eventFilter( QObject *object, QEvent *event ) override;
136 
137  signals:
138 
139  void mousePress( QPointF );
140  void mouseRelease( QPointF );
141  void mouseMove( QPointF );
142 
143  private:
144 
145  QwtPlot *mPlot = nullptr;
146  QPointF mapPoint( QPointF point ) const;
147 };
149 #endif
150 
151 #endif
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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.