diff --git a/src/ossimGui/HistogramRemapperEditor.cpp b/src/ossimGui/HistogramRemapperEditor.cpp index 48a1268..9999c3b 100644 --- a/src/ossimGui/HistogramRemapperEditor.cpp +++ b/src/ossimGui/HistogramRemapperEditor.cpp @@ -186,32 +186,65 @@ void ossimGui::HistogramRemapperEditor::initializeUiValues() void ossimGui::HistogramRemapperEditor::populateClipPoints() { - QString currentText = m_bandComboBox->currentText(); - bool masterFlag = currentText=="master"; - double value =0.0; if(m_histogramRemapper.valid()) { - value = masterFlag?m_histogramRemapper->getLowNormalizedClipPoint():m_histogramRemapper->getLowNormalizedClipPoint(currentText.toLong()); - m_lowClipPercentLineEdit->setText(QString().setNum(value, 'g', 8)); - value = masterFlag?m_histogramRemapper->getHighNormalizedClipPoint():m_histogramRemapper->getHighNormalizedClipPoint(currentText.toLong()); - m_highClipPercentLineEdit->setText(QString().setNum(value, 'g', 8)); + QString currentText = m_bandComboBox->currentText(); + bool masterFlag = currentText=="master"; + double value =0.0; + std::ostringstream os; + + os.precision(2); + os.setf( std::ios::fixed, std:: ios::floatfield ); + + value = masterFlag?m_histogramRemapper->getLowNormalizedClipPoint(): + m_histogramRemapper->getLowNormalizedClipPoint(currentText.toLong()); + value *= 100.0; + os << value; + + m_lowClipPercentLineEdit->setText( QString( os.str().c_str() ) ); + + value = masterFlag?m_histogramRemapper->getHighNormalizedClipPoint(): + m_histogramRemapper->getHighNormalizedClipPoint(currentText.toLong()); + value = (1.0 - value) * 100.0; + os.str( std::string("") ); + os << value; + m_highClipPercentLineEdit->setText( QString( os.str().c_str() ) ); + + if ( ossim::isInteger( m_histogramRemapper->getOutputScalarType() ) ) + { + os.precision(0); + } - value = masterFlag?m_histogramRemapper->getLowClipPoint():m_histogramRemapper->getLowClipPoint(currentText.toLong()); - m_lowClipValueLineEdit->setText(QString().setNum(value, 'g', 8)); - value = masterFlag?m_histogramRemapper->getHighClipPoint():m_histogramRemapper->getHighClipPoint(currentText.toLong()); - m_highClipValueLineEdit->setText(QString().setNum(value, 'g', 8)); + value = masterFlag?m_histogramRemapper->getLowClipPoint(): + m_histogramRemapper->getLowClipPoint(currentText.toLong()); + os.str( std::string("") ); + os << value; + m_lowClipValueLineEdit->setText( QString( os.str().c_str() ) ); - value = masterFlag?m_histogramRemapper->getMidPoint():m_histogramRemapper->getMidPoint(currentText.toLong()); - m_midPointLineEdit->setText(QString().setNum(value, 'g', 8)); + value = masterFlag?m_histogramRemapper->getHighClipPoint(): + m_histogramRemapper->getHighClipPoint(currentText.toLong()); + os.str( std::string("") ); + os << value; + m_highClipValueLineEdit->setText(QString( os.str().c_str() ) ); - value = masterFlag?m_histogramRemapper->getMinOutputValue():m_histogramRemapper->getMinOutputValue(currentText.toLong()); - m_outputMinValue->setText(QString().setNum(value, 'g', 8)); - value = masterFlag?m_histogramRemapper->getMaxOutputValue():m_histogramRemapper->getMaxOutputValue(currentText.toLong()); - m_outputMaxValue->setText(QString().setNum(value, 'g', 8)); + value = masterFlag?m_histogramRemapper->getMinOutputValue(): + m_histogramRemapper->getMinOutputValue(currentText.toLong()); + os.str( std::string("") ); + os << value; + m_outputMinValue->setText(QString( os.str().c_str() ) ); + + value = masterFlag?m_histogramRemapper->getMaxOutputValue(): + m_histogramRemapper->getMaxOutputValue(currentText.toLong()); + os.str( std::string("") ); + os << value; + m_outputMaxValue->setText( QString( os.str().c_str() ) ); m_histogramWidget->blockSignals(true); - m_histogramWidget->setPenetration(masterFlag?m_histogramRemapper->getLowNormalizedClipPoint():m_histogramRemapper->getLowNormalizedClipPoint(currentText.toLong()), - 1.0-(masterFlag?m_histogramRemapper->getHighNormalizedClipPoint():m_histogramRemapper->getHighNormalizedClipPoint(currentText.toLong())) + m_histogramWidget->setPenetration( + masterFlag?m_histogramRemapper->getLowNormalizedClipPoint(): + m_histogramRemapper->getLowNormalizedClipPoint(currentText.toLong()), + 1.0-(masterFlag?m_histogramRemapper->getHighNormalizedClipPoint(): + m_histogramRemapper->getHighNormalizedClipPoint(currentText.toLong())) ); m_histogramWidget->blockSignals(false); } @@ -237,20 +270,21 @@ void ossimGui::HistogramRemapperEditor::bandActivated ( int index ) void ossimGui::HistogramRemapperEditor::stretchModeActivated(int index) { - if(!m_histogramRemapper.valid()) return; - - m_histogramRemapper->setStretchModeAsString(stretchModes[index], true); - if(stretchModes[index] == ossimString("linear_one_piece")) + if( m_histogramRemapper.valid() ) { - m_histogramWidget->setReadOnly(false); - } - else - { - m_histogramWidget->setReadOnly(true); + // "true" arg to rebuild table on mode change. + m_histogramRemapper->setStretchModeAsString(stretchModes[index], true); + if(stretchModes[index] == ossimString("linear_one_piece")) + { + m_histogramWidget->setReadOnly(false); + } + else + { + m_histogramWidget->setReadOnly(true); + } + populateClipPoints(); + fireRefreshEvent(); } - - populateClipPoints(); - fireRefreshEvent(); } void ossimGui::HistogramRemapperEditor::openHistogramButton(bool) @@ -291,12 +325,15 @@ void ossimGui::HistogramRemapperEditor::calculateAverageHistogram() h.resize(nBands); if(!h.size()) return; - bool validDrawFlag = true; + //bool validDrawFlag = true; for(band = 0; band < nBands; ++ band) { h[band] = m_multiResHistogram->getHistogram(band); } - + + // Assuming all bands have the same scalar and null value. + ossimScalarType scalar = h[0]->getScalarType(); + float nullValue = h[0]->getNullValue(); float minValue = 99999.0; float maxValue = -99999.0; float max_count = 0.0; @@ -317,13 +354,15 @@ void ossimGui::HistogramRemapperEditor::calculateAverageHistogram() max_count += hmax_count; } } - m_averageHistogram = new ossimHistogram(maxBins, minValue, maxValue); + + m_averageHistogram = new ossimHistogram( + maxBins, minValue, maxValue, nullValue, scalar); ossim_uint32 binIdx = 0; float delta = (maxValue-minValue)/maxBins; - float* sumCounts = m_averageHistogram->GetCounts(); + ossim_int64* sumCounts = m_averageHistogram->GetCounts(); ossim_int32 sumIndex = 0; float value = 0.0; - memset(sumCounts, '\0', sizeof(float)*maxBins); + memset(sumCounts, '\0', sizeof(ossim_int64)*maxBins); value = minValue+delta*0.5; for(binIdx = 0; binIdx < maxBins;++binIdx) { diff --git a/src/ossimGui/HistogramWidget.cpp b/src/ossimGui/HistogramWidget.cpp index b34d851..a7ab29c 100644 --- a/src/ossimGui/HistogramWidget.cpp +++ b/src/ossimGui/HistogramWidget.cpp @@ -126,13 +126,14 @@ void ossimGui::HistogramWidget::updateScaledHistogram() if(m_histogram.valid()) { ossim_uint32 w = width(); - ossim_uint32 h = height(); float minValue = m_histogram->GetRangeMin();//floor(m_histogram->GetMinVal()); float maxValue = m_histogram->GetRangeMax();//ceil(m_histogram->GetMaxVal()); + float nullValue = m_histogram->getNullValue(); float maxBins = m_histogram->GetRes(); - m_scaledHistogram = new ossimHistogram(w, minValue, maxValue); - float* counts = m_histogram->GetCounts(); - float* sumCounts = m_scaledHistogram->GetCounts(); + m_scaledHistogram = new ossimHistogram( + w, minValue, maxValue, nullValue, m_histogram->getScalarType()); + ossim_int64* counts = m_histogram->GetCounts(); + ossim_int64* sumCounts = m_scaledHistogram->GetCounts(); ossim_uint32 binIdx = 0; float delta = (maxValue - minValue)/maxBins; ossim_int32 sumIndex = 0; @@ -201,7 +202,7 @@ void ossimGui::HistogramWidget::paintEvent(QPaintEvent* /* event */) if (m_scaledHistogram.valid()) { // p.drawRect(QRect(0,0,width()-1,H-1)); - float* sumCounts = m_scaledHistogram->GetCounts(); + ossim_int64* sumCounts = m_scaledHistogram->GetCounts(); ossim_int32 col; ossim_int32 res = m_scaledHistogram->GetRes(); @@ -219,7 +220,6 @@ void ossimGui::HistogramWidget::paintEvent(QPaintEvent* /* event */) alphaBrush.setColor(QColor(255,255,255,128)); alphaBrush.setStyle(Qt::SolidPattern); painter->setBrush(alphaBrush); - QSize thisSize = size(); double clipW = fabs(clipMaxxValue-clipMinxValue); painter->drawRect(QRect(clipMinxValue,0,clipW,H)); painter->restore(); diff --git a/src/ossimGui/ui/HistogramRemapperEditor.ui b/src/ossimGui/ui/HistogramRemapperEditor.ui index 98e5c76..8b2c68d 100644 --- a/src/ossimGui/ui/HistogramRemapperEditor.ui +++ b/src/ossimGui/ui/HistogramRemapperEditor.ui @@ -265,62 +265,7 @@ - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 20 - - - - - - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 32767 - - - - true - - - - - - - mid point - - - false - - - - + Qt::Horizontal