Commit 03028bba authored by allens's avatar allens

Histogram edit for CQ

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@15843 18c085ea-50e0-402c-830e-de6fd14e8384
parent fbdbfe37
......@@ -1903,15 +1903,15 @@ avtH5PartFileFormat::ConstructHistogram(avtHistogramSpecification *spec)
EXCEPTION1(ImproperUseException, "NULL Histogram Specification");
// Compute the hisogram
int timestep = spec->GetTimestep();
bool regularBinning = spec->IsRegularBinning();
int timestep = spec->GetTimestep();
bool regularBinning = spec->IsRegularBinning();
std::vector<std::string> variables = spec->GetVariables();
std::vector<int> numBins = spec->GetNumberOfBins();
bool boundsSpecified = spec->BoundsSpecified();
std::string condition(spec->GetCondition());
std::vector<int> numBins = spec->GetNumberOfBins();
bool boundsSpecified = spec->BoundsSpecified();
std::string condition = spec->GetCondition();
int boundsSize = spec->GetBounds().size();
VISIT_LONG_LONG * counts = spec->GetCounts();
int boundsSize = spec->GetBounds().size();
VISIT_LONG_LONG * counts = spec->GetCounts();
#ifdef VERYVERBOSE
std::cout << "Constructing histogram for time step " << timestep << std::endl;
......
......@@ -856,18 +856,73 @@ CQFilter::SelectAndHistogram(const int *allDomains, const int *allCellIds,
// We need to bin the index array into some number of bins and select
// the cells in the selected bins into our new narrowed selection.
int *binPoints = new int[props.GetHistogramNumBins() + 1];
for(int i = 0; i < props.GetHistogramNumBins()+1; ++i)
int *binPoints, numBins;
// For IDs the bins are based on the number of cells
if(props.GetHistogramType() == SelectionProperties::HistogramID)
{
float t = float(i) / float(props.GetHistogramNumBins());
numBins = props.GetHistogramNumBins();
binPoints = new int[numBins + 1];
for(int i = 0; i < numBins+1; ++i)
{
float t = float(i) / float(numBins);
binPoints[i] = int(t * float(totalCells));
}
}
else if(props.GetHistogramType() == SelectionProperties::HistogramMatches ||
props.GetHistogramType() == SelectionProperties::HistogramVariable)
{
double min, max;
if(props.GetHistogramType() == SelectionProperties::HistogramMatches)
{
min = allFrequencies[index[0]];
max = allFrequencies[index[totalCells-1]];
numBins = max-min+1;
binPoints = new int[numBins + 1];
}
else if( props.GetHistogramType() == SelectionProperties::HistogramVariable)
{
numBins = props.GetHistogramNumBins();
binPoints = new int[numBins + 1];
min = allVariables[index[0]];
max = allVariables[index[totalCells-1]];
}
// The starting binPoints will always be the first cell.
binPoints[0] = 0;
int j = 0;
for(int i = 1; i < numBins; ++i)
{
// Get the threshold for this bin. The threshold is based on
// the frequency of matches.
float t = min + float(i) * (max-min) / float(numBins);
if(props.GetHistogramType() == SelectionProperties::HistogramMatches)
while( allFrequencies[index[j]] < t )
++j;
else if(props.GetHistogramType() == SelectionProperties::HistogramVariable)
while( allVariables[index[j]] < t )
++j;
binPoints[i] = j;
}
// The ending binPoints will always be the totalCells.
binPoints[numBins] = totalCells;
}
debug5 << "numBins=" << props.GetHistogramNumBins()
debug5 << "numBins=" << numBins
<< ", startBin=" << props.GetHistogramStartBin()
<< ", endBin=" << props.GetHistogramEndBin() << endl;
for(int bin = 0; bin < props.GetHistogramNumBins(); ++bin)
for(int bin = 0; bin < numBins; ++bin)
{
// If the bin is one that we're selecting then add its cells to the
// narrowed selection.
......@@ -898,13 +953,22 @@ CQFilter::SelectAndHistogram(const int *allDomains, const int *allCellIds,
}
}
if(props.GetHistogramType() == SelectionProperties::HistogramID)
{
// Compute an average for the bin.
double sum = 0.;
for(int i = binPoints[bin]; i < binPoints[bin+1]; ++i)
double sum = 0.;
for(int i = binPoints[bin]; i < binPoints[bin+1]; ++i)
sum += allFrequencies[index[i]];
double averageForBin = sum / double(binPoints[bin+1] - binPoints[bin]);
histogram.push_back(averageForBin);
debug5 << "Bin " << bin << " average frequency: " << averageForBin << endl;
double averageForBin;
if( binPoints[bin+1] > binPoints[bin] )
averageForBin = sum / double(binPoints[bin+1] - binPoints[bin]);
else
averageForBin = 0;
histogram.push_back(averageForBin);
debug5 << "Bin " << bin << " average frequency: " << averageForBin << endl;
}
else
histogram.push_back(binPoints[bin+1] - binPoints[bin]);
}
delete [] binPoints;
......@@ -1025,7 +1089,9 @@ CQFilter::ExecuteAllTimesteps(std::vector<avtDataTree_p> &timesteps)
narrowedSelection = selection;
for(size_t i = 0; i < timesteps.size(); ++i)
hist.push_back(double(cellsPerTimestep[i]));
{
hist.push_back(double(cellsPerTimestep[i]));
}
}
else
{
......@@ -1322,4 +1388,3 @@ CumulativeQueryNamedSelectionExtension::GetSelectionSummary() const
{
return summary;
}
......@@ -478,8 +478,8 @@ QvisSelectionsWindow::CreateCQHistogramControls(QWidget *parent)
cqHistogramType->addButton(id,2);
cqHistogramType->addButton(cqHistogramVariableButton,3);
aLayout->addWidget(timeSlice, 0, 1);
aLayout->addWidget(id, 0, 2);
aLayout->addWidget(matches, 1, 1);
aLayout->addWidget(id, 1, 1);
aLayout->addWidget(matches, 0, 2);
aLayout->addWidget(cqHistogramVariableButton, 1, 2);
cqHistogramVariable = new QComboBox(axisGroup);
......@@ -490,6 +490,7 @@ QvisSelectionsWindow::CreateCQHistogramControls(QWidget *parent)
cqHistogramNumBinsLabel = new QLabel(tr("Number of bins"), axisGroup);
aLayout->addWidget(cqHistogramNumBinsLabel, 2, 0);
cqHistogramNumBins = new QSpinBox(axisGroup);
cqHistogramNumBins->setRange(1,1024);
connect(cqHistogramNumBins, SIGNAL(valueChanged(int)),
this, SLOT(histogramNumBinsChanged(int)));
aLayout->addWidget(cqHistogramNumBins, 2, 1);
......@@ -512,6 +513,7 @@ QvisSelectionsWindow::CreateCQHistogramControls(QWidget *parent)
cqHistogramMinLabel = new QLabel(tr("Minimum bin"), summationGroup);
cqHistogramMin = new QSpinBox(summationGroup);
cqHistogramMin->setRange(0,1023);
connect(cqHistogramMin, SIGNAL(valueChanged(int)),
this, SLOT(histogramStartChanged(int)));
sLayout->addWidget(cqHistogramMinLabel, 1, 0);
......@@ -519,6 +521,7 @@ QvisSelectionsWindow::CreateCQHistogramControls(QWidget *parent)
cqHistogramMaxLabel = new QLabel(tr("Maximum bin"), summationGroup);
cqHistogramMax = new QSpinBox(summationGroup);
cqHistogramMax->setRange(0,1023);
connect(cqHistogramMax, SIGNAL(valueChanged(int)),
this, SLOT(histogramEndChanged(int)));
sLayout->addWidget(cqHistogramMaxLabel, 1, 2);
......@@ -810,6 +813,17 @@ QvisSelectionsWindow::UpdateHistogram(const double *values, int nvalues,
delete [] normalized;
delete [] mask;
if( nvalues != selectionProps.GetHistogramNumBins() )
{
selectionProps.SetHistogramNumBins(nvalues);
selectionProps.SetHistogramStartBin(0);
selectionProps.SetHistogramEndBin(nvalues-1);
Apply();
UpdateMinMaxBins(true, true, true);
}
}
}
......@@ -841,9 +855,9 @@ QvisSelectionsWindow::UpdateHistogram()
else
{
UpdateHistogram(&hist[0], hist.size(),
selectionProps.GetHistogramStartBin(),
selectionProps.GetHistogramEndBin(),
selectionProps.GetHistogramType() != SelectionProperties::HistogramTime);
selectionProps.GetHistogramStartBin(),
selectionProps.GetHistogramEndBin(), true );
// selectionProps.GetHistogramType() != SelectionProperties::HistogramTime);
}
}
else
......@@ -905,7 +919,7 @@ void
QvisSelectionsWindow::UpdateMinMaxBins(bool updateMin, bool updateMax,
bool updateValues)
{
bool notTime = selectionProps.GetHistogramType() != SelectionProperties::HistogramTime;
// bool notTime = selectionProps.GetHistogramType() != SelectionProperties::HistogramTime;
// Set the min value and extents.
int hMin = 0, hMax = 100000;
......@@ -914,20 +928,20 @@ QvisSelectionsWindow::UpdateMinMaxBins(bool updateMin, bool updateMax,
int val = selectionProps.GetHistogramStartBin();
if(val < 0)
val = 0;
if(notTime)
// if(notTime)
{
hMin = 0;
hMax = qMin(selectionProps.GetHistogramEndBin(),
selectionProps.GetHistogramNumBins()-1);
}
cqHistogramMin->blockSignals(true);
cqHistogramMin->setMinimum(hMin);
cqHistogramMin->setMaximum(hMax);
cqHistogramMin->setRange(hMin, hMax);
if(updateValues)
cqHistogramMin->setValue(val);
cqHistogramMin->blockSignals(false);
cqHistogramMin->setEnabled(notTime);
cqHistogramMinLabel->setEnabled(notTime);
// cqHistogramMin->setEnabled(notTime);
// cqHistogramMinLabel->setEnabled(notTime);
}
if(updateMax)
......@@ -936,19 +950,19 @@ QvisSelectionsWindow::UpdateMinMaxBins(bool updateMin, bool updateMax,
int val = selectionProps.GetHistogramEndBin();
if(val >= selectionProps.GetHistogramNumBins()-1)
val = selectionProps.GetHistogramNumBins()-1;
if(notTime)
// if(notTime)
{
hMin = qMax(selectionProps.GetHistogramStartBin(), 0);
hMax = selectionProps.GetHistogramNumBins()-1;
}
cqHistogramMax->blockSignals(true);
cqHistogramMax->setMinimum(hMin);
cqHistogramMax->setMaximum(hMax);
cqHistogramMax->setRange(hMin, hMax);
if(updateValues)
cqHistogramMax->setValue(val);
cqHistogramMax->blockSignals(false);
cqHistogramMax->setEnabled(notTime);
cqHistogramMaxLabel->setEnabled(notTime);
// cqHistogramMax->setEnabled(notTime);
// cqHistogramMaxLabel->setEnabled(notTime);
}
}
......@@ -1122,9 +1136,11 @@ QvisSelectionsWindow::UpdateSelectionProperties()
cqHistogramNumBins->blockSignals(true);
cqHistogramNumBins->setValue(selectionProps.GetHistogramNumBins());
cqHistogramNumBins->blockSignals(false);
bool notTime = selectionProps.GetHistogramType() != SelectionProperties::HistogramTime;
cqHistogramNumBins->setEnabled(notTime);
cqHistogramNumBinsLabel->setEnabled(notTime);
bool setBins =
selectionProps.GetHistogramType() == SelectionProperties::HistogramID ||
selectionProps.GetHistogramType() == SelectionProperties::HistogramVariable;
cqHistogramNumBins->setEnabled(setBins);
cqHistogramNumBinsLabel->setEnabled(setBins);
UpdateMinMaxBins(true, true, true);
......@@ -1823,9 +1839,11 @@ QvisSelectionsWindow::histogramTypeChanged(int value)
cqHistogramVariableButton->setEnabled(!selectionProps.GetVariables().empty());
cqHistogramVariable->setEnabled(!selectionProps.GetVariables().empty() &&
selectionProps.GetHistogramType() == SelectionProperties::HistogramVariable);
bool notTime = selectionProps.GetHistogramType() != SelectionProperties::HistogramTime;
cqHistogramNumBins->setEnabled(notTime);
cqHistogramNumBinsLabel->setEnabled(notTime);
bool setBins =
selectionProps.GetHistogramType() == SelectionProperties::HistogramID ||
selectionProps.GetHistogramType() == SelectionProperties::HistogramVariable;
cqHistogramNumBins->setEnabled(setBins);
cqHistogramNumBinsLabel->setEnabled(setBins);
UpdateMinMaxBins(true, true, true);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment