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()
290 int myBandCountInt = mRasterLayer->
bandCount();
293 if ( ! forceComputeFlag )
295 for (
int myIteratorInt = 1;
296 myIteratorInt <= myBandCountInt;
299 int sampleSize = 250000;
300 if ( !mRasterLayer->
dataProvider()->
hasHistogram( myIteratorInt, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
QgsRectangle(), sampleSize ) )
309 stackedWidget2->setCurrentIndex( 1 );
310 connect( mRasterLayer, SIGNAL( progressUpdate(
int ) ), mHistogramProgress, SLOT( setValue(
int ) ) );
313 for (
int myIteratorInt = 1;
314 myIteratorInt <= myBandCountInt;
317 int sampleSize = 250000;
318 mRasterLayer->
dataProvider()->
histogram( myIteratorInt, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
QgsRectangle(), sampleSize );
321 disconnect( mRasterLayer, SIGNAL( progressUpdate(
int ) ), mHistogramProgress, SLOT( setValue(
int ) ) );
323 stackedWidget2->setCurrentIndex( 0 );
341 int myBandCountInt = mRasterLayer->
bandCount();
348 stackedWidget2->setCurrentIndex( 2 );
353 mpPlot->detachItems();
356 mpPlot->setAutoDelete(
true );
357 mpPlot->setTitle(
QObject::tr(
"Raster Histogram" ) );
358 mpPlot->insertLegend(
new QwtLegend(), QwtPlot::BottomLegend );
360 mpPlot->setAxisTitle( QwtPlot::xBottom,
QObject::tr(
"Pixel Value" ) );
361 mpPlot->setAxisTitle( QwtPlot::yLeft,
QObject::tr(
"Frequency" ) );
362 mpPlot->setAxisAutoScale( QwtPlot::yLeft );
366 QwtPlotGrid * myGrid =
new QwtPlotGrid();
367 myGrid->attach( mpPlot );
370 mHistoColors.
clear();
371 mHistoColors << Qt::black;
373 myColors << Qt::red << Qt::green << Qt::blue << Qt::magenta << Qt::darkYellow << Qt::cyan;
374 qsrand( myBandCountInt * 100 );
375 while ( myColors.
size() <= myBandCountInt )
378 QColor( 1 + (
int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ),
379 1 + (
int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ),
380 1 + (
int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ) );
383 qsrand( time(
nullptr ) );
388 if ( mRendererName ==
"singlebandgray" )
390 int myGrayBand = mySelectedBands[0];
391 for (
int i = 1; i <= myBandCountInt; i++ )
393 if ( i == myGrayBand )
395 mHistoColors << Qt::darkGray;
396 cboHistoBand->setItemData( i - 1,
QColor( Qt::darkGray ), Qt::ForegroundRole );
402 mHistoColors << myColors.
first();
407 mHistoColors << Qt::black;
409 cboHistoBand->setItemData( i - 1,
QColor( Qt::black ), Qt::ForegroundRole );
414 else if ( mRendererName ==
"multibandcolor" )
416 int myRedBand = mySelectedBands[0];
417 int myGreenBand = mySelectedBands[1];
418 int myBlueBand = mySelectedBands[2];
422 for (
int i = 1; i <= myBandCountInt; i++ )
425 if ( i == myRedBand )
427 else if ( i == myGreenBand )
429 else if ( i == myBlueBand )
435 myColor = myColors.
first();
442 cboHistoBand->setItemData( i - 1,
QColor( Qt::black ), Qt::ForegroundRole );
444 if ( i == myRedBand || i == myGreenBand || i == myBlueBand )
446 cboHistoBand->setItemData( i - 1, myColor, Qt::ForegroundRole );
448 mHistoColors << myColor;
453 mHistoColors << myColors;
468 bool myFirstIteration =
true;
470 mySelectedBands = histoSelectedBands();
471 double myBinXStep = 1;
474 for (
int myIteratorInt = 1;
475 myIteratorInt <= myBandCountInt;
479 if ( mHistoShowBands != ShowAll )
481 if ( ! mySelectedBands.
contains( myIteratorInt ) )
485 int sampleSize = 250000;
491 bool myDrawLines =
true;
492 if ( ! mHistoDrawLines &&
500 QwtPlotCurve * mypCurve =
nullptr;
503 mypCurve =
new QwtPlotCurve(
tr(
"Band %1" ).arg( myIteratorInt ) );
505 mypCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
506 mypCurve->setPen(
QPen( mHistoColors.
at( myIteratorInt ) ) );
509 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 510 QwtPlotHistogram * mypHisto = 0;
513 mypHisto =
new QwtPlotHistogram(
tr(
"Band %1" ).arg( myIteratorInt ) );
514 mypHisto->setRenderHint( QwtPlotItem::RenderAntialiased );
516 mypHisto->setPen(
QPen( Qt::lightGray ) );
518 mypHisto->setBrush(
QBrush( mHistoColors.
at( myIteratorInt ) ) );
521 HistogramItem *mypHistoItem =
nullptr;
524 mypHistoItem =
new HistogramItem(
tr(
"Band %1" ).arg( myIteratorInt ) );
525 mypHistoItem->setRenderHint( QwtPlotItem::RenderAntialiased );
526 mypHistoItem->setColor( mHistoColors.
at( myIteratorInt ) );
530 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 537 QwtArray<QwtDoubleInterval> intervalsHisto;
538 QwtArray<double> valuesHisto;
546 myBinX = myHistogram.
minimum + myBinXStep / 2.0;
554 for (
int myBin = 0; myBin < myHistogram.
binCount; myBin++ )
557 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 560 data <<
QPointF( myBinX, myBinValue );
564 dataHisto << QwtIntervalSample( myBinValue, myBinX - myBinXStep / 2.0, myBinX + myBinXStep / 2.0 );
569 myX2Data.
append(
double( myBinX ) );
570 myY2Data.
append(
double( myBinValue ) );
574 intervalsHisto.append( QwtDoubleInterval( myBinX - myBinXStep / 2.0, myBinX + myBinXStep / 2.0 ) );
575 valuesHisto.append(
double( myBinValue ) );
578 myBinX += myBinXStep;
581 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 584 mypCurve->setSamples( data );
585 mypCurve->attach( mpPlot );
589 mypHisto->setSamples( dataHisto );
590 mypHisto->attach( mpPlot );
595 mypCurve->setData( myX2Data, myY2Data );
596 mypCurve->attach( mpPlot );
600 mypHistoItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
601 mypHistoItem->attach( mpPlot );
605 if ( myFirstIteration || mHistoMin > myHistogram.
minimum )
607 mHistoMin = myHistogram.
minimum;
609 if ( myFirstIteration || mHistoMax < myHistogram.
maximum )
611 mHistoMax = myHistogram.
maximum;
613 QgsDebugMsg(
QString(
"computed histo min = %1 max = %2" ).arg( mHistoMin ).arg( mHistoMax ) );
614 myFirstIteration =
false;
617 if ( mHistoMin < mHistoMax )
623 mpPlot->setAxisScale( QwtPlot::xBottom,
624 mHistoMin - myBinXStep / 2,
625 mHistoMax + myBinXStep / 2 );
626 mpPlot->setEnabled(
true );
631 mHistoMarkerMin =
new QwtPlotMarker();
632 mHistoMarkerMin->attach( mpPlot );
633 mHistoMarkerMax =
new QwtPlotMarker();
634 mHistoMarkerMax->attach( mpPlot );
635 updateHistoMarkers();
640 mHistoPicker =
new QwtPlotPicker( mpPlot->canvas() );
642 mHistoPicker->setTrackerMode( QwtPicker::AlwaysOff );
643 mHistoPicker->setRubberBand( QwtPicker::VLineRubberBand );
644 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 645 mHistoPicker->setStateMachine(
new QwtPickerDragPointMachine );
646 connect( mHistoPicker, SIGNAL( selected(
const QPointF & ) ),
this, SLOT( histoPickerSelected(
const QPointF & ) ) );
648 mHistoPicker->setSelectionFlags( QwtPicker::PointSelection | QwtPicker::DragSelection );
649 connect( mHistoPicker, SIGNAL( selected(
const QwtDoublePoint & ) ),
this, SLOT( histoPickerSelectedQwt5(
const QwtDoublePoint & ) ) );
652 mHistoPicker->setEnabled(
false );
657 mHistoZoomer =
new QwtPlotZoomer( mpPlot->canvas() );
658 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 659 mHistoZoomer->setStateMachine(
new QwtPickerDragRectMachine );
661 mHistoZoomer->setSelectionFlags( QwtPicker::RectSelection | QwtPicker::DragSelection );
663 mHistoZoomer->setTrackerMode( QwtPicker::AlwaysOff );
665 mHistoZoomer->setEnabled(
true );
669 mpPlot->setDisabled(
true );
671 mHistoPicker->setEnabled(
false );
673 mHistoZoomer->setEnabled(
false );
676 disconnect( mRasterLayer, SIGNAL( progressUpdate(
int ) ), mHistogramProgress, SLOT( setValue(
int ) ) );
677 stackedWidget2->setCurrentIndex( 0 );
690 QFileInfo myInfo( myFileNameAndFilter.first );
703 if ( ! myDir.exists() )
705 QgsDebugMsg(
QString(
"Error, directory %1 non-existent (theFilename = %2)" ).arg( myDir.absolutePath(), theFilename ) );
710 QPixmap myPixmap( width, height );
711 QRect myQRect( 5, 5, width - 10, height - 10 );
712 myPixmap.
fill( Qt::white );
714 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000 715 QwtPlotRenderer myRenderer;
716 myRenderer.setDiscardFlags( QwtPlotRenderer::DiscardBackground |
717 QwtPlotRenderer::DiscardCanvasBackground );
718 myRenderer.setLayoutFlags( QwtPlotRenderer::FrameWithScales );
721 myPainter.
begin( &myPixmap );
722 myRenderer.render( mpPlot, &myPainter, myQRect );
725 QwtPlotPrintFilter myFilter;
726 int myOptions = QwtPlotPrintFilter::PrintAll;
727 myOptions &= ~QwtPlotPrintFilter::PrintBackground;
728 myOptions |= QwtPlotPrintFilter::PrintFrameWithScales;
729 myFilter.setOptions( myOptions );
732 myPainter.
begin( &myPixmap );
733 mpPlot->print( &myPainter, myQRect, myFilter );
743 myPixmap.
save( theFilename,
nullptr, quality );
751 cboHistoBand->setCurrentIndex( theBandNo - 1 );
754 void QgsRasterHistogramWidget::on_cboHistoBand_currentIndexChanged(
int index )
756 if ( mHistoShowBands == ShowSelected )
760 index = cboHistoBand->currentIndex();
763 mHistoPicker->setEnabled(
false );
764 mHistoPicker->setRubberBandPen(
QPen( mHistoColors.
at( index + 1 ) ) );
767 mHistoZoomer->setEnabled(
true );
768 btnHistoMin->setEnabled(
true );
769 btnHistoMax->setEnabled(
true );
772 leHistoMin->setText( myMinMax.first );
773 leHistoMax->setText( myMinMax.second );
779 void QgsRasterHistogramWidget::histoActionTriggered(
QAction* action )
788 if ( actionName ==
"" )
792 QgsDebugMsg(
QString(
"band = %1 action = %2" ).arg( cboHistoBand->currentIndex() + 1 ).arg( actionName ) );
795 if ( actionName ==
"Show markers" )
797 mHistoShowMarkers = actionFlag;
799 settings.
setValue(
"/Raster/histogram/showMarkers", mHistoShowMarkers );
800 updateHistoMarkers();
803 else if ( actionName ==
"Zoom min_max" )
805 mHistoZoomToMinMax = actionFlag;
807 settings.
setValue(
"/Raster/histogram/zoomToMinMax", mHistoZoomToMinMax );
810 else if ( actionName ==
"Update min_max" )
812 mHistoUpdateStyleToMinMax = actionFlag;
814 settings.
setValue(
"/Raster/histogram/updateStyleToMinMax", mHistoUpdateStyleToMinMax );
817 else if ( actionName ==
"Show all" )
819 mHistoShowBands = ShowAll;
824 else if ( actionName ==
"Show selected" )
826 mHistoShowBands = ShowSelected;
831 else if ( actionName ==
"Show RGB" )
833 mHistoShowBands = ShowRGB;
838 else if ( actionName ==
"Draw lines" )
840 mHistoDrawLines = actionFlag;
842 settings.
setValue(
"/Raster/histogram/drawLines", mHistoDrawLines );
843 on_btnHistoCompute_clicked();
847 else if ( actionName ==
"Load apply all" )
849 mHistoLoadApplyAll = actionFlag;
850 settings.setValue(
"/Raster/histogram/loadApplyAll", mHistoLoadApplyAll );
856 else if ( actionName.
left( 5 ) ==
"Load " && mRendererWidget )
862 double minMaxValues[2];
865 if ( mHistoLoadApplyAll )
867 int myBandCountInt = mRasterLayer->
bandCount();
868 for (
int i = 1; i <= myBandCountInt; i++ )
870 if ( i != cboHistoBand->currentIndex() + 1 )
877 myBands << cboHistoBand->currentIndex() + 1;
881 double myStdDev = 1.0;
882 if ( actionName ==
"Load stddev" )
889 leHistoMin->blockSignals(
true );
890 leHistoMax->blockSignals(
true );
893 Q_FOREACH (
int theBandNo, myBands )
897 if ( actionName ==
"Load actual" )
900 theBandNo, minMaxValues );
902 else if ( actionName ==
"Load estimate" )
905 theBandNo, minMaxValues );
907 else if ( actionName ==
"Load extent" )
910 theBandNo, minMaxValues );
912 else if ( actionName ==
"Load 1 stddev" ||
913 actionName ==
"Load stddev" )
915 ok = mRendererWidget->bandMinMaxFromStdDev( myStdDev, theBandNo, minMaxValues );
920 cboHistoBand->setCurrentIndex( theBandNo - 1 );
921 if ( !ok || actionName ==
"Load reset" )
943 leHistoMin->blockSignals(
false );
944 leHistoMax->blockSignals(
false );
945 updateHistoMarkers();
947 else if ( actionName ==
"Compute histogram" )
949 on_btnHistoCompute_clicked();
958 void QgsRasterHistogramWidget::applyHistoMin()
960 if ( ! mRendererWidget )
963 int theBandNo = cboHistoBand->currentIndex() + 1;
966 for (
int i = 0; i <= mySelectedBands.
size(); i++ )
970 min = leHistoMin->text();
971 if ( mHistoUpdateStyleToMinMax )
972 mRendererWidget->
setMin( min, i );
976 updateHistoMarkers();
978 if ( ! min.
isEmpty() && mHistoZoomToMinMax && mHistoZoomer )
982 mHistoZoomer->zoom( rect );
987 void QgsRasterHistogramWidget::applyHistoMax()
989 if ( ! mRendererWidget )
992 int theBandNo = cboHistoBand->currentIndex() + 1;
995 for (
int i = 0; i <= mySelectedBands.
size(); i++ )
999 max = leHistoMax->text();
1000 if ( mHistoUpdateStyleToMinMax )
1001 mRendererWidget->
setMax( max, i );
1005 updateHistoMarkers();
1007 if ( ! max.
isEmpty() && mHistoZoomToMinMax && mHistoZoomer )
1011 mHistoZoomer->zoom( rect );
1015 void QgsRasterHistogramWidget::on_btnHistoMin_toggled()
1017 if ( mpPlot && mHistoPicker )
1021 if ( btnHistoMin->isChecked() )
1023 btnHistoMax->setChecked(
false );
1027 mHistoZoomer->setEnabled( ! btnHistoMin->isChecked() );
1028 mHistoPicker->setEnabled( btnHistoMin->isChecked() );
1030 updateHistoMarkers();
1033 void QgsRasterHistogramWidget::on_btnHistoMax_toggled()
1035 if ( mpPlot && mHistoPicker )
1039 if ( btnHistoMax->isChecked() )
1041 btnHistoMin->setChecked(
false );
1045 mHistoZoomer->setEnabled( ! btnHistoMax->isChecked() );
1046 mHistoPicker->setEnabled( btnHistoMax->isChecked() );
1048 updateHistoMarkers();
1055 if ( !scale )
return "";
1059 double diff = ( minorTicks[1] - minorTicks[0] ) / div;
1060 double min = majorTicks[0] - diff;
1062 min -= ( majorTicks[1] - majorTicks[0] );
1063 #if defined(QWT_VERSION) && QWT_VERSION<0x050200 1064 double max = scale->hBound();
1066 double max = scale->upperBound();
1068 double closest = target;
1069 double current =
min;
1071 while ( current < max )
1074 if ( current > target )
1076 closest = ( qAbs( target - current + diff ) < qAbs( target - current ) ) ? current - diff : current;
1085 void QgsRasterHistogramWidget::histoPickerSelected(
QPointF pos )
1087 if ( btnHistoMin->isChecked() || btnHistoMax->isChecked() )
1089 #if defined(QWT_VERSION) && QWT_VERSION>=0x060100 1090 const QwtScaleDiv * scale = &mpPlot->axisScaleDiv( QwtPlot::xBottom );
1092 const QwtScaleDiv * scale = mpPlot->axisScaleDiv( QwtPlot::xBottom );
1095 if ( btnHistoMin->isChecked() )
1099 btnHistoMin->setChecked(
false );
1105 btnHistoMax->setChecked(
false );
1112 void QgsRasterHistogramWidget::histoPickerSelectedQwt5( QwtDoublePoint pos )
1114 histoPickerSelected(
QPointF( pos.x(), pos.y() ) );
1117 void QgsRasterHistogramWidget::updateHistoMarkers()
1120 if ( leHistoMin->signalsBlocked() )
1123 if ( !mpPlot || !mHistoMarkerMin || !mHistoMarkerMax )
1126 int theBandNo = cboHistoBand->currentIndex() + 1;
1129 if (( ! mHistoShowMarkers && ! btnHistoMin->isChecked() && ! btnHistoMax->isChecked() ) ||
1130 ( ! mySelectedBands.
isEmpty() && ! mySelectedBands.
contains( theBandNo ) ) )
1132 mHistoMarkerMin->hide();
1133 mHistoMarkerMax->hide();
1138 double minVal = mHistoMin;
1139 double maxVal = mHistoMax;
1140 QString minStr = leHistoMin->text();
1141 QString maxStr = leHistoMax->text();
1147 QPen linePen =
QPen( mHistoColors.
at( theBandNo ) );
1149 mHistoMarkerMin->setLineStyle( QwtPlotMarker::VLine );
1150 mHistoMarkerMin->setLinePen( linePen );
1151 mHistoMarkerMin->setXValue( minVal );
1152 mHistoMarkerMin->show();
1153 mHistoMarkerMax->setLineStyle( QwtPlotMarker::VLine );
1154 mHistoMarkerMax->setLinePen( linePen );
1155 mHistoMarkerMax->setXValue( maxVal );
1156 mHistoMarkerMax->show();
1162 QList< int > QgsRasterHistogramWidget::histoSelectedBands()
1166 if ( mHistoShowBands != ShowAll )
1168 if ( mHistoShowBands == ShowSelected )
1170 mySelectedBands << cboHistoBand->currentIndex() + 1;
1172 else if ( mHistoShowBands == ShowRGB )
1174 mySelectedBands = rendererSelectedBands();
1178 return mySelectedBands;
1181 QList< int > QgsRasterHistogramWidget::rendererSelectedBands()
1185 if ( ! mRendererWidget )
1187 mySelectedBands << -1 << -1 << -1;
1188 return mySelectedBands;
1191 if ( mRendererName ==
"singlebandgray" )
1195 else if ( mRendererName ==
"multibandcolor" )
1197 for (
int i = 0; i <= 2; i++ )
1203 return mySelectedBands;
1210 if ( ! mRendererWidget )
1213 if ( mRendererName ==
"singlebandgray" )
1217 myMinMax.first = mRendererWidget->
min();
1218 myMinMax.second = mRendererWidget->
max();
1221 else if ( mRendererName ==
"multibandcolor" )
1223 for (
int i = 0; i <= 2; i++ )
1227 myMinMax.first = mRendererWidget->
min( i );
1228 myMinMax.second = mRendererWidget->
max( i );
1244 if ( myMinMax.first.isEmpty() )
1246 if ( myMinMax.second.isEmpty() )
1249 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)
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)
int bandCount() const
Get the number of bands in this layer.
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()