31 #include <qwt_global.h> 32 #include <qwt_plot_canvas.h> 33 #include <qwt_legend.h> 35 #include <qwt_plot_curve.h> 36 #include <qwt_plot_grid.h> 37 #include <qwt_plot_marker.h> 38 #include <qwt_plot_picker.h> 39 #include <qwt_picker_machine.h> 40 #include <qwt_plot_zoomer.h> 41 #include <qwt_plot_layout.h> 42 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 43 #include <qwt_plot_renderer.h> 44 #include <qwt_plot_histogram.h> 60 , mRendererWidget( nullptr )
66 mRendererWidget =
nullptr;
67 mRendererName =
"singlebandgray";
72 mHistoPicker =
nullptr;
73 mHistoZoomer =
nullptr;
74 mHistoMarkerMin =
nullptr;
75 mHistoMarkerMax =
nullptr;
78 mHistoShowMarkers = settings.
value(
"/Raster/histogram/showMarkers",
false ).
toBool();
80 mHistoZoomToMinMax = settings.
value(
"/Raster/histogram/zoomToMinMax",
false ).
toBool();
81 mHistoUpdateStyleToMinMax = settings.
value(
"/Raster/histogram/updateStyleToMinMax",
true ).
toBool();
82 mHistoDrawLines = settings.
value(
"/Raster/histogram/drawLines",
true ).
toBool();
84 mHistoShowBands = ShowAll;
90 int myBandCountInt = mRasterLayer->
bandCount();
91 for (
int myIteratorInt = 1;
92 myIteratorInt <= myBandCountInt;
95 cboHistoBand->addItem( mRasterLayer->
bandName( myIteratorInt ) );
111 connect( leHistoMin, SIGNAL( editingFinished() ),
this, SLOT( applyHistoMin() ) );
112 connect( leHistoMax, SIGNAL( editingFinished() ),
this, SLOT( applyHistoMax() ) );
118 btnHistoActions->setMenu( menu );
126 action =
new QAction(
tr(
"Min/Max options" ), group );
129 action =
new QAction(
tr(
"Always show min/max markers" ), group );
134 action =
new QAction(
tr(
"Zoom to min/max" ), group );
139 action =
new QAction(
tr(
"Update style to min/max" ), group );
142 action->
setChecked( mHistoUpdateStyleToMinMax );
149 action =
new QAction(
tr(
"Visibility" ), group );
155 action =
new QAction(
tr(
"Show all bands" ), group );
158 action->
setChecked( mHistoShowBands == ShowAll );
160 action =
new QAction(
tr(
"Show RGB/Gray band(s)" ), group );
163 action->
setChecked( mHistoShowBands == ShowRGB );
165 action =
new QAction(
tr(
"Show selected band" ), group );
168 action->
setChecked( mHistoShowBands == ShowSelected );
175 action =
new QAction(
tr(
"Display" ), group );
179 action =
new QAction(
"", group );
183 action->
setText(
tr(
"Draw as lines" ) );
189 action->
setText(
tr(
"Draw as lines (only int layers)" ) );
195 action =
new QAction(
tr(
"Actions" ), group );
203 action =
new QAction(
tr(
"Reset" ), group );
211 action =
new QAction(
tr(
"Load min/max" ), group );
214 action =
new QAction(
tr(
"Estimate (faster)" ), group );
217 action =
new QAction(
tr(
"Actual (slower)" ), group );
220 action =
new QAction(
tr(
"Current extent" ), group );
223 action =
new QAction(
tr(
"Use stddev (1.0)" ), group );
226 action =
new QAction(
tr(
"Use stddev (custom)" ), group );
229 action =
new QAction(
tr(
"Load for each band" ), group );
237 action =
new QAction(
tr(
"Recompute Histogram" ), group );
252 mRendererName =
name;
253 mRendererWidget = rendererWidget;
255 on_cboHistoBand_currentIndexChanged( -1 );
263 on_cboHistoBand_currentIndexChanged( -1 );
269 btnHistoMin->setChecked(
false );
270 btnHistoMax->setChecked(
false );
274 void QgsRasterHistogramWidget::on_btnHistoCompute_clicked()
289 int myBandCountInt = mRasterLayer->
bandCount();
292 if ( ! forceComputeFlag )
294 for (
int myIteratorInt = 1;
295 myIteratorInt <= myBandCountInt;
298 int sampleSize = 250000;
299 if ( !mRasterLayer->
dataProvider()->
hasHistogram( myIteratorInt, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
QgsRectangle(), sampleSize ) )
308 stackedWidget2->setCurrentIndex( 1 );
309 connect( mRasterLayer, SIGNAL( progressUpdate(
int ) ), mHistogramProgress, SLOT( setValue(
int ) ) );
312 for (
int myIteratorInt = 1;
313 myIteratorInt <= myBandCountInt;
316 int sampleSize = 250000;
317 mRasterLayer->
dataProvider()->
histogram( myIteratorInt, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
QgsRectangle(), sampleSize );
320 disconnect( mRasterLayer, SIGNAL( progressUpdate(
int ) ), mHistogramProgress, SLOT( setValue(
int ) ) );
322 stackedWidget2->setCurrentIndex( 0 );
340 int myBandCountInt = mRasterLayer->
bandCount();
346 stackedWidget2->setCurrentIndex( 2 );
351 mpPlot->detachItems();
354 mpPlot->setAutoDelete(
true );
355 mpPlot->setTitle(
QObject::tr(
"Raster Histogram" ) );
356 mpPlot->insertLegend(
new QwtLegend(), QwtPlot::BottomLegend );
358 mpPlot->setAxisTitle( QwtPlot::xBottom,
QObject::tr(
"Pixel Value" ) );
359 mpPlot->setAxisTitle( QwtPlot::yLeft,
QObject::tr(
"Frequency" ) );
360 mpPlot->setAxisAutoScale( QwtPlot::yLeft );
364 QwtPlotGrid * myGrid =
new QwtPlotGrid();
365 myGrid->attach( mpPlot );
368 mHistoColors.
clear();
369 mHistoColors << Qt::black;
371 myColors << Qt::red << Qt::green << Qt::blue << Qt::magenta << Qt::darkYellow << Qt::cyan;
372 qsrand( myBandCountInt * 100 );
373 while ( myColors.
size() <= myBandCountInt )
376 QColor( 1 + (
int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ),
377 1 + (
int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ),
378 1 + (
int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ) );
381 qsrand( time(
nullptr ) );
386 if ( mRendererName ==
"singlebandgray" )
388 int myGrayBand = mySelectedBands[0];
389 for (
int i = 1; i <= myBandCountInt; i++ )
391 if ( i == myGrayBand )
393 mHistoColors << Qt::darkGray;
394 cboHistoBand->setItemData( i - 1,
QColor( Qt::darkGray ), Qt::ForegroundRole );
400 mHistoColors << myColors.
first();
405 mHistoColors << Qt::black;
407 cboHistoBand->setItemData( i - 1,
QColor( Qt::black ), Qt::ForegroundRole );
412 else if ( mRendererName ==
"multibandcolor" )
414 int myRedBand = mySelectedBands[0];
415 int myGreenBand = mySelectedBands[1];
416 int myBlueBand = mySelectedBands[2];
420 for (
int i = 1; i <= myBandCountInt; i++ )
423 if ( i == myRedBand )
425 else if ( i == myGreenBand )
427 else if ( i == myBlueBand )
433 myColor = myColors.
first();
440 cboHistoBand->setItemData( i - 1,
QColor( Qt::black ), Qt::ForegroundRole );
442 if ( i == myRedBand || i == myGreenBand || i == myBlueBand )
444 cboHistoBand->setItemData( i - 1, myColor, Qt::ForegroundRole );
446 mHistoColors << myColor;
451 mHistoColors << myColors;
466 bool myFirstIteration =
true;
468 mySelectedBands = histoSelectedBands();
469 double myBinXStep = 1;
472 for (
int myIteratorInt = 1;
473 myIteratorInt <= myBandCountInt;
477 if ( mHistoShowBands != ShowAll )
479 if ( ! mySelectedBands.
contains( myIteratorInt ) )
483 int sampleSize = 250000;
489 bool myDrawLines =
true;
490 if ( ! mHistoDrawLines &&
498 QwtPlotCurve * mypCurve =
nullptr;
501 mypCurve =
new QwtPlotCurve(
tr(
"Band %1" ).arg( myIteratorInt ) );
503 mypCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
504 mypCurve->setPen(
QPen( mHistoColors.
at( myIteratorInt ) ) );
507 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 508 QwtPlotHistogram * mypHisto = 0;
511 mypHisto =
new QwtPlotHistogram(
tr(
"Band %1" ).arg( myIteratorInt ) );
512 mypHisto->setRenderHint( QwtPlotItem::RenderAntialiased );
514 mypHisto->setPen(
QPen( Qt::lightGray ) );
516 mypHisto->setBrush(
QBrush( mHistoColors.
at( myIteratorInt ) ) );
519 HistogramItem *mypHistoItem =
nullptr;
522 mypHistoItem =
new HistogramItem(
tr(
"Band %1" ).arg( myIteratorInt ) );
523 mypHistoItem->setRenderHint( QwtPlotItem::RenderAntialiased );
524 mypHistoItem->setColor( mHistoColors.
at( myIteratorInt ) );
528 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 535 QwtArray<QwtDoubleInterval> intervalsHisto;
536 QwtArray<double> valuesHisto;
544 myBinX = myHistogram.
minimum + myBinXStep / 2.0;
552 for (
int myBin = 0; myBin < myHistogram.
binCount; myBin++ )
555 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 558 data <<
QPointF( myBinX, myBinValue );
562 dataHisto << QwtIntervalSample( myBinValue, myBinX - myBinXStep / 2.0, myBinX + myBinXStep / 2.0 );
567 myX2Data.
append(
double( myBinX ) );
568 myY2Data.
append(
double( myBinValue ) );
572 intervalsHisto.append( QwtDoubleInterval( myBinX - myBinXStep / 2.0, myBinX + myBinXStep / 2.0 ) );
573 valuesHisto.append(
double( myBinValue ) );
576 myBinX += myBinXStep;
579 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 582 mypCurve->setSamples( data );
583 mypCurve->attach( mpPlot );
587 mypHisto->setSamples( dataHisto );
588 mypHisto->attach( mpPlot );
593 mypCurve->setData( myX2Data, myY2Data );
594 mypCurve->attach( mpPlot );
598 mypHistoItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
599 mypHistoItem->attach( mpPlot );
603 if ( myFirstIteration || mHistoMin > myHistogram.
minimum )
605 mHistoMin = myHistogram.
minimum;
607 if ( myFirstIteration || mHistoMax < myHistogram.
maximum )
609 mHistoMax = myHistogram.
maximum;
611 QgsDebugMsg(
QString(
"computed histo min = %1 max = %2" ).arg( mHistoMin ).arg( mHistoMax ) );
612 myFirstIteration =
false;
615 if ( mHistoMin < mHistoMax )
621 mpPlot->setAxisScale( QwtPlot::xBottom,
622 mHistoMin - myBinXStep / 2,
623 mHistoMax + myBinXStep / 2 );
624 mpPlot->setEnabled(
true );
629 mHistoMarkerMin =
new QwtPlotMarker();
630 mHistoMarkerMin->attach( mpPlot );
631 mHistoMarkerMax =
new QwtPlotMarker();
632 mHistoMarkerMax->attach( mpPlot );
633 updateHistoMarkers();
638 mHistoPicker =
new QwtPlotPicker( mpPlot->canvas() );
640 mHistoPicker->setTrackerMode( QwtPicker::AlwaysOff );
641 mHistoPicker->setRubberBand( QwtPicker::VLineRubberBand );
642 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 643 mHistoPicker->setStateMachine(
new QwtPickerDragPointMachine );
644 connect( mHistoPicker, SIGNAL( selected(
const QPointF & ) ),
this, SLOT( histoPickerSelected(
const QPointF & ) ) );
646 mHistoPicker->setSelectionFlags( QwtPicker::PointSelection | QwtPicker::DragSelection );
647 connect( mHistoPicker, SIGNAL( selected(
const QwtDoublePoint & ) ),
this, SLOT( histoPickerSelectedQwt5(
const QwtDoublePoint & ) ) );
650 mHistoPicker->setEnabled(
false );
655 mHistoZoomer =
new QwtPlotZoomer( mpPlot->canvas() );
656 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 657 mHistoZoomer->setStateMachine(
new QwtPickerDragRectMachine );
659 mHistoZoomer->setSelectionFlags( QwtPicker::RectSelection | QwtPicker::DragSelection );
661 mHistoZoomer->setTrackerMode( QwtPicker::AlwaysOff );
663 mHistoZoomer->setEnabled(
true );
667 mpPlot->setDisabled(
true );
669 mHistoPicker->setEnabled(
false );
671 mHistoZoomer->setEnabled(
false );
674 disconnect( mRasterLayer, SIGNAL( progressUpdate(
int ) ), mHistogramProgress, SLOT( setValue(
int ) ) );
675 stackedWidget2->setCurrentIndex( 0 );
688 QFileInfo myInfo( myFileNameAndFilter.first );
701 if ( ! myDir.exists() )
703 QgsDebugMsg(
QString(
"Error, directory %1 non-existent (theFilename = %2)" ).arg( myDir.absolutePath(), theFilename ) );
708 QPixmap myPixmap( width, height );
709 QRect myQRect( 5, 5, width - 10, height - 10 );
710 myPixmap.
fill( Qt::white );
712 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 713 QwtPlotRenderer myRenderer;
714 myRenderer.setDiscardFlags( QwtPlotRenderer::DiscardBackground |
715 QwtPlotRenderer::DiscardCanvasBackground );
716 myRenderer.setLayoutFlags( QwtPlotRenderer::FrameWithScales );
719 myPainter.
begin( &myPixmap );
720 myRenderer.render( mpPlot, &myPainter, myQRect );
723 QwtPlotPrintFilter myFilter;
724 int myOptions = QwtPlotPrintFilter::PrintAll;
725 myOptions &= ~QwtPlotPrintFilter::PrintBackground;
726 myOptions |= QwtPlotPrintFilter::PrintFrameWithScales;
727 myFilter.setOptions( myOptions );
730 myPainter.
begin( &myPixmap );
731 mpPlot->print( &myPainter, myQRect, myFilter );
741 myPixmap.
save( theFilename,
nullptr, quality );
749 cboHistoBand->setCurrentIndex( theBandNo - 1 );
752 void QgsRasterHistogramWidget::on_cboHistoBand_currentIndexChanged(
int index )
754 if ( mHistoShowBands == ShowSelected )
758 index = cboHistoBand->currentIndex();
761 mHistoPicker->setEnabled(
false );
762 mHistoPicker->setRubberBandPen(
QPen( mHistoColors.
at( index + 1 ) ) );
765 mHistoZoomer->setEnabled(
true );
766 btnHistoMin->setEnabled(
true );
767 btnHistoMax->setEnabled(
true );
770 leHistoMin->setText( myMinMax.first );
771 leHistoMax->setText( myMinMax.second );
777 void QgsRasterHistogramWidget::histoActionTriggered(
QAction* action )
786 if ( actionName ==
"" )
790 QgsDebugMsg(
QString(
"band = %1 action = %2" ).arg( cboHistoBand->currentIndex() + 1 ).arg( actionName ) );
793 if ( actionName ==
"Show markers" )
795 mHistoShowMarkers = actionFlag;
797 settings.
setValue(
"/Raster/histogram/showMarkers", mHistoShowMarkers );
798 updateHistoMarkers();
801 else if ( actionName ==
"Zoom min_max" )
803 mHistoZoomToMinMax = actionFlag;
805 settings.
setValue(
"/Raster/histogram/zoomToMinMax", mHistoZoomToMinMax );
808 else if ( actionName ==
"Update min_max" )
810 mHistoUpdateStyleToMinMax = actionFlag;
812 settings.
setValue(
"/Raster/histogram/updateStyleToMinMax", mHistoUpdateStyleToMinMax );
815 else if ( actionName ==
"Show all" )
817 mHistoShowBands = ShowAll;
822 else if ( actionName ==
"Show selected" )
824 mHistoShowBands = ShowSelected;
829 else if ( actionName ==
"Show RGB" )
831 mHistoShowBands = ShowRGB;
836 else if ( actionName ==
"Draw lines" )
838 mHistoDrawLines = actionFlag;
840 settings.
setValue(
"/Raster/histogram/drawLines", mHistoDrawLines );
841 on_btnHistoCompute_clicked();
845 else if ( actionName ==
"Load apply all" )
847 mHistoLoadApplyAll = actionFlag;
848 settings.setValue(
"/Raster/histogram/loadApplyAll", mHistoLoadApplyAll );
854 else if ( actionName.
left( 5 ) ==
"Load " && mRendererWidget )
860 double minMaxValues[2];
863 if ( mHistoLoadApplyAll )
865 int myBandCountInt = mRasterLayer->
bandCount();
866 for (
int i = 1; i <= myBandCountInt; i++ )
868 if ( i != cboHistoBand->currentIndex() + 1 )
875 myBands << cboHistoBand->currentIndex() + 1;
879 double myStdDev = 1.0;
880 if ( actionName ==
"Load stddev" )
887 leHistoMin->blockSignals(
true );
888 leHistoMax->blockSignals(
true );
891 Q_FOREACH (
int theBandNo, myBands )
895 if ( actionName ==
"Load actual" )
898 theBandNo, minMaxValues );
900 else if ( actionName ==
"Load estimate" )
903 theBandNo, minMaxValues );
905 else if ( actionName ==
"Load extent" )
908 theBandNo, minMaxValues );
910 else if ( actionName ==
"Load 1 stddev" ||
911 actionName ==
"Load stddev" )
913 ok = mRendererWidget->bandMinMaxFromStdDev( myStdDev, theBandNo, minMaxValues );
918 cboHistoBand->setCurrentIndex( theBandNo - 1 );
919 if ( !ok || actionName ==
"Load reset" )
941 leHistoMin->blockSignals(
false );
942 leHistoMax->blockSignals(
false );
943 updateHistoMarkers();
945 else if ( actionName ==
"Compute histogram" )
947 on_btnHistoCompute_clicked();
956 void QgsRasterHistogramWidget::applyHistoMin()
958 if ( ! mRendererWidget )
961 int theBandNo = cboHistoBand->currentIndex() + 1;
964 for (
int i = 0; i <= mySelectedBands.
size(); i++ )
968 min = leHistoMin->text();
969 if ( mHistoUpdateStyleToMinMax )
970 mRendererWidget->
setMin( min, i );
974 updateHistoMarkers();
976 if ( ! min.
isEmpty() && mHistoZoomToMinMax && mHistoZoomer )
980 mHistoZoomer->zoom( rect );
985 void QgsRasterHistogramWidget::applyHistoMax()
987 if ( ! mRendererWidget )
990 int theBandNo = cboHistoBand->currentIndex() + 1;
993 for (
int i = 0; i <= mySelectedBands.
size(); i++ )
997 max = leHistoMax->text();
998 if ( mHistoUpdateStyleToMinMax )
999 mRendererWidget->
setMax( max, i );
1003 updateHistoMarkers();
1005 if ( ! max.
isEmpty() && mHistoZoomToMinMax && mHistoZoomer )
1009 mHistoZoomer->zoom( rect );
1014 void QgsRasterHistogramWidget::on_btnHistoMin_toggled()
1016 if ( mpPlot && mHistoPicker )
1020 if ( btnHistoMin->isChecked() )
1022 btnHistoMax->setChecked(
false );
1026 mHistoZoomer->setEnabled( ! btnHistoMin->isChecked() );
1027 mHistoPicker->setEnabled( btnHistoMin->isChecked() );
1029 updateHistoMarkers();
1032 void QgsRasterHistogramWidget::on_btnHistoMax_toggled()
1034 if ( mpPlot && mHistoPicker )
1038 if ( btnHistoMax->isChecked() )
1040 btnHistoMin->setChecked(
false );
1044 mHistoZoomer->setEnabled( ! btnHistoMax->isChecked() );
1045 mHistoPicker->setEnabled( btnHistoMax->isChecked() );
1047 updateHistoMarkers();
1054 if ( !scale )
return "";
1058 double diff = ( minorTicks[1] - minorTicks[0] ) / div;
1059 double min = majorTicks[0] - diff;
1061 min -= ( majorTicks[1] - majorTicks[0] );
1062 #if defined(QWT_VERSION) && QWT_VERSION<0x050200 1063 double max = scale->hBound();
1065 double max = scale->upperBound();
1067 double closest = target;
1068 double current =
min;
1070 while ( current < max )
1073 if ( current > target )
1075 closest = ( qAbs( target - current + diff ) < qAbs( target - current ) ) ? current - diff : current;
1084 void QgsRasterHistogramWidget::histoPickerSelected(
QPointF pos )
1086 if ( btnHistoMin->isChecked() || btnHistoMax->isChecked() )
1088 #if defined(QWT_VERSION) && QWT_VERSION>=0x060100 1089 const QwtScaleDiv * scale = &mpPlot->axisScaleDiv( QwtPlot::xBottom );
1091 const QwtScaleDiv * scale = mpPlot->axisScaleDiv( QwtPlot::xBottom );
1094 if ( btnHistoMin->isChecked() )
1098 btnHistoMin->setChecked(
false );
1104 btnHistoMax->setChecked(
false );
1111 void QgsRasterHistogramWidget::histoPickerSelectedQwt5( QwtDoublePoint pos )
1113 histoPickerSelected(
QPointF( pos.x(), pos.y() ) );
1116 void QgsRasterHistogramWidget::updateHistoMarkers()
1119 if ( leHistoMin->signalsBlocked() )
1122 if ( !mpPlot || !mHistoMarkerMin || !mHistoMarkerMax )
1125 int theBandNo = cboHistoBand->currentIndex() + 1;
1128 if (( ! mHistoShowMarkers && ! btnHistoMin->isChecked() && ! btnHistoMax->isChecked() ) ||
1129 ( ! mySelectedBands.
isEmpty() && ! mySelectedBands.
contains( theBandNo ) ) )
1131 mHistoMarkerMin->hide();
1132 mHistoMarkerMax->hide();
1137 double minVal = mHistoMin;
1138 double maxVal = mHistoMax;
1139 QString minStr = leHistoMin->text();
1140 QString maxStr = leHistoMax->text();
1146 QPen linePen =
QPen( mHistoColors.
at( theBandNo ) );
1148 mHistoMarkerMin->setLineStyle( QwtPlotMarker::VLine );
1149 mHistoMarkerMin->setLinePen( linePen );
1150 mHistoMarkerMin->setXValue( minVal );
1151 mHistoMarkerMin->show();
1152 mHistoMarkerMax->setLineStyle( QwtPlotMarker::VLine );
1153 mHistoMarkerMax->setLinePen( linePen );
1154 mHistoMarkerMax->setXValue( maxVal );
1155 mHistoMarkerMax->show();
1161 QList< int > QgsRasterHistogramWidget::histoSelectedBands()
1165 if ( mHistoShowBands != ShowAll )
1167 if ( mHistoShowBands == ShowSelected )
1169 mySelectedBands << cboHistoBand->currentIndex() + 1;
1171 else if ( mHistoShowBands == ShowRGB )
1173 mySelectedBands = rendererSelectedBands();
1177 return mySelectedBands;
1180 QList< int > QgsRasterHistogramWidget::rendererSelectedBands()
1184 if ( ! mRendererWidget )
1186 mySelectedBands << -1 << -1 << -1;
1187 return mySelectedBands;
1190 if ( mRendererName ==
"singlebandgray" )
1194 else if ( mRendererName ==
"multibandcolor" )
1196 for (
int i = 0; i <= 2; i++ )
1202 return mySelectedBands;
1209 if ( ! mRendererWidget )
1212 if ( mRendererName ==
"singlebandgray" )
1216 myMinMax.first = mRendererWidget->
min();
1217 myMinMax.second = mRendererWidget->
max();
1220 else if ( mRendererName ==
"multibandcolor" )
1222 for (
int i = 0; i <= 2; i++ )
1226 myMinMax.first = mRendererWidget->
min( i );
1227 myMinMax.second = mRendererWidget->
max( i );
1243 if ( myMinMax.first.isEmpty() )
1245 if ( myMinMax.second.isEmpty() )
1248 QgsDebugMsg(
QString(
"bandNo %1 got min/max [%2] [%3]" ).arg( theBandNo ).arg( myMinMax.first, myMinMax.second ) );
void setText(const QString &text)
Eight bit unsigned integer (quint8)
A rectangle specified with double values.
void setStyle(Qt::PenStyle style)
void setSeparator(bool b)
int bandCount() const
Get the number of bands in this layer.
void append(const T &value)
void fill(const QColor &color)
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
double minimum
The minimum histogram value.
static double maximumValuePossible(QGis::DataType)
Helper function that returns the maximum possible value for a GDAL data type.
double toDouble(bool *ok) const
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QString tr(const char *sourceText, const char *disambiguation, int n)
static QPixmap getThemePixmap(const QString &theName)
Helper to get a theme icon as a pixmap.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
void setValue(const QString &key, const QVariant &value)
const char * name() const
QString number(int n, int base)
static double minimumValuePossible(QGis::DataType)
Helper function that returns the minimum possible value for a GDAL data type.
virtual bool hasHistogram(int theBandNo, int theBinCount, double theMinimum=std::numeric_limits< double >::quiet_NaN(), double theMaximum=std::numeric_limits< double >::quiet_NaN(), const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0, bool theIncludeOutOfRange=false)
Returns true if histogram is available (cached, already calculated), the parameters are the same as i...
bool save(const QString &fileName, const char *format, int quality) const
Sixteen bit unsigned integer (quint16)
virtual QGis::DataType srcDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
Thirty two bit signed integer (qint32)
Thirty two bit unsigned integer (quint32)
void setOverrideCursor(const QCursor &cursor)
const QString bandName(int theBandNoInt)
Get the name of a band given its number.
void restoreOverrideCursor()
Sixteen bit signed integer (qint16)
virtual QgsRasterHistogram histogram(int theBandNo, int theBinCount=0, double theMinimum=std::numeric_limits< double >::quiet_NaN(), double theMaximum=std::numeric_limits< double >::quiet_NaN(), const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0, bool theIncludeOutOfRange=false)
Get histogram.
void setData(const QVariant &userData)
double maximum
The maximum histogram value.
bool contains(const T &value) const
virtual QGis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
const T & at(int i) const
QVariant value(const QString &key, const QVariant &defaultValue) const
DataType
Raster data types.
QString left(int n) const
The QgsRasterHistogram is a container for histogram of a single raster band.
QPair< QString, QString > GUI_EXPORT getSaveAsImageName(QWidget *theParent, const QString &theMessage, const QString &defaultFilename)
A helper function to get an image name from the user.
int binCount
Number of bins (intervals,buckets) in histogram.
QgsRasterDataProvider * dataProvider()
Returns the data provider.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
HistogramVector histogramVector
Store the histogram for a given layer.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool begin(QPaintDevice *device)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QCursor * overrideCursor()