Skip to content

Commit

Permalink
Merge pull request #8 from ossimlabs/drb-histogram-mod-20190212
Browse files Browse the repository at this point in the history
Fixed build errors post mods in core. Fixed histogram widget not disp…
  • Loading branch information
gpotts authored Mar 11, 2019
2 parents 1d8ee42 + 8ac9295 commit f7bb989
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 98 deletions.
111 changes: 75 additions & 36 deletions src/ossimGui/HistogramRemapperEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
12 changes: 6 additions & 6 deletions src/ossimGui/HistogramWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -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();
Expand Down
57 changes: 1 addition & 56 deletions src/ossimGui/ui/HistogramRemapperEditor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -265,62 +265,7 @@
</property>
</widget>
</item>
<item>
<spacer name="spacer14_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLineEdit" name="m_midPointLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>32767</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_midPointLineEditLabel">
<property name="text">
<string>mid point</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<item>
<spacer name="spacer15_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down

0 comments on commit f7bb989

Please sign in to comment.