29#include "moc_qgssinglebandgrayrendererwidget.cpp"
31using namespace Qt::StringLiterals;
37 connect( mMinLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandGrayRendererWidget::mMinLineEdit_textChanged );
38 connect( mMaxLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandGrayRendererWidget::mMaxLineEdit_textChanged );
40 connect( mLegendSettingsButton, &QPushButton::clicked,
this, &QgsSingleBandGrayRendererWidget::showLegendSettings );
57 mMinMaxWidget->setExtent( extent );
58 mMinMaxWidget->setMapCanvas(
mCanvas );
60 QHBoxLayout *layout =
new QHBoxLayout();
61 layout->setContentsMargins( 0, 0, 0, 0 );
62 mMinMaxContainerWidget->setLayout( layout );
63 layout->addWidget( mMinMaxWidget );
96 const int band = mGrayBandComboBox->currentBand();
104 renderer->setContrastEnhancement( e );
107 renderer->setMinMaxOrigin( mMinMaxWidget->minMaxOrigin() );
116 mMinMaxWidget->doComputations();
122 mMinMaxWidget->setMapCanvas( canvas );
125void QgsSingleBandGrayRendererWidget::mMinLineEdit_textChanged(
const QString & )
127 QString text = mMinLineEdit->text();
129 if ( mMinLineEdit->validator()->validate( text, pos ) == QValidator::Acceptable )
135void QgsSingleBandGrayRendererWidget::mMaxLineEdit_textChanged(
const QString & )
137 QString text = mMaxLineEdit->text();
139 if ( mMaxLineEdit->validator()->validate( text, pos ) == QValidator::Acceptable )
145void QgsSingleBandGrayRendererWidget::minMaxModified()
147 if ( !mDisableMinMaxWidgetRefresh )
153 mMinMaxWidget->userHasSetManualMinMaxValues();
165 mDisableMinMaxWidgetRefresh =
true;
166 if ( std::isnan(
min ) )
168 mMinLineEdit->clear();
172 mMinLineEdit->setText( QLocale().toString(
min ) );
175 if ( std::isnan(
max ) )
177 mMaxLineEdit->clear();
181 mMaxLineEdit->setText( QLocale().toString(
max ) );
183 mDisableMinMaxWidgetRefresh =
false;
186void QgsSingleBandGrayRendererWidget::bandChanged()
189 myBands.append( mGrayBandComboBox->currentBand() );
200 mGrayBandComboBox->setBand( gr->
inputBand() );
201 mMinMaxWidget->setBands( QList<int>() << gr->
inputBand() );
202 mGradientComboBox->setCurrentIndex( mGradientComboBox->findData( gr->
gradient() ) );
208 mDisableMinMaxWidgetRefresh =
true;
209 mMinLineEdit->setText( QLocale().toString( ce->
minimumValue() ) );
210 mMaxLineEdit->setText( QLocale().toString( ce->
maximumValue() ) );
211 mDisableMinMaxWidgetRefresh =
false;
213 mContrastEnhancementComboBox->setCurrentIndex( mContrastEnhancementComboBox->findData( (
int ) ( ce->
contrastEnhancementAlgorithm() ) ) );
216 mMinMaxWidget->setFromMinMaxOrigin( gr->
minMaxOrigin() );
225 mDisableMinMaxWidgetRefresh =
true;
226 mMinLineEdit->setText( value );
227 mDisableMinMaxWidgetRefresh =
false;
232 mDisableMinMaxWidgetRefresh =
true;
233 mMaxLineEdit->setText( value );
234 mDisableMinMaxWidgetRefresh =
false;
237void QgsSingleBandGrayRendererWidget::showLegendSettings()
247 mLegendSettings = legendPanel->
settings();
254 QgsColorRampLegendNodeDialog dialog( mLegendSettings,
this );
255 dialog.setUseContinuousRampCheckBoxVisibility(
false );
256 dialog.setWindowTitle( tr(
"Legend Settings" ) );
259 mLegendSettings = dialog.settings();
272 mDisableMinMaxWidgetRefresh =
true;
273 mContrastEnhancementComboBox->setCurrentIndex( mContrastEnhancementComboBox->findData(
static_cast<int>(
algorithm ) ) );
274 mDisableMinMaxWidgetRefresh =
false;
DataType
Raster data types.
Settings for a color ramp legend node.
Handles contrast enhancement and clipping.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used.
@ StretchToMinimumMaximum
Linear histogram.
@ StretchAndClipToMinimumMaximum
@ NoEnhancement
Default color scaling algorithm, no scaling is applied.
void setMinimumValue(double value, bool generateTable=true)
Sets the minimum value for the contrast enhancement range.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm, bool generateTable=true)
Sets the contrast enhancement algorithm.
double minimumValue() const
Returns the minimum value for the contrast enhancement range.
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
void setMaximumValue(double value, bool generateTable=true)
Sets the maximum value for the contrast enhancement range.
double maximumValue() const
Returns the maximum value for the contrast enhancement range.
A custom validator which allows entry of doubles in a locale-tolerant way.
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Map canvas is a class for displaying all GIS data types on a canvas.
void bandChanged(int band)
Emitted when the currently selected band changes.
Base class for raster data providers.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Represents a raster layer.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
Raster renderer pipe that applies colors to a raster.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
A rectangle specified with double values.
Raster renderer pipe for single band gray.
const QgsContrastEnhancement * contrastEnhancement() const
Gradient gradient() const
const QgsColorRampLegendNodeSettings * legendSettings() const
Returns the color ramp shader legend settings.
int inputBand() const override
Returns the input band for the renderer, or -1 if no input band is available.
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 allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
#define QgsDebugMsgLevel(str, level)