24#include <QColorDialog>
26#include <QInputDialog>
29#include <QTableWidget>
32#include "moc_qgsgradientcolorrampdialog.cpp"
34using namespace Qt::StringLiterals;
42#include <qwt_global.h>
43#include <qwt_plot_canvas.h>
45#include <qwt_plot_curve.h>
46#include <qwt_plot_grid.h>
47#include <qwt_plot_marker.h>
48#include <qwt_plot_picker.h>
49#include <qwt_picker_machine.h>
50#include <qwt_plot_layout.h>
51#include <qwt_symbol.h>
52#include <qwt_legend.h>
53#include <qwt_scale_div.h>
54#include <qwt_scale_map.h>
63 mColorWidget->setColorModelEditable(
false );
65 mStopColorSpec->addItem( tr(
"RGB" ),
static_cast<int>( QColor::Spec::Rgb ) );
66 mStopColorSpec->addItem( tr(
"HSV" ),
static_cast<int>( QColor::Spec::Hsv ) );
67 mStopColorSpec->addItem( tr(
"HSL" ),
static_cast<int>( QColor::Spec::Hsl ) );
68 mStopColorSpec->addItem( tr(
"CMYK" ),
static_cast<int>( QColor::Spec::Cmyk ) );
69 mStopColorSpec->setCurrentIndex( mStopColorSpec->findData(
static_cast<int>(
ramp.colorSpec() ) ) );
73 mStopDirection->setCurrentIndex( mStopColorSpec->findData(
static_cast<int>(
ramp.direction() ) ) );
75 mStopDirection->setEnabled( hasDirection(
static_cast<QColor::Spec
>( mStopColorSpec->currentData().toInt() ) ) );
77 connect( mStopColorSpec,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this] {
78 const QColor::Spec colorSpec =
static_cast<QColor::Spec
>( mStopColorSpec->currentData().toInt() );
79 mStopDirection->setEnabled( hasDirection( colorSpec ) );
81 if ( colorSpec != mColorWidget->color().spec() )
83 mColorWidget->setColor( mColorWidget->color().convertTo( colorSpec ) );
89 mStopEditor->setSelectedStopColorSpec( colorSpec );
92 connect( mStopDirection,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this] {
96 mStopEditor->setSelectedStopDirection(
static_cast<Qgis::AngularDirection>( mStopDirection->currentData().toInt() ) );
99 connect( cboType,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsGradientColorRampDialog::cboType_currentIndexChanged );
100 connect( btnInformation, &QPushButton::pressed,
this, &QgsGradientColorRampDialog::btnInformation_pressed );
101 connect( mPositionSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientColorRampDialog::mPositionSpinBox_valueChanged );
102 connect( mPlotHueCheckbox, &QCheckBox::toggled,
this, &QgsGradientColorRampDialog::mPlotHueCheckbox_toggled );
103 connect( mPlotLightnessCheckbox, &QCheckBox::toggled,
this, &QgsGradientColorRampDialog::mPlotLightnessCheckbox_toggled );
104 connect( mPlotSaturationCheckbox, &QCheckBox::toggled,
this, &QgsGradientColorRampDialog::mPlotSaturationCheckbox_toggled );
105 connect( mPlotAlphaCheckbox, &QCheckBox::toggled,
this, &QgsGradientColorRampDialog::mPlotAlphaCheckbox_toggled );
107 setWindowModality( Qt::WindowModal );
110 mPositionSpinBox->setShowClearButton(
false );
111 btnColor1->setAllowOpacity(
true );
112 btnColor1->setColorDialogTitle( tr(
"Select Ramp Color" ) );
113 btnColor1->setContext( u
"symbology"_s );
114 btnColor1->setShowNoColor(
true );
115 btnColor1->setNoColorString( tr(
"Transparent" ) );
116 btnColor2->setAllowOpacity(
true );
117 btnColor2->setColorDialogTitle( tr(
"Select Ramp Color" ) );
118 btnColor2->setContext( u
"symbology"_s );
119 btnColor2->setShowNoColor(
true );
120 btnColor2->setNoColorString( tr(
"Transparent" ) );
121 updateColorButtons();
126 cboType->blockSignals(
true );
127 cboType->addItem( tr(
"Discrete" ) );
128 cboType->addItem( tr(
"Continuous" ) );
129 if ( mRamp.isDiscrete() )
130 cboType->setCurrentIndex( 0 );
132 cboType->setCurrentIndex( 1 );
133 cboType->blockSignals(
false );
135 if ( mRamp.info().isEmpty() )
136 btnInformation->setEnabled(
false );
138 mStopEditor->setGradientRamp( mRamp );
145 mPlot->setFrameStyle( QFrame::NoFrame );
146 QFrame *plotCanvasFrame =
dynamic_cast<QFrame *
>( mPlot->canvas() );
147 if ( plotCanvasFrame )
148 plotCanvasFrame->setFrameStyle( QFrame::NoFrame );
150 mPlot->setAxisScale( QwtPlot::yLeft, 0.0, 1.0 );
151 mPlot->enableAxis( QwtPlot::yLeft,
false );
154 QwtPlotGrid *grid =
new QwtPlotGrid();
155 QwtScaleDiv gridDiv( 0.0, 1.0, QList<double>(), QList<double>(), QList<double>() << 0.2 << 0.4 << 0.6 << 0.8 );
156 grid->setXDiv( gridDiv );
157 grid->setYDiv( gridDiv );
158 grid->setPen( QPen( QColor( 0, 0, 0, 50 ) ) );
159 grid->attach( mPlot );
161 mLightnessCurve =
new QwtPlotCurve();
162 mLightnessCurve->setTitle( tr(
"Lightness" ) );
163 mLightnessCurve->setPen( QPen( QColor( 70, 150, 255 ), 0.0 ) ), mLightnessCurve->setRenderHint( QwtPlotItem::RenderAntialiased,
true );
164 mLightnessCurve->attach( mPlot );
166 mHueCurve =
new QwtPlotCurve();
167 mHueCurve->setTitle( tr(
"Hue" ) );
168 mHueCurve->setPen( QPen( QColor( 255, 215, 70 ), 0.0 ) ), mHueCurve->setRenderHint( QwtPlotItem::RenderAntialiased,
true );
169 mHueCurve->attach( mPlot );
171 mSaturationCurve =
new QwtPlotCurve();
172 mSaturationCurve->setTitle( tr(
"Saturation" ) );
173 mSaturationCurve->setPen( QPen( QColor( 255, 70, 150 ), 0.0 ) ), mSaturationCurve->setRenderHint( QwtPlotItem::RenderAntialiased,
true );
174 mSaturationCurve->attach( mPlot );
176 mAlphaCurve =
new QwtPlotCurve();
177 mAlphaCurve->setTitle( tr(
"Opacity" ) );
178 mAlphaCurve->setPen( QPen( QColor( 50, 50, 50 ), 0.0 ) ), mAlphaCurve->setRenderHint( QwtPlotItem::RenderAntialiased,
true );
179 mAlphaCurve->attach( mPlot );
181 mPlotFilter =
new QgsGradientPlotEventFilter( mPlot );
182 connect( mPlotFilter, &QgsGradientPlotEventFilter::mousePress,
this, &QgsGradientColorRampDialog::plotMousePress );
183 connect( mPlotFilter, &QgsGradientPlotEventFilter::mouseRelease,
this, &QgsGradientColorRampDialog::plotMouseRelease );
184 connect( mPlotFilter, &QgsGradientPlotEventFilter::mouseMove,
this, &QgsGradientColorRampDialog::plotMouseMove );
191 mHueCurve->setVisible( mPlotHueCheckbox->isChecked() );
192 mLightnessCurve->setVisible( mPlotLightnessCheckbox->isChecked() );
193 mSaturationCurve->setVisible( mPlotSaturationCheckbox->isChecked() );
194 mAlphaCurve->setVisible( mPlotAlphaCheckbox->isChecked() );
197 mStopEditor->selectStop( 0 );
199 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsGradientColorRampDialog::showHelp );
214 updateColorButtons();
226void QgsGradientColorRampDialog::cboType_currentIndexChanged(
int index )
231 updateColorButtons();
238void QgsGradientColorRampDialog::btnInformation_pressed()
240 if ( mRamp.info().isEmpty() )
243 QgsDialog *dlg =
new QgsDialog(
this );
244 QLabel *label =
nullptr;
247 QTableWidget *tableInfo =
new QTableWidget( dlg );
248 tableInfo->verticalHeader()->hide();
249 tableInfo->horizontalHeader()->hide();
250 tableInfo->setRowCount( mRamp.info().count() );
251 tableInfo->setColumnCount( 2 );
254 for ( QgsStringMap::const_iterator it = rampInfo.constBegin(); it != rampInfo.constEnd(); ++it )
256 if ( it.key().startsWith(
"cpt-city"_L1 ) )
258 tableInfo->setItem( i, 0,
new QTableWidgetItem( it.key() ) );
259 tableInfo->setItem( i, 1,
new QTableWidgetItem( it.value() ) );
260 tableInfo->resizeRowToContents( i );
263 tableInfo->resizeColumnToContents( 0 );
264 tableInfo->horizontalHeader()->setStretchLastSection(
true );
265 tableInfo->setRowCount( i );
266 tableInfo->setFixedHeight( tableInfo->rowHeight( 0 ) * i + 5 );
267 dlg->
layout()->addWidget( tableInfo );
268 dlg->resize( 600, 250 );
270 dlg->
layout()->addSpacing( 5 );
273 QString gradientFile = mRamp.info().value( u
"cpt-city-gradient"_s );
274 if ( !gradientFile.isNull() )
276 QString fileName = gradientFile;
278 if ( !QFile::exists( fileName ) )
280 fileName = gradientFile;
281 fileName.replace(
"<cpt-city>"_L1,
"http://soliton.vm.bytemark.co.uk/pub/cpt-city"_L1 );
283 label =
new QLabel( tr(
"Gradient file : %1" ).arg( fileName ), dlg );
284 label->setTextInteractionFlags( Qt::TextBrowserInteraction );
285 dlg->
layout()->addSpacing( 5 );
286 dlg->
layout()->addWidget( label );
290 QString licenseFile = mRamp.info().value( u
"cpt-city-license"_s );
291 if ( !licenseFile.isNull() )
293 QString fileName = licenseFile;
295 if ( !QFile::exists( fileName ) )
297 fileName = licenseFile;
298 fileName.replace(
"<cpt-city>"_L1,
"http://soliton.vm.bytemark.co.uk/pub/cpt-city"_L1 );
300 label =
new QLabel( tr(
"License file : %1" ).arg( fileName ), dlg );
301 label->setTextInteractionFlags( Qt::TextBrowserInteraction );
302 dlg->
layout()->addSpacing( 5 );
303 dlg->
layout()->addWidget( label );
304 if ( QFile::exists( fileName ) )
306 QTextEdit *textEdit =
new QTextEdit( dlg );
307 textEdit->setReadOnly(
true );
308 QFile file( fileName );
309 if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
311 textEdit->setText( file.readAll() );
313 dlg->
layout()->addSpacing( 5 );
314 dlg->
layout()->addWidget( textEdit );
315 dlg->resize( 600, 500 );
323void QgsGradientColorRampDialog::updateColorButtons()
325 btnColor1->blockSignals(
true );
326 btnColor1->setColor( mRamp.color1() );
327 btnColor1->blockSignals(
false );
328 btnColor2->blockSignals(
true );
329 btnColor2->setColor( mRamp.color2() );
330 btnColor2->blockSignals(
false );
333void QgsGradientColorRampDialog::updateStopEditor()
335 mStopEditor->blockSignals(
true );
336 mStopEditor->setGradientRamp( mRamp );
337 mStopEditor->blockSignals(
false );
340void QgsGradientColorRampDialog::selectedStopChanged(
const QgsGradientStop &stop )
343 mColorWidget->blockSignals(
true );
344 mColorWidget->setColor( stop.
color );
345 mColorWidget->blockSignals(
false );
346 mPositionSpinBox->blockSignals(
true );
347 mPositionSpinBox->setValue( stop.
offset * 100 );
348 mPositionSpinBox->blockSignals(
false );
350 mStopColorSpec->setCurrentIndex( mStopColorSpec->findData(
static_cast<int>( mStopEditor->selectedStop().colorSpec() ) ) );
351 mStopDirection->setCurrentIndex( mStopDirection->findData(
static_cast<int>( mStopEditor->selectedStop().direction() ) ) );
354 if ( ( stop.
offset == 0 && stop.
color == mRamp.color1() ) || ( stop.
offset == 1.0 && stop.
color == mRamp.color2() ) )
357 mPositionSpinBox->setDisabled(
true );
358 mDeleteStopButton->setDisabled(
true );
362 mPositionSpinBox->setDisabled(
false );
363 mDeleteStopButton->setDisabled(
false );
367 mStopColorSpec->setEnabled( !( stop.
offset == 0 && stop.
color == mRamp.color1() ) );
368 mStopDirection->setEnabled( !( stop.
offset == 0 && stop.
color == mRamp.color1() ) && hasDirection( mStopEditor->selectedStop().colorSpec() ) );
373void QgsGradientColorRampDialog::colorWidgetChanged(
const QColor &color )
375 mStopEditor->setSelectedStopColor( color );
378void QgsGradientColorRampDialog::mPositionSpinBox_valueChanged(
double val )
380 mStopEditor->setSelectedStopOffset( val / 100.0 );
383void QgsGradientColorRampDialog::mPlotHueCheckbox_toggled(
bool checked )
385 mHueCurve->setVisible( checked );
389void QgsGradientColorRampDialog::mPlotLightnessCheckbox_toggled(
bool checked )
391 mLightnessCurve->setVisible( checked );
395void QgsGradientColorRampDialog::mPlotSaturationCheckbox_toggled(
bool checked )
397 mSaturationCurve->setVisible( checked );
401void QgsGradientColorRampDialog::mPlotAlphaCheckbox_toggled(
bool checked )
403 mAlphaCurve->setVisible( checked );
407void QgsGradientColorRampDialog::plotMousePress( QPointF point )
412 mCurrentPlotColorComponent = -1;
413 mCurrentPlotMarkerIndex = -1;
416 for (
int i = 0; i < mRamp.count(); ++i )
419 double currentOff = 0.0;
423 currentCol = mRamp.color1();
425 else if ( i == mRamp.count() - 1 )
428 currentCol = mRamp.color2();
432 currentOff = mRamp.stops().at( i - 1 ).offset;
433 currentCol = mRamp.stops().at( i - 1 ).color;
437 if ( mPlotHueCheckbox->isChecked() )
439 currentDist = std::pow( point.x() - currentOff, 2.0 ) + std::pow( point.y() - currentCol.hslHueF(), 2.0 );
440 if ( currentDist < minDist )
442 minDist = currentDist;
443 mCurrentPlotColorComponent = 0;
444 mCurrentPlotMarkerIndex = i;
447 if ( mPlotLightnessCheckbox->isChecked() )
449 currentDist = std::pow( point.x() - currentOff, 2.0 ) + std::pow( point.y() - currentCol.lightnessF(), 2.0 );
450 if ( currentDist < minDist )
452 minDist = currentDist;
453 mCurrentPlotColorComponent = 1;
454 mCurrentPlotMarkerIndex = i;
457 if ( mPlotSaturationCheckbox->isChecked() )
459 currentDist = std::pow( point.x() - currentOff, 2.0 ) + std::pow( point.y() - currentCol.hslSaturationF(), 2.0 );
460 if ( currentDist < minDist )
462 minDist = currentDist;
463 mCurrentPlotColorComponent = 2;
464 mCurrentPlotMarkerIndex = i;
467 if ( mPlotAlphaCheckbox->isChecked() )
469 currentDist = std::pow( point.x() - currentOff, 2.0 ) + std::pow( point.y() - currentCol.alphaF(), 2.0 );
470 if ( currentDist < minDist )
472 minDist = currentDist;
473 mCurrentPlotColorComponent = 3;
474 mCurrentPlotMarkerIndex = i;
480 if ( mCurrentPlotMarkerIndex >= 0 )
481 mStopEditor->selectStop( mCurrentPlotMarkerIndex );
484void QgsGradientColorRampDialog::plotMouseRelease( QPointF )
486 mCurrentPlotColorComponent = -1;
489void QgsGradientColorRampDialog::plotMouseMove( QPointF point )
491 QColor newColor = mStopEditor->selectedStop().color;
493 if ( mCurrentPlotColorComponent == 0 )
494 newColor = QColor::fromHslF( std::clamp( point.y(), qreal( 0.0 ), qreal( 1.0 ) ), newColor.hslSaturationF(), newColor.lightnessF(), newColor.alphaF() );
495 else if ( mCurrentPlotColorComponent == 1 )
496 newColor = QColor::fromHslF( newColor.hslHueF(), newColor.hslSaturationF(), std::clamp( point.y(), qreal( 0.0 ), qreal( 1.0 ) ), newColor.alphaF() );
497 else if ( mCurrentPlotColorComponent == 2 )
498 newColor = QColor::fromHslF( newColor.hslHueF(), std::clamp( point.y(), qreal( 0.0 ), qreal( 1.0 ) ), newColor.lightnessF(), newColor.alphaF() );
499 else if ( mCurrentPlotColorComponent == 3 )
500 newColor = QColor::fromHslF( newColor.hslHueF(), newColor.hslSaturationF(), newColor.lightnessF(), std::clamp( point.y(), qreal( 0.0 ), qreal( 1.0 ) ) );
502 mStopEditor->setSelectedStopDetails( newColor, std::clamp( point.x(), qreal( 0.0 ), qreal( 1.0 ) ) );
505bool byX( QPointF p1, QPointF p2 )
507 return p1.x() < p2.x();
510void QgsGradientColorRampDialog::addPlotMarker(
double x,
double y,
const QColor &color,
bool isSelected )
512 QColor borderColor = color.darker( 200 );
513 borderColor.setAlpha( 255 );
515 QColor brushColor = color;
516 brushColor.setAlpha( 255 );
518 QwtPlotMarker *marker =
new QwtPlotMarker();
519 marker->setSymbol(
new QwtSymbol( QwtSymbol::Ellipse, QBrush( brushColor ), QPen( borderColor, isSelected ? 2 : 1 ), QSize( 8, 8 ) ) );
520 marker->setValue( x, y );
521 marker->attach( mPlot );
522 marker->setRenderHint( QwtPlotItem::RenderAntialiased,
true );
526void QgsGradientColorRampDialog::addMarkersForColor(
double x,
const QColor &color,
bool isSelected )
528 if ( mPlotHueCheckbox->isChecked() )
529 addPlotMarker( x, color.hslHueF(), color, isSelected && mCurrentPlotColorComponent == 0 );
530 if ( mPlotLightnessCheckbox->isChecked() )
531 addPlotMarker( x, color.lightnessF(), color, isSelected && mCurrentPlotColorComponent == 1 );
532 if ( mPlotSaturationCheckbox->isChecked() )
533 addPlotMarker( x, color.hslSaturationF(), color, isSelected && mCurrentPlotColorComponent == 2 );
534 if ( mPlotAlphaCheckbox->isChecked() )
535 addPlotMarker( x, color.alphaF(), color, isSelected && mCurrentPlotColorComponent == 3 );
538bool QgsGradientColorRampDialog::hasDirection( QColor::Spec colorSpec )
542 case QColor::Spec::Rgb:
543 case QColor::Spec::ExtendedRgb:
544 case QColor::Spec::Cmyk:
545 case QColor::Spec::Invalid:
548 case QColor::Spec::Hsv:
549 case QColor::Spec::Hsl:
556void QgsGradientColorRampDialog::updatePlot()
559 const auto constMMarkers = mMarkers;
560 for ( QwtPlotMarker *marker : constMMarkers )
567 QPolygonF lightnessPoints;
569 QPolygonF saturationPoints;
570 QPolygonF alphaPoints;
571 lightnessPoints << QPointF( 0.0, mRamp.color1().lightnessF() );
572 huePoints << QPointF( 0.0, mRamp.color1().hslHueF() );
573 saturationPoints << QPointF( 0.0, mRamp.color1().hslSaturationF() );
574 alphaPoints << QPointF( 0.0, mRamp.color1().alphaF() );
575 addMarkersForColor( 0, mRamp.color1(), mCurrentPlotMarkerIndex == 0 );
578 const auto constStops = mRamp.stops();
579 for (
const QgsGradientStop &stop : constStops )
581 lightnessPoints << QPointF( stop.
offset, stop.
color.lightnessF() );
582 huePoints << QPointF( stop.
offset, stop.
color.hslHueF() );
583 saturationPoints << QPointF( stop.
offset, stop.
color.hslSaturationF() );
584 alphaPoints << QPointF( stop.
offset, stop.
color.alphaF() );
586 addMarkersForColor( stop.
offset, stop.
color, mCurrentPlotMarkerIndex == i );
591 for (
double p = 0.001; p < 1.0; p += 0.001 )
593 QColor
c = mRamp.color( p );
594 lightnessPoints << QPointF( p,
c.lightnessF() );
595 huePoints << QPointF( p,
c.hslHueF() );
596 saturationPoints << QPointF( p,
c.hslSaturationF() );
597 alphaPoints << QPointF( p,
c.alphaF() );
600 lightnessPoints << QPointF( 1.0, mRamp.color2().lightnessF() );
601 huePoints << QPointF( 1.0, mRamp.color2().hslHueF() );
602 saturationPoints << QPointF( 1.0, mRamp.color2().hslSaturationF() );
603 alphaPoints << QPointF( 1.0, mRamp.color2().alphaF() );
604 addMarkersForColor( 1.0, mRamp.color2(), mCurrentPlotMarkerIndex == i );
606 std::sort( lightnessPoints.begin(), lightnessPoints.end(),
byX );
607 std::sort( huePoints.begin(), huePoints.end(),
byX );
608 std::sort( saturationPoints.begin(), saturationPoints.end(),
byX );
609 std::sort( alphaPoints.begin(), alphaPoints.end(),
byX );
611 mLightnessCurve->setSamples( lightnessPoints );
612 mHueCurve->setSamples( huePoints );
613 mSaturationCurve->setSamples( saturationPoints );
614 mAlphaCurve->setSamples( alphaPoints );
618void QgsGradientColorRampDialog::updateRampFromStopEditor()
620 mRamp = mStopEditor->gradientRamp();
623 mPositionSpinBox->blockSignals(
true );
624 mPositionSpinBox->setValue( mStopEditor->selectedStop().offset * 100 );
625 mPositionSpinBox->blockSignals(
false );
626 mColorWidget->blockSignals(
true );
627 mColorWidget->setColor( mStopEditor->selectedStop().color );
628 mColorWidget->blockSignals(
false );
630 mStopColorSpec->setCurrentIndex( mStopColorSpec->findData(
static_cast<int>( mStopEditor->selectedStop().colorSpec() ) ) );
631 mStopDirection->setCurrentIndex( mStopDirection->findData(
static_cast<int>( mStopEditor->selectedStop().direction() ) ) );
635 mStopColorSpec->setEnabled( !( mStopEditor->selectedStop().offset == 0 && mStopEditor->selectedStop().color == mRamp.color1() ) );
636 mStopDirection->setEnabled( !( mStopEditor->selectedStop().offset == 0 && mStopEditor->selectedStop().color == mRamp.color1() ) && hasDirection( mStopEditor->selectedStop().colorSpec() ) );
638 updateColorButtons();
646 mStopEditor->setColor1( color );
647 updateColorButtons();
652 mStopEditor->setColor2( color );
653 updateColorButtons();
656void QgsGradientColorRampDialog::showHelp()
664QgsGradientPlotEventFilter::QgsGradientPlotEventFilter( QwtPlot *plot )
668 mPlot->canvas()->installEventFilter(
this );
671bool QgsGradientPlotEventFilter::eventFilter( QObject *
object, QEvent *event )
673 if ( !mPlot->isEnabled() )
674 return QObject::eventFilter(
object, event );
676 switch ( event->type() )
678 case QEvent::MouseButtonPress:
680 const QMouseEvent *mouseEvent =
static_cast<QMouseEvent *
>( event );
681 if ( mouseEvent->button() == Qt::LeftButton )
683 emit mousePress( mapPoint( mouseEvent->pos() ) );
687 case QEvent::MouseMove:
689 const QMouseEvent *mouseEvent =
static_cast<QMouseEvent *
>( event );
690 if ( mouseEvent->buttons() & Qt::LeftButton )
693 emit mouseMove( mapPoint( mouseEvent->pos() ) );
697 case QEvent::MouseButtonRelease:
699 const QMouseEvent *mouseEvent =
static_cast<QMouseEvent *
>( event );
700 if ( mouseEvent->button() == Qt::LeftButton )
702 emit mouseRelease( mapPoint( mouseEvent->pos() ) );
710 return QObject::eventFilter(
object, event );
713QPointF QgsGradientPlotEventFilter::mapPoint( QPointF point )
const
718 return QPointF( mPlot->canvasMap( QwtPlot::xBottom ).invTransform( point.x() ), mPlot->canvasMap( QwtPlot::yLeft ).invTransform( point.y() ) );
AngularDirection
Angular directions.
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
static QString defaultBaseDir()
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
static const QgsSettingsEntryBool * settingsPlotSaturation
~QgsGradientColorRampDialog() override
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
void setColor2(const QColor &color)
Sets the end color for the gradient ramp.
QgsGradientColorRamp ramp
static const QgsSettingsEntryBool * settingsPlotHue
static const QgsSettingsEntryBool * settingsPlotAlpha
void setRamp(const QgsGradientColorRamp &ramp)
Sets the color ramp to show in the dialog.
QgsGradientColorRampDialog(const QgsGradientColorRamp &ramp, QWidget *parent=nullptr)
Constructor for QgsGradientColorRampDialog.
void setColor1(const QColor &color)
Sets the start color for the gradient ramp.
void changed()
Emitted when the dialog settings change.
static const QgsSettingsEntryBool * settingsPlotLightness
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
bool isDiscrete() const
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating betw...
void convertToDiscrete(bool discrete)
Converts a gradient with existing color stops to or from discrete interpolation.
void changed()
Emitted when the gradient ramp is changed by a user.
void deleteSelectedStop()
Deletes the current selected stop.
void selectedStopChanged(const QgsGradientStop &stop)
Emitted when the current selected stop changes.
Represents a color stop within a QgsGradientColorRamp color ramp.
double offset
Relative positional offset, between 0 and 1.
QColor color
Gradient color at stop.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
A boolean settings entry.
static QgsSettingsTreeNode * sTreeGradientEditor
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define BUILTIN_UNREACHABLE
QMap< QString, QString > QgsStringMap
bool byX(QPointF p1, QPointF p2)